@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
|
@@ -8,6 +8,7 @@
|
|
|
8
8
|
*/
|
|
9
9
|
import { appendFileSync, mkdirSync, existsSync } from 'node:fs';
|
|
10
10
|
import { join, dirname } from 'node:path';
|
|
11
|
+
import { DEFAULT_TENANT_ID } from '@octopi-agent/core/types.js';
|
|
11
12
|
/**
|
|
12
13
|
* AuditWriter — 审计写入器
|
|
13
14
|
*
|
|
@@ -17,9 +18,11 @@ import { join, dirname } from 'node:path';
|
|
|
17
18
|
export class AuditWriter {
|
|
18
19
|
auditDir;
|
|
19
20
|
agentId;
|
|
21
|
+
tenantId;
|
|
20
22
|
constructor(config) {
|
|
21
23
|
this.auditDir = config.auditDir;
|
|
22
24
|
this.agentId = config.agentId;
|
|
25
|
+
this.tenantId = config.tenantId;
|
|
23
26
|
}
|
|
24
27
|
/**
|
|
25
28
|
* 写入审计记录
|
|
@@ -28,27 +31,44 @@ export class AuditWriter {
|
|
|
28
31
|
*/
|
|
29
32
|
write(run) {
|
|
30
33
|
try {
|
|
31
|
-
|
|
34
|
+
// 事件必带租户(§4 隔离矩阵):run 自带 > 写入器配置 > DEFAULT;
|
|
35
|
+
// **分区与记录用同一个租户**(MIN-3:分区≠记录会让按租户取证失去完整性)
|
|
36
|
+
const tenantId = run.tenantId ?? this.tenantId ?? DEFAULT_TENANT_ID;
|
|
37
|
+
const record = { ...run, tenantId };
|
|
38
|
+
const filePath = this.getFilePath(tenantId, run.subsystemId, run.timestamp);
|
|
32
39
|
const dir = dirname(filePath);
|
|
33
40
|
if (!existsSync(dir)) {
|
|
34
41
|
mkdirSync(dir, { recursive: true });
|
|
35
42
|
}
|
|
36
|
-
appendFileSync(filePath, JSON.stringify(
|
|
43
|
+
appendFileSync(filePath, JSON.stringify(record) + '\n', 'utf-8');
|
|
37
44
|
}
|
|
38
45
|
catch {
|
|
39
46
|
// 审计写入失败不阻塞主系统
|
|
40
47
|
}
|
|
41
48
|
}
|
|
42
49
|
/**
|
|
43
|
-
*
|
|
50
|
+
* 获取审计文件路径(三段式:{auditDir}/{tenantId}/[{agentId}/]{subsystemId}/{date}.jsonl)。
|
|
51
|
+
* 分区段 = 记录的生效租户(与记录恒一致)。
|
|
44
52
|
*/
|
|
45
|
-
getFilePath(subsystemId, timestamp) {
|
|
53
|
+
getFilePath(tenantId, subsystemId, timestamp) {
|
|
46
54
|
const date = new Date(timestamp).toISOString().slice(0, 10); // YYYY-MM-DD
|
|
47
|
-
const parts = [this.auditDir];
|
|
55
|
+
const parts = [this.auditDir, safeSegment(tenantId, 'tenantId')];
|
|
48
56
|
if (this.agentId) {
|
|
49
|
-
parts.push(this.agentId);
|
|
57
|
+
parts.push(safeSegment(this.agentId, 'agentId'));
|
|
50
58
|
}
|
|
51
|
-
parts.push(subsystemId, `${date}.jsonl`);
|
|
59
|
+
parts.push(safeSegment(subsystemId, 'subsystemId'), `${date}.jsonl`);
|
|
52
60
|
return join(...parts);
|
|
53
61
|
}
|
|
54
62
|
}
|
|
63
|
+
/**
|
|
64
|
+
* 路径段安全断言:ID 进文件路径前拒分隔符与 `..`(路径穿越面;NIT 2026-11-13 评审)。
|
|
65
|
+
*
|
|
66
|
+
* @param value - 路径段
|
|
67
|
+
* @param label - 字段名(报错用)
|
|
68
|
+
*/
|
|
69
|
+
function safeSegment(value, label) {
|
|
70
|
+
if (!value || /[/\\]/.test(value) || value.includes('..')) {
|
|
71
|
+
throw new Error(`audit_unsafe_path_segment: ${label}=${value}`);
|
|
72
|
+
}
|
|
73
|
+
return value;
|
|
74
|
+
}
|
|
@@ -64,6 +64,19 @@ export function validateSubsystemSpec(spec, enforcement) {
|
|
|
64
64
|
message: 'sense.source "schedule" requires interval >= 1000ms',
|
|
65
65
|
});
|
|
66
66
|
}
|
|
67
|
+
const delay = spec.sense.startupDelayMs;
|
|
68
|
+
if (delay !== undefined && (!Number.isFinite(delay) || delay < 0)) {
|
|
69
|
+
errors.push({
|
|
70
|
+
field: 'sense.startupDelayMs',
|
|
71
|
+
message: 'sense.startupDelayMs must be a finite number >= 0',
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
if (delay !== undefined && interval !== undefined && Number.isFinite(delay) && delay > interval) {
|
|
75
|
+
errors.push({
|
|
76
|
+
field: 'sense.startupDelayMs',
|
|
77
|
+
message: 'sense.startupDelayMs must be <= interval(否则周期 tick 早于首跳,错峰语义失效)',
|
|
78
|
+
});
|
|
79
|
+
}
|
|
67
80
|
}
|
|
68
81
|
// ── act.mode 非 none 时,信号通道不能只有 escalate ──
|
|
69
82
|
// (如果 act 已经直接行动了,escalate 应该配合其他通道一起用)
|
|
@@ -282,6 +282,7 @@ async function buildSpec(config, systemPrompt, source, dirPath) {
|
|
|
282
282
|
} : undefined,
|
|
283
283
|
interval: senseRaw.interval,
|
|
284
284
|
runOnStart: senseRaw.runOnStart,
|
|
285
|
+
startupDelayMs: senseRaw.startupDelayMs,
|
|
285
286
|
cooldownMs: senseRaw.cooldownMs,
|
|
286
287
|
isolation: (senseRaw.isolation ?? 'structured'),
|
|
287
288
|
fields: senseRaw.fields,
|
|
@@ -291,7 +292,7 @@ async function buildSpec(config, systemPrompt, source, dirPath) {
|
|
|
291
292
|
implementation: impl,
|
|
292
293
|
systemPrompt: thinkRaw.systemPrompt ?? systemPrompt,
|
|
293
294
|
model: thinkRaw.model ?? config.model,
|
|
294
|
-
|
|
295
|
+
maxSteps: thinkRaw.maxSteps ?? config.maxSteps,
|
|
295
296
|
handler,
|
|
296
297
|
preProcess,
|
|
297
298
|
postProcess,
|
|
@@ -7,6 +7,7 @@
|
|
|
7
7
|
* @module autonomous-subsystem/runtime
|
|
8
8
|
*/
|
|
9
9
|
import type { EventBus } from '@octopi-agent/core/primitives/event-bus.js';
|
|
10
|
+
import type { PulseSpec } from '../../activation/run-protocol.js';
|
|
10
11
|
import type { Message } from '@octopi-agent/core/types.js';
|
|
11
12
|
import type { ModelProvider } from '@octopi-agent/core/interfaces/model-provider.js';
|
|
12
13
|
import type { ErrorStrategy } from '@octopi-agent/core/interfaces/error-strategy.js';
|
|
@@ -44,6 +45,8 @@ export interface SharedDeps {
|
|
|
44
45
|
export interface SubsystemRuntimeConfig {
|
|
45
46
|
deps: SharedDeps;
|
|
46
47
|
auditDir?: string;
|
|
48
|
+
/** 归属租户(arch/multi-tenancy.md §4);透传 AuditWriter 分区/打标(生产装配接线随 T2) */
|
|
49
|
+
tenantId?: string;
|
|
47
50
|
agentId?: string;
|
|
48
51
|
/** SEC-6 宿主能力声明(必填):`sandboxed` 声明只有在 L4 可用时才放行 */
|
|
49
52
|
securityEnforcement: SecurityEnforcementContext;
|
|
@@ -121,6 +124,14 @@ export declare class SubsystemRuntime {
|
|
|
121
124
|
* 清理所有资源
|
|
122
125
|
*/
|
|
123
126
|
dispose(): void;
|
|
127
|
+
/**
|
|
128
|
+
* 脉搏声明(P0c A′):schedule 型子系统的周期声明,供装配层聚合为实例级 PulseSpec。
|
|
129
|
+
*/
|
|
130
|
+
pulseSpecs(): PulseSpec[];
|
|
131
|
+
/**
|
|
132
|
+
* 脉搏入口:gateway 单发驱动一次 schedule tick。key 形态 `subsystem.schedule:<id>`。
|
|
133
|
+
*/
|
|
134
|
+
pulse(key: string): Promise<void>;
|
|
124
135
|
/**
|
|
125
136
|
* 触发回调(由 SenseEngine 调用)
|
|
126
137
|
*/
|
|
@@ -71,6 +71,7 @@ export class SubsystemRuntime {
|
|
|
71
71
|
this.auditWriter = new AuditWriter({
|
|
72
72
|
auditDir: config.auditDir,
|
|
73
73
|
agentId: config.agentId,
|
|
74
|
+
tenantId: config.tenantId,
|
|
74
75
|
});
|
|
75
76
|
}
|
|
76
77
|
}
|
|
@@ -269,6 +270,22 @@ export class SubsystemRuntime {
|
|
|
269
270
|
this.sessionManager.dispose();
|
|
270
271
|
this.signalBus.clear();
|
|
271
272
|
}
|
|
273
|
+
/**
|
|
274
|
+
* 脉搏声明(P0c A′):schedule 型子系统的周期声明,供装配层聚合为实例级 PulseSpec。
|
|
275
|
+
*/
|
|
276
|
+
pulseSpecs() {
|
|
277
|
+
return this.senseEngine.pulseSpecs();
|
|
278
|
+
}
|
|
279
|
+
/**
|
|
280
|
+
* 脉搏入口:gateway 单发驱动一次 schedule tick。key 形态 `subsystem.schedule:<id>`。
|
|
281
|
+
*/
|
|
282
|
+
async pulse(key) {
|
|
283
|
+
const prefix = 'subsystem.schedule:';
|
|
284
|
+
if (!key.startsWith(prefix)) {
|
|
285
|
+
throw new Error(`subsystem-runtime: unknown pulse key "${key}"`);
|
|
286
|
+
}
|
|
287
|
+
await this.senseEngine.pulseSchedule(key.slice(prefix.length));
|
|
288
|
+
}
|
|
272
289
|
// ── 内部方法 ──
|
|
273
290
|
/**
|
|
274
291
|
* 触发回调(由 SenseEngine 调用)
|
|
@@ -7,6 +7,7 @@
|
|
|
7
7
|
* @module autonomous-subsystem/sense/engine
|
|
8
8
|
*/
|
|
9
9
|
import type { EventBus } from '@octopi-agent/core/primitives/event-bus.js';
|
|
10
|
+
import type { PulseSpec } from '../../../activation/run-protocol.js';
|
|
10
11
|
import type { SenseContext, SubsystemSpec } from '../types.js';
|
|
11
12
|
import { MetricsStore } from './metrics.js';
|
|
12
13
|
export interface SenseEngineConfig {
|
|
@@ -41,9 +42,9 @@ export declare class SenseEngine {
|
|
|
41
42
|
private subsystems;
|
|
42
43
|
/** 全局传播深度追踪 */
|
|
43
44
|
private depthTracker;
|
|
44
|
-
/** 深度重置定时器 */
|
|
45
|
-
private depthResetTimer?;
|
|
46
45
|
constructor(config: SenseEngineConfig);
|
|
46
|
+
/** 惰性深度重置(P0c A′:替代原 depthResetTimer setInterval——零 self-arm 定时器) */
|
|
47
|
+
private depthExceeded;
|
|
47
48
|
/** 获取指标存储(供主循环注入指标) */
|
|
48
49
|
get metricsStore(): MetricsStore;
|
|
49
50
|
/**
|
|
@@ -54,9 +55,18 @@ export declare class SenseEngine {
|
|
|
54
55
|
*/
|
|
55
56
|
register(spec: SubsystemSpec, onTrigger: (ctx: SenseContext) => void): void;
|
|
56
57
|
/**
|
|
57
|
-
* 注销子系统:拆除其 EventBus
|
|
58
|
+
* 注销子系统:拆除其 EventBus 监听
|
|
58
59
|
*/
|
|
59
60
|
unregister(subsystemId: string): void;
|
|
61
|
+
/**
|
|
62
|
+
* 脉搏声明(P0c A′):全部 schedule 型子系统的周期声明,供装配层聚合。
|
|
63
|
+
*/
|
|
64
|
+
pulseSpecs(): PulseSpec[];
|
|
65
|
+
/**
|
|
66
|
+
* 脉搏入口:gateway 单发驱动一次 schedule tick(复用冷却/深度/condition)。
|
|
67
|
+
* 未注册或非 schedule 型 fail-loud。
|
|
68
|
+
*/
|
|
69
|
+
pulseSchedule(subsystemId: string): Promise<void>;
|
|
60
70
|
/**
|
|
61
71
|
* 手动触发子系统(API 调用,可穿透冷却期)
|
|
62
72
|
*
|
|
@@ -105,7 +115,7 @@ export declare class SenseEngine {
|
|
|
105
115
|
* - 字符串字面量原样保留(不再把 `'recent'` 误识别为变量)
|
|
106
116
|
* - SenseContext 顶层字段(sessionLifecycle / eventData / …)→ `ctx.<field>`
|
|
107
117
|
* - `eventData.x` → `ctx.eventData.x`;`metrics.x` → `ctx.metrics['x']`
|
|
108
|
-
* - 其余标识符 → `ctx.metrics['id']`(兼容 `
|
|
118
|
+
* - 其余标识符 → `ctx.metrics['id']`(兼容 `step.count` 等指标键)
|
|
109
119
|
*/
|
|
110
120
|
private compileConditionExpression;
|
|
111
121
|
}
|
|
@@ -27,8 +27,6 @@ export class SenseEngine {
|
|
|
27
27
|
subsystems = new Map();
|
|
28
28
|
/** 全局传播深度追踪 */
|
|
29
29
|
depthTracker = { depth: 0, chainStartTime: Date.now() };
|
|
30
|
-
/** 深度重置定时器 */
|
|
31
|
-
depthResetTimer;
|
|
32
30
|
constructor(config) {
|
|
33
31
|
this.events = config.events;
|
|
34
32
|
this.metrics = new MetricsStore();
|
|
@@ -36,10 +34,13 @@ export class SenseEngine {
|
|
|
36
34
|
this.maxDepth = config.maxDepth ?? 5;
|
|
37
35
|
this.depthResetIntervalMs = config.depthResetIntervalMs ?? 60000;
|
|
38
36
|
this.evaluatorTimeoutMs = config.evaluatorTimeoutMs ?? 30_000;
|
|
39
|
-
|
|
40
|
-
|
|
37
|
+
}
|
|
38
|
+
/** 惰性深度重置(P0c A′:替代原 depthResetTimer setInterval——零 self-arm 定时器) */
|
|
39
|
+
depthExceeded() {
|
|
40
|
+
if (Date.now() - this.depthTracker.chainStartTime >= this.depthResetIntervalMs) {
|
|
41
41
|
this.depthTracker = { depth: 0, chainStartTime: Date.now() };
|
|
42
|
-
}
|
|
42
|
+
}
|
|
43
|
+
return this.depthTracker.depth >= this.maxDepth;
|
|
43
44
|
}
|
|
44
45
|
// ── 公共 API ──
|
|
45
46
|
/** 获取指标存储(供主循环注入指标) */
|
|
@@ -63,6 +64,7 @@ export class SenseEngine {
|
|
|
63
64
|
minEvents: spec.sense.filter?.minEvents ?? 1,
|
|
64
65
|
eventCount: 0,
|
|
65
66
|
evaluator,
|
|
67
|
+
onTrigger,
|
|
66
68
|
disposables: [],
|
|
67
69
|
};
|
|
68
70
|
this.subsystems.set(spec.id, entry);
|
|
@@ -75,7 +77,9 @@ export class SenseEngine {
|
|
|
75
77
|
entry.disposables.push(disposable);
|
|
76
78
|
}
|
|
77
79
|
}
|
|
78
|
-
// schedule
|
|
80
|
+
// schedule:周期 tick 与首跳**不再 self-arm**(P0c A′ 零常驻触发器)——
|
|
81
|
+
// 改由 gateway 脉搏调度器经 `pulseSchedule()` 单发驱动;runOnStart 首跳随
|
|
82
|
+
// `pulseSpecs()` 的 `runOnStart` 标记由调度器发出。
|
|
79
83
|
// 双脉搏:schedule 子系统也可监听 filter.events(如 memory.health.* / 手动 request)
|
|
80
84
|
if (spec.sense.source === 'schedule') {
|
|
81
85
|
if (spec.sense.filter?.events) {
|
|
@@ -86,27 +90,10 @@ export class SenseEngine {
|
|
|
86
90
|
entry.disposables.push(disposable);
|
|
87
91
|
}
|
|
88
92
|
}
|
|
89
|
-
const intervalMs = spec.sense.interval;
|
|
90
|
-
if (intervalMs && intervalMs > 0) {
|
|
91
|
-
entry.scheduleTimer = setInterval(() => {
|
|
92
|
-
void this.onScheduleTick(spec.id, onTrigger);
|
|
93
|
-
}, intervalMs);
|
|
94
|
-
if (typeof entry.scheduleTimer === 'object' && entry.scheduleTimer !== null && 'unref' in entry.scheduleTimer) {
|
|
95
|
-
entry.scheduleTimer.unref?.();
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
// 启动首跳:注册完成后补一次 tick(长 interval 首跳跨不过进程生命周期时的保底脉搏;
|
|
99
|
-
// setTimeout(0) 保证 builder 同步注册/依赖注入全部完成后才跑)
|
|
100
|
-
if (spec.sense.runOnStart) {
|
|
101
|
-
const starter = setTimeout(() => {
|
|
102
|
-
void this.onScheduleTick(spec.id, onTrigger);
|
|
103
|
-
}, 0);
|
|
104
|
-
starter.unref?.();
|
|
105
|
-
}
|
|
106
93
|
}
|
|
107
94
|
}
|
|
108
95
|
/**
|
|
109
|
-
* 注销子系统:拆除其 EventBus
|
|
96
|
+
* 注销子系统:拆除其 EventBus 监听
|
|
110
97
|
*/
|
|
111
98
|
unregister(subsystemId) {
|
|
112
99
|
const entry = this.subsystems.get(subsystemId);
|
|
@@ -116,12 +103,42 @@ export class SenseEngine {
|
|
|
116
103
|
d.dispose();
|
|
117
104
|
}
|
|
118
105
|
entry.disposables = [];
|
|
119
|
-
if (entry.scheduleTimer) {
|
|
120
|
-
clearInterval(entry.scheduleTimer);
|
|
121
|
-
entry.scheduleTimer = undefined;
|
|
122
|
-
}
|
|
123
106
|
this.subsystems.delete(subsystemId);
|
|
124
107
|
}
|
|
108
|
+
/**
|
|
109
|
+
* 脉搏声明(P0c A′):全部 schedule 型子系统的周期声明,供装配层聚合。
|
|
110
|
+
*/
|
|
111
|
+
pulseSpecs() {
|
|
112
|
+
const specs = [];
|
|
113
|
+
for (const [id, entry] of this.subsystems) {
|
|
114
|
+
if (entry.spec.sense.source !== 'schedule')
|
|
115
|
+
continue;
|
|
116
|
+
const intervalMs = entry.spec.sense.interval;
|
|
117
|
+
if (!intervalMs || intervalMs <= 0)
|
|
118
|
+
continue;
|
|
119
|
+
specs.push({
|
|
120
|
+
key: `subsystem.schedule:${id}`,
|
|
121
|
+
intervalMs,
|
|
122
|
+
runOnStart: entry.spec.sense.runOnStart,
|
|
123
|
+
startupDelayMs: entry.spec.sense.startupDelayMs,
|
|
124
|
+
});
|
|
125
|
+
}
|
|
126
|
+
return specs;
|
|
127
|
+
}
|
|
128
|
+
/**
|
|
129
|
+
* 脉搏入口:gateway 单发驱动一次 schedule tick(复用冷却/深度/condition)。
|
|
130
|
+
* 未注册或非 schedule 型 fail-loud。
|
|
131
|
+
*/
|
|
132
|
+
async pulseSchedule(subsystemId) {
|
|
133
|
+
const entry = this.subsystems.get(subsystemId);
|
|
134
|
+
if (!entry) {
|
|
135
|
+
throw new Error(`sense-engine: unknown pulse subsystem "${subsystemId}"`);
|
|
136
|
+
}
|
|
137
|
+
if (entry.spec.sense.source !== 'schedule') {
|
|
138
|
+
throw new Error(`sense-engine: subsystem "${subsystemId}" is not schedule-sensed`);
|
|
139
|
+
}
|
|
140
|
+
await this.onScheduleTick(subsystemId, entry.onTrigger);
|
|
141
|
+
}
|
|
125
142
|
/**
|
|
126
143
|
* 手动触发子系统(API 调用,可穿透冷却期)
|
|
127
144
|
*
|
|
@@ -134,7 +151,7 @@ export class SenseEngine {
|
|
|
134
151
|
if (!entry)
|
|
135
152
|
return false;
|
|
136
153
|
// 检查并发深度
|
|
137
|
-
if (this.
|
|
154
|
+
if (this.depthExceeded()) {
|
|
138
155
|
return false;
|
|
139
156
|
}
|
|
140
157
|
// API 触发穿透冷却期,但仍评估条件
|
|
@@ -256,14 +273,6 @@ export class SenseEngine {
|
|
|
256
273
|
d.dispose();
|
|
257
274
|
}
|
|
258
275
|
entry.disposables = [];
|
|
259
|
-
if (entry.scheduleTimer) {
|
|
260
|
-
clearInterval(entry.scheduleTimer);
|
|
261
|
-
entry.scheduleTimer = undefined;
|
|
262
|
-
}
|
|
263
|
-
}
|
|
264
|
-
if (this.depthResetTimer) {
|
|
265
|
-
clearInterval(this.depthResetTimer);
|
|
266
|
-
this.depthResetTimer = undefined;
|
|
267
276
|
}
|
|
268
277
|
this.subsystems.clear();
|
|
269
278
|
}
|
|
@@ -303,7 +312,7 @@ export class SenseEngine {
|
|
|
303
312
|
if (now < entry.cooldown.until || entry.inFlight) {
|
|
304
313
|
return;
|
|
305
314
|
}
|
|
306
|
-
if (this.
|
|
315
|
+
if (this.depthExceeded()) {
|
|
307
316
|
return;
|
|
308
317
|
}
|
|
309
318
|
const data = (event.data ?? {});
|
|
@@ -352,7 +361,7 @@ export class SenseEngine {
|
|
|
352
361
|
if (now < entry.cooldown.until || entry.inFlight) {
|
|
353
362
|
return;
|
|
354
363
|
}
|
|
355
|
-
if (this.
|
|
364
|
+
if (this.depthExceeded()) {
|
|
356
365
|
return;
|
|
357
366
|
}
|
|
358
367
|
const ctx = {
|
|
@@ -434,7 +443,7 @@ export class SenseEngine {
|
|
|
434
443
|
* - 字符串字面量原样保留(不再把 `'recent'` 误识别为变量)
|
|
435
444
|
* - SenseContext 顶层字段(sessionLifecycle / eventData / …)→ `ctx.<field>`
|
|
436
445
|
* - `eventData.x` → `ctx.eventData.x`;`metrics.x` → `ctx.metrics['x']`
|
|
437
|
-
* - 其余标识符 → `ctx.metrics['id']`(兼容 `
|
|
446
|
+
* - 其余标识符 → `ctx.metrics['id']`(兼容 `step.count` 等指标键)
|
|
438
447
|
*/
|
|
439
448
|
compileConditionExpression(expr) {
|
|
440
449
|
const body = rewriteConditionExpression(expr);
|
|
@@ -544,7 +553,7 @@ export function rewriteConditionExpression(expr) {
|
|
|
544
553
|
i = rest;
|
|
545
554
|
continue;
|
|
546
555
|
}
|
|
547
|
-
// 其余标识符:整段 dotted name 作为 metrics key(
|
|
556
|
+
// 其余标识符:整段 dotted name 作为 metrics key(step.count)
|
|
548
557
|
let name = base;
|
|
549
558
|
let rest = j;
|
|
550
559
|
while (rest < expr.length &&
|
|
@@ -21,7 +21,7 @@ export function buildAgentInput(spec, ctx) {
|
|
|
21
21
|
input.sessionMetadata = {
|
|
22
22
|
agentId: ctx.runConfig.agentId ?? 'unknown',
|
|
23
23
|
sessionId: ctx.runConfig.sessionId ?? 'unknown',
|
|
24
|
-
|
|
24
|
+
stepCount: ctx.messages.filter((m) => m.role === 'assistant').length,
|
|
25
25
|
sessionLifecycle: ctx.sessionLifecycle,
|
|
26
26
|
lastInteractionAt: ctx.lastInteractionAt,
|
|
27
27
|
idleMs: ctx.idleMs,
|
|
@@ -53,7 +53,7 @@ export function buildAgentInput(spec, ctx) {
|
|
|
53
53
|
input.sessionMetadata = {
|
|
54
54
|
agentId: ctx.runConfig.agentId ?? 'unknown',
|
|
55
55
|
sessionId: ctx.runConfig.sessionId ?? 'unknown',
|
|
56
|
-
|
|
56
|
+
stepCount: ctx.messages.filter((m) => m.role === 'assistant').length,
|
|
57
57
|
};
|
|
58
58
|
break;
|
|
59
59
|
case 'token_count':
|
|
@@ -72,7 +72,7 @@ export function buildAgentInput(spec, ctx) {
|
|
|
72
72
|
...(input.sessionMetadata ?? {
|
|
73
73
|
agentId: ctx.runConfig.agentId ?? 'unknown',
|
|
74
74
|
sessionId: ctx.runConfig.sessionId ?? 'unknown',
|
|
75
|
-
|
|
75
|
+
stepCount: ctx.messages.filter((m) => m.role === 'assistant').length,
|
|
76
76
|
}),
|
|
77
77
|
sessionLifecycle: ctx.sessionLifecycle,
|
|
78
78
|
lastInteractionAt: ctx.lastInteractionAt,
|
|
@@ -93,7 +93,7 @@ export function buildAgentInput(spec, ctx) {
|
|
|
93
93
|
input.sessionMetadata = {
|
|
94
94
|
agentId: ctx.runConfig.agentId ?? 'unknown',
|
|
95
95
|
sessionId: ctx.runConfig.sessionId ?? 'unknown',
|
|
96
|
-
|
|
96
|
+
stepCount: ctx.messages.filter((m) => m.role === 'assistant').length,
|
|
97
97
|
};
|
|
98
98
|
if (ctx.pendingToolCall)
|
|
99
99
|
input.pendingToolCall = ctx.pendingToolCall;
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
/**
|
|
10
10
|
* MetricsStore — 线程安全的指标存储
|
|
11
11
|
*
|
|
12
|
-
* 存储主循环注入的运行时指标(如
|
|
12
|
+
* 存储主循环注入的运行时指标(如 step.count、token.used 等),
|
|
13
13
|
* 供 SenseEngine 的 condition 表达式评估使用。
|
|
14
14
|
*/
|
|
15
15
|
export declare class MetricsStore {
|
|
@@ -17,7 +17,7 @@ export declare class MetricsStore {
|
|
|
17
17
|
/**
|
|
18
18
|
* 更新指标值
|
|
19
19
|
*
|
|
20
|
-
* @param key - 指标名(如 '
|
|
20
|
+
* @param key - 指标名(如 'step.count')
|
|
21
21
|
* @param value - 指标值
|
|
22
22
|
*/
|
|
23
23
|
update(key: string, value: number): void;
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
/**
|
|
10
10
|
* MetricsStore — 线程安全的指标存储
|
|
11
11
|
*
|
|
12
|
-
* 存储主循环注入的运行时指标(如
|
|
12
|
+
* 存储主循环注入的运行时指标(如 step.count、token.used 等),
|
|
13
13
|
* 供 SenseEngine 的 condition 表达式评估使用。
|
|
14
14
|
*/
|
|
15
15
|
export class MetricsStore {
|
|
@@ -17,7 +17,7 @@ export class MetricsStore {
|
|
|
17
17
|
/**
|
|
18
18
|
* 更新指标值
|
|
19
19
|
*
|
|
20
|
-
* @param key - 指标名(如 '
|
|
20
|
+
* @param key - 指标名(如 'step.count')
|
|
21
21
|
* @param value - 指标值
|
|
22
22
|
*/
|
|
23
23
|
update(key, value) {
|
|
@@ -32,6 +32,12 @@ export interface ContextInjection {
|
|
|
32
32
|
messages: Array<{
|
|
33
33
|
role: 'system' | 'user' | 'assistant';
|
|
34
34
|
content: string;
|
|
35
|
+
/** 载体标记(engineHint 等);isTurnAnchor/回放按此判语义 */
|
|
36
|
+
metadata?: {
|
|
37
|
+
source?: string;
|
|
38
|
+
};
|
|
39
|
+
/** 状态快照类注入:同 run 只留最新一份,不落库 */
|
|
40
|
+
ephemeral?: boolean;
|
|
35
41
|
}>;
|
|
36
42
|
/** 是否标记为压缩结果 */
|
|
37
43
|
compressed?: boolean;
|
|
@@ -84,7 +84,12 @@ export class SignalBus {
|
|
|
84
84
|
messages.push({
|
|
85
85
|
...msg,
|
|
86
86
|
timestamp: Date.now(),
|
|
87
|
-
|
|
87
|
+
// P0-B 同范式:统一 engineHint 载体(ENGINE_CARRIER_SOURCES 成员,
|
|
88
|
+
// 不被 isTurnAnchor 认作轮锚点——否则信号更新会钉死老化边界);
|
|
89
|
+
// compressed 快照保留既有标记。上游 metadata 不透传:载体内涵由本转换定义。
|
|
90
|
+
metadata: injection.compressed
|
|
91
|
+
? { compressed: true, source: 'engineHint' }
|
|
92
|
+
: { source: 'engineHint' },
|
|
88
93
|
});
|
|
89
94
|
}
|
|
90
95
|
}
|
|
@@ -159,15 +164,31 @@ export class SignalBus {
|
|
|
159
164
|
if (signal.action === 'replace') {
|
|
160
165
|
this.contextQueue.push({
|
|
161
166
|
subsystemId,
|
|
162
|
-
|
|
167
|
+
// 状态快照:engineHint 载体 + ephemeral(同 run 只留最新一份,不落库)
|
|
168
|
+
messages: [
|
|
169
|
+
{
|
|
170
|
+
role: 'user',
|
|
171
|
+
content: signal.reason,
|
|
172
|
+
ephemeral: true,
|
|
173
|
+
metadata: { source: 'engineHint' },
|
|
174
|
+
},
|
|
175
|
+
],
|
|
163
176
|
compressed: true,
|
|
164
177
|
});
|
|
165
178
|
}
|
|
166
179
|
else {
|
|
167
|
-
// suggest / alert →
|
|
180
|
+
// suggest / alert → 注入为引擎提示(user 形态 + engineHint 标记,随历史保留)。
|
|
181
|
+
// 不用 role:'system':非托管 system 会被 provider 适配层拼进 system 字段,
|
|
182
|
+
// 状态变化即前缀整段失效(context-size-accounting.md §1)。
|
|
168
183
|
this.contextQueue.push({
|
|
169
184
|
subsystemId,
|
|
170
|
-
messages: [
|
|
185
|
+
messages: [
|
|
186
|
+
{
|
|
187
|
+
role: 'user',
|
|
188
|
+
content: `[${signal.action}] ${signal.reason}`,
|
|
189
|
+
metadata: { source: 'engineHint' },
|
|
190
|
+
},
|
|
191
|
+
],
|
|
171
192
|
});
|
|
172
193
|
}
|
|
173
194
|
}
|
|
@@ -121,7 +121,7 @@ export class ThinkExecutor {
|
|
|
121
121
|
if (event.type === 'assistant_message') {
|
|
122
122
|
lastContent = typeof event.message.content === 'string' ? event.message.content : '';
|
|
123
123
|
}
|
|
124
|
-
if (event.type === '
|
|
124
|
+
if (event.type === 'step_end' && event.usage) {
|
|
125
125
|
const u = event.usage;
|
|
126
126
|
tokenUsage = {
|
|
127
127
|
prompt: u.inputReportedTokens ??
|
|
@@ -209,6 +209,9 @@ export class ThinkExecutor {
|
|
|
209
209
|
name: t.definition.name,
|
|
210
210
|
description: t.definition.description,
|
|
211
211
|
executionMode: t.executionMode,
|
|
212
|
+
// 结果老化策略(同 executionMode:唯一声明源在 RegisteredTool)
|
|
213
|
+
...(t.ageArgs ? { ageArgs: t.ageArgs } : {}),
|
|
214
|
+
...(t.ageResult ? { ageResult: t.ageResult } : {}),
|
|
212
215
|
parameters: {
|
|
213
216
|
type: 'object',
|
|
214
217
|
properties: Object.fromEntries(Object.entries(t.definition.parameters).map(([key, param]) => [
|
|
@@ -75,7 +75,7 @@ export type ContextField = 'task_summary' | 'tool_calls' | 'tool_results' | 'wor
|
|
|
75
75
|
export interface SenseFilter {
|
|
76
76
|
/** 监听的事件类型(source=eventBus 时) */
|
|
77
77
|
events?: string[];
|
|
78
|
-
/** 声明式条件表达式(如 "
|
|
78
|
+
/** 声明式条件表达式(如 "step.count % 10 === 0") */
|
|
79
79
|
condition?: string;
|
|
80
80
|
/** 代码引用(如 "./handler.ts:shouldExtract"),与 condition 互斥 */
|
|
81
81
|
conditionRef?: string;
|
|
@@ -97,6 +97,8 @@ export interface SenseConfig {
|
|
|
97
97
|
interval?: number;
|
|
98
98
|
/** schedule 模式:注册后立即补一次首跳(长 interval 跨不过进程生命周期时的保底脉搏) */
|
|
99
99
|
runOnStart?: boolean;
|
|
100
|
+
/** schedule 模式:首跳延迟(毫秒)——多子系统首跳按数据流依赖序错峰(如 govern 先于下游巩固/归因) */
|
|
101
|
+
startupDelayMs?: number;
|
|
100
102
|
/** 本子系统的触发冷却(毫秒);缺省用 SenseEngine 全局 defaultCooldownMs */
|
|
101
103
|
cooldownMs?: number;
|
|
102
104
|
isolation: IsolationLevel;
|
|
@@ -130,7 +132,7 @@ export interface ThinkConfig {
|
|
|
130
132
|
/** 模型级别引用(如 "mini"、"standard"、"pro")或 provider/model 格式 */
|
|
131
133
|
model?: string;
|
|
132
134
|
/** 最大推理轮次(默认 1) */
|
|
133
|
-
|
|
135
|
+
maxSteps?: number;
|
|
134
136
|
/** hybrid 模式的预处理函数 */
|
|
135
137
|
preProcess?: (input: SubsystemInput) => Promise<SubsystemInput>;
|
|
136
138
|
/** hybrid 模式的后处理函数 */
|
|
@@ -306,7 +308,7 @@ export interface SubsystemInput {
|
|
|
306
308
|
sessionMetadata?: {
|
|
307
309
|
agentId: string;
|
|
308
310
|
sessionId: string;
|
|
309
|
-
|
|
311
|
+
stepCount: number;
|
|
310
312
|
} & Record<string, unknown>;
|
|
311
313
|
/** Token 使用量 */
|
|
312
314
|
tokenCount?: {
|
|
@@ -378,6 +380,8 @@ export interface SubsystemRun {
|
|
|
378
380
|
id: string;
|
|
379
381
|
/** 子系统标识 */
|
|
380
382
|
subsystemId: string;
|
|
383
|
+
/** 归属租户(arch/multi-tenancy.md §4;缺省 'default',AuditWriter.write 可代打) */
|
|
384
|
+
tenantId?: string;
|
|
381
385
|
/** 触发原因 */
|
|
382
386
|
trigger: {
|
|
383
387
|
source: string;
|
|
@@ -18,16 +18,20 @@
|
|
|
18
18
|
* 本端口管"目标本地怎么起 Run"。两者不可互相渗透。
|
|
19
19
|
*/
|
|
20
20
|
import type { SessionStore } from '@octopi-agent/core/interfaces/session-store.js';
|
|
21
|
-
import type { TokenUsage } from '@octopi-agent/core/types/
|
|
21
|
+
import type { TokenUsage } from '@octopi-agent/core/types/step.js';
|
|
22
22
|
import type { AgentEvent } from '@octopi-agent/core/primitives/event-bus.js';
|
|
23
23
|
import type { SessionData, SessionSpawnLink } from '../../session/types.js';
|
|
24
24
|
import type { DelegationBudget, DelegationContextMode } from './types.js';
|
|
25
25
|
/** 子 Run 入参 */
|
|
26
26
|
export interface ChildRunInput {
|
|
27
|
+
/** 归属租户(继承父会话,arch/multi-tenancy.md §8);接线在 T4,缺省 DEFAULT_TENANT_ID */
|
|
28
|
+
tenantId?: import('@octopi-agent/core/types.js').TenantId;
|
|
27
29
|
delegationId: string;
|
|
28
30
|
/** 目标 agentId(已解析) */
|
|
29
31
|
childAgentId: string;
|
|
30
32
|
task: string;
|
|
33
|
+
/** 子会话显示标题(工具面必填;缺省时退任务派生标题,不产生「新会话」) */
|
|
34
|
+
title?: string;
|
|
31
35
|
input: string;
|
|
32
36
|
/** 上下文传递模式 */
|
|
33
37
|
context: DelegationContextMode;
|
|
@@ -116,6 +120,11 @@ export declare class RunnerChildRunPort implements ChildRunPort {
|
|
|
116
120
|
/** 构造带 `spawnBy` 的 child session 骨架 */
|
|
117
121
|
private newChildSession;
|
|
118
122
|
}
|
|
123
|
+
/** 委派 → 子会话标题(单一来源,委派单记录与子会话同用此值):显式 title 优先(压单行、截 120);缺省退任务派生(delegation: 前缀,兼容直连 API 老调用方) */
|
|
124
|
+
export declare function delegationSessionTitle(input: {
|
|
125
|
+
title?: string;
|
|
126
|
+
task: string;
|
|
127
|
+
}): string;
|
|
119
128
|
/** 委派指令片段(§9.4:模板 persona + 编排指令) */
|
|
120
129
|
export interface DelegationPromptOptions {
|
|
121
130
|
/** 子 agent 的 persona(来自 `AgentConfig.persona`) */
|