@octopi-agent/engine 0.102.10 → 0.121.15
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/builtin-model-info.js +28 -7
- package/dist/config-admin/agent-presets.d.ts +32 -0
- package/dist/config-admin/agent-presets.js +133 -0
- package/dist/config-admin/console-access-key.d.ts +46 -0
- package/dist/config-admin/console-access-key.js +47 -0
- package/dist/config-admin/discover.d.ts +33 -4
- package/dist/config-admin/discover.js +101 -6
- package/dist/config-admin/env.d.ts +11 -0
- package/dist/config-admin/env.js +41 -0
- package/dist/config-admin/error-copy.d.ts +106 -0
- package/dist/config-admin/error-copy.js +287 -0
- package/dist/config-admin/i18n.d.ts +21 -0
- package/dist/config-admin/i18n.js +19 -0
- package/dist/config-admin/index.d.ts +8 -2
- package/dist/config-admin/index.js +4 -1
- package/dist/config-admin/model-presets.d.ts +14 -0
- package/dist/config-admin/model-presets.js +595 -70
- package/dist/config-admin/onboarding-apply.d.ts +83 -0
- package/dist/config-admin/onboarding-apply.js +259 -0
- package/dist/config-admin/onboarding.d.ts +160 -0
- package/dist/config-admin/onboarding.js +298 -0
- package/dist/config-admin/password-policy.d.ts +24 -0
- package/dist/config-admin/password-policy.js +31 -0
- package/dist/config-admin/redact.d.ts +42 -9
- package/dist/config-admin/redact.js +69 -5
- package/dist/config-schema/agent.d.ts +5 -1
- package/dist/config-schema/agent.js +20 -2
- package/dist/config-schema/browser.d.ts +62 -0
- package/dist/config-schema/browser.js +89 -0
- package/dist/config-schema/context.d.ts +7 -2
- package/dist/config-schema/context.js +6 -3
- package/dist/config-schema/engine.d.ts +86 -7
- package/dist/config-schema/engine.js +9 -2
- package/dist/config-schema/governance.d.ts +12 -1
- package/dist/config-schema/governance.js +10 -2
- package/dist/config-schema/models.d.ts +12 -8
- package/dist/config-schema/models.js +16 -1
- package/dist/config-schema/run.d.ts +4 -0
- package/dist/config-schema/run.js +10 -0
- package/dist/config-schema/shared.d.ts +1 -0
- package/dist/config-schema/shared.js +4 -2
- package/dist/config-schema/substrate.d.ts +5 -0
- package/dist/config-schema/substrate.js +8 -0
- package/dist/config.d.ts +116 -10
- package/dist/config.js +109 -13
- package/dist/file-mode.d.ts +67 -0
- package/dist/file-mode.js +182 -0
- package/dist/fork-child.d.ts +82 -0
- package/dist/fork-child.js +123 -0
- package/dist/harness/activation/delegated-run.d.ts +42 -0
- package/dist/harness/activation/delegated-run.js +71 -0
- package/dist/harness/activation/dispatcher.js +4 -0
- package/dist/harness/activation/index.d.ts +1 -0
- package/dist/harness/activation/run-backend.d.ts +92 -0
- package/dist/harness/activation/run-backend.js +16 -0
- package/dist/harness/activation/run-protocol.d.ts +392 -0
- package/dist/harness/activation/run-protocol.js +19 -0
- package/dist/harness/activation/runtime.d.ts +33 -0
- package/dist/harness/activation/runtime.js +119 -28
- package/dist/harness/activation/types.d.ts +19 -2
- package/dist/harness/agent/builder.d.ts +12 -0
- package/dist/harness/agent/builder.js +78 -22
- package/dist/harness/agent/config-bridge.d.ts +10 -1
- package/dist/harness/agent/config-bridge.js +15 -3
- package/dist/harness/agent/registered-tool-adapter.d.ts +27 -0
- package/dist/harness/agent/registered-tool-adapter.js +67 -0
- package/dist/harness/agent/wire-agent-builder.d.ts +2 -0
- package/dist/harness/agent/wire-agent-builder.js +9 -2
- package/dist/harness/capabilities/document/backends/plain.js +2 -1
- package/dist/harness/capabilities/document/legacy/factory.js +3 -2
- package/dist/harness/collaboration/autonomous-subsystem/audit/reader.d.ts +17 -0
- package/dist/harness/collaboration/autonomous-subsystem/audit/reader.js +66 -36
- package/dist/harness/collaboration/autonomous-subsystem/audit/writer.d.ts +6 -2
- package/dist/harness/collaboration/autonomous-subsystem/audit/writer.js +27 -7
- package/dist/harness/collaboration/autonomous-subsystem/boundary/validator.js +13 -0
- package/dist/harness/collaboration/autonomous-subsystem/loader.js +1 -0
- package/dist/harness/collaboration/autonomous-subsystem/runtime.d.ts +11 -0
- package/dist/harness/collaboration/autonomous-subsystem/runtime.js +17 -0
- package/dist/harness/collaboration/autonomous-subsystem/sense/engine.d.ts +13 -3
- package/dist/harness/collaboration/autonomous-subsystem/sense/engine.js +48 -39
- package/dist/harness/collaboration/autonomous-subsystem/think/executor.js +3 -0
- package/dist/harness/collaboration/autonomous-subsystem/types.d.ts +4 -0
- package/dist/harness/collaboration/delegation/child-run.d.ts +9 -0
- package/dist/harness/collaboration/delegation/child-run.js +34 -2
- package/dist/harness/collaboration/delegation/registry-types.d.ts +2 -0
- package/dist/harness/collaboration/delegation/service.d.ts +9 -4
- package/dist/harness/collaboration/delegation/service.js +33 -12
- package/dist/harness/collaboration/delegation/store.d.ts +2 -0
- package/dist/harness/collaboration/delegation/store.js +1 -0
- package/dist/harness/collaboration/delegation/types.d.ts +11 -0
- package/dist/harness/collaboration/delegation/wiring.d.ts +2 -0
- package/dist/harness/collaboration/delegation/wiring.js +1 -0
- package/dist/harness/context/capabilities/compact/engine.d.ts +44 -5
- package/dist/harness/context/capabilities/compact/engine.js +127 -39
- package/dist/harness/context/capabilities/compact/index.d.ts +2 -1
- package/dist/harness/context/capabilities/compact/index.js +1 -1
- package/dist/harness/context/capabilities/compact/types.d.ts +59 -9
- package/dist/harness/context/capabilities/summary/gate.d.ts +19 -2
- package/dist/harness/context/capabilities/summary/gate.js +53 -6
- package/dist/harness/context/capabilities/summary/registry.js +20 -0
- package/dist/harness/context/capabilities/summary/tool-binding.js +16 -12
- package/dist/harness/context/capabilities/summary/tool-bindings.d.ts +13 -0
- package/dist/harness/context/capabilities/summary/tool-bindings.js +22 -0
- package/dist/harness/context/capabilities/summary/types.d.ts +16 -0
- package/dist/harness/context/constitution/default-agents.md +85 -0
- package/dist/harness/context/context-size-ledger.js +8 -1
- package/dist/harness/context/default-context-engine.d.ts +100 -6
- package/dist/harness/context/default-context-engine.js +382 -89
- package/dist/harness/context/index.d.ts +2 -1
- package/dist/harness/context/index.js +1 -0
- package/dist/harness/context/layer-health.d.ts +4 -0
- package/dist/harness/context/layer-health.js +4 -0
- package/dist/harness/context/layer-types.d.ts +57 -0
- package/dist/harness/context/layer-types.js +73 -1
- package/dist/harness/context/layers.d.ts +3 -0
- package/dist/harness/context/layers.js +13 -6
- package/dist/harness/context/prefix-fingerprint.d.ts +46 -0
- package/dist/harness/context/prefix-fingerprint.js +52 -0
- package/dist/harness/context/summarize.js +18 -0
- package/dist/harness/context/system-prompt-assembler.d.ts +2 -0
- package/dist/harness/context/system-prompt-assembler.js +5 -2
- package/dist/harness/context/tool-result-aging.d.ts +104 -16
- package/dist/harness/context/tool-result-aging.js +211 -57
- package/dist/harness/context/types.d.ts +71 -4
- package/dist/harness/context/types.js +25 -1
- package/dist/harness/extension/execution-environment/effect-policy.d.ts +4 -3
- package/dist/harness/extension/execution-environment/effect-policy.js +2 -2
- package/dist/harness/extension/execution-environment/privileged-exec.js +4 -1
- package/dist/harness/extension/execution-environment/workspace.js +1 -1
- package/dist/harness/extension/plugin-ecosystem/channel-types.d.ts +27 -1
- package/dist/harness/extension/plugin-ecosystem/channel-types.js +11 -2
- package/dist/harness/extension/plugin-ecosystem/client-tools/registry.d.ts +12 -0
- package/dist/harness/extension/plugin-ecosystem/client-tools/registry.js +25 -0
- package/dist/harness/extension/plugin-ecosystem/commands/builtin.js +28 -1
- package/dist/harness/extension/plugin-ecosystem/index.d.ts +1 -0
- package/dist/harness/extension/plugin-ecosystem/index.js +1 -0
- package/dist/harness/extension/plugin-ecosystem/plugins/api.d.ts +168 -1
- package/dist/harness/extension/plugin-ecosystem/plugins/api.js +156 -15
- package/dist/harness/extension/plugin-ecosystem/plugins/contribution-instances.d.ts +95 -0
- package/dist/harness/extension/plugin-ecosystem/plugins/contribution-instances.js +170 -0
- package/dist/harness/extension/plugin-ecosystem/plugins/contribution-kinds.d.ts +178 -0
- package/dist/harness/extension/plugin-ecosystem/plugins/contribution-kinds.js +314 -0
- package/dist/harness/extension/plugin-ecosystem/plugins/contribution-registry.d.ts +40 -5
- package/dist/harness/extension/plugin-ecosystem/plugins/contribution-registry.js +45 -26
- package/dist/harness/extension/plugin-ecosystem/plugins/index.d.ts +1 -1
- package/dist/harness/extension/plugin-ecosystem/plugins/loader.d.ts +11 -1
- package/dist/harness/extension/plugin-ecosystem/plugins/loader.js +42 -76
- package/dist/harness/extension/plugin-ecosystem/plugins/manager.d.ts +30 -1
- package/dist/harness/extension/plugin-ecosystem/plugins/manager.js +46 -0
- package/dist/harness/extension/plugin-ecosystem/plugins/manifest.d.ts +9 -0
- package/dist/harness/extension/plugin-ecosystem/plugins/manifest.js +19 -14
- package/dist/harness/extension/plugin-ecosystem/plugins/staging.d.ts +3 -1
- package/dist/harness/extension/plugin-ecosystem/plugins/staging.js +1 -1
- package/dist/harness/extension/plugin-ecosystem/tools/browser-types.d.ts +333 -0
- package/dist/harness/extension/plugin-ecosystem/tools/browser-types.js +16 -0
- package/dist/harness/extension/plugin-ecosystem/tools/browser.d.ts +64 -0
- package/dist/harness/extension/plugin-ecosystem/tools/browser.js +692 -0
- package/dist/harness/extension/plugin-ecosystem/tools/builtin.d.ts +0 -37
- package/dist/harness/extension/plugin-ecosystem/tools/builtin.js +108 -4
- package/dist/harness/extension/plugin-ecosystem/tools/delegation.js +18 -0
- package/dist/harness/extension/plugin-ecosystem/tools/file-edit.js +34 -0
- package/dist/harness/extension/plugin-ecosystem/tools/file-search.d.ts +0 -6
- package/dist/harness/extension/plugin-ecosystem/tools/file-search.js +57 -4
- package/dist/harness/extension/plugin-ecosystem/tools/git-tools.js +81 -13
- package/dist/harness/extension/plugin-ecosystem/tools/http.js +5 -0
- package/dist/harness/extension/plugin-ecosystem/tools/knowledge.js +13 -7
- package/dist/harness/extension/plugin-ecosystem/tools/package-tools.js +126 -14
- package/dist/harness/extension/plugin-ecosystem/tools/platform.d.ts +1 -1
- package/dist/harness/extension/plugin-ecosystem/tools/platform.js +44 -5
- package/dist/harness/extension/plugin-ecosystem/tools/tool-bus.js +10 -24
- package/dist/harness/extension/plugin-ecosystem/tools/tool-set.d.ts +7 -0
- package/dist/harness/extension/plugin-ecosystem/tools/tool-set.js +4 -0
- package/dist/harness/governance/credentials/db.d.ts +9 -0
- package/dist/harness/governance/credentials/db.js +122 -31
- package/dist/harness/governance/credentials/store.d.ts +68 -7
- package/dist/harness/governance/credentials/store.js +177 -64
- package/dist/harness/governance/credentials/types.d.ts +13 -2
- package/dist/harness/governance/index.d.ts +1 -0
- package/dist/harness/governance/index.js +1 -0
- package/dist/harness/governance/registry/db.d.ts +32 -0
- package/dist/harness/governance/registry/db.js +142 -0
- package/dist/harness/governance/registry/index.d.ts +9 -0
- package/dist/harness/governance/registry/index.js +9 -0
- package/dist/harness/governance/registry/service.d.ts +381 -0
- package/dist/harness/governance/registry/service.js +825 -0
- package/dist/harness/governance/registry/types.d.ts +77 -0
- package/dist/harness/governance/registry/types.js +7 -0
- package/dist/harness/governance/security/default-security-guard.d.ts +3 -0
- package/dist/harness/governance/security/default-security-guard.js +12 -1
- package/dist/harness/governance/security/risk-evaluator.d.ts +13 -3
- package/dist/harness/governance/security/risk-evaluator.js +307 -21
- package/dist/harness/governance/security/shell-parser-treesitter.js +12 -4
- package/dist/harness/governance/session-acl/tool-rights.d.ts +1 -0
- package/dist/harness/index.d.ts +5 -3
- package/dist/harness/index.js +2 -2
- package/dist/harness/knowledge/boot-config.d.ts +2 -0
- package/dist/harness/knowledge/boot-config.js +2 -0
- package/dist/harness/knowledge/client.d.ts +53 -7
- package/dist/harness/knowledge/client.js +77 -20
- package/dist/harness/knowledge/db.d.ts +16 -0
- package/dist/harness/knowledge/db.js +107 -41
- package/dist/harness/knowledge/engine-thread.js +5 -7
- package/dist/harness/knowledge/grounding.js +4 -1
- package/dist/harness/knowledge/http-app.d.ts +15 -0
- package/dist/harness/knowledge/http-app.js +82 -21
- package/dist/harness/knowledge/http-bridge.d.ts +15 -0
- package/dist/harness/knowledge/http-bridge.js +19 -0
- package/dist/harness/knowledge/knowledge-serve-child.js +2 -3
- package/dist/harness/knowledge/query-service.d.ts +12 -2
- package/dist/harness/knowledge/query-service.js +75 -41
- package/dist/harness/knowledge/query-worker-client.d.ts +5 -1
- package/dist/harness/knowledge/query-worker-client.js +4 -1
- package/dist/harness/knowledge/query-worker.js +5 -3
- package/dist/harness/knowledge/read-http.d.ts +2 -0
- package/dist/harness/knowledge/read-http.js +9 -2
- package/dist/harness/knowledge/retriever.d.ts +1 -1
- package/dist/harness/knowledge/retriever.js +1 -2
- package/dist/harness/knowledge/serve.d.ts +6 -1
- package/dist/harness/knowledge/serve.js +5 -6
- package/dist/harness/knowledge/source-store.d.ts +101 -5
- package/dist/harness/knowledge/source-store.js +297 -71
- package/dist/harness/knowledge/start-service-process.d.ts +27 -8
- package/dist/harness/knowledge/start-service-process.js +49 -90
- package/dist/harness/knowledge/tenant-gate.d.ts +81 -0
- package/dist/harness/knowledge/tenant-gate.js +167 -0
- package/dist/harness/knowledge/writer-service.d.ts +18 -2
- package/dist/harness/knowledge/writer-service.js +80 -16
- package/dist/harness/knowledge/writer-worker-client.d.ts +9 -2
- package/dist/harness/knowledge/writer-worker-client.js +20 -3
- package/dist/harness/knowledge/writer-worker.js +11 -4
- package/dist/harness/memory/backfill-trigger.d.ts +10 -3
- package/dist/harness/memory/backfill-trigger.js +19 -19
- package/dist/harness/memory/cognition-seeds.d.ts +45 -0
- package/dist/harness/memory/cognition-seeds.js +67 -0
- package/dist/harness/memory/cognition.d.ts +12 -3
- package/dist/harness/memory/cognition.js +55 -35
- package/dist/harness/memory/conceptualizer.d.ts +11 -1
- package/dist/harness/memory/conceptualizer.js +10 -1
- package/dist/harness/memory/context-slice.d.ts +42 -0
- package/dist/harness/memory/context-slice.js +197 -0
- package/dist/harness/memory/health-probe.d.ts +8 -2
- package/dist/harness/memory/health-probe.js +10 -13
- package/dist/harness/memory/index.d.ts +5 -1
- package/dist/harness/memory/index.js +3 -1
- package/dist/harness/memory/sqlite/agent-db.d.ts +1 -0
- package/dist/harness/memory/sqlite/agent-db.js +9 -8
- package/dist/harness/memory/sqlite/cognition-store.d.ts +26 -3
- package/dist/harness/memory/sqlite/cognition-store.js +103 -45
- package/dist/harness/memory/sqlite/memory-store.js +4 -0
- package/dist/harness/memory/sqlite/sqlite-vec.d.ts +24 -1
- package/dist/harness/memory/sqlite/sqlite-vec.js +37 -1
- package/dist/harness/memory/types.d.ts +18 -2
- package/dist/harness/observability/observer/hub.d.ts +10 -0
- package/dist/harness/observability/observer/hub.js +95 -2
- package/dist/harness/run/agent/agent.js +3 -2
- package/dist/harness/run/concurrency/tool-validator.js +4 -3
- package/dist/harness/run/reliability/run-agent.d.ts +22 -0
- package/dist/harness/run/reliability/run-agent.js +79 -10
- package/dist/harness/run/run-host.d.ts +302 -0
- package/dist/harness/run/run-host.js +978 -0
- package/dist/harness/run/run-scope.d.ts +11 -0
- package/dist/harness/run/run-scope.js +19 -1
- package/dist/harness/run/runner.d.ts +149 -22
- package/dist/harness/run/runner.js +352 -35
- package/dist/harness/session/in-memory-store.js +13 -1
- package/dist/harness/session/schedules/service.d.ts +10 -2
- package/dist/harness/session/schedules/service.js +13 -2
- package/dist/harness/session/tasks/tools.js +12 -0
- package/dist/harness/session/types.d.ts +10 -14
- package/dist/harness/shared/events/agent-event-map.d.ts +29 -0
- package/dist/harness/shared/types/agent-definition.d.ts +6 -0
- package/dist/index.d.ts +3 -2
- package/dist/index.js +2 -1
- package/dist/integration/agent-runtime/channel-message-source.d.ts +3 -1
- package/dist/integration/agent-runtime/channel-message-source.js +4 -3
- package/dist/integration/browser/camoufox.d.ts +40 -0
- package/dist/integration/browser/camoufox.js +80 -0
- package/dist/integration/browser/index.d.ts +91 -0
- package/dist/integration/browser/index.js +110 -0
- package/dist/integration/browser/install.d.ts +47 -0
- package/dist/integration/browser/install.js +214 -0
- package/dist/integration/browser/playwright.d.ts +224 -0
- package/dist/integration/browser/playwright.js +925 -0
- package/dist/integration/browser/service.d.ts +41 -0
- package/dist/integration/browser/service.js +181 -0
- package/dist/integration/browser/stealth.d.ts +42 -0
- package/dist/integration/browser/stealth.js +104 -0
- package/dist/integration/providers/anthropic-message-normalize.d.ts +20 -0
- package/dist/integration/providers/anthropic-message-normalize.js +48 -0
- package/dist/integration/providers/anthropic.js +27 -2
- package/dist/integration/providers/fetch-timeout.d.ts +17 -0
- package/dist/integration/providers/fetch-timeout.js +24 -0
- package/dist/integration/providers/openai.d.ts +8 -0
- package/dist/integration/providers/openai.js +41 -1
- package/dist/integration/providers/wire-dump-diff.js +2 -1
- package/dist/integration/providers/wire-dump.d.ts +56 -2
- package/dist/integration/providers/wire-dump.js +119 -6
- package/dist/integration/storage/archive-manager.d.ts +14 -2
- package/dist/integration/storage/archive-manager.js +24 -8
- package/dist/integration/storage/atomic-tmp.d.ts +12 -0
- package/dist/integration/storage/atomic-tmp.js +36 -0
- package/dist/integration/storage/jsonl.d.ts +9 -0
- package/dist/integration/storage/jsonl.js +137 -38
- package/dist/integration/storage/session-index.d.ts +5 -0
- package/dist/integration/storage/session-index.js +25 -4
- package/dist/integration/tools/assemble.d.ts +50 -0
- package/dist/integration/tools/assemble.js +137 -0
- package/dist/paths.d.ts +18 -0
- package/dist/paths.js +36 -0
- package/dist/subsystems/cognition-steward/conceptualize/config.yaml +3 -1
- package/dist/subsystems/cognition-steward/conceptualize/handler.js +74 -5
- package/dist/subsystems/cognition-steward/consolidate/SUBSYSTEM.md +3 -2
- package/dist/subsystems/cognition-steward/consolidate/config.yaml +11 -2
- package/dist/subsystems/cognition-steward/consolidate/handler.d.ts +6 -3
- package/dist/subsystems/cognition-steward/consolidate/handler.js +266 -28
- package/dist/subsystems/memory-steward/backfill/handler.js +3 -2
- package/dist/subsystems/memory-steward/govern/config.yaml +6 -1
- package/dist/subsystems/wisdom-steward/attribute/config.yaml +5 -1
- package/dist/subsystems/wisdom-steward/formation/config.yaml +3 -0
- package/dist/subsystems/wisdom-steward/govern/config.yaml +6 -1
- package/package.json +5 -3
|
@@ -13,6 +13,7 @@ import { LocalKnowledgeQueryService, } from './query-service.js';
|
|
|
13
13
|
/** meta:列表/控制面(UI 轮询必须稳);search:检索/catalog(可慢) */
|
|
14
14
|
const META_METHODS = new Set([
|
|
15
15
|
'listProjects',
|
|
16
|
+
'getProject',
|
|
16
17
|
'listSources',
|
|
17
18
|
'getSource',
|
|
18
19
|
'getSourceDetail',
|
|
@@ -55,9 +56,7 @@ async function main() {
|
|
|
55
56
|
dbPath: boot.dbPath,
|
|
56
57
|
readOnly: true,
|
|
57
58
|
skipMigrate: true,
|
|
58
|
-
sqliteVec: boot.
|
|
59
|
-
? { extensionPath: boot.sqliteVecExtensionPath }
|
|
60
|
-
: true,
|
|
59
|
+
sqliteVec: boot.sqliteVec ?? true,
|
|
61
60
|
});
|
|
62
61
|
let embeddingProvider = null;
|
|
63
62
|
// embed.enabled=false:纯关键词索引——检索侧不建 provider,query 不外发 embed(与写侧 resolveEmbedding 同判)
|
|
@@ -115,6 +114,9 @@ async function main() {
|
|
|
115
114
|
case 'listProjects':
|
|
116
115
|
data = await svc.listProjects(msg.identity);
|
|
117
116
|
break;
|
|
117
|
+
case 'getProject':
|
|
118
|
+
data = await svc.getProject(msg.identity, msg.projectKey);
|
|
119
|
+
break;
|
|
118
120
|
case 'getSource':
|
|
119
121
|
data = await svc.getSource(msg.sourceId, msg.identity);
|
|
120
122
|
break;
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* 禁止在此碰写连接或同步 SQLite。鉴权后的纯读请求不再进 Engine Worker,
|
|
5
5
|
* ingest 占死写线程时列表/详情仍应答。
|
|
6
6
|
*/
|
|
7
|
-
import { matchKnowledgeToken } from './http-bridge.js';
|
|
7
|
+
import { matchKnowledgeToken, resolveTenantClaim } from './http-bridge.js';
|
|
8
8
|
import { promotionThresholdsFromParams } from './http-params.js';
|
|
9
9
|
function json(res, status, payload) {
|
|
10
10
|
const buf = Buffer.from(JSON.stringify(payload), 'utf8');
|
|
@@ -373,5 +373,12 @@ export function authenticateRead(tokens, req) {
|
|
|
373
373
|
const hit = matchKnowledgeToken(tokens, req.headers.authorization);
|
|
374
374
|
if (!hit)
|
|
375
375
|
return null;
|
|
376
|
-
|
|
376
|
+
// 租户断言(T3):x-octopi-tenant 上行;重复头/越域断言按未认证拒(fail-loud,不回落)
|
|
377
|
+
const claim = req.headers['x-octopi-tenant'];
|
|
378
|
+
if (Array.isArray(claim))
|
|
379
|
+
return null;
|
|
380
|
+
const resolved = resolveTenantClaim(hit.tenantId, claim ? claim : undefined);
|
|
381
|
+
if ('error' in resolved)
|
|
382
|
+
return null;
|
|
383
|
+
return { tenantId: resolved.tenantId, gatewayId: hit.gatewayId, claimed: Boolean(claim) };
|
|
377
384
|
}
|
|
@@ -87,7 +87,7 @@ export declare class KnowledgeRetriever {
|
|
|
87
87
|
private readonly hybridKeyword;
|
|
88
88
|
constructor(options: KnowledgeRetrieverOptions);
|
|
89
89
|
/**
|
|
90
|
-
* 可见 sourceId
|
|
90
|
+
* 可见 sourceId 列表(isVisible 已含租户闸 ⊕ 网关漏斗,不再二次过滤)
|
|
91
91
|
*/
|
|
92
92
|
visibleSourceIds(agentId: string, sessionId?: string, identity?: {
|
|
93
93
|
tenantId?: string;
|
|
@@ -29,12 +29,11 @@ export class KnowledgeRetriever {
|
|
|
29
29
|
this.hybridKeyword = options.hybridKeyword !== false;
|
|
30
30
|
}
|
|
31
31
|
/**
|
|
32
|
-
* 可见 sourceId
|
|
32
|
+
* 可见 sourceId 列表(isVisible 已含租户闸 ⊕ 网关漏斗,不再二次过滤)
|
|
33
33
|
*/
|
|
34
34
|
visibleSourceIds(agentId, sessionId, identity) {
|
|
35
35
|
return this.sources
|
|
36
36
|
.listVisible(agentId, sessionId, identity)
|
|
37
|
-
.filter((s) => this.sources.isGatewayVisible(s, identity))
|
|
38
37
|
.map((s) => s.id);
|
|
39
38
|
}
|
|
40
39
|
/** 可见集 ∩ 请求过滤;无过滤时原样返回可见集 */
|
|
@@ -29,7 +29,12 @@ export interface KnowledgeServeOptions {
|
|
|
29
29
|
retriever?: KnowledgeBootRetriever | null;
|
|
30
30
|
/** false = 索引稳定后不自动生成 generatedDescription(knowledge.catalog.autoDescribe) */
|
|
31
31
|
autoDescribe?: boolean;
|
|
32
|
-
|
|
32
|
+
sqliteVec?: boolean | {
|
|
33
|
+
extensionPath?: string;
|
|
34
|
+
require?: boolean;
|
|
35
|
+
};
|
|
36
|
+
/** 跨租户共享闸(B-5):允许创建 visibility='public' 项目 */
|
|
37
|
+
allowPublic?: boolean;
|
|
33
38
|
embeddingModels?: {
|
|
34
39
|
providers?: Record<string, unknown>;
|
|
35
40
|
embedding?: unknown;
|
|
@@ -37,9 +37,7 @@ async function startQueryWorker(opts) {
|
|
|
37
37
|
embeddingModels: opts.embeddingModels ?? null,
|
|
38
38
|
embed: opts.embed ?? null,
|
|
39
39
|
retriever: opts.retriever ?? null,
|
|
40
|
-
|
|
41
|
-
? { sqliteVecExtensionPath: opts.sqliteVecExtensionPath }
|
|
42
|
-
: {}),
|
|
40
|
+
sqliteVec: opts.sqliteVec,
|
|
43
41
|
});
|
|
44
42
|
}
|
|
45
43
|
/**
|
|
@@ -58,12 +56,13 @@ export async function startKnowledgeService(opts) {
|
|
|
58
56
|
tokens: opts.tokens,
|
|
59
57
|
autoRegisterPrincipals: opts.autoRegisterPrincipals ?? true,
|
|
60
58
|
documentConfig: opts.documentConfig ?? null,
|
|
61
|
-
|
|
59
|
+
sqliteVec: opts.sqliteVec,
|
|
62
60
|
embeddingModels: opts.embeddingModels ?? null,
|
|
63
61
|
embed: opts.embed ?? null,
|
|
64
62
|
ingest: opts.ingest ?? null,
|
|
65
63
|
retriever: opts.retriever ?? null,
|
|
66
64
|
autoDescribe: opts.autoDescribe,
|
|
65
|
+
allowPublic: opts.allowPublic,
|
|
67
66
|
testEmbeddingStub: opts.testEmbeddingStub ?? false,
|
|
68
67
|
// 文件库:纯读在主线程 Meta/Search;Engine 只做写编排 + 残留短读
|
|
69
68
|
skipQueryWorker: useSplitQuery,
|
|
@@ -103,7 +102,7 @@ export async function startKnowledgeService(opts) {
|
|
|
103
102
|
startQueryWorker({
|
|
104
103
|
dbPath: opts.dbPath,
|
|
105
104
|
role: 'meta',
|
|
106
|
-
|
|
105
|
+
sqliteVec: opts.sqliteVec,
|
|
107
106
|
embeddingModels: opts.embeddingModels,
|
|
108
107
|
embed: opts.embed,
|
|
109
108
|
retriever: opts.retriever,
|
|
@@ -111,7 +110,7 @@ export async function startKnowledgeService(opts) {
|
|
|
111
110
|
startQueryWorker({
|
|
112
111
|
dbPath: opts.dbPath,
|
|
113
112
|
role: 'search',
|
|
114
|
-
|
|
113
|
+
sqliteVec: opts.sqliteVec,
|
|
115
114
|
embeddingModels: opts.embeddingModels,
|
|
116
115
|
embed: opts.embed,
|
|
117
116
|
retriever: opts.retriever,
|
|
@@ -6,6 +6,10 @@ import { KnowledgeDatabase } from './db.js';
|
|
|
6
6
|
import type { KnowledgeSource, KnowledgeSourceId, KnowledgeSourceInput, KnowledgeSourcePatch } from './types.js';
|
|
7
7
|
export declare class KnowledgeSourceStore {
|
|
8
8
|
private db;
|
|
9
|
+
/** listVisible 批处理期的 source 行同步缓存(filter 无 await,无并发窗口;平时为 null) */
|
|
10
|
+
private rowCache;
|
|
11
|
+
/** 项目行批处理缓存(评审 m6:防逐源 N+1;与 rowCache 同模式,批次内同步读) */
|
|
12
|
+
private projectRowCache;
|
|
9
13
|
constructor(db: KnowledgeDatabase);
|
|
10
14
|
/**
|
|
11
15
|
* 打开 knowledge.db 上的源注册表
|
|
@@ -17,7 +21,11 @@ export declare class KnowledgeSourceStore {
|
|
|
17
21
|
/**
|
|
18
22
|
* 注册知识源
|
|
19
23
|
*/
|
|
20
|
-
register(input: KnowledgeSourceInput
|
|
24
|
+
register(input: KnowledgeSourceInput, opts?: {
|
|
25
|
+
tenantId?: string;
|
|
26
|
+
registeredBy?: string;
|
|
27
|
+
visibility?: string;
|
|
28
|
+
}): KnowledgeSource;
|
|
21
29
|
/**
|
|
22
30
|
* 更新源字段(不改 id / createdAt)
|
|
23
31
|
*/
|
|
@@ -61,15 +69,40 @@ export declare class KnowledgeSourceStore {
|
|
|
61
69
|
tenantId?: string;
|
|
62
70
|
gatewayId?: string;
|
|
63
71
|
}): void;
|
|
72
|
+
/**
|
|
73
|
+
* 挂载(T3b,arch/multi-tenancy.md §6 挂载库):include 覆盖基础可见性(含翻转既有隐藏)。
|
|
74
|
+
* 租户闸不受影响——挂载不出租户(registry 侧另有 guard)。
|
|
75
|
+
*/
|
|
76
|
+
mountSource(agentId: string, sourceId: KnowledgeSourceId | string, opts?: {
|
|
77
|
+
tenantId?: string;
|
|
78
|
+
gatewayId?: string;
|
|
79
|
+
}): void;
|
|
80
|
+
/** 卸载:只撤 include(隐藏 exclude 行不受影响);回基础可见性 */
|
|
81
|
+
unmountSource(agentId: string, sourceId: KnowledgeSourceId | string, opts?: {
|
|
82
|
+
tenantId?: string;
|
|
83
|
+
gatewayId?: string;
|
|
84
|
+
}): void;
|
|
64
85
|
listHidden(agentId: string, opts?: {
|
|
65
86
|
tenantId?: string;
|
|
66
87
|
gatewayId?: string;
|
|
67
88
|
}): string[];
|
|
89
|
+
/** 已挂载源(include) */
|
|
90
|
+
listMounted(agentId: string, opts?: {
|
|
91
|
+
tenantId?: string;
|
|
92
|
+
gatewayId?: string;
|
|
93
|
+
}): string[];
|
|
94
|
+
private listAgentOp;
|
|
68
95
|
/** 哪些 agent 对该 global 源做了隐藏 */
|
|
69
96
|
listAgentsHidingSource(sourceId: string, opts?: {
|
|
70
97
|
tenantId?: string;
|
|
71
98
|
gatewayId?: string;
|
|
72
99
|
}): string[];
|
|
100
|
+
/** 哪些 agent 挂载了该源 */
|
|
101
|
+
listAgentsMountingSource(sourceId: string, opts?: {
|
|
102
|
+
tenantId?: string;
|
|
103
|
+
gatewayId?: string;
|
|
104
|
+
}): string[];
|
|
105
|
+
private listAgentsOp;
|
|
73
106
|
/**
|
|
74
107
|
* 会话 overlay:单条 upsert(资产归属不变,只改本场视图)
|
|
75
108
|
*/
|
|
@@ -90,7 +123,7 @@ export declare class KnowledgeSourceStore {
|
|
|
90
123
|
}, identity?: {
|
|
91
124
|
tenantId?: string;
|
|
92
125
|
gatewayId?: string;
|
|
93
|
-
}): void;
|
|
126
|
+
}, op?: 'include' | 'exclude'): void;
|
|
94
127
|
listSessionVisibility(sessionId: string, identity?: {
|
|
95
128
|
tenantId?: string;
|
|
96
129
|
gatewayId?: string;
|
|
@@ -100,6 +133,7 @@ export declare class KnowledgeSourceStore {
|
|
|
100
133
|
tenantId?: string;
|
|
101
134
|
gatewayId?: string;
|
|
102
135
|
}): Array<{
|
|
136
|
+
tenantId: string;
|
|
103
137
|
projectKey: string;
|
|
104
138
|
displayName?: string;
|
|
105
139
|
sourceCount: number;
|
|
@@ -109,6 +143,7 @@ export declare class KnowledgeSourceStore {
|
|
|
109
143
|
createProject(projectKey: string, displayName?: string, opts?: {
|
|
110
144
|
tenantId?: string;
|
|
111
145
|
registeredBy?: string;
|
|
146
|
+
visibility?: string;
|
|
112
147
|
}): void;
|
|
113
148
|
/**
|
|
114
149
|
* 删除项目登记。非空项目拒绝(先卸载/删除项目下源),避免孤儿源与静默收养。
|
|
@@ -117,14 +152,27 @@ export declare class KnowledgeSourceStore {
|
|
|
117
152
|
tenantId?: string;
|
|
118
153
|
}): boolean;
|
|
119
154
|
/**
|
|
120
|
-
* 源是否对 (agent, session)
|
|
155
|
+
* 源是否对 (agent, session) 可见(租户闸 ⊕ 网关漏斗 ⊕ base ⊕ session overlay)
|
|
121
156
|
*/
|
|
122
157
|
isVisible(source: KnowledgeSource, agentId: string, sessionId?: string, identity?: {
|
|
123
158
|
tenantId?: string;
|
|
124
159
|
gatewayId?: string;
|
|
125
160
|
}): boolean;
|
|
126
|
-
/**
|
|
127
|
-
|
|
161
|
+
/**
|
|
162
|
+
* 租户闸(arch/multi-tenancy.md §4/§6):有归属租户即生效(不依赖 gatewayId)。
|
|
163
|
+
* platform 域(PLATFORM_TENANT_ID)= broker/运维面,全量可见;其余只见本域 ∪ platform;
|
|
164
|
+
* 无归属 = DEFAULT 域(fail-closed,评审 MAJ-2:不做全量放行——存量语义即 default 域)。
|
|
165
|
+
*/
|
|
166
|
+
isTenantVisible(source: {
|
|
167
|
+
id: string;
|
|
168
|
+
}, identity?: {
|
|
169
|
+
tenantId?: string;
|
|
170
|
+
gatewayId?: string;
|
|
171
|
+
}): boolean;
|
|
172
|
+
/** 网关漏斗:registered_by=己方 ∪ public(租户闸已由 isTenantVisible 独立收口) */
|
|
173
|
+
isGatewayVisible(source: {
|
|
174
|
+
id: string;
|
|
175
|
+
}, identity?: {
|
|
128
176
|
tenantId?: string;
|
|
129
177
|
gatewayId?: string;
|
|
130
178
|
}): boolean;
|
|
@@ -136,6 +184,10 @@ export declare class KnowledgeSourceStore {
|
|
|
136
184
|
private applySessionOverlay;
|
|
137
185
|
private sessionOp;
|
|
138
186
|
private isHidden;
|
|
187
|
+
/** 挂载(T3b):include 覆盖 = 挂载库(§6 命中=挂载库∪本租户公共∪platform 公共) */
|
|
188
|
+
private isMounted;
|
|
189
|
+
/** (agent, source) 的可见性 override(单 op:include=挂载 / exclude=隐藏;无行=基础语义) */
|
|
190
|
+
private agentOp;
|
|
139
191
|
private isProjectAssigned;
|
|
140
192
|
/** catalog 规模/topics 派生缓存(Tier 0 每轮装配;短 TTL 足够) */
|
|
141
193
|
private catalogExtrasCache;
|
|
@@ -180,6 +232,50 @@ export declare class KnowledgeSourceStore {
|
|
|
180
232
|
tenantId?: string;
|
|
181
233
|
gatewayId?: string;
|
|
182
234
|
}): KnowledgeSource[];
|
|
235
|
+
/**
|
|
236
|
+
* 批量判定期的项目行缓存(评审 m6):一次装载全部项目行,批次内逐源判定走缓存;
|
|
237
|
+
* 可嵌套(外层已开则复用),finally 必须还原(防缓存外泄到批次外的读路径)。
|
|
238
|
+
*/
|
|
239
|
+
withProjectRowCache<T>(fn: () => T): T;
|
|
240
|
+
/** source 行读取(listVisible 批处理期走同步缓存) */
|
|
241
|
+
private sourceRow;
|
|
242
|
+
/** 项目行按 key 批量缓存读取(缓存期一次装载;否则按 key 单查——idx_knowledge_projects_key) */
|
|
243
|
+
private projectRowsByKey;
|
|
244
|
+
/** 项目行按源归属域解析(同一 project_key 可在多个租户域各登记一行,必须按域取行) */
|
|
245
|
+
private projectRow;
|
|
246
|
+
/**
|
|
247
|
+
* 项目跨域闸(arch/multi-tenancy.md §6):本域项目可见;platform 项目仅
|
|
248
|
+
* `visibility='public'` 才对租户可见(跨租户共享唯一合法形态 = platform 公共);
|
|
249
|
+
* 项目行按**源自身归属域**解析;无登记行(孤儿挂载)= 无归属,不设闸。
|
|
250
|
+
*/
|
|
251
|
+
isProjectVisible(source: {
|
|
252
|
+
id: string;
|
|
253
|
+
}, projectKey: string, identity?: {
|
|
254
|
+
tenantId?: string;
|
|
255
|
+
gatewayId?: string;
|
|
256
|
+
}): boolean;
|
|
257
|
+
/**
|
|
258
|
+
* 项目跨域闸(写侧防绕过用):key 必须存在**对写者可见**的登记行(任一域命中即放行);
|
|
259
|
+
* 完全无登记行 = 孤儿挂载,不设闸(既有语义)。
|
|
260
|
+
*/
|
|
261
|
+
isProjectVisibleTo(projectKey: string, identity?: {
|
|
262
|
+
tenantId?: string;
|
|
263
|
+
gatewayId?: string;
|
|
264
|
+
}): boolean;
|
|
265
|
+
/**
|
|
266
|
+
* 项目行解析(管理面域继承用):返回对 identity 可见的项目行(同 key 跨域多行时
|
|
267
|
+
* 本域优先,其次 platform,再按域名字典序);无可见行 = null。
|
|
268
|
+
*/
|
|
269
|
+
getProject(projectKey: string, identity?: {
|
|
270
|
+
tenantId?: string;
|
|
271
|
+
gatewayId?: string;
|
|
272
|
+
}): {
|
|
273
|
+
tenantId: string;
|
|
274
|
+
projectKey: string;
|
|
275
|
+
displayName?: string;
|
|
276
|
+
visibility: 'public' | 'private';
|
|
277
|
+
} | null;
|
|
278
|
+
private resolveProjectRow;
|
|
183
279
|
/** Agent 级 base 可见源(不含会话 overlay) */
|
|
184
280
|
listBaseVisible(agentId: string, sessionId?: string, identity?: {
|
|
185
281
|
tenantId?: string;
|