@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
|
@@ -5,7 +5,9 @@
|
|
|
5
5
|
* 读走 KnowledgeQueryService。**禁止**在此打开 knowledge.db。
|
|
6
6
|
* 纯读 GET 在主线程 `read-http.ts` 直达 Meta/Search,不经本层。
|
|
7
7
|
*/
|
|
8
|
-
import {
|
|
8
|
+
import { DEFAULT_TENANT_ID, PLATFORM_TENANT_ID } from '@octopi-agent/core/types.js';
|
|
9
|
+
import { matchKnowledgeToken, resolveTenantClaim } from './http-bridge.js';
|
|
10
|
+
import { promotionThresholdsFromParams } from './http-params.js';
|
|
9
11
|
function json(res, status, payload) {
|
|
10
12
|
const buf = Buffer.from(JSON.stringify(payload), 'utf8');
|
|
11
13
|
res.writeHead(status, {
|
|
@@ -28,6 +30,21 @@ function mapWriteError(res, e) {
|
|
|
28
30
|
err(res, 403, 'not_principal_owner', msg);
|
|
29
31
|
return true;
|
|
30
32
|
}
|
|
33
|
+
if (code === 'project_not_visible' ||
|
|
34
|
+
code === 'source_not_visible' ||
|
|
35
|
+
/not visible to writer/i.test(msg)) {
|
|
36
|
+
err(res, 403, code || 'not_visible', msg);
|
|
37
|
+
return true;
|
|
38
|
+
}
|
|
39
|
+
if (code === 'visibility_requires_platform_claim' ||
|
|
40
|
+
/requires an explicit platform claim/i.test(msg)) {
|
|
41
|
+
err(res, 403, 'visibility_requires_platform_claim', msg);
|
|
42
|
+
return true;
|
|
43
|
+
}
|
|
44
|
+
if (code === 'public_projects_disabled') {
|
|
45
|
+
err(res, 403, 'public_projects_disabled', msg);
|
|
46
|
+
return true;
|
|
47
|
+
}
|
|
31
48
|
if (code === 'principal_not_registered' || /principal not registered/i.test(msg)) {
|
|
32
49
|
err(res, 403, 'principal_not_registered', msg);
|
|
33
50
|
return true;
|
|
@@ -72,8 +89,25 @@ export class KnowledgeHttpApp {
|
|
|
72
89
|
query() {
|
|
73
90
|
return this.opts.query;
|
|
74
91
|
}
|
|
92
|
+
/** 写身份:归属域(platform token 无 claim → DEFAULT,不写 platform 共享面) */
|
|
75
93
|
identityOf(ctx) {
|
|
76
|
-
return {
|
|
94
|
+
return {
|
|
95
|
+
tenantId: ctx.writeTenantId ?? ctx.tenantId,
|
|
96
|
+
gatewayId: ctx.gatewayId,
|
|
97
|
+
claimed: ctx.claimed,
|
|
98
|
+
};
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* 读身份:claim-or-token 域(v0.113.10 语义「读口不受影响」)——platform broker 无 claim
|
|
102
|
+
* = 运维面全量;claim 在场 = 租户收口。写域不得代劳读域(T3b 自审修复:曾共用 identityOf,
|
|
103
|
+
* 把运维读误收窄到 DEFAULT)。
|
|
104
|
+
*/
|
|
105
|
+
readIdentityOf(ctx) {
|
|
106
|
+
return {
|
|
107
|
+
tenantId: ctx.tenantId,
|
|
108
|
+
gatewayId: ctx.gatewayId,
|
|
109
|
+
claimed: ctx.claimed,
|
|
110
|
+
};
|
|
77
111
|
}
|
|
78
112
|
route(method, pattern, handler) {
|
|
79
113
|
const keys = [];
|
|
@@ -109,7 +143,7 @@ export class KnowledgeHttpApp {
|
|
|
109
143
|
});
|
|
110
144
|
});
|
|
111
145
|
this.route('GET', '/v1/principals/:agentId', async (_req, res, ctx, params) => {
|
|
112
|
-
const row = await this.query().getPrincipal(this.
|
|
146
|
+
const row = await this.query().getPrincipal(this.readIdentityOf(ctx), params.agentId);
|
|
113
147
|
if (!row)
|
|
114
148
|
return err(res, 404, 'principal_not_registered', 'principal not found');
|
|
115
149
|
json(res, 200, { ok: true, data: row });
|
|
@@ -117,7 +151,7 @@ export class KnowledgeHttpApp {
|
|
|
117
151
|
this.route('GET', '/v1/projects', async (_req, res, ctx) => {
|
|
118
152
|
json(res, 200, {
|
|
119
153
|
ok: true,
|
|
120
|
-
data: await this.query().listProjects(this.
|
|
154
|
+
data: await this.query().listProjects(this.readIdentityOf(ctx)),
|
|
121
155
|
});
|
|
122
156
|
});
|
|
123
157
|
this.route('POST', '/v1/projects', async (_req, res, ctx, _p, body) => {
|
|
@@ -138,6 +172,12 @@ export class KnowledgeHttpApp {
|
|
|
138
172
|
}
|
|
139
173
|
}
|
|
140
174
|
});
|
|
175
|
+
this.route('GET', '/v1/projects/:projectKey', async (_req, res, ctx, params) => {
|
|
176
|
+
const row = await this.query().getProject(this.readIdentityOf(ctx), params.projectKey);
|
|
177
|
+
if (!row)
|
|
178
|
+
return err(res, 404, 'project_not_found', 'project not found');
|
|
179
|
+
json(res, 200, { ok: true, data: row });
|
|
180
|
+
});
|
|
141
181
|
this.route('DELETE', '/v1/projects/:projectKey', async (_req, res, ctx, params) => {
|
|
142
182
|
try {
|
|
143
183
|
const data = await this.write.removeProject(this.identityOf(ctx), params.projectKey);
|
|
@@ -198,7 +238,7 @@ export class KnowledgeHttpApp {
|
|
|
198
238
|
: {}),
|
|
199
239
|
...(projectKey != null && projectKey !== '' ? { projectKey } : {}),
|
|
200
240
|
...(sessionId != null && sessionId !== '' ? { sessionId } : {}),
|
|
201
|
-
identity: this.
|
|
241
|
+
identity: this.readIdentityOf(ctx),
|
|
202
242
|
});
|
|
203
243
|
json(res, 200, { ok: true, data: list });
|
|
204
244
|
});
|
|
@@ -217,7 +257,7 @@ export class KnowledgeHttpApp {
|
|
|
217
257
|
}
|
|
218
258
|
});
|
|
219
259
|
this.route('GET', '/v1/sources/:sid', async (_req, res, ctx, params) => {
|
|
220
|
-
const detail = await this.query().getSourceDetail(params.sid, this.
|
|
260
|
+
const detail = await this.query().getSourceDetail(params.sid, this.readIdentityOf(ctx));
|
|
221
261
|
if (!detail) {
|
|
222
262
|
return err(res, 404, 'source_not_found', 'source not found');
|
|
223
263
|
}
|
|
@@ -304,9 +344,29 @@ export class KnowledgeHttpApp {
|
|
|
304
344
|
}
|
|
305
345
|
json(res, 200, { ok: true, data: await this.write.resumeSource(params.sid) });
|
|
306
346
|
});
|
|
307
|
-
this.route('POST', '/v1/sources/:sid/describe', async (_req, res, ctx, params) => {
|
|
347
|
+
this.route('POST', '/v1/sources/:sid/describe', async (_req, res, ctx, params, body) => {
|
|
348
|
+
try {
|
|
349
|
+
// 写入口(B 方案):body {description,source} = gateway 回写 LLM 描述;无 body = 本地启发式生成
|
|
350
|
+
const input = body;
|
|
351
|
+
const data = await this.write.describeSource(this.identityOf(ctx), params.sid, input?.description != null
|
|
352
|
+
? {
|
|
353
|
+
description: String(input.description),
|
|
354
|
+
...(input.source === 'heuristic' ? { source: 'heuristic' } : {}),
|
|
355
|
+
}
|
|
356
|
+
: undefined);
|
|
357
|
+
if (!data)
|
|
358
|
+
return err(res, 404, 'source_not_found', 'source not found');
|
|
359
|
+
json(res, 200, { ok: true, data });
|
|
360
|
+
}
|
|
361
|
+
catch (e) {
|
|
362
|
+
if (!mapWriteError(res, e)) {
|
|
363
|
+
err(res, 400, 'bad_request', e instanceof Error ? e.message : String(e));
|
|
364
|
+
}
|
|
365
|
+
}
|
|
366
|
+
});
|
|
367
|
+
this.route('GET', '/v1/sources/:sid/describe-sample', async (req, res, ctx, params) => {
|
|
308
368
|
try {
|
|
309
|
-
const data = await this.write.
|
|
369
|
+
const data = await this.write.describeSample(this.identityOf(ctx), params.sid);
|
|
310
370
|
if (!data)
|
|
311
371
|
return err(res, 404, 'source_not_found', 'source not found');
|
|
312
372
|
json(res, 200, { ok: true, data });
|
|
@@ -317,6 +377,12 @@ export class KnowledgeHttpApp {
|
|
|
317
377
|
}
|
|
318
378
|
}
|
|
319
379
|
});
|
|
380
|
+
this.route('GET', '/v1/describe-pending', async (req, res, ctx) => {
|
|
381
|
+
json(res, 200, {
|
|
382
|
+
ok: true,
|
|
383
|
+
data: await this.write.listDescribePending(this.identityOf(ctx)),
|
|
384
|
+
});
|
|
385
|
+
});
|
|
320
386
|
this.route('POST', '/v1/jobs/abort', async (_req, res, ctx) => {
|
|
321
387
|
json(res, 200, { ok: true, data: await this.write.abortAllOwned(this.identityOf(ctx)) });
|
|
322
388
|
});
|
|
@@ -347,12 +413,12 @@ export class KnowledgeHttpApp {
|
|
|
347
413
|
...(url.searchParams.get('pageSize')
|
|
348
414
|
? { pageSize: Number(url.searchParams.get('pageSize')) }
|
|
349
415
|
: {}),
|
|
350
|
-
}, this.
|
|
416
|
+
}, this.readIdentityOf(ctx));
|
|
351
417
|
return json(res, 200, { ok: true, data });
|
|
352
418
|
}
|
|
353
419
|
json(res, 200, {
|
|
354
420
|
ok: true,
|
|
355
|
-
data: await this.query().listFiles(params.sid, this.
|
|
421
|
+
data: await this.query().listFiles(params.sid, this.readIdentityOf(ctx)),
|
|
356
422
|
});
|
|
357
423
|
});
|
|
358
424
|
this.route('GET', '/v1/principals/:agentId/search', async (req, res, ctx, params) => {
|
|
@@ -363,7 +429,7 @@ export class KnowledgeHttpApp {
|
|
|
363
429
|
q: url.searchParams.get('q') ?? '',
|
|
364
430
|
sessionId: url.searchParams.get('sessionId') ?? undefined,
|
|
365
431
|
limit: Number(url.searchParams.get('limit') ?? 8),
|
|
366
|
-
identity: this.
|
|
432
|
+
identity: this.readIdentityOf(ctx),
|
|
367
433
|
});
|
|
368
434
|
json(res, 200, { ok: true, data: result });
|
|
369
435
|
});
|
|
@@ -380,13 +446,13 @@ export class KnowledgeHttpApp {
|
|
|
380
446
|
sessionId: url.searchParams.get('sessionId') ?? undefined,
|
|
381
447
|
limit: Number(url.searchParams.get('limit') ?? 8),
|
|
382
448
|
...(recall ? { recall } : {}),
|
|
383
|
-
identity: this.
|
|
449
|
+
identity: this.readIdentityOf(ctx),
|
|
384
450
|
});
|
|
385
451
|
json(res, 200, { ok: true, data: result });
|
|
386
452
|
});
|
|
387
453
|
this.route('GET', '/v1/principals/:agentId/stats', async (_req, res, ctx, params) => {
|
|
388
454
|
await this.write.ensurePrincipal(this.identityOf(ctx), params.agentId, this.opts.autoRegisterPrincipals ?? true);
|
|
389
|
-
const principal = await this.query().principalStats(params.agentId, this.
|
|
455
|
+
const principal = await this.query().principalStats(params.agentId, this.readIdentityOf(ctx));
|
|
390
456
|
json(res, 200, {
|
|
391
457
|
ok: true,
|
|
392
458
|
data: {
|
|
@@ -400,7 +466,7 @@ export class KnowledgeHttpApp {
|
|
|
400
466
|
await this.write.ensurePrincipal(this.identityOf(ctx), params.agentId, this.opts.autoRegisterPrincipals ?? true);
|
|
401
467
|
json(res, 200, {
|
|
402
468
|
ok: true,
|
|
403
|
-
data: await this.query().catalog(params.agentId, this.
|
|
469
|
+
data: await this.query().catalog(params.agentId, this.readIdentityOf(ctx)),
|
|
404
470
|
});
|
|
405
471
|
});
|
|
406
472
|
this.route('GET', '/v1/principals/:agentId/chunks', async (req, res, ctx, params) => {
|
|
@@ -411,7 +477,7 @@ export class KnowledgeHttpApp {
|
|
|
411
477
|
if (!sourceId || !path) {
|
|
412
478
|
return err(res, 400, 'bad_request', 'sourceId and path required');
|
|
413
479
|
}
|
|
414
|
-
const data = await this.query().listChunks(params.agentId, sourceId, path, this.
|
|
480
|
+
const data = await this.query().listChunks(params.agentId, sourceId, path, this.readIdentityOf(ctx), ctx.sessionId);
|
|
415
481
|
if (data == null) {
|
|
416
482
|
return err(res, 404, 'file_not_found', 'source not found');
|
|
417
483
|
}
|
|
@@ -424,13 +490,13 @@ export class KnowledgeHttpApp {
|
|
|
424
490
|
return err(res, 400, 'bad_request', 'chunkId or (sourceId+path) required');
|
|
425
491
|
}
|
|
426
492
|
if (b.chunkId) {
|
|
427
|
-
const data = await this.query().read(params.agentId, b, this.
|
|
493
|
+
const data = await this.query().read(params.agentId, b, this.readIdentityOf(ctx), ctx.sessionId);
|
|
428
494
|
if (!data.found) {
|
|
429
495
|
return err(res, 404, 'file_not_found', 'chunk not found');
|
|
430
496
|
}
|
|
431
497
|
return json(res, 200, { ok: true, data });
|
|
432
498
|
}
|
|
433
|
-
const chunks = await this.query().listChunks(params.agentId, b.sourceId, b.path, this.
|
|
499
|
+
const chunks = await this.query().listChunks(params.agentId, b.sourceId, b.path, this.readIdentityOf(ctx), ctx.sessionId);
|
|
434
500
|
if (chunks == null) {
|
|
435
501
|
return err(res, 404, 'source_not_found', 'source not found');
|
|
436
502
|
}
|
|
@@ -449,7 +515,7 @@ export class KnowledgeHttpApp {
|
|
|
449
515
|
await this.write.ensurePrincipal(this.identityOf(ctx), params.agentId, this.opts.autoRegisterPrincipals ?? true);
|
|
450
516
|
json(res, 200, {
|
|
451
517
|
ok: true,
|
|
452
|
-
data: await this.query().visibility(params.agentId, this.
|
|
518
|
+
data: await this.query().visibility(params.agentId, this.readIdentityOf(ctx)),
|
|
453
519
|
});
|
|
454
520
|
});
|
|
455
521
|
this.route('POST', '/v1/principals/:agentId/visibility', async (_req, res, ctx, params, body) => {
|
|
@@ -473,6 +539,12 @@ export class KnowledgeHttpApp {
|
|
|
473
539
|
else if (op === 'unhide' && sourceId) {
|
|
474
540
|
await this.write.unhideSource(identity, agentId, sourceId);
|
|
475
541
|
}
|
|
542
|
+
else if (op === 'mount' && sourceId) {
|
|
543
|
+
await this.write.mountSource(identity, agentId, sourceId);
|
|
544
|
+
}
|
|
545
|
+
else if (op === 'unmount' && sourceId) {
|
|
546
|
+
await this.write.unmountSource(identity, agentId, sourceId);
|
|
547
|
+
}
|
|
476
548
|
else {
|
|
477
549
|
return err(res, 400, 'bad_request', 'unknown visibility op');
|
|
478
550
|
}
|
|
@@ -494,7 +566,7 @@ export class KnowledgeHttpApp {
|
|
|
494
566
|
return err(res, 400, 'session_required', 'sessionId required');
|
|
495
567
|
json(res, 200, {
|
|
496
568
|
ok: true,
|
|
497
|
-
data: await this.query().sessionVisibility(agentId, sessionId, this.
|
|
569
|
+
data: await this.query().sessionVisibility(agentId, sessionId, this.readIdentityOf(ctx)),
|
|
498
570
|
});
|
|
499
571
|
});
|
|
500
572
|
this.route('PUT', '/v1/principals/:agentId/session-visibility', async (_req, res, ctx, params, body) => {
|
|
@@ -540,11 +612,12 @@ export class KnowledgeHttpApp {
|
|
|
540
612
|
return err(res, 400, 'session_required', 'sessionId required');
|
|
541
613
|
const targetType = url.searchParams.get('targetType');
|
|
542
614
|
const targetId = url.searchParams.get('targetId');
|
|
615
|
+
const op = url.searchParams.get('op');
|
|
543
616
|
if (targetType && targetId) {
|
|
544
617
|
await this.write.clearSessionVisibility(this.identityOf(ctx), sessionId, {
|
|
545
618
|
targetType: targetType,
|
|
546
619
|
targetId,
|
|
547
|
-
});
|
|
620
|
+
}, op === 'include' || op === 'exclude' ? op : undefined);
|
|
548
621
|
json(res, 200, { ok: true, data: { sessionId, targetType, targetId } });
|
|
549
622
|
return;
|
|
550
623
|
}
|
|
@@ -556,7 +629,7 @@ export class KnowledgeHttpApp {
|
|
|
556
629
|
json(res, 200, {
|
|
557
630
|
ok: true,
|
|
558
631
|
data: await this.query().listJobs({
|
|
559
|
-
identity: this.
|
|
632
|
+
identity: this.readIdentityOf(ctx),
|
|
560
633
|
sourceId: url.searchParams.get('sourceId') ?? undefined,
|
|
561
634
|
status: url.searchParams.get('status') ?? undefined,
|
|
562
635
|
}),
|
|
@@ -570,13 +643,17 @@ export class KnowledgeHttpApp {
|
|
|
570
643
|
if (!(await this.write.isSourceOwner(sourceId, ctx.gatewayId))) {
|
|
571
644
|
return err(res, 403, 'not_resource_owner', 'not source owner');
|
|
572
645
|
}
|
|
573
|
-
const detail = await this.query().getSourceDetail(sourceId, this.
|
|
646
|
+
const detail = await this.query().getSourceDetail(sourceId, this.readIdentityOf(ctx));
|
|
574
647
|
if (!detail)
|
|
575
648
|
return err(res, 404, 'source_not_found', 'source not found');
|
|
576
649
|
json(res, 200, { ok: true, data: detail.jobControl });
|
|
577
650
|
});
|
|
578
|
-
this.route('GET', '/v1/promotion-candidates', async (
|
|
579
|
-
|
|
651
|
+
this.route('GET', '/v1/promotion-candidates', async (req, res) => {
|
|
652
|
+
const url = new URL(req.url ?? '/', 'http://local');
|
|
653
|
+
json(res, 200, {
|
|
654
|
+
ok: true,
|
|
655
|
+
data: await this.query().promotionCandidates(promotionThresholdsFromParams(url.searchParams)),
|
|
656
|
+
});
|
|
580
657
|
});
|
|
581
658
|
}
|
|
582
659
|
/** 拉起 ingest 运行时(Service 入口调用一次;实现落在 Writer) */
|
|
@@ -641,7 +718,22 @@ export class KnowledgeHttpApp {
|
|
|
641
718
|
const hit = matchKnowledgeToken(this.opts.tokens, req.headers.authorization);
|
|
642
719
|
if (!hit)
|
|
643
720
|
return null;
|
|
644
|
-
|
|
721
|
+
// 租户断言(T3):x-octopi-tenant 上行;重复头/越域断言按未认证拒(fail-loud,不回落)
|
|
722
|
+
const claim = req.headers['x-octopi-tenant'];
|
|
723
|
+
if (Array.isArray(claim))
|
|
724
|
+
return null;
|
|
725
|
+
const resolved = resolveTenantClaim(hit.tenantId, claim ? claim : undefined);
|
|
726
|
+
if ('error' in resolved)
|
|
727
|
+
return null;
|
|
728
|
+
// 写归属域(T3a 收尾护栏):platform 域(broker)无显式 claim 时,写一律降级 DEFAULT 域。
|
|
729
|
+
// 读口不受影响(platform = 全量视图);写绝不能把用户资产落进 platform 共享面。
|
|
730
|
+
const writeTenantId = resolved.tenantId === PLATFORM_TENANT_ID && !claim ? DEFAULT_TENANT_ID : resolved.tenantId;
|
|
731
|
+
return {
|
|
732
|
+
tenantId: resolved.tenantId,
|
|
733
|
+
gatewayId: hit.gatewayId,
|
|
734
|
+
claimed: Boolean(claim),
|
|
735
|
+
writeTenantId,
|
|
736
|
+
};
|
|
645
737
|
}
|
|
646
738
|
}
|
|
647
739
|
/**
|
|
@@ -8,6 +8,21 @@ export interface KnowledgeTokenInfo {
|
|
|
8
8
|
tenantId: string;
|
|
9
9
|
gatewayId: string;
|
|
10
10
|
}
|
|
11
|
+
/**
|
|
12
|
+
* 租户断言(受信 gateway 上行,arch/multi-tenancy.md T3):
|
|
13
|
+
* `x-octopi-tenant` = 调用方断言的 run 归属租户(与 X-Registry-Token 同族的归属通道)。
|
|
14
|
+
* token 域 = PLATFORM(跨域受信)→ 断言任意域放行;token 域 = 其他 → 只可断言本域。
|
|
15
|
+
* 无断言 = token 域(旧语义)。
|
|
16
|
+
*
|
|
17
|
+
* @param tokenTenantId - token 绑定域
|
|
18
|
+
* @param claimed - 请求断言的租户(可缺省)
|
|
19
|
+
* @returns 生效域;断言越域时 `{ error }`(调用方按 401/403 拒)
|
|
20
|
+
*/
|
|
21
|
+
export declare function resolveTenantClaim(tokenTenantId: string, claimed: string | undefined): {
|
|
22
|
+
tenantId: string;
|
|
23
|
+
} | {
|
|
24
|
+
error: 'tenant_mismatch';
|
|
25
|
+
};
|
|
11
26
|
/**
|
|
12
27
|
* Token → (tenant, gateway)。主线程 401 快速拒绝 + Engine 再验(同一实现)。
|
|
13
28
|
*/
|
|
@@ -3,6 +3,25 @@
|
|
|
3
3
|
*
|
|
4
4
|
* 主线程不得跑 Knowledge 业务/SQLite;只转发,保证 /health 在引擎忙时仍可答。
|
|
5
5
|
*/
|
|
6
|
+
import { PLATFORM_TENANT_ID } from '@octopi-agent/core/types.js';
|
|
7
|
+
/**
|
|
8
|
+
* 租户断言(受信 gateway 上行,arch/multi-tenancy.md T3):
|
|
9
|
+
* `x-octopi-tenant` = 调用方断言的 run 归属租户(与 X-Registry-Token 同族的归属通道)。
|
|
10
|
+
* token 域 = PLATFORM(跨域受信)→ 断言任意域放行;token 域 = 其他 → 只可断言本域。
|
|
11
|
+
* 无断言 = token 域(旧语义)。
|
|
12
|
+
*
|
|
13
|
+
* @param tokenTenantId - token 绑定域
|
|
14
|
+
* @param claimed - 请求断言的租户(可缺省)
|
|
15
|
+
* @returns 生效域;断言越域时 `{ error }`(调用方按 401/403 拒)
|
|
16
|
+
*/
|
|
17
|
+
export function resolveTenantClaim(tokenTenantId, claimed) {
|
|
18
|
+
if (!claimed)
|
|
19
|
+
return { tenantId: tokenTenantId };
|
|
20
|
+
if (tokenTenantId === PLATFORM_TENANT_ID || tokenTenantId === claimed) {
|
|
21
|
+
return { tenantId: claimed };
|
|
22
|
+
}
|
|
23
|
+
return { error: 'tenant_mismatch' };
|
|
24
|
+
}
|
|
6
25
|
/**
|
|
7
26
|
* Token → (tenant, gateway)。主线程 401 快速拒绝 + Engine 再验(同一实现)。
|
|
8
27
|
*/
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* HTTP 查询参数解析(纯函数叶子模块)
|
|
3
|
+
*
|
|
4
|
+
* API 路由(http-app)与纯读路由(read-http)共用;刻意不依赖 query-service
|
|
5
|
+
* 实现,避免 HTTP 层反向依赖服务层。
|
|
6
|
+
*
|
|
7
|
+
* @module harness/knowledge/http-params
|
|
8
|
+
*/
|
|
9
|
+
/**
|
|
10
|
+
* 解析 promotion 候选阈值查询参数(非法值忽略,回落 hit-log 默认 3/10)。
|
|
11
|
+
*
|
|
12
|
+
* @param searchParams - URL 查询参数(`minSessions` / `minHits`)
|
|
13
|
+
* @returns 有效阈值;未配置或非法的键不出现
|
|
14
|
+
*/
|
|
15
|
+
export declare function promotionThresholdsFromParams(searchParams: URLSearchParams): {
|
|
16
|
+
minSessions?: number;
|
|
17
|
+
minHits?: number;
|
|
18
|
+
};
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* HTTP 查询参数解析(纯函数叶子模块)
|
|
3
|
+
*
|
|
4
|
+
* API 路由(http-app)与纯读路由(read-http)共用;刻意不依赖 query-service
|
|
5
|
+
* 实现,避免 HTTP 层反向依赖服务层。
|
|
6
|
+
*
|
|
7
|
+
* @module harness/knowledge/http-params
|
|
8
|
+
*/
|
|
9
|
+
/**
|
|
10
|
+
* 解析 promotion 候选阈值查询参数(非法值忽略,回落 hit-log 默认 3/10)。
|
|
11
|
+
*
|
|
12
|
+
* @param searchParams - URL 查询参数(`minSessions` / `minHits`)
|
|
13
|
+
* @returns 有效阈值;未配置或非法的键不出现
|
|
14
|
+
*/
|
|
15
|
+
export function promotionThresholdsFromParams(searchParams) {
|
|
16
|
+
const out = {};
|
|
17
|
+
const minSessions = Number(searchParams.get('minSessions'));
|
|
18
|
+
if (Number.isFinite(minSessions) && minSessions > 0)
|
|
19
|
+
out.minSessions = Math.floor(minSessions);
|
|
20
|
+
const minHits = Number(searchParams.get('minHits'));
|
|
21
|
+
if (Number.isFinite(minHits) && minHits > 0)
|
|
22
|
+
out.minHits = Math.floor(minHits);
|
|
23
|
+
return out;
|
|
24
|
+
}
|
|
@@ -28,6 +28,8 @@ export { EmbedRunner } from './embed-runner.js';
|
|
|
28
28
|
export type { EmbedSecretPolicy } from './embed-runner.js';
|
|
29
29
|
export { DEFAULT_KNOWLEDGE_FILE_LIMITS, classifyFileKind, decideBySize, formatMaxBytes, isRetryableSkipReason, parseTimeoutForSize, resolveKnowledgeFileLimits, } from './file-limits.js';
|
|
30
30
|
export type { KnowledgeFileKind, KnowledgeFileLimits, KnowledgeFileLimitsInput, OversizePolicy, } from './file-limits.js';
|
|
31
|
+
export { knowledgeTuningFromConfig } from './boot-config.js';
|
|
32
|
+
export type { KnowledgeBootTuning, KnowledgeBootEmbed, KnowledgeBootIngest, KnowledgeBootRetriever, } from './boot-config.js';
|
|
31
33
|
export { LocalFsFetcher, UrlFetcher, } from './fetchers.js';
|
|
32
34
|
export type { SourceFetcher, DiscoveredDocRef, DiscoverResult, VirtualDocument, } from './fetchers.js';
|
|
33
35
|
export { ConnectorRegistry, RestConnector } from './connectors.js';
|
|
@@ -18,6 +18,7 @@ export { KnowledgeJobControl } from './job-control.js';
|
|
|
18
18
|
export { JobQueue } from './job-queue.js';
|
|
19
19
|
export { EmbedRunner } from './embed-runner.js';
|
|
20
20
|
export { DEFAULT_KNOWLEDGE_FILE_LIMITS, classifyFileKind, decideBySize, formatMaxBytes, isRetryableSkipReason, parseTimeoutForSize, resolveKnowledgeFileLimits, } from './file-limits.js';
|
|
21
|
+
export { knowledgeTuningFromConfig } from './boot-config.js';
|
|
21
22
|
export { LocalFsFetcher, UrlFetcher, } from './fetchers.js';
|
|
22
23
|
export { ConnectorRegistry, RestConnector } from './connectors.js';
|
|
23
24
|
export { ConnectorFetcher } from './connector-fetcher.js';
|
|
@@ -48,9 +48,11 @@ async function main() {
|
|
|
48
48
|
documentConfig: boot.documentConfig ?? null,
|
|
49
49
|
embeddingModels: boot.embeddingModels ?? null,
|
|
50
50
|
embed: boot.embed ?? null,
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
51
|
+
ingest: boot.ingest ?? null,
|
|
52
|
+
retriever: boot.retriever ?? null,
|
|
53
|
+
autoDescribe: boot.autoDescribe,
|
|
54
|
+
sqliteVec: boot.sqliteVec,
|
|
55
|
+
allowPublic: boot.allowPublic,
|
|
54
56
|
});
|
|
55
57
|
let closing = false;
|
|
56
58
|
const shutdown = async (code) => {
|
|
@@ -47,8 +47,11 @@ export class KnowledgePurger {
|
|
|
47
47
|
return false;
|
|
48
48
|
if (!source.generatedDescription)
|
|
49
49
|
return false;
|
|
50
|
-
// 人工 description
|
|
51
|
-
this.sources.update(sourceId, {
|
|
50
|
+
// 人工 description 权威不动;只清自动描述(含生成方归因),待重生成
|
|
51
|
+
this.sources.update(sourceId, {
|
|
52
|
+
generatedDescription: null,
|
|
53
|
+
generatedDescriptionSource: null,
|
|
54
|
+
});
|
|
52
55
|
return true;
|
|
53
56
|
}
|
|
54
57
|
}
|
|
@@ -14,6 +14,7 @@ import type { KnowledgeSource } from './types.js';
|
|
|
14
14
|
import type { KnowledgeCatalogItem } from './catalog-types.js';
|
|
15
15
|
import { type KnowledgeJobControlState } from './job-control-state.js';
|
|
16
16
|
import { type PromotionCandidate } from './hit-log.js';
|
|
17
|
+
import type { KnowledgeBootRetriever, KnowledgeBootEmbed } from './boot-config.js';
|
|
17
18
|
export interface QueryIdentity {
|
|
18
19
|
tenantId?: string;
|
|
19
20
|
gatewayId?: string;
|
|
@@ -109,6 +110,8 @@ export interface KnowledgeQueryService {
|
|
|
109
110
|
autoGround(query: AutoGroundQuery): Promise<AutoGroundDecision>;
|
|
110
111
|
listSources(query: ListSourcesQuery): Promise<KnowledgeSource[]>;
|
|
111
112
|
listProjects(identity?: QueryIdentity): Promise<Array<Record<string, unknown>>>;
|
|
113
|
+
/** 单项目登记行(含归属域/可见性);未登记/不可见 = null(管理面域继承用) */
|
|
114
|
+
getProject(identity: QueryIdentity, projectKey: string): Promise<Record<string, unknown> | null>;
|
|
112
115
|
getSource(sourceId: string, identity?: QueryIdentity): Promise<{
|
|
113
116
|
source: KnowledgeSource;
|
|
114
117
|
stats: SourceStatsBundle;
|
|
@@ -166,7 +169,10 @@ export interface KnowledgeQueryService {
|
|
|
166
169
|
isSourceOwner(sourceId: string, gatewayId: string): Promise<boolean>;
|
|
167
170
|
ready(): Promise<ReadySnapshot>;
|
|
168
171
|
listJobs(query: ListJobsQuery): Promise<Array<Record<string, unknown>>>;
|
|
169
|
-
promotionCandidates(
|
|
172
|
+
promotionCandidates(opts?: {
|
|
173
|
+
minSessions?: number;
|
|
174
|
+
minHits?: number;
|
|
175
|
+
}): Promise<PromotionCandidate[]>;
|
|
170
176
|
dispose(): Promise<void> | void;
|
|
171
177
|
}
|
|
172
178
|
export interface LocalQueryDeps {
|
|
@@ -188,6 +194,7 @@ export declare class LocalKnowledgeQueryService implements KnowledgeQueryService
|
|
|
188
194
|
autoGround(query: AutoGroundQuery): Promise<AutoGroundDecision>;
|
|
189
195
|
listSources(query: ListSourcesQuery): Promise<KnowledgeSource[]>;
|
|
190
196
|
listProjects(identity?: QueryIdentity): Promise<Array<Record<string, unknown>>>;
|
|
197
|
+
getProject(identity: QueryIdentity, projectKey: string): Promise<Record<string, unknown> | null>;
|
|
191
198
|
getSource(sourceId: string, identity?: QueryIdentity): Promise<{
|
|
192
199
|
source: KnowledgeSource;
|
|
193
200
|
stats: SourceStatsBundle;
|
|
@@ -243,9 +250,16 @@ export declare class LocalKnowledgeQueryService implements KnowledgeQueryService
|
|
|
243
250
|
isSourceOwner(sourceId: string, gatewayId: string): Promise<boolean>;
|
|
244
251
|
ready(): Promise<ReadySnapshot>;
|
|
245
252
|
listJobs(query: ListJobsQuery): Promise<Array<Record<string, unknown>>>;
|
|
246
|
-
promotionCandidates(
|
|
253
|
+
promotionCandidates(opts?: {
|
|
254
|
+
minSessions?: number;
|
|
255
|
+
minHits?: number;
|
|
256
|
+
}): Promise<PromotionCandidate[]>;
|
|
247
257
|
dispose(): void;
|
|
248
|
-
|
|
258
|
+
/**
|
|
259
|
+
* 控制面读口域闸(T3b,评审 MAJ-4):租户闸 ⊕ 网关漏斗 ⊕ 项目跨域闸,单源委托 source-store
|
|
260
|
+
* (原为本地第二套 gatewayVisible 实现——无租户检查,跨租户可读;且违反单源律)。
|
|
261
|
+
*/
|
|
262
|
+
private domainVisible;
|
|
249
263
|
}
|
|
250
264
|
/**
|
|
251
265
|
* 组装只读服务。
|
|
@@ -265,8 +279,15 @@ export declare function createKnowledgeQueryService(opts: {
|
|
|
265
279
|
providers?: Record<string, unknown>;
|
|
266
280
|
embedding?: unknown;
|
|
267
281
|
} | null;
|
|
268
|
-
|
|
282
|
+
sqliteVec?: boolean | {
|
|
283
|
+
extensionPath?: string;
|
|
284
|
+
require?: boolean;
|
|
285
|
+
};
|
|
269
286
|
/** Worker 角色:meta=列表/控制面,search=检索/catalog,all=单 Worker 全量 */
|
|
270
287
|
role?: QueryWorkerRole;
|
|
271
288
|
queryTimeoutMs?: number;
|
|
289
|
+
/** 向量化开关(embed.enabled=false 时检索侧不建 embedding provider,不外发 query embed) */
|
|
290
|
+
embed?: KnowledgeBootEmbed | null;
|
|
291
|
+
/** 检索调参(透传进 Worker 的 KnowledgeRetriever) */
|
|
292
|
+
retriever?: KnowledgeBootRetriever | null;
|
|
272
293
|
}): Promise<KnowledgeQueryService>;
|