@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,248 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ToolEffectPolicy P3 — 运行模式预设与有效策略
|
|
3
|
+
*
|
|
4
|
+
* 命名模式(workspace / project / host / untrusted)展开为正交旋钮。
|
|
5
|
+
* 见 arch/tool-effect-policy.md §7。
|
|
6
|
+
*/
|
|
7
|
+
import type { HitlDecision } from '@octopi-agent/core/types/tools.js';
|
|
8
|
+
import type { ToolIsolationMode } from './isolation.js';
|
|
9
|
+
import { type ProcessIsolationProfile } from './process-isolation.js';
|
|
10
|
+
/** 命名运行模式 */
|
|
11
|
+
export type EffectRunMode = 'workspace' | 'project' | 'host' | 'untrusted';
|
|
12
|
+
/**
|
|
13
|
+
* Engine default when `effectPolicy.mode` is omitted (secure-by-default).
|
|
14
|
+
* Scaffold/`octopi init` / `octopi.example.json` set `mode: "host"` explicitly
|
|
15
|
+
* so evaluation gets full capability; embedders who omit `mode` get `workspace`.
|
|
16
|
+
* See `docs/process-isolation.md`.
|
|
17
|
+
*/
|
|
18
|
+
export declare const DEFAULT_EFFECT_RUN_MODE: EffectRunMode;
|
|
19
|
+
/** 路径包含级别(L2) */
|
|
20
|
+
export type PathContainment = 'strict' | 'soft' | 'none';
|
|
21
|
+
/** shell 工具策略(非「越界」;无 L4 时 deny=拒绝整个 shell) */
|
|
22
|
+
export type ShellEscapePolicy = 'deny' | 'confirm' | 'allow';
|
|
23
|
+
/** commit 策略 */
|
|
24
|
+
export type EffectCommitPolicy = 'auto' | 'manual';
|
|
25
|
+
/** 效应确认通道 */
|
|
26
|
+
/** 效应意图(host-gate confirmEffect 入参) */
|
|
27
|
+
export type EffectIntent = {
|
|
28
|
+
kind: 'file.write';
|
|
29
|
+
path: string;
|
|
30
|
+
mode: 'create' | 'overwrite' | 'append' | 'edit';
|
|
31
|
+
/** 是否落在事务 root 内(可 undo) */
|
|
32
|
+
transactional: boolean;
|
|
33
|
+
} | {
|
|
34
|
+
kind: 'shell';
|
|
35
|
+
command: string;
|
|
36
|
+
cwd?: string;
|
|
37
|
+
} | {
|
|
38
|
+
/** project_run / package_install — executes workspace-defined scripts. Not shellEscape-gated. */
|
|
39
|
+
kind: 'runner';
|
|
40
|
+
command: string;
|
|
41
|
+
cwd?: string;
|
|
42
|
+
description?: string;
|
|
43
|
+
} | {
|
|
44
|
+
/** Local VCS porcelain (git). Not shellEscape-gated. */
|
|
45
|
+
kind: 'vcs';
|
|
46
|
+
operation: string;
|
|
47
|
+
cwd?: string;
|
|
48
|
+
description?: string;
|
|
49
|
+
} | {
|
|
50
|
+
kind: 'memory.write';
|
|
51
|
+
domain: 'memory' | 'cognition' | 'wisdom';
|
|
52
|
+
transactional: true;
|
|
53
|
+
} | {
|
|
54
|
+
kind: 'other';
|
|
55
|
+
description: string;
|
|
56
|
+
};
|
|
57
|
+
export type ConfirmEffectDecision = HitlDecision;
|
|
58
|
+
/**
|
|
59
|
+
* host-gate 确认回调(P4)。engine 不内置审批 UI。
|
|
60
|
+
* 宿主可自动放行 / 弹自己的确认框 / 策略引擎。
|
|
61
|
+
* 返回 {@link HitlDecision};session/always 由引擎 HitlDecisionCache 记账。
|
|
62
|
+
*/
|
|
63
|
+
export type ConfirmEffect = NonNullable<import('@octopi-agent/core/types/tools.js').ToolExecutionContext['confirmEffect']>;
|
|
64
|
+
export type EffectConfirmChannel = 'engine' | 'host-gate';
|
|
65
|
+
/** shell 记账深度(§5.6):snapshot=采 before 可逆;off=只知情 */
|
|
66
|
+
export type ShellJournalMode = 'snapshot' | 'off';
|
|
67
|
+
/** How to admit `untrusted` when L4 process jail is missing */
|
|
68
|
+
export type UntrustedAdmission = 'refuse' | 'degrade';
|
|
69
|
+
/** Effective tool surface after isolation admission */
|
|
70
|
+
export type ToolSurface = 'full' | 'reduced';
|
|
71
|
+
/** Machine-readable degradations (never silent) */
|
|
72
|
+
export type SecurityDegradation = 'no_process_jail' | 'network_open' | 'env_inherit' | 'privilege_same' | 'filesystem_not_jailed';
|
|
73
|
+
/** 配置形状(可覆盖预设) */
|
|
74
|
+
export interface EffectPolicyConfig {
|
|
75
|
+
/**
|
|
76
|
+
* Omitted = `DEFAULT_EFFECT_RUN_MODE` (**workspace**, secure-by-default).
|
|
77
|
+
* Scaffold/config templates set `"mode": "host"` explicitly for local evaluation.
|
|
78
|
+
*/
|
|
79
|
+
mode?: EffectRunMode;
|
|
80
|
+
/**
|
|
81
|
+
* `untrusted` 无 L4 时:`refuse`(缺省,第三方)拒绝运行;
|
|
82
|
+
* `degrade` 降 effectiveMode + toolSurface=reduced + securityDegraded。
|
|
83
|
+
*/
|
|
84
|
+
untrustedAdmission?: UntrustedAdmission;
|
|
85
|
+
/** 额外事务 root(绝对路径);并入 allowRoots */
|
|
86
|
+
transactionRoots?: string[];
|
|
87
|
+
pathContainment?: PathContainment;
|
|
88
|
+
shellEscape?: ShellEscapePolicy;
|
|
89
|
+
/**
|
|
90
|
+
* Jail network posture (D4-c). Omitted = mode default:
|
|
91
|
+
* host/project → `open`, workspace/untrusted → `deny`.
|
|
92
|
+
*/
|
|
93
|
+
network?: 'open' | 'deny' | 'allowlist';
|
|
94
|
+
processLimits?: boolean;
|
|
95
|
+
commit?: EffectCommitPolicy;
|
|
96
|
+
/** commit=manual 时会话关闭/超时如何收残留 undo */
|
|
97
|
+
onClose?: 'commit' | 'discard';
|
|
98
|
+
effects?: EffectConfirmChannel;
|
|
99
|
+
/** 覆盖模式推导的 toolIsolation */
|
|
100
|
+
toolIsolation?: ToolIsolationMode;
|
|
101
|
+
/** undo 配额;缺省不限。撞顶停记 before,业务写继续 */
|
|
102
|
+
undoLimit?: {
|
|
103
|
+
maxEntries?: number;
|
|
104
|
+
maxBlobBytes?: number;
|
|
105
|
+
};
|
|
106
|
+
/** shell 记账深度;缺省 snapshot */
|
|
107
|
+
shellJournal?: ShellJournalMode;
|
|
108
|
+
/** shell 清点/快照预算;缺省不限 */
|
|
109
|
+
shellJournalLimit?: {
|
|
110
|
+
maxFiles?: number;
|
|
111
|
+
maxBytes?: number;
|
|
112
|
+
maxFileSize?: number;
|
|
113
|
+
};
|
|
114
|
+
}
|
|
115
|
+
/** 展开后的有效策略 */
|
|
116
|
+
export interface EffectiveEffectPolicy {
|
|
117
|
+
/** Configured/requested mode (audit trail) */
|
|
118
|
+
requestedMode: EffectRunMode;
|
|
119
|
+
/**
|
|
120
|
+
* Effective mode after untrusted admission.
|
|
121
|
+
* Equals `requestedMode` when isolation is sufficient (or mode ≠ untrusted).
|
|
122
|
+
*/
|
|
123
|
+
mode: EffectRunMode;
|
|
124
|
+
untrustedAdmission: UntrustedAdmission;
|
|
125
|
+
/** `reduced` strips shell/http/MCP-style power when untrusted degrades */
|
|
126
|
+
toolSurface: ToolSurface;
|
|
127
|
+
/** Non-empty when isolation is weaker than requested */
|
|
128
|
+
securityDegraded: SecurityDegradation[];
|
|
129
|
+
toolIsolation: ToolIsolationMode;
|
|
130
|
+
pathContainment: PathContainment;
|
|
131
|
+
shellEscape: ShellEscapePolicy;
|
|
132
|
+
/** Resolved jail network posture */
|
|
133
|
+
network: 'open' | 'deny' | 'allowlist';
|
|
134
|
+
processLimits: boolean;
|
|
135
|
+
commit: EffectCommitPolicy;
|
|
136
|
+
onClose: 'commit' | 'discard';
|
|
137
|
+
effects: EffectConfirmChannel;
|
|
138
|
+
/** L2 允许根(含 workspace + transactionRoots) */
|
|
139
|
+
allowRoots: string[];
|
|
140
|
+
/** 事务 root 语义标签 */
|
|
141
|
+
transactionRoots: Array<'workspace' | 'memory' | 'host'>;
|
|
142
|
+
undoLimit?: {
|
|
143
|
+
maxEntries?: number;
|
|
144
|
+
maxBlobBytes?: number;
|
|
145
|
+
};
|
|
146
|
+
shellJournal: ShellJournalMode;
|
|
147
|
+
shellJournalLimit?: {
|
|
148
|
+
maxFiles?: number;
|
|
149
|
+
maxBytes?: number;
|
|
150
|
+
maxFileSize?: number;
|
|
151
|
+
};
|
|
152
|
+
}
|
|
153
|
+
/**
|
|
154
|
+
* 展开 effectPolicy 为有效策略
|
|
155
|
+
*
|
|
156
|
+
* @param config - 用户配置(mode 可省略,缺省 `DEFAULT_EFFECT_RUN_MODE`)
|
|
157
|
+
* @param baseWorkspace - 工具基路径(agent.workspace / RunConfig.cwd)
|
|
158
|
+
* @returns 有效策略
|
|
159
|
+
*/
|
|
160
|
+
/**
|
|
161
|
+
* Expand effectPolicy into an effective policy.
|
|
162
|
+
*
|
|
163
|
+
* `untrusted` requires an L4 process profile. When the host cannot offer it:
|
|
164
|
+
* - `untrustedAdmission: 'refuse'` (default) throws
|
|
165
|
+
* - `untrustedAdmission: 'degrade'` renames effectiveMode to workspace,
|
|
166
|
+
* sets toolSurface=reduced, and records securityDegraded[] (never silent)
|
|
167
|
+
*
|
|
168
|
+
* @param config - user config (mode optional)
|
|
169
|
+
* @param baseWorkspace - tool base path
|
|
170
|
+
* @param isolation - probed process isolation (optional; treated as supervised if absent)
|
|
171
|
+
* @returns effective policy with requested vs effective mode
|
|
172
|
+
* @throws Error when untrusted is refused
|
|
173
|
+
*/
|
|
174
|
+
export declare function resolveEffectiveEffectPolicy(config: EffectPolicyConfig, baseWorkspace?: string, isolation?: ProcessIsolationProfile): EffectiveEffectPolicy;
|
|
175
|
+
/**
|
|
176
|
+
* Whether a tool is on the reduced surface (untrusted degrade).
|
|
177
|
+
* Reduced keeps content tools inside L2; strips egress and code-exec power.
|
|
178
|
+
*
|
|
179
|
+
* @param toolName - registered tool name
|
|
180
|
+
* @param surface - full or reduced
|
|
181
|
+
* @returns whether the tool may run
|
|
182
|
+
*/
|
|
183
|
+
export declare function isToolAllowedOnSurface(toolName: string, surface: ToolSurface, capabilities?: readonly string[] | null): boolean;
|
|
184
|
+
/**
|
|
185
|
+
* L2:路径是否落在 allowRoots 内
|
|
186
|
+
*
|
|
187
|
+
* @param resolved - 已 resolve 的绝对路径
|
|
188
|
+
* @param allowRoots - 允许根
|
|
189
|
+
* @param containment - 级别;none 一律放行;soft 仅用于审计(由调用方记日志)
|
|
190
|
+
* @returns 是否允许
|
|
191
|
+
*/
|
|
192
|
+
export declare function isPathAllowed(resolved: string, allowRoots: string[], containment: PathContainment): boolean;
|
|
193
|
+
/**
|
|
194
|
+
* 效应闸(P4):事务内自动放行;host-gate 交给宿主;engine 通道按内置策略。
|
|
195
|
+
*
|
|
196
|
+
* @param intent - 效应意图
|
|
197
|
+
* @param options - 通道与回调
|
|
198
|
+
* @throws Error 当拒绝执行时
|
|
199
|
+
*/
|
|
200
|
+
export declare function gateEffect(intent: EffectIntent, options: {
|
|
201
|
+
effects: EffectConfirmChannel;
|
|
202
|
+
confirmEffect?: ConfirmEffect;
|
|
203
|
+
shellEscape?: ShellEscapePolicy;
|
|
204
|
+
/** SEC-7:session-scope 缓存键;缺省尝试 RunScope */
|
|
205
|
+
sessionId?: string;
|
|
206
|
+
/** SEC-7:always-scope 缓存键(agent 分桶);缺省尝试 RunScope */
|
|
207
|
+
agentId?: string;
|
|
208
|
+
hitlCache?: import('../../governance/human-in-the-loop/decision-cache.js').HitlDecisionCache;
|
|
209
|
+
}): Promise<void>;
|
|
210
|
+
/**
|
|
211
|
+
* Session-only effect overrides. Append-only: may add allow roots for this
|
|
212
|
+
* session; must never loosen pathContainment / shellEscape.
|
|
213
|
+
*/
|
|
214
|
+
export interface SessionEffectOverrides {
|
|
215
|
+
/** Extra allow/transaction roots (absolute paths), merged into allowRoots */
|
|
216
|
+
transactionRoots?: string[];
|
|
217
|
+
}
|
|
218
|
+
/**
|
|
219
|
+
* Parse `session.metadata.effectOverrides` safely (read path).
|
|
220
|
+
*
|
|
221
|
+
* Invalid entries are **skipped**, not thrown: a poisoned/corrupt metadata bag
|
|
222
|
+
* must not abort run start. Strict validation belongs on the write API
|
|
223
|
+
* (`normalizeTransactionRoots`).
|
|
224
|
+
*
|
|
225
|
+
* @param metadata - session metadata bag
|
|
226
|
+
* @returns valid absolute roots only (empty when absent/invalid)
|
|
227
|
+
*/
|
|
228
|
+
export declare function readSessionEffectOverrides(metadata: Record<string, unknown> | undefined): SessionEffectOverrides;
|
|
229
|
+
/**
|
|
230
|
+
* Normalize and validate transaction root paths (absolute, non-empty).
|
|
231
|
+
*
|
|
232
|
+
* @param paths - raw paths
|
|
233
|
+
* @returns absolute normalized unique paths
|
|
234
|
+
* @throws Error when a path is empty or not absolute
|
|
235
|
+
*/
|
|
236
|
+
export declare function normalizeTransactionRoots(paths: string[]): string[];
|
|
237
|
+
/**
|
|
238
|
+
* Append session roots to base allowRoots (dedupe; base wins on conflicts).
|
|
239
|
+
*
|
|
240
|
+
* @param baseRoots - roots from effectPolicy / workspace
|
|
241
|
+
* @param extraRoots - session temporary roots
|
|
242
|
+
* @returns combined unique list
|
|
243
|
+
*/
|
|
244
|
+
export declare function mergeTransactionRoots(baseRoots: string[], extraRoots: string[] | undefined): string[];
|
|
245
|
+
/**
|
|
246
|
+
* Metadata key used on SessionData.metadata / SessionStore.updateMetadata.
|
|
247
|
+
*/
|
|
248
|
+
export declare const SESSION_EFFECT_OVERRIDES_KEY = "effectOverrides";
|
|
@@ -0,0 +1,334 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ToolEffectPolicy P3 — 运行模式预设与有效策略
|
|
3
|
+
*
|
|
4
|
+
* 命名模式(workspace / project / host / untrusted)展开为正交旋钮。
|
|
5
|
+
* 见 arch/tool-effect-policy.md §7。
|
|
6
|
+
*/
|
|
7
|
+
import { isAbsolute, resolve } from 'node:path';
|
|
8
|
+
import { deniesReducedSurface, resolveToolCapabilities, } from './tool-capabilities.js';
|
|
9
|
+
import { assessL4ProcessMinimum, } from './process-isolation.js';
|
|
10
|
+
import { resolveHitlDecision } from '../../governance/human-in-the-loop/decision-cache.js';
|
|
11
|
+
import { getRunSessionId, getRunScope } from '../../run/run-scope.js';
|
|
12
|
+
/**
|
|
13
|
+
* Engine default when `effectPolicy.mode` is omitted (secure-by-default).
|
|
14
|
+
* Scaffold/`octopi init` / `octopi.example.json` set `mode: "host"` explicitly
|
|
15
|
+
* so evaluation gets full capability; embedders who omit `mode` get `workspace`.
|
|
16
|
+
* See `docs/process-isolation.md`.
|
|
17
|
+
*/
|
|
18
|
+
export const DEFAULT_EFFECT_RUN_MODE = 'workspace';
|
|
19
|
+
const MODE_DEFAULTS = {
|
|
20
|
+
workspace: {
|
|
21
|
+
mode: 'workspace',
|
|
22
|
+
toolIsolation: 'session-subdir',
|
|
23
|
+
pathContainment: 'strict',
|
|
24
|
+
// 无 L4 时无法「只禁越界」:deny = 拒绝 shell 工具(fail-closed)
|
|
25
|
+
shellEscape: 'deny',
|
|
26
|
+
network: 'deny',
|
|
27
|
+
processLimits: true,
|
|
28
|
+
commit: 'auto',
|
|
29
|
+
onClose: 'commit',
|
|
30
|
+
effects: 'engine',
|
|
31
|
+
shellJournal: 'snapshot',
|
|
32
|
+
},
|
|
33
|
+
project: {
|
|
34
|
+
mode: 'project',
|
|
35
|
+
toolIsolation: 'session-subdir',
|
|
36
|
+
pathContainment: 'strict',
|
|
37
|
+
// 编码 agent 必须有 shell;文件侧靠 L2,shell FS 越界待 L4
|
|
38
|
+
shellEscape: 'allow',
|
|
39
|
+
network: 'open',
|
|
40
|
+
processLimits: true,
|
|
41
|
+
commit: 'auto',
|
|
42
|
+
onClose: 'commit',
|
|
43
|
+
effects: 'engine',
|
|
44
|
+
shellJournal: 'snapshot',
|
|
45
|
+
},
|
|
46
|
+
host: {
|
|
47
|
+
mode: 'host',
|
|
48
|
+
toolIsolation: 'none',
|
|
49
|
+
pathContainment: 'none',
|
|
50
|
+
shellEscape: 'allow',
|
|
51
|
+
network: 'open',
|
|
52
|
+
processLimits: true,
|
|
53
|
+
commit: 'auto',
|
|
54
|
+
onClose: 'commit',
|
|
55
|
+
effects: 'engine',
|
|
56
|
+
shellJournal: 'snapshot',
|
|
57
|
+
},
|
|
58
|
+
untrusted: {
|
|
59
|
+
mode: 'untrusted',
|
|
60
|
+
toolIsolation: 'session-subdir',
|
|
61
|
+
pathContainment: 'strict',
|
|
62
|
+
shellEscape: 'deny',
|
|
63
|
+
network: 'deny',
|
|
64
|
+
processLimits: true,
|
|
65
|
+
commit: 'auto',
|
|
66
|
+
onClose: 'discard',
|
|
67
|
+
effects: 'engine',
|
|
68
|
+
shellJournal: 'snapshot',
|
|
69
|
+
},
|
|
70
|
+
};
|
|
71
|
+
/**
|
|
72
|
+
* 展开 effectPolicy 为有效策略
|
|
73
|
+
*
|
|
74
|
+
* @param config - 用户配置(mode 可省略,缺省 `DEFAULT_EFFECT_RUN_MODE`)
|
|
75
|
+
* @param baseWorkspace - 工具基路径(agent.workspace / RunConfig.cwd)
|
|
76
|
+
* @returns 有效策略
|
|
77
|
+
*/
|
|
78
|
+
/**
|
|
79
|
+
* Expand effectPolicy into an effective policy.
|
|
80
|
+
*
|
|
81
|
+
* `untrusted` requires an L4 process profile. When the host cannot offer it:
|
|
82
|
+
* - `untrustedAdmission: 'refuse'` (default) throws
|
|
83
|
+
* - `untrustedAdmission: 'degrade'` renames effectiveMode to workspace,
|
|
84
|
+
* sets toolSurface=reduced, and records securityDegraded[] (never silent)
|
|
85
|
+
*
|
|
86
|
+
* @param config - user config (mode optional)
|
|
87
|
+
* @param baseWorkspace - tool base path
|
|
88
|
+
* @param isolation - probed process isolation (optional; treated as supervised if absent)
|
|
89
|
+
* @returns effective policy with requested vs effective mode
|
|
90
|
+
* @throws Error when untrusted is refused
|
|
91
|
+
*/
|
|
92
|
+
export function resolveEffectiveEffectPolicy(config, baseWorkspace, isolation) {
|
|
93
|
+
const requestedMode = config.mode ?? DEFAULT_EFFECT_RUN_MODE;
|
|
94
|
+
const untrustedAdmission = config.untrustedAdmission ?? 'refuse';
|
|
95
|
+
let mode = requestedMode;
|
|
96
|
+
let toolSurface = 'full';
|
|
97
|
+
const securityDegraded = [];
|
|
98
|
+
if (requestedMode === 'untrusted') {
|
|
99
|
+
const profile = isolation;
|
|
100
|
+
const l4 = profile ? assessL4ProcessMinimum(profile) : { ok: false, missing: ['processTree'] };
|
|
101
|
+
if (!l4.ok) {
|
|
102
|
+
if (untrustedAdmission === 'refuse') {
|
|
103
|
+
throw new Error(`untrusted_refused: L4 process jail unavailable (missing: ${l4.missing.join(', ')}). ` +
|
|
104
|
+
`Install bwrap/sandbox-exec or set effectPolicy.untrustedAdmission=degrade.`);
|
|
105
|
+
}
|
|
106
|
+
// degrade: rename + strip power, do not keep the untrusted label
|
|
107
|
+
mode = 'workspace';
|
|
108
|
+
toolSurface = 'reduced';
|
|
109
|
+
securityDegraded.push('no_process_jail');
|
|
110
|
+
if (profile?.filesystem === 'none' || profile?.filesystem === 'cwd-pin') {
|
|
111
|
+
securityDegraded.push('filesystem_not_jailed');
|
|
112
|
+
}
|
|
113
|
+
if (profile?.privilege === 'same')
|
|
114
|
+
securityDegraded.push('privilege_same');
|
|
115
|
+
if (profile?.envHygiene === 'inherit')
|
|
116
|
+
securityDegraded.push('env_inherit');
|
|
117
|
+
}
|
|
118
|
+
// Declare open egress whenever the host cannot close it — not only when
|
|
119
|
+
// effective mode is still named untrusted (degrade renames mode first).
|
|
120
|
+
if (isolation?.network === 'open') {
|
|
121
|
+
securityDegraded.push('network_open');
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
// Path jail is part of the untrusted promise; never loosen it from config.
|
|
125
|
+
const d = MODE_DEFAULTS[mode];
|
|
126
|
+
const pathContainment = requestedMode === 'untrusted'
|
|
127
|
+
? 'strict'
|
|
128
|
+
: (config.pathContainment ?? d.pathContainment);
|
|
129
|
+
// untrusted intent residue: keep discard-on-close even when effectiveMode renames
|
|
130
|
+
const onClose = config.onClose ??
|
|
131
|
+
(requestedMode === 'untrusted' ? MODE_DEFAULTS.untrusted.onClose : d.onClose);
|
|
132
|
+
const extra = (config.transactionRoots ?? []).map((p) => p.trim()).filter(Boolean);
|
|
133
|
+
const allowRoots = [...(baseWorkspace?.trim() ? [baseWorkspace.trim()] : []), ...extra];
|
|
134
|
+
return {
|
|
135
|
+
requestedMode,
|
|
136
|
+
mode,
|
|
137
|
+
untrustedAdmission,
|
|
138
|
+
toolSurface,
|
|
139
|
+
securityDegraded,
|
|
140
|
+
toolIsolation: config.toolIsolation ?? d.toolIsolation,
|
|
141
|
+
pathContainment,
|
|
142
|
+
// degraded untrusted must not leave shell allow as a hole
|
|
143
|
+
shellEscape: toolSurface === 'reduced' ? 'deny' : (config.shellEscape ?? d.shellEscape),
|
|
144
|
+
// untrusted product promise: egress deny is not a config knob (like pathContainment)
|
|
145
|
+
network: requestedMode === 'untrusted' || toolSurface === 'reduced'
|
|
146
|
+
? 'deny'
|
|
147
|
+
: (config.network ?? d.network),
|
|
148
|
+
processLimits: config.processLimits ?? d.processLimits,
|
|
149
|
+
commit: config.commit ?? d.commit,
|
|
150
|
+
onClose,
|
|
151
|
+
effects: config.effects ?? d.effects,
|
|
152
|
+
allowRoots,
|
|
153
|
+
transactionRoots: [
|
|
154
|
+
'workspace',
|
|
155
|
+
'memory',
|
|
156
|
+
...extra.map(() => 'host'),
|
|
157
|
+
],
|
|
158
|
+
undoLimit: config.undoLimit,
|
|
159
|
+
shellJournal: config.shellJournal ?? 'snapshot',
|
|
160
|
+
shellJournalLimit: config.shellJournalLimit,
|
|
161
|
+
};
|
|
162
|
+
}
|
|
163
|
+
/**
|
|
164
|
+
* Whether a tool is on the reduced surface (untrusted degrade).
|
|
165
|
+
* Reduced keeps content tools inside L2; strips egress and code-exec power.
|
|
166
|
+
*
|
|
167
|
+
* @param toolName - registered tool name
|
|
168
|
+
* @param surface - full or reduced
|
|
169
|
+
* @returns whether the tool may run
|
|
170
|
+
*/
|
|
171
|
+
export function isToolAllowedOnSurface(toolName, surface, capabilities) {
|
|
172
|
+
if (surface === 'full')
|
|
173
|
+
return true;
|
|
174
|
+
// D5-a: capability tags, not names. Unknown on reduced = reject (unknown-reject).
|
|
175
|
+
const caps = resolveToolCapabilities(toolName, capabilities);
|
|
176
|
+
if (caps === null)
|
|
177
|
+
return false;
|
|
178
|
+
return !deniesReducedSurface(caps);
|
|
179
|
+
}
|
|
180
|
+
/**
|
|
181
|
+
* L2:路径是否落在 allowRoots 内
|
|
182
|
+
*
|
|
183
|
+
* @param resolved - 已 resolve 的绝对路径
|
|
184
|
+
* @param allowRoots - 允许根
|
|
185
|
+
* @param containment - 级别;none 一律放行;soft 仅用于审计(由调用方记日志)
|
|
186
|
+
* @returns 是否允许
|
|
187
|
+
*/
|
|
188
|
+
export function isPathAllowed(resolved, allowRoots, containment) {
|
|
189
|
+
if (containment === 'none')
|
|
190
|
+
return true;
|
|
191
|
+
if (allowRoots.length === 0)
|
|
192
|
+
return containment !== 'strict';
|
|
193
|
+
const norm = (p) => p.replace(/\\/g, '/').replace(/\/+$/, '');
|
|
194
|
+
const win = process.platform === 'win32';
|
|
195
|
+
const target = win ? norm(resolved).toLowerCase() : norm(resolved);
|
|
196
|
+
return allowRoots.some((root) => {
|
|
197
|
+
const r = win ? norm(root).toLowerCase() : norm(root);
|
|
198
|
+
return target === r || target.startsWith(r + '/');
|
|
199
|
+
});
|
|
200
|
+
}
|
|
201
|
+
/**
|
|
202
|
+
* 效应闸(P4):事务内自动放行;host-gate 交给宿主;engine 通道按内置策略。
|
|
203
|
+
*
|
|
204
|
+
* @param intent - 效应意图
|
|
205
|
+
* @param options - 通道与回调
|
|
206
|
+
* @throws Error 当拒绝执行时
|
|
207
|
+
*/
|
|
208
|
+
export async function gateEffect(intent, options) {
|
|
209
|
+
// 可事务化(可 undo)→ 自动
|
|
210
|
+
if (intent.kind === 'memory.write' && intent.transactional)
|
|
211
|
+
return;
|
|
212
|
+
if (intent.kind === 'file.write' && intent.transactional)
|
|
213
|
+
return;
|
|
214
|
+
if (intent.kind === 'shell') {
|
|
215
|
+
const esc = options.shellEscape ?? 'allow';
|
|
216
|
+
// deny:无 L4 无法只禁越界,必须拒绝 shell(fail-closed,保策略语义)
|
|
217
|
+
if (esc === 'deny') {
|
|
218
|
+
throw new Error('shell_denied: shellEscape=deny (cannot contain shell escapes until L4; use mode=project|host or shellEscape=allow|confirm)');
|
|
219
|
+
}
|
|
220
|
+
// confirm:必须走 host-gate
|
|
221
|
+
if (esc === 'confirm' && options.effects !== 'host-gate') {
|
|
222
|
+
throw new Error('shell_confirm_required: shellEscape=confirm requires effectPolicy.effects=host-gate + confirmEffect');
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
// `runner` / `vcs` are dedicated allowlisted tools, not arbitrary shell.
|
|
226
|
+
// shellEscape gates the shell tool only — workspace stays capable of git/project scripts.
|
|
227
|
+
if (options.effects !== 'host-gate') {
|
|
228
|
+
// engine 通道:路径牢笼由 L2 承担;shell 已在上方按 shellEscape 处理
|
|
229
|
+
return;
|
|
230
|
+
}
|
|
231
|
+
// host-gate:非事务效应交给宿主(自动放行 / 宿主 UI / 策略引擎)
|
|
232
|
+
const decide = options.confirmEffect;
|
|
233
|
+
if (!decide) {
|
|
234
|
+
throw new Error('confirm_effect_missing: effectPolicy.effects=host-gate requires confirmEffect callback');
|
|
235
|
+
}
|
|
236
|
+
// SEC-7:HitlDecision + 引擎缓存;失败路径 fail-closed
|
|
237
|
+
const allowed = await resolveHitlDecision({
|
|
238
|
+
cache: options.hitlCache,
|
|
239
|
+
channel: 'effect',
|
|
240
|
+
key: intent.kind,
|
|
241
|
+
sessionId: options.sessionId ?? getRunSessionId(),
|
|
242
|
+
agentId: options.agentId ?? getRunScope()?.agentId,
|
|
243
|
+
ask: () => decide(intent),
|
|
244
|
+
});
|
|
245
|
+
if (!allowed) {
|
|
246
|
+
throw new Error(`effect_denied: ${intent.kind}`);
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
const EFFECT_OVERRIDES_META_KEY = 'effectOverrides';
|
|
250
|
+
/**
|
|
251
|
+
* Parse `session.metadata.effectOverrides` safely (read path).
|
|
252
|
+
*
|
|
253
|
+
* Invalid entries are **skipped**, not thrown: a poisoned/corrupt metadata bag
|
|
254
|
+
* must not abort run start. Strict validation belongs on the write API
|
|
255
|
+
* (`normalizeTransactionRoots`).
|
|
256
|
+
*
|
|
257
|
+
* @param metadata - session metadata bag
|
|
258
|
+
* @returns valid absolute roots only (empty when absent/invalid)
|
|
259
|
+
*/
|
|
260
|
+
export function readSessionEffectOverrides(metadata) {
|
|
261
|
+
const raw = metadata?.[EFFECT_OVERRIDES_META_KEY];
|
|
262
|
+
if (!raw || typeof raw !== 'object')
|
|
263
|
+
return {};
|
|
264
|
+
const bag = raw;
|
|
265
|
+
const list = bag.transactionRoots;
|
|
266
|
+
if (!Array.isArray(list))
|
|
267
|
+
return {};
|
|
268
|
+
const out = [];
|
|
269
|
+
const seen = new Set();
|
|
270
|
+
for (const item of list) {
|
|
271
|
+
if (typeof item !== 'string')
|
|
272
|
+
continue;
|
|
273
|
+
const t = item.trim();
|
|
274
|
+
if (!t || !isAbsolute(t))
|
|
275
|
+
continue;
|
|
276
|
+
const abs = resolve(t);
|
|
277
|
+
const key = process.platform === 'win32' ? abs.toLowerCase() : abs;
|
|
278
|
+
if (seen.has(key))
|
|
279
|
+
continue;
|
|
280
|
+
seen.add(key);
|
|
281
|
+
out.push(abs);
|
|
282
|
+
}
|
|
283
|
+
return { transactionRoots: out };
|
|
284
|
+
}
|
|
285
|
+
/**
|
|
286
|
+
* Normalize and validate transaction root paths (absolute, non-empty).
|
|
287
|
+
*
|
|
288
|
+
* @param paths - raw paths
|
|
289
|
+
* @returns absolute normalized unique paths
|
|
290
|
+
* @throws Error when a path is empty or not absolute
|
|
291
|
+
*/
|
|
292
|
+
export function normalizeTransactionRoots(paths) {
|
|
293
|
+
const out = [];
|
|
294
|
+
const seen = new Set();
|
|
295
|
+
for (const raw of paths) {
|
|
296
|
+
const t = typeof raw === 'string' ? raw.trim() : '';
|
|
297
|
+
if (!t)
|
|
298
|
+
throw new Error('effect_root_empty: path must be a non-empty string');
|
|
299
|
+
// Require caller-supplied absolute paths (do not silently join cwd)
|
|
300
|
+
if (!isAbsolute(t)) {
|
|
301
|
+
throw new Error(`effect_root_not_absolute: ${t}`);
|
|
302
|
+
}
|
|
303
|
+
const abs = resolve(t);
|
|
304
|
+
const key = process.platform === 'win32' ? abs.toLowerCase() : abs;
|
|
305
|
+
if (seen.has(key))
|
|
306
|
+
continue;
|
|
307
|
+
seen.add(key);
|
|
308
|
+
out.push(abs);
|
|
309
|
+
}
|
|
310
|
+
return out;
|
|
311
|
+
}
|
|
312
|
+
/**
|
|
313
|
+
* Append session roots to base allowRoots (dedupe; base wins on conflicts).
|
|
314
|
+
*
|
|
315
|
+
* @param baseRoots - roots from effectPolicy / workspace
|
|
316
|
+
* @param extraRoots - session temporary roots
|
|
317
|
+
* @returns combined unique list
|
|
318
|
+
*/
|
|
319
|
+
export function mergeTransactionRoots(baseRoots, extraRoots) {
|
|
320
|
+
const out = [...baseRoots];
|
|
321
|
+
const seen = new Set(out.map((p) => (process.platform === 'win32' ? p.toLowerCase() : p)));
|
|
322
|
+
for (const p of extraRoots ?? []) {
|
|
323
|
+
const key = process.platform === 'win32' ? p.toLowerCase() : p;
|
|
324
|
+
if (seen.has(key))
|
|
325
|
+
continue;
|
|
326
|
+
seen.add(key);
|
|
327
|
+
out.push(p);
|
|
328
|
+
}
|
|
329
|
+
return out;
|
|
330
|
+
}
|
|
331
|
+
/**
|
|
332
|
+
* Metadata key used on SessionData.metadata / SessionStore.updateMetadata.
|
|
333
|
+
*/
|
|
334
|
+
export const SESSION_EFFECT_OVERRIDES_KEY = EFFECT_OVERRIDES_META_KEY;
|
|
@@ -1,10 +1,26 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Execution Environment 领域 — 执行环境
|
|
3
3
|
*
|
|
4
|
-
*
|
|
4
|
+
* 职责:沙箱管理、工作区生命周期、文件操作、资源限制、turn 文件 undo(L3)。
|
|
5
5
|
* 契约见 ./types.ts。
|
|
6
6
|
*/
|
|
7
|
-
export { ProcessSandbox } from './sandbox.js';
|
|
7
|
+
export { ProcessSandbox, createProcessSandbox, assessL4ProcessMinimum, supervisedSpawnProfile, } from './sandbox.js';
|
|
8
|
+
export { probeProcessIsolation, scrubEnv, killProcessTree, L4_PROCESS_MINIMUM, } from './process-isolation.js';
|
|
9
|
+
export type { ProcessIsolationProfile, IsolationBackend, ProcessTreeIsolation, FilesystemIsolation, ResourceIsolation, NetworkIsolation, PrivilegeIsolation, EnvHygiene, L4ProcessAssessment, } from './process-isolation.js';
|
|
8
10
|
export { FileWorkspace } from './workspace.js';
|
|
9
11
|
export type { FileWorkspaceConfig } from './workspace.js';
|
|
12
|
+
export { DEFAULT_TOOL_ISOLATION, resolveToolIsolationCwd, safeSessionDirSegment, looksLikeAbsoluteSessionPath, } from './isolation.js';
|
|
13
|
+
export type { ToolIsolationMode, ResolveToolIsolationCwdInput, ResolveToolIsolationCwdResult, } from './isolation.js';
|
|
14
|
+
export { TurnFileUndoLog, commitSessionFileUndo, discardSessionFileUndo, resolveSessionUndoPaths, resolveSessionUndoOnClose, } from './undo-log.js';
|
|
15
|
+
export type { SessionUndoPaths, FileUndoEntry, DiscardFileEffectsResult, DiscardConflictReason, } from './undo-log.js';
|
|
16
|
+
export { isProbablyText, reverseAgentOverwrite, merge3Lines } from './undo-merge.js';
|
|
17
|
+
export { snapshotShellRoots, captureShellInventory, diffShellInventory, journalShellDiff, writeNotReversed, } from './shell-journal.js';
|
|
18
|
+
export { resolveEffectiveEffectPolicy, isPathAllowed, isToolAllowedOnSurface, gateEffect, DEFAULT_EFFECT_RUN_MODE, readSessionEffectOverrides, normalizeTransactionRoots, mergeTransactionRoots, SESSION_EFFECT_OVERRIDES_KEY, } from './effect-policy.js';
|
|
19
|
+
export type { UntrustedAdmission, ToolSurface, SecurityDegradation, EffectiveEffectPolicy, SessionEffectOverrides, } from './effect-policy.js';
|
|
20
|
+
export { runWithToolLimits, resolveToolTimeoutMs, ToolTimeoutError, } from './resource-limits.js';
|
|
21
|
+
export type { ToolRunLimits } from './resource-limits.js';
|
|
22
|
+
export { TurnMemoryJournal, JournaledMemoryStore, createMemoryRestorer, discardMemoryUndo, } from './memory-undo.js';
|
|
23
|
+
export type { MemoryUndoEntry, MemoryEffectRestorer, DiscardMemoryEffectsResult, } from './memory-undo.js';
|
|
10
24
|
export type { IsolationLevel, SandboxConfig, ResourceLimits, ResourceUsage, SandboxResult, SandboxProvider, WorkspaceConfig, WorkspaceSnapshot, Workspace, SearchOptions, FileMatch, } from './types.js';
|
|
25
|
+
export { resolveToolCapabilities, deniesReducedSurface, BUILTIN_TOOL_CAPABILITIES, REDUCED_DENIED_CAPABILITIES, } from './tool-capabilities.js';
|
|
26
|
+
export type { ToolCapability } from './tool-capabilities.js';
|
|
@@ -1,8 +1,17 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Execution Environment 领域 — 执行环境
|
|
3
3
|
*
|
|
4
|
-
*
|
|
4
|
+
* 职责:沙箱管理、工作区生命周期、文件操作、资源限制、turn 文件 undo(L3)。
|
|
5
5
|
* 契约见 ./types.ts。
|
|
6
6
|
*/
|
|
7
|
-
export { ProcessSandbox } from './sandbox.js';
|
|
7
|
+
export { ProcessSandbox, createProcessSandbox, assessL4ProcessMinimum, supervisedSpawnProfile, } from './sandbox.js';
|
|
8
|
+
export { probeProcessIsolation, scrubEnv, killProcessTree, L4_PROCESS_MINIMUM, } from './process-isolation.js';
|
|
8
9
|
export { FileWorkspace } from './workspace.js';
|
|
10
|
+
export { DEFAULT_TOOL_ISOLATION, resolveToolIsolationCwd, safeSessionDirSegment, looksLikeAbsoluteSessionPath, } from './isolation.js';
|
|
11
|
+
export { TurnFileUndoLog, commitSessionFileUndo, discardSessionFileUndo, resolveSessionUndoPaths, resolveSessionUndoOnClose, } from './undo-log.js';
|
|
12
|
+
export { isProbablyText, reverseAgentOverwrite, merge3Lines } from './undo-merge.js';
|
|
13
|
+
export { snapshotShellRoots, captureShellInventory, diffShellInventory, journalShellDiff, writeNotReversed, } from './shell-journal.js';
|
|
14
|
+
export { resolveEffectiveEffectPolicy, isPathAllowed, isToolAllowedOnSurface, gateEffect, DEFAULT_EFFECT_RUN_MODE, readSessionEffectOverrides, normalizeTransactionRoots, mergeTransactionRoots, SESSION_EFFECT_OVERRIDES_KEY, } from './effect-policy.js';
|
|
15
|
+
export { runWithToolLimits, resolveToolTimeoutMs, ToolTimeoutError, } from './resource-limits.js';
|
|
16
|
+
export { TurnMemoryJournal, JournaledMemoryStore, createMemoryRestorer, discardMemoryUndo, } from './memory-undo.js';
|
|
17
|
+
export { resolveToolCapabilities, deniesReducedSurface, BUILTIN_TOOL_CAPABILITIES, REDUCED_DENIED_CAPABILITIES, } from './tool-capabilities.js';
|