@dikolab/kbdb 0.1.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/LICENSE +15 -0
- package/README.md +270 -0
- package/dist/chunk-QCCN7OZH.mjs +82 -0
- package/dist/chunk-QCCN7OZH.mjs.map +7 -0
- package/dist/cli.cjs +3598 -0
- package/dist/cli.cjs.map +7 -0
- package/dist/cli.mjs +3537 -0
- package/dist/cli.mjs.map +7 -0
- package/dist/kbdb-worker.cjs +1659 -0
- package/dist/kbdb-worker.cjs.map +7 -0
- package/dist/mod.cjs +538 -0
- package/dist/mod.cjs.map +7 -0
- package/dist/mod.d.ts +3 -0
- package/dist/mod.mjs +507 -0
- package/dist/mod.mjs.map +7 -0
- package/dist/src/cli.d.ts +1 -0
- package/dist/src/shared/cli/constants/defaults.constant.d.ts +11 -0
- package/dist/src/shared/cli/constants/help-text.constant.d.ts +2 -0
- package/dist/src/shared/cli/functions/dispatch-command.function.d.ts +37 -0
- package/dist/src/shared/cli/functions/ensure-db.function.d.ts +11 -0
- package/dist/src/shared/cli/functions/error-to-message.function.d.ts +7 -0
- package/dist/src/shared/cli/functions/find-db.function.d.ts +13 -0
- package/dist/src/shared/cli/functions/format-output.function.d.ts +15 -0
- package/dist/src/shared/cli/functions/generate-help.function.d.ts +31 -0
- package/dist/src/shared/cli/functions/is-stdin-tty.function.d.ts +7 -0
- package/dist/src/shared/cli/functions/parse-args.function.d.ts +25 -0
- package/dist/src/shared/cli/functions/prompt-user.function.d.ts +13 -0
- package/dist/src/shared/cli/functions/run-agent-create.function.d.ts +58 -0
- package/dist/src/shared/cli/functions/run-agent-delete.function.d.ts +32 -0
- package/dist/src/shared/cli/functions/run-agent-get.function.d.ts +46 -0
- package/dist/src/shared/cli/functions/run-agent-list.function.d.ts +45 -0
- package/dist/src/shared/cli/functions/run-check.function.d.ts +64 -0
- package/dist/src/shared/cli/functions/run-cli.function.d.ts +39 -0
- package/dist/src/shared/cli/functions/run-content.function.d.ts +40 -0
- package/dist/src/shared/cli/functions/run-db-init.function.d.ts +23 -0
- package/dist/src/shared/cli/functions/run-db-migrate.function.d.ts +32 -0
- package/dist/src/shared/cli/functions/run-gc.function.d.ts +38 -0
- package/dist/src/shared/cli/functions/run-init.function.d.ts +27 -0
- package/dist/src/shared/cli/functions/run-learn.function.d.ts +46 -0
- package/dist/src/shared/cli/functions/run-migrate.function.d.ts +57 -0
- package/dist/src/shared/cli/functions/run-rebuild.function.d.ts +40 -0
- package/dist/src/shared/cli/functions/run-search.function.d.ts +39 -0
- package/dist/src/shared/cli/functions/run-skill-delete.function.d.ts +30 -0
- package/dist/src/shared/cli/functions/run-skill-get.function.d.ts +49 -0
- package/dist/src/shared/cli/functions/run-skill-learn.function.d.ts +36 -0
- package/dist/src/shared/cli/functions/run-skill-list.function.d.ts +43 -0
- package/dist/src/shared/cli/functions/run-status.function.d.ts +22 -0
- package/dist/src/shared/cli/functions/run-unlearn.function.d.ts +45 -0
- package/dist/src/shared/cli/index.d.ts +35 -0
- package/dist/src/shared/cli/typings/cli-options.interface.d.ts +53 -0
- package/dist/src/shared/cli/typings/command-result.model.d.ts +15 -0
- package/dist/src/shared/cli/typings/learn-result.model.d.ts +11 -0
- package/dist/src/shared/cli/typings/search-display.model.d.ts +17 -0
- package/dist/src/shared/dir-resolver/functions/resolve-base-dir.function.d.ts +3 -0
- package/dist/src/shared/dir-resolver/functions/resolve-wasm-dir.function.d.ts +1 -0
- package/dist/src/shared/dir-resolver/functions/resolve-worker-script.function.d.ts +2 -0
- package/dist/src/shared/dir-resolver/index.d.ts +4 -0
- package/dist/src/shared/dir-resolver/typings/base-dir.interface.d.ts +4 -0
- package/dist/src/shared/hash/functions/compute-sha256.d.ts +10 -0
- package/dist/src/shared/hash/index.d.ts +1 -0
- package/dist/src/shared/mcp/classes/mcp-server.class.d.ts +55 -0
- package/dist/src/shared/mcp/constants/mcp-error-codes.constant.d.ts +26 -0
- package/dist/src/shared/mcp/functions/create-mcp-server.function.d.ts +11 -0
- package/dist/src/shared/mcp/functions/create-prompt-definitions.function.d.ts +41 -0
- package/dist/src/shared/mcp/functions/create-resource-templates.function.d.ts +7 -0
- package/dist/src/shared/mcp/functions/create-tool-definitions.function.d.ts +7 -0
- package/dist/src/shared/mcp/functions/extract-skill-arguments.function.d.ts +13 -0
- package/dist/src/shared/mcp/functions/handle-agent-create.function.d.ts +29 -0
- package/dist/src/shared/mcp/functions/handle-agent-delete.function.d.ts +28 -0
- package/dist/src/shared/mcp/functions/handle-agent-get.function.d.ts +29 -0
- package/dist/src/shared/mcp/functions/handle-agent-list.function.d.ts +31 -0
- package/dist/src/shared/mcp/functions/handle-completion.function.d.ts +58 -0
- package/dist/src/shared/mcp/functions/handle-prompt-get.function.d.ts +23 -0
- package/dist/src/shared/mcp/functions/handle-resource-read.function.d.ts +26 -0
- package/dist/src/shared/mcp/functions/handle-roots-list.function.d.ts +21 -0
- package/dist/src/shared/mcp/functions/handle-tool-call.function.d.ts +26 -0
- package/dist/src/shared/mcp/functions/parse-skill-content.function.d.ts +15 -0
- package/dist/src/shared/mcp/functions/serialize-skill-content.function.d.ts +9 -0
- package/dist/src/shared/mcp/functions/should-emit-log.function.d.ts +20 -0
- package/dist/src/shared/mcp/index.d.ts +9 -0
- package/dist/src/shared/mcp/typings/agent-types.interface.d.ts +38 -0
- package/dist/src/shared/mcp/typings/log-types.interface.d.ts +17 -0
- package/dist/src/shared/mcp/typings/mcp-client.interface.d.ts +217 -0
- package/dist/src/shared/mcp/typings/mcp-types.interface.d.ts +149 -0
- package/dist/src/shared/mcp/typings/prompt-types.interface.d.ts +37 -0
- package/dist/src/shared/mcp/typings/remove-section-result.model.d.ts +10 -0
- package/dist/src/shared/mcp/typings/sampling-types.interface.d.ts +46 -0
- package/dist/src/shared/mcp/typings/skill-types.interface.d.ts +28 -0
- package/dist/src/shared/mod.d.ts +1 -0
- package/dist/src/shared/platform/functions/get-ipc-path.function.d.ts +11 -0
- package/dist/src/shared/platform/functions/get-tmpdir.function.d.ts +4 -0
- package/dist/src/shared/platform/functions/is-process-alive.function.d.ts +10 -0
- package/dist/src/shared/platform/index.d.ts +3 -0
- package/dist/src/shared/runtime/functions/detect-runtime.d.ts +8 -0
- package/dist/src/shared/runtime/functions/get-args.d.ts +7 -0
- package/dist/src/shared/runtime/index.d.ts +3 -0
- package/dist/src/shared/runtime/typings/runtime.d.ts +2 -0
- package/dist/src/shared/version/constants/version.constant.d.ts +2 -0
- package/dist/src/shared/version/index.d.ts +1 -0
- package/dist/src/shared/wasm-codec/functions/decode-compose-output.function.d.ts +5 -0
- package/dist/src/shared/wasm-codec/functions/decode-document-manifest-list.function.d.ts +14 -0
- package/dist/src/shared/wasm-codec/functions/decode-document-manifest.function.d.ts +40 -0
- package/dist/src/shared/wasm-codec/functions/decode-f32.function.d.ts +2 -0
- package/dist/src/shared/wasm-codec/functions/decode-key-value-text.function.d.ts +1 -0
- package/dist/src/shared/wasm-codec/functions/decode-remove-flag.function.d.ts +1 -0
- package/dist/src/shared/wasm-codec/functions/decode-scored-results.function.d.ts +10 -0
- package/dist/src/shared/wasm-codec/functions/decode-section-record-list.function.d.ts +13 -0
- package/dist/src/shared/wasm-codec/functions/decode-section-records.function.d.ts +50 -0
- package/dist/src/shared/wasm-codec/functions/decode-string.function.d.ts +5 -0
- package/dist/src/shared/wasm-codec/functions/decode-u32.function.d.ts +2 -0
- package/dist/src/shared/wasm-codec/functions/decode-u64.function.d.ts +2 -0
- package/dist/src/shared/wasm-codec/functions/encode-add-section-params.function.d.ts +10 -0
- package/dist/src/shared/wasm-codec/functions/encode-group-params.function.d.ts +10 -0
- package/dist/src/shared/wasm-codec/functions/encode-identifier-list.function.d.ts +1 -0
- package/dist/src/shared/wasm-codec/functions/encode-kbid-list.function.d.ts +1 -0
- package/dist/src/shared/wasm-codec/functions/encode-option-string.function.d.ts +1 -0
- package/dist/src/shared/wasm-codec/functions/encode-search-params.function.d.ts +1 -0
- package/dist/src/shared/wasm-codec/functions/encode-section-type.function.d.ts +1 -0
- package/dist/src/shared/wasm-codec/functions/encode-string.function.d.ts +1 -0
- package/dist/src/shared/wasm-codec/functions/encode-type-filter-param.function.d.ts +11 -0
- package/dist/src/shared/wasm-codec/functions/encode-u32.function.d.ts +1 -0
- package/dist/src/shared/wasm-codec/functions/encode-update-section-params.function.d.ts +2 -0
- package/dist/src/shared/wasm-codec/index.d.ts +29 -0
- package/dist/src/shared/worker-client/classes/worker-client.class.d.ts +230 -0
- package/dist/src/shared/worker-client/functions/compute-context-id.function.d.ts +11 -0
- package/dist/src/shared/worker-client/functions/create-worker-client.function.d.ts +18 -0
- package/dist/src/shared/worker-client/functions/discover-daemon.function.d.ts +14 -0
- package/dist/src/shared/worker-client/functions/resolve-db-path.function.d.ts +11 -0
- package/dist/src/shared/worker-client/functions/spawn-daemon.function.d.ts +11 -0
- package/dist/src/shared/worker-client/functions/wait-for-daemon.function.d.ts +13 -0
- package/dist/src/shared/worker-client/index.d.ts +22 -0
- package/dist/src/shared/worker-client/typings/add-section-result.model.d.ts +22 -0
- package/dist/src/shared/worker-client/typings/content-result.model.d.ts +12 -0
- package/dist/src/shared/worker-client/typings/daemon-info.model.d.ts +7 -0
- package/dist/src/shared/worker-client/typings/gc-result.model.d.ts +12 -0
- package/dist/src/shared/worker-client/typings/integrity-check-result.model.d.ts +36 -0
- package/dist/src/shared/worker-client/typings/migrate-result.model.d.ts +11 -0
- package/dist/src/shared/worker-client/typings/rebuild-result.model.d.ts +12 -0
- package/dist/src/shared/worker-client/typings/remove-section-result.model.d.ts +7 -0
- package/dist/src/shared/worker-client/typings/search-params.model.d.ts +12 -0
- package/dist/src/shared/worker-client/typings/search-result.model.d.ts +14 -0
- package/dist/src/shared/worker-client/typings/section.model.d.ts +26 -0
- package/dist/src/shared/worker-client/typings/status-result.model.d.ts +14 -0
- package/dist/src/shared/worker-client/typings/version-status.model.d.ts +24 -0
- package/dist/src/shared/worker-client/typings/worker-client-error.interface.d.ts +8 -0
- package/dist/src/shared/worker-client/typings/worker-client-options.interface.d.ts +30 -0
- package/dist/src/shared/worker-daemon/classes/worker-daemon.class.d.ts +147 -0
- package/dist/src/shared/worker-daemon/constants/daemon-defaults.constant.d.ts +24 -0
- package/dist/src/shared/worker-daemon/functions/create-host-imports.function.d.ts +68 -0
- package/dist/src/shared/worker-daemon/functions/create-ipc-server.function.d.ts +18 -0
- package/dist/src/shared/worker-daemon/functions/load-wasm-modules.function.d.ts +19 -0
- package/dist/src/shared/worker-daemon/functions/read-config.function.d.ts +12 -0
- package/dist/src/shared/worker-daemon/functions/run-worker.function.d.ts +26 -0
- package/dist/src/shared/worker-daemon/functions/start-daemon.function.d.ts +13 -0
- package/dist/src/shared/worker-daemon/index.d.ts +9 -0
- package/dist/src/shared/worker-daemon/typings/daemon-config.interface.d.ts +13 -0
- package/dist/src/shared/worker-daemon/typings/ipc-handler.interface.d.ts +36 -0
- package/dist/src/shared/worker-daemon/typings/wasm-modules.interface.d.ts +7 -0
- package/dist/src/worker.d.ts +1 -0
- package/dist/vitest.config.d.ts +2 -0
- package/dist/worker.mjs +1615 -0
- package/dist/worker.mjs.map +7 -0
- package/mod.ts +17 -0
- package/package.json +85 -0
- package/src/cli.ts +62 -0
- package/src/shared/cli/constants/defaults.constant.ts +19 -0
- package/src/shared/cli/constants/help-text.constant.ts +4 -0
- package/src/shared/cli/functions/dispatch-command.function.ts +338 -0
- package/src/shared/cli/functions/ensure-db.function.ts +21 -0
- package/src/shared/cli/functions/error-to-message.function.ts +9 -0
- package/src/shared/cli/functions/find-db.function.ts +20 -0
- package/src/shared/cli/functions/format-output.function.ts +64 -0
- package/src/shared/cli/functions/generate-help.function.ts +599 -0
- package/src/shared/cli/functions/is-stdin-tty.function.ts +12 -0
- package/src/shared/cli/functions/parse-args.function.ts +133 -0
- package/src/shared/cli/functions/prompt-user.function.ts +36 -0
- package/src/shared/cli/functions/run-agent-create.function.ts +114 -0
- package/src/shared/cli/functions/run-agent-delete.function.ts +47 -0
- package/src/shared/cli/functions/run-agent-get.function.ts +166 -0
- package/src/shared/cli/functions/run-agent-list.function.ts +58 -0
- package/src/shared/cli/functions/run-check.function.ts +78 -0
- package/src/shared/cli/functions/run-cli.function.ts +299 -0
- package/src/shared/cli/functions/run-content.function.ts +47 -0
- package/src/shared/cli/functions/run-db-init.function.ts +44 -0
- package/src/shared/cli/functions/run-db-migrate.function.ts +40 -0
- package/src/shared/cli/functions/run-gc.function.ts +45 -0
- package/src/shared/cli/functions/run-init.function.ts +91 -0
- package/src/shared/cli/functions/run-learn.function.ts +171 -0
- package/src/shared/cli/functions/run-migrate.function.ts +85 -0
- package/src/shared/cli/functions/run-rebuild.function.ts +47 -0
- package/src/shared/cli/functions/run-search.function.ts +62 -0
- package/src/shared/cli/functions/run-skill-delete.function.ts +47 -0
- package/src/shared/cli/functions/run-skill-get.function.ts +90 -0
- package/src/shared/cli/functions/run-skill-learn.function.ts +70 -0
- package/src/shared/cli/functions/run-skill-list.function.ts +74 -0
- package/src/shared/cli/functions/run-status.function.ts +29 -0
- package/src/shared/cli/functions/run-unlearn.function.ts +58 -0
- package/src/shared/cli/index.ts +48 -0
- package/src/shared/cli/typings/cli-options.interface.ts +55 -0
- package/src/shared/cli/typings/command-result.model.ts +15 -0
- package/src/shared/cli/typings/learn-result.model.ts +11 -0
- package/src/shared/cli/typings/search-display.model.ts +17 -0
- package/src/shared/dir-resolver/functions/resolve-base-dir.function.ts +25 -0
- package/src/shared/dir-resolver/functions/resolve-wasm-dir.function.ts +5 -0
- package/src/shared/dir-resolver/functions/resolve-worker-script.function.ts +13 -0
- package/src/shared/dir-resolver/index.ts +7 -0
- package/src/shared/dir-resolver/typings/base-dir.interface.ts +4 -0
- package/src/shared/hash/functions/compute-sha256.ts +17 -0
- package/src/shared/hash/index.ts +1 -0
- package/src/shared/mcp/classes/mcp-server.class.ts +448 -0
- package/src/shared/mcp/constants/mcp-error-codes.constant.ts +30 -0
- package/src/shared/mcp/functions/create-mcp-server.function.ts +14 -0
- package/src/shared/mcp/functions/create-prompt-definitions.function.ts +102 -0
- package/src/shared/mcp/functions/create-resource-templates.function.ts +23 -0
- package/src/shared/mcp/functions/create-tool-definitions.function.ts +401 -0
- package/src/shared/mcp/functions/extract-skill-arguments.function.ts +27 -0
- package/src/shared/mcp/functions/handle-agent-create.function.ts +116 -0
- package/src/shared/mcp/functions/handle-agent-delete.function.ts +50 -0
- package/src/shared/mcp/functions/handle-agent-get.function.ts +160 -0
- package/src/shared/mcp/functions/handle-agent-list.function.ts +50 -0
- package/src/shared/mcp/functions/handle-completion.function.ts +114 -0
- package/src/shared/mcp/functions/handle-prompt-get.function.ts +214 -0
- package/src/shared/mcp/functions/handle-resource-read.function.ts +56 -0
- package/src/shared/mcp/functions/handle-roots-list.function.ts +29 -0
- package/src/shared/mcp/functions/handle-tool-call.function.ts +464 -0
- package/src/shared/mcp/functions/parse-skill-content.function.ts +38 -0
- package/src/shared/mcp/functions/serialize-skill-content.function.ts +12 -0
- package/src/shared/mcp/functions/should-emit-log.function.ts +38 -0
- package/src/shared/mcp/index.ts +28 -0
- package/src/shared/mcp/typings/agent-types.interface.ts +39 -0
- package/src/shared/mcp/typings/log-types.interface.ts +26 -0
- package/src/shared/mcp/typings/mcp-client.interface.ts +252 -0
- package/src/shared/mcp/typings/mcp-types.interface.ts +158 -0
- package/src/shared/mcp/typings/prompt-types.interface.ts +39 -0
- package/src/shared/mcp/typings/remove-section-result.model.ts +10 -0
- package/src/shared/mcp/typings/sampling-types.interface.ts +48 -0
- package/src/shared/mcp/typings/skill-types.interface.ts +29 -0
- package/src/shared/mod.ts +1 -0
- package/src/shared/platform/functions/get-ipc-path.function.ts +19 -0
- package/src/shared/platform/functions/get-tmpdir.function.ts +8 -0
- package/src/shared/platform/functions/is-process-alive.function.ts +17 -0
- package/src/shared/platform/index.ts +3 -0
- package/src/shared/runtime/functions/detect-runtime.ts +14 -0
- package/src/shared/runtime/functions/get-args.ts +16 -0
- package/src/shared/runtime/index.ts +3 -0
- package/src/shared/runtime/typings/runtime.ts +2 -0
- package/src/shared/version/constants/version.constant.ts +2 -0
- package/src/shared/version/index.ts +1 -0
- package/src/shared/wasm-codec/functions/decode-compose-output.function.ts +16 -0
- package/src/shared/wasm-codec/functions/decode-document-manifest-list.function.ts +70 -0
- package/src/shared/wasm-codec/functions/decode-document-manifest.function.ts +87 -0
- package/src/shared/wasm-codec/functions/decode-f32.function.ts +16 -0
- package/src/shared/wasm-codec/functions/decode-key-value-text.function.ts +15 -0
- package/src/shared/wasm-codec/functions/decode-remove-flag.function.ts +3 -0
- package/src/shared/wasm-codec/functions/decode-scored-results.function.ts +54 -0
- package/src/shared/wasm-codec/functions/decode-section-record-list.function.ts +20 -0
- package/src/shared/wasm-codec/functions/decode-section-records.function.ts +162 -0
- package/src/shared/wasm-codec/functions/decode-string.function.ts +22 -0
- package/src/shared/wasm-codec/functions/decode-u32.function.ts +16 -0
- package/src/shared/wasm-codec/functions/decode-u64.function.ts +16 -0
- package/src/shared/wasm-codec/functions/encode-add-section-params.function.ts +34 -0
- package/src/shared/wasm-codec/functions/encode-group-params.function.ts +28 -0
- package/src/shared/wasm-codec/functions/encode-identifier-list.function.ts +17 -0
- package/src/shared/wasm-codec/functions/encode-kbid-list.function.ts +17 -0
- package/src/shared/wasm-codec/functions/encode-option-string.function.ts +14 -0
- package/src/shared/wasm-codec/functions/encode-search-params.function.ts +9 -0
- package/src/shared/wasm-codec/functions/encode-section-type.function.ts +18 -0
- package/src/shared/wasm-codec/functions/encode-string.function.ts +9 -0
- package/src/shared/wasm-codec/functions/encode-type-filter-param.function.ts +13 -0
- package/src/shared/wasm-codec/functions/encode-u32.function.ts +5 -0
- package/src/shared/wasm-codec/functions/encode-update-section-params.function.ts +16 -0
- package/src/shared/wasm-codec/index.ts +36 -0
- package/src/shared/worker-client/classes/worker-client.class.ts +427 -0
- package/src/shared/worker-client/functions/compute-context-id.function.ts +18 -0
- package/src/shared/worker-client/functions/create-worker-client.function.ts +70 -0
- package/src/shared/worker-client/functions/discover-daemon.function.ts +47 -0
- package/src/shared/worker-client/functions/resolve-db-path.function.ts +21 -0
- package/src/shared/worker-client/functions/spawn-daemon.function.ts +35 -0
- package/src/shared/worker-client/functions/wait-for-daemon.function.ts +34 -0
- package/src/shared/worker-client/index.ts +31 -0
- package/src/shared/worker-client/typings/add-section-result.model.ts +22 -0
- package/src/shared/worker-client/typings/content-result.model.ts +12 -0
- package/src/shared/worker-client/typings/daemon-info.model.ts +7 -0
- package/src/shared/worker-client/typings/gc-result.model.ts +12 -0
- package/src/shared/worker-client/typings/integrity-check-result.model.ts +43 -0
- package/src/shared/worker-client/typings/migrate-result.model.ts +11 -0
- package/src/shared/worker-client/typings/rebuild-result.model.ts +12 -0
- package/src/shared/worker-client/typings/remove-section-result.model.ts +7 -0
- package/src/shared/worker-client/typings/search-params.model.ts +12 -0
- package/src/shared/worker-client/typings/search-result.model.ts +14 -0
- package/src/shared/worker-client/typings/section.model.ts +27 -0
- package/src/shared/worker-client/typings/status-result.model.ts +14 -0
- package/src/shared/worker-client/typings/version-status.model.ts +28 -0
- package/src/shared/worker-client/typings/worker-client-error.interface.ts +8 -0
- package/src/shared/worker-client/typings/worker-client-options.interface.ts +30 -0
- package/src/shared/worker-daemon/classes/worker-daemon.class.ts +1001 -0
- package/src/shared/worker-daemon/constants/daemon-defaults.constant.ts +29 -0
- package/src/shared/worker-daemon/functions/create-host-imports.function.ts +312 -0
- package/src/shared/worker-daemon/functions/create-ipc-server.function.ts +83 -0
- package/src/shared/worker-daemon/functions/load-wasm-modules.function.ts +98 -0
- package/src/shared/worker-daemon/functions/read-config.function.ts +83 -0
- package/src/shared/worker-daemon/functions/run-worker.function.ts +57 -0
- package/src/shared/worker-daemon/functions/start-daemon.function.ts +74 -0
- package/src/shared/worker-daemon/index.ts +16 -0
- package/src/shared/worker-daemon/typings/daemon-config.interface.ts +13 -0
- package/src/shared/worker-daemon/typings/ipc-handler.interface.ts +39 -0
- package/src/shared/worker-daemon/typings/wasm-modules.interface.ts +7 -0
- package/src/worker.ts +34 -0
|
@@ -0,0 +1,401 @@
|
|
|
1
|
+
import type { McpToolDefinition } from '../typings/mcp-types.interface.ts';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Returns the full list of MCP tool definitions exposed by the
|
|
5
|
+
* knowledge-base server. Each definition includes the tool name,
|
|
6
|
+
* a human-readable description, and a JSON Schema for its inputs.
|
|
7
|
+
*/
|
|
8
|
+
export function createToolDefinitions(): McpToolDefinition[] {
|
|
9
|
+
return [
|
|
10
|
+
{
|
|
11
|
+
name: 'search',
|
|
12
|
+
description:
|
|
13
|
+
'Search the knowledge base for relevant' +
|
|
14
|
+
' sections using natural language queries.',
|
|
15
|
+
inputSchema: {
|
|
16
|
+
type: 'object',
|
|
17
|
+
properties: {
|
|
18
|
+
query: {
|
|
19
|
+
type: 'string',
|
|
20
|
+
description: 'Search query text',
|
|
21
|
+
},
|
|
22
|
+
mode: {
|
|
23
|
+
type: 'string',
|
|
24
|
+
enum: ['sections', 'documents', 'stats'],
|
|
25
|
+
description: 'Search mode (default: sections)',
|
|
26
|
+
},
|
|
27
|
+
limit: {
|
|
28
|
+
type: 'number',
|
|
29
|
+
description: 'Maximum results (default: 20)',
|
|
30
|
+
},
|
|
31
|
+
},
|
|
32
|
+
required: ['query'],
|
|
33
|
+
},
|
|
34
|
+
annotations: {
|
|
35
|
+
title: 'Search KB',
|
|
36
|
+
readOnlyHint: true,
|
|
37
|
+
destructiveHint: false,
|
|
38
|
+
idempotentHint: true,
|
|
39
|
+
},
|
|
40
|
+
},
|
|
41
|
+
{
|
|
42
|
+
name: 'learn',
|
|
43
|
+
description: 'Add a text section to the knowledge base.',
|
|
44
|
+
inputSchema: {
|
|
45
|
+
type: 'object',
|
|
46
|
+
properties: {
|
|
47
|
+
content: {
|
|
48
|
+
type: 'string',
|
|
49
|
+
description: 'Text content to add',
|
|
50
|
+
},
|
|
51
|
+
type: {
|
|
52
|
+
type: 'string',
|
|
53
|
+
description:
|
|
54
|
+
'MIME type (default: text/markdown).' +
|
|
55
|
+
' Use image/* for images.',
|
|
56
|
+
},
|
|
57
|
+
title: {
|
|
58
|
+
type: 'string',
|
|
59
|
+
description:
|
|
60
|
+
'Section title.' + ' Required for image/* types.',
|
|
61
|
+
},
|
|
62
|
+
description: {
|
|
63
|
+
type: 'string',
|
|
64
|
+
description: 'Optional section description',
|
|
65
|
+
},
|
|
66
|
+
docid: {
|
|
67
|
+
type: 'string',
|
|
68
|
+
description: 'Document ID to group under',
|
|
69
|
+
},
|
|
70
|
+
},
|
|
71
|
+
required: ['content'],
|
|
72
|
+
},
|
|
73
|
+
annotations: {
|
|
74
|
+
title: 'Import Content',
|
|
75
|
+
readOnlyHint: false,
|
|
76
|
+
destructiveHint: false,
|
|
77
|
+
idempotentHint: true,
|
|
78
|
+
},
|
|
79
|
+
},
|
|
80
|
+
{
|
|
81
|
+
name: 'unlearn',
|
|
82
|
+
description:
|
|
83
|
+
'Remove a section from the knowledge base' +
|
|
84
|
+
' by its kb-id.',
|
|
85
|
+
inputSchema: {
|
|
86
|
+
type: 'object',
|
|
87
|
+
properties: {
|
|
88
|
+
kbid: {
|
|
89
|
+
type: 'string',
|
|
90
|
+
description: 'Knowledge base ID of the section',
|
|
91
|
+
},
|
|
92
|
+
},
|
|
93
|
+
required: ['kbid'],
|
|
94
|
+
},
|
|
95
|
+
annotations: {
|
|
96
|
+
title: 'Remove Section',
|
|
97
|
+
readOnlyHint: false,
|
|
98
|
+
destructiveHint: true,
|
|
99
|
+
idempotentHint: true,
|
|
100
|
+
},
|
|
101
|
+
},
|
|
102
|
+
{
|
|
103
|
+
name: 'retrieve',
|
|
104
|
+
description:
|
|
105
|
+
'Retrieve a section or document by ID.' +
|
|
106
|
+
' Provide kbid or docid.',
|
|
107
|
+
inputSchema: {
|
|
108
|
+
type: 'object',
|
|
109
|
+
properties: {
|
|
110
|
+
kbid: {
|
|
111
|
+
type: 'string',
|
|
112
|
+
description: 'Section kb-id',
|
|
113
|
+
},
|
|
114
|
+
docid: {
|
|
115
|
+
type: 'string',
|
|
116
|
+
description: 'Document ID',
|
|
117
|
+
},
|
|
118
|
+
},
|
|
119
|
+
},
|
|
120
|
+
annotations: {
|
|
121
|
+
title: 'Fetch Content',
|
|
122
|
+
readOnlyHint: true,
|
|
123
|
+
destructiveHint: false,
|
|
124
|
+
idempotentHint: true,
|
|
125
|
+
},
|
|
126
|
+
},
|
|
127
|
+
{
|
|
128
|
+
name: 'status',
|
|
129
|
+
description:
|
|
130
|
+
'Get database metadata including document count,' +
|
|
131
|
+
' section count, index size, and cache statistics.',
|
|
132
|
+
inputSchema: {
|
|
133
|
+
type: 'object',
|
|
134
|
+
properties: {},
|
|
135
|
+
},
|
|
136
|
+
annotations: {
|
|
137
|
+
title: 'DB Status',
|
|
138
|
+
readOnlyHint: true,
|
|
139
|
+
destructiveHint: false,
|
|
140
|
+
idempotentHint: true,
|
|
141
|
+
},
|
|
142
|
+
},
|
|
143
|
+
{
|
|
144
|
+
name: 'content',
|
|
145
|
+
description:
|
|
146
|
+
'Compose a rendered Markdown document from one or' +
|
|
147
|
+
' more kbid or docid identifiers.',
|
|
148
|
+
inputSchema: {
|
|
149
|
+
type: 'object',
|
|
150
|
+
properties: {
|
|
151
|
+
ids: {
|
|
152
|
+
type: 'array',
|
|
153
|
+
items: { type: 'string' },
|
|
154
|
+
description:
|
|
155
|
+
'One or more kbid or docid identifiers' +
|
|
156
|
+
' (may be mixed)',
|
|
157
|
+
},
|
|
158
|
+
},
|
|
159
|
+
required: ['ids'],
|
|
160
|
+
},
|
|
161
|
+
annotations: {
|
|
162
|
+
title: 'Compose Content',
|
|
163
|
+
readOnlyHint: true,
|
|
164
|
+
destructiveHint: false,
|
|
165
|
+
idempotentHint: true,
|
|
166
|
+
},
|
|
167
|
+
},
|
|
168
|
+
{
|
|
169
|
+
name: 'check',
|
|
170
|
+
description:
|
|
171
|
+
'Verify the integrity of the knowledge base.' +
|
|
172
|
+
' Reports checksum mismatches, orphan sections,' +
|
|
173
|
+
' broken references, and circular reference chains.',
|
|
174
|
+
inputSchema: {
|
|
175
|
+
type: 'object',
|
|
176
|
+
properties: {},
|
|
177
|
+
},
|
|
178
|
+
annotations: {
|
|
179
|
+
title: 'Integrity Check',
|
|
180
|
+
readOnlyHint: true,
|
|
181
|
+
destructiveHint: false,
|
|
182
|
+
idempotentHint: true,
|
|
183
|
+
},
|
|
184
|
+
},
|
|
185
|
+
{
|
|
186
|
+
name: 'gc',
|
|
187
|
+
description:
|
|
188
|
+
'Remove unreferenced sections from the knowledge' +
|
|
189
|
+
' base. A section is eligible when no document' +
|
|
190
|
+
' manifest references it.',
|
|
191
|
+
inputSchema: {
|
|
192
|
+
type: 'object',
|
|
193
|
+
properties: {},
|
|
194
|
+
},
|
|
195
|
+
annotations: {
|
|
196
|
+
title: 'Garbage Collect',
|
|
197
|
+
readOnlyHint: false,
|
|
198
|
+
destructiveHint: true,
|
|
199
|
+
idempotentHint: false,
|
|
200
|
+
},
|
|
201
|
+
},
|
|
202
|
+
{
|
|
203
|
+
name: 'rebuild',
|
|
204
|
+
description:
|
|
205
|
+
'Reconstruct all index files from section files' +
|
|
206
|
+
' and document manifests on disk. Use this to' +
|
|
207
|
+
' recover from index corruption.',
|
|
208
|
+
inputSchema: {
|
|
209
|
+
type: 'object',
|
|
210
|
+
properties: {},
|
|
211
|
+
},
|
|
212
|
+
annotations: {
|
|
213
|
+
title: 'Rebuild Indexes',
|
|
214
|
+
readOnlyHint: false,
|
|
215
|
+
destructiveHint: false,
|
|
216
|
+
idempotentHint: false,
|
|
217
|
+
},
|
|
218
|
+
},
|
|
219
|
+
{
|
|
220
|
+
name: 'skill-learn',
|
|
221
|
+
description:
|
|
222
|
+
'Create or update a skill definition.' +
|
|
223
|
+
' Skills are reusable AI agent capabilities' +
|
|
224
|
+
' with template placeholders.',
|
|
225
|
+
inputSchema: {
|
|
226
|
+
type: 'object',
|
|
227
|
+
properties: {
|
|
228
|
+
name: {
|
|
229
|
+
type: 'string',
|
|
230
|
+
description: 'Skill name',
|
|
231
|
+
},
|
|
232
|
+
description: {
|
|
233
|
+
type: 'string',
|
|
234
|
+
description: 'Skill description',
|
|
235
|
+
},
|
|
236
|
+
body: {
|
|
237
|
+
type: 'string',
|
|
238
|
+
description:
|
|
239
|
+
'Skill body template.' +
|
|
240
|
+
' Use {{argName}} for placeholders.',
|
|
241
|
+
},
|
|
242
|
+
},
|
|
243
|
+
required: ['name', 'body'],
|
|
244
|
+
},
|
|
245
|
+
annotations: {
|
|
246
|
+
title: 'Create Skill',
|
|
247
|
+
readOnlyHint: false,
|
|
248
|
+
destructiveHint: false,
|
|
249
|
+
idempotentHint: true,
|
|
250
|
+
},
|
|
251
|
+
},
|
|
252
|
+
{
|
|
253
|
+
name: 'skill-list',
|
|
254
|
+
description: 'List all skills in the knowledge base.',
|
|
255
|
+
inputSchema: {
|
|
256
|
+
type: 'object',
|
|
257
|
+
properties: {},
|
|
258
|
+
},
|
|
259
|
+
annotations: {
|
|
260
|
+
title: 'List Skills',
|
|
261
|
+
readOnlyHint: true,
|
|
262
|
+
destructiveHint: false,
|
|
263
|
+
idempotentHint: true,
|
|
264
|
+
},
|
|
265
|
+
},
|
|
266
|
+
{
|
|
267
|
+
name: 'skill-get',
|
|
268
|
+
description: 'Get a skill definition by name or kbid.',
|
|
269
|
+
inputSchema: {
|
|
270
|
+
type: 'object',
|
|
271
|
+
properties: {
|
|
272
|
+
name: {
|
|
273
|
+
type: 'string',
|
|
274
|
+
description: 'Skill name',
|
|
275
|
+
},
|
|
276
|
+
kbid: {
|
|
277
|
+
type: 'string',
|
|
278
|
+
description: 'Knowledge base ID',
|
|
279
|
+
},
|
|
280
|
+
},
|
|
281
|
+
},
|
|
282
|
+
annotations: {
|
|
283
|
+
title: 'Get Skill',
|
|
284
|
+
readOnlyHint: true,
|
|
285
|
+
destructiveHint: false,
|
|
286
|
+
idempotentHint: true,
|
|
287
|
+
},
|
|
288
|
+
},
|
|
289
|
+
{
|
|
290
|
+
name: 'skill-delete',
|
|
291
|
+
description: 'Delete a skill by its kbid.',
|
|
292
|
+
inputSchema: {
|
|
293
|
+
type: 'object',
|
|
294
|
+
properties: {
|
|
295
|
+
kbid: {
|
|
296
|
+
type: 'string',
|
|
297
|
+
description: 'Knowledge base ID',
|
|
298
|
+
},
|
|
299
|
+
},
|
|
300
|
+
required: ['kbid'],
|
|
301
|
+
},
|
|
302
|
+
annotations: {
|
|
303
|
+
title: 'Delete Skill',
|
|
304
|
+
readOnlyHint: false,
|
|
305
|
+
destructiveHint: true,
|
|
306
|
+
idempotentHint: true,
|
|
307
|
+
},
|
|
308
|
+
},
|
|
309
|
+
{
|
|
310
|
+
name: 'agent-create',
|
|
311
|
+
description:
|
|
312
|
+
'Create an AI agent with a persona and' +
|
|
313
|
+
' optional skill references.',
|
|
314
|
+
inputSchema: {
|
|
315
|
+
type: 'object',
|
|
316
|
+
properties: {
|
|
317
|
+
name: {
|
|
318
|
+
type: 'string',
|
|
319
|
+
description: 'Agent name',
|
|
320
|
+
},
|
|
321
|
+
description: {
|
|
322
|
+
type: 'string',
|
|
323
|
+
description: 'Agent description',
|
|
324
|
+
},
|
|
325
|
+
persona: {
|
|
326
|
+
type: 'string',
|
|
327
|
+
description: 'Agent persona prompt',
|
|
328
|
+
},
|
|
329
|
+
skills: {
|
|
330
|
+
type: 'array',
|
|
331
|
+
items: { type: 'string' },
|
|
332
|
+
description: 'Skill kbid references to attach',
|
|
333
|
+
},
|
|
334
|
+
},
|
|
335
|
+
required: ['name', 'persona'],
|
|
336
|
+
},
|
|
337
|
+
annotations: {
|
|
338
|
+
title: 'Create Agent',
|
|
339
|
+
readOnlyHint: false,
|
|
340
|
+
destructiveHint: false,
|
|
341
|
+
idempotentHint: true,
|
|
342
|
+
},
|
|
343
|
+
},
|
|
344
|
+
{
|
|
345
|
+
name: 'agent-list',
|
|
346
|
+
description: 'List all agents in the knowledge base.',
|
|
347
|
+
inputSchema: {
|
|
348
|
+
type: 'object',
|
|
349
|
+
properties: {},
|
|
350
|
+
},
|
|
351
|
+
annotations: {
|
|
352
|
+
title: 'List Agents',
|
|
353
|
+
readOnlyHint: true,
|
|
354
|
+
destructiveHint: false,
|
|
355
|
+
idempotentHint: true,
|
|
356
|
+
},
|
|
357
|
+
},
|
|
358
|
+
{
|
|
359
|
+
name: 'agent-get',
|
|
360
|
+
description: 'Get an agent definition by document ID.',
|
|
361
|
+
inputSchema: {
|
|
362
|
+
type: 'object',
|
|
363
|
+
properties: {
|
|
364
|
+
docid: {
|
|
365
|
+
type: 'string',
|
|
366
|
+
description: 'Document ID of the agent',
|
|
367
|
+
},
|
|
368
|
+
},
|
|
369
|
+
required: ['docid'],
|
|
370
|
+
},
|
|
371
|
+
annotations: {
|
|
372
|
+
title: 'Get Agent',
|
|
373
|
+
readOnlyHint: true,
|
|
374
|
+
destructiveHint: false,
|
|
375
|
+
idempotentHint: true,
|
|
376
|
+
},
|
|
377
|
+
},
|
|
378
|
+
{
|
|
379
|
+
name: 'agent-delete',
|
|
380
|
+
description:
|
|
381
|
+
'Delete an agent by its document ID.' +
|
|
382
|
+
' Skill sections are not removed.',
|
|
383
|
+
inputSchema: {
|
|
384
|
+
type: 'object',
|
|
385
|
+
properties: {
|
|
386
|
+
docid: {
|
|
387
|
+
type: 'string',
|
|
388
|
+
description: 'Document ID of the agent',
|
|
389
|
+
},
|
|
390
|
+
},
|
|
391
|
+
required: ['docid'],
|
|
392
|
+
},
|
|
393
|
+
annotations: {
|
|
394
|
+
title: 'Delete Agent',
|
|
395
|
+
readOnlyHint: false,
|
|
396
|
+
destructiveHint: true,
|
|
397
|
+
idempotentHint: true,
|
|
398
|
+
},
|
|
399
|
+
},
|
|
400
|
+
];
|
|
401
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type { SkillArgument } from '../typings/skill-types.interface.ts';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Extracts `{{argName}}` placeholder names from a skill body string
|
|
5
|
+
* and returns them as `SkillArgument` objects marked as required.
|
|
6
|
+
*
|
|
7
|
+
* Each placeholder is included only once regardless of how many
|
|
8
|
+
* times it appears, and the returned array preserves the order of
|
|
9
|
+
* first occurrence.
|
|
10
|
+
*
|
|
11
|
+
* @param body - skill body template text to scan for placeholders
|
|
12
|
+
* @returns ordered, deduplicated list of argument definitions
|
|
13
|
+
*/
|
|
14
|
+
export function extractSkillArguments(body: string): SkillArgument[] {
|
|
15
|
+
const seen = new Set<string>();
|
|
16
|
+
const args: SkillArgument[] = [];
|
|
17
|
+
const re = /\{\{(\w+)\}\}/g;
|
|
18
|
+
let match: RegExpExecArray | null;
|
|
19
|
+
while ((match = re.exec(body)) !== null) {
|
|
20
|
+
const name = match[1];
|
|
21
|
+
if (!seen.has(name)) {
|
|
22
|
+
seen.add(name);
|
|
23
|
+
args.push({ name, required: true });
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
return args;
|
|
27
|
+
}
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
import type { McpWorkerClient } from '../typings/mcp-client.interface.ts';
|
|
2
|
+
|
|
3
|
+
/** Shape of a content item in an MCP tool call response. */
|
|
4
|
+
interface ToolContent {
|
|
5
|
+
/** Content type identifier, typically `'text'`. */
|
|
6
|
+
readonly type: string;
|
|
7
|
+
/** The text payload. */
|
|
8
|
+
readonly text: string;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
/** Result returned by the agent-create tool handler. */
|
|
12
|
+
interface ToolCallResult {
|
|
13
|
+
/** One or more content items describing the result. */
|
|
14
|
+
readonly content: ToolContent[];
|
|
15
|
+
/** Set to `true` when the tool encountered an error. */
|
|
16
|
+
readonly isError?: boolean;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Narrows an `unknown` value to a string, returning the fallback
|
|
21
|
+
* when the value is not already a string.
|
|
22
|
+
*/
|
|
23
|
+
function asString(value: unknown, fallback: string): string {
|
|
24
|
+
return typeof value === 'string' ? value : fallback;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Narrows an `unknown` value to a `string[]`, returning an empty
|
|
29
|
+
* array when the value is not an array of strings.
|
|
30
|
+
*/
|
|
31
|
+
function asStringArray(value: unknown): string[] {
|
|
32
|
+
if (
|
|
33
|
+
Array.isArray(value) &&
|
|
34
|
+
value.every((item) => typeof item === 'string')
|
|
35
|
+
) {
|
|
36
|
+
return value;
|
|
37
|
+
}
|
|
38
|
+
return [];
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Handles the `agent:create` MCP tool call.
|
|
43
|
+
*
|
|
44
|
+
* Validates required arguments, verifies that referenced skill kbids
|
|
45
|
+
* exist, stores agent metadata as a JSON section, groups all sections
|
|
46
|
+
* into a single document, and returns the resulting document
|
|
47
|
+
* identifier.
|
|
48
|
+
*
|
|
49
|
+
* @param client - the worker client used to execute operations
|
|
50
|
+
* @param args - tool arguments from the MCP request
|
|
51
|
+
* @returns content items with optional `isError` flag
|
|
52
|
+
*/
|
|
53
|
+
export async function handleAgentCreate(
|
|
54
|
+
client: McpWorkerClient,
|
|
55
|
+
args: Record<string, unknown>,
|
|
56
|
+
): Promise<ToolCallResult> {
|
|
57
|
+
const name = asString(args['name'], '');
|
|
58
|
+
const description = asString(args['description'], '');
|
|
59
|
+
const persona = asString(args['persona'], '');
|
|
60
|
+
const skills = asStringArray(args['skills']);
|
|
61
|
+
|
|
62
|
+
if (!name) {
|
|
63
|
+
return {
|
|
64
|
+
content: [{ type: 'text', text: 'name is required' }],
|
|
65
|
+
isError: true,
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
if (!persona) {
|
|
69
|
+
return {
|
|
70
|
+
content: [{ type: 'text', text: 'persona is required' }],
|
|
71
|
+
isError: true,
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
if (skills.length > 0) {
|
|
76
|
+
const sections = await client.readSections(skills);
|
|
77
|
+
const found = new Set(sections.map((s) => s.kbid));
|
|
78
|
+
const missing = skills.filter((k) => !found.has(k));
|
|
79
|
+
if (missing.length > 0) {
|
|
80
|
+
return {
|
|
81
|
+
content: [
|
|
82
|
+
{
|
|
83
|
+
type: 'text',
|
|
84
|
+
text: `skill not found: ${missing.join(', ')}`,
|
|
85
|
+
},
|
|
86
|
+
],
|
|
87
|
+
isError: true,
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
const metadata = JSON.stringify({ name, description, persona });
|
|
93
|
+
|
|
94
|
+
const metaResult = await client.addSection({
|
|
95
|
+
sectionType: 'text',
|
|
96
|
+
content: metadata,
|
|
97
|
+
title: name,
|
|
98
|
+
description,
|
|
99
|
+
});
|
|
100
|
+
|
|
101
|
+
const allKbids = [metaResult.kbid, ...skills];
|
|
102
|
+
const docid = await client.groupSections(name, allKbids);
|
|
103
|
+
|
|
104
|
+
return {
|
|
105
|
+
content: [
|
|
106
|
+
{
|
|
107
|
+
type: 'text',
|
|
108
|
+
text: JSON.stringify({
|
|
109
|
+
docid,
|
|
110
|
+
name,
|
|
111
|
+
skillCount: skills.length,
|
|
112
|
+
}),
|
|
113
|
+
},
|
|
114
|
+
],
|
|
115
|
+
};
|
|
116
|
+
}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import type { McpWorkerClient } from '../typings/mcp-client.interface.ts';
|
|
2
|
+
|
|
3
|
+
/** Shape of a content item in an MCP tool call response. */
|
|
4
|
+
interface ToolContent {
|
|
5
|
+
/** Content type identifier, typically `'text'`. */
|
|
6
|
+
readonly type: string;
|
|
7
|
+
/** The text payload. */
|
|
8
|
+
readonly text: string;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
/** Result returned by the agent-delete tool handler. */
|
|
12
|
+
interface ToolCallResult {
|
|
13
|
+
/** One or more content items describing the result. */
|
|
14
|
+
readonly content: ToolContent[];
|
|
15
|
+
/** Set to `true` when the tool encountered an error. */
|
|
16
|
+
readonly isError?: boolean;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Handles the `agent:delete` MCP tool call.
|
|
21
|
+
*
|
|
22
|
+
* Removes the document grouping identified by `docid`. The skill
|
|
23
|
+
* sections referenced by the agent are not deleted; only the grouping
|
|
24
|
+
* record is removed.
|
|
25
|
+
*
|
|
26
|
+
* @param client - the worker client used to execute operations
|
|
27
|
+
* @param args - tool arguments; must include a `docid` string
|
|
28
|
+
* @returns content items confirming removal, or an error item
|
|
29
|
+
*/
|
|
30
|
+
export async function handleAgentDelete(
|
|
31
|
+
client: McpWorkerClient,
|
|
32
|
+
args: Record<string, unknown>,
|
|
33
|
+
): Promise<ToolCallResult> {
|
|
34
|
+
const docid = typeof args['docid'] === 'string' ? args['docid'] : '';
|
|
35
|
+
if (!docid) {
|
|
36
|
+
return {
|
|
37
|
+
content: [{ type: 'text', text: 'docid is required' }],
|
|
38
|
+
isError: true,
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
await client.removeGrouping(docid);
|
|
42
|
+
return {
|
|
43
|
+
content: [
|
|
44
|
+
{
|
|
45
|
+
type: 'text',
|
|
46
|
+
text: JSON.stringify({ docid, removed: true }),
|
|
47
|
+
},
|
|
48
|
+
],
|
|
49
|
+
};
|
|
50
|
+
}
|