@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
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* delegated-run — 委派子 run 的执行腿适配(arch/service-topology.md §9.5 S1 收口)。
|
|
3
|
+
*
|
|
4
|
+
* attach / child-run 不持裸 runner:RunnerChildRunPort 调的 `handle()` 经
|
|
5
|
+
* RunRequest → host.startRun(准入闸门 + in-flight 计数 + abort 判据 + 退役可见),
|
|
6
|
+
* 不再直连 SessionAwareRunner.handle。与 SessionRunnerDispatcher(RunRequest →
|
|
7
|
+
* runner.handle)互为正反映射。
|
|
8
|
+
*/
|
|
9
|
+
import { randomUUID } from 'node:crypto';
|
|
10
|
+
/**
|
|
11
|
+
* 构造委派子 run 的 RunRequest(纯映射)。
|
|
12
|
+
* D3 天花板随 req 透传,由 Runner 与模板天花板取交集(只能收紧)。
|
|
13
|
+
*
|
|
14
|
+
* @param sessionId - 子会话 id(D7 预创建,含 spawnBy)
|
|
15
|
+
* @param input - RunnerChildRunPort 交给 handle 的用户输入
|
|
16
|
+
* @param runConfig - 子 run 配置(systemPrompt / rightsCeiling / model)
|
|
17
|
+
* @returns 契约 RunRequest
|
|
18
|
+
* @throws runConfig.agentId 缺失(委派执行腿必有目标)
|
|
19
|
+
*/
|
|
20
|
+
export function buildDelegatedRunRequest(sessionId, input, runConfig) {
|
|
21
|
+
const agentId = runConfig.agentId;
|
|
22
|
+
if (!agentId) {
|
|
23
|
+
throw new Error('delegate child run requires runConfig.agentId');
|
|
24
|
+
}
|
|
25
|
+
const text = typeof input.content === 'string' ? input.content : JSON.stringify(input.content ?? '');
|
|
26
|
+
const trigger = {
|
|
27
|
+
id: `child-${randomUUID()}`,
|
|
28
|
+
type: 'message',
|
|
29
|
+
agentId,
|
|
30
|
+
sessionId,
|
|
31
|
+
timestamp: Date.now(),
|
|
32
|
+
payload: { kind: 'user_message', content: text },
|
|
33
|
+
};
|
|
34
|
+
return {
|
|
35
|
+
requestId: `child-${randomUUID()}`,
|
|
36
|
+
triggers: [trigger],
|
|
37
|
+
agentId,
|
|
38
|
+
sessionId,
|
|
39
|
+
messages: [input],
|
|
40
|
+
actorType: 'agent',
|
|
41
|
+
// §9.1-6:子 run principal 归属继承父租户(dispatcher 合入 principal)
|
|
42
|
+
...(runConfig.principal?.tenantId === undefined ? {} : { tenantId: runConfig.principal.tenantId }),
|
|
43
|
+
...(runConfig.model === undefined ? {} : { modelOverride: runConfig.model }),
|
|
44
|
+
...(runConfig.modelProvider === undefined ? {} : { modelProvider: runConfig.modelProvider }),
|
|
45
|
+
...(runConfig.systemPrompt === undefined ? {} : { systemPrompt: runConfig.systemPrompt }),
|
|
46
|
+
...(runConfig.rightsCeiling === undefined ? {} : { rightsCeiling: runConfig.rightsCeiling }),
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* 委派子 run 的执行腿 handle(SessionAwareRunner.handle 的结构替代面)。
|
|
51
|
+
* 目标未挂载即 get-or-mount(/runs 同语义);缺定义 fail-loud。
|
|
52
|
+
*
|
|
53
|
+
* @param deps - 执行腿依赖面
|
|
54
|
+
* @returns handle(sessionId, input, runConfig, signal) 事件流
|
|
55
|
+
*/
|
|
56
|
+
export function createDelegatedLegHandle(deps) {
|
|
57
|
+
return (sessionId, input, runConfig, signal) => (async function* () {
|
|
58
|
+
const agentId = runConfig.agentId;
|
|
59
|
+
if (!agentId) {
|
|
60
|
+
throw new Error('delegate child run requires runConfig.agentId');
|
|
61
|
+
}
|
|
62
|
+
const def = deps.getDefinition(agentId);
|
|
63
|
+
if (!def) {
|
|
64
|
+
throw new Error(`delegate target not runnable: ${agentId}`);
|
|
65
|
+
}
|
|
66
|
+
if (!deps.get(agentId)) {
|
|
67
|
+
await deps.ensureMounted(agentId, def);
|
|
68
|
+
}
|
|
69
|
+
yield* deps.startRun(buildDelegatedRunRequest(sessionId, input, runConfig), signal);
|
|
70
|
+
})();
|
|
71
|
+
}
|
|
@@ -27,6 +27,17 @@ export class SessionRunnerDispatcher {
|
|
|
27
27
|
sessionId: req.sessionId,
|
|
28
28
|
model: req.modelOverride,
|
|
29
29
|
modelProvider: req.modelProvider,
|
|
30
|
+
// per-run 覆盖(委派子 run):显式值后置胜出;rightsCeiling 由 Runner
|
|
31
|
+
// 与模板天花板取交集(D3 只能收紧),此处透传不放宽。
|
|
32
|
+
...(req.systemPrompt === undefined ? {} : { systemPrompt: req.systemPrompt }),
|
|
33
|
+
...(req.rightsCeiling === undefined ? {} : { rightsCeiling: req.rightsCeiling }),
|
|
34
|
+
...(req.actorId === undefined && req.actorType === undefined && req.tenantId === undefined ? {} : {
|
|
35
|
+
principal: {
|
|
36
|
+
...(req.actorId === undefined ? {} : { actorId: req.actorId }),
|
|
37
|
+
...(req.actorType === undefined ? {} : { actorType: req.actorType }),
|
|
38
|
+
...(req.tenantId === undefined ? {} : { tenantId: req.tenantId }),
|
|
39
|
+
},
|
|
40
|
+
}),
|
|
30
41
|
};
|
|
31
42
|
const entries = req.triggers.map((trigger, index) => ({
|
|
32
43
|
id: trigger.id,
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
import type { AgentEvent } from '@octopi-agent/core/primitives/event-bus.js';
|
|
10
10
|
import type { Message } from '@octopi-agent/core/types.js';
|
|
11
11
|
import type { Trigger } from './types.js';
|
|
12
|
-
export type InboxOfferResult = '
|
|
12
|
+
export type InboxOfferResult = 'continued' | 'dispatched' | 'duplicate';
|
|
13
13
|
export interface SessionInboxSignal {
|
|
14
14
|
agentId: string;
|
|
15
15
|
sessionId: string;
|
|
@@ -26,7 +26,7 @@ export interface SessionInboxSignal {
|
|
|
26
26
|
trigger?: Trigger;
|
|
27
27
|
/** 调用方的收尾通道(频道回复捕获等);消费时由 Runner 转发事件。 */
|
|
28
28
|
onEvent?: (event: AgentEvent) => void;
|
|
29
|
-
onAdmitted?: (delivery: '
|
|
29
|
+
onAdmitted?: (delivery: 'continued') => void;
|
|
30
30
|
}
|
|
31
31
|
export interface SessionInboxEntry {
|
|
32
32
|
readonly id: string;
|
|
@@ -71,7 +71,7 @@ export declare class SessionInbox {
|
|
|
71
71
|
private readonly unacked;
|
|
72
72
|
constructor(redispatch: (entry: SessionInboxEntry) => void | Promise<unknown>, idLimit?: number);
|
|
73
73
|
/**
|
|
74
|
-
* 有兼容的活跃接收端才接收(返回
|
|
74
|
+
* 有兼容的活跃接收端才接收(返回 continued);否则调用方继续原 Trigger。
|
|
75
75
|
* duplicate = 同 id 已被接收或已入上下文,不得再次执行。
|
|
76
76
|
* 兼容性:显式换模型(≠ 活跃 Run 模型)/ 带附件输入不接续,走完整新 Run。
|
|
77
77
|
*/
|
|
@@ -31,7 +31,7 @@ export class SessionInbox {
|
|
|
31
31
|
this.idLimit = idLimit;
|
|
32
32
|
}
|
|
33
33
|
/**
|
|
34
|
-
* 有兼容的活跃接收端才接收(返回
|
|
34
|
+
* 有兼容的活跃接收端才接收(返回 continued);否则调用方继续原 Trigger。
|
|
35
35
|
* duplicate = 同 id 已被接收或已入上下文,不得再次执行。
|
|
36
36
|
* 兼容性:显式换模型(≠ 活跃 Run 模型)/ 带附件输入不接续,走完整新 Run。
|
|
37
37
|
*/
|
|
@@ -61,8 +61,8 @@ export class SessionInbox {
|
|
|
61
61
|
};
|
|
62
62
|
this.owned.add(id);
|
|
63
63
|
active.state.pending.push(entry);
|
|
64
|
-
signal.onAdmitted?.('
|
|
65
|
-
return '
|
|
64
|
+
signal.onAdmitted?.('continued');
|
|
65
|
+
return 'continued';
|
|
66
66
|
}
|
|
67
67
|
/** 仅 Runner 持锁后调用;同 (agent, session) 同时只有一个接收端。 */
|
|
68
68
|
open(sessionId, agentId, runId, entries, runModel) {
|
|
@@ -18,3 +18,4 @@ export { RuntimeEvents } from './types.js';
|
|
|
18
18
|
export { ScheduleSource, EscalateBridge, AgentSignalSource, emitEscalate, emitAgentSignal, ESCALATE_EVENT_TYPE, SIGNAL_ESCALATE_EVENT_TYPE, AGENT_SIGNAL_EVENT_TYPE, } from './sources/index.js';
|
|
19
19
|
export type { ScheduleJob, ScheduleSourceConfig, EscalateBridgeConfig, AgentSignal, AgentSignalSourceConfig, } from './sources/index.js';
|
|
20
20
|
export type { Trigger, TriggerType, TriggerPayload, TriggerSource, RunRequest, RunDispatcher, RouteTarget, AgentRouter, RuntimeAgent, DispatchResult, FanoutDispatchResult, RuntimeEvent, RuntimeEventType, RuntimeEventListener, } from './types.js';
|
|
21
|
+
export type { RunBackend, RunBackendHealth, } from './run-backend.js';
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* RunBackend — gateway ↔ run 侧契约缝(arch/service-topology.md §4)
|
|
3
|
+
*
|
|
4
|
+
* 语义边界(触发面/执行面分离,§5.4):
|
|
5
|
+
* - 触发面(AgentRuntime / TriggerSource / 准入政策)归 gateway;
|
|
6
|
+
* - 执行面(Runner 构建/执行/退役/会话锁)一律经本契约触达,gateway 不得直摸 Runner。
|
|
7
|
+
*
|
|
8
|
+
* 实现分期(§4 单实现决策):
|
|
9
|
+
* - P0a:InProcessRunBackend(gateway 包内,进程内脚手架,P0b 后删除);
|
|
10
|
+
* - P0b 起:RemoteRunBackend(进程间唯一实现)。
|
|
11
|
+
*
|
|
12
|
+
* P0b 迁移注记:compactSession 的函数型参数(compactStructural / summarize)已数据化
|
|
13
|
+
* 清偿(2026-11-10,解析入 engine RunHost)——控制面只传键,实现在 run 侧解析。
|
|
14
|
+
* 本契约禁止再引入函数型参数。
|
|
15
|
+
*/
|
|
16
|
+
import type { RunDispatcher } from './types.js';
|
|
17
|
+
import type { SessionLease } from '../run/concurrency/session-lease.js';
|
|
18
|
+
import type { CompactTransportOutcome } from '../context/capabilities/compact/types.js';
|
|
19
|
+
import type { OpsAuditEvent } from '../extension/execution-environment/ops-audit.js';
|
|
20
|
+
/**
|
|
21
|
+
* run 起点准入闸门结果(三件套:账本 event + state + run 通道错误,ops P2)。
|
|
22
|
+
* 政策面(gateway)↔ 执行面(backend)的握手类型;远程化时须可传输(state 保持
|
|
23
|
+
* 原样序列化,不在此收窄——闸门可为 knowledge/drift/kill-switch 等多种政策复用)。
|
|
24
|
+
*/
|
|
25
|
+
export interface AdmissionGateResult {
|
|
26
|
+
/** 账本事件名(联合类型,如 ops.knowledge.run_refused) */
|
|
27
|
+
event: OpsAuditEvent;
|
|
28
|
+
/** run 通道错误文案(也是账本 reason) */
|
|
29
|
+
error: string;
|
|
30
|
+
/** 账本 state 载荷(如 knowledge 运行状态) */
|
|
31
|
+
state: unknown;
|
|
32
|
+
}
|
|
33
|
+
/** 运行面健康快照 */
|
|
34
|
+
export interface RunBackendHealth {
|
|
35
|
+
mountedAgents: number;
|
|
36
|
+
inFlightRuns: number;
|
|
37
|
+
retiredRunners: number;
|
|
38
|
+
/**
|
|
39
|
+
* 脉搏自述(P0c A′):装配产物声明的全部 PulseSpec。gateway 脉搏调度器据此
|
|
40
|
+
* 单发驱动;也是「无 self-arm 定时器」结构性断言的自证面(清单有、定时器无)。
|
|
41
|
+
*/
|
|
42
|
+
pulses?: import('../activation/run-protocol.js').PulseSpec[];
|
|
43
|
+
/**
|
|
44
|
+
* fleet 聚合时的不可达实例清单(单实例恒空;fail-loud 可见性,§4.2)。
|
|
45
|
+
* 现状:生产消费者仅 fleetStatus 诊断面(DOC-5 标注:诊断预留,非控制信号)。
|
|
46
|
+
*/
|
|
47
|
+
unreachableInstances?: string[];
|
|
48
|
+
/**
|
|
49
|
+
* 守卫在位状态(§4.3 健康门跨版本核查):'armed'=实例按 configPath 自建了
|
|
50
|
+
* securityIntegrity 守卫;'absent'=未自建(旧版 run-serve-child 或未配)。
|
|
51
|
+
* 配置含 securityIntegrity 而实例报 absent → 健康门拒(防跨版本漂移闸 fail-open)。
|
|
52
|
+
*/
|
|
53
|
+
securityGuard?: 'armed' | 'absent';
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* RunBackend —— run 托管契约(单一 remote 实现为终态)。
|
|
57
|
+
*
|
|
58
|
+
* 契约拆分(P1-1b,OP-P0B-1 ③):P0a 脚手架面(mount/get/handles/
|
|
59
|
+
* mountedAgentIds/retire + InProcessAgentHandle/RunBackendMountSpec)已归
|
|
60
|
+
* RunHost 域(harness/run/run-host.ts)——执行体装配是 run 服务自身面,
|
|
61
|
+
* 不是 gateway 消费面。本契约只保留 gateway 侧消费面。
|
|
62
|
+
*
|
|
63
|
+
* 错误表面(fail-loud,两形态):未装载时 `execute`/`compactSession` **同步抛错**;
|
|
64
|
+
* 准入闸门拒 run 是**异步事件流内抛错**(消费方经 for-await 收到)。远程实现须把
|
|
65
|
+
* 两者映射为明确的失败事件,不得静默吞(§4 契约纪律)。
|
|
66
|
+
*
|
|
67
|
+
* `execute`(继承自 RunDispatcher)是契约统一执行入口(测试与未来 startRun 通道
|
|
68
|
+
* 使用);in-process 生产链路当前经 AgentRuntime → handle.dispatcher 直达同一包装,
|
|
69
|
+
* 两条路汇聚于同一执行腿,无第二执行语义。
|
|
70
|
+
*/
|
|
71
|
+
export interface RunBackend extends RunDispatcher {
|
|
72
|
+
/** 会话执行互斥(宪法 E1/E2;run lease 前身,P1 分布式化) */
|
|
73
|
+
readonly sessionLock: SessionLease;
|
|
74
|
+
/**
|
|
75
|
+
* 会话压缩(控制面 op;与 run 共用 sessionLock 排队)。
|
|
76
|
+
* 纯数据签名:systemPrompt/tools/摘要绑定由实现侧(RunHost)从 run 状态解析。
|
|
77
|
+
*
|
|
78
|
+
* @param sessionId - 会话 id
|
|
79
|
+
* @param agentId - compact 视图归属 agent
|
|
80
|
+
* @returns 压缩结果
|
|
81
|
+
*/
|
|
82
|
+
compactSession(sessionId: string, agentId: string): Promise<CompactTransportOutcome>;
|
|
83
|
+
/**
|
|
84
|
+
* 运行面健康(supervise 健康门的进程内形态)。
|
|
85
|
+
* 计数口径注记:inFlightRuns 只计**在挂**执行体;热失效退役中仍有 in-flight 的
|
|
86
|
+
* runner 不计入(retiredRunners 只报个数)。P0c 接健康门时须先补退役侧计数,
|
|
87
|
+
* 否则会低估负载(见 arch/service-topology.md §5)。
|
|
88
|
+
*/
|
|
89
|
+
health(): Promise<RunBackendHealth>;
|
|
90
|
+
/** 全量回收(停机路径,fail-open) */
|
|
91
|
+
disposeAll(): void;
|
|
92
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* RunBackend — gateway ↔ run 侧契约缝(arch/service-topology.md §4)
|
|
3
|
+
*
|
|
4
|
+
* 语义边界(触发面/执行面分离,§5.4):
|
|
5
|
+
* - 触发面(AgentRuntime / TriggerSource / 准入政策)归 gateway;
|
|
6
|
+
* - 执行面(Runner 构建/执行/退役/会话锁)一律经本契约触达,gateway 不得直摸 Runner。
|
|
7
|
+
*
|
|
8
|
+
* 实现分期(§4 单实现决策):
|
|
9
|
+
* - P0a:InProcessRunBackend(gateway 包内,进程内脚手架,P0b 后删除);
|
|
10
|
+
* - P0b 起:RemoteRunBackend(进程间唯一实现)。
|
|
11
|
+
*
|
|
12
|
+
* P0b 迁移注记:compactSession 的函数型参数(compactStructural / summarize)已数据化
|
|
13
|
+
* 清偿(2026-11-10,解析入 engine RunHost)——控制面只传键,实现在 run 侧解析。
|
|
14
|
+
* 本契约禁止再引入函数型参数。
|
|
15
|
+
*/
|
|
16
|
+
export {};
|
|
@@ -0,0 +1,392 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Run 契约线上协议(arch/service-topology.md §4「P0b 落地形态」)。
|
|
3
|
+
*
|
|
4
|
+
* 两个通道,各司其职:
|
|
5
|
+
* - **契约通道**(gateway → run 实例,loopback HTTP):`POST /runs`(RunRequest →
|
|
6
|
+
* NDJSON `RunStreamEntry` 流)/ `POST /control`(`RunControlOp`)/ `GET /health`;
|
|
7
|
+
* - **宿主通知**(run 实例 → gateway,fork IPC):`RunHostNotify`——审批请求、
|
|
8
|
+
* 客户端工具调用、out-of-run 会话事件、inbox 重投等控制面推送。
|
|
9
|
+
*
|
|
10
|
+
* 纪律:本文件只放**可序列化**数据形状;函数型参数禁止上契约(P0a 债务已随
|
|
11
|
+
* compactSession 数据化清偿)。审批/工具事件直接复用 hooks 既有数据类型(单一来源)。
|
|
12
|
+
*/
|
|
13
|
+
import type { AgentEvent } from '@octopi-agent/core/primitives/event-bus.js';
|
|
14
|
+
import type { Message, ToolDefinition, ToolSource } from '@octopi-agent/core/types.js';
|
|
15
|
+
import type { Trigger } from './types.js';
|
|
16
|
+
import type { CommandDefinition } from '../extension/plugin-ecosystem/commands/types.js';
|
|
17
|
+
import type { HitlAskResult } from '../governance/human-in-the-loop/decision-cache.js';
|
|
18
|
+
/** 线上错误形状(两形态错误表面的传输载体:同步抛 = HTTP 4xx/5xx body;闸门拒 = 流内 error entry) */
|
|
19
|
+
export interface RunWireError {
|
|
20
|
+
message: string;
|
|
21
|
+
name?: string;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* `POST /runs` 响应流(NDJSON,逐行一个 entry):
|
|
25
|
+
* 事件流若干 `{type:'event'}`,然后恰好一个终态 `done` 或 `error`。
|
|
26
|
+
* 流内 error = 异步错误表面(准入闸门拒等);未装载等同步错误不进流,直接 HTTP 4xx。
|
|
27
|
+
*/
|
|
28
|
+
export type RunStreamEntry = {
|
|
29
|
+
type: 'event';
|
|
30
|
+
event: AgentEvent;
|
|
31
|
+
} | {
|
|
32
|
+
type: 'done';
|
|
33
|
+
} | {
|
|
34
|
+
type: 'error';
|
|
35
|
+
error: RunWireError;
|
|
36
|
+
};
|
|
37
|
+
/** 客户端工具注册的线上形状(handler 不可传输;由 run 侧桥接实现承接) */
|
|
38
|
+
export interface ClientToolWireSpec {
|
|
39
|
+
definition: ToolDefinition;
|
|
40
|
+
source?: ToolSource;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* 客户端工具可见性快照(`createVisibilityFilter` 谓词的数据化):
|
|
44
|
+
* gateway 在注册表变化时推送 + 周期 diff 刷(TTL 过期是「心跳缺失」——缺因态没有
|
|
45
|
+
* 事件可挂,生产者只能是时间刷),run 侧本地求值(stale 窗口 = 推送间隔,已声明收敛)。
|
|
46
|
+
*/
|
|
47
|
+
export interface ClientToolVisibilitySnapshot {
|
|
48
|
+
/** ClientToolHost 已安装的客户端工具名(累积:网关生命周期内不卸载,保证工具面恒定) */
|
|
49
|
+
installed: string[];
|
|
50
|
+
/**
|
|
51
|
+
* 当前有 live provider 的 (session, tool) 对——**仅用于调用期 liveness 校验**。
|
|
52
|
+
* 不参与工具面过滤:liveness 抖动不得改变 LLM 可见的 tools schema
|
|
53
|
+
* (tools 在缓存前缀最前,任何增删都会让整段历史前缀失效)。
|
|
54
|
+
*/
|
|
55
|
+
live: Array<{
|
|
56
|
+
sessionId: string;
|
|
57
|
+
toolName: string;
|
|
58
|
+
}>;
|
|
59
|
+
/**
|
|
60
|
+
* 会话内「曾经 live 过」的 (session, tool) 对——**工具面粘滞依据**(方案 A)。
|
|
61
|
+
* 一旦某会话见过某客户端工具,该会话生命周期内它始终保持可见;
|
|
62
|
+
* 客户端不可用时由调用期返回 `client_unavailable`(响亮失败、可重试),
|
|
63
|
+
* 而不是把工具从 schema 里摘掉。
|
|
64
|
+
* 缺省(旧网关)= 回落 `live`。
|
|
65
|
+
*/
|
|
66
|
+
everLive?: Array<{
|
|
67
|
+
sessionId: string;
|
|
68
|
+
toolName: string;
|
|
69
|
+
}>;
|
|
70
|
+
/**
|
|
71
|
+
* 快照有效期(epoch ms):**只约束调用期 liveness 判定的可信度**。
|
|
72
|
+
* 过期 ≠ 工具面收缩(那会烧前缀);过期时调用期检查退化为「照常派发」,
|
|
73
|
+
* 由调用自身 TTL 兜底。
|
|
74
|
+
*/
|
|
75
|
+
expiresAt: number;
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* run lease 冲突标记(`supervise: lease_held` 错误文案的判据锚):产生点在
|
|
79
|
+
* FleetRunBackend.startRun(yield* 之前,消息未入上下文);消费点在
|
|
80
|
+
* AgentRuntime.finalizeDelivery 的唤醒重投判定。两端同源此常量,防字符串
|
|
81
|
+
* 跨包漂移。
|
|
82
|
+
*/
|
|
83
|
+
export declare const RUN_LEASE_HELD_MARKER = "lease_held";
|
|
84
|
+
/**
|
|
85
|
+
* 会话级控制 op(纯数据)。对应契约 `control(op)`:
|
|
86
|
+
* 每个 op 都有对应的 run 侧执行语义(RunHost.handleControl)。
|
|
87
|
+
*/
|
|
88
|
+
export type RunControlOp =
|
|
89
|
+
/** 中止会话在途 run(不丢内容;对应 run 侧 AbortController 集合) */
|
|
90
|
+
{
|
|
91
|
+
type: 'abort';
|
|
92
|
+
sessionId: string;
|
|
93
|
+
reason?: string;
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* 会话消息追加(schedule 通知投递等控制面写路径;写者单点 = run 节点,§3)。
|
|
97
|
+
* 执行:sessionLock → load → push → save(与 Runner.handle 共锁,防漂移整包抹除)。
|
|
98
|
+
*/
|
|
99
|
+
| {
|
|
100
|
+
type: 'sessionAppendMessage';
|
|
101
|
+
sessionId: string;
|
|
102
|
+
message: Message;
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* 截断会话消息(编辑重发/丢弃的唯一入口)。执行含本轮校验(仅最后一轮中止)、
|
|
106
|
+
* 租约下标收缩、abortedTurn 清理与本轮文件效应逆放(用户手改保留)。
|
|
107
|
+
*/
|
|
108
|
+
| {
|
|
109
|
+
type: 'truncateMessagesFrom';
|
|
110
|
+
sessionId: string;
|
|
111
|
+
fromIndex: number;
|
|
112
|
+
}
|
|
113
|
+
/** 审批回执(答复 RunHostNotify.approval_request;HitlAskResult 为既有数据形状) */
|
|
114
|
+
| {
|
|
115
|
+
type: 'approvalReply';
|
|
116
|
+
approvalId: string;
|
|
117
|
+
result: HitlAskResult;
|
|
118
|
+
}
|
|
119
|
+
/** 客户端工具结果回传(答复 RunHostNotify.client_tool_call) */
|
|
120
|
+
| {
|
|
121
|
+
type: 'clientToolResult';
|
|
122
|
+
callId: string;
|
|
123
|
+
outcome: {
|
|
124
|
+
ok: true;
|
|
125
|
+
result: unknown;
|
|
126
|
+
} | {
|
|
127
|
+
ok: false;
|
|
128
|
+
error: RunWireError;
|
|
129
|
+
};
|
|
130
|
+
}
|
|
131
|
+
/** ask_user 作答回传(答复 RunHostNotify.ask_user_request;失败拒接让工具 fail-loud) */
|
|
132
|
+
| {
|
|
133
|
+
type: 'askUserReply';
|
|
134
|
+
askId: string;
|
|
135
|
+
outcome: {
|
|
136
|
+
ok: true;
|
|
137
|
+
answer: string;
|
|
138
|
+
} | {
|
|
139
|
+
ok: false;
|
|
140
|
+
error: RunWireError;
|
|
141
|
+
};
|
|
142
|
+
}
|
|
143
|
+
/**
|
|
144
|
+
* 会话压缩。**纯数据**:systemPrompt/tools/摘要模型绑定等全部由 run 侧从自身
|
|
145
|
+
* 状态解析(P0a 迁移注记的清偿形态);控制面只传键。
|
|
146
|
+
*/
|
|
147
|
+
| {
|
|
148
|
+
type: 'compact';
|
|
149
|
+
sessionId: string;
|
|
150
|
+
agentId: string;
|
|
151
|
+
}
|
|
152
|
+
/** 热重建:新 AgentDefinition 数据下发,run 侧重建执行体(旧体退役判据不变) */
|
|
153
|
+
| {
|
|
154
|
+
type: 'reloadAgent';
|
|
155
|
+
agentId: string;
|
|
156
|
+
definition: AgentDefinitionWire;
|
|
157
|
+
}
|
|
158
|
+
/** 退役执行体(removeAgent) */
|
|
159
|
+
| {
|
|
160
|
+
type: 'retireAgent';
|
|
161
|
+
agentId: string;
|
|
162
|
+
}
|
|
163
|
+
/**
|
|
164
|
+
* provider 热重建(评审 B4 深层:run worker 是独立进程,boot 拿 config 快照——
|
|
165
|
+
* gateway 热应用后 worker 的 provider 表过期,startRun 409 "provider not found")。
|
|
166
|
+
* 执行:按快照全量重建 provider 表。
|
|
167
|
+
*/
|
|
168
|
+
| {
|
|
169
|
+
type: 'reloadProviders';
|
|
170
|
+
modelProviders: Record<string, unknown>;
|
|
171
|
+
}
|
|
172
|
+
/** 动态客户端工具同步(E5 语义:add/remove + 可见性快照) */
|
|
173
|
+
| {
|
|
174
|
+
type: 'setClientTools';
|
|
175
|
+
ops: Array<{
|
|
176
|
+
op: 'add';
|
|
177
|
+
tool: ClientToolWireSpec;
|
|
178
|
+
} | {
|
|
179
|
+
op: 'remove';
|
|
180
|
+
name: string;
|
|
181
|
+
}>;
|
|
182
|
+
visibility: ClientToolVisibilitySnapshot;
|
|
183
|
+
}
|
|
184
|
+
/** 知识运行时状态同步(准入闸门输入;状态是 gateway 运行时已知值,非实时探测) */
|
|
185
|
+
| {
|
|
186
|
+
type: 'syncKnowledgeState';
|
|
187
|
+
state: KnowledgeStateWire;
|
|
188
|
+
}
|
|
189
|
+
/**
|
|
190
|
+
* inbox 插话 offer(跨进程形态,协调面「插话」原语):把接续消息 offer 给目标
|
|
191
|
+
* agent 在 run 实例内的 SessionInbox。语义与本地 offer 一致——活跃 Run 接收
|
|
192
|
+
* (`continued`)则由它在下一个合法消息边界消费;未接收(`dispatched`)由
|
|
193
|
+
* 调用方照常 dispatch 新 Run;`duplicate` 为 entryId 去重命中。回调字段不
|
|
194
|
+
* 过线(onEvent/onAdmitted 归本地调用方),wire 只带纯数据。
|
|
195
|
+
*/
|
|
196
|
+
| {
|
|
197
|
+
type: 'inboxOffer';
|
|
198
|
+
agentId: string;
|
|
199
|
+
sessionId: string;
|
|
200
|
+
/** trigger.id / delegationId 去重键 */
|
|
201
|
+
entryId?: string;
|
|
202
|
+
human?: boolean;
|
|
203
|
+
triggerType?: string;
|
|
204
|
+
modelOverride?: string;
|
|
205
|
+
modelProvider?: string;
|
|
206
|
+
message: Message;
|
|
207
|
+
/** 原 Trigger(Run 关闭未消费时 run 侧按它 redispatch) */
|
|
208
|
+
trigger?: Trigger;
|
|
209
|
+
}
|
|
210
|
+
/** 七层上下文健康探针 */
|
|
211
|
+
| {
|
|
212
|
+
type: 'contextHealth';
|
|
213
|
+
agentId?: string;
|
|
214
|
+
}
|
|
215
|
+
/**
|
|
216
|
+
* console 受控写后重锚定安全指纹(ops P2 §8.4)。boot 纯数据无法携带活守卫,
|
|
217
|
+
* run 实例自建 guard 后由宿主经此 op 同步署名(service-topology §7.3)。
|
|
218
|
+
*/
|
|
219
|
+
| {
|
|
220
|
+
type: 'reattestSecurity';
|
|
221
|
+
expectHash: string;
|
|
222
|
+
allowedChanged: string[];
|
|
223
|
+
}
|
|
224
|
+
/**
|
|
225
|
+
* 脉搏(P0c 脉搏单源,arch/service-topology-p0c.md §3 方案 A′):gateway 脉搏调度器
|
|
226
|
+
* 单发,副本收到后跑一次声明式 tick(原 self-arm 定时器的驱动源)。key 是实例自述的
|
|
227
|
+
* `PulseSpec.key`(opaque,gateway 不解释产品语义)。
|
|
228
|
+
*/
|
|
229
|
+
| {
|
|
230
|
+
type: 'pulse';
|
|
231
|
+
key: string;
|
|
232
|
+
};
|
|
233
|
+
/**
|
|
234
|
+
* 脉搏声明(P0c A′):run 实例装配后自述「我有哪些周期任务」,gateway 单发驱动。
|
|
235
|
+
* key 在实例内全局唯一(`<agentId>:<base>` 形态,产品语义不进 gateway)。
|
|
236
|
+
*/
|
|
237
|
+
export interface PulseSpec {
|
|
238
|
+
/** 实例内唯一脉搏键(opaque) */
|
|
239
|
+
key: string;
|
|
240
|
+
/** 周期(毫秒) */
|
|
241
|
+
intervalMs: number;
|
|
242
|
+
/** 归属 agent(诊断用) */
|
|
243
|
+
agentId?: string;
|
|
244
|
+
/** 首次收集后立即发一跳(替代原 runOnStart 自跳) */
|
|
245
|
+
runOnStart?: boolean;
|
|
246
|
+
/** 首跳延迟(毫秒)——多子系统按数据流依赖序错峰(govern 先于下游巩固/归因跑完) */
|
|
247
|
+
startupDelayMs?: number;
|
|
248
|
+
}
|
|
249
|
+
/**
|
|
250
|
+
* 冒烟报告(健康门 §4.3)——`POST /smoke` 独立通道的应答(**不是 run,不占 run 语义**)。
|
|
251
|
+
* 逐 agent 装配热路径自检:工具面枚举 + 一次 no-LLM 应答(contextHealth)。
|
|
252
|
+
*/
|
|
253
|
+
export interface RunSmokeReport {
|
|
254
|
+
ok: boolean;
|
|
255
|
+
/**
|
|
256
|
+
* 该构建无冒烟端点(跨版本:pre-v0.108.2)——消费方降级为 health+guard 判定(MAJ-3),
|
|
257
|
+
* 不得当作冒烟失败挡回滚。
|
|
258
|
+
*/
|
|
259
|
+
unavailable?: boolean;
|
|
260
|
+
agents: Array<{
|
|
261
|
+
agentId: string;
|
|
262
|
+
toolCount: number;
|
|
263
|
+
checks: Array<{
|
|
264
|
+
name: string;
|
|
265
|
+
ok: boolean;
|
|
266
|
+
detail?: string;
|
|
267
|
+
}>;
|
|
268
|
+
}>;
|
|
269
|
+
}
|
|
270
|
+
/** AgentDefinition 线上传输别名(config-schema 数据对象,见 src/config-schema) */
|
|
271
|
+
export type AgentDefinitionWire = Record<string, unknown>;
|
|
272
|
+
/** 知识运行时状态(与 gateway KnowledgeRuntimeState 同枚举;线上自包含) */
|
|
273
|
+
export type KnowledgeStateWire = 'starting' | 'disabled' | 'ready' | 'degraded';
|
|
274
|
+
/** control 响应:成功(result 形状随 op)或失败(不得静默吞,见契约错误表面) */
|
|
275
|
+
export type RunControlResponse = {
|
|
276
|
+
ok: true;
|
|
277
|
+
result?: unknown;
|
|
278
|
+
} | {
|
|
279
|
+
ok: false;
|
|
280
|
+
error: RunWireError;
|
|
281
|
+
};
|
|
282
|
+
/**
|
|
283
|
+
* 审批请求载荷(Gateway.requestApproval 同构的纯数据面;引擎侧自包含)。
|
|
284
|
+
* 插件工具审批(HookToolEvent/HookToolApproval)经 toolApprovalToRequestInput 归一到此形。
|
|
285
|
+
*/
|
|
286
|
+
export interface RunApprovalRequestInput {
|
|
287
|
+
sessionId: string;
|
|
288
|
+
agentId: string;
|
|
289
|
+
request: {
|
|
290
|
+
kind: 'high_risk' | 'effect';
|
|
291
|
+
toolName: string;
|
|
292
|
+
arguments: Record<string, unknown>;
|
|
293
|
+
riskLevel: 'low' | 'medium' | 'high' | 'critical' | 'unknown';
|
|
294
|
+
riskDescription: string;
|
|
295
|
+
actionDescription: string;
|
|
296
|
+
};
|
|
297
|
+
timeoutMs?: number;
|
|
298
|
+
}
|
|
299
|
+
/**
|
|
300
|
+
* run 实例进程向 gateway 的控制面推送。审批请求走这里而非 run 流:
|
|
301
|
+
* 工具审批可发生在任意执行上下文,且请求/回执是跨通道配对(notify 出、control 回)。
|
|
302
|
+
*/
|
|
303
|
+
export type RunHostNotify =
|
|
304
|
+
/** 审批请求(gateway 挂 UI 通道;回执走 control 'approvalReply') */
|
|
305
|
+
{
|
|
306
|
+
type: 'approval_request';
|
|
307
|
+
approvalId: string;
|
|
308
|
+
input: RunApprovalRequestInput;
|
|
309
|
+
}
|
|
310
|
+
/** 客户端工具调用(gateway 转发客户端执行;结果走 control 'clientToolResult') */
|
|
311
|
+
| {
|
|
312
|
+
type: 'client_tool_call';
|
|
313
|
+
callId: string;
|
|
314
|
+
sessionId: string;
|
|
315
|
+
agentId: string;
|
|
316
|
+
toolName: string;
|
|
317
|
+
args: Record<string, unknown>;
|
|
318
|
+
/**
|
|
319
|
+
* 调用时刻的 episode 消息列表(ToolExecutionContext.messages 的跨进程还原)。
|
|
320
|
+
* 随桥携带是有意的载荷成本:handler 契约承诺真实 messages,禁以空数组冒充。
|
|
321
|
+
*/
|
|
322
|
+
messages: Message[];
|
|
323
|
+
}
|
|
324
|
+
/**
|
|
325
|
+
* 客户端工具调用取消(run 侧中止信号触发)。gateway 据此中止该 callId 的
|
|
326
|
+
* 执行腿(per-call AbortSignal),否则 pending 会挂到 TTL 过期——覆盖不经
|
|
327
|
+
* `abortSession()` 的中止路径(runGuard/budget/引擎内中止等)。
|
|
328
|
+
*/
|
|
329
|
+
| {
|
|
330
|
+
type: 'client_tool_cancel';
|
|
331
|
+
callId: string;
|
|
332
|
+
reason?: string;
|
|
333
|
+
}
|
|
334
|
+
/** out-of-run 会话事件(compact 进度、ClientToolHost 会话事件等;gateway 转 WS/store) */
|
|
335
|
+
| {
|
|
336
|
+
type: 'session_event';
|
|
337
|
+
sessionId: string;
|
|
338
|
+
event: AgentEvent;
|
|
339
|
+
}
|
|
340
|
+
/** inbox 未消费项的原 Trigger 重投(原 registerRuntimeAgent.redispatch 的远程形态) */
|
|
341
|
+
| {
|
|
342
|
+
type: 'redispatch';
|
|
343
|
+
trigger: Trigger;
|
|
344
|
+
}
|
|
345
|
+
/** ask_user 提问(gateway 挂 pending question 等 UI 作答;回执走 control 'askUserReply') */
|
|
346
|
+
| {
|
|
347
|
+
type: 'ask_user_request';
|
|
348
|
+
askId: string;
|
|
349
|
+
sessionId: string;
|
|
350
|
+
agentId: string;
|
|
351
|
+
question: string;
|
|
352
|
+
options?: string[];
|
|
353
|
+
}
|
|
354
|
+
/** 命令注册(skill/用户命令发现结果,数据下发;gateway 注册 UI 命令面) */
|
|
355
|
+
| {
|
|
356
|
+
type: 'commands_registered';
|
|
357
|
+
agentId: string;
|
|
358
|
+
commands: Array<{
|
|
359
|
+
definition: CommandDefinition;
|
|
360
|
+
ref: string;
|
|
361
|
+
}>;
|
|
362
|
+
}
|
|
363
|
+
/** run 侧日志转发(保 [Gateway] 前缀文案的运维 grep 面) */
|
|
364
|
+
| {
|
|
365
|
+
type: 'log';
|
|
366
|
+
level: 'log' | 'warn' | 'error';
|
|
367
|
+
message: string;
|
|
368
|
+
}
|
|
369
|
+
/**
|
|
370
|
+
* 会话写入已落盘(P1-1 投影收口:检索投影单写者=gateway 门面,§3 表)。
|
|
371
|
+
* run 节点直写会话文件后发此通知(载荷只有 id),gateway 侧节流补投影;
|
|
372
|
+
* 投影可重建非权威(I2),通知丢失仅滞后检索,由 rebuild 兜底。
|
|
373
|
+
*/
|
|
374
|
+
| {
|
|
375
|
+
type: 'session_saved';
|
|
376
|
+
sessionId: string;
|
|
377
|
+
}
|
|
378
|
+
/** 会话删除已落盘(同上收口:gateway 门面据此删投影行) */
|
|
379
|
+
| {
|
|
380
|
+
type: 'session_removed';
|
|
381
|
+
sessionId: string;
|
|
382
|
+
}
|
|
383
|
+
/**
|
|
384
|
+
* run 终态事件归档(P1-3b,Q3=(a):随会话 jsonl 旁路、门面写):Hub 导出槽
|
|
385
|
+
* timeline 上行,gateway 落 `<sid>.events.jsonl`(历史回放面)。事件为纯数据
|
|
386
|
+
* (RunTimelineEventView 打平,不含引擎类型)。
|
|
387
|
+
*/
|
|
388
|
+
| {
|
|
389
|
+
type: 'run_events_archived';
|
|
390
|
+
sessionId: string;
|
|
391
|
+
events: Array<Record<string, unknown>>;
|
|
392
|
+
};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Run 契约线上协议(arch/service-topology.md §4「P0b 落地形态」)。
|
|
3
|
+
*
|
|
4
|
+
* 两个通道,各司其职:
|
|
5
|
+
* - **契约通道**(gateway → run 实例,loopback HTTP):`POST /runs`(RunRequest →
|
|
6
|
+
* NDJSON `RunStreamEntry` 流)/ `POST /control`(`RunControlOp`)/ `GET /health`;
|
|
7
|
+
* - **宿主通知**(run 实例 → gateway,fork IPC):`RunHostNotify`——审批请求、
|
|
8
|
+
* 客户端工具调用、out-of-run 会话事件、inbox 重投等控制面推送。
|
|
9
|
+
*
|
|
10
|
+
* 纪律:本文件只放**可序列化**数据形状;函数型参数禁止上契约(P0a 债务已随
|
|
11
|
+
* compactSession 数据化清偿)。审批/工具事件直接复用 hooks 既有数据类型(单一来源)。
|
|
12
|
+
*/
|
|
13
|
+
/**
|
|
14
|
+
* run lease 冲突标记(`supervise: lease_held` 错误文案的判据锚):产生点在
|
|
15
|
+
* FleetRunBackend.startRun(yield* 之前,消息未入上下文);消费点在
|
|
16
|
+
* AgentRuntime.finalizeDelivery 的唤醒重投判定。两端同源此常量,防字符串
|
|
17
|
+
* 跨包漂移。
|
|
18
|
+
*/
|
|
19
|
+
export const RUN_LEASE_HELD_MARKER = 'lease_held';
|