@agentproto/adapter-knowledge-gbrain-doc 0.2.8 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +3 -1
- package/dist/index.mjs +27 -0
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
|
-
import { KnowledgeCapabilities, IKnowledgeProvider, KnowledgeIngestInput, KnowledgeSource, KnowledgeQuery, KnowledgeQueryResult, ListSourcesFilter } from '@agentproto/knowledge-engine';
|
|
2
|
+
import { KnowledgeCapabilities, IKnowledgeProvider, KnowledgeIngestInput, KnowledgeSource, KnowledgeQuery, KnowledgeQueryResult, ListSourcesFilter, KnowledgeProvenance } from '@agentproto/knowledge-engine';
|
|
3
3
|
import { AdapterCatalog, AdapterHandle, AdapterResolver } from '@agentproto/provider-kit';
|
|
4
4
|
|
|
5
5
|
/**
|
|
@@ -73,6 +73,8 @@ declare class GbrainDocKnowledgeAdapter implements IKnowledgeProvider {
|
|
|
73
73
|
listSources(filter?: ListSourcesFilter): Promise<readonly KnowledgeSource[]>;
|
|
74
74
|
getSource(id: string): Promise<KnowledgeSource | null>;
|
|
75
75
|
deleteSource(id: string): Promise<void>;
|
|
76
|
+
supersede(_id: string, _by?: string): Promise<void>;
|
|
77
|
+
explain(id: string): Promise<KnowledgeProvenance | null>;
|
|
76
78
|
healthCheck(): Promise<boolean>;
|
|
77
79
|
dispose(): Promise<void>;
|
|
78
80
|
private authHeaders;
|
package/dist/index.mjs
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
|
+
import { KnowledgeNotSupportedError } from '@agentproto/knowledge-engine';
|
|
2
3
|
import { makeAdapterResolver } from '@agentproto/provider-kit';
|
|
3
4
|
|
|
4
5
|
/**
|
|
@@ -175,6 +176,32 @@ var GbrainDocKnowledgeAdapter = class {
|
|
|
175
176
|
throw err;
|
|
176
177
|
}
|
|
177
178
|
}
|
|
179
|
+
async supersede(_id, _by) {
|
|
180
|
+
throw new KnowledgeNotSupportedError(
|
|
181
|
+
this.id,
|
|
182
|
+
"supersede",
|
|
183
|
+
"gbrain's page API has no supersede/status verb (only put_page/delete_page)"
|
|
184
|
+
);
|
|
185
|
+
}
|
|
186
|
+
async explain(id) {
|
|
187
|
+
try {
|
|
188
|
+
const result = await this.callTool("get_page", { slug: id });
|
|
189
|
+
const page = pageSchema.parse(parseToolJson(result));
|
|
190
|
+
return {
|
|
191
|
+
sourceId: page.slug,
|
|
192
|
+
derivedFrom: page.source_uri ? [page.source_uri] : [],
|
|
193
|
+
metadata: {
|
|
194
|
+
type: page.type ?? "note",
|
|
195
|
+
...page.source_uri ? { sourceUri: page.source_uri } : {},
|
|
196
|
+
...page.created_at ? { createdAt: page.created_at } : {},
|
|
197
|
+
...page.updated_at ? { updatedAt: page.updated_at } : {}
|
|
198
|
+
}
|
|
199
|
+
};
|
|
200
|
+
} catch (err) {
|
|
201
|
+
if (isNotFound(err)) return null;
|
|
202
|
+
throw err;
|
|
203
|
+
}
|
|
204
|
+
}
|
|
178
205
|
async healthCheck() {
|
|
179
206
|
try {
|
|
180
207
|
const res = await fetch(`${this.endpoint}/health`, {
|
package/dist/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/adapter.ts","../src/env.ts","../src/standalone.ts","../src/catalog.ts","../src/handle.ts"],"names":[],"mappings":";;;;;;;;;AA4DO,IAAM,oBAAA,GAAuB;AA6B7B,IAAM,4BAAA,GAA+B,EAAE,MAAA,CAAO;AAAA;AAAA;AAAA,EAGnD,QAAA,EAAU,CAAA,CAAE,MAAA,EAAO,CAAE,GAAA,EAAI;AAAA;AAAA;AAAA,EAGzB,WAAA,EAAa,CAAA,CAAE,MAAA,EAAO,CAAE,IAAI,CAAC,CAAA;AAAA;AAAA,EAE7B,SAAA,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QACL,IAAA;AAAA,QACA,MAAM,YAAA,CAAa,IAAA;AAAA,QACnB,aAAa,YAAA,CAAa,WAAA;AAAA,QAC1B,OAAA,EAAS,OAAA;AAAA,QACT,aAAA,EAAe,IAAA;AAAA,QACf,YAAA,EAAc,IAAA;AAAA;AAAA;AAAA;AAAA,QAId,OAAO,YAAY;AACjB,UAAA,IAAI;AACF,YAAA,OAAO,MAAM,gCAAA,EAAiC,CAAE,WAAA,EAAY;AAAA,UAC9D,CAAA,CAAA,MAAQ;AACN,YAAA,OAAO,KAAA;AAAA,UACT;AAAA,QACF,CAAA;AAAA,QACA,IAAA,GAAO;AACL,UAAA,OAAO;AAAA,YACL,IAAA;AAAA,YACA,MAAA,EAAQ,YAAA;AAAA,YACR,YAAA,EAAc,EAAE,YAAA,EAAc,IAAA,EAAM,YAAY,IAAA;AAAK,WACvD;AAAA,QACF,CAAA;AAAA,QACA,QAAA,EAAU,MAAM,gCAAA;AAAiC,OACnD;AAAA,IACF;AAAA;AAGF,EAAA,MAAM,IAAI,KAAA,CAAM,CAAA,kCAAA,EAAqC,IAAI,CAAA,CAAE,CAAA;AAC7D;AAMO,SAAS,8BAAA,GAAmE;AACjF,EAAA,OAAO,mBAAA,CAAqC;AAAA,IAC1C,IAAA,EAAM,OAAO,IAAA,KACX,uBAAA,CAAwB,IAAI;AAAA,GAC/B,CAAA;AACH","file":"index.mjs","sourcesContent":["/**\n * GbrainDocKnowledgeAdapter — the `IKnowledgeProvider` over gbrain's DOCUMENT\n * API.\n *\n * Connects the `@agentproto/knowledge-engine` `IKnowledgeProvider` contract to a\n * gbrain server's document surface, reached over its JSON-RPC MCP endpoint\n * (`POST /mcp`, bearer-authenticated) via pure `fetch` — no vendor SDK. The two\n * load-bearing tools are `put_page` (ingest) and `search` (query); the\n * lifecycle verbs (`list_pages` / `get_page` / `delete_page`) round out the\n * contract. Lets a host plug \"my own gbrain\" as a first-class knowledge engine\n * alongside the files / corpus / qdrant backends.\n *\n * DISTINCT from `@agentproto/adapter-code-brain-gbrain`: that adapter is the\n * CODE-GRAPH one (`ICodeBrainProvider`: define / callers / callees). THIS one is\n * the KNOWLEDGE-DOC one (`IKnowledgeProvider` over gbrain's document store).\n * Same backend, different contract — they never share a package edge; gbrain is\n * reached only at runtime over HTTP.\n *\n * Lifted from the studio integration package\n * (`packages/integration/knowledge/src/providers/gbrain-knowledge.adapter.ts`).\n * Changes on the lift:\n * 1. The contract + data types now come from `@agentproto/knowledge-engine`\n * (was the studio `../base-knowledge.provider` / `../../types`).\n * 2. The ONE cross-package edge — a type-only import of `JsonRpcRequest` /\n * `JsonRpcResponse` from the studio `core/protocol` package\n * (`gbrain-knowledge.adapter.ts:23`) — is replaced by the two inline\n * interfaces below. No studio dependency survives.\n * 3. The wire shapes are typed against the LIVE gbrain doc API (probed at\n * build time), which drifts from the studio original:\n * - `put_page` args are `{ slug, content }` (studio sent a `source`\n * field; gbrain's real field is the server-stamped `source_uri`).\n * - `search` args are `{ query, limit, offset }` (studio sent a\n * `min_score` gbrain doesn't accept — `minScore` is applied\n * client-side here instead).\n * - a `search` hit carries `chunk_text` / `score` / `chunk_index`\n * (studio expected `snippet` / `rerank_score`).\n * Every response is zod-parsed — nothing untyped reaches a call site.\n *\n * Scope of this adapter:\n * - `ingest({ kind, uri, title?, content })` — `put_page` a markdown doc\n * - `query({ query, topK, minScore })` — `search` (gbrain fuses lexical +\n * semantic recall, so `modeUsed` is stamped `\"hybrid\"`)\n * - `listSources()` / `getSource(id)` / `deleteSource(id)` — via\n * `list_pages` / `get_page` / `delete_page`\n * - `healthCheck()` — `GET /health` returns OK\n */\n\nimport { z } from \"zod\"\nimport type {\n IKnowledgeProvider,\n KnowledgeCapabilities,\n KnowledgeHit,\n KnowledgeIngestInput,\n KnowledgeQuery,\n KnowledgeQueryResult,\n KnowledgeSource,\n KnowledgeSourceKind,\n ListSourcesFilter,\n} from \"@agentproto/knowledge-engine\"\n\nexport const GBRAIN_DOC_ENGINE_ID = \"gbrain-doc\" as const\n\n// ── Inline JSON-RPC 2.0 wire types ──────────────────────────────────\n//\n// Replaces the studio adapter's ONE cross-package edge: a type-only import of\n// `JsonRpcRequest` / `JsonRpcResponse` from the studio `core/protocol` package.\n// gbrain speaks JSON-RPC 2.0 over `POST /mcp`; these two frames are all we send\n// and receive, so they inline here with zero new dependency. The response is\n// additionally zod-validated on the wire ({@link mcpEnvelopeSchema}) so nothing\n// untyped reaches a call site.\n\n/** A JSON-RPC 2.0 request frame — the body we POST to gbrain's `/mcp`. */\ninterface JsonRpcRequest<TParams = unknown> {\n readonly jsonrpc: \"2.0\"\n readonly id: number\n readonly method: string\n readonly params?: TParams\n}\n\n/** A JSON-RPC 2.0 response frame — success carries `result`, failure `error`. */\ninterface JsonRpcResponse<TResult = unknown> {\n readonly jsonrpc?: \"2.0\"\n readonly id?: number | string | null\n readonly result?: TResult\n readonly error?: { readonly code?: number; readonly message: string }\n}\n\n// ── Config ──────────────────────────────────────────────────────────\n\nexport const GbrainDocAdapterConfigSchema = z.object({\n /** Base URL of the gbrain HTTP server (no trailing slash needed). The\n * JSON-RPC `/mcp` endpoint is appended. */\n endpoint: z.string().url(),\n /** Machine bearer token accepted by the gbrain server (`GBRAIN_BEARER_TOKEN`).\n * Required — the `/mcp` endpoint is OAuth 2.1 / bearer-protected. */\n bearerToken: z.string().min(1),\n /** Per-request timeout (ms). Default 45_000. */\n timeoutMs: z.number().int().positive().default(45_000),\n /** Optional human label for logs. */\n label: z.string().optional(),\n})\n\nexport type GbrainDocAdapterConfig = z.infer<typeof GbrainDocAdapterConfigSchema>\n\nexport function parseGbrainDocAdapterConfig(\n raw: Readonly<Record<string, unknown>>,\n): GbrainDocAdapterConfig {\n return GbrainDocAdapterConfigSchema.parse(raw)\n}\n\n// ── Capabilities ────────────────────────────────────────────────────\n\nexport const GBRAIN_DOC_CAPABILITIES: KnowledgeCapabilities = Object.freeze({\n // gbrain `search` fuses lexical (tsvector) + semantic recall, so both the\n // vector + hybrid flags are honest.\n vectorSearch: true,\n hybridSearch: true,\n // This adapter drives the DOCUMENT surface (put_page / search); it does NOT\n // reach gbrain's graph traversal (`traverse_graph` / `query`).\n graphTraversal: false,\n multiModal: false,\n streaming: false,\n citations: true,\n // gbrain caps a `/mcp` request body at 1 MiB; keep a chunk comfortably inside.\n maxChunkBytes: 64 * 1024,\n})\n\n// ── Wire shapes (zod-parsed — nothing untyped reaches a call site) ───\n\n/** The MCP `tools/call` result envelope: a text block (+ optional structured\n * content) and an `isError` flag gbrain sets for e.g. page-not-found. */\nconst mcpToolResultSchema = z.object({\n content: z\n .array(z.object({ type: z.string(), text: z.string().optional() }))\n .optional(),\n structuredContent: z.unknown().optional(),\n isError: z.boolean().optional(),\n})\n\ntype McpToolResult = z.infer<typeof mcpToolResultSchema>\n\n/** The JSON-RPC envelope wrapping an MCP `tools/call` result. Mirrors the\n * inline {@link JsonRpcResponse} interface, validated on the wire. */\nconst mcpEnvelopeSchema = z.object({\n jsonrpc: z.literal(\"2.0\").optional(),\n id: z.union([z.number(), z.string(), z.null()]).optional(),\n result: mcpToolResultSchema.optional(),\n error: z\n .object({ code: z.number().optional(), message: z.string() })\n .optional(),\n})\n\n/** A single `search` hit row (gbrain doc API). Known fields are typed; the rest\n * (page_id, type, source_id, evidence, …) flow through to `metadata`. */\nconst searchHitSchema = z\n .object({\n slug: z.string(),\n chunk_text: z.string().optional(),\n chunk_index: z.number().optional(),\n chunk_id: z.union([z.number(), z.string()]).optional(),\n score: z.number().optional(),\n base_score: z.number().optional(),\n })\n .catchall(z.unknown())\n\n/** `search` returns a bare array of hits; some builds wrap it as `{ results }`.\n * Accept both. */\nconst searchResultSchema = z.union([\n z.array(searchHitSchema),\n z.object({ results: z.array(searchHitSchema) }),\n])\n\n/** `put_page` result — status + chunk count (+ passthrough backstop fields). */\nconst putPageResultSchema = z\n .object({\n slug: z.string().optional(),\n status: z.string().optional(),\n chunks: z.number().optional(),\n })\n .catchall(z.unknown())\n\n/** A `get_page` document envelope. */\nconst pageSchema = z\n .object({\n slug: z.string(),\n type: z.string().optional(),\n title: z.string().optional(),\n compiled_truth: z.string().optional(),\n source_uri: z.string().nullish(),\n updated_at: z.string().optional(),\n created_at: z.string().optional(),\n })\n .catchall(z.unknown())\n\n/** A `list_pages` row (slim: no body). */\nconst pageListItemSchema = z\n .object({\n slug: z.string(),\n type: z.string().optional(),\n title: z.string().optional(),\n updated_at: z.string().optional(),\n })\n .catchall(z.unknown())\n\nconst pageListSchema = z.union([\n z.array(pageListItemSchema),\n z.object({ pages: z.array(pageListItemSchema) }),\n])\n\n// ── Adapter ──────────────────────────────────────────────────────────\n\nexport class GbrainDocKnowledgeAdapter implements IKnowledgeProvider {\n readonly id = GBRAIN_DOC_ENGINE_ID\n readonly capabilities = GBRAIN_DOC_CAPABILITIES\n\n private readonly endpoint: string\n private readonly bearerToken: string\n private readonly timeoutMs: number\n private readonly label?: string\n\n private rpcCounter = 0\n\n constructor(config: GbrainDocAdapterConfig) {\n this.endpoint = config.endpoint.replace(/\\/$/, \"\")\n this.bearerToken = config.bearerToken\n this.timeoutMs = config.timeoutMs\n this.label = config.label\n }\n\n async ingest(input: KnowledgeIngestInput): Promise<KnowledgeSource> {\n const content = normalizeContent(input.content)\n if (!content.trim()) {\n throw new Error(\n `GbrainDocKnowledgeAdapter: ingest payload is empty (uri=${input.uri}); gbrain put_page requires document content.`,\n )\n }\n const slug = deriveSlug(input)\n // gbrain put_page takes { slug, content }. `source_uri` is SERVER-STAMPED\n // for remote callers (client value ignored), so we don't send it — the\n // caller's uri round-trips through the returned KnowledgeSource instead.\n const result = await this.callTool(\"put_page\", { slug, content })\n const parsed = putPageResultSchema.parse(parseToolJson(result))\n return {\n id: parsed.slug ?? slug,\n kind: input.kind,\n uri: input.uri,\n title: input.title,\n bytes: byteLength(content),\n status: \"ready\",\n indexedAt: new Date(),\n metadata: {\n ...(input.metadata ?? {}),\n gbrainStatus: parsed.status ?? \"created_or_updated\",\n ...(parsed.chunks !== undefined ? { chunks: parsed.chunks } : {}),\n },\n }\n }\n\n async query(q: KnowledgeQuery): Promise<KnowledgeQueryResult> {\n const start = Date.now()\n // `\"none\"` is the cold-start sentinel — skip retrieval entirely.\n if (q.mode === \"none\") {\n return { engine: this.id, modeUsed: \"none\", hits: [], tookMs: 0 }\n }\n\n const args: Record<string, number | string> = { query: q.query }\n if (q.topK !== undefined) args.limit = q.topK\n\n const result = await this.callTool(\"search\", args)\n const parsed = searchResultSchema.parse(parseToolJson(result))\n const rows = Array.isArray(parsed) ? parsed : parsed.results\n\n let hits: KnowledgeHit[] = rows.map((row, i) => searchRowToHit(row, i))\n // gbrain `search` has no server-side score floor, so honour `minScore`\n // client-side (the contract lets adapters enforce it either way).\n if (q.minScore !== undefined) {\n const floor = q.minScore\n hits = hits.filter((h) => h.score >= floor)\n }\n\n return {\n engine: this.id,\n // gbrain search fuses lexical + semantic recall — surface the real mode\n // regardless of the caller's hint.\n modeUsed: \"hybrid\",\n hits,\n tookMs: Date.now() - start,\n }\n }\n\n async listSources(\n filter?: ListSourcesFilter,\n ): Promise<readonly KnowledgeSource[]> {\n const args: Record<string, string> = {}\n if (filter?.kind) args.type = kindToGbrainType(filter.kind)\n const result = await this.callTool(\"list_pages\", args)\n const parsed = pageListSchema.parse(parseToolJson(result))\n const rows = Array.isArray(parsed) ? parsed : parsed.pages\n let out = rows.map((row) => listItemToSource(row, filter?.kind))\n // `status` isn't a gbrain list dimension — every listed page is live, so a\n // `status` filter keeps only \"ready\" (all of them) or nothing.\n if (filter?.status) out = out.filter((s) => s.status === filter.status)\n return out\n }\n\n async getSource(id: string): Promise<KnowledgeSource | null> {\n try {\n const result = await this.callTool(\"get_page\", { slug: id })\n const parsed = pageSchema.parse(parseToolJson(result))\n return pageToSource(parsed)\n } catch (err) {\n // gbrain flags a missing page with isError + a \"page_not_found\" body —\n // fold that to null; re-throw anything else.\n if (isNotFound(err)) return null\n throw err\n }\n }\n\n async deleteSource(id: string): Promise<void> {\n try {\n await this.callTool(\"delete_page\", { slug: id })\n } catch (err) {\n // Deleting an already-absent page is a no-op, not an error.\n if (isNotFound(err)) return\n throw err\n }\n }\n\n async healthCheck(): Promise<boolean> {\n try {\n const res = await fetch(`${this.endpoint}/health`, {\n method: \"GET\",\n headers: this.authHeaders(),\n })\n return res.ok\n } catch {\n return false\n }\n }\n\n async dispose(): Promise<void> {\n // No connections to tear down — gbrain calls are stateless JSON-RPC over\n // HTTP. Kept on the interface for adapters that hold long-lived clients.\n }\n\n // ── Internal: MCP / JSON-RPC plumbing ────────────────────────────\n\n private authHeaders(): Record<string, string> {\n return {\n Authorization: `Bearer ${this.bearerToken}`,\n \"Content-Type\": \"application/json\",\n // gbrain serves `/mcp` as MCP Streamable HTTP; the client MUST declare it\n // accepts BOTH JSON and event-stream or the server answers 406.\n Accept: \"application/json, text/event-stream\",\n }\n }\n\n private nextRpcId(): number {\n this.rpcCounter += 1\n return this.rpcCounter\n }\n\n /** Issue one MCP `tools/call` and return the parsed result envelope. Throws a\n * labelled error when gbrain sets `isError` (e.g. page-not-found). */\n private async callTool(\n name: string,\n args: Readonly<Record<string, unknown>>,\n ): Promise<McpToolResult> {\n const envelope = await this.rpcCall(\"tools/call\", { name, arguments: args })\n if (envelope.error !== undefined) {\n throw new Error(this.errPrefix(`tool ${name}: ${envelope.error.message}`))\n }\n const result = envelope.result\n if (result === undefined) {\n throw new Error(this.errPrefix(`tool ${name} returned no result`))\n }\n if (result.isError) {\n throw new Error(this.errPrefix(`tool ${name}: ${readToolError(result)}`))\n }\n return result\n }\n\n private async rpcCall(\n method: string,\n params: unknown,\n ): Promise<z.infer<typeof mcpEnvelopeSchema>> {\n const body: JsonRpcRequest = {\n jsonrpc: \"2.0\",\n id: this.nextRpcId(),\n method,\n params,\n }\n const controller = new AbortController()\n const timer = setTimeout(() => controller.abort(), this.timeoutMs)\n try {\n const res = await fetch(`${this.endpoint}/mcp`, {\n method: \"POST\",\n headers: this.authHeaders(),\n body: JSON.stringify(body),\n signal: controller.signal,\n })\n if (!res.ok) {\n const detail = await res.text().catch(() => \"\")\n throw new Error(\n this.errPrefix(\n `${method} → HTTP ${res.status}${detail ? `: ${detail.slice(0, 300)}` : \"\"}`,\n ),\n )\n }\n // gbrain replies as a Streamable-HTTP SSE frame (`data: {…}`) OR plain\n // JSON — {@link extractJsonRpcPayload} normalises both.\n const raw = await res.text()\n return mcpEnvelopeSchema.parse(JSON.parse(extractJsonRpcPayload(raw)))\n } finally {\n clearTimeout(timer)\n }\n }\n\n private errPrefix(msg: string): string {\n const labelPart = this.label ? ` (${this.label})` : \"\"\n return `GbrainDocKnowledgeAdapter${labelPart}: ${msg}`\n }\n}\n\n/** Construct a {@link GbrainDocKnowledgeAdapter} from a validated config. */\nexport function gbrainDocKnowledgeAdapter(\n config: GbrainDocAdapterConfig,\n): GbrainDocKnowledgeAdapter {\n return new GbrainDocKnowledgeAdapter(config)\n}\n\n// ── Pure helpers (no I/O) — exported where a test drives them ─────────\n\n/**\n * Extract the JSON-RPC envelope from a Streamable-HTTP response body. gbrain\n * replies with SSE frames (`event: message\\ndata: {…}`); the last non-empty\n * `data:` line carries the JSON-RPC payload. A plain-JSON body (no SSE framing)\n * is returned whole.\n */\nexport function extractJsonRpcPayload(body: string): string {\n const dataLines = body\n .split(/\\r?\\n/)\n .filter((line) => line.startsWith(\"data:\"))\n .map((line) => line.slice(\"data:\".length).trim())\n .filter((payload) => payload.length > 0)\n const last = dataLines[dataLines.length - 1]\n return last ?? body.trim()\n}\n\n/**\n * Pull the JSON payload out of an MCP tool result: prefer `structuredContent`,\n * else the first text block parsed as JSON. Returns the raw text when it isn't\n * JSON. The caller zod-parses the returned value into a concrete shape.\n */\nfunction parseToolJson(result: McpToolResult): unknown {\n if (result.structuredContent !== undefined) return result.structuredContent\n const first = result.content?.find((c) => c.text !== undefined && c.text !== \"\")\n if (first?.text === undefined) return null\n try {\n return JSON.parse(first.text)\n } catch {\n return first.text\n }\n}\n\n/** The error text gbrain packs into a `tools/call` result when `isError` is set. */\nfunction readToolError(result: McpToolResult): string {\n const first = result.content?.find((c) => c.text !== undefined && c.text !== \"\")\n return first?.text ?? \"unknown error\"\n}\n\nfunction isNotFound(err: unknown): boolean {\n return err instanceof Error && /not.?found/i.test(err.message)\n}\n\ntype SearchRow = z.infer<typeof searchHitSchema>\n\nfunction searchRowToHit(row: SearchRow, index: number): KnowledgeHit {\n const { slug, chunk_text, chunk_index, chunk_id, score, base_score, ...rest } =\n row\n const chunkIndex = chunk_index ?? index\n return {\n sourceId: slug,\n chunkId:\n chunk_id !== undefined ? `${slug}#${chunk_id}` : `${slug}#${chunkIndex}`,\n text: chunk_text ?? \"\",\n score: score ?? base_score ?? 0,\n // Round-trip every other gbrain field (title, type, page_id, source_id,\n // evidence, …) so a hit carries full provenance to the LLM.\n metadata: { chunkIndex, ...rest },\n }\n}\n\ntype PageRow = z.infer<typeof pageSchema>\n\nfunction pageToSource(page: PageRow): KnowledgeSource {\n const compiled = page.compiled_truth ?? \"\"\n return {\n id: page.slug,\n kind: gbrainTypeToKind(page.type),\n uri: page.source_uri ?? page.slug,\n title: page.title,\n bytes: byteLength(compiled),\n status: \"ready\",\n indexedAt: parseDate(page.updated_at ?? page.created_at),\n metadata: { type: page.type ?? \"note\" },\n }\n}\n\ntype PageListRow = z.infer<typeof pageListItemSchema>\n\nfunction listItemToSource(\n row: PageListRow,\n hintedKind?: KnowledgeSourceKind,\n): KnowledgeSource {\n return {\n id: row.slug,\n kind: hintedKind ?? gbrainTypeToKind(row.type),\n uri: row.slug,\n title: row.title,\n // list_pages is a slim projection (no body) — bytes are unknown here.\n bytes: 0,\n status: \"ready\",\n indexedAt: parseDate(row.updated_at),\n metadata: { type: row.type ?? \"note\" },\n }\n}\n\nfunction deriveSlug(input: KnowledgeIngestInput): string {\n if (input.title) return slugify(input.title)\n const [pathPart = \"\"] = input.uri.split(/[?#]/)\n const tail = pathPart.split(\"/\").filter(Boolean).pop()\n if (tail) return slugify(tail)\n return \"note\"\n}\n\nfunction slugify(s: string): string {\n return (\n s\n .toLowerCase()\n .replace(/[^a-z0-9]+/g, \"-\")\n .replace(/^-+|-+$/g, \"\")\n .slice(0, 80) || \"note\"\n )\n}\n\nfunction gbrainTypeToKind(t: string | undefined): KnowledgeSourceKind {\n if (!t) return \"text\"\n if (t === \"url\" || t === \"link\") return \"url\"\n if (t === \"file\" || t === \"document\" || t === \"code\") return \"file\"\n if (t === \"connector\") return \"connector\"\n return \"text\"\n}\n\nfunction kindToGbrainType(kind: KnowledgeSourceKind): string {\n switch (kind) {\n case \"url\":\n return \"url\"\n case \"file\":\n return \"file\"\n case \"connector\":\n return \"connector\"\n case \"text\":\n default:\n return \"note\"\n }\n}\n\nfunction normalizeContent(content: KnowledgeIngestInput[\"content\"]): string {\n if (content === undefined) return \"\"\n if (typeof content === \"string\") return content\n return new TextDecoder().decode(content)\n}\n\n/** UTF-8 byte length without a `node:buffer` edge — runs on edge runtimes too. */\nfunction byteLength(text: string): number {\n return new TextEncoder().encode(text).byteLength\n}\n\nfunction parseDate(v: string | undefined): Date | undefined {\n if (v === undefined) return undefined\n const d = new Date(v)\n return Number.isNaN(d.getTime()) ? undefined : d\n}\n","/**\n * Typed environment module for the gbrain-doc knowledge adapter.\n *\n * Every `process.env` read in this package flows through here — no raw\n * `process.env.X` at a call site (mirrors the code-brain + files + corpus +\n * qdrant adapters' `env.ts`). The loader parses the ambient env into a typed,\n * validated config once, so the rest of the adapter is a pure function of its\n * inputs. This is the ONE place the gbrain-flavoured env names (`GBRAIN_*`)\n * live, keeping the backend idiom confined to the adapter.\n *\n * `GBRAIN_BEARER_TOKEN` is shared with `@agentproto/adapter-code-brain-gbrain`'s\n * HTTP backend by design — same gbrain server, same machine token — but the two\n * adapters never share a package edge; the token only ever meets gbrain at\n * runtime over HTTP.\n */\n\nimport type { GbrainDocAdapterConfig } from \"./adapter.js\"\n\nfunction parsePositiveInt(value: string | undefined, fallback: number): number {\n if (value === undefined || value === \"\") return fallback\n const parsed = Number.parseInt(value, 10)\n if (Number.isNaN(parsed) || parsed <= 0) return fallback\n return parsed\n}\n\nfunction nonEmpty(value: string | undefined): string | undefined {\n if (value === undefined) return undefined\n const trimmed = value.trim()\n return trimmed === \"\" ? undefined : trimmed\n}\n\n/** Config for the standalone gbrain-doc backend — a gbrain HTTP endpoint + a\n * machine bearer token. */\nexport interface GbrainDocKnowledgeEnv {\n /** gbrain HTTP base URL (`GBRAIN_ENDPOINT`); the `/mcp` JSON-RPC endpoint is\n * appended. Default `\"http://127.0.0.1:3132\"`. */\n readonly endpoint: string\n /** Machine bearer token (`GBRAIN_BEARER_TOKEN`). Required — the `/mcp`\n * endpoint is bearer-protected. */\n readonly bearerToken: string\n /** Per-request timeout (ms) (`GBRAIN_HTTP_TIMEOUT_MS`). Default 45_000. */\n readonly timeoutMs: number\n}\n\n/**\n * Load {@link GbrainDocKnowledgeEnv} from `process.env` with defaults.\n *\n * Throws when `GBRAIN_BEARER_TOKEN` is absent — the adapter cannot authenticate\n * to the `/mcp` endpoint without it, and failing at construction time is\n * clearer than a 401 on the first call.\n */\nexport function loadGbrainDocKnowledgeEnv(): GbrainDocKnowledgeEnv {\n const bearerToken = nonEmpty(process.env.GBRAIN_BEARER_TOKEN)\n if (bearerToken === undefined) {\n throw new Error(\n \"GBRAIN_BEARER_TOKEN is required for the gbrain-doc knowledge adapter; mint one via gbrain's admin API (OAuth 2.1 client_credentials) and set it in the environment.\",\n )\n }\n return {\n endpoint: nonEmpty(process.env.GBRAIN_ENDPOINT) ?? \"http://127.0.0.1:3132\",\n bearerToken,\n timeoutMs: parsePositiveInt(process.env.GBRAIN_HTTP_TIMEOUT_MS, 45_000),\n }\n}\n\n/** Project the typed env into a {@link GbrainDocAdapterConfig}. */\nexport function gbrainDocEnvToConfig(\n env: GbrainDocKnowledgeEnv,\n): GbrainDocAdapterConfig {\n return {\n endpoint: env.endpoint,\n bearerToken: env.bearerToken,\n timeoutMs: env.timeoutMs,\n }\n}\n","/**\n * Standalone wiring for {@link GbrainDocKnowledgeAdapter}.\n *\n * The adapter class itself is config-driven: it consumes a plain\n * {@link GbrainDocAdapterConfig} and knows nothing about `process.env`. This\n * module is the ONE place that binds it to the ambient environment — it reads\n * the typed `GBRAIN_*` env (via {@link loadGbrainDocKnowledgeEnv}) and\n * constructs an adapter from it, exactly the role the code-brain adapter's\n * provider factories play for their backends. Hosts that already hold a config\n * (e.g. a studio guild host resolving a per-KB `configRef` + vault secrets)\n * should construct `GbrainDocKnowledgeAdapter` directly and skip this factory.\n */\n\nimport { GbrainDocKnowledgeAdapter } from \"./adapter.js\"\nimport { gbrainDocEnvToConfig, loadGbrainDocKnowledgeEnv } from \"./env.js\"\n\n/**\n * Build a {@link GbrainDocKnowledgeAdapter} from the ambient `GBRAIN_*` env.\n * Throws (via {@link loadGbrainDocKnowledgeEnv}) when `GBRAIN_BEARER_TOKEN` is\n * absent. Each call returns a fresh adapter — the adapter holds no warm state\n * (stateless JSON-RPC over HTTP), so sharing an instance is a convenience, not\n * a requirement.\n */\nexport function createStandaloneGbrainDocAdapter(): GbrainDocKnowledgeAdapter {\n return new GbrainDocKnowledgeAdapter(\n gbrainDocEnvToConfig(loadGbrainDocKnowledgeEnv()),\n )\n}\n","import type { AdapterCatalog } from \"@agentproto/provider-kit\"\n\n/**\n * Family key used for the knowledge backend creds/ledger store path.\n *\n * The gbrain-doc engine is the document-retrieval sibling of the `files`\n * (BM25), `corpus` (AIP-10 composition), and `qdrant` (vector) backends — same\n * `knowledge` family, so all four surface through the same provider-kit\n * discovery convention (`@agentproto/adapter-knowledge-*`).\n */\nexport const KNOWLEDGE_FAMILY = \"knowledge\" as const\n\n/** The single backend slug this adapter provides. */\nexport const GBRAIN_DOC_SLUG = \"gbrain-doc\" as const\n\n/**\n * Static catalog of knowledge backends shipped by this adapter. The `gbrain-doc`\n * slug resolves from THIS package (`@agentproto/adapter-knowledge-gbrain-doc`) —\n * document retrieval over a gbrain server's `put_page` / `search` API, reached\n * over its JSON-RPC `/mcp` endpoint via pure `fetch` (no vendor SDK). Needs a\n * gbrain endpoint + a machine bearer token, so it requires a setup pass.\n *\n * DISTINCT from `@agentproto/adapter-code-brain-gbrain` (the code-graph gbrain\n * adapter) — same backend, different contract, no shared package edge.\n */\nexport const KNOWLEDGE_GBRAIN_DOC_CATALOG: AdapterCatalog = [\n {\n slug: GBRAIN_DOC_SLUG,\n name: \"gbrain (doc)\",\n description:\n \"Document knowledge retrieval over a gbrain server's put_page / search \" +\n \"API, reached over its JSON-RPC /mcp endpoint via pure fetch — no vendor \" +\n \"SDK. gbrain fuses lexical (tsvector) + semantic recall. Needs a gbrain \" +\n \"endpoint + a machine bearer token. Distinct from the code-graph gbrain \" +\n \"adapter.\",\n packageName: \"@agentproto/adapter-knowledge-gbrain-doc\",\n hint: \"gbrain · doc\",\n },\n]\n","/**\n * provider-kit family wiring for the gbrain-doc knowledge backend.\n *\n * The studio home-grown `createEngineRegistry`-based knowledge registry is NOT\n * ported (it was the guild resolution layer, which stays studio-side per the\n * Ph4 plan — the studio gbrain `descriptor` recursively resolves per-KB config\n * + reveals the vault bearer through that registry, and the retired E2B/sandbox\n * provisioning path stays studio-side too). Instead the gbrain-doc backend\n * registers as a provider-kit family (`TInfo = KnowledgeGbrainDocInfo`, `THandle\n * = KnowledgeHandle extends AdapterHandle`), reusing the exact consumer shape\n * the code-brain + files + corpus + qdrant adapters established — catalog +\n * resolver + a safe `info()` descriptor that NEVER carries a secret. Discovery\n * flows through the kit's `@agentproto/adapter-knowledge-*` naming convention.\n *\n * gbrain-doc needs a gbrain endpoint + a bearer token, so `requiresSetup` /\n * `authRequired` are both true and `provider()` (via\n * {@link createStandaloneGbrainDocAdapter}) throws when `GBRAIN_BEARER_TOKEN` is\n * absent.\n */\n\nimport type { IKnowledgeProvider } from \"@agentproto/knowledge-engine\"\nimport {\n makeAdapterResolver,\n type AdapterHandle,\n type AdapterResolver,\n} from \"@agentproto/provider-kit\"\nimport { GBRAIN_DOC_SLUG, KNOWLEDGE_GBRAIN_DOC_CATALOG } from \"./catalog.js\"\nimport { createStandaloneGbrainDocAdapter } from \"./standalone.js\"\n\n/** Safe descriptor for a knowledge backend — NEVER carries a secret. */\nexport interface KnowledgeGbrainDocInfo {\n readonly slug: string\n /** The retrieval engine this backend uses. */\n readonly engine: \"gbrain-doc\"\n readonly capabilities: {\n /** True — gbrain fuses lexical + semantic document retrieval. */\n readonly hybridSearch: boolean\n /** True — gbrain-doc needs a gbrain endpoint + a machine bearer token. */\n readonly needsCreds: boolean\n }\n}\n\n/** A resolved knowledge backend handle. */\nexport interface KnowledgeHandle extends AdapterHandle {\n /** Safe descriptor — NEVER a secret. */\n info(): KnowledgeGbrainDocInfo\n /**\n * Build the live {@link IKnowledgeProvider} from the ambient `GBRAIN_*` env.\n * Throws when `GBRAIN_BEARER_TOKEN` is absent — construction-time failure is\n * clearer than a 401 on the first query.\n */\n provider(): IKnowledgeProvider\n}\n\n/**\n * Resolve a catalog slug to a concrete knowledge handle. Throws for unknown\n * slugs so the kit's resolver wrapper folds the miss to `null`. `provider()` is\n * lazy — the `GBRAIN_BEARER_TOKEN` requirement is enforced only when a provider\n * is actually built, not at resolution time.\n */\nexport function resolveKnowledgeBackend(slug: string): KnowledgeHandle {\n const catalogEntry = KNOWLEDGE_GBRAIN_DOC_CATALOG.find(\n (entry) => entry.slug === slug,\n )\n if (catalogEntry === undefined) {\n throw new Error(`unknown knowledge backend slug: ${slug}`)\n }\n\n switch (slug) {\n case GBRAIN_DOC_SLUG: {\n return {\n slug,\n name: catalogEntry.name,\n description: catalogEntry.description,\n version: \"0.1.0\",\n requiresSetup: true,\n authRequired: true,\n // Health probe: build from env + hit GET /health. When the env is\n // absent, construction throws — fold that to \"not reachable\" rather\n // than propagating so a listing probe stays total.\n check: async () => {\n try {\n return await createStandaloneGbrainDocAdapter().healthCheck()\n } catch {\n return false\n }\n },\n info() {\n return {\n slug,\n engine: \"gbrain-doc\",\n capabilities: { hybridSearch: true, needsCreds: true },\n }\n },\n provider: () => createStandaloneGbrainDocAdapter(),\n }\n }\n }\n\n throw new Error(`unhandled knowledge backend slug: ${slug}`)\n}\n\n/**\n * Build the knowledge resolver: resolves a catalog slug to a handle, returning\n * `null` when the slug is unknown (via the kit's wrapper).\n */\nexport function makeKnowledgeGbrainDocResolver(): AdapterResolver<KnowledgeHandle> {\n return makeAdapterResolver<KnowledgeHandle>({\n load: async (slug: string): Promise<KnowledgeHandle> =>\n resolveKnowledgeBackend(slug),\n })\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["../src/adapter.ts","../src/env.ts","../src/standalone.ts","../src/catalog.ts","../src/handle.ts"],"names":[],"mappings":";;;;;;;;;;AA8DO,IAAM,oBAAA,GAAuB;AA6B7B,IAAM,4BAAA,GAA+B,EAAE,MAAA,CAAO;AAAA;AAAA;AAAA,EAGnD,QAAA,EAAU,CAAA,CAAE,MAAA,EAAO,CAAE,GAAA,EAAI;AAAA;AAAA;AAAA,EAGzB,WAAA,EAAa,CAAA,CAAE,MAAA,EAAO,CAAE,IAAI,CAAC,CAAA;AAAA;AAAA,EAE7B,SAAA,EAAW,EAAE,MAAA,EAAO,CAAE,KAAI,CAAE,QAAA,EAAS,CAAE,OAAA,CAAQ,IAAM,CAAA;AAAA;AAAA,EAErD,KAAA,EAAO,CAAA,CAAE,MAAA,EAAO,CAAE,QAAA;AACpB,CAAC;AAIM,SAAS,4BACd,GAAA,EACwB;AACxB,EAAA,OAAO,4BAAA,CAA6B,MAAM,GAAG,CAAA;AAC/C;AAIO,IAAM,uBAAA,GAAiD,OAAO,MAAA,CAAO;AAAA;AAAA;AAAA,EAG1E,YAAA,EAAc,IAAA;AAAA,EACd,YAAA,EAAc,IAAA;AAAA;AAAA;AAAA,EAGd,cAAA,EAAgB,KAAA;AAAA,EAChB,UAAA,EAAY,KAAA;AAAA,EACZ,SAAA,EAAW,KAAA;AAAA,EACX,SAAA,EAAW,IAAA;AAAA;AAAA,EAEX,eAAe,EAAA,GAAK;AACtB,CAAC;AAMD,IAAM,mBAAA,GAAsB,EAAE,MAAA,CAAO;AAAA,EACnC,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file":"index.mjs","sourcesContent":["/**\n * GbrainDocKnowledgeAdapter — the `IKnowledgeProvider` over gbrain's DOCUMENT\n * API.\n *\n * Connects the `@agentproto/knowledge-engine` `IKnowledgeProvider` contract to a\n * gbrain server's document surface, reached over its JSON-RPC MCP endpoint\n * (`POST /mcp`, bearer-authenticated) via pure `fetch` — no vendor SDK. The two\n * load-bearing tools are `put_page` (ingest) and `search` (query); the\n * lifecycle verbs (`list_pages` / `get_page` / `delete_page`) round out the\n * contract. Lets a host plug \"my own gbrain\" as a first-class knowledge engine\n * alongside the files / corpus / qdrant backends.\n *\n * DISTINCT from `@agentproto/adapter-code-brain-gbrain`: that adapter is the\n * CODE-GRAPH one (`ICodeBrainProvider`: define / callers / callees). THIS one is\n * the KNOWLEDGE-DOC one (`IKnowledgeProvider` over gbrain's document store).\n * Same backend, different contract — they never share a package edge; gbrain is\n * reached only at runtime over HTTP.\n *\n * Lifted from the studio integration package\n * (`packages/integration/knowledge/src/providers/gbrain-knowledge.adapter.ts`).\n * Changes on the lift:\n * 1. The contract + data types now come from `@agentproto/knowledge-engine`\n * (was the studio `../base-knowledge.provider` / `../../types`).\n * 2. The ONE cross-package edge — a type-only import of `JsonRpcRequest` /\n * `JsonRpcResponse` from the studio `core/protocol` package\n * (`gbrain-knowledge.adapter.ts:23`) — is replaced by the two inline\n * interfaces below. No studio dependency survives.\n * 3. The wire shapes are typed against the LIVE gbrain doc API (probed at\n * build time), which drifts from the studio original:\n * - `put_page` args are `{ slug, content }` (studio sent a `source`\n * field; gbrain's real field is the server-stamped `source_uri`).\n * - `search` args are `{ query, limit, offset }` (studio sent a\n * `min_score` gbrain doesn't accept — `minScore` is applied\n * client-side here instead).\n * - a `search` hit carries `chunk_text` / `score` / `chunk_index`\n * (studio expected `snippet` / `rerank_score`).\n * Every response is zod-parsed — nothing untyped reaches a call site.\n *\n * Scope of this adapter:\n * - `ingest({ kind, uri, title?, content })` — `put_page` a markdown doc\n * - `query({ query, topK, minScore })` — `search` (gbrain fuses lexical +\n * semantic recall, so `modeUsed` is stamped `\"hybrid\"`)\n * - `listSources()` / `getSource(id)` / `deleteSource(id)` — via\n * `list_pages` / `get_page` / `delete_page`\n * - `healthCheck()` — `GET /health` returns OK\n */\n\nimport { z } from \"zod\"\nimport {\n KnowledgeNotSupportedError,\n type IKnowledgeProvider,\n type KnowledgeCapabilities,\n type KnowledgeHit,\n type KnowledgeIngestInput,\n type KnowledgeQuery,\n type KnowledgeQueryResult,\n type KnowledgeSource,\n type KnowledgeSourceKind,\n type ListSourcesFilter,\n type KnowledgeProvenance,\n} from \"@agentproto/knowledge-engine\"\n\nexport const GBRAIN_DOC_ENGINE_ID = \"gbrain-doc\" as const\n\n// ── Inline JSON-RPC 2.0 wire types ──────────────────────────────────\n//\n// Replaces the studio adapter's ONE cross-package edge: a type-only import of\n// `JsonRpcRequest` / `JsonRpcResponse` from the studio `core/protocol` package.\n// gbrain speaks JSON-RPC 2.0 over `POST /mcp`; these two frames are all we send\n// and receive, so they inline here with zero new dependency. The response is\n// additionally zod-validated on the wire ({@link mcpEnvelopeSchema}) so nothing\n// untyped reaches a call site.\n\n/** A JSON-RPC 2.0 request frame — the body we POST to gbrain's `/mcp`. */\ninterface JsonRpcRequest<TParams = unknown> {\n readonly jsonrpc: \"2.0\"\n readonly id: number\n readonly method: string\n readonly params?: TParams\n}\n\n/** A JSON-RPC 2.0 response frame — success carries `result`, failure `error`. */\ninterface JsonRpcResponse<TResult = unknown> {\n readonly jsonrpc?: \"2.0\"\n readonly id?: number | string | null\n readonly result?: TResult\n readonly error?: { readonly code?: number; readonly message: string }\n}\n\n// ── Config ──────────────────────────────────────────────────────────\n\nexport const GbrainDocAdapterConfigSchema = z.object({\n /** Base URL of the gbrain HTTP server (no trailing slash needed). The\n * JSON-RPC `/mcp` endpoint is appended. */\n endpoint: z.string().url(),\n /** Machine bearer token accepted by the gbrain server (`GBRAIN_BEARER_TOKEN`).\n * Required — the `/mcp` endpoint is OAuth 2.1 / bearer-protected. */\n bearerToken: z.string().min(1),\n /** Per-request timeout (ms). Default 45_000. */\n timeoutMs: z.number().int().positive().default(45_000),\n /** Optional human label for logs. */\n label: z.string().optional(),\n})\n\nexport type GbrainDocAdapterConfig = z.infer<typeof GbrainDocAdapterConfigSchema>\n\nexport function parseGbrainDocAdapterConfig(\n raw: Readonly<Record<string, unknown>>,\n): GbrainDocAdapterConfig {\n return GbrainDocAdapterConfigSchema.parse(raw)\n}\n\n// ── Capabilities ────────────────────────────────────────────────────\n\nexport const GBRAIN_DOC_CAPABILITIES: KnowledgeCapabilities = Object.freeze({\n // gbrain `search` fuses lexical (tsvector) + semantic recall, so both the\n // vector + hybrid flags are honest.\n vectorSearch: true,\n hybridSearch: true,\n // This adapter drives the DOCUMENT surface (put_page / search); it does NOT\n // reach gbrain's graph traversal (`traverse_graph` / `query`).\n graphTraversal: false,\n multiModal: false,\n streaming: false,\n citations: true,\n // gbrain caps a `/mcp` request body at 1 MiB; keep a chunk comfortably inside.\n maxChunkBytes: 64 * 1024,\n})\n\n// ── Wire shapes (zod-parsed — nothing untyped reaches a call site) ───\n\n/** The MCP `tools/call` result envelope: a text block (+ optional structured\n * content) and an `isError` flag gbrain sets for e.g. page-not-found. */\nconst mcpToolResultSchema = z.object({\n content: z\n .array(z.object({ type: z.string(), text: z.string().optional() }))\n .optional(),\n structuredContent: z.unknown().optional(),\n isError: z.boolean().optional(),\n})\n\ntype McpToolResult = z.infer<typeof mcpToolResultSchema>\n\n/** The JSON-RPC envelope wrapping an MCP `tools/call` result. Mirrors the\n * inline {@link JsonRpcResponse} interface, validated on the wire. */\nconst mcpEnvelopeSchema = z.object({\n jsonrpc: z.literal(\"2.0\").optional(),\n id: z.union([z.number(), z.string(), z.null()]).optional(),\n result: mcpToolResultSchema.optional(),\n error: z\n .object({ code: z.number().optional(), message: z.string() })\n .optional(),\n})\n\n/** A single `search` hit row (gbrain doc API). Known fields are typed; the rest\n * (page_id, type, source_id, evidence, …) flow through to `metadata`. */\nconst searchHitSchema = z\n .object({\n slug: z.string(),\n chunk_text: z.string().optional(),\n chunk_index: z.number().optional(),\n chunk_id: z.union([z.number(), z.string()]).optional(),\n score: z.number().optional(),\n base_score: z.number().optional(),\n })\n .catchall(z.unknown())\n\n/** `search` returns a bare array of hits; some builds wrap it as `{ results }`.\n * Accept both. */\nconst searchResultSchema = z.union([\n z.array(searchHitSchema),\n z.object({ results: z.array(searchHitSchema) }),\n])\n\n/** `put_page` result — status + chunk count (+ passthrough backstop fields). */\nconst putPageResultSchema = z\n .object({\n slug: z.string().optional(),\n status: z.string().optional(),\n chunks: z.number().optional(),\n })\n .catchall(z.unknown())\n\n/** A `get_page` document envelope. */\nconst pageSchema = z\n .object({\n slug: z.string(),\n type: z.string().optional(),\n title: z.string().optional(),\n compiled_truth: z.string().optional(),\n source_uri: z.string().nullish(),\n updated_at: z.string().optional(),\n created_at: z.string().optional(),\n })\n .catchall(z.unknown())\n\n/** A `list_pages` row (slim: no body). */\nconst pageListItemSchema = z\n .object({\n slug: z.string(),\n type: z.string().optional(),\n title: z.string().optional(),\n updated_at: z.string().optional(),\n })\n .catchall(z.unknown())\n\nconst pageListSchema = z.union([\n z.array(pageListItemSchema),\n z.object({ pages: z.array(pageListItemSchema) }),\n])\n\n// ── Adapter ──────────────────────────────────────────────────────────\n\nexport class GbrainDocKnowledgeAdapter implements IKnowledgeProvider {\n readonly id = GBRAIN_DOC_ENGINE_ID\n readonly capabilities = GBRAIN_DOC_CAPABILITIES\n\n private readonly endpoint: string\n private readonly bearerToken: string\n private readonly timeoutMs: number\n private readonly label?: string\n\n private rpcCounter = 0\n\n constructor(config: GbrainDocAdapterConfig) {\n this.endpoint = config.endpoint.replace(/\\/$/, \"\")\n this.bearerToken = config.bearerToken\n this.timeoutMs = config.timeoutMs\n this.label = config.label\n }\n\n async ingest(input: KnowledgeIngestInput): Promise<KnowledgeSource> {\n const content = normalizeContent(input.content)\n if (!content.trim()) {\n throw new Error(\n `GbrainDocKnowledgeAdapter: ingest payload is empty (uri=${input.uri}); gbrain put_page requires document content.`,\n )\n }\n const slug = deriveSlug(input)\n // gbrain put_page takes { slug, content }. `source_uri` is SERVER-STAMPED\n // for remote callers (client value ignored), so we don't send it — the\n // caller's uri round-trips through the returned KnowledgeSource instead.\n const result = await this.callTool(\"put_page\", { slug, content })\n const parsed = putPageResultSchema.parse(parseToolJson(result))\n return {\n id: parsed.slug ?? slug,\n kind: input.kind,\n uri: input.uri,\n title: input.title,\n bytes: byteLength(content),\n status: \"ready\",\n indexedAt: new Date(),\n metadata: {\n ...(input.metadata ?? {}),\n gbrainStatus: parsed.status ?? \"created_or_updated\",\n ...(parsed.chunks !== undefined ? { chunks: parsed.chunks } : {}),\n },\n }\n }\n\n async query(q: KnowledgeQuery): Promise<KnowledgeQueryResult> {\n const start = Date.now()\n // `\"none\"` is the cold-start sentinel — skip retrieval entirely.\n if (q.mode === \"none\") {\n return { engine: this.id, modeUsed: \"none\", hits: [], tookMs: 0 }\n }\n\n const args: Record<string, number | string> = { query: q.query }\n if (q.topK !== undefined) args.limit = q.topK\n\n const result = await this.callTool(\"search\", args)\n const parsed = searchResultSchema.parse(parseToolJson(result))\n const rows = Array.isArray(parsed) ? parsed : parsed.results\n\n let hits: KnowledgeHit[] = rows.map((row, i) => searchRowToHit(row, i))\n // gbrain `search` has no server-side score floor, so honour `minScore`\n // client-side (the contract lets adapters enforce it either way).\n if (q.minScore !== undefined) {\n const floor = q.minScore\n hits = hits.filter((h) => h.score >= floor)\n }\n\n return {\n engine: this.id,\n // gbrain search fuses lexical + semantic recall — surface the real mode\n // regardless of the caller's hint.\n modeUsed: \"hybrid\",\n hits,\n tookMs: Date.now() - start,\n }\n }\n\n async listSources(\n filter?: ListSourcesFilter,\n ): Promise<readonly KnowledgeSource[]> {\n const args: Record<string, string> = {}\n if (filter?.kind) args.type = kindToGbrainType(filter.kind)\n const result = await this.callTool(\"list_pages\", args)\n const parsed = pageListSchema.parse(parseToolJson(result))\n const rows = Array.isArray(parsed) ? parsed : parsed.pages\n let out = rows.map((row) => listItemToSource(row, filter?.kind))\n // `status` isn't a gbrain list dimension — every listed page is live, so a\n // `status` filter keeps only \"ready\" (all of them) or nothing.\n if (filter?.status) out = out.filter((s) => s.status === filter.status)\n return out\n }\n\n async getSource(id: string): Promise<KnowledgeSource | null> {\n try {\n const result = await this.callTool(\"get_page\", { slug: id })\n const parsed = pageSchema.parse(parseToolJson(result))\n return pageToSource(parsed)\n } catch (err) {\n // gbrain flags a missing page with isError + a \"page_not_found\" body —\n // fold that to null; re-throw anything else.\n if (isNotFound(err)) return null\n throw err\n }\n }\n\n async deleteSource(id: string): Promise<void> {\n try {\n await this.callTool(\"delete_page\", { slug: id })\n } catch (err) {\n // Deleting an already-absent page is a no-op, not an error.\n if (isNotFound(err)) return\n throw err\n }\n }\n\n async supersede(_id: string, _by?: string): Promise<void> {\n // The documented doc surface is put_page / get_page / list_pages /\n // delete_page / search — no status or supersede verb, and put_page can't\n // carry one (source_uri is server-stamped).\n throw new KnowledgeNotSupportedError(\n this.id,\n \"supersede\",\n \"gbrain's page API has no supersede/status verb (only put_page/delete_page)\",\n )\n }\n\n async explain(id: string): Promise<KnowledgeProvenance | null> {\n try {\n const result = await this.callTool(\"get_page\", { slug: id })\n const page = pageSchema.parse(parseToolJson(result))\n return {\n sourceId: page.slug,\n derivedFrom: page.source_uri ? [page.source_uri] : [],\n metadata: {\n type: page.type ?? \"note\",\n ...(page.source_uri ? { sourceUri: page.source_uri } : {}),\n ...(page.created_at ? { createdAt: page.created_at } : {}),\n ...(page.updated_at ? { updatedAt: page.updated_at } : {}),\n },\n }\n } catch (err) {\n if (isNotFound(err)) return null\n throw err\n }\n }\n\n async healthCheck(): Promise<boolean> {\n try {\n const res = await fetch(`${this.endpoint}/health`, {\n method: \"GET\",\n headers: this.authHeaders(),\n })\n return res.ok\n } catch {\n return false\n }\n }\n\n async dispose(): Promise<void> {\n // No connections to tear down — gbrain calls are stateless JSON-RPC over\n // HTTP. Kept on the interface for adapters that hold long-lived clients.\n }\n\n // ── Internal: MCP / JSON-RPC plumbing ────────────────────────────\n\n private authHeaders(): Record<string, string> {\n return {\n Authorization: `Bearer ${this.bearerToken}`,\n \"Content-Type\": \"application/json\",\n // gbrain serves `/mcp` as MCP Streamable HTTP; the client MUST declare it\n // accepts BOTH JSON and event-stream or the server answers 406.\n Accept: \"application/json, text/event-stream\",\n }\n }\n\n private nextRpcId(): number {\n this.rpcCounter += 1\n return this.rpcCounter\n }\n\n /** Issue one MCP `tools/call` and return the parsed result envelope. Throws a\n * labelled error when gbrain sets `isError` (e.g. page-not-found). */\n private async callTool(\n name: string,\n args: Readonly<Record<string, unknown>>,\n ): Promise<McpToolResult> {\n const envelope = await this.rpcCall(\"tools/call\", { name, arguments: args })\n if (envelope.error !== undefined) {\n throw new Error(this.errPrefix(`tool ${name}: ${envelope.error.message}`))\n }\n const result = envelope.result\n if (result === undefined) {\n throw new Error(this.errPrefix(`tool ${name} returned no result`))\n }\n if (result.isError) {\n throw new Error(this.errPrefix(`tool ${name}: ${readToolError(result)}`))\n }\n return result\n }\n\n private async rpcCall(\n method: string,\n params: unknown,\n ): Promise<z.infer<typeof mcpEnvelopeSchema>> {\n const body: JsonRpcRequest = {\n jsonrpc: \"2.0\",\n id: this.nextRpcId(),\n method,\n params,\n }\n const controller = new AbortController()\n const timer = setTimeout(() => controller.abort(), this.timeoutMs)\n try {\n const res = await fetch(`${this.endpoint}/mcp`, {\n method: \"POST\",\n headers: this.authHeaders(),\n body: JSON.stringify(body),\n signal: controller.signal,\n })\n if (!res.ok) {\n const detail = await res.text().catch(() => \"\")\n throw new Error(\n this.errPrefix(\n `${method} → HTTP ${res.status}${detail ? `: ${detail.slice(0, 300)}` : \"\"}`,\n ),\n )\n }\n // gbrain replies as a Streamable-HTTP SSE frame (`data: {…}`) OR plain\n // JSON — {@link extractJsonRpcPayload} normalises both.\n const raw = await res.text()\n return mcpEnvelopeSchema.parse(JSON.parse(extractJsonRpcPayload(raw)))\n } finally {\n clearTimeout(timer)\n }\n }\n\n private errPrefix(msg: string): string {\n const labelPart = this.label ? ` (${this.label})` : \"\"\n return `GbrainDocKnowledgeAdapter${labelPart}: ${msg}`\n }\n}\n\n/** Construct a {@link GbrainDocKnowledgeAdapter} from a validated config. */\nexport function gbrainDocKnowledgeAdapter(\n config: GbrainDocAdapterConfig,\n): GbrainDocKnowledgeAdapter {\n return new GbrainDocKnowledgeAdapter(config)\n}\n\n// ── Pure helpers (no I/O) — exported where a test drives them ─────────\n\n/**\n * Extract the JSON-RPC envelope from a Streamable-HTTP response body. gbrain\n * replies with SSE frames (`event: message\\ndata: {…}`); the last non-empty\n * `data:` line carries the JSON-RPC payload. A plain-JSON body (no SSE framing)\n * is returned whole.\n */\nexport function extractJsonRpcPayload(body: string): string {\n const dataLines = body\n .split(/\\r?\\n/)\n .filter((line) => line.startsWith(\"data:\"))\n .map((line) => line.slice(\"data:\".length).trim())\n .filter((payload) => payload.length > 0)\n const last = dataLines[dataLines.length - 1]\n return last ?? body.trim()\n}\n\n/**\n * Pull the JSON payload out of an MCP tool result: prefer `structuredContent`,\n * else the first text block parsed as JSON. Returns the raw text when it isn't\n * JSON. The caller zod-parses the returned value into a concrete shape.\n */\nfunction parseToolJson(result: McpToolResult): unknown {\n if (result.structuredContent !== undefined) return result.structuredContent\n const first = result.content?.find((c) => c.text !== undefined && c.text !== \"\")\n if (first?.text === undefined) return null\n try {\n return JSON.parse(first.text)\n } catch {\n return first.text\n }\n}\n\n/** The error text gbrain packs into a `tools/call` result when `isError` is set. */\nfunction readToolError(result: McpToolResult): string {\n const first = result.content?.find((c) => c.text !== undefined && c.text !== \"\")\n return first?.text ?? \"unknown error\"\n}\n\nfunction isNotFound(err: unknown): boolean {\n return err instanceof Error && /not.?found/i.test(err.message)\n}\n\ntype SearchRow = z.infer<typeof searchHitSchema>\n\nfunction searchRowToHit(row: SearchRow, index: number): KnowledgeHit {\n const { slug, chunk_text, chunk_index, chunk_id, score, base_score, ...rest } =\n row\n const chunkIndex = chunk_index ?? index\n return {\n sourceId: slug,\n chunkId:\n chunk_id !== undefined ? `${slug}#${chunk_id}` : `${slug}#${chunkIndex}`,\n text: chunk_text ?? \"\",\n score: score ?? base_score ?? 0,\n // Round-trip every other gbrain field (title, type, page_id, source_id,\n // evidence, …) so a hit carries full provenance to the LLM.\n metadata: { chunkIndex, ...rest },\n }\n}\n\ntype PageRow = z.infer<typeof pageSchema>\n\nfunction pageToSource(page: PageRow): KnowledgeSource {\n const compiled = page.compiled_truth ?? \"\"\n return {\n id: page.slug,\n kind: gbrainTypeToKind(page.type),\n uri: page.source_uri ?? page.slug,\n title: page.title,\n bytes: byteLength(compiled),\n status: \"ready\",\n indexedAt: parseDate(page.updated_at ?? page.created_at),\n metadata: { type: page.type ?? \"note\" },\n }\n}\n\ntype PageListRow = z.infer<typeof pageListItemSchema>\n\nfunction listItemToSource(\n row: PageListRow,\n hintedKind?: KnowledgeSourceKind,\n): KnowledgeSource {\n return {\n id: row.slug,\n kind: hintedKind ?? gbrainTypeToKind(row.type),\n uri: row.slug,\n title: row.title,\n // list_pages is a slim projection (no body) — bytes are unknown here.\n bytes: 0,\n status: \"ready\",\n indexedAt: parseDate(row.updated_at),\n metadata: { type: row.type ?? \"note\" },\n }\n}\n\nfunction deriveSlug(input: KnowledgeIngestInput): string {\n if (input.title) return slugify(input.title)\n const [pathPart = \"\"] = input.uri.split(/[?#]/)\n const tail = pathPart.split(\"/\").filter(Boolean).pop()\n if (tail) return slugify(tail)\n return \"note\"\n}\n\nfunction slugify(s: string): string {\n return (\n s\n .toLowerCase()\n .replace(/[^a-z0-9]+/g, \"-\")\n .replace(/^-+|-+$/g, \"\")\n .slice(0, 80) || \"note\"\n )\n}\n\nfunction gbrainTypeToKind(t: string | undefined): KnowledgeSourceKind {\n if (!t) return \"text\"\n if (t === \"url\" || t === \"link\") return \"url\"\n if (t === \"file\" || t === \"document\" || t === \"code\") return \"file\"\n if (t === \"connector\") return \"connector\"\n return \"text\"\n}\n\nfunction kindToGbrainType(kind: KnowledgeSourceKind): string {\n switch (kind) {\n case \"url\":\n return \"url\"\n case \"file\":\n return \"file\"\n case \"connector\":\n return \"connector\"\n case \"text\":\n default:\n return \"note\"\n }\n}\n\nfunction normalizeContent(content: KnowledgeIngestInput[\"content\"]): string {\n if (content === undefined) return \"\"\n if (typeof content === \"string\") return content\n return new TextDecoder().decode(content)\n}\n\n/** UTF-8 byte length without a `node:buffer` edge — runs on edge runtimes too. */\nfunction byteLength(text: string): number {\n return new TextEncoder().encode(text).byteLength\n}\n\nfunction parseDate(v: string | undefined): Date | undefined {\n if (v === undefined) return undefined\n const d = new Date(v)\n return Number.isNaN(d.getTime()) ? undefined : d\n}\n","/**\n * Typed environment module for the gbrain-doc knowledge adapter.\n *\n * Every `process.env` read in this package flows through here — no raw\n * `process.env.X` at a call site (mirrors the code-brain + files + corpus +\n * qdrant adapters' `env.ts`). The loader parses the ambient env into a typed,\n * validated config once, so the rest of the adapter is a pure function of its\n * inputs. This is the ONE place the gbrain-flavoured env names (`GBRAIN_*`)\n * live, keeping the backend idiom confined to the adapter.\n *\n * `GBRAIN_BEARER_TOKEN` is shared with `@agentproto/adapter-code-brain-gbrain`'s\n * HTTP backend by design — same gbrain server, same machine token — but the two\n * adapters never share a package edge; the token only ever meets gbrain at\n * runtime over HTTP.\n */\n\nimport type { GbrainDocAdapterConfig } from \"./adapter.js\"\n\nfunction parsePositiveInt(value: string | undefined, fallback: number): number {\n if (value === undefined || value === \"\") return fallback\n const parsed = Number.parseInt(value, 10)\n if (Number.isNaN(parsed) || parsed <= 0) return fallback\n return parsed\n}\n\nfunction nonEmpty(value: string | undefined): string | undefined {\n if (value === undefined) return undefined\n const trimmed = value.trim()\n return trimmed === \"\" ? undefined : trimmed\n}\n\n/** Config for the standalone gbrain-doc backend — a gbrain HTTP endpoint + a\n * machine bearer token. */\nexport interface GbrainDocKnowledgeEnv {\n /** gbrain HTTP base URL (`GBRAIN_ENDPOINT`); the `/mcp` JSON-RPC endpoint is\n * appended. Default `\"http://127.0.0.1:3132\"`. */\n readonly endpoint: string\n /** Machine bearer token (`GBRAIN_BEARER_TOKEN`). Required — the `/mcp`\n * endpoint is bearer-protected. */\n readonly bearerToken: string\n /** Per-request timeout (ms) (`GBRAIN_HTTP_TIMEOUT_MS`). Default 45_000. */\n readonly timeoutMs: number\n}\n\n/**\n * Load {@link GbrainDocKnowledgeEnv} from `process.env` with defaults.\n *\n * Throws when `GBRAIN_BEARER_TOKEN` is absent — the adapter cannot authenticate\n * to the `/mcp` endpoint without it, and failing at construction time is\n * clearer than a 401 on the first call.\n */\nexport function loadGbrainDocKnowledgeEnv(): GbrainDocKnowledgeEnv {\n const bearerToken = nonEmpty(process.env.GBRAIN_BEARER_TOKEN)\n if (bearerToken === undefined) {\n throw new Error(\n \"GBRAIN_BEARER_TOKEN is required for the gbrain-doc knowledge adapter; mint one via gbrain's admin API (OAuth 2.1 client_credentials) and set it in the environment.\",\n )\n }\n return {\n endpoint: nonEmpty(process.env.GBRAIN_ENDPOINT) ?? \"http://127.0.0.1:3132\",\n bearerToken,\n timeoutMs: parsePositiveInt(process.env.GBRAIN_HTTP_TIMEOUT_MS, 45_000),\n }\n}\n\n/** Project the typed env into a {@link GbrainDocAdapterConfig}. */\nexport function gbrainDocEnvToConfig(\n env: GbrainDocKnowledgeEnv,\n): GbrainDocAdapterConfig {\n return {\n endpoint: env.endpoint,\n bearerToken: env.bearerToken,\n timeoutMs: env.timeoutMs,\n }\n}\n","/**\n * Standalone wiring for {@link GbrainDocKnowledgeAdapter}.\n *\n * The adapter class itself is config-driven: it consumes a plain\n * {@link GbrainDocAdapterConfig} and knows nothing about `process.env`. This\n * module is the ONE place that binds it to the ambient environment — it reads\n * the typed `GBRAIN_*` env (via {@link loadGbrainDocKnowledgeEnv}) and\n * constructs an adapter from it, exactly the role the code-brain adapter's\n * provider factories play for their backends. Hosts that already hold a config\n * (e.g. a studio guild host resolving a per-KB `configRef` + vault secrets)\n * should construct `GbrainDocKnowledgeAdapter` directly and skip this factory.\n */\n\nimport { GbrainDocKnowledgeAdapter } from \"./adapter.js\"\nimport { gbrainDocEnvToConfig, loadGbrainDocKnowledgeEnv } from \"./env.js\"\n\n/**\n * Build a {@link GbrainDocKnowledgeAdapter} from the ambient `GBRAIN_*` env.\n * Throws (via {@link loadGbrainDocKnowledgeEnv}) when `GBRAIN_BEARER_TOKEN` is\n * absent. Each call returns a fresh adapter — the adapter holds no warm state\n * (stateless JSON-RPC over HTTP), so sharing an instance is a convenience, not\n * a requirement.\n */\nexport function createStandaloneGbrainDocAdapter(): GbrainDocKnowledgeAdapter {\n return new GbrainDocKnowledgeAdapter(\n gbrainDocEnvToConfig(loadGbrainDocKnowledgeEnv()),\n )\n}\n","import type { AdapterCatalog } from \"@agentproto/provider-kit\"\n\n/**\n * Family key used for the knowledge backend creds/ledger store path.\n *\n * The gbrain-doc engine is the document-retrieval sibling of the `files`\n * (BM25), `corpus` (AIP-10 composition), and `qdrant` (vector) backends — same\n * `knowledge` family, so all four surface through the same provider-kit\n * discovery convention (`@agentproto/adapter-knowledge-*`).\n */\nexport const KNOWLEDGE_FAMILY = \"knowledge\" as const\n\n/** The single backend slug this adapter provides. */\nexport const GBRAIN_DOC_SLUG = \"gbrain-doc\" as const\n\n/**\n * Static catalog of knowledge backends shipped by this adapter. The `gbrain-doc`\n * slug resolves from THIS package (`@agentproto/adapter-knowledge-gbrain-doc`) —\n * document retrieval over a gbrain server's `put_page` / `search` API, reached\n * over its JSON-RPC `/mcp` endpoint via pure `fetch` (no vendor SDK). Needs a\n * gbrain endpoint + a machine bearer token, so it requires a setup pass.\n *\n * DISTINCT from `@agentproto/adapter-code-brain-gbrain` (the code-graph gbrain\n * adapter) — same backend, different contract, no shared package edge.\n */\nexport const KNOWLEDGE_GBRAIN_DOC_CATALOG: AdapterCatalog = [\n {\n slug: GBRAIN_DOC_SLUG,\n name: \"gbrain (doc)\",\n description:\n \"Document knowledge retrieval over a gbrain server's put_page / search \" +\n \"API, reached over its JSON-RPC /mcp endpoint via pure fetch — no vendor \" +\n \"SDK. gbrain fuses lexical (tsvector) + semantic recall. Needs a gbrain \" +\n \"endpoint + a machine bearer token. Distinct from the code-graph gbrain \" +\n \"adapter.\",\n packageName: \"@agentproto/adapter-knowledge-gbrain-doc\",\n hint: \"gbrain · doc\",\n },\n]\n","/**\n * provider-kit family wiring for the gbrain-doc knowledge backend.\n *\n * The studio home-grown `createEngineRegistry`-based knowledge registry is NOT\n * ported (it was the guild resolution layer, which stays studio-side per the\n * Ph4 plan — the studio gbrain `descriptor` recursively resolves per-KB config\n * + reveals the vault bearer through that registry, and the retired E2B/sandbox\n * provisioning path stays studio-side too). Instead the gbrain-doc backend\n * registers as a provider-kit family (`TInfo = KnowledgeGbrainDocInfo`, `THandle\n * = KnowledgeHandle extends AdapterHandle`), reusing the exact consumer shape\n * the code-brain + files + corpus + qdrant adapters established — catalog +\n * resolver + a safe `info()` descriptor that NEVER carries a secret. Discovery\n * flows through the kit's `@agentproto/adapter-knowledge-*` naming convention.\n *\n * gbrain-doc needs a gbrain endpoint + a bearer token, so `requiresSetup` /\n * `authRequired` are both true and `provider()` (via\n * {@link createStandaloneGbrainDocAdapter}) throws when `GBRAIN_BEARER_TOKEN` is\n * absent.\n */\n\nimport type { IKnowledgeProvider } from \"@agentproto/knowledge-engine\"\nimport {\n makeAdapterResolver,\n type AdapterHandle,\n type AdapterResolver,\n} from \"@agentproto/provider-kit\"\nimport { GBRAIN_DOC_SLUG, KNOWLEDGE_GBRAIN_DOC_CATALOG } from \"./catalog.js\"\nimport { createStandaloneGbrainDocAdapter } from \"./standalone.js\"\n\n/** Safe descriptor for a knowledge backend — NEVER carries a secret. */\nexport interface KnowledgeGbrainDocInfo {\n readonly slug: string\n /** The retrieval engine this backend uses. */\n readonly engine: \"gbrain-doc\"\n readonly capabilities: {\n /** True — gbrain fuses lexical + semantic document retrieval. */\n readonly hybridSearch: boolean\n /** True — gbrain-doc needs a gbrain endpoint + a machine bearer token. */\n readonly needsCreds: boolean\n }\n}\n\n/** A resolved knowledge backend handle. */\nexport interface KnowledgeHandle extends AdapterHandle {\n /** Safe descriptor — NEVER a secret. */\n info(): KnowledgeGbrainDocInfo\n /**\n * Build the live {@link IKnowledgeProvider} from the ambient `GBRAIN_*` env.\n * Throws when `GBRAIN_BEARER_TOKEN` is absent — construction-time failure is\n * clearer than a 401 on the first query.\n */\n provider(): IKnowledgeProvider\n}\n\n/**\n * Resolve a catalog slug to a concrete knowledge handle. Throws for unknown\n * slugs so the kit's resolver wrapper folds the miss to `null`. `provider()` is\n * lazy — the `GBRAIN_BEARER_TOKEN` requirement is enforced only when a provider\n * is actually built, not at resolution time.\n */\nexport function resolveKnowledgeBackend(slug: string): KnowledgeHandle {\n const catalogEntry = KNOWLEDGE_GBRAIN_DOC_CATALOG.find(\n (entry) => entry.slug === slug,\n )\n if (catalogEntry === undefined) {\n throw new Error(`unknown knowledge backend slug: ${slug}`)\n }\n\n switch (slug) {\n case GBRAIN_DOC_SLUG: {\n return {\n slug,\n name: catalogEntry.name,\n description: catalogEntry.description,\n version: \"0.1.0\",\n requiresSetup: true,\n authRequired: true,\n // Health probe: build from env + hit GET /health. When the env is\n // absent, construction throws — fold that to \"not reachable\" rather\n // than propagating so a listing probe stays total.\n check: async () => {\n try {\n return await createStandaloneGbrainDocAdapter().healthCheck()\n } catch {\n return false\n }\n },\n info() {\n return {\n slug,\n engine: \"gbrain-doc\",\n capabilities: { hybridSearch: true, needsCreds: true },\n }\n },\n provider: () => createStandaloneGbrainDocAdapter(),\n }\n }\n }\n\n throw new Error(`unhandled knowledge backend slug: ${slug}`)\n}\n\n/**\n * Build the knowledge resolver: resolves a catalog slug to a handle, returning\n * `null` when the slug is unknown (via the kit's wrapper).\n */\nexport function makeKnowledgeGbrainDocResolver(): AdapterResolver<KnowledgeHandle> {\n return makeAdapterResolver<KnowledgeHandle>({\n load: async (slug: string): Promise<KnowledgeHandle> =>\n resolveKnowledgeBackend(slug),\n })\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@agentproto/adapter-knowledge-gbrain-doc",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0",
|
|
4
4
|
"description": "Knowledge adapter: implements @agentproto/knowledge-engine's IKnowledgeProvider over a gbrain server's document API (put_page / search) via pure fetch over its JSON-RPC /mcp endpoint. gbrain fuses lexical (tsvector) + semantic recall. Registers as a provider-kit family. No vendor SDK, no app coupling. Distinct from the code-graph gbrain adapter.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"agentproto",
|
|
@@ -48,7 +48,7 @@
|
|
|
48
48
|
},
|
|
49
49
|
"dependencies": {
|
|
50
50
|
"zod": "^4.6.5",
|
|
51
|
-
"@agentproto/knowledge-engine": "0.
|
|
51
|
+
"@agentproto/knowledge-engine": "0.3.0",
|
|
52
52
|
"@agentproto/provider-kit": "0.4.6"
|
|
53
53
|
},
|
|
54
54
|
"devDependencies": {
|