@octopi-agent/engine 0.65.0 → 0.86.38
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/LICENSE +201 -201
- package/NOTICE +7 -7
- package/README.md +64 -26
- package/dist/config-schema/agent.d.ts +89 -1
- package/dist/config-schema/agent.js +69 -0
- package/dist/config-schema/context.d.ts +23 -4
- package/dist/config-schema/context.js +28 -1
- package/dist/config-schema/engine.d.ts +285 -9
- package/dist/config-schema/engine.js +35 -3
- package/dist/config-schema/governance.d.ts +95 -0
- package/dist/config-schema/governance.js +91 -0
- package/dist/config-schema/models.d.ts +1 -1
- package/dist/config-schema/observability.d.ts +6 -0
- package/dist/config-schema/observability.js +16 -0
- package/dist/config-schema/run.d.ts +10 -0
- package/dist/config-schema/run.js +18 -0
- package/dist/config-schema/shared.d.ts +10 -0
- package/dist/config-schema/shared.js +10 -0
- package/dist/config-schema/substrate.d.ts +87 -1
- package/dist/config-schema/substrate.js +114 -0
- package/dist/config-schema/subsystems.d.ts +1 -1
- package/dist/config-schema/subsystems.js +2 -1
- package/dist/config.d.ts +249 -7
- package/dist/config.js +113 -3
- package/dist/harness/activation/compiler.js +3 -0
- package/dist/harness/activation/runtime.d.ts +7 -0
- package/dist/harness/activation/runtime.js +60 -2
- package/dist/harness/activation/sources/agent-signal.d.ts +11 -0
- package/dist/harness/activation/sources/agent-signal.js +33 -0
- package/dist/harness/activation/types.d.ts +6 -1
- package/dist/harness/agent/builder.d.ts +48 -4
- package/dist/harness/agent/builder.js +206 -55
- package/dist/harness/agent/config-bridge.d.ts +33 -25
- package/dist/harness/agent/config-bridge.js +83 -280
- package/dist/harness/agent/index.d.ts +3 -1
- package/dist/harness/agent/index.js +2 -1
- package/dist/harness/agent/tool-purpose.d.ts +38 -0
- package/dist/harness/agent/tool-purpose.js +118 -0
- package/dist/harness/agent/wire-agent-builder.d.ts +133 -0
- package/dist/harness/agent/wire-agent-builder.js +363 -0
- package/dist/harness/collaboration/autonomous-subsystem/runtime.d.ts +4 -1
- package/dist/harness/collaboration/autonomous-subsystem/runtime.js +14 -8
- package/dist/harness/collaboration/autonomous-subsystem/sense/metrics.d.ts +12 -0
- package/dist/harness/collaboration/autonomous-subsystem/sense/metrics.js +19 -0
- package/dist/harness/collaboration/autonomous-subsystem/sense/session-lifecycle-bridge.d.ts +6 -0
- package/dist/harness/collaboration/autonomous-subsystem/sense/session-lifecycle-bridge.js +24 -7
- package/dist/harness/collaboration/autonomous-subsystem/think/executor.d.ts +5 -2
- package/dist/harness/collaboration/autonomous-subsystem/think/executor.js +11 -3
- package/dist/harness/collaboration/autonomous-subsystem/think/index.d.ts +1 -1
- package/dist/harness/collaboration/autonomous-subsystem/think/index.js +1 -1
- package/dist/harness/collaboration/autonomous-subsystem/think/llm-port.d.ts +7 -4
- package/dist/harness/collaboration/autonomous-subsystem/think/llm-port.js +8 -9
- package/dist/harness/collaboration/autonomous-subsystem/think/model-resolver.d.ts +36 -10
- package/dist/harness/collaboration/autonomous-subsystem/think/model-resolver.js +60 -7
- package/dist/harness/collaboration/delegation/child-run.d.ts +144 -0
- package/dist/harness/collaboration/delegation/child-run.js +241 -0
- package/dist/harness/collaboration/delegation/index.d.ts +26 -0
- package/dist/harness/collaboration/delegation/index.js +25 -0
- package/dist/harness/collaboration/delegation/notifier.d.ts +46 -0
- package/dist/harness/collaboration/delegation/notifier.js +84 -0
- package/dist/harness/collaboration/delegation/registry-types.d.ts +200 -0
- package/dist/harness/collaboration/delegation/registry-types.js +61 -0
- package/dist/harness/collaboration/delegation/registry.d.ts +110 -0
- package/dist/harness/collaboration/delegation/registry.js +220 -0
- package/dist/harness/collaboration/delegation/service.d.ts +249 -0
- package/dist/harness/collaboration/delegation/service.js +499 -0
- package/dist/harness/collaboration/delegation/store.d.ts +155 -0
- package/dist/harness/collaboration/delegation/store.js +271 -0
- package/dist/harness/collaboration/delegation/transport.d.ts +73 -0
- package/dist/harness/collaboration/delegation/transport.js +61 -0
- package/dist/harness/collaboration/delegation/types.d.ts +231 -0
- package/dist/harness/collaboration/delegation/types.js +70 -0
- package/dist/harness/collaboration/delegation/wiring.d.ts +111 -0
- package/dist/harness/collaboration/delegation/wiring.js +145 -0
- package/dist/harness/collaboration/orchestration/index.d.ts +11 -13
- package/dist/harness/collaboration/orchestration/index.js +11 -11
- package/dist/harness/context/assembler.d.ts +2 -2
- package/dist/harness/context/assembler.js +12 -7
- package/dist/harness/context/capabilities/compact/engine.js +80 -38
- package/dist/harness/context/capabilities/compact/types.d.ts +12 -1
- package/dist/harness/context/capabilities/summary/gate.js +2 -2
- package/dist/harness/context/capabilities/summary/policies.js +5 -5
- package/dist/harness/context/capabilities/summary/registry.js +39 -24
- package/dist/harness/context/constitution/default-agents.md +230 -228
- package/dist/harness/context/default-context-engine.d.ts +101 -23
- package/dist/harness/context/default-context-engine.js +483 -172
- package/dist/harness/context/hybrid-compressor.d.ts +3 -3
- package/dist/harness/context/hybrid-compressor.js +18 -23
- package/dist/harness/context/index.d.ts +5 -1
- package/dist/harness/context/index.js +2 -0
- package/dist/harness/context/layer-health.js +3 -2
- package/dist/harness/context/layer-snapshot.d.ts +4 -0
- package/dist/harness/context/layer-snapshot.js +30 -18
- package/dist/harness/context/layer-types.d.ts +49 -1
- package/dist/harness/context/layer-types.js +72 -4
- package/dist/harness/context/layers.d.ts +32 -15
- package/dist/harness/context/layers.js +87 -71
- package/dist/harness/context/llm-summarizer.d.ts +15 -1
- package/dist/harness/context/llm-summarizer.js +107 -56
- package/dist/harness/context/message-selector.js +6 -2
- package/dist/harness/context/root-instructions.d.ts +72 -0
- package/dist/harness/context/root-instructions.js +227 -0
- package/dist/harness/context/runtime-datetime.d.ts +34 -7
- package/dist/harness/context/runtime-datetime.js +66 -10
- package/dist/harness/context/smart-router.d.ts +1 -1
- package/dist/harness/context/smart-router.js +1 -1
- package/dist/harness/context/system-prompt-assembler.d.ts +33 -0
- package/dist/harness/context/system-prompt-assembler.js +78 -7
- package/dist/harness/context/token-constants.d.ts +2 -2
- package/dist/harness/context/token-constants.js +2 -2
- package/dist/harness/context/token-estimate-fns.d.ts +1 -3
- package/dist/harness/context/token-estimate-fns.js +2 -4
- package/dist/harness/context/token-estimator.d.ts +1 -1
- package/dist/harness/context/token-estimator.js +14 -6
- package/dist/harness/context/tool-result-aging.d.ts +140 -0
- package/dist/harness/context/tool-result-aging.js +331 -0
- package/dist/harness/context/tool-result-body.d.ts +10 -0
- package/dist/harness/context/tool-result-body.js +27 -0
- package/dist/harness/context/turn-envelope.d.ts +123 -0
- package/dist/harness/context/turn-envelope.js +188 -0
- package/dist/harness/context/types.d.ts +35 -47
- package/dist/harness/extension/execution-environment/effect-policy.d.ts +248 -0
- package/dist/harness/extension/execution-environment/effect-policy.js +334 -0
- package/dist/harness/extension/execution-environment/index.d.ts +18 -2
- package/dist/harness/extension/execution-environment/index.js +11 -2
- package/dist/harness/extension/execution-environment/memory-undo.d.ts +101 -0
- package/dist/harness/extension/execution-environment/memory-undo.js +192 -0
- package/dist/harness/extension/execution-environment/process-isolation.d.ts +84 -0
- package/dist/harness/extension/execution-environment/process-isolation.js +315 -0
- package/dist/harness/extension/execution-environment/resource-limits.d.ts +36 -0
- package/dist/harness/extension/execution-environment/resource-limits.js +84 -0
- package/dist/harness/extension/execution-environment/sandbox.d.ts +125 -4
- package/dist/harness/extension/execution-environment/sandbox.js +493 -51
- package/dist/harness/extension/execution-environment/shell-journal.d.ts +100 -0
- package/dist/harness/extension/execution-environment/shell-journal.js +299 -0
- package/dist/harness/extension/execution-environment/tool-capabilities.d.ts +45 -0
- package/dist/harness/extension/execution-environment/tool-capabilities.js +126 -0
- package/dist/harness/extension/execution-environment/types.d.ts +67 -39
- package/dist/harness/extension/execution-environment/types.js +2 -2
- package/dist/harness/extension/execution-environment/undo-log.d.ts +203 -0
- package/dist/harness/extension/execution-environment/undo-log.js +627 -0
- package/dist/harness/extension/execution-environment/undo-merge.d.ts +40 -0
- package/dist/harness/extension/execution-environment/undo-merge.js +167 -0
- package/dist/harness/extension/plugin-ecosystem/client-tools/index.d.ts +4 -0
- package/dist/harness/extension/plugin-ecosystem/client-tools/index.js +3 -0
- package/dist/harness/extension/plugin-ecosystem/client-tools/invoke.d.ts +56 -0
- package/dist/harness/extension/plugin-ecosystem/client-tools/invoke.js +281 -0
- package/dist/harness/extension/plugin-ecosystem/client-tools/registry.d.ts +98 -0
- package/dist/harness/extension/plugin-ecosystem/client-tools/registry.js +250 -0
- package/dist/harness/extension/plugin-ecosystem/client-tools/stream.d.ts +124 -0
- package/dist/harness/extension/plugin-ecosystem/client-tools/stream.js +372 -0
- package/dist/harness/extension/plugin-ecosystem/client-tools/types.d.ts +118 -0
- package/dist/harness/extension/plugin-ecosystem/client-tools/types.js +8 -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/mcp/bridge.js +2 -0
- package/dist/harness/extension/plugin-ecosystem/plugins/api.d.ts +1 -6
- package/dist/harness/extension/plugin-ecosystem/plugins/api.js +3 -8
- package/dist/harness/extension/plugin-ecosystem/plugins/capability.d.ts +0 -3
- package/dist/harness/extension/plugin-ecosystem/plugins/capability.js +0 -3
- package/dist/harness/extension/plugin-ecosystem/plugins/entry.d.ts +2 -10
- package/dist/harness/extension/plugin-ecosystem/plugins/entry.js +2 -9
- package/dist/harness/extension/plugin-ecosystem/plugins/index.d.ts +1 -3
- package/dist/harness/extension/plugin-ecosystem/plugins/index.js +1 -3
- package/dist/harness/extension/plugin-ecosystem/plugins/loader.d.ts +2 -4
- package/dist/harness/extension/plugin-ecosystem/plugins/loader.js +4 -21
- package/dist/harness/extension/plugin-ecosystem/plugins/manager.d.ts +3 -9
- package/dist/harness/extension/plugin-ecosystem/plugins/manager.js +4 -8
- package/dist/harness/extension/plugin-ecosystem/plugins/manifest.d.ts +1 -4
- package/dist/harness/extension/plugin-ecosystem/plugins/manifest.js +1 -3
- package/dist/harness/extension/plugin-ecosystem/skills/manager.d.ts +1 -1
- package/dist/harness/extension/plugin-ecosystem/skills/manager.js +1 -1
- package/dist/harness/extension/plugin-ecosystem/tools/allowlisted-run.d.ts +45 -0
- package/dist/harness/extension/plugin-ecosystem/tools/allowlisted-run.js +136 -0
- package/dist/harness/extension/plugin-ecosystem/tools/ask-user.js +1 -0
- package/dist/harness/extension/plugin-ecosystem/tools/builtin.d.ts +18 -3
- package/dist/harness/extension/plugin-ecosystem/tools/builtin.js +278 -82
- package/dist/harness/extension/plugin-ecosystem/tools/delegation.d.ts +31 -0
- package/dist/harness/extension/plugin-ecosystem/tools/delegation.js +291 -0
- package/dist/harness/extension/plugin-ecosystem/tools/document-tools.js +10 -2
- package/dist/harness/extension/plugin-ecosystem/tools/env-info.js +1 -0
- package/dist/harness/extension/plugin-ecosystem/tools/eol.d.ts +35 -0
- package/dist/harness/extension/plugin-ecosystem/tools/eol.js +43 -0
- package/dist/harness/extension/plugin-ecosystem/tools/file-edit.js +40 -9
- package/dist/harness/extension/plugin-ecosystem/tools/file-ops.d.ts +33 -0
- package/dist/harness/extension/plugin-ecosystem/tools/file-ops.js +376 -0
- package/dist/harness/extension/plugin-ecosystem/tools/file-search.d.ts +12 -2
- package/dist/harness/extension/plugin-ecosystem/tools/file-search.js +239 -61
- package/dist/harness/extension/plugin-ecosystem/tools/git-tools.d.ts +27 -0
- package/dist/harness/extension/plugin-ecosystem/tools/git-tools.js +554 -0
- package/dist/harness/extension/plugin-ecosystem/tools/http.d.ts +10 -6
- package/dist/harness/extension/plugin-ecosystem/tools/http.js +41 -47
- package/dist/harness/extension/plugin-ecosystem/tools/index.d.ts +2 -0
- package/dist/harness/extension/plugin-ecosystem/tools/index.js +2 -0
- package/dist/harness/extension/plugin-ecosystem/tools/knowledge.js +4 -0
- package/dist/harness/extension/plugin-ecosystem/tools/memory.d.ts +11 -1
- package/dist/harness/extension/plugin-ecosystem/tools/memory.js +39 -1
- package/dist/harness/extension/plugin-ecosystem/tools/package-tools.d.ts +13 -0
- package/dist/harness/extension/plugin-ecosystem/tools/package-tools.js +391 -0
- package/dist/harness/extension/plugin-ecosystem/tools/platform.d.ts +51 -2
- package/dist/harness/extension/plugin-ecosystem/tools/platform.js +151 -12
- package/dist/harness/extension/plugin-ecosystem/tools/session-history.js +2 -0
- package/dist/harness/extension/plugin-ecosystem/tools/tool-bus.d.ts +10 -1
- package/dist/harness/extension/plugin-ecosystem/tools/tool-bus.js +35 -19
- package/dist/harness/extension/plugin-ecosystem/tools/tool-set.d.ts +8 -0
- package/dist/harness/extension/plugin-ecosystem/tools/tool-set.js +5 -0
- package/dist/harness/extension/plugin-ecosystem/tools/web-search.js +1 -0
- package/dist/harness/governance/credentials/index.d.ts +1 -1
- package/dist/harness/governance/credentials/store.d.ts +16 -4
- package/dist/harness/governance/credentials/store.js +33 -6
- package/dist/harness/governance/credentials/types.d.ts +11 -0
- package/dist/harness/governance/human-in-the-loop/decision-cache.d.ts +105 -0
- package/dist/harness/governance/human-in-the-loop/decision-cache.js +184 -0
- package/dist/harness/governance/human-in-the-loop/index.d.ts +5 -5
- package/dist/harness/governance/human-in-the-loop/index.js +3 -3
- package/dist/harness/governance/human-in-the-loop/types.d.ts +7 -62
- package/dist/harness/governance/human-in-the-loop/types.js +6 -2
- package/dist/harness/governance/security/capability-enforcer.d.ts +9 -1
- package/dist/harness/governance/security/capability-enforcer.js +31 -8
- package/dist/harness/governance/security/degradation.js +5 -7
- package/dist/harness/governance/security/risk-evaluator.d.ts +1 -1
- package/dist/harness/governance/security/risk-evaluator.js +4 -82
- package/dist/harness/governance/security/temp-path.d.ts +41 -0
- package/dist/harness/governance/security/temp-path.js +117 -0
- package/dist/harness/governance/session-acl/index.d.ts +1 -0
- package/dist/harness/governance/session-acl/index.js +1 -0
- package/dist/harness/governance/session-acl/rights.d.ts +12 -0
- package/dist/harness/governance/session-acl/rights.js +89 -7
- package/dist/harness/governance/session-acl/seed-roles.js +9 -1
- package/dist/harness/governance/session-acl/service.js +21 -29
- package/dist/harness/governance/session-acl/tool-rights.d.ts +81 -0
- package/dist/harness/governance/session-acl/tool-rights.js +238 -0
- package/dist/harness/governance/session-acl/types.d.ts +22 -0
- package/dist/harness/index.d.ts +18 -15
- package/dist/harness/index.js +11 -7
- package/dist/harness/knowledge/file-index-store.js +11 -11
- package/dist/harness/knowledge/grounding.d.ts +2 -1
- package/dist/harness/knowledge/grounding.js +6 -3
- package/dist/harness/knowledge/index.d.ts +2 -2
- package/dist/harness/knowledge/index.js +1 -1
- package/dist/harness/knowledge/ingest.js +4 -1
- package/dist/harness/knowledge/job-control-state.js +4 -4
- package/dist/harness/knowledge/job-control.js +11 -11
- package/dist/harness/knowledge/membership-store.js +11 -11
- package/dist/harness/knowledge/network-guard.d.ts +61 -4
- package/dist/harness/knowledge/network-guard.js +390 -113
- package/dist/harness/knowledge/query-service.js +8 -8
- package/dist/harness/knowledge/retriever.js +1 -1
- package/dist/harness/knowledge/source-store.d.ts +17 -2
- package/dist/harness/knowledge/source-store.js +6 -5
- package/dist/harness/knowledge/writer-service.d.ts +2 -0
- package/dist/harness/knowledge/writer-service.js +14 -13
- package/dist/harness/memory/backfill-trigger.d.ts +2 -2
- package/dist/harness/memory/backfill-trigger.js +4 -4
- package/dist/harness/memory/cognition-decay.d.ts +36 -0
- package/dist/harness/memory/cognition-decay.js +55 -0
- package/dist/harness/memory/cognition-gates.d.ts +60 -0
- package/dist/harness/memory/cognition-gates.js +191 -0
- package/dist/harness/memory/cognition-trigger.d.ts +30 -0
- package/dist/harness/memory/cognition-trigger.js +41 -0
- package/dist/harness/memory/cognition-types.d.ts +1 -1
- package/dist/harness/memory/cognition.d.ts +40 -8
- package/dist/harness/memory/cognition.js +432 -79
- package/dist/harness/memory/conceptualizer.d.ts +66 -0
- package/dist/harness/memory/conceptualizer.js +246 -0
- package/dist/harness/memory/index.d.ts +17 -2
- package/dist/harness/memory/index.js +12 -1
- package/dist/harness/memory/sqlite/agent-db.d.ts +9 -0
- package/dist/harness/memory/sqlite/agent-db.js +120 -15
- package/dist/harness/memory/sqlite/cognition-store.d.ts +55 -16
- package/dist/harness/memory/sqlite/cognition-store.js +591 -144
- package/dist/harness/memory/sqlite/memory-store.d.ts +1 -0
- package/dist/harness/memory/sqlite/memory-store.js +14 -4
- package/dist/harness/memory/sqlite/wisdom-store.d.ts +33 -14
- package/dist/harness/memory/sqlite/wisdom-store.js +257 -44
- package/dist/harness/memory/store.d.ts +1 -0
- package/dist/harness/memory/store.js +3 -0
- package/dist/harness/memory/time-format.d.ts +28 -0
- package/dist/harness/memory/time-format.js +52 -0
- package/dist/harness/memory/types.d.ts +343 -16
- package/dist/harness/memory/types.js +49 -0
- package/dist/harness/memory/wisdom-formation.d.ts +101 -0
- package/dist/harness/memory/wisdom-formation.js +304 -0
- package/dist/harness/memory/wisdom-gates.d.ts +50 -0
- package/dist/harness/memory/wisdom-gates.js +204 -0
- package/dist/harness/memory/wisdom-policy.d.ts +107 -0
- package/dist/harness/memory/wisdom-policy.js +220 -0
- package/dist/harness/memory/wisdom-types.d.ts +3 -2
- package/dist/harness/memory/wisdom-types.js +2 -2
- package/dist/harness/memory/wisdom.d.ts +27 -0
- package/dist/harness/memory/wisdom.js +181 -0
- package/dist/harness/observability/observer/hub.js +23 -1
- package/dist/harness/observability/observer/index.d.ts +2 -2
- package/dist/harness/observability/observer/index.js +1 -1
- package/dist/harness/observability/observer/types.d.ts +57 -0
- package/dist/harness/observability/observer/types.js +118 -9
- package/dist/harness/run/agent/agent.d.ts +27 -0
- package/dist/harness/run/agent/agent.js +45 -0
- package/dist/harness/run/concurrency/tool-loop-detection-core.d.ts +1 -1
- package/dist/harness/run/concurrency/tool-loop-detection-core.js +1 -1
- package/dist/harness/run/reliability/harness-events.d.ts +4 -0
- package/dist/harness/run/reliability/run-agent.js +116 -20
- package/dist/harness/run/reliability/run-metrics-collector.d.ts +28 -2
- package/dist/harness/run/reliability/run-metrics-collector.js +92 -2
- package/dist/harness/run/run-guard/default-run-guard.d.ts +0 -5
- package/dist/harness/run/run-guard/default-run-guard.js +104 -44
- package/dist/harness/run/run-scope.d.ts +52 -0
- package/dist/harness/run/runner.d.ts +101 -16
- package/dist/harness/run/runner.js +557 -158
- package/dist/harness/session/attachments/llm-intent.js +17 -17
- package/dist/harness/session/history/port.js +1 -0
- package/dist/harness/session/in-memory-store.d.ts +1 -0
- package/dist/harness/session/in-memory-store.js +22 -1
- package/dist/harness/session/index.d.ts +1 -0
- package/dist/harness/session/index.js +1 -0
- package/dist/harness/session/schedules/index.d.ts +10 -0
- package/dist/harness/session/schedules/index.js +10 -0
- package/dist/harness/session/schedules/render.d.ts +13 -0
- package/dist/harness/session/schedules/render.js +63 -0
- package/dist/harness/session/schedules/service.d.ts +179 -0
- package/dist/harness/session/schedules/service.js +695 -0
- package/dist/harness/session/schedules/store.d.ts +119 -0
- package/dist/harness/session/schedules/store.js +323 -0
- package/dist/harness/session/schedules/tools.d.ts +39 -0
- package/dist/harness/session/schedules/tools.js +442 -0
- package/dist/harness/session/schedules/types.d.ts +104 -0
- package/dist/harness/session/schedules/types.js +97 -0
- package/dist/harness/session/tasks/tools.js +22 -0
- package/dist/harness/session/title.d.ts +86 -0
- package/dist/harness/session/title.js +268 -0
- package/dist/harness/session/types.d.ts +35 -0
- package/dist/harness/shared/events/agent-event-map.d.ts +21 -0
- package/dist/harness/shared/events/agent-event-map.js +1 -0
- package/dist/harness/shared/types/agent-definition.d.ts +23 -0
- package/dist/index.d.ts +25 -9
- package/dist/index.js +11 -2
- package/dist/integration/providers/anthropic.d.ts +10 -0
- package/dist/integration/providers/anthropic.js +44 -1
- package/dist/integration/providers/openai.d.ts +10 -0
- package/dist/integration/providers/openai.js +58 -2
- package/dist/integration/providers/wire-dump-diff.d.ts +191 -0
- package/dist/integration/providers/wire-dump-diff.js +351 -0
- package/dist/integration/providers/wire-dump.d.ts +178 -0
- package/dist/integration/providers/wire-dump.js +396 -0
- package/dist/integration/storage/jsonl.d.ts +11 -0
- package/dist/integration/storage/jsonl.js +148 -39
- package/dist/integration/storage/session-index.js +63 -8
- package/dist/subsystems/cognition-steward/conceptualize/SUBSYSTEM.md +43 -0
- package/dist/subsystems/cognition-steward/conceptualize/config.yaml +50 -0
- package/dist/subsystems/cognition-steward/conceptualize/handler.d.ts +9 -0
- package/dist/subsystems/cognition-steward/conceptualize/handler.js +125 -0
- package/dist/subsystems/cognition-steward/consolidate/SUBSYSTEM.md +6 -0
- package/dist/subsystems/cognition-steward/consolidate/config.yaml +54 -0
- package/dist/subsystems/cognition-steward/consolidate/handler.d.ts +12 -0
- package/dist/subsystems/cognition-steward/consolidate/handler.js +93 -0
- package/dist/subsystems/memory-steward/backfill/handler.js +9 -0
- package/dist/subsystems/wisdom-steward/evaluate/config.yaml +50 -0
- package/dist/subsystems/wisdom-steward/evaluate/handler.d.ts +18 -0
- package/dist/subsystems/wisdom-steward/evaluate/handler.js +91 -0
- package/dist/subsystems/wisdom-steward/formation/SUBSYSTEM.md +42 -0
- package/dist/subsystems/wisdom-steward/formation/config.yaml +54 -0
- package/dist/subsystems/wisdom-steward/formation/handler.d.ts +18 -0
- package/dist/subsystems/wisdom-steward/formation/handler.js +212 -0
- package/dist/subsystems/wisdom-steward/govern/config.yaml +55 -0
- package/dist/subsystems/wisdom-steward/govern/handler.d.ts +17 -0
- package/dist/subsystems/wisdom-steward/govern/handler.js +68 -0
- package/package.json +115 -115
- package/dist/harness/collaboration/multi-agent/agent-registry-types.d.ts +0 -144
- package/dist/harness/collaboration/multi-agent/agent-registry-types.js +0 -25
- package/dist/harness/collaboration/multi-agent/index.d.ts +0 -17
- package/dist/harness/collaboration/multi-agent/index.js +0 -15
- package/dist/harness/collaboration/multi-agent/process.d.ts +0 -167
- package/dist/harness/collaboration/multi-agent/process.js +0 -256
- package/dist/harness/collaboration/multi-agent/registry.d.ts +0 -36
- package/dist/harness/collaboration/multi-agent/registry.js +0 -137
- package/dist/harness/collaboration/multi-agent/swarm.d.ts +0 -135
- package/dist/harness/collaboration/multi-agent/swarm.js +0 -317
- package/dist/harness/collaboration/multi-agent/types.d.ts +0 -66
- package/dist/harness/collaboration/multi-agent/types.js +0 -15
- package/dist/harness/collaboration/orchestration/async-task-store.d.ts +0 -107
- package/dist/harness/collaboration/orchestration/async-task-store.js +0 -12
- package/dist/harness/collaboration/orchestration/async-task.d.ts +0 -156
- package/dist/harness/collaboration/orchestration/async-task.js +0 -359
- package/dist/harness/collaboration/orchestration/planner/hybrid-planner.d.ts +0 -47
- package/dist/harness/collaboration/orchestration/planner/hybrid-planner.js +0 -61
- package/dist/harness/collaboration/orchestration/planner/index.d.ts +0 -9
- package/dist/harness/collaboration/orchestration/planner/index.js +0 -6
- package/dist/harness/collaboration/orchestration/planner/llm-planner.d.ts +0 -54
- package/dist/harness/collaboration/orchestration/planner/llm-planner.js +0 -167
- package/dist/harness/collaboration/orchestration/planner/rule-planner.d.ts +0 -85
- package/dist/harness/collaboration/orchestration/planner/rule-planner.js +0 -175
- package/dist/harness/collaboration/orchestration/quality/classifier.d.ts +0 -21
- package/dist/harness/collaboration/orchestration/quality/classifier.js +0 -235
- package/dist/harness/collaboration/orchestration/quality/gate.d.ts +0 -29
- package/dist/harness/collaboration/orchestration/quality/gate.js +0 -409
- package/dist/harness/collaboration/orchestration/quality/index.d.ts +0 -9
- package/dist/harness/collaboration/orchestration/quality/index.js +0 -8
- package/dist/harness/collaboration/orchestration/quality/types.d.ts +0 -159
- package/dist/harness/collaboration/orchestration/quality/types.js +0 -33
- package/dist/harness/collaboration/orchestration/scheduler/index.d.ts +0 -5
- package/dist/harness/collaboration/orchestration/scheduler/index.js +0 -4
- package/dist/harness/collaboration/orchestration/scheduler/task-scheduler.d.ts +0 -143
- package/dist/harness/collaboration/orchestration/scheduler/task-scheduler.js +0 -297
- package/dist/harness/collaboration/orchestration/strategy/classifier.d.ts +0 -12
- package/dist/harness/collaboration/orchestration/strategy/classifier.js +0 -81
- package/dist/harness/collaboration/orchestration/strategy/index.d.ts +0 -3
- package/dist/harness/collaboration/orchestration/strategy/index.js +0 -2
- package/dist/harness/collaboration/orchestration/strategy/router.d.ts +0 -28
- package/dist/harness/collaboration/orchestration/strategy/router.js +0 -105
- package/dist/harness/collaboration/orchestration/strategy/types.d.ts +0 -49
- package/dist/harness/collaboration/orchestration/strategy/types.js +0 -4
- package/dist/harness/collaboration/orchestration/workflow/engine.d.ts +0 -86
- package/dist/harness/collaboration/orchestration/workflow/engine.js +0 -298
- package/dist/harness/collaboration/orchestration/workflow/index.d.ts +0 -9
- package/dist/harness/collaboration/orchestration/workflow/index.js +0 -7
- package/dist/harness/collaboration/orchestration/workflow/types.d.ts +0 -143
- package/dist/harness/collaboration/orchestration/workflow/types.js +0 -7
- package/dist/harness/governance/human-in-the-loop/approval-manager.d.ts +0 -32
- package/dist/harness/governance/human-in-the-loop/approval-manager.js +0 -93
- /package/dist/harness/collaboration/{multi-agent → delegation}/message-channel-types.d.ts +0 -0
- /package/dist/harness/collaboration/{multi-agent → delegation}/message-channel-types.js +0 -0
|
@@ -0,0 +1,299 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shell 账本(ToolEffectPolicy §5.6)
|
|
3
|
+
*
|
|
4
|
+
* 无 L4 时由 shell 工具在 spawn 前后制造记账边界:
|
|
5
|
+
* before 快照(内容寻址)→ 执行 → after diff → 注入 TurnFileUndoLog。
|
|
6
|
+
* 清点范围外不装懂;预算撞顶停采 before、业务跑完,标 truncated。
|
|
7
|
+
*/
|
|
8
|
+
import { createHash } from 'node:crypto';
|
|
9
|
+
import { readdir, readFile, stat } from 'node:fs/promises';
|
|
10
|
+
import { join, relative } from 'node:path';
|
|
11
|
+
import { pathKey } from './undo-merge.js';
|
|
12
|
+
const DEFAULT_EXCLUDES = new Set([
|
|
13
|
+
'node_modules',
|
|
14
|
+
'.git',
|
|
15
|
+
'.hg',
|
|
16
|
+
'.svn',
|
|
17
|
+
'dist',
|
|
18
|
+
'build',
|
|
19
|
+
'.next',
|
|
20
|
+
'.turbo',
|
|
21
|
+
'.venv',
|
|
22
|
+
'venv',
|
|
23
|
+
'__pycache__',
|
|
24
|
+
'.octopi',
|
|
25
|
+
'coverage',
|
|
26
|
+
]);
|
|
27
|
+
function sha256Hex(data) {
|
|
28
|
+
return createHash('sha256').update(data).digest('hex');
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* 遍历 roots,收集文件内容哈希(供 before/after 对比)。
|
|
32
|
+
*
|
|
33
|
+
* @param options - 根与预算
|
|
34
|
+
* @returns 采集结果;truncated=true 表示撞顶未扫全
|
|
35
|
+
*/
|
|
36
|
+
export async function captureShellInventory(options) {
|
|
37
|
+
const map = new Map();
|
|
38
|
+
const exclude = new Set(options.excludeDirs ?? [...DEFAULT_EXCLUDES]);
|
|
39
|
+
const limit = options.limit ?? {};
|
|
40
|
+
let scanned = 0;
|
|
41
|
+
let bytes = 0;
|
|
42
|
+
let truncated = false;
|
|
43
|
+
const walk = async (dir) => {
|
|
44
|
+
if (truncated)
|
|
45
|
+
return;
|
|
46
|
+
let items;
|
|
47
|
+
try {
|
|
48
|
+
items = await readdir(dir, { withFileTypes: true });
|
|
49
|
+
}
|
|
50
|
+
catch {
|
|
51
|
+
return;
|
|
52
|
+
}
|
|
53
|
+
for (const item of items) {
|
|
54
|
+
if (truncated)
|
|
55
|
+
return;
|
|
56
|
+
const full = join(dir, item.name);
|
|
57
|
+
if (item.isDirectory()) {
|
|
58
|
+
if (exclude.has(item.name))
|
|
59
|
+
continue;
|
|
60
|
+
await walk(full);
|
|
61
|
+
continue;
|
|
62
|
+
}
|
|
63
|
+
if (!item.isFile())
|
|
64
|
+
continue;
|
|
65
|
+
if (limit.maxFiles !== undefined && limit.maxFiles > 0 && scanned >= limit.maxFiles) {
|
|
66
|
+
truncated = true;
|
|
67
|
+
return;
|
|
68
|
+
}
|
|
69
|
+
const st = await stat(full).catch(() => undefined);
|
|
70
|
+
if (!st)
|
|
71
|
+
continue;
|
|
72
|
+
if (limit.maxFileSize !== undefined && limit.maxFileSize > 0 && st.size > limit.maxFileSize) {
|
|
73
|
+
continue;
|
|
74
|
+
}
|
|
75
|
+
if (limit.maxBytes !== undefined && limit.maxBytes > 0 && bytes + st.size > limit.maxBytes) {
|
|
76
|
+
truncated = true;
|
|
77
|
+
return;
|
|
78
|
+
}
|
|
79
|
+
const data = await readFile(full).catch(() => undefined);
|
|
80
|
+
if (!data)
|
|
81
|
+
continue;
|
|
82
|
+
scanned += 1;
|
|
83
|
+
bytes += data.length;
|
|
84
|
+
map.set(pathKey(full), {
|
|
85
|
+
path: full,
|
|
86
|
+
hash: sha256Hex(data),
|
|
87
|
+
size: data.length,
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
};
|
|
91
|
+
for (const root of options.roots) {
|
|
92
|
+
const st = await stat(root).catch(() => undefined);
|
|
93
|
+
if (!st)
|
|
94
|
+
continue;
|
|
95
|
+
if (st.isDirectory())
|
|
96
|
+
await walk(root);
|
|
97
|
+
else if (st.isFile()) {
|
|
98
|
+
const data = await readFile(root).catch(() => undefined);
|
|
99
|
+
if (data) {
|
|
100
|
+
scanned += 1;
|
|
101
|
+
bytes += data.length;
|
|
102
|
+
map.set(pathKey(root), { path: root, hash: sha256Hex(data), size: data.length });
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
return { map, truncated, scannedFiles: scanned };
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* 对比 before/after 清单。
|
|
110
|
+
*
|
|
111
|
+
* @param before - shell 前
|
|
112
|
+
* @param after - shell 后
|
|
113
|
+
* @returns 变更集
|
|
114
|
+
*/
|
|
115
|
+
export function diffShellInventory(before, after) {
|
|
116
|
+
const created = [];
|
|
117
|
+
const modified = [];
|
|
118
|
+
const deleted = [];
|
|
119
|
+
for (const [key, entry] of after.map) {
|
|
120
|
+
const prev = before.map.get(key);
|
|
121
|
+
if (!prev)
|
|
122
|
+
created.push(entry.path);
|
|
123
|
+
else if (prev.hash !== entry.hash)
|
|
124
|
+
modified.push(entry.path);
|
|
125
|
+
}
|
|
126
|
+
for (const [key, entry] of before.map) {
|
|
127
|
+
if (!after.map.has(key))
|
|
128
|
+
deleted.push(entry.path);
|
|
129
|
+
}
|
|
130
|
+
return { created, modified, deleted };
|
|
131
|
+
}
|
|
132
|
+
export function createShellSnapshotStore() {
|
|
133
|
+
const byPath = new Map();
|
|
134
|
+
const hashes = new Map();
|
|
135
|
+
return {
|
|
136
|
+
async get(path) {
|
|
137
|
+
return byPath.get(pathKey(path));
|
|
138
|
+
},
|
|
139
|
+
async put(path, data) {
|
|
140
|
+
const key = pathKey(path);
|
|
141
|
+
byPath.set(key, data);
|
|
142
|
+
hashes.set(key, sha256Hex(data));
|
|
143
|
+
},
|
|
144
|
+
hashOf(path) {
|
|
145
|
+
return hashes.get(pathKey(path));
|
|
146
|
+
},
|
|
147
|
+
};
|
|
148
|
+
}
|
|
149
|
+
/**
|
|
150
|
+
* shell 前:快照 roots 内文件字节(供 undo)。
|
|
151
|
+
*
|
|
152
|
+
* @param options - roots + 预算
|
|
153
|
+
* @returns 采集 + 字节库
|
|
154
|
+
*/
|
|
155
|
+
export async function snapshotShellRoots(options) {
|
|
156
|
+
const store = createShellSnapshotStore();
|
|
157
|
+
const exclude = new Set(options.excludeDirs ?? [...DEFAULT_EXCLUDES]);
|
|
158
|
+
const limit = options.limit ?? {};
|
|
159
|
+
const map = new Map();
|
|
160
|
+
let scanned = 0;
|
|
161
|
+
let bytes = 0;
|
|
162
|
+
let truncated = false;
|
|
163
|
+
const walk = async (dir) => {
|
|
164
|
+
if (truncated)
|
|
165
|
+
return;
|
|
166
|
+
let items;
|
|
167
|
+
try {
|
|
168
|
+
items = await readdir(dir, { withFileTypes: true });
|
|
169
|
+
}
|
|
170
|
+
catch {
|
|
171
|
+
return;
|
|
172
|
+
}
|
|
173
|
+
for (const item of items) {
|
|
174
|
+
if (truncated)
|
|
175
|
+
return;
|
|
176
|
+
const full = join(dir, item.name);
|
|
177
|
+
if (item.isDirectory()) {
|
|
178
|
+
if (exclude.has(item.name))
|
|
179
|
+
continue;
|
|
180
|
+
await walk(full);
|
|
181
|
+
continue;
|
|
182
|
+
}
|
|
183
|
+
if (!item.isFile())
|
|
184
|
+
continue;
|
|
185
|
+
if (limit.maxFiles !== undefined && limit.maxFiles > 0 && scanned >= limit.maxFiles) {
|
|
186
|
+
truncated = true;
|
|
187
|
+
return;
|
|
188
|
+
}
|
|
189
|
+
const st = await stat(full).catch(() => undefined);
|
|
190
|
+
if (!st)
|
|
191
|
+
continue;
|
|
192
|
+
if (limit.maxFileSize !== undefined && limit.maxFileSize > 0 && st.size > limit.maxFileSize) {
|
|
193
|
+
continue;
|
|
194
|
+
}
|
|
195
|
+
if (limit.maxBytes !== undefined && limit.maxBytes > 0 && bytes + st.size > limit.maxBytes) {
|
|
196
|
+
truncated = true;
|
|
197
|
+
return;
|
|
198
|
+
}
|
|
199
|
+
const data = await readFile(full).catch(() => undefined);
|
|
200
|
+
if (!data)
|
|
201
|
+
continue;
|
|
202
|
+
scanned += 1;
|
|
203
|
+
bytes += data.length;
|
|
204
|
+
await store.put(full, data);
|
|
205
|
+
map.set(pathKey(full), {
|
|
206
|
+
path: full,
|
|
207
|
+
hash: sha256Hex(data),
|
|
208
|
+
size: data.length,
|
|
209
|
+
});
|
|
210
|
+
}
|
|
211
|
+
};
|
|
212
|
+
for (const root of options.roots) {
|
|
213
|
+
const st = await stat(root).catch(() => undefined);
|
|
214
|
+
if (!st)
|
|
215
|
+
continue;
|
|
216
|
+
if (st.isDirectory())
|
|
217
|
+
await walk(root);
|
|
218
|
+
else if (st.isFile()) {
|
|
219
|
+
const data = await readFile(root).catch(() => undefined);
|
|
220
|
+
if (data) {
|
|
221
|
+
scanned += 1;
|
|
222
|
+
bytes += data.length;
|
|
223
|
+
await store.put(root, data);
|
|
224
|
+
map.set(pathKey(root), { path: root, hash: sha256Hex(data), size: data.length });
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
return { capture: { map, truncated, scannedFiles: scanned }, store };
|
|
229
|
+
}
|
|
230
|
+
/**
|
|
231
|
+
* shell 后:diff 并写入效应账本。
|
|
232
|
+
*
|
|
233
|
+
* @param effects - undo log
|
|
234
|
+
* @param before - 前清单
|
|
235
|
+
* @param after - 后清单
|
|
236
|
+
* @param store - before 字节
|
|
237
|
+
* @returns 变更与是否已入账
|
|
238
|
+
*/
|
|
239
|
+
export async function journalShellDiff(effects, before, after, store) {
|
|
240
|
+
// 截断的 before 不得把「未扫到的旧文件」推断成 create(否则 discard 会误删)
|
|
241
|
+
const beforeIncomplete = before.truncated;
|
|
242
|
+
const diff = diffShellInventory(before, after);
|
|
243
|
+
const notInventable = [];
|
|
244
|
+
const created = [];
|
|
245
|
+
const modified = [];
|
|
246
|
+
const deleted = [];
|
|
247
|
+
for (const p of diff.created) {
|
|
248
|
+
if (beforeIncomplete) {
|
|
249
|
+
notInventable.push(p);
|
|
250
|
+
continue;
|
|
251
|
+
}
|
|
252
|
+
const data = await readFile(p).catch(() => undefined);
|
|
253
|
+
await effects.recordCreate(p, data);
|
|
254
|
+
created.push(p);
|
|
255
|
+
}
|
|
256
|
+
for (const p of diff.modified) {
|
|
257
|
+
const beforeBytes = await store.get(p);
|
|
258
|
+
const afterBytes = await readFile(p).catch(() => undefined);
|
|
259
|
+
if (beforeBytes !== undefined) {
|
|
260
|
+
await effects.recordOverwrite(p, beforeBytes, afterBytes);
|
|
261
|
+
modified.push(p);
|
|
262
|
+
}
|
|
263
|
+
else if (beforeIncomplete || before.truncated) {
|
|
264
|
+
notInventable.push(p);
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
for (const p of diff.deleted) {
|
|
268
|
+
const beforeBytes = await store.get(p);
|
|
269
|
+
if (beforeBytes !== undefined) {
|
|
270
|
+
await effects.recordDelete(p, beforeBytes);
|
|
271
|
+
deleted.push(p);
|
|
272
|
+
}
|
|
273
|
+
else {
|
|
274
|
+
notInventable.push(p);
|
|
275
|
+
}
|
|
276
|
+
}
|
|
277
|
+
// after 也不完整时,未覆盖范围视为不可逆
|
|
278
|
+
if (after.truncated) {
|
|
279
|
+
// 未扫到的路径未知;标记预算截断供 noteNotReversed
|
|
280
|
+
}
|
|
281
|
+
return { created, modified, deleted, journaled: true, notInventable };
|
|
282
|
+
}
|
|
283
|
+
/** 相对路径辅助(诊断用) */
|
|
284
|
+
export function relToRoot(root, path) {
|
|
285
|
+
return relative(root, path) || path;
|
|
286
|
+
}
|
|
287
|
+
/** 供 discard 读取的不可逆清单文件名 */
|
|
288
|
+
export const NOT_REVERSED_FILE = 'not-reversed.json';
|
|
289
|
+
/**
|
|
290
|
+
* 落盘不可逆效应清单(不进 log.jsonl)。
|
|
291
|
+
*
|
|
292
|
+
* @param undoRoot - sessions/<sid>/undo
|
|
293
|
+
* @param payload - 原因 + 路径清单
|
|
294
|
+
*/
|
|
295
|
+
export async function writeNotReversed(undoRoot, payload) {
|
|
296
|
+
const { mkdir, writeFile } = await import('node:fs/promises');
|
|
297
|
+
await mkdir(undoRoot, { recursive: true });
|
|
298
|
+
await writeFile(join(undoRoot, NOT_REVERSED_FILE), JSON.stringify(payload) + '\n', 'utf8');
|
|
299
|
+
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Tool capability tags (D5-a). Reduced surface strips `exec` / `egress` /
|
|
3
|
+
* `send` / `dynamic-code` / `runner`. Name-based fallback is only for builtins
|
|
4
|
+
* that are listed here; unknown tools are rejected on reduced (unknown-reject).
|
|
5
|
+
*
|
|
6
|
+
* `vcs` is intentionally **not** stripped: local git porcelain (fixed argv
|
|
7
|
+
* allowlist, hooks disabled) stays available so workspace/untrusted agents can
|
|
8
|
+
* still commit/diff without a shell.
|
|
9
|
+
*/
|
|
10
|
+
import type { ToolCapability } from '@octopi-agent/core/types.js';
|
|
11
|
+
export type { ToolCapability };
|
|
12
|
+
/** Capabilities that are denied on the reduced tool surface. */
|
|
13
|
+
export declare const REDUCED_DENIED_CAPABILITIES: readonly ["exec", "egress", "send", "dynamic-code", "runner"];
|
|
14
|
+
/**
|
|
15
|
+
* Builtin name → capability tags. Keep in sync with each tool definition's
|
|
16
|
+
* `capabilities` field (backfilled for every builtin).
|
|
17
|
+
*/
|
|
18
|
+
export declare const BUILTIN_TOOL_CAPABILITIES: Record<string, ToolCapability[]>;
|
|
19
|
+
/**
|
|
20
|
+
* Record capabilities for a registered tool (called from ToolBus.register).
|
|
21
|
+
* Untagged registration is stored as `unknown` so a third-party tool cannot
|
|
22
|
+
* inherit the builtin name map by shadowing a builtin name (P1-2 residual).
|
|
23
|
+
*
|
|
24
|
+
* @param toolName - registered name
|
|
25
|
+
* @param capabilities - definition.capabilities (undefined = untagged → unknown)
|
|
26
|
+
*/
|
|
27
|
+
export declare function registerToolCapabilities(toolName: string, capabilities?: readonly string[] | null): void;
|
|
28
|
+
/**
|
|
29
|
+
* Resolve capabilities for a tool.
|
|
30
|
+
*
|
|
31
|
+
* Precedence: explicit arg → runtime registry → builtin name map.
|
|
32
|
+
* Explicit `[]` is authoritative (no dangerous caps). Unknown → null.
|
|
33
|
+
*
|
|
34
|
+
* @param toolName - registered tool name
|
|
35
|
+
* @param explicit - capabilities from ToolDefinition (preferred)
|
|
36
|
+
* @returns tags, or null when unknown
|
|
37
|
+
*/
|
|
38
|
+
export declare function resolveToolCapabilities(toolName: string, explicit?: readonly string[] | null): ToolCapability[] | null;
|
|
39
|
+
/**
|
|
40
|
+
* Whether any capability is denied on the reduced surface.
|
|
41
|
+
*
|
|
42
|
+
* @param caps - resolved capability tags
|
|
43
|
+
* @returns true when the tool must be stripped
|
|
44
|
+
*/
|
|
45
|
+
export declare function deniesReducedSurface(caps: readonly string[]): boolean;
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Tool capability tags (D5-a). Reduced surface strips `exec` / `egress` /
|
|
3
|
+
* `send` / `dynamic-code` / `runner`. Name-based fallback is only for builtins
|
|
4
|
+
* that are listed here; unknown tools are rejected on reduced (unknown-reject).
|
|
5
|
+
*
|
|
6
|
+
* `vcs` is intentionally **not** stripped: local git porcelain (fixed argv
|
|
7
|
+
* allowlist, hooks disabled) stays available so workspace/untrusted agents can
|
|
8
|
+
* still commit/diff without a shell.
|
|
9
|
+
*/
|
|
10
|
+
/** Capabilities that are denied on the reduced tool surface. */
|
|
11
|
+
export const REDUCED_DENIED_CAPABILITIES = [
|
|
12
|
+
'exec',
|
|
13
|
+
'egress',
|
|
14
|
+
'send',
|
|
15
|
+
'dynamic-code',
|
|
16
|
+
/** project_run executes workspace-defined scripts (code execution) */
|
|
17
|
+
'runner',
|
|
18
|
+
];
|
|
19
|
+
/**
|
|
20
|
+
* Builtin name → capability tags. Keep in sync with each tool definition's
|
|
21
|
+
* `capabilities` field (backfilled for every builtin).
|
|
22
|
+
*/
|
|
23
|
+
export const BUILTIN_TOOL_CAPABILITIES = {
|
|
24
|
+
shell: ['exec'],
|
|
25
|
+
file_read: ['fs-read'],
|
|
26
|
+
file_write: ['fs-write'],
|
|
27
|
+
file_edit: ['fs-write', 'fs-read'],
|
|
28
|
+
file_delete: ['fs-write'],
|
|
29
|
+
file_list: ['fs-read'],
|
|
30
|
+
file_search: ['fs-read'],
|
|
31
|
+
file_mkdir: ['fs-write'],
|
|
32
|
+
file_rmdir: ['fs-write'],
|
|
33
|
+
file_rename: ['fs-write'],
|
|
34
|
+
file_copy: ['fs-write', 'fs-read'],
|
|
35
|
+
file_stat: ['fs-read'],
|
|
36
|
+
// Local VCS porcelain (spawn git argv allowlist; hooks disabled)
|
|
37
|
+
git_status: ['vcs', 'fs-read'],
|
|
38
|
+
git_diff: ['vcs', 'fs-read'],
|
|
39
|
+
git_log: ['vcs', 'fs-read'],
|
|
40
|
+
git_show: ['vcs', 'fs-read'],
|
|
41
|
+
git_commit: ['vcs', 'fs-write'],
|
|
42
|
+
git_branch: ['vcs', 'fs-write'],
|
|
43
|
+
git_restore: ['vcs', 'fs-write'],
|
|
44
|
+
// Package / project tooling
|
|
45
|
+
package_edit: ['fs-write', 'fs-read'],
|
|
46
|
+
project_run: ['runner'],
|
|
47
|
+
package_install: ['egress', 'runner'],
|
|
48
|
+
document_read: ['fs-read'],
|
|
49
|
+
document_probe: ['fs-read'],
|
|
50
|
+
env_info: ['fs-read'],
|
|
51
|
+
http_request: ['egress'],
|
|
52
|
+
web_search: ['egress'],
|
|
53
|
+
ask_user: [],
|
|
54
|
+
memory_store: ['memory'],
|
|
55
|
+
memory_search: ['memory'],
|
|
56
|
+
knowledge_search: ['fs-read'],
|
|
57
|
+
knowledge_read: ['fs-read'],
|
|
58
|
+
session_search: ['fs-read'],
|
|
59
|
+
session_read: ['fs-read'],
|
|
60
|
+
// Session task tools (session/tasks/tools.ts) — tagged via resolve as needed
|
|
61
|
+
task_create: ['fs-write'],
|
|
62
|
+
task_list: ['fs-read'],
|
|
63
|
+
task_plan: ['fs-write'],
|
|
64
|
+
task_complete: ['fs-write'],
|
|
65
|
+
task_pause: ['fs-write'],
|
|
66
|
+
task_resume: ['fs-write'],
|
|
67
|
+
task_drop: ['fs-write'],
|
|
68
|
+
task_note: ['fs-write'],
|
|
69
|
+
};
|
|
70
|
+
const registeredCapabilities = new Map();
|
|
71
|
+
/**
|
|
72
|
+
* Record capabilities for a registered tool (called from ToolBus.register).
|
|
73
|
+
* Untagged registration is stored as `unknown` so a third-party tool cannot
|
|
74
|
+
* inherit the builtin name map by shadowing a builtin name (P1-2 residual).
|
|
75
|
+
*
|
|
76
|
+
* @param toolName - registered name
|
|
77
|
+
* @param capabilities - definition.capabilities (undefined = untagged → unknown)
|
|
78
|
+
*/
|
|
79
|
+
export function registerToolCapabilities(toolName, capabilities) {
|
|
80
|
+
const n = toolName.toLowerCase();
|
|
81
|
+
if (capabilities && capabilities.length > 0) {
|
|
82
|
+
registeredCapabilities.set(n, [...capabilities]);
|
|
83
|
+
return;
|
|
84
|
+
}
|
|
85
|
+
if (capabilities && capabilities.length === 0) {
|
|
86
|
+
registeredCapabilities.set(n, []);
|
|
87
|
+
return;
|
|
88
|
+
}
|
|
89
|
+
// Untagged: do not fall back to BUILTIN_TOOL_CAPABILITIES for this name
|
|
90
|
+
registeredCapabilities.set(n, 'unknown');
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* Resolve capabilities for a tool.
|
|
94
|
+
*
|
|
95
|
+
* Precedence: explicit arg → runtime registry → builtin name map.
|
|
96
|
+
* Explicit `[]` is authoritative (no dangerous caps). Unknown → null.
|
|
97
|
+
*
|
|
98
|
+
* @param toolName - registered tool name
|
|
99
|
+
* @param explicit - capabilities from ToolDefinition (preferred)
|
|
100
|
+
* @returns tags, or null when unknown
|
|
101
|
+
*/
|
|
102
|
+
export function resolveToolCapabilities(toolName, explicit) {
|
|
103
|
+
if (explicit !== undefined && explicit !== null) {
|
|
104
|
+
return [...explicit];
|
|
105
|
+
}
|
|
106
|
+
const n = toolName.toLowerCase();
|
|
107
|
+
const reg = registeredCapabilities.get(n);
|
|
108
|
+
if (reg === 'unknown')
|
|
109
|
+
return null;
|
|
110
|
+
if (reg)
|
|
111
|
+
return [...reg];
|
|
112
|
+
// Unregistered: builtin name map only (tests / pre-register probes)
|
|
113
|
+
const builtin = BUILTIN_TOOL_CAPABILITIES[n];
|
|
114
|
+
if (builtin)
|
|
115
|
+
return [...builtin];
|
|
116
|
+
return null;
|
|
117
|
+
}
|
|
118
|
+
/**
|
|
119
|
+
* Whether any capability is denied on the reduced surface.
|
|
120
|
+
*
|
|
121
|
+
* @param caps - resolved capability tags
|
|
122
|
+
* @returns true when the tool must be stripped
|
|
123
|
+
*/
|
|
124
|
+
export function deniesReducedSurface(caps) {
|
|
125
|
+
return caps.some((c) => REDUCED_DENIED_CAPABILITIES.includes(c));
|
|
126
|
+
}
|
|
@@ -1,80 +1,108 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Execution Environment
|
|
2
|
+
* Execution Environment interface contracts
|
|
3
3
|
*
|
|
4
|
-
* @layer harness/extension/execution-environment
|
|
4
|
+
* @layer harness/extension/execution-environment
|
|
5
5
|
*/
|
|
6
|
-
|
|
6
|
+
import type { ProcessIsolationProfile } from './process-isolation.js';
|
|
7
|
+
/** Legacy coarse isolation level (prefer ProcessIsolationProfile) */
|
|
7
8
|
export type IsolationLevel = 'none' | 'process' | 'container';
|
|
8
|
-
/**
|
|
9
|
+
/** Sandbox config */
|
|
9
10
|
export interface SandboxConfig {
|
|
10
|
-
/**
|
|
11
|
-
isolationLevel
|
|
12
|
-
/**
|
|
11
|
+
/** Requested isolation level (legacy knob) */
|
|
12
|
+
isolationLevel?: IsolationLevel;
|
|
13
|
+
/** Working directory */
|
|
13
14
|
cwd?: string;
|
|
14
|
-
/**
|
|
15
|
+
/**
|
|
16
|
+
* Explicit environment. Merged on top of the scrubbed allowlist.
|
|
17
|
+
* Never spreads `process.env` — secrets must not ride along.
|
|
18
|
+
*/
|
|
15
19
|
env?: Record<string, string>;
|
|
16
|
-
/**
|
|
20
|
+
/** Resource limits */
|
|
17
21
|
limits?: ResourceLimits;
|
|
18
|
-
/**
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
+
/**
|
|
23
|
+
* Network posture for jail backends (bwrap / Seatbelt).
|
|
24
|
+
* Default when omitted: `deny` (D4-c). `allowlist` is interface-only this release
|
|
25
|
+
* and is enforced as `deny` with an honest note.
|
|
26
|
+
*/
|
|
27
|
+
networkPolicy?: 'open' | 'deny' | 'allowlist';
|
|
28
|
+
/**
|
|
29
|
+
* Absolute roots the jail may read/write (bind mounts / Seatbelt write-allow).
|
|
30
|
+
* Falls back to `[cwd]` when omitted. Not a substitute for L2 path policy.
|
|
31
|
+
*/
|
|
32
|
+
allowRoots?: string[];
|
|
33
|
+
/**
|
|
34
|
+
* D7: when true (untrusted / L4-required), jail backend must actually apply.
|
|
35
|
+
* Setup failure throws instead of falling back to supervised spawn.
|
|
36
|
+
*/
|
|
37
|
+
requireJail?: boolean;
|
|
38
|
+
/**
|
|
39
|
+
* Allow `$HOME` writes inside the jail (project/host only per 2b).
|
|
40
|
+
* tmpdir and, on POSIX, shared `/tmp` + `/var/tmp` are always writable (2a);
|
|
41
|
+
* tmp writes are not journaled (2c notReversed).
|
|
42
|
+
*/
|
|
43
|
+
homeWrite?: boolean;
|
|
44
|
+
/** Run-level hook for execute-time degradation (falls back to isolation.notes). */
|
|
45
|
+
noteSecurityDegraded?: (reason: string) => void;
|
|
46
|
+
/** Abort in-flight execution */
|
|
47
|
+
signal?: AbortSignal;
|
|
22
48
|
}
|
|
23
|
-
/**
|
|
49
|
+
/** Resource limits */
|
|
24
50
|
export interface ResourceLimits {
|
|
25
|
-
/**
|
|
51
|
+
/** Max wall time (ms) */
|
|
26
52
|
timeoutMs?: number;
|
|
27
|
-
/**
|
|
53
|
+
/** Max memory (bytes) */
|
|
28
54
|
maxMemoryBytes?: number;
|
|
29
|
-
/**
|
|
55
|
+
/** Max captured output (bytes) */
|
|
30
56
|
maxOutputBytes?: number;
|
|
31
|
-
/**
|
|
57
|
+
/** Max CPU time (ms) */
|
|
32
58
|
maxCpuTimeMs?: number;
|
|
33
59
|
}
|
|
34
|
-
/**
|
|
60
|
+
/** Resource usage */
|
|
35
61
|
export interface ResourceUsage {
|
|
36
|
-
/**
|
|
62
|
+
/** Elapsed wall time (ms) */
|
|
37
63
|
elapsedMs: number;
|
|
38
|
-
/**
|
|
64
|
+
/** Peak memory (bytes, -1 unknown) */
|
|
39
65
|
peakMemoryBytes: number;
|
|
40
|
-
/** CPU
|
|
66
|
+
/** CPU time (ms, -1 unknown) */
|
|
41
67
|
cpuTimeMs: number;
|
|
42
|
-
/**
|
|
68
|
+
/** Output size (bytes) */
|
|
43
69
|
outputBytes: number;
|
|
44
70
|
}
|
|
45
|
-
/**
|
|
71
|
+
/** Sandbox execution result */
|
|
46
72
|
export interface SandboxResult {
|
|
47
|
-
/**
|
|
73
|
+
/** Exit code */
|
|
48
74
|
exitCode: number;
|
|
49
|
-
/**
|
|
75
|
+
/** stdout */
|
|
50
76
|
stdout: string;
|
|
51
|
-
/**
|
|
77
|
+
/** stderr */
|
|
52
78
|
stderr: string;
|
|
53
|
-
/**
|
|
79
|
+
/** Terminated by sandbox (timeout, OOM, output cap) */
|
|
54
80
|
terminated: boolean;
|
|
55
|
-
/**
|
|
81
|
+
/** Terminate reason */
|
|
56
82
|
terminateReason?: string;
|
|
57
|
-
/**
|
|
83
|
+
/** Resource usage */
|
|
58
84
|
usage: ResourceUsage;
|
|
85
|
+
/** Honest isolation actually applied for this run */
|
|
86
|
+
isolation: ProcessIsolationProfile;
|
|
59
87
|
}
|
|
60
88
|
/**
|
|
61
|
-
* SandboxProvider —
|
|
62
|
-
*
|
|
63
|
-
* 在隔离环境中执行命令。不同实现可以提供不同级别的隔离:
|
|
64
|
-
* - none: 直接执行(开发模式)
|
|
65
|
-
* - process: 进程级隔离(spawn + resource limits)
|
|
66
|
-
* - container: 容器级隔离(Docker/firejail)
|
|
89
|
+
* SandboxProvider — execute commands under an isolation profile.
|
|
90
|
+
* Implementations must report real capabilities via `isolation` / `probe()`.
|
|
67
91
|
*/
|
|
68
92
|
export interface SandboxProvider {
|
|
69
|
-
/**
|
|
93
|
+
/** Legacy coarse level */
|
|
70
94
|
readonly level: IsolationLevel;
|
|
95
|
+
/** Honest isolation profile for this provider */
|
|
96
|
+
probe(): Promise<ProcessIsolationProfile>;
|
|
71
97
|
/**
|
|
72
|
-
*
|
|
98
|
+
* Execute a shell command line (platform shell) under isolation.
|
|
73
99
|
*/
|
|
74
100
|
execute(command: string, config?: SandboxConfig): Promise<SandboxResult>;
|
|
75
101
|
/**
|
|
76
|
-
*
|
|
102
|
+
* Execute an argv vector (preferred — no shell string parsing).
|
|
77
103
|
*/
|
|
104
|
+
executeArgv?(argv: string[], config?: SandboxConfig): Promise<SandboxResult>;
|
|
105
|
+
/** Whether this provider can run on the current host */
|
|
78
106
|
isAvailable(): Promise<boolean>;
|
|
79
107
|
}
|
|
80
108
|
/** 工作区配置 */
|