Get returns one page of a document plus explicit pagination guidance.
(source, kb string, offset int)
| 73 | |
| 74 | // Get returns one page of a document plus explicit pagination guidance. |
| 75 | func (a *knowledgePluginAdapter) Get(source, kb string, offset int) (string, error) { |
| 76 | mgr := a.manager() |
| 77 | if mgr == nil { |
| 78 | return "", fmt.Errorf("context manager unavailable in this session") |
| 79 | } |
| 80 | page, total, next, err := mgr.KnowledgeDocument(a.sessionID(), kb, source, offset) |
| 81 | if err != nil { |
| 82 | return "", err |
| 83 | } |
| 84 | var b strings.Builder |
| 85 | fmt.Fprintf(&b, "📄 %s (chars %d-%d of %d)\n\n", source, offset, offset+len(page), total) |
| 86 | b.WriteString(page) |
| 87 | if next > 0 { |
| 88 | fmt.Fprintf(&b, "\n\n[document continues — call get again with {\"source\":%q,\"offset\":%d}]", source, next) |
| 89 | } |
| 90 | return b.String(), nil |
| 91 | } |
| 92 | |
| 93 | // TOC lists document paths, optionally narrowed by prefix. |
| 94 | func (a *knowledgePluginAdapter) TOC(kb, prefix string) (string, error) { |