@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,101 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Turn 记忆面 undo(ToolEffectPolicy L3 P2)
|
|
3
|
+
*
|
|
4
|
+
* 与文件 undo 同目录(`sessions/<sid>/undo/memory.jsonl`)。
|
|
5
|
+
* 只覆盖 **本轮 run 作用域内** 经 store 写口的效应;steward 异步写不进 journal。
|
|
6
|
+
* knowledge 不在此列(非事务)。
|
|
7
|
+
*/
|
|
8
|
+
import type { MemoryEffectDomain, MemoryEffectJournal } from '@octopi-agent/core/types/tools.js';
|
|
9
|
+
import type { MemoryEntry, MemoryStore } from '../../memory/types.js';
|
|
10
|
+
/** 记忆面 undo 条目 */
|
|
11
|
+
export type MemoryUndoEntry = {
|
|
12
|
+
op: 'insert';
|
|
13
|
+
domain: MemoryEffectDomain;
|
|
14
|
+
id: string;
|
|
15
|
+
} | {
|
|
16
|
+
op: 'update';
|
|
17
|
+
domain: MemoryEffectDomain;
|
|
18
|
+
id: string;
|
|
19
|
+
before: unknown;
|
|
20
|
+
} | {
|
|
21
|
+
op: 'delete';
|
|
22
|
+
domain: MemoryEffectDomain;
|
|
23
|
+
id: string;
|
|
24
|
+
before: unknown;
|
|
25
|
+
};
|
|
26
|
+
/** 记忆面逆放执行器(由 store 提供) */
|
|
27
|
+
export interface MemoryEffectRestorer {
|
|
28
|
+
/** 逆放 insert:按 id 删除 */
|
|
29
|
+
deleteById(domain: MemoryEffectDomain, id: string): Promise<void>;
|
|
30
|
+
/** 逆放 update/delete:恢复 before 整行(同 id) */
|
|
31
|
+
restoreRow(domain: MemoryEffectDomain, id: string, before: unknown): Promise<void>;
|
|
32
|
+
}
|
|
33
|
+
export interface DiscardMemoryEffectsResult {
|
|
34
|
+
reversed: Array<{
|
|
35
|
+
domain: MemoryEffectDomain;
|
|
36
|
+
id: string;
|
|
37
|
+
op: MemoryUndoEntry['op'];
|
|
38
|
+
}>;
|
|
39
|
+
failed: Array<{
|
|
40
|
+
domain: MemoryEffectDomain;
|
|
41
|
+
id: string;
|
|
42
|
+
reason: string;
|
|
43
|
+
}>;
|
|
44
|
+
entries: number;
|
|
45
|
+
}
|
|
46
|
+
/** 本轮记忆 journal 写入端 */
|
|
47
|
+
export declare class TurnMemoryJournal implements MemoryEffectJournal {
|
|
48
|
+
private readonly entries;
|
|
49
|
+
private sealed;
|
|
50
|
+
private readonly logPath;
|
|
51
|
+
private flushChain;
|
|
52
|
+
constructor(undoRoot: string);
|
|
53
|
+
get size(): number;
|
|
54
|
+
recordInsert(domain: MemoryEffectDomain, id: string): Promise<void>;
|
|
55
|
+
recordUpdate(domain: MemoryEffectDomain, id: string, before: unknown): Promise<void>;
|
|
56
|
+
recordDelete(domain: MemoryEffectDomain, id: string, before: unknown): Promise<void>;
|
|
57
|
+
private append;
|
|
58
|
+
private flush;
|
|
59
|
+
private doFlush;
|
|
60
|
+
seal(): void;
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* 逆放记忆效应(编辑重发)。按记录逆序执行。
|
|
64
|
+
*
|
|
65
|
+
* @param undoRoot - `sessions/<sid>/undo`
|
|
66
|
+
* @param restorer - store 逆放器;缺失时全部记 failed
|
|
67
|
+
* @returns 逆放结果
|
|
68
|
+
*/
|
|
69
|
+
export declare function discardMemoryUndo(undoRoot: string, restorer?: MemoryEffectRestorer): Promise<DiscardMemoryEffectsResult>;
|
|
70
|
+
/**
|
|
71
|
+
* MemoryStore 装饰器:写口记 journal(RunScope ALS 提供)。
|
|
72
|
+
* 无活跃 journal 时写入照常(steward / turn 外),不记 undo。
|
|
73
|
+
*/
|
|
74
|
+
export declare class JournaledMemoryStore implements MemoryStore {
|
|
75
|
+
private readonly inner;
|
|
76
|
+
private readonly journalSource;
|
|
77
|
+
readonly name: string;
|
|
78
|
+
constructor(inner: MemoryStore, journalSource: () => MemoryEffectJournal | undefined);
|
|
79
|
+
store(entry: Omit<MemoryEntry, 'id' | 'accessCount' | 'lastAccessedAt' | 'createdAt' | 'decayFactor'>): Promise<string>;
|
|
80
|
+
retrieve: MemoryStore['retrieve'];
|
|
81
|
+
get(id: string): Promise<MemoryEntry | null>;
|
|
82
|
+
update(id: string, patch: Partial<MemoryEntry>): Promise<void>;
|
|
83
|
+
delete(id: string): Promise<void>;
|
|
84
|
+
softDelete(id: string, meta: {
|
|
85
|
+
by: string;
|
|
86
|
+
reason: string;
|
|
87
|
+
winnerId?: string;
|
|
88
|
+
}): Promise<void>;
|
|
89
|
+
undelete(id: string): Promise<void>;
|
|
90
|
+
importEntry(entry: MemoryEntry): Promise<void>;
|
|
91
|
+
listForGovern: MemoryStore['listForGovern'];
|
|
92
|
+
decay: MemoryStore['decay'];
|
|
93
|
+
stats: MemoryStore['stats'];
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* 由 MemoryStore 实现 restorer(编辑重发逆放)。
|
|
97
|
+
*
|
|
98
|
+
* @param store - 记忆 store
|
|
99
|
+
* @returns restorer
|
|
100
|
+
*/
|
|
101
|
+
export declare function createMemoryRestorer(store: MemoryStore): MemoryEffectRestorer;
|
|
@@ -0,0 +1,192 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Turn 记忆面 undo(ToolEffectPolicy L3 P2)
|
|
3
|
+
*
|
|
4
|
+
* 与文件 undo 同目录(`sessions/<sid>/undo/memory.jsonl`)。
|
|
5
|
+
* 只覆盖 **本轮 run 作用域内** 经 store 写口的效应;steward 异步写不进 journal。
|
|
6
|
+
* knowledge 不在此列(非事务)。
|
|
7
|
+
*/
|
|
8
|
+
import { mkdir, readFile, rm, writeFile } from 'node:fs/promises';
|
|
9
|
+
import { join } from 'node:path';
|
|
10
|
+
function memoryLogPath(undoRoot) {
|
|
11
|
+
return join(undoRoot, 'memory.jsonl');
|
|
12
|
+
}
|
|
13
|
+
/** 本轮记忆 journal 写入端 */
|
|
14
|
+
export class TurnMemoryJournal {
|
|
15
|
+
entries = [];
|
|
16
|
+
sealed = false;
|
|
17
|
+
logPath;
|
|
18
|
+
flushChain = Promise.resolve();
|
|
19
|
+
constructor(undoRoot) {
|
|
20
|
+
this.logPath = memoryLogPath(undoRoot);
|
|
21
|
+
}
|
|
22
|
+
get size() {
|
|
23
|
+
return this.entries.length;
|
|
24
|
+
}
|
|
25
|
+
async recordInsert(domain, id) {
|
|
26
|
+
this.append({ op: 'insert', domain, id });
|
|
27
|
+
await this.flush();
|
|
28
|
+
}
|
|
29
|
+
async recordUpdate(domain, id, before) {
|
|
30
|
+
this.append({ op: 'update', domain, id, before });
|
|
31
|
+
await this.flush();
|
|
32
|
+
}
|
|
33
|
+
async recordDelete(domain, id, before) {
|
|
34
|
+
this.append({ op: 'delete', domain, id, before });
|
|
35
|
+
await this.flush();
|
|
36
|
+
}
|
|
37
|
+
append(entry) {
|
|
38
|
+
if (this.sealed) {
|
|
39
|
+
throw new Error('turn memory undo journal already sealed');
|
|
40
|
+
}
|
|
41
|
+
this.entries.push(entry);
|
|
42
|
+
}
|
|
43
|
+
flush() {
|
|
44
|
+
this.flushChain = this.flushChain.then(() => this.doFlush()).catch(() => undefined);
|
|
45
|
+
return this.flushChain;
|
|
46
|
+
}
|
|
47
|
+
async doFlush() {
|
|
48
|
+
await mkdir(join(this.logPath, '..'), { recursive: true });
|
|
49
|
+
const body = this.entries.map((e) => JSON.stringify(e)).join('\n');
|
|
50
|
+
await writeFile(this.logPath, body + (this.entries.length ? '\n' : ''), 'utf8');
|
|
51
|
+
}
|
|
52
|
+
seal() {
|
|
53
|
+
this.sealed = true;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* 逆放记忆效应(编辑重发)。按记录逆序执行。
|
|
58
|
+
*
|
|
59
|
+
* @param undoRoot - `sessions/<sid>/undo`
|
|
60
|
+
* @param restorer - store 逆放器;缺失时全部记 failed
|
|
61
|
+
* @returns 逆放结果
|
|
62
|
+
*/
|
|
63
|
+
export async function discardMemoryUndo(undoRoot, restorer) {
|
|
64
|
+
const result = { reversed: [], failed: [], entries: 0 };
|
|
65
|
+
const path = memoryLogPath(undoRoot);
|
|
66
|
+
let raw;
|
|
67
|
+
try {
|
|
68
|
+
raw = await readFile(path, 'utf8');
|
|
69
|
+
}
|
|
70
|
+
catch {
|
|
71
|
+
return result;
|
|
72
|
+
}
|
|
73
|
+
const entries = raw
|
|
74
|
+
.split('\n')
|
|
75
|
+
.filter((l) => l.trim())
|
|
76
|
+
.map((l) => JSON.parse(l));
|
|
77
|
+
result.entries = entries.length;
|
|
78
|
+
for (const entry of [...entries].reverse()) {
|
|
79
|
+
if (!restorer) {
|
|
80
|
+
result.failed.push({ domain: entry.domain, id: entry.id, reason: 'memory_restorer_missing' });
|
|
81
|
+
continue;
|
|
82
|
+
}
|
|
83
|
+
try {
|
|
84
|
+
if (entry.op === 'insert') {
|
|
85
|
+
await restorer.deleteById(entry.domain, entry.id);
|
|
86
|
+
}
|
|
87
|
+
else {
|
|
88
|
+
await restorer.restoreRow(entry.domain, entry.id, entry.before);
|
|
89
|
+
}
|
|
90
|
+
result.reversed.push({ domain: entry.domain, id: entry.id, op: entry.op });
|
|
91
|
+
}
|
|
92
|
+
catch (err) {
|
|
93
|
+
result.failed.push({
|
|
94
|
+
domain: entry.domain,
|
|
95
|
+
id: entry.id,
|
|
96
|
+
reason: err instanceof Error ? err.message : String(err),
|
|
97
|
+
});
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
await rm(path, { force: true });
|
|
101
|
+
return result;
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* MemoryStore 装饰器:写口记 journal(RunScope ALS 提供)。
|
|
105
|
+
* 无活跃 journal 时写入照常(steward / turn 外),不记 undo。
|
|
106
|
+
*/
|
|
107
|
+
export class JournaledMemoryStore {
|
|
108
|
+
inner;
|
|
109
|
+
journalSource;
|
|
110
|
+
name;
|
|
111
|
+
constructor(inner, journalSource) {
|
|
112
|
+
this.inner = inner;
|
|
113
|
+
this.journalSource = journalSource;
|
|
114
|
+
this.name = inner.name;
|
|
115
|
+
}
|
|
116
|
+
async store(entry) {
|
|
117
|
+
const id = await this.inner.store(entry);
|
|
118
|
+
await this.journalSource()?.recordInsert('memory', id);
|
|
119
|
+
return id;
|
|
120
|
+
}
|
|
121
|
+
retrieve = (query) => this.inner.retrieve(query);
|
|
122
|
+
get(id) {
|
|
123
|
+
return this.inner.get(id);
|
|
124
|
+
}
|
|
125
|
+
async update(id, patch) {
|
|
126
|
+
const before = await this.inner.get(id);
|
|
127
|
+
await this.inner.update(id, patch);
|
|
128
|
+
if (before)
|
|
129
|
+
await this.journalSource()?.recordUpdate('memory', id, before);
|
|
130
|
+
}
|
|
131
|
+
async delete(id) {
|
|
132
|
+
const before = await this.inner.get(id);
|
|
133
|
+
await this.inner.delete(id);
|
|
134
|
+
if (before)
|
|
135
|
+
await this.journalSource()?.recordDelete('memory', id, before);
|
|
136
|
+
}
|
|
137
|
+
async softDelete(id, meta) {
|
|
138
|
+
const before = await this.inner.get(id);
|
|
139
|
+
await this.inner.softDelete(id, meta);
|
|
140
|
+
if (before)
|
|
141
|
+
await this.journalSource()?.recordUpdate('memory', id, before);
|
|
142
|
+
}
|
|
143
|
+
async undelete(id) {
|
|
144
|
+
const before = await this.inner.get(id);
|
|
145
|
+
await this.inner.undelete(id);
|
|
146
|
+
if (before)
|
|
147
|
+
await this.journalSource()?.recordUpdate('memory', id, before);
|
|
148
|
+
}
|
|
149
|
+
async importEntry(entry) {
|
|
150
|
+
const withImport = this.inner;
|
|
151
|
+
if (withImport.importEntry) {
|
|
152
|
+
await withImport.importEntry(entry);
|
|
153
|
+
await this.journalSource()?.recordInsert('memory', entry.id);
|
|
154
|
+
return;
|
|
155
|
+
}
|
|
156
|
+
throw new Error('importEntry_not_supported');
|
|
157
|
+
}
|
|
158
|
+
listForGovern = (filter) => this.inner.listForGovern(filter);
|
|
159
|
+
decay = (options) => this.inner.decay(options);
|
|
160
|
+
stats = () => this.inner.stats();
|
|
161
|
+
}
|
|
162
|
+
/**
|
|
163
|
+
* 由 MemoryStore 实现 restorer(编辑重发逆放)。
|
|
164
|
+
*
|
|
165
|
+
* @param store - 记忆 store
|
|
166
|
+
* @returns restorer
|
|
167
|
+
*/
|
|
168
|
+
export function createMemoryRestorer(store) {
|
|
169
|
+
return {
|
|
170
|
+
async deleteById(_domain, id) {
|
|
171
|
+
await store.delete(id);
|
|
172
|
+
},
|
|
173
|
+
async restoreRow(_domain, id, before) {
|
|
174
|
+
const row = before;
|
|
175
|
+
const existing = await store.get(id);
|
|
176
|
+
if (existing) {
|
|
177
|
+
await store.update(id, row);
|
|
178
|
+
// softDelete 痕迹:before 未删而 current 已删 → undelete
|
|
179
|
+
if (!row.deleted && existing.deleted) {
|
|
180
|
+
await store.undelete(id);
|
|
181
|
+
}
|
|
182
|
+
return;
|
|
183
|
+
}
|
|
184
|
+
const withImport = store;
|
|
185
|
+
if (withImport.importEntry) {
|
|
186
|
+
await withImport.importEntry({ ...row, id });
|
|
187
|
+
return;
|
|
188
|
+
}
|
|
189
|
+
throw new Error(`cannot_restore_memory_row:${id}`);
|
|
190
|
+
},
|
|
191
|
+
};
|
|
192
|
+
}
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Process isolation capability contract (L4 process tier).
|
|
3
|
+
*
|
|
4
|
+
* A process jail is a capability profile, not a single OS API. Backends declare
|
|
5
|
+
* what they actually enforce; consumers must trust the profile, never the name.
|
|
6
|
+
* Public contract: `docs/process-isolation.md`.
|
|
7
|
+
*/
|
|
8
|
+
import { type ChildProcess } from 'node:child_process';
|
|
9
|
+
/** Kill semantics for the process tree */
|
|
10
|
+
export type ProcessTreeIsolation = 'supervised' | 'killable' | 'contained';
|
|
11
|
+
/** Filesystem confinement for writes */
|
|
12
|
+
export type FilesystemIsolation = 'none' | 'cwd-pin' | 'write-jailed' | 'write-jailed-best-effort' | 'root-jailed';
|
|
13
|
+
/** Resource enforcement quality */
|
|
14
|
+
export type ResourceIsolation = 'none' | 'best-effort' | 'os-enforced';
|
|
15
|
+
/** Egress posture (not part of L4 process minimum) */
|
|
16
|
+
export type NetworkIsolation = 'open' | 'deny' | 'allowlist';
|
|
17
|
+
/**
|
|
18
|
+
* Privilege of the child.
|
|
19
|
+
* `dropped` = the jail **denies privilege-gaining OS operations**
|
|
20
|
+
* (user namespace and/or Seatbelt `process-exec` denials for sudo/su/…).
|
|
21
|
+
* This does **not** require a different uid — `notes` must record which
|
|
22
|
+
* mechanism applies (`userns` vs `ops-denied`).
|
|
23
|
+
*/
|
|
24
|
+
export type PrivilegeIsolation = 'same' | 'dropped';
|
|
25
|
+
/** Whether host secrets can ride along in the environment */
|
|
26
|
+
export type EnvHygiene = 'inherit' | 'scrubbed';
|
|
27
|
+
/** Which backend produced the profile */
|
|
28
|
+
export type IsolationBackend = 'supervised-spawn' | 'linux-bwrap' | 'mac-seatbelt' | 'win-job' | 'container';
|
|
29
|
+
/** Honest isolation report for one execute/probe */
|
|
30
|
+
export interface ProcessIsolationProfile {
|
|
31
|
+
backend: IsolationBackend;
|
|
32
|
+
processTree: ProcessTreeIsolation;
|
|
33
|
+
filesystem: FilesystemIsolation;
|
|
34
|
+
resources: ResourceIsolation;
|
|
35
|
+
network: NetworkIsolation;
|
|
36
|
+
privilege: PrivilegeIsolation;
|
|
37
|
+
envHygiene: EnvHygiene;
|
|
38
|
+
/** Free-form capability notes for operators (e.g. missing bwrap) */
|
|
39
|
+
notes?: string[];
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* L4 process minimum (network is intentionally NOT required).
|
|
43
|
+
* `filesystem: write-jailed-best-effort` counts as meeting the floor (Windows).
|
|
44
|
+
*/
|
|
45
|
+
export declare const L4_PROCESS_MINIMUM: {
|
|
46
|
+
readonly processTree: ProcessTreeIsolation[];
|
|
47
|
+
readonly filesystem: FilesystemIsolation[];
|
|
48
|
+
readonly resources: ResourceIsolation[];
|
|
49
|
+
readonly envHygiene: EnvHygiene[];
|
|
50
|
+
readonly privilege: PrivilegeIsolation[];
|
|
51
|
+
};
|
|
52
|
+
export interface L4ProcessAssessment {
|
|
53
|
+
ok: boolean;
|
|
54
|
+
missing: Array<'processTree' | 'filesystem' | 'resources' | 'envHygiene' | 'privilege'>;
|
|
55
|
+
}
|
|
56
|
+
/** @param profile - isolation profile to assess */
|
|
57
|
+
export declare function assessL4ProcessMinimum(profile: ProcessIsolationProfile): L4ProcessAssessment;
|
|
58
|
+
/**
|
|
59
|
+
* Environment allowlist. Deny-by-default: only listed keys pass through.
|
|
60
|
+
* Secrets (API keys, tokens) must never inherit via `...process.env`.
|
|
61
|
+
*
|
|
62
|
+
* @param extra - explicit env for this run (still filtered against allowlist unless force)
|
|
63
|
+
* @param options - allow forcing extra keys (host responsibility)
|
|
64
|
+
* @returns scrubbed environment
|
|
65
|
+
*/
|
|
66
|
+
export declare function scrubEnv(extra?: Record<string, string>, options?: {
|
|
67
|
+
forceKeys?: string[];
|
|
68
|
+
}): Record<string, string>;
|
|
69
|
+
/**
|
|
70
|
+
* Best-effort process-tree kill. POSIX uses the process group; Windows uses taskkill /T.
|
|
71
|
+
*
|
|
72
|
+
* @param child - spawned child
|
|
73
|
+
* @returns whether a kill signal was issued
|
|
74
|
+
*/
|
|
75
|
+
export declare function killProcessTree(child: ChildProcess): boolean;
|
|
76
|
+
/** Reset probe cache (tests). */
|
|
77
|
+
export declare function resetProcessIsolationProbeCache(): void;
|
|
78
|
+
export declare function probeProcessIsolation(): Promise<ProcessIsolationProfile>;
|
|
79
|
+
/**
|
|
80
|
+
* Synthetic supervised profile (L1 only). Used when no probe has run yet.
|
|
81
|
+
*
|
|
82
|
+
* @returns baseline profile for supervised spawn
|
|
83
|
+
*/
|
|
84
|
+
export declare function supervisedSpawnProfile(): ProcessIsolationProfile;
|
|
@@ -0,0 +1,315 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Process isolation capability contract (L4 process tier).
|
|
3
|
+
*
|
|
4
|
+
* A process jail is a capability profile, not a single OS API. Backends declare
|
|
5
|
+
* what they actually enforce; consumers must trust the profile, never the name.
|
|
6
|
+
* Public contract: `docs/process-isolation.md`.
|
|
7
|
+
*/
|
|
8
|
+
import { spawn } from 'node:child_process';
|
|
9
|
+
import { access, constants } from 'node:fs/promises';
|
|
10
|
+
import { delimiter, join } from 'node:path';
|
|
11
|
+
/**
|
|
12
|
+
* L4 process minimum (network is intentionally NOT required).
|
|
13
|
+
* `filesystem: write-jailed-best-effort` counts as meeting the floor (Windows).
|
|
14
|
+
*/
|
|
15
|
+
export const L4_PROCESS_MINIMUM = {
|
|
16
|
+
processTree: ['killable', 'contained'],
|
|
17
|
+
filesystem: [
|
|
18
|
+
'write-jailed',
|
|
19
|
+
'write-jailed-best-effort',
|
|
20
|
+
'root-jailed',
|
|
21
|
+
],
|
|
22
|
+
resources: ['best-effort', 'os-enforced'],
|
|
23
|
+
envHygiene: ['scrubbed'],
|
|
24
|
+
privilege: ['dropped'],
|
|
25
|
+
};
|
|
26
|
+
/** @param profile - isolation profile to assess */
|
|
27
|
+
export function assessL4ProcessMinimum(profile) {
|
|
28
|
+
const missing = [];
|
|
29
|
+
if (!L4_PROCESS_MINIMUM.processTree.includes(profile.processTree))
|
|
30
|
+
missing.push('processTree');
|
|
31
|
+
if (!L4_PROCESS_MINIMUM.filesystem.includes(profile.filesystem))
|
|
32
|
+
missing.push('filesystem');
|
|
33
|
+
if (!L4_PROCESS_MINIMUM.resources.includes(profile.resources))
|
|
34
|
+
missing.push('resources');
|
|
35
|
+
if (profile.envHygiene !== 'scrubbed')
|
|
36
|
+
missing.push('envHygiene');
|
|
37
|
+
if (profile.privilege !== 'dropped')
|
|
38
|
+
missing.push('privilege');
|
|
39
|
+
return { ok: missing.length === 0, missing };
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Environment allowlist. Deny-by-default: only listed keys pass through.
|
|
43
|
+
* Secrets (API keys, tokens) must never inherit via `...process.env`.
|
|
44
|
+
*
|
|
45
|
+
* @param extra - explicit env for this run (still filtered against allowlist unless force)
|
|
46
|
+
* @param options - allow forcing extra keys (host responsibility)
|
|
47
|
+
* @returns scrubbed environment
|
|
48
|
+
*/
|
|
49
|
+
export function scrubEnv(extra, options) {
|
|
50
|
+
const allow = new Set([
|
|
51
|
+
'PATH',
|
|
52
|
+
'Path',
|
|
53
|
+
'HOME',
|
|
54
|
+
'USERPROFILE',
|
|
55
|
+
'HOMEDRIVE',
|
|
56
|
+
'HOMEPATH',
|
|
57
|
+
'TMP',
|
|
58
|
+
'TEMP',
|
|
59
|
+
'TMPDIR',
|
|
60
|
+
'LANG',
|
|
61
|
+
'LC_ALL',
|
|
62
|
+
'LC_CTYPE',
|
|
63
|
+
'TZ',
|
|
64
|
+
'SHELL',
|
|
65
|
+
'TERM',
|
|
66
|
+
'COMSPEC',
|
|
67
|
+
'PATHEXT',
|
|
68
|
+
'SYSTEMROOT',
|
|
69
|
+
'SystemRoot',
|
|
70
|
+
'WINDIR',
|
|
71
|
+
'windir',
|
|
72
|
+
'USER',
|
|
73
|
+
'LOGNAME',
|
|
74
|
+
'PWD',
|
|
75
|
+
'OLDPWD',
|
|
76
|
+
'NODE_ENV',
|
|
77
|
+
].map((k) => k.toLowerCase()));
|
|
78
|
+
for (const k of options?.forceKeys ?? [])
|
|
79
|
+
allow.add(k.toLowerCase());
|
|
80
|
+
const out = {};
|
|
81
|
+
for (const [k, v] of Object.entries(extra ?? {})) {
|
|
82
|
+
if (allow.has(k.toLowerCase()))
|
|
83
|
+
out[k] = v;
|
|
84
|
+
}
|
|
85
|
+
return out;
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* Best-effort process-tree kill. POSIX uses the process group; Windows uses taskkill /T.
|
|
89
|
+
*
|
|
90
|
+
* @param child - spawned child
|
|
91
|
+
* @returns whether a kill signal was issued
|
|
92
|
+
*/
|
|
93
|
+
export function killProcessTree(child) {
|
|
94
|
+
const pid = child.pid;
|
|
95
|
+
if (typeof pid !== 'number' || pid <= 0)
|
|
96
|
+
return false;
|
|
97
|
+
try {
|
|
98
|
+
if (process.platform === 'win32') {
|
|
99
|
+
spawn('taskkill', ['/pid', String(pid), '/T', '/F'], {
|
|
100
|
+
stdio: 'ignore',
|
|
101
|
+
windowsHide: true,
|
|
102
|
+
}).unref();
|
|
103
|
+
return true;
|
|
104
|
+
}
|
|
105
|
+
// Negative pid = process group (child spawned with detached/setpgid)
|
|
106
|
+
try {
|
|
107
|
+
process.kill(-pid, 'SIGKILL');
|
|
108
|
+
return true;
|
|
109
|
+
}
|
|
110
|
+
catch {
|
|
111
|
+
child.kill('SIGKILL');
|
|
112
|
+
return true;
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
catch {
|
|
116
|
+
return false;
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
async function canExecute(file) {
|
|
120
|
+
try {
|
|
121
|
+
await access(file, constants.X_OK);
|
|
122
|
+
return true;
|
|
123
|
+
}
|
|
124
|
+
catch {
|
|
125
|
+
return false;
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
async function which(cmd) {
|
|
129
|
+
const exts = process.platform === 'win32'
|
|
130
|
+
? (process.env.PATHEXT ?? '.EXE;.CMD;.BAT').split(';').filter(Boolean)
|
|
131
|
+
: [''];
|
|
132
|
+
const paths = (process.env.PATH ?? '').split(delimiter).filter(Boolean);
|
|
133
|
+
for (const dir of paths) {
|
|
134
|
+
for (const ext of exts) {
|
|
135
|
+
const candidate = join(dir, cmd + ext);
|
|
136
|
+
if (await canExecute(candidate))
|
|
137
|
+
return candidate;
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
return null;
|
|
141
|
+
}
|
|
142
|
+
/**
|
|
143
|
+
* Probe the current host for the strongest available process backend.
|
|
144
|
+
* Never invents isolation: if nothing is available, returns supervised-spawn.
|
|
145
|
+
*
|
|
146
|
+
* @returns isolation profile this process can offer
|
|
147
|
+
*/
|
|
148
|
+
let cachedProbe = null;
|
|
149
|
+
/** Reset probe cache (tests). */
|
|
150
|
+
export function resetProcessIsolationProbeCache() {
|
|
151
|
+
cachedProbe = null;
|
|
152
|
+
}
|
|
153
|
+
/**
|
|
154
|
+
* One-shot bwrap usability smoke (user namespaces may be disabled in containers).
|
|
155
|
+
*
|
|
156
|
+
* @returns true when bwrap can actually spawn a jailed no-op
|
|
157
|
+
*/
|
|
158
|
+
async function bwrapUsable(bwrap) {
|
|
159
|
+
return new Promise((resolve) => {
|
|
160
|
+
const child = spawn(bwrap, ['--die-with-parent', '--unshare-all', '--ro-bind', '/', '/', '--', 'true'], {
|
|
161
|
+
stdio: 'ignore',
|
|
162
|
+
timeout: 2000,
|
|
163
|
+
});
|
|
164
|
+
child.on('error', () => resolve(false));
|
|
165
|
+
child.on('close', (code) => resolve(code === 0));
|
|
166
|
+
});
|
|
167
|
+
}
|
|
168
|
+
/**
|
|
169
|
+
* One-shot Seatbelt usability smoke (`sandbox_apply` may be denied inside
|
|
170
|
+
* another sandbox). Probe and execute must agree: when no profile can be
|
|
171
|
+
* applied, the honest backend is supervised spawn from the start — never a
|
|
172
|
+
* wrapper run that then has to "recover".
|
|
173
|
+
*
|
|
174
|
+
* @param sandboxExec - resolved path to sandbox-exec
|
|
175
|
+
* @returns true when sandbox-exec can actually apply a profile
|
|
176
|
+
*/
|
|
177
|
+
async function sandboxExecUsable(sandboxExec) {
|
|
178
|
+
return new Promise((resolve) => {
|
|
179
|
+
const child = spawn(sandboxExec, ['-p', '(version 1)(allow default)', '--', '/usr/bin/true'], {
|
|
180
|
+
stdio: 'pipe',
|
|
181
|
+
timeout: 2000,
|
|
182
|
+
});
|
|
183
|
+
child.on('error', () => resolve(false));
|
|
184
|
+
child.on('close', (code) => resolve(code === 0));
|
|
185
|
+
});
|
|
186
|
+
}
|
|
187
|
+
export async function probeProcessIsolation() {
|
|
188
|
+
if (cachedProbe)
|
|
189
|
+
return cachedProbe;
|
|
190
|
+
const notes = [];
|
|
191
|
+
if (process.platform === 'linux') {
|
|
192
|
+
const bwrap = await which('bwrap');
|
|
193
|
+
if (bwrap) {
|
|
194
|
+
if (await bwrapUsable(bwrap)) {
|
|
195
|
+
cachedProbe = {
|
|
196
|
+
backend: 'linux-bwrap',
|
|
197
|
+
processTree: 'contained',
|
|
198
|
+
filesystem: 'root-jailed',
|
|
199
|
+
resources: 'best-effort',
|
|
200
|
+
// Default jail posture (D4-c); execute() honors SandboxConfig.networkPolicy
|
|
201
|
+
network: 'deny',
|
|
202
|
+
privilege: 'dropped',
|
|
203
|
+
envHygiene: 'scrubbed',
|
|
204
|
+
notes: [`bwrap=${bwrap}`, 'privilege=dropped (userns)'],
|
|
205
|
+
};
|
|
206
|
+
return cachedProbe;
|
|
207
|
+
}
|
|
208
|
+
notes.push(`bwrap=${bwrap} present but unusable (userns denied?); no process jail`);
|
|
209
|
+
cachedProbe = {
|
|
210
|
+
backend: 'supervised-spawn',
|
|
211
|
+
processTree: 'killable',
|
|
212
|
+
filesystem: 'cwd-pin',
|
|
213
|
+
resources: 'best-effort',
|
|
214
|
+
network: 'open',
|
|
215
|
+
privilege: 'same',
|
|
216
|
+
envHygiene: 'scrubbed',
|
|
217
|
+
notes,
|
|
218
|
+
};
|
|
219
|
+
return cachedProbe;
|
|
220
|
+
}
|
|
221
|
+
notes.push('linux: bwrap not found; no process jail');
|
|
222
|
+
cachedProbe = {
|
|
223
|
+
backend: 'supervised-spawn',
|
|
224
|
+
processTree: 'killable',
|
|
225
|
+
filesystem: 'cwd-pin',
|
|
226
|
+
resources: 'best-effort',
|
|
227
|
+
network: 'open',
|
|
228
|
+
privilege: 'same',
|
|
229
|
+
envHygiene: 'scrubbed',
|
|
230
|
+
notes,
|
|
231
|
+
};
|
|
232
|
+
return cachedProbe;
|
|
233
|
+
}
|
|
234
|
+
if (process.platform === 'darwin') {
|
|
235
|
+
const sandboxExec = await which('sandbox-exec');
|
|
236
|
+
if (sandboxExec && (await sandboxExecUsable(sandboxExec))) {
|
|
237
|
+
// D3-b+: we generate a Seatbelt profile at execute time (allowRoots + network).
|
|
238
|
+
// write-jailed is therefore honest without OCTOPI_SB_PROFILE.
|
|
239
|
+
cachedProbe = {
|
|
240
|
+
backend: 'mac-seatbelt',
|
|
241
|
+
processTree: 'killable',
|
|
242
|
+
filesystem: 'write-jailed',
|
|
243
|
+
resources: 'best-effort',
|
|
244
|
+
network: 'deny',
|
|
245
|
+
privilege: 'dropped',
|
|
246
|
+
envHygiene: 'scrubbed',
|
|
247
|
+
notes: [
|
|
248
|
+
`sandbox-exec=${sandboxExec}`,
|
|
249
|
+
'privilege=dropped (ops-denied; uid unchanged)',
|
|
250
|
+
],
|
|
251
|
+
};
|
|
252
|
+
return cachedProbe;
|
|
253
|
+
}
|
|
254
|
+
if (sandboxExec) {
|
|
255
|
+
notes.push(`sandbox-exec=${sandboxExec} present but sandbox_apply denied (nested sandbox?); no write jail`);
|
|
256
|
+
}
|
|
257
|
+
else {
|
|
258
|
+
notes.push('darwin: sandbox-exec not found; no write jail');
|
|
259
|
+
}
|
|
260
|
+
cachedProbe = {
|
|
261
|
+
backend: 'supervised-spawn',
|
|
262
|
+
processTree: 'killable',
|
|
263
|
+
filesystem: 'cwd-pin',
|
|
264
|
+
resources: 'best-effort',
|
|
265
|
+
network: 'open',
|
|
266
|
+
privilege: 'same',
|
|
267
|
+
envHygiene: 'scrubbed',
|
|
268
|
+
notes,
|
|
269
|
+
};
|
|
270
|
+
return cachedProbe;
|
|
271
|
+
}
|
|
272
|
+
if (process.platform === 'win32') {
|
|
273
|
+
// Job Object / restricted token need a native helper (future). Pure Node = supervised.
|
|
274
|
+
notes.push('win32: Job Object + restricted token not bundled; processTree via taskkill /T only');
|
|
275
|
+
cachedProbe = {
|
|
276
|
+
backend: 'supervised-spawn',
|
|
277
|
+
processTree: 'killable',
|
|
278
|
+
filesystem: 'cwd-pin',
|
|
279
|
+
resources: 'best-effort',
|
|
280
|
+
network: 'open',
|
|
281
|
+
privilege: 'same',
|
|
282
|
+
envHygiene: 'scrubbed',
|
|
283
|
+
notes,
|
|
284
|
+
};
|
|
285
|
+
return cachedProbe;
|
|
286
|
+
}
|
|
287
|
+
notes.push(`${process.platform}: generic supervised spawn only`);
|
|
288
|
+
cachedProbe = {
|
|
289
|
+
backend: 'supervised-spawn',
|
|
290
|
+
processTree: 'killable',
|
|
291
|
+
filesystem: 'cwd-pin',
|
|
292
|
+
resources: 'best-effort',
|
|
293
|
+
network: 'open',
|
|
294
|
+
privilege: 'same',
|
|
295
|
+
envHygiene: 'scrubbed',
|
|
296
|
+
notes,
|
|
297
|
+
};
|
|
298
|
+
return cachedProbe;
|
|
299
|
+
}
|
|
300
|
+
/**
|
|
301
|
+
* Synthetic supervised profile (L1 only). Used when no probe has run yet.
|
|
302
|
+
*
|
|
303
|
+
* @returns baseline profile for supervised spawn
|
|
304
|
+
*/
|
|
305
|
+
export function supervisedSpawnProfile() {
|
|
306
|
+
return {
|
|
307
|
+
backend: 'supervised-spawn',
|
|
308
|
+
processTree: 'killable',
|
|
309
|
+
filesystem: 'cwd-pin',
|
|
310
|
+
resources: 'best-effort',
|
|
311
|
+
network: 'open',
|
|
312
|
+
privilege: 'same',
|
|
313
|
+
envHygiene: 'scrubbed',
|
|
314
|
+
};
|
|
315
|
+
}
|