@octopi-agent/engine 0.98.4 → 0.121.10
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/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 +6 -2
- package/dist/config-admin/index.js +3 -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 +71 -0
- package/dist/config-admin/onboarding-apply.js +235 -0
- package/dist/config-admin/onboarding.d.ts +154 -0
- package/dist/config-admin/onboarding.js +270 -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 +40 -6
- package/dist/config-schema/agent.js +44 -6
- package/dist/config-schema/browser.d.ts +62 -0
- package/dist/config-schema/browser.js +89 -0
- package/dist/config-schema/context.d.ts +12 -37
- package/dist/config-schema/context.js +10 -31
- package/dist/config-schema/engine.d.ts +140 -164
- package/dist/config-schema/engine.js +10 -7
- package/dist/config-schema/governance.d.ts +20 -2
- package/dist/config-schema/governance.js +18 -3
- package/dist/config-schema/models.d.ts +10 -12
- package/dist/config-schema/models.js +16 -3
- package/dist/config-schema/run.d.ts +6 -2
- package/dist/config-schema/run.js +12 -2
- package/dist/config-schema/shared.d.ts +1 -3
- package/dist/config-schema/shared.js +4 -4
- package/dist/config-schema/substrate.d.ts +19 -88
- package/dist/config-schema/substrate.js +30 -107
- package/dist/config.d.ts +161 -123
- package/dist/config.js +109 -7
- 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 +11 -0
- package/dist/harness/activation/inbox.d.ts +3 -3
- package/dist/harness/activation/inbox.js +3 -3
- 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 +130 -31
- package/dist/harness/activation/types.d.ts +20 -3
- package/dist/harness/agent/builder.d.ts +36 -3
- package/dist/harness/agent/builder.js +206 -46
- package/dist/harness/agent/config-bridge.d.ts +10 -1
- package/dist/harness/agent/config-bridge.js +24 -5
- package/dist/harness/agent/config-integrity.js +19 -2
- 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 +13 -3
- package/dist/harness/agent/wire-agent-builder.js +35 -9
- package/dist/harness/capabilities/document/backends/plain.js +2 -1
- package/dist/harness/capabilities/document/factory.d.ts +5 -0
- package/dist/harness/capabilities/document/factory.js +1 -0
- package/dist/harness/capabilities/document/legacy/factory.js +3 -2
- package/dist/harness/capabilities/document/port.js +6 -3
- package/dist/harness/capabilities/document/types.d.ts +5 -0
- 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 +2 -1
- 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 +14 -4
- package/dist/harness/collaboration/autonomous-subsystem/sense/engine.js +50 -41
- package/dist/harness/collaboration/autonomous-subsystem/sense/input-builder.js +4 -4
- package/dist/harness/collaboration/autonomous-subsystem/sense/metrics.d.ts +2 -2
- package/dist/harness/collaboration/autonomous-subsystem/sense/metrics.js +2 -2
- package/dist/harness/collaboration/autonomous-subsystem/signal/bus.d.ts +6 -0
- package/dist/harness/collaboration/autonomous-subsystem/signal/bus.js +25 -4
- package/dist/harness/collaboration/autonomous-subsystem/think/executor.js +4 -1
- package/dist/harness/collaboration/autonomous-subsystem/types.d.ts +7 -3
- package/dist/harness/collaboration/delegation/child-run.d.ts +10 -1
- package/dist/harness/collaboration/delegation/child-run.js +38 -6
- package/dist/harness/collaboration/delegation/index.d.ts +1 -1
- package/dist/harness/collaboration/delegation/index.js +1 -1
- package/dist/harness/collaboration/delegation/notifier.d.ts +6 -1
- package/dist/harness/collaboration/delegation/notifier.js +8 -1
- package/dist/harness/collaboration/delegation/registry-types.d.ts +2 -0
- package/dist/harness/collaboration/delegation/service.d.ts +11 -4
- package/dist/harness/collaboration/delegation/service.js +35 -13
- package/dist/harness/collaboration/delegation/store.d.ts +4 -0
- package/dist/harness/collaboration/delegation/store.js +3 -1
- package/dist/harness/collaboration/delegation/types.d.ts +34 -2
- package/dist/harness/collaboration/delegation/types.js +22 -0
- package/dist/harness/collaboration/delegation/wiring.d.ts +2 -0
- package/dist/harness/collaboration/delegation/wiring.js +12 -1
- package/dist/harness/context/budget-allocator.d.ts +26 -18
- package/dist/harness/context/budget-allocator.js +67 -32
- package/dist/harness/context/capabilities/compact/engine.d.ts +44 -11
- package/dist/harness/context/capabilities/compact/engine.js +296 -160
- package/dist/harness/context/capabilities/compact/handover.d.ts +5 -3
- package/dist/harness/context/capabilities/compact/handover.js +7 -5
- package/dist/harness/context/capabilities/compact/index.d.ts +7 -2
- package/dist/harness/context/capabilities/compact/index.js +5 -1
- package/dist/harness/context/capabilities/compact/mechanical.d.ts +130 -0
- package/dist/harness/context/capabilities/compact/mechanical.js +268 -0
- package/dist/harness/context/capabilities/compact/messages.d.ts +60 -0
- package/dist/harness/context/capabilities/compact/messages.js +91 -0
- package/dist/harness/context/capabilities/compact/types.d.ts +134 -19
- package/dist/harness/context/capabilities/compact/types.js +11 -1
- package/dist/harness/context/capabilities/compact/view-split.d.ts +36 -0
- package/dist/harness/context/capabilities/compact/view-split.js +72 -0
- 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/port.js +0 -1
- package/dist/harness/context/capabilities/summary/registry.js +20 -0
- package/dist/harness/context/capabilities/summary/resolver.d.ts +1 -1
- package/dist/harness/context/capabilities/summary/resolver.js +1 -6
- package/dist/harness/context/capabilities/summary/tool-binding.d.ts +1 -1
- 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 +19 -6
- package/dist/harness/context/constitution/default-agents.md +85 -0
- package/dist/harness/context/context-size-ledger.d.ts +143 -0
- package/dist/harness/context/context-size-ledger.js +243 -0
- package/dist/harness/context/default-context-engine.d.ts +290 -120
- package/dist/harness/context/default-context-engine.js +1555 -764
- package/dist/harness/context/index.d.ts +3 -2
- package/dist/harness/context/index.js +2 -1
- 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 +72 -0
- package/dist/harness/context/layer-types.js +87 -2
- package/dist/harness/context/layers.d.ts +17 -15
- package/dist/harness/context/layers.js +54 -17
- package/dist/harness/context/message-selector.d.ts +10 -8
- package/dist/harness/context/message-selector.js +49 -27
- package/dist/harness/context/prefix-fingerprint.d.ts +46 -0
- package/dist/harness/context/prefix-fingerprint.js +52 -0
- package/dist/harness/context/summarize.d.ts +2 -2
- package/dist/harness/context/summarize.js +27 -2
- package/dist/harness/context/system-prompt-assembler.d.ts +4 -0
- package/dist/harness/context/system-prompt-assembler.js +7 -3
- package/dist/harness/context/token-constants.d.ts +8 -6
- package/dist/harness/context/token-constants.js +8 -7
- package/dist/harness/context/token-estimate-fns.d.ts +37 -27
- package/dist/harness/context/token-estimate-fns.js +85 -66
- package/dist/harness/context/token-estimator.d.ts +27 -12
- package/dist/harness/context/token-estimator.js +120 -66
- package/dist/harness/context/token-segments.d.ts +88 -0
- package/dist/harness/context/token-segments.js +103 -0
- package/dist/harness/context/tool-result-aging.d.ts +109 -16
- package/dist/harness/context/tool-result-aging.js +220 -55
- package/dist/harness/context/tool-result-body.js +2 -0
- package/dist/harness/context/transform/anchors.d.ts +66 -0
- package/dist/harness/context/transform/anchors.js +125 -0
- package/dist/harness/context/transform/fold.d.ts +56 -0
- package/dist/harness/context/transform/fold.js +135 -0
- package/dist/harness/context/transform/migrate.d.ts +41 -0
- package/dist/harness/context/transform/migrate.js +69 -0
- package/dist/harness/context/transform/types.d.ts +129 -0
- package/dist/harness/context/transform/types.js +19 -0
- package/dist/harness/context/turn-envelope.d.ts +6 -3
- package/dist/harness/context/types.d.ts +196 -119
- 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/ops-audit.d.ts +1 -1
- package/dist/harness/extension/execution-environment/privileged-exec.js +4 -1
- package/dist/harness/extension/execution-environment/resource-limits.d.ts +1 -1
- package/dist/harness/extension/execution-environment/resource-limits.js +1 -1
- package/dist/harness/extension/execution-environment/workspace.js +1 -1
- package/dist/harness/extension/plugin-ecosystem/channel-types.d.ts +28 -2
- 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/commands/index.d.ts +3 -1
- package/dist/harness/extension/plugin-ecosystem/commands/index.js +1 -0
- package/dist/harness/extension/plugin-ecosystem/commands/plugin-bridge.d.ts +12 -1
- package/dist/harness/extension/plugin-ecosystem/commands/plugin-bridge.js +14 -4
- package/dist/harness/extension/plugin-ecosystem/commands/router.d.ts +5 -4
- package/dist/harness/extension/plugin-ecosystem/commands/router.js +23 -14
- package/dist/harness/extension/plugin-ecosystem/commands/types.d.ts +8 -1
- package/dist/harness/extension/plugin-ecosystem/commands/types.js +2 -1
- package/dist/harness/extension/plugin-ecosystem/hooks/adapter.d.ts +54 -0
- package/dist/harness/extension/plugin-ecosystem/hooks/adapter.js +397 -0
- package/dist/harness/extension/plugin-ecosystem/hooks/compaction-integration.d.ts +16 -0
- package/dist/harness/extension/plugin-ecosystem/hooks/compaction-integration.js +66 -0
- package/dist/harness/extension/plugin-ecosystem/hooks/index.d.ts +4 -0
- package/dist/harness/extension/plugin-ecosystem/hooks/index.js +2 -0
- package/dist/harness/extension/plugin-ecosystem/hooks/iteration-snapshot.d.ts +11 -0
- package/dist/harness/extension/plugin-ecosystem/hooks/iteration-snapshot.js +54 -0
- package/dist/harness/extension/plugin-ecosystem/hooks/journal.d.ts +9 -0
- package/dist/harness/extension/plugin-ecosystem/hooks/journal.js +22 -0
- package/dist/harness/extension/plugin-ecosystem/hooks/policy-error.d.ts +12 -0
- package/dist/harness/extension/plugin-ecosystem/hooks/policy-error.js +19 -0
- package/dist/harness/extension/plugin-ecosystem/hooks/run-integration.d.ts +36 -0
- package/dist/harness/extension/plugin-ecosystem/hooks/run-integration.js +338 -0
- package/dist/harness/extension/plugin-ecosystem/hooks/services.d.ts +24 -0
- package/dist/harness/extension/plugin-ecosystem/hooks/services.js +139 -0
- package/dist/harness/extension/plugin-ecosystem/hooks/types.d.ts +229 -0
- package/dist/harness/extension/plugin-ecosystem/hooks/types.js +1 -0
- 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 +223 -222
- package/dist/harness/extension/plugin-ecosystem/plugins/api.js +218 -203
- 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 +78 -0
- package/dist/harness/extension/plugin-ecosystem/plugins/contribution-registry.js +80 -0
- package/dist/harness/extension/plugin-ecosystem/plugins/engine-compatibility.d.ts +4 -0
- package/dist/harness/extension/plugin-ecosystem/plugins/engine-compatibility.js +18 -0
- package/dist/harness/extension/plugin-ecosystem/plugins/entry.d.ts +7 -85
- package/dist/harness/extension/plugin-ecosystem/plugins/entry.js +8 -50
- package/dist/harness/extension/plugin-ecosystem/plugins/index.d.ts +6 -23
- package/dist/harness/extension/plugin-ecosystem/plugins/index.js +3 -23
- package/dist/harness/extension/plugin-ecosystem/plugins/loader.d.ts +57 -114
- package/dist/harness/extension/plugin-ecosystem/plugins/loader.js +279 -282
- package/dist/harness/extension/plugin-ecosystem/plugins/manager.d.ts +46 -484
- package/dist/harness/extension/plugin-ecosystem/plugins/manager.js +123 -345
- package/dist/harness/extension/plugin-ecosystem/plugins/manifest.d.ts +50 -223
- package/dist/harness/extension/plugin-ecosystem/plugins/manifest.js +144 -20
- package/dist/harness/extension/plugin-ecosystem/plugins/staging.d.ts +17 -0
- package/dist/harness/extension/plugin-ecosystem/plugins/staging.js +15 -0
- package/dist/harness/extension/plugin-ecosystem/skills/manager.d.ts +6 -1
- package/dist/harness/extension/plugin-ecosystem/skills/manager.js +17 -1
- package/dist/harness/extension/plugin-ecosystem/tools/ask-user.d.ts +3 -0
- package/dist/harness/extension/plugin-ecosystem/tools/ask-user.js +46 -21
- 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 +36 -8
- 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/plugin-tool.d.ts +11 -0
- package/dist/harness/extension/plugin-ecosystem/tools/plugin-tool.js +39 -0
- package/dist/harness/extension/plugin-ecosystem/tools/tool-bus.d.ts +1 -1
- package/dist/harness/extension/plugin-ecosystem/tools/tool-bus.js +19 -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/accounting/usage-ledger.d.ts +13 -1
- package/dist/harness/governance/accounting/usage-ledger.js +23 -1
- 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/human-in-the-loop/decision-cache.d.ts +3 -3
- package/dist/harness/governance/human-in-the-loop/decision-cache.js +2 -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/capability-enforcer.js +1 -2
- 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 +17 -15
- package/dist/harness/index.js +9 -9
- package/dist/harness/knowledge/boot-config.d.ts +57 -0
- package/dist/harness/knowledge/boot-config.js +52 -0
- package/dist/harness/knowledge/catalog-types.d.ts +2 -0
- package/dist/harness/knowledge/client.d.ts +77 -9
- package/dist/harness/knowledge/client.js +95 -24
- package/dist/harness/knowledge/db.d.ts +16 -0
- package/dist/harness/knowledge/db.js +112 -41
- package/dist/harness/knowledge/describe-sample.d.ts +23 -0
- package/dist/harness/knowledge/describe-sample.js +58 -0
- package/dist/harness/knowledge/describe.d.ts +8 -0
- package/dist/harness/knowledge/describe.js +18 -2
- package/dist/harness/knowledge/engine-thread.js +11 -7
- package/dist/harness/knowledge/grounding.js +7 -2
- package/dist/harness/knowledge/http-app.d.ts +15 -0
- package/dist/harness/knowledge/http-app.js +117 -25
- package/dist/harness/knowledge/http-bridge.d.ts +15 -0
- package/dist/harness/knowledge/http-bridge.js +19 -0
- package/dist/harness/knowledge/http-params.d.ts +18 -0
- package/dist/harness/knowledge/http-params.js +24 -0
- package/dist/harness/knowledge/index.d.ts +2 -0
- package/dist/harness/knowledge/index.js +1 -0
- package/dist/harness/knowledge/knowledge-serve-child.js +5 -3
- package/dist/harness/knowledge/purge.js +5 -2
- package/dist/harness/knowledge/query-service.d.ts +25 -4
- package/dist/harness/knowledge/query-service.js +79 -43
- package/dist/harness/knowledge/query-worker-client.d.ts +14 -2
- package/dist/harness/knowledge/query-worker-client.js +8 -3
- package/dist/harness/knowledge/query-worker.js +9 -5
- package/dist/harness/knowledge/read-http.d.ts +2 -0
- package/dist/harness/knowledge/read-http.js +14 -3
- package/dist/harness/knowledge/retriever.d.ts +1 -1
- package/dist/harness/knowledge/retriever.js +1 -2
- package/dist/harness/knowledge/serve.d.ts +14 -8
- package/dist/harness/knowledge/serve.js +14 -6
- package/dist/harness/knowledge/source-store.d.ts +101 -5
- package/dist/harness/knowledge/source-store.js +323 -74
- package/dist/harness/knowledge/start-service-process.d.ts +41 -14
- package/dist/harness/knowledge/start-service-process.js +67 -96
- package/dist/harness/knowledge/tenant-gate.d.ts +81 -0
- package/dist/harness/knowledge/tenant-gate.js +167 -0
- package/dist/harness/knowledge/types.d.ts +7 -0
- package/dist/harness/knowledge/writer-service.d.ts +55 -11
- package/dist/harness/knowledge/writer-service.js +200 -30
- package/dist/harness/knowledge/writer-worker-client.d.ts +19 -11
- package/dist/harness/knowledge/writer-worker-client.js +40 -5
- package/dist/harness/knowledge/writer-worker.js +20 -5
- 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/sqlite/wisdom-store.js +35 -10
- package/dist/harness/memory/types.d.ts +24 -6
- package/dist/harness/memory/wisdom-formation.d.ts +14 -3
- package/dist/harness/memory/wisdom-formation.js +85 -22
- package/dist/harness/memory/wisdom-gates.d.ts +14 -0
- package/dist/harness/memory/wisdom-gates.js +59 -19
- package/dist/harness/memory/wisdom.js +9 -0
- package/dist/harness/observability/observer/hub.d.ts +10 -0
- package/dist/harness/observability/observer/hub.js +120 -17
- package/dist/harness/observability/observer/types.d.ts +10 -6
- package/dist/harness/run/agent/agent.d.ts +40 -21
- package/dist/harness/run/agent/agent.js +67 -13
- package/dist/harness/run/agent/index.d.ts +1 -1
- package/dist/harness/run/budget/budget.d.ts +28 -10
- package/dist/harness/run/budget/budget.js +38 -15
- package/dist/harness/run/concurrency/tool-validator.js +4 -3
- package/dist/harness/run/model/index.d.ts +3 -1
- package/dist/harness/run/model/index.js +2 -1
- package/dist/harness/run/model/resolver.d.ts +4 -1
- package/dist/harness/run/model/resolver.js +36 -2
- package/dist/harness/run/model/run-scope.d.ts +2 -0
- package/dist/harness/run/model/run-scope.js +7 -0
- package/dist/harness/run/model/types.d.ts +22 -5
- package/dist/harness/run/model/types.js +3 -2
- package/dist/harness/run/model/window-truth.d.ts +37 -0
- package/dist/harness/run/model/window-truth.js +39 -0
- package/dist/harness/run/reliability/context-length-feedback.d.ts +77 -0
- package/dist/harness/run/reliability/context-length-feedback.js +128 -0
- package/dist/harness/run/reliability/harness-events.d.ts +3 -3
- package/dist/harness/run/reliability/model-error-policy.js +4 -0
- package/dist/harness/run/reliability/run-agent.d.ts +32 -4
- package/dist/harness/run/reliability/run-agent.js +216 -63
- package/dist/harness/run/reliability/run-metrics-collector.d.ts +19 -8
- package/dist/harness/run/reliability/run-metrics-collector.js +38 -23
- package/dist/harness/run/run-guard/default-run-guard.js +8 -8
- 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 +48 -4
- package/dist/harness/run/run-scope.js +19 -1
- package/dist/harness/run/runner.d.ts +181 -39
- package/dist/harness/run/runner.js +654 -119
- package/dist/harness/session/attachments/index.d.ts +1 -0
- package/dist/harness/session/attachments/index.js +1 -0
- package/dist/harness/session/attachments/inject.d.ts +21 -10
- package/dist/harness/session/attachments/inject.js +76 -24
- package/dist/harness/session/attachments/recall-index.d.ts +70 -0
- package/dist/harness/session/attachments/recall-index.js +219 -0
- package/dist/harness/session/attachments/service.d.ts +21 -0
- package/dist/harness/session/attachments/service.js +258 -139
- package/dist/harness/session/attachments/types.d.ts +6 -0
- 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/transform-store.d.ts +136 -0
- package/dist/harness/session/transform-store.js +302 -0
- package/dist/harness/session/types.d.ts +11 -15
- package/dist/harness/shared/events/agent-event-map.d.ts +75 -13
- package/dist/harness/shared/events/agent-event-map.js +3 -2
- package/dist/harness/shared/events/scenario-events.d.ts +6 -6
- package/dist/harness/shared/types/agent-definition.d.ts +7 -2
- package/dist/index.d.ts +16 -18
- package/dist/index.js +9 -10
- 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/observability/metrics.d.ts +6 -6
- package/dist/integration/observability/metrics.js +13 -13
- package/dist/integration/observability/observer-bridge.js +2 -2
- package/dist/integration/observability/trace-collector.d.ts +5 -5
- package/dist/integration/observability/trace-collector.js +34 -35
- package/dist/integration/observability/trace-events.d.ts +3 -3
- package/dist/integration/observability/trace-events.js +3 -3
- 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 +41 -3
- 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 +48 -2
- package/dist/integration/providers/usage.d.ts +1 -1
- package/dist/integration/providers/wire-dump-diff.js +2 -1
- package/dist/integration/providers/wire-dump.d.ts +57 -3
- package/dist/integration/providers/wire-dump.js +119 -6
- package/dist/integration/storage/archive-manager.d.ts +20 -2
- package/dist/integration/storage/archive-manager.js +34 -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 +10 -1
- package/dist/integration/storage/jsonl.js +155 -54
- 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/SUBSYSTEM.md +8 -1
- package/dist/subsystems/wisdom-steward/formation/config.yaml +4 -0
- package/dist/subsystems/wisdom-steward/formation/handler.js +27 -5
- package/dist/subsystems/wisdom-steward/govern/config.yaml +6 -1
- package/package.json +14 -15
- package/dist/harness/context/hybrid-compressor.d.ts +0 -41
- package/dist/harness/context/hybrid-compressor.js +0 -159
- package/dist/harness/context/llm-summarizer.d.ts +0 -46
- package/dist/harness/context/llm-summarizer.js +0 -249
- package/dist/harness/context/smart-router.d.ts +0 -75
- package/dist/harness/context/smart-router.js +0 -118
- package/dist/harness/context/truncate-compressor.d.ts +0 -28
- package/dist/harness/context/truncate-compressor.js +0 -107
- package/dist/harness/extension/plugin-ecosystem/plugins/capability.d.ts +0 -97
- package/dist/harness/extension/plugin-ecosystem/plugins/capability.js +0 -155
- package/dist/harness/extension/plugin-ecosystem/plugins/hooks.d.ts +0 -7
- package/dist/harness/extension/plugin-ecosystem/plugins/hooks.js +0 -7
- package/dist/harness/extension/plugin-ecosystem/plugins/lifecycle.d.ts +0 -86
- package/dist/harness/extension/plugin-ecosystem/plugins/lifecycle.js +0 -139
|
@@ -7,6 +7,7 @@
|
|
|
7
7
|
* **禁止**在此接口上实现任何写路径(唯一写者是 Writer Worker / LocalKnowledgeWriteService)。
|
|
8
8
|
*/
|
|
9
9
|
import { readJobControlState, } from './job-control-state.js';
|
|
10
|
+
import { ownerFunnelSql, projectGateSql, tenantGateSql, tenantOwnGateSql, tenantPrecedenceOrder } from './tenant-gate.js';
|
|
10
11
|
import { KnowledgeHitLog } from './hit-log.js';
|
|
11
12
|
/**
|
|
12
13
|
* 进程内只读实现(测试 / 共享 :memory:)。
|
|
@@ -43,7 +44,7 @@ export class LocalKnowledgeQueryService {
|
|
|
43
44
|
const { sources } = this.deps;
|
|
44
45
|
let list = sources.list();
|
|
45
46
|
if (query.identity) {
|
|
46
|
-
list = list.filter((s) => this.
|
|
47
|
+
list = sources.withProjectRowCache(() => list.filter((s) => this.domainVisible(s, query.identity)));
|
|
47
48
|
}
|
|
48
49
|
if (query.scopeLevel === 'global' || query.scopeLevel === 'project' || query.scopeLevel === 'session') {
|
|
49
50
|
list = list.filter((s) => s.scopeRef.level === query.scopeLevel);
|
|
@@ -66,18 +67,21 @@ export class LocalKnowledgeQueryService {
|
|
|
66
67
|
gatewayId: identity?.gatewayId,
|
|
67
68
|
});
|
|
68
69
|
}
|
|
70
|
+
async getProject(identity, projectKey) {
|
|
71
|
+
return this.deps.sources.getProject(projectKey, identity);
|
|
72
|
+
}
|
|
69
73
|
async getSource(sourceId, identity) {
|
|
70
74
|
const src = this.deps.sources.get(sourceId);
|
|
71
75
|
if (!src)
|
|
72
76
|
return null;
|
|
73
|
-
if (identity && !this.
|
|
77
|
+
if (identity && !this.domainVisible(src, identity))
|
|
74
78
|
return null;
|
|
75
79
|
return { source: src, stats: this.deps.index.sourceStats(sourceId) };
|
|
76
80
|
}
|
|
77
81
|
async listFiles(sourceId, identity) {
|
|
78
82
|
if (identity) {
|
|
79
83
|
const src = this.deps.sources.get(sourceId);
|
|
80
|
-
if (!src || !this.
|
|
84
|
+
if (!src || !this.domainVisible(src, identity))
|
|
81
85
|
return [];
|
|
82
86
|
}
|
|
83
87
|
return this.deps.index.listFiles(sourceId);
|
|
@@ -85,7 +89,7 @@ export class LocalKnowledgeQueryService {
|
|
|
85
89
|
async listFilesPaged(sourceId, opts, identity) {
|
|
86
90
|
if (identity) {
|
|
87
91
|
const src = this.deps.sources.get(sourceId);
|
|
88
|
-
if (!src || !this.
|
|
92
|
+
if (!src || !this.domainVisible(src, identity)) {
|
|
89
93
|
return {
|
|
90
94
|
items: [],
|
|
91
95
|
total: 0,
|
|
@@ -100,20 +104,32 @@ export class LocalKnowledgeQueryService {
|
|
|
100
104
|
}
|
|
101
105
|
async principalStats(agentId, identity) {
|
|
102
106
|
const { sources, db } = this.deps;
|
|
103
|
-
const visible = sources.listVisible(agentId, undefined, identity).filter((s) => {
|
|
104
|
-
return !identity || this.
|
|
105
|
-
});
|
|
106
|
-
|
|
107
|
+
const visible = sources.withProjectRowCache(() => sources.listVisible(agentId, undefined, identity).filter((s) => {
|
|
108
|
+
return !identity || this.domainVisible(s, identity);
|
|
109
|
+
}));
|
|
110
|
+
// 评审 m7(拍板 B):面板统计=本视图口径(只数可见源);全库口径属运维面
|
|
111
|
+
// (doctor/ops),等运维功能落地后再回接,避免「统计有数、列表为空」式误读
|
|
112
|
+
const stats = db.statsForSourceIds(visible.map((s) => s.id));
|
|
113
|
+
const assignedProjects = sources.withProjectRowCache(() => sources
|
|
114
|
+
.list()
|
|
115
|
+
.filter((s) => s.scopeRef.level === 'project' &&
|
|
116
|
+
sources.isVisible(s, agentId, undefined, identity) &&
|
|
117
|
+
(!identity || this.domainVisible(s, identity)))
|
|
118
|
+
.map((s) => s.scopeRef.key));
|
|
119
|
+
const hiddenSourceIds = sources.listHidden(agentId, identity ?? {});
|
|
120
|
+
// 可见性计数器同口径:报本 agent/本身份自己的行,不报全库注册表规模
|
|
121
|
+
stats.projectAgents = assignedProjects.length;
|
|
122
|
+
stats.agentHidden = hiddenSourceIds.length;
|
|
123
|
+
stats.agentMounted = sources.listMounted(agentId, identity ?? {}).length;
|
|
124
|
+
const sessionGate = tenantOwnGateSql('tenant_id', identity ?? {});
|
|
125
|
+
stats.sessionVisibility = db.raw
|
|
126
|
+
.prepare(`SELECT COUNT(*) AS count FROM knowledge_session_visibility WHERE ${sessionGate.sql}`)
|
|
127
|
+
.get(...sessionGate.params).count;
|
|
107
128
|
return {
|
|
108
129
|
stats,
|
|
109
130
|
visibility: {
|
|
110
|
-
assignedProjects
|
|
111
|
-
|
|
112
|
-
.filter((s) => s.scopeRef.level === 'project' &&
|
|
113
|
-
sources.isVisible(s, agentId, undefined, identity) &&
|
|
114
|
-
(!identity || this.gatewayVisible(s, identity)))
|
|
115
|
-
.map((s) => s.scopeRef.key),
|
|
116
|
-
hiddenSourceIds: sources.listHidden(agentId, identity ?? {}),
|
|
131
|
+
assignedProjects,
|
|
132
|
+
hiddenSourceIds,
|
|
117
133
|
},
|
|
118
134
|
visibleSources: visible.length,
|
|
119
135
|
};
|
|
@@ -122,17 +138,17 @@ export class LocalKnowledgeQueryService {
|
|
|
122
138
|
const items = this.deps.sources.catalogFor(agentId, { identity });
|
|
123
139
|
if (!identity)
|
|
124
140
|
return items;
|
|
125
|
-
return items.filter((item) => {
|
|
141
|
+
return this.deps.sources.withProjectRowCache(() => items.filter((item) => {
|
|
126
142
|
const src = this.deps.sources.get(item.id);
|
|
127
|
-
return !src || this.
|
|
128
|
-
});
|
|
143
|
+
return !src || this.domainVisible(src, identity);
|
|
144
|
+
}));
|
|
129
145
|
}
|
|
130
146
|
async listChunks(agentId, sourceId, path, identity, sessionId) {
|
|
131
147
|
const { sources, index } = this.deps;
|
|
132
148
|
const src = sources.get(sourceId);
|
|
133
149
|
if (!src)
|
|
134
150
|
return null;
|
|
135
|
-
if (identity && !this.
|
|
151
|
+
if (identity && !this.domainVisible(src, identity))
|
|
136
152
|
return null;
|
|
137
153
|
if (!sources.isVisible(src, agentId, sessionId, identity))
|
|
138
154
|
return null;
|
|
@@ -143,7 +159,7 @@ export class LocalKnowledgeQueryService {
|
|
|
143
159
|
const visible = (src) => {
|
|
144
160
|
if (!src)
|
|
145
161
|
return false;
|
|
146
|
-
if (identity && !this.
|
|
162
|
+
if (identity && !this.domainVisible(src, identity))
|
|
147
163
|
return false;
|
|
148
164
|
return sources.isVisible(src, agentId, sessionId, identity);
|
|
149
165
|
};
|
|
@@ -189,7 +205,7 @@ export class LocalKnowledgeQueryService {
|
|
|
189
205
|
.list()
|
|
190
206
|
.filter((s) => s.scopeRef.level === 'project' &&
|
|
191
207
|
sources.isVisible(s, agentId, undefined, identity) &&
|
|
192
|
-
(!identity || this.
|
|
208
|
+
(!identity || this.domainVisible(s, identity)))
|
|
193
209
|
.map((s) => s.scopeRef.key);
|
|
194
210
|
return {
|
|
195
211
|
assignedProjects: [...new Set(assigned)],
|
|
@@ -205,7 +221,7 @@ export class LocalKnowledgeQueryService {
|
|
|
205
221
|
if (item.targetType !== 'source')
|
|
206
222
|
return true;
|
|
207
223
|
const src = this.deps.sources.get(item.targetId);
|
|
208
|
-
return !src || this.
|
|
224
|
+
return !src || this.domainVisible(src, identity);
|
|
209
225
|
});
|
|
210
226
|
}
|
|
211
227
|
async dbStats() {
|
|
@@ -216,7 +232,7 @@ export class LocalKnowledgeQueryService {
|
|
|
216
232
|
const src = sources.get(sourceId);
|
|
217
233
|
if (!src)
|
|
218
234
|
return null;
|
|
219
|
-
if (identity && !this.
|
|
235
|
+
if (identity && !this.domainVisible(src, identity))
|
|
220
236
|
return null;
|
|
221
237
|
const jobControl = readJobControlState(db, index, sourceId, {
|
|
222
238
|
embeddingEnabled: this.deps.embeddingEnabled ?? true,
|
|
@@ -232,18 +248,22 @@ export class LocalKnowledgeQueryService {
|
|
|
232
248
|
};
|
|
233
249
|
}
|
|
234
250
|
async getPrincipal(identity, agentId) {
|
|
251
|
+
const gate = tenantOwnGateSql('tenant_id', identity);
|
|
252
|
+
const order = tenantPrecedenceOrder('tenant_id', identity);
|
|
235
253
|
const row = this.deps.db.raw
|
|
236
254
|
.prepare(`SELECT * FROM knowledge_principals
|
|
237
|
-
WHERE
|
|
238
|
-
|
|
255
|
+
WHERE ${gate.sql} AND gateway_id = ? AND local_agent_id = ?
|
|
256
|
+
ORDER BY ${order.sql} LIMIT 1`)
|
|
257
|
+
.get(...gate.params, identity.gatewayId ?? 'default', agentId, ...order.params);
|
|
239
258
|
return row ?? null;
|
|
240
259
|
}
|
|
241
260
|
async isPrincipalForeign(identity, agentId) {
|
|
261
|
+
const gate = tenantOwnGateSql('tenant_id', identity);
|
|
242
262
|
const row = this.deps.db.raw
|
|
243
263
|
.prepare(`SELECT 1 AS ok FROM knowledge_principals
|
|
244
|
-
WHERE
|
|
264
|
+
WHERE ${gate.sql} AND local_agent_id = ? AND gateway_id != ?
|
|
245
265
|
LIMIT 1`)
|
|
246
|
-
.get(
|
|
266
|
+
.get(...gate.params, agentId, identity.gatewayId ?? 'default');
|
|
247
267
|
return Boolean(row);
|
|
248
268
|
}
|
|
249
269
|
async isSourceOwner(sourceId, gatewayId) {
|
|
@@ -273,10 +293,24 @@ export class LocalKnowledgeQueryService {
|
|
|
273
293
|
};
|
|
274
294
|
}
|
|
275
295
|
async listJobs(query) {
|
|
296
|
+
const tenantGate = tenantGateSql('s.tenant_id', query.identity);
|
|
297
|
+
const funnel = ownerFunnelSql('s.registered_by', 's.visibility', query.identity);
|
|
298
|
+
const projectGate = projectGateSql('p.tenant_id', 'p.visibility', query.identity);
|
|
299
|
+
// 源范围与读侧同口径(评审 m1):租户闸 ⊕ 归属漏斗 ⊕ 项目跨域闸——job 行携带 path/last_error,
|
|
300
|
+
// 不得成为项目闸旁路的元数据泄漏面
|
|
276
301
|
const where = [
|
|
277
|
-
`source_id IN (
|
|
302
|
+
`source_id IN (
|
|
303
|
+
SELECT s.id FROM knowledge_sources s
|
|
304
|
+
WHERE ${tenantGate.sql} AND ${funnel.sql}
|
|
305
|
+
AND (s.scope_level != 'project' OR EXISTS (
|
|
306
|
+
SELECT 1 FROM knowledge_projects p
|
|
307
|
+
WHERE p.project_key = s.scope_key
|
|
308
|
+
AND IFNULL(p.tenant_id, '') = IFNULL(s.tenant_id, '')
|
|
309
|
+
AND ${projectGate.sql}
|
|
310
|
+
))
|
|
311
|
+
)`,
|
|
278
312
|
];
|
|
279
|
-
const args = [
|
|
313
|
+
const args = [...tenantGate.params, ...funnel.params, ...projectGate.params];
|
|
280
314
|
if (query.sourceId) {
|
|
281
315
|
where.push('source_id = ?');
|
|
282
316
|
args.push(query.sourceId);
|
|
@@ -290,23 +324,23 @@ export class LocalKnowledgeQueryService {
|
|
|
290
324
|
.prepare(`SELECT * FROM knowledge_jobs WHERE ${where.join(' AND ')} ORDER BY created_at DESC LIMIT ?`)
|
|
291
325
|
.all(...args, limit);
|
|
292
326
|
}
|
|
293
|
-
async promotionCandidates() {
|
|
294
|
-
return new KnowledgeHitLog(this.deps.db).promotionCandidates();
|
|
327
|
+
async promotionCandidates(opts) {
|
|
328
|
+
return new KnowledgeHitLog(this.deps.db).promotionCandidates(opts);
|
|
295
329
|
}
|
|
296
330
|
dispose() {
|
|
297
331
|
/* 只读;连接由调用方持有 */
|
|
298
332
|
}
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
return
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
333
|
+
/**
|
|
334
|
+
* 控制面读口域闸(T3b,评审 MAJ-4):租户闸 ⊕ 网关漏斗 ⊕ 项目跨域闸,单源委托 source-store
|
|
335
|
+
* (原为本地第二套 gatewayVisible 实现——无租户检查,跨租户可读;且违反单源律)。
|
|
336
|
+
*/
|
|
337
|
+
domainVisible(src, identity) {
|
|
338
|
+
if (src.scopeRef.level === 'project' &&
|
|
339
|
+
!this.deps.sources.isProjectVisible(src, src.scopeRef.key, identity)) {
|
|
340
|
+
return false;
|
|
341
|
+
}
|
|
342
|
+
return (this.deps.sources.isTenantVisible(src, identity) &&
|
|
343
|
+
this.deps.sources.isGatewayVisible(src, identity));
|
|
310
344
|
}
|
|
311
345
|
}
|
|
312
346
|
export async function createKnowledgeQueryService(opts) {
|
|
@@ -319,8 +353,10 @@ export async function createKnowledgeQueryService(opts) {
|
|
|
319
353
|
return WorkerQueryService.start({
|
|
320
354
|
dbPath: opts.dbPath,
|
|
321
355
|
embeddingModels: opts.embeddingModels ?? null,
|
|
322
|
-
|
|
356
|
+
sqliteVec: opts.sqliteVec,
|
|
323
357
|
role: opts.role ?? 'all',
|
|
324
358
|
queryTimeoutMs: opts.queryTimeoutMs,
|
|
359
|
+
embed: opts.embed ?? null,
|
|
360
|
+
retriever: opts.retriever ?? null,
|
|
325
361
|
});
|
|
326
362
|
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { KnowledgeQueryService, SearchQuery, AutoGroundQuery, ListSourcesQuery, QueryIdentity, PrincipalStats, ReadChunkResult, SourceStatsBundle, SourceDetail, ListJobsQuery, ReadySnapshot, QueryWorkerRole } from './query-service.js';
|
|
2
2
|
import type { PromotionCandidate } from './hit-log.js';
|
|
3
|
+
import type { KnowledgeBootEmbed, KnowledgeBootRetriever } from './boot-config.js';
|
|
3
4
|
import type { HybridSearchResult, AutoGroundDecision } from './retriever.js';
|
|
4
5
|
import type { KnowledgeSource } from './types.js';
|
|
5
6
|
import type { KnowledgeCatalogItem } from './catalog-types.js';
|
|
@@ -22,13 +23,20 @@ export declare class WorkerQueryService implements KnowledgeQueryService {
|
|
|
22
23
|
*/
|
|
23
24
|
static start(opts: {
|
|
24
25
|
dbPath: string;
|
|
25
|
-
|
|
26
|
+
sqliteVec?: boolean | {
|
|
27
|
+
extensionPath?: string;
|
|
28
|
+
require?: boolean;
|
|
29
|
+
};
|
|
26
30
|
queryTimeoutMs?: number;
|
|
27
31
|
role?: QueryWorkerRole;
|
|
28
32
|
embeddingModels?: {
|
|
29
33
|
providers?: Record<string, unknown>;
|
|
30
34
|
embedding?: unknown;
|
|
31
35
|
} | null;
|
|
36
|
+
/** 向量化开关(embed.enabled=false 时不建 embedding provider) */
|
|
37
|
+
embed?: KnowledgeBootEmbed | null;
|
|
38
|
+
/** 检索调参(透传进 Worker 的 KnowledgeRetriever) */
|
|
39
|
+
retriever?: KnowledgeBootRetriever | null;
|
|
32
40
|
}): Promise<WorkerQueryService>;
|
|
33
41
|
private failAll;
|
|
34
42
|
private call;
|
|
@@ -36,6 +44,7 @@ export declare class WorkerQueryService implements KnowledgeQueryService {
|
|
|
36
44
|
autoGround(query: AutoGroundQuery): Promise<AutoGroundDecision>;
|
|
37
45
|
listSources(query: ListSourcesQuery): Promise<KnowledgeSource[]>;
|
|
38
46
|
listProjects(identity?: QueryIdentity): Promise<Array<Record<string, unknown>>>;
|
|
47
|
+
getProject(identity: QueryIdentity, projectKey: string): Promise<Record<string, unknown> | null>;
|
|
39
48
|
getSource(sourceId: string, identity?: QueryIdentity): Promise<{
|
|
40
49
|
source: KnowledgeSource;
|
|
41
50
|
stats: SourceStatsBundle;
|
|
@@ -91,6 +100,9 @@ export declare class WorkerQueryService implements KnowledgeQueryService {
|
|
|
91
100
|
isSourceOwner(sourceId: string, gatewayId: string): Promise<boolean>;
|
|
92
101
|
ready(): Promise<ReadySnapshot>;
|
|
93
102
|
listJobs(query: ListJobsQuery): Promise<Array<Record<string, unknown>>>;
|
|
94
|
-
promotionCandidates(
|
|
103
|
+
promotionCandidates(opts?: {
|
|
104
|
+
minSessions?: number;
|
|
105
|
+
minHits?: number;
|
|
106
|
+
}): Promise<PromotionCandidate[]>;
|
|
95
107
|
dispose(): Promise<void>;
|
|
96
108
|
}
|
|
@@ -72,9 +72,11 @@ export class WorkerQueryService {
|
|
|
72
72
|
const worker = new Worker(resolveWorkerUrl('./query-worker.js', import.meta.url), {
|
|
73
73
|
workerData: {
|
|
74
74
|
dbPath: opts.dbPath,
|
|
75
|
-
|
|
75
|
+
sqliteVec: opts.sqliteVec,
|
|
76
76
|
embeddingModels: opts.embeddingModels ?? null,
|
|
77
77
|
role: opts.role ?? 'all',
|
|
78
|
+
embed: opts.embed ?? null,
|
|
79
|
+
retriever: opts.retriever ?? null,
|
|
78
80
|
},
|
|
79
81
|
});
|
|
80
82
|
const client = new WorkerQueryService(worker, opts.queryTimeoutMs ?? 15_000);
|
|
@@ -127,6 +129,9 @@ export class WorkerQueryService {
|
|
|
127
129
|
async listProjects(identity) {
|
|
128
130
|
return (await this.call({ method: 'listProjects', identity }));
|
|
129
131
|
}
|
|
132
|
+
async getProject(identity, projectKey) {
|
|
133
|
+
return (await this.call({ method: 'getProject', identity, projectKey }));
|
|
134
|
+
}
|
|
130
135
|
async getSource(sourceId, identity) {
|
|
131
136
|
return (await this.call({ method: 'getSource', sourceId, identity }));
|
|
132
137
|
}
|
|
@@ -187,8 +192,8 @@ export class WorkerQueryService {
|
|
|
187
192
|
async listJobs(query) {
|
|
188
193
|
return (await this.call({ method: 'listJobs', query }));
|
|
189
194
|
}
|
|
190
|
-
async promotionCandidates() {
|
|
191
|
-
return (await this.call({ method: 'promotionCandidates' }));
|
|
195
|
+
async promotionCandidates(opts) {
|
|
196
|
+
return (await this.call({ method: 'promotionCandidates', opts }));
|
|
192
197
|
}
|
|
193
198
|
async dispose() {
|
|
194
199
|
if (this.disposed)
|
|
@@ -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,12 +56,11 @@ 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 同判)
|
|
63
|
+
if (boot.embeddingModels && boot.embed?.enabled !== false) {
|
|
64
64
|
const { resolveEmbeddingRuntime } = await import('../memory/sqlite/embedding-from-models.js');
|
|
65
65
|
const runtime = resolveEmbeddingRuntime(boot.embeddingModels);
|
|
66
66
|
embeddingProvider = runtime?.provider ?? null;
|
|
@@ -71,6 +71,7 @@ async function main() {
|
|
|
71
71
|
sourceStore: sources,
|
|
72
72
|
indexStore: index,
|
|
73
73
|
embeddingProvider: embeddingProvider,
|
|
74
|
+
...(boot.retriever ?? {}),
|
|
74
75
|
});
|
|
75
76
|
const svc = new LocalKnowledgeQueryService({
|
|
76
77
|
db,
|
|
@@ -113,6 +114,9 @@ async function main() {
|
|
|
113
114
|
case 'listProjects':
|
|
114
115
|
data = await svc.listProjects(msg.identity);
|
|
115
116
|
break;
|
|
117
|
+
case 'getProject':
|
|
118
|
+
data = await svc.getProject(msg.identity, msg.projectKey);
|
|
119
|
+
break;
|
|
116
120
|
case 'getSource':
|
|
117
121
|
data = await svc.getSource(msg.sourceId, msg.identity);
|
|
118
122
|
break;
|
|
@@ -162,7 +166,7 @@ async function main() {
|
|
|
162
166
|
data = await svc.listJobs(msg.query);
|
|
163
167
|
break;
|
|
164
168
|
case 'promotionCandidates':
|
|
165
|
-
data = await svc.promotionCandidates();
|
|
169
|
+
data = await svc.promotionCandidates(msg.opts);
|
|
166
170
|
break;
|
|
167
171
|
default:
|
|
168
172
|
throw new Error(`unknown_query_method`);
|
|
@@ -4,7 +4,8 @@
|
|
|
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
|
+
import { promotionThresholdsFromParams } from './http-params.js';
|
|
8
9
|
function json(res, status, payload) {
|
|
9
10
|
const buf = Buffer.from(JSON.stringify(payload), 'utf8');
|
|
10
11
|
res.writeHead(status, {
|
|
@@ -337,7 +338,10 @@ export async function handleKnowledgeReadHttp(deps, req, res, auth) {
|
|
|
337
338
|
return true;
|
|
338
339
|
}
|
|
339
340
|
if (path === '/v1/promotion-candidates') {
|
|
340
|
-
json(res, 200, {
|
|
341
|
+
json(res, 200, {
|
|
342
|
+
ok: true,
|
|
343
|
+
data: await meta.promotionCandidates(promotionThresholdsFromParams(url.searchParams)),
|
|
344
|
+
});
|
|
341
345
|
return true;
|
|
342
346
|
}
|
|
343
347
|
err(res, 404, 'not_found', `no route ${method} ${path}`);
|
|
@@ -369,5 +373,12 @@ export function authenticateRead(tokens, req) {
|
|
|
369
373
|
const hit = matchKnowledgeToken(tokens, req.headers.authorization);
|
|
370
374
|
if (!hit)
|
|
371
375
|
return null;
|
|
372
|
-
|
|
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) };
|
|
373
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
|
/** 可见集 ∩ 请求过滤;无过滤时原样返回可见集 */
|
|
@@ -12,6 +12,7 @@
|
|
|
12
12
|
*/
|
|
13
13
|
import { type Server } from 'node:http';
|
|
14
14
|
import type { KnowledgeServiceToken } from './http-app.js';
|
|
15
|
+
import type { KnowledgeBootEmbed, KnowledgeBootIngest, KnowledgeBootRetriever } from './boot-config.js';
|
|
15
16
|
export interface KnowledgeServeOptions {
|
|
16
17
|
dbPath: string;
|
|
17
18
|
host?: string;
|
|
@@ -21,14 +22,19 @@ export interface KnowledgeServeOptions {
|
|
|
21
22
|
documentConfig?: import('../capabilities/document/factory.js').DocumentCapabilityConfig | null;
|
|
22
23
|
/** 测试 stub(闭包无法进 Worker);生产用 embeddingModels */
|
|
23
24
|
testEmbeddingStub?: boolean;
|
|
24
|
-
embed?:
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
25
|
+
embed?: KnowledgeBootEmbed | null;
|
|
26
|
+
/** Ingest 调参(knowledge.load / index.queue / index.files) */
|
|
27
|
+
ingest?: KnowledgeBootIngest | null;
|
|
28
|
+
/** 检索调参(knowledge.keywordWeight / autoInject / hint / index.hybridKeyword) */
|
|
29
|
+
retriever?: KnowledgeBootRetriever | null;
|
|
30
|
+
/** false = 索引稳定后不自动生成 generatedDescription(knowledge.catalog.autoDescribe) */
|
|
31
|
+
autoDescribe?: boolean;
|
|
32
|
+
sqliteVec?: boolean | {
|
|
33
|
+
extensionPath?: string;
|
|
34
|
+
require?: boolean;
|
|
35
|
+
};
|
|
36
|
+
/** 跨租户共享闸(B-5):允许创建 visibility='public' 项目 */
|
|
37
|
+
allowPublic?: boolean;
|
|
32
38
|
embeddingModels?: {
|
|
33
39
|
providers?: Record<string, unknown>;
|
|
34
40
|
embedding?: unknown;
|
|
@@ -35,9 +35,9 @@ async function startQueryWorker(opts) {
|
|
|
35
35
|
mode: 'worker',
|
|
36
36
|
role: opts.role,
|
|
37
37
|
embeddingModels: opts.embeddingModels ?? null,
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
38
|
+
embed: opts.embed ?? null,
|
|
39
|
+
retriever: opts.retriever ?? null,
|
|
40
|
+
sqliteVec: opts.sqliteVec,
|
|
41
41
|
});
|
|
42
42
|
}
|
|
43
43
|
/**
|
|
@@ -56,9 +56,13 @@ export async function startKnowledgeService(opts) {
|
|
|
56
56
|
tokens: opts.tokens,
|
|
57
57
|
autoRegisterPrincipals: opts.autoRegisterPrincipals ?? true,
|
|
58
58
|
documentConfig: opts.documentConfig ?? null,
|
|
59
|
-
|
|
59
|
+
sqliteVec: opts.sqliteVec,
|
|
60
60
|
embeddingModels: opts.embeddingModels ?? null,
|
|
61
61
|
embed: opts.embed ?? null,
|
|
62
|
+
ingest: opts.ingest ?? null,
|
|
63
|
+
retriever: opts.retriever ?? null,
|
|
64
|
+
autoDescribe: opts.autoDescribe,
|
|
65
|
+
allowPublic: opts.allowPublic,
|
|
62
66
|
testEmbeddingStub: opts.testEmbeddingStub ?? false,
|
|
63
67
|
// 文件库:纯读在主线程 Meta/Search;Engine 只做写编排 + 残留短读
|
|
64
68
|
skipQueryWorker: useSplitQuery,
|
|
@@ -98,14 +102,18 @@ export async function startKnowledgeService(opts) {
|
|
|
98
102
|
startQueryWorker({
|
|
99
103
|
dbPath: opts.dbPath,
|
|
100
104
|
role: 'meta',
|
|
101
|
-
|
|
105
|
+
sqliteVec: opts.sqliteVec,
|
|
102
106
|
embeddingModels: opts.embeddingModels,
|
|
107
|
+
embed: opts.embed,
|
|
108
|
+
retriever: opts.retriever,
|
|
103
109
|
}),
|
|
104
110
|
startQueryWorker({
|
|
105
111
|
dbPath: opts.dbPath,
|
|
106
112
|
role: 'search',
|
|
107
|
-
|
|
113
|
+
sqliteVec: opts.sqliteVec,
|
|
108
114
|
embeddingModels: opts.embeddingModels,
|
|
115
|
+
embed: opts.embed,
|
|
116
|
+
retriever: opts.retriever,
|
|
109
117
|
}),
|
|
110
118
|
]);
|
|
111
119
|
}
|