@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
|
@@ -4,30 +4,35 @@
|
|
|
4
4
|
* 为什么是进程而不是 Worker:知识索引重且稳定不可控,不得与 Gateway 共命运。
|
|
5
5
|
* Worker 仍共享堆/OOM 与进程生命周期,只是把 event loop 挪开,不是故障隔离。
|
|
6
6
|
*
|
|
7
|
-
* fork
|
|
8
|
-
*
|
|
9
|
-
* -
|
|
10
|
-
*
|
|
11
|
-
* -
|
|
12
|
-
* 换成捆绑 node.exe 当 execPath 会切断 Windows 上的 fork IPC。
|
|
7
|
+
* fork 根因约束见 `forkChildNodeOptions`(`execArgv: []` / 剥离 `NODE_CHANNEL_*` /
|
|
8
|
+
* `windowsHide` / Electron 宿主)。本处只保留两点知识专属取舍:
|
|
9
|
+
* - `stdio` 全 `ignore` 而非 `inherit`:Windows 管道句柄继承会干扰 IPC
|
|
10
|
+
* (run 实例相反——它的日志要靠继承的 fd 落 `logs/gateway.log`)。
|
|
11
|
+
* - **保持** `process.execPath`:Electron 下换成捆绑 node.exe 会切断 Windows 上的 fork IPC。
|
|
13
12
|
*/
|
|
14
13
|
import { type ChildProcess } from 'node:child_process';
|
|
15
14
|
import type { KnowledgeServiceToken } from './http-app.js';
|
|
16
15
|
import type { DocumentCapabilityConfig } from '../capabilities/document/factory.js';
|
|
16
|
+
import type { KnowledgeBootEmbed, KnowledgeBootIngest, KnowledgeBootRetriever } from './boot-config.js';
|
|
17
17
|
export interface KnowledgeServiceProcessOptions {
|
|
18
18
|
dbPath: string;
|
|
19
19
|
port?: number;
|
|
20
20
|
host?: string;
|
|
21
21
|
tokens: KnowledgeServiceToken[];
|
|
22
22
|
documentConfig?: DocumentCapabilityConfig | null;
|
|
23
|
-
embed?:
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
23
|
+
embed?: KnowledgeBootEmbed;
|
|
24
|
+
/** Ingest 调参(knowledge.load / index.queue / index.files) */
|
|
25
|
+
ingest?: KnowledgeBootIngest;
|
|
26
|
+
/** 检索调参(knowledge.keywordWeight / autoInject / hint / index.hybridKeyword) */
|
|
27
|
+
retriever?: KnowledgeBootRetriever;
|
|
28
|
+
/** false = 索引稳定后不自动生成 generatedDescription(knowledge.catalog.autoDescribe) */
|
|
29
|
+
autoDescribe?: boolean;
|
|
30
|
+
/** 跨租户共享闸(B-5):允许创建 visibility='public' 项目;缺省 false(fail-closed) */
|
|
31
|
+
allowPublic?: boolean;
|
|
32
|
+
sqliteVec?: boolean | {
|
|
33
|
+
extensionPath?: string;
|
|
34
|
+
require?: boolean;
|
|
29
35
|
};
|
|
30
|
-
sqliteVecExtensionPath?: string;
|
|
31
36
|
embeddingModels?: {
|
|
32
37
|
providers?: Record<string, unknown>;
|
|
33
38
|
embedding?: unknown;
|
|
@@ -37,9 +42,21 @@ export interface KnowledgeServiceProcessOptions {
|
|
|
37
42
|
export interface KnowledgeServiceProcessHandle {
|
|
38
43
|
child: ChildProcess;
|
|
39
44
|
port: number;
|
|
40
|
-
/**
|
|
45
|
+
/**
|
|
46
|
+
* 停止子进程并**等待其退出**。connected 时先发 close 让其优雅收摊,3s 未退则
|
|
47
|
+
* SIGTERM,再 2s 未退则 SIGKILL;通道已断(宿主硬死)时直接走信号升级。
|
|
48
|
+
* SIGKILL 之后仍等 1s 观察 exit,超时则放行(避免不可观测的僵尸让调用方永久挂起,
|
|
49
|
+
* 代价是极端情形下进程可能尚未完全退出)。
|
|
50
|
+
*/
|
|
41
51
|
stop(): Promise<void>;
|
|
42
52
|
}
|
|
53
|
+
/**
|
|
54
|
+
* 组装 boot 文件内容 — Gateway 调参面 → Service 子进程的唯一交接面(纯函数,可单测锁 hop)。
|
|
55
|
+
*
|
|
56
|
+
* @param opts - 进程启动选项(与 startKnowledgeService 同构 + embeddingModels)
|
|
57
|
+
* @returns boot JSON 对象(与 knowledge-serve-child 的 BootFile 同构)
|
|
58
|
+
*/
|
|
59
|
+
export declare function buildKnowledgeServiceBootFile(opts: KnowledgeServiceProcessOptions): Record<string, unknown>;
|
|
43
60
|
/**
|
|
44
61
|
* 在独立子进程启动 Knowledge HTTP Service。
|
|
45
62
|
*
|
|
@@ -47,3 +64,13 @@ export interface KnowledgeServiceProcessHandle {
|
|
|
47
64
|
* @returns child + 端口 + stop
|
|
48
65
|
*/
|
|
49
66
|
export declare function startKnowledgeServiceProcess(opts: KnowledgeServiceProcessOptions): Promise<KnowledgeServiceProcessHandle>;
|
|
67
|
+
/**
|
|
68
|
+
* 停止 knowledge 子进程并等待它退出(转调共享实现,预算为本服务的历史取值)。
|
|
69
|
+
*
|
|
70
|
+
* 语义与告警行为见 `stopForkedChild`:3s 优雅宽限 → SIGTERM → 2s → SIGKILL →
|
|
71
|
+
* 1s 兜底放行。
|
|
72
|
+
*
|
|
73
|
+
* @param child - knowledge 子进程
|
|
74
|
+
* @returns 子进程已退出(或兜底放行)时 resolve
|
|
75
|
+
*/
|
|
76
|
+
export declare function stopChild(child: ChildProcess): Promise<void>;
|
|
@@ -4,63 +4,73 @@
|
|
|
4
4
|
* 为什么是进程而不是 Worker:知识索引重且稳定不可控,不得与 Gateway 共命运。
|
|
5
5
|
* Worker 仍共享堆/OOM 与进程生命周期,只是把 event loop 挪开,不是故障隔离。
|
|
6
6
|
*
|
|
7
|
-
* fork
|
|
8
|
-
*
|
|
9
|
-
* -
|
|
10
|
-
*
|
|
11
|
-
* -
|
|
12
|
-
* 换成捆绑 node.exe 当 execPath 会切断 Windows 上的 fork IPC。
|
|
7
|
+
* fork 根因约束见 `forkChildNodeOptions`(`execArgv: []` / 剥离 `NODE_CHANNEL_*` /
|
|
8
|
+
* `windowsHide` / Electron 宿主)。本处只保留两点知识专属取舍:
|
|
9
|
+
* - `stdio` 全 `ignore` 而非 `inherit`:Windows 管道句柄继承会干扰 IPC
|
|
10
|
+
* (run 实例相反——它的日志要靠继承的 fd 落 `logs/gateway.log`)。
|
|
11
|
+
* - **保持** `process.execPath`:Electron 下换成捆绑 node.exe 会切断 Windows 上的 fork IPC。
|
|
13
12
|
*/
|
|
14
13
|
import { fork } from 'node:child_process';
|
|
15
14
|
import { fileURLToPath } from 'node:url';
|
|
16
|
-
import {
|
|
17
|
-
import { tmpdir } from 'node:os';
|
|
15
|
+
import { rm } from 'node:fs/promises';
|
|
18
16
|
import { join } from 'node:path';
|
|
17
|
+
import { forkChildNodeOptions, stopForkedChild } from '../../fork-child.js';
|
|
18
|
+
import { createPrivateTempDir, writeSecretFileSync } from '../../file-mode.js';
|
|
19
19
|
import { resolveWorkerUrl } from '../../worker-path.js';
|
|
20
|
-
function isElectronHost() {
|
|
21
|
-
return (Boolean(process.versions.electron) ||
|
|
22
|
-
/electron|MiMo\.exe/i.test(process.execPath));
|
|
23
|
-
}
|
|
24
|
-
function childNodeEnv() {
|
|
25
|
-
const env = { ...process.env };
|
|
26
|
-
// 父进程可能是 IPC 子进程(vitest worker / octopi serve daemon):不得把通道句柄带进孙进程
|
|
27
|
-
delete env.NODE_CHANNEL_FD;
|
|
28
|
-
delete env.NODE_CHANNEL_SERIALIZATION;
|
|
29
|
-
delete env.NODE_UNIQUE_ID;
|
|
30
|
-
if (isElectronHost()) {
|
|
31
|
-
env.ELECTRON_RUN_AS_NODE = '1';
|
|
32
|
-
}
|
|
33
|
-
return env;
|
|
34
|
-
}
|
|
35
20
|
/**
|
|
36
|
-
*
|
|
21
|
+
* 组装 boot 文件内容 — Gateway 调参面 → Service 子进程的唯一交接面(纯函数,可单测锁 hop)。
|
|
37
22
|
*
|
|
38
|
-
* @param opts -
|
|
39
|
-
* @returns child
|
|
23
|
+
* @param opts - 进程启动选项(与 startKnowledgeService 同构 + embeddingModels)
|
|
24
|
+
* @returns boot JSON 对象(与 knowledge-serve-child 的 BootFile 同构)
|
|
40
25
|
*/
|
|
41
|
-
export
|
|
42
|
-
|
|
43
|
-
const bootDir = await mkdtemp(join(tmpdir(), 'octopi-kn-boot-'));
|
|
44
|
-
const bootPath = join(bootDir, 'boot.json');
|
|
45
|
-
await writeFile(bootPath, JSON.stringify({
|
|
26
|
+
export function buildKnowledgeServiceBootFile(opts) {
|
|
27
|
+
return {
|
|
46
28
|
dbPath: opts.dbPath,
|
|
47
29
|
host: opts.host,
|
|
48
30
|
port: opts.port ?? 18280,
|
|
49
31
|
tokens: opts.tokens,
|
|
50
32
|
documentConfig: opts.documentConfig ?? null,
|
|
51
33
|
embed: opts.embed,
|
|
52
|
-
|
|
34
|
+
ingest: opts.ingest,
|
|
35
|
+
retriever: opts.retriever,
|
|
36
|
+
autoDescribe: opts.autoDescribe,
|
|
37
|
+
allowPublic: opts.allowPublic,
|
|
38
|
+
sqliteVec: opts.sqliteVec,
|
|
53
39
|
embeddingModels: opts.embeddingModels ?? null,
|
|
54
|
-
}), 'utf8');
|
|
55
|
-
// @types/node 的 ForkOptions 未声明 windowsHide 等字段,运行时有效
|
|
56
|
-
// execPath 必须保持 process.execPath:Electron 下换捆绑 node 会切断 IPC
|
|
57
|
-
const forkOpts = {
|
|
58
|
-
stdio: ['ignore', 'ignore', 'ignore', 'ipc'],
|
|
59
|
-
windowsHide: true,
|
|
60
|
-
execArgv: [],
|
|
61
|
-
env: childNodeEnv(),
|
|
62
40
|
};
|
|
63
|
-
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* 在独立子进程启动 Knowledge HTTP Service。
|
|
44
|
+
*
|
|
45
|
+
* @param opts - 与 startKnowledgeService 同构 + embeddingModels(子进程内重建 provider)
|
|
46
|
+
* @returns child + 端口 + stop
|
|
47
|
+
*/
|
|
48
|
+
export async function startKnowledgeServiceProcess(opts) {
|
|
49
|
+
const entry = fileURLToPath(resolveWorkerUrl('./knowledge-serve-child.js', import.meta.url));
|
|
50
|
+
// 私有目录 + 真实权限收紧:boot 含 loopback token,Windows 上 `mode` 不生效。
|
|
51
|
+
// 建目录之后的每一步都可能抛(写 secret、fork),而 `finally` 在 try 之外不生效——
|
|
52
|
+
// 所以把它们全部纳入 try,失败时连目录(含 token)一起回收。
|
|
53
|
+
const bootDir = createPrivateTempDir('octopi-kn-boot-');
|
|
54
|
+
const bootPath = join(bootDir, 'boot.json');
|
|
55
|
+
let child;
|
|
56
|
+
try {
|
|
57
|
+
writeSecretFileSync(bootPath, JSON.stringify(buildKnowledgeServiceBootFile(opts)));
|
|
58
|
+
}
|
|
59
|
+
catch (err) {
|
|
60
|
+
await rm(bootDir, { recursive: true, force: true }).catch(() => undefined);
|
|
61
|
+
throw err;
|
|
62
|
+
}
|
|
63
|
+
try {
|
|
64
|
+
// execPath 保持 process.execPath:Electron 下换捆绑 node 会切断 IPC
|
|
65
|
+
child = fork(entry, [bootPath], forkChildNodeOptions({
|
|
66
|
+
stdio: ['ignore', 'ignore', 'ignore'],
|
|
67
|
+
}));
|
|
68
|
+
}
|
|
69
|
+
catch (err) {
|
|
70
|
+
// fork 同步抛:boot 已写而子进程没机会读删——父进程兜底清 secret
|
|
71
|
+
await rm(bootDir, { recursive: true, force: true }).catch(() => undefined);
|
|
72
|
+
throw err;
|
|
73
|
+
}
|
|
64
74
|
const startTimeoutMs = opts.startTimeoutMs ?? 30_000;
|
|
65
75
|
try {
|
|
66
76
|
const port = await new Promise((resolve, reject) => {
|
|
@@ -98,61 +108,22 @@ export async function startKnowledgeServiceProcess(opts) {
|
|
|
98
108
|
};
|
|
99
109
|
}
|
|
100
110
|
finally {
|
|
101
|
-
|
|
111
|
+
// 清理失败不改变启动结果,但必须留痕:这类 EPERM 正是"句柄未释放就删目录"的症状,
|
|
112
|
+
// 静默吞掉会让下一轮排障从零开始。
|
|
113
|
+
await rm(bootDir, { recursive: true, force: true }).catch((err) => {
|
|
114
|
+
console.warn(`[knowledge] boot dir cleanup failed (${String(err)}): ${bootDir}`);
|
|
115
|
+
});
|
|
102
116
|
}
|
|
103
117
|
}
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
const hard = setTimeout(() => {
|
|
116
|
-
try {
|
|
117
|
-
child.kill('SIGKILL');
|
|
118
|
-
}
|
|
119
|
-
catch {
|
|
120
|
-
/* ignore */
|
|
121
|
-
}
|
|
122
|
-
resolve();
|
|
123
|
-
}, 2_000);
|
|
124
|
-
hard.unref?.();
|
|
125
|
-
}, 3_000);
|
|
126
|
-
child.once('exit', () => {
|
|
127
|
-
clearTimeout(timer);
|
|
128
|
-
resolve();
|
|
129
|
-
});
|
|
130
|
-
try {
|
|
131
|
-
if (child.connected) {
|
|
132
|
-
child.send({ type: 'close' }, () => {
|
|
133
|
-
/* send callback only observes channel errors; exit path resolves */
|
|
134
|
-
});
|
|
135
|
-
}
|
|
136
|
-
else {
|
|
137
|
-
clearTimeout(timer);
|
|
138
|
-
try {
|
|
139
|
-
child.kill('SIGTERM');
|
|
140
|
-
}
|
|
141
|
-
catch {
|
|
142
|
-
/* ignore */
|
|
143
|
-
}
|
|
144
|
-
resolve();
|
|
145
|
-
}
|
|
146
|
-
}
|
|
147
|
-
catch {
|
|
148
|
-
clearTimeout(timer);
|
|
149
|
-
try {
|
|
150
|
-
child.kill('SIGTERM');
|
|
151
|
-
}
|
|
152
|
-
catch {
|
|
153
|
-
/* ignore */
|
|
154
|
-
}
|
|
155
|
-
resolve();
|
|
156
|
-
}
|
|
157
|
-
});
|
|
118
|
+
/**
|
|
119
|
+
* 停止 knowledge 子进程并等待它退出(转调共享实现,预算为本服务的历史取值)。
|
|
120
|
+
*
|
|
121
|
+
* 语义与告警行为见 `stopForkedChild`:3s 优雅宽限 → SIGTERM → 2s → SIGKILL →
|
|
122
|
+
* 1s 兜底放行。
|
|
123
|
+
*
|
|
124
|
+
* @param child - knowledge 子进程
|
|
125
|
+
* @returns 子进程已退出(或兜底放行)时 resolve
|
|
126
|
+
*/
|
|
127
|
+
export function stopChild(child) {
|
|
128
|
+
return stopForkedChild(child, { graceMs: 3_000, termMs: 2_000, reapFallbackMs: 1_000, label: 'knowledge' });
|
|
158
129
|
}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
/** 闸身份:缺省字段按 DEFAULT 域(fail-closed,评审 MAJ-2)解析。 */
|
|
2
|
+
export interface GateIdentity {
|
|
3
|
+
tenantId?: string;
|
|
4
|
+
gatewayId?: string;
|
|
5
|
+
}
|
|
6
|
+
/** SQL 谓词片段:`sql` 直接拼接进 WHERE,`params` 按序绑定。 */
|
|
7
|
+
export interface GateSql {
|
|
8
|
+
sql: string;
|
|
9
|
+
params: string[];
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* 租户域闸(内存形态)。
|
|
13
|
+
*
|
|
14
|
+
* @param rowTenant 行归属租户(来源行的 tenant_id);空值视为无归属(可见)
|
|
15
|
+
* @param identity 读身份;undefined = 宿主面(不设闸)
|
|
16
|
+
* @returns 行是否落在该身份的可见域内
|
|
17
|
+
*/
|
|
18
|
+
export declare function tenantGateAllows(rowTenant: string | undefined | null, identity?: GateIdentity): boolean;
|
|
19
|
+
/**
|
|
20
|
+
* 租户域闸(SQL 形态;与 {@link tenantGateAllows} 逐格等价)。
|
|
21
|
+
*
|
|
22
|
+
* @param column tenant_id 列名(可带表别名前缀)
|
|
23
|
+
* @param identity 读身份;undefined = 宿主面(不设闸)
|
|
24
|
+
* @returns 可拼接的 WHERE 谓词与绑定参数
|
|
25
|
+
*/
|
|
26
|
+
export declare function tenantGateSql(column?: string, identity?: GateIdentity): GateSql;
|
|
27
|
+
/**
|
|
28
|
+
* 本域闸(内存形态)——用于**写入物**(agent/session 覆盖行、挂载行、主体行):
|
|
29
|
+
* 这类行按域归属隔离,platform 行**不**自动扩散到租户(与资产闸 {@link tenantGateAllows}
|
|
30
|
+
* 的「platform=公共」语义有意不同:覆盖行扩散=平台行悄悄操纵他租户 agent 可见性);
|
|
31
|
+
* 仅 platform 读身份(broker 运维面)= 全量。
|
|
32
|
+
*
|
|
33
|
+
* @param rowTenant 行归属租户;空值视为无归属(可见)
|
|
34
|
+
* @param identity 读身份;undefined = 宿主面(不设闸)
|
|
35
|
+
*/
|
|
36
|
+
export declare function tenantOwnGateAllows(rowTenant: string | undefined | null, identity?: GateIdentity): boolean;
|
|
37
|
+
/** 本域闸(SQL 形态;与 {@link tenantOwnGateAllows} 逐格等价) */
|
|
38
|
+
export declare function tenantOwnGateSql(column?: string, identity?: GateIdentity): GateSql;
|
|
39
|
+
/**
|
|
40
|
+
* 单行读取的确定性排序(同 (gateway, agent/session, target) 可在多域各有一行,
|
|
41
|
+
* `.get()` 无序返回任意行会让可见性判定漂移):本域行优先,其次 platform 行,再按域名字典序。
|
|
42
|
+
*/
|
|
43
|
+
export declare function tenantPrecedenceOrder(column?: string, identity?: GateIdentity): GateSql;
|
|
44
|
+
/**
|
|
45
|
+
* 归属漏斗(内存形态;只用于源)。
|
|
46
|
+
*
|
|
47
|
+
* @param rowRegisteredBy 行登记网关(registered_by)
|
|
48
|
+
* @param rowVisibility 行可见性('public' | 'private')
|
|
49
|
+
* @param identity 读身份;undefined = 宿主面(不设闸);无 gatewayId = 不设漏斗
|
|
50
|
+
* @returns 行是否通过归属漏斗
|
|
51
|
+
*/
|
|
52
|
+
export declare function ownerFunnelAllows(rowRegisteredBy: string | undefined | null, rowVisibility: string | undefined | null, identity?: GateIdentity): boolean;
|
|
53
|
+
/**
|
|
54
|
+
* 归属漏斗(SQL 形态;与 {@link ownerFunnelAllows} 逐格等价)。
|
|
55
|
+
*
|
|
56
|
+
* @param registeredByColumn registered_by 列名(可带表别名前缀)
|
|
57
|
+
* @param visibilityColumn visibility 列名(可带表别名前缀)
|
|
58
|
+
* @param identity 读身份;undefined = 宿主面(不设闸);无 gatewayId = 不设漏斗
|
|
59
|
+
* @returns 可拼接的 WHERE 谓词与绑定参数
|
|
60
|
+
*/
|
|
61
|
+
export declare function ownerFunnelSql(registeredByColumn?: string, visibilityColumn?: string, identity?: GateIdentity): GateSql;
|
|
62
|
+
/**
|
|
63
|
+
* 项目跨域闸(内存形态):本域项目(含无归属)始终可见;platform 项目仅
|
|
64
|
+
* `visibility='public'` 才对租户可见(跨租户共享唯一合法形态 = platform 公共,
|
|
65
|
+
* arch/multi-tenancy.md §6);platform 身份 = 全量视图。
|
|
66
|
+
*
|
|
67
|
+
* @param rowTenant 项目行归属租户
|
|
68
|
+
* @param rowVisibility 项目行可见性('public' | 'private')
|
|
69
|
+
* @param identity 读身份;undefined = 宿主面(不设闸)
|
|
70
|
+
* @returns 项目行是否对该身份可见
|
|
71
|
+
*/
|
|
72
|
+
export declare function projectGateAllows(rowTenant: string | undefined | null, rowVisibility: string | undefined | null, identity?: GateIdentity): boolean;
|
|
73
|
+
/**
|
|
74
|
+
* 项目跨域闸(SQL 形态;与 {@link projectGateAllows} 逐格等价)。
|
|
75
|
+
*
|
|
76
|
+
* @param tenantColumn tenant_id 列名(可带表别名前缀)
|
|
77
|
+
* @param visibilityColumn visibility 列名(可带表别名前缀)
|
|
78
|
+
* @param identity 读身份;undefined = 宿主面(不设闸)
|
|
79
|
+
* @returns 可拼接的 WHERE 谓词与绑定参数
|
|
80
|
+
*/
|
|
81
|
+
export declare function projectGateSql(tenantColumn?: string, visibilityColumn?: string, identity?: GateIdentity): GateSql;
|
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 租户闸(arch/multi-tenancy.md §6:命中 = 挂载库 ∪ 本租户公共 ∪ platform 公共)。
|
|
3
|
+
*
|
|
4
|
+
* 单源两形态:本模块同时导出内存判定与 SQL 谓词,二者必须逐格等价
|
|
5
|
+
* (tests/harness/knowledge-tenant-gate.test.ts 固化)。所有读路径改用本模块,
|
|
6
|
+
* 禁止再手写 `tenant_id = ?` 硬等值——platform 域(broker 全量视图)会被硬等值清空
|
|
7
|
+
* (MAJ-4 遗留:管理面读口租户闸)。
|
|
8
|
+
*
|
|
9
|
+
* 语义(三闸各司其职,勿混用):
|
|
10
|
+
* - `tenantGate*` 租户域闸:platform=全量;行无归属=可见;platform 行=对全租户可见;其余=本域。
|
|
11
|
+
* - `ownerFunnel*` 归属漏斗(**只属于源**):registered_by=己方 ∪ visibility='public'。
|
|
12
|
+
* 项目**不**走漏斗:同租户跨网关共享项目是既定设计
|
|
13
|
+
* (tests/harness/knowledge-cross-gateway.test.ts「catalog/挂载同口径」)。
|
|
14
|
+
* - `projectGate*` 项目跨域闸:本域项目可见;platform 项目仅 visibility='public' 才跨域可见。
|
|
15
|
+
*
|
|
16
|
+
* 无身份(identity === undefined)= 宿主面 = 不设闸(与 listSources/getSource 既有语义一致)。
|
|
17
|
+
*/
|
|
18
|
+
import { DEFAULT_TENANT_ID, PLATFORM_TENANT_ID } from '@octopi-agent/core/types.js';
|
|
19
|
+
/** 解析读身份的租户域;无身份返回 null(宿主面,不设闸)。 */
|
|
20
|
+
function tenantOf(identity) {
|
|
21
|
+
if (identity === undefined)
|
|
22
|
+
return null;
|
|
23
|
+
return identity.tenantId ?? DEFAULT_TENANT_ID;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* 租户域闸(内存形态)。
|
|
27
|
+
*
|
|
28
|
+
* @param rowTenant 行归属租户(来源行的 tenant_id);空值视为无归属(可见)
|
|
29
|
+
* @param identity 读身份;undefined = 宿主面(不设闸)
|
|
30
|
+
* @returns 行是否落在该身份的可见域内
|
|
31
|
+
*/
|
|
32
|
+
export function tenantGateAllows(rowTenant, identity) {
|
|
33
|
+
const tenant = tenantOf(identity);
|
|
34
|
+
if (tenant === null || tenant === PLATFORM_TENANT_ID)
|
|
35
|
+
return true;
|
|
36
|
+
if (!rowTenant)
|
|
37
|
+
return true;
|
|
38
|
+
if (rowTenant === PLATFORM_TENANT_ID)
|
|
39
|
+
return true;
|
|
40
|
+
return rowTenant === tenant;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* 租户域闸(SQL 形态;与 {@link tenantGateAllows} 逐格等价)。
|
|
44
|
+
*
|
|
45
|
+
* @param column tenant_id 列名(可带表别名前缀)
|
|
46
|
+
* @param identity 读身份;undefined = 宿主面(不设闸)
|
|
47
|
+
* @returns 可拼接的 WHERE 谓词与绑定参数
|
|
48
|
+
*/
|
|
49
|
+
export function tenantGateSql(column = 'tenant_id', identity) {
|
|
50
|
+
const tenant = tenantOf(identity);
|
|
51
|
+
if (tenant === null || tenant === PLATFORM_TENANT_ID)
|
|
52
|
+
return { sql: '1 = 1', params: [] };
|
|
53
|
+
return {
|
|
54
|
+
sql: `(IFNULL(${column}, '') = '' OR ${column} = ? OR ${column} = ?)`,
|
|
55
|
+
params: [tenant, PLATFORM_TENANT_ID],
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* 本域闸(内存形态)——用于**写入物**(agent/session 覆盖行、挂载行、主体行):
|
|
60
|
+
* 这类行按域归属隔离,platform 行**不**自动扩散到租户(与资产闸 {@link tenantGateAllows}
|
|
61
|
+
* 的「platform=公共」语义有意不同:覆盖行扩散=平台行悄悄操纵他租户 agent 可见性);
|
|
62
|
+
* 仅 platform 读身份(broker 运维面)= 全量。
|
|
63
|
+
*
|
|
64
|
+
* @param rowTenant 行归属租户;空值视为无归属(可见)
|
|
65
|
+
* @param identity 读身份;undefined = 宿主面(不设闸)
|
|
66
|
+
*/
|
|
67
|
+
export function tenantOwnGateAllows(rowTenant, identity) {
|
|
68
|
+
const tenant = tenantOf(identity);
|
|
69
|
+
if (tenant === null || tenant === PLATFORM_TENANT_ID)
|
|
70
|
+
return true;
|
|
71
|
+
if (!rowTenant)
|
|
72
|
+
return true;
|
|
73
|
+
return rowTenant === tenant;
|
|
74
|
+
}
|
|
75
|
+
/** 本域闸(SQL 形态;与 {@link tenantOwnGateAllows} 逐格等价) */
|
|
76
|
+
export function tenantOwnGateSql(column = 'tenant_id', identity) {
|
|
77
|
+
const tenant = tenantOf(identity);
|
|
78
|
+
if (tenant === null || tenant === PLATFORM_TENANT_ID)
|
|
79
|
+
return { sql: '1 = 1', params: [] };
|
|
80
|
+
return {
|
|
81
|
+
sql: `(IFNULL(${column}, '') = '' OR ${column} = ?)`,
|
|
82
|
+
params: [tenant],
|
|
83
|
+
};
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* 单行读取的确定性排序(同 (gateway, agent/session, target) 可在多域各有一行,
|
|
87
|
+
* `.get()` 无序返回任意行会让可见性判定漂移):本域行优先,其次 platform 行,再按域名字典序。
|
|
88
|
+
*/
|
|
89
|
+
export function tenantPrecedenceOrder(column = 'tenant_id', identity) {
|
|
90
|
+
const tenant = tenantOf(identity) ?? '';
|
|
91
|
+
return {
|
|
92
|
+
sql: `CASE WHEN IFNULL(${column}, '') = ? THEN 0 WHEN ${column} = ? THEN 1 ELSE 2 END, ${column}`,
|
|
93
|
+
params: [tenant, PLATFORM_TENANT_ID],
|
|
94
|
+
};
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* 归属漏斗(内存形态;只用于源)。
|
|
98
|
+
*
|
|
99
|
+
* @param rowRegisteredBy 行登记网关(registered_by)
|
|
100
|
+
* @param rowVisibility 行可见性('public' | 'private')
|
|
101
|
+
* @param identity 读身份;undefined = 宿主面(不设闸);无 gatewayId = 不设漏斗
|
|
102
|
+
* @returns 行是否通过归属漏斗
|
|
103
|
+
*/
|
|
104
|
+
export function ownerFunnelAllows(rowRegisteredBy, rowVisibility, identity) {
|
|
105
|
+
if (identity === undefined)
|
|
106
|
+
return true;
|
|
107
|
+
const gw = identity.gatewayId;
|
|
108
|
+
if (!gw)
|
|
109
|
+
return true;
|
|
110
|
+
if (!rowRegisteredBy || rowRegisteredBy === gw)
|
|
111
|
+
return true;
|
|
112
|
+
return rowVisibility === 'public';
|
|
113
|
+
}
|
|
114
|
+
/**
|
|
115
|
+
* 归属漏斗(SQL 形态;与 {@link ownerFunnelAllows} 逐格等价)。
|
|
116
|
+
*
|
|
117
|
+
* @param registeredByColumn registered_by 列名(可带表别名前缀)
|
|
118
|
+
* @param visibilityColumn visibility 列名(可带表别名前缀)
|
|
119
|
+
* @param identity 读身份;undefined = 宿主面(不设闸);无 gatewayId = 不设漏斗
|
|
120
|
+
* @returns 可拼接的 WHERE 谓词与绑定参数
|
|
121
|
+
*/
|
|
122
|
+
export function ownerFunnelSql(registeredByColumn = 'registered_by', visibilityColumn = 'visibility', identity) {
|
|
123
|
+
if (identity === undefined || !identity.gatewayId)
|
|
124
|
+
return { sql: '1 = 1', params: [] };
|
|
125
|
+
return {
|
|
126
|
+
sql: `(IFNULL(${registeredByColumn}, '') = '' OR ${registeredByColumn} = ? OR ${visibilityColumn} = 'public')`,
|
|
127
|
+
params: [identity.gatewayId],
|
|
128
|
+
};
|
|
129
|
+
}
|
|
130
|
+
/**
|
|
131
|
+
* 项目跨域闸(内存形态):本域项目(含无归属)始终可见;platform 项目仅
|
|
132
|
+
* `visibility='public'` 才对租户可见(跨租户共享唯一合法形态 = platform 公共,
|
|
133
|
+
* arch/multi-tenancy.md §6);platform 身份 = 全量视图。
|
|
134
|
+
*
|
|
135
|
+
* @param rowTenant 项目行归属租户
|
|
136
|
+
* @param rowVisibility 项目行可见性('public' | 'private')
|
|
137
|
+
* @param identity 读身份;undefined = 宿主面(不设闸)
|
|
138
|
+
* @returns 项目行是否对该身份可见
|
|
139
|
+
*/
|
|
140
|
+
export function projectGateAllows(rowTenant, rowVisibility, identity) {
|
|
141
|
+
const tenant = tenantOf(identity);
|
|
142
|
+
if (tenant === null || tenant === PLATFORM_TENANT_ID)
|
|
143
|
+
return true;
|
|
144
|
+
if (!rowTenant)
|
|
145
|
+
return true;
|
|
146
|
+
if (rowTenant === PLATFORM_TENANT_ID)
|
|
147
|
+
return rowVisibility === 'public';
|
|
148
|
+
return rowTenant === tenant;
|
|
149
|
+
}
|
|
150
|
+
/**
|
|
151
|
+
* 项目跨域闸(SQL 形态;与 {@link projectGateAllows} 逐格等价)。
|
|
152
|
+
*
|
|
153
|
+
* @param tenantColumn tenant_id 列名(可带表别名前缀)
|
|
154
|
+
* @param visibilityColumn visibility 列名(可带表别名前缀)
|
|
155
|
+
* @param identity 读身份;undefined = 宿主面(不设闸)
|
|
156
|
+
* @returns 可拼接的 WHERE 谓词与绑定参数
|
|
157
|
+
*/
|
|
158
|
+
export function projectGateSql(tenantColumn = 'tenant_id', visibilityColumn = 'visibility', identity) {
|
|
159
|
+
const tenant = tenantOf(identity);
|
|
160
|
+
if (tenant === null || tenant === PLATFORM_TENANT_ID)
|
|
161
|
+
return { sql: '1 = 1', params: [] };
|
|
162
|
+
return {
|
|
163
|
+
sql: `(IFNULL(${tenantColumn}, '') = '' OR ${tenantColumn} = ?` +
|
|
164
|
+
` OR (${tenantColumn} = ? AND ${visibilityColumn} = 'public'))`,
|
|
165
|
+
params: [tenant, PLATFORM_TENANT_ID],
|
|
166
|
+
};
|
|
167
|
+
}
|
|
@@ -20,6 +20,8 @@ export interface KnowledgeScopeRef {
|
|
|
20
20
|
/** global: 'global';project: projectKey;session: sessionId */
|
|
21
21
|
key: string;
|
|
22
22
|
}
|
|
23
|
+
/** generatedDescription 生成方(信任分级 human > llm > heuristic) */
|
|
24
|
+
export type KnowledgeGeneratedDescriptionSource = 'heuristic' | 'llm' | 'blocked_secret';
|
|
23
25
|
export type KnowledgeSourceStatus = 'pending' | 'discovering' | 'partial' | 'ready' | 'error' | 'disabled' | 'removed';
|
|
24
26
|
export type KnowledgeSourceKind = 'workspace' | 'directory' | 'file' | 'url' | 'connector';
|
|
25
27
|
export interface KnowledgeSourceSync {
|
|
@@ -72,6 +74,8 @@ export interface KnowledgeSource {
|
|
|
72
74
|
description?: string;
|
|
73
75
|
/** 自动描述(可被 description 覆盖) */
|
|
74
76
|
generatedDescription?: string;
|
|
77
|
+
/** 自动描述生成方(信任分级:llm 优于 heuristic;blocked_secret=抽样含密钥形态,未外发) */
|
|
78
|
+
generatedDescriptionSource?: KnowledgeGeneratedDescriptionSource;
|
|
75
79
|
catalogPriority?: number;
|
|
76
80
|
hiddenFromCatalog?: boolean;
|
|
77
81
|
/** CredentialStore 凭证名(密钥不进本库) */
|
|
@@ -94,6 +98,7 @@ export type KnowledgeSourceInput = {
|
|
|
94
98
|
displayName?: string;
|
|
95
99
|
description?: string;
|
|
96
100
|
generatedDescription?: string;
|
|
101
|
+
generatedDescriptionSource?: KnowledgeGeneratedDescriptionSource;
|
|
97
102
|
catalogPriority?: number;
|
|
98
103
|
hiddenFromCatalog?: boolean;
|
|
99
104
|
status?: KnowledgeSourceStatus;
|
|
@@ -107,6 +112,8 @@ export type KnowledgeSourcePatch = Partial<Pick<KnowledgeSource, 'location' | 's
|
|
|
107
112
|
displayName?: string | null;
|
|
108
113
|
description?: string | null;
|
|
109
114
|
generatedDescription?: string | null;
|
|
115
|
+
/** 传 null 可清除(与 generatedDescription 同清) */
|
|
116
|
+
generatedDescriptionSource?: KnowledgeGeneratedDescriptionSource | null;
|
|
110
117
|
authRef?: string | null;
|
|
111
118
|
network?: KnowledgeSourceNetwork | null;
|
|
112
119
|
discover?: KnowledgeSourceDiscover | null;
|