@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
|
@@ -1,18 +1,13 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Plugin Entry
|
|
2
|
+
* Plugin Entry
|
|
3
3
|
*
|
|
4
4
|
* definePluginEntry 是创建 plugin 的标准方式。
|
|
5
5
|
* 它定义了 plugin 的 id、name、register 回调等。
|
|
6
|
-
*
|
|
7
|
-
* 对齐 OpenClaw 的:
|
|
8
|
-
* import { definePluginEntry } from "openclaw/plugin-sdk/plugin-entry";
|
|
9
|
-
*
|
|
10
|
-
* 参考: https://docs.openclaw.ai/plugins/building-plugins
|
|
11
6
|
*/
|
|
12
7
|
/**
|
|
13
8
|
* 定义一个 Plugin Entry
|
|
14
9
|
*
|
|
15
|
-
* 这是创建 plugin
|
|
10
|
+
* 这是创建 plugin 的标准方式。
|
|
16
11
|
*
|
|
17
12
|
* @param definition - Plugin 定义
|
|
18
13
|
* @returns Plugin 定义对象
|
|
@@ -50,8 +45,6 @@ export function definePluginEntry(definition) {
|
|
|
50
45
|
/**
|
|
51
46
|
* 定义一个 Channel Plugin Entry
|
|
52
47
|
*
|
|
53
|
-
* 对齐 OpenClaw 的 defineChannelPluginEntry。
|
|
54
|
-
*
|
|
55
48
|
* @param definition - Channel Plugin 定义
|
|
56
49
|
* @returns Plugin 定义对象
|
|
57
50
|
*/
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Plugin System
|
|
2
|
+
* Plugin System
|
|
3
3
|
*
|
|
4
4
|
* 核心概念:
|
|
5
5
|
* - Plugin = 能力的所有权边界(Provider/Channel/Tool/Hook 等)
|
|
@@ -9,8 +9,6 @@
|
|
|
9
9
|
* - PluginLoader = 发现和加载 plugins
|
|
10
10
|
* - PluginManager = 管理 plugin 生命周期和 hook 执行
|
|
11
11
|
* - CapabilityRegistry = 能力注册中心
|
|
12
|
-
*
|
|
13
|
-
* 参考: https://docs.openclaw.ai/plugins/overview
|
|
14
12
|
*/
|
|
15
13
|
export { definePluginEntry, defineChannelPluginEntry } from './entry.js';
|
|
16
14
|
export type { OctopiPluginDefinition, OctopiChannelPluginDefinition } from './entry.js';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Plugin System
|
|
2
|
+
* Plugin System
|
|
3
3
|
*
|
|
4
4
|
* 核心概念:
|
|
5
5
|
* - Plugin = 能力的所有权边界(Provider/Channel/Tool/Hook 等)
|
|
@@ -9,8 +9,6 @@
|
|
|
9
9
|
* - PluginLoader = 发现和加载 plugins
|
|
10
10
|
* - PluginManager = 管理 plugin 生命周期和 hook 执行
|
|
11
11
|
* - CapabilityRegistry = 能力注册中心
|
|
12
|
-
*
|
|
13
|
-
* 参考: https://docs.openclaw.ai/plugins/overview
|
|
14
12
|
*/
|
|
15
13
|
// ── 定义和创建 ──
|
|
16
14
|
export { definePluginEntry, defineChannelPluginEntry } from './entry.js';
|
|
@@ -1,13 +1,11 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Plugin Loader — Plugin 发现和加载
|
|
3
3
|
*
|
|
4
|
-
*
|
|
4
|
+
* 加载流程:
|
|
5
5
|
* 1. Discovery — 从配置路径发现候选 plugins
|
|
6
6
|
* 2. Validation — 验证 manifest、检查 enable/disable 状态
|
|
7
7
|
* 3. Loading — 进程内加载 plugin 代码
|
|
8
8
|
* 4. Registration — 调用 register() 注册能力
|
|
9
|
-
*
|
|
10
|
-
* 参考: https://docs.openclaw.ai/plugins/architecture#architecture-overview
|
|
11
9
|
*/
|
|
12
10
|
import type { PluginManifest } from './manifest.js';
|
|
13
11
|
import type { OctopiPluginDefinition } from './entry.js';
|
|
@@ -46,7 +44,7 @@ export interface PluginLoaderConfig {
|
|
|
46
44
|
pluginEntries?: Record<string, PluginEntryConfig>;
|
|
47
45
|
}
|
|
48
46
|
/**
|
|
49
|
-
* Plugin Entry
|
|
47
|
+
* Plugin Entry 配置(来自宿主配置)
|
|
50
48
|
*/
|
|
51
49
|
export interface PluginEntryConfig {
|
|
52
50
|
/** 是否启用 */
|
|
@@ -1,13 +1,11 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Plugin Loader — Plugin 发现和加载
|
|
3
3
|
*
|
|
4
|
-
*
|
|
4
|
+
* 加载流程:
|
|
5
5
|
* 1. Discovery — 从配置路径发现候选 plugins
|
|
6
6
|
* 2. Validation — 验证 manifest、检查 enable/disable 状态
|
|
7
7
|
* 3. Loading — 进程内加载 plugin 代码
|
|
8
8
|
* 4. Registration — 调用 register() 注册能力
|
|
9
|
-
*
|
|
10
|
-
* 参考: https://docs.openclaw.ai/plugins/architecture#architecture-overview
|
|
11
9
|
*/
|
|
12
10
|
import * as path from 'node:path';
|
|
13
11
|
import * as fs from 'node:fs/promises';
|
|
@@ -86,19 +84,10 @@ export class PluginLoader {
|
|
|
86
84
|
continue;
|
|
87
85
|
const pluginDir = path.join(dirPath, entry.name);
|
|
88
86
|
const manifestPath = path.join(pluginDir, 'octopi.plugin.json');
|
|
89
|
-
|
|
90
|
-
const openclawManifestPath = path.join(pluginDir, 'openclaw.plugin.json');
|
|
91
|
-
let manifestFile = null;
|
|
92
|
-
if (existsSync(manifestPath)) {
|
|
93
|
-
manifestFile = manifestPath;
|
|
94
|
-
}
|
|
95
|
-
else if (existsSync(openclawManifestPath)) {
|
|
96
|
-
manifestFile = openclawManifestPath;
|
|
97
|
-
}
|
|
98
|
-
if (!manifestFile)
|
|
87
|
+
if (!existsSync(manifestPath))
|
|
99
88
|
continue;
|
|
100
89
|
try {
|
|
101
|
-
const plugin = await this.loadPluginFromDir(pluginDir,
|
|
90
|
+
const plugin = await this.loadPluginFromDir(pluginDir, manifestPath);
|
|
102
91
|
if (plugin) {
|
|
103
92
|
plugins.push(plugin);
|
|
104
93
|
}
|
|
@@ -188,12 +177,6 @@ export class PluginLoader {
|
|
|
188
177
|
if (existsSync(pkgPath)) {
|
|
189
178
|
try {
|
|
190
179
|
const pkg = JSON.parse(await fs.readFile(pkgPath, 'utf-8'));
|
|
191
|
-
// openclaw 字段中的 extensions
|
|
192
|
-
if (pkg.openclaw?.extensions?.[0]) {
|
|
193
|
-
const ext = path.resolve(pluginDir, pkg.openclaw.extensions[0]);
|
|
194
|
-
if (existsSync(ext))
|
|
195
|
-
return ext;
|
|
196
|
-
}
|
|
197
180
|
// main 字段
|
|
198
181
|
if (pkg.main) {
|
|
199
182
|
const main = path.resolve(pluginDir, pkg.main);
|
|
@@ -259,7 +242,7 @@ export class PluginLoader {
|
|
|
259
242
|
for (const dep of plugin.manifest.requiresPlugins) {
|
|
260
243
|
if (!plugins.some((p) => p.id === dep)) {
|
|
261
244
|
console.warn(`[PluginLoader] Plugin "${plugin.id}" requires "${dep}" which is not loaded`);
|
|
262
|
-
//
|
|
245
|
+
// 依赖缺失不阻塞加载,只警告
|
|
263
246
|
}
|
|
264
247
|
}
|
|
265
248
|
}
|
|
@@ -1,18 +1,15 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Plugin Manager
|
|
2
|
+
* Plugin Manager
|
|
3
3
|
*
|
|
4
4
|
* 这是 plugin 系统的顶层管理器,负责:
|
|
5
5
|
* - 加载和管理所有 plugins
|
|
6
6
|
* - 运行 hooks(支持 priority、timeout、拦截语义)
|
|
7
7
|
* - 能力注册和查询
|
|
8
|
-
* - 对齐 OpenClaw 的 hook catalog
|
|
9
8
|
*
|
|
10
|
-
* Hook
|
|
9
|
+
* Hook 分类:
|
|
11
10
|
* - 拦截语义:返回值改变执行流程
|
|
12
11
|
* - 观察语义:所有 plugin 都执行
|
|
13
12
|
* - 上下文注入:返回 prependContext / systemPrompt 等
|
|
14
|
-
*
|
|
15
|
-
* 参考: https://docs.openclaw.ai/plugins/hooks
|
|
16
13
|
*/
|
|
17
14
|
import type { Message, ToolCall, ToolResult, ThinkingLevel } from '@octopi-agent/core/types.js';
|
|
18
15
|
import type { ChannelAdapter, ChannelMessage, ChannelReply } from '../channel-types.js';
|
|
@@ -192,7 +189,6 @@ export interface BeforeInstallEvent {
|
|
|
192
189
|
* before_iteration 事件
|
|
193
190
|
*
|
|
194
191
|
* 每次 LLM 调用前触发(per-iteration)。
|
|
195
|
-
* 与 OpenClaw 的 before_agent_reply(per-message)不同,
|
|
196
192
|
* 这是 Octopi 独有的迭代级 hook。
|
|
197
193
|
*/
|
|
198
194
|
export interface BeforeIterationEvent {
|
|
@@ -231,7 +227,6 @@ export interface BeforeIterationResult {
|
|
|
231
227
|
* after_iteration 事件
|
|
232
228
|
*
|
|
233
229
|
* 每次 LLM 调用 + 工具执行完成后触发(per-iteration)。
|
|
234
|
-
* 与 OpenClaw 的 after_tool_call(per-tool)不同,
|
|
235
230
|
* 这是 Octopi 独有的迭代级 hook。
|
|
236
231
|
*/
|
|
237
232
|
export interface AfterIterationEvent {
|
|
@@ -359,7 +354,6 @@ export interface InstallResult {
|
|
|
359
354
|
/**
|
|
360
355
|
* Plugin Manager
|
|
361
356
|
*
|
|
362
|
-
* 对齐 OpenClaw 的 plugin 管理系统。
|
|
363
357
|
* 负责加载 plugins、运行 hooks、管理能力注册。
|
|
364
358
|
*/
|
|
365
359
|
export declare class PluginManager {
|
|
@@ -389,7 +383,7 @@ export declare class PluginManager {
|
|
|
389
383
|
/**
|
|
390
384
|
* 运行指定 hook
|
|
391
385
|
*
|
|
392
|
-
*
|
|
386
|
+
* 语义:
|
|
393
387
|
* - 按 priority 降序执行
|
|
394
388
|
* - 支持 per-handler timeout
|
|
395
389
|
* - 拦截语义:返回非 null/undefined 的结果时中断后续 handlers
|
|
@@ -1,18 +1,15 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Plugin Manager
|
|
2
|
+
* Plugin Manager
|
|
3
3
|
*
|
|
4
4
|
* 这是 plugin 系统的顶层管理器,负责:
|
|
5
5
|
* - 加载和管理所有 plugins
|
|
6
6
|
* - 运行 hooks(支持 priority、timeout、拦截语义)
|
|
7
7
|
* - 能力注册和查询
|
|
8
|
-
* - 对齐 OpenClaw 的 hook catalog
|
|
9
8
|
*
|
|
10
|
-
* Hook
|
|
9
|
+
* Hook 分类:
|
|
11
10
|
* - 拦截语义:返回值改变执行流程
|
|
12
11
|
* - 观察语义:所有 plugin 都执行
|
|
13
12
|
* - 上下文注入:返回 prependContext / systemPrompt 等
|
|
14
|
-
*
|
|
15
|
-
* 参考: https://docs.openclaw.ai/plugins/hooks
|
|
16
13
|
*/
|
|
17
14
|
import { PluginLoader } from './loader.js';
|
|
18
15
|
// ================================================================
|
|
@@ -21,7 +18,6 @@ import { PluginLoader } from './loader.js';
|
|
|
21
18
|
/**
|
|
22
19
|
* Plugin Manager
|
|
23
20
|
*
|
|
24
|
-
* 对齐 OpenClaw 的 plugin 管理系统。
|
|
25
21
|
* 负责加载 plugins、运行 hooks、管理能力注册。
|
|
26
22
|
*/
|
|
27
23
|
export class PluginManager {
|
|
@@ -63,12 +59,12 @@ export class PluginManager {
|
|
|
63
59
|
return this.loader.getPlugin(id);
|
|
64
60
|
}
|
|
65
61
|
// ================================================================
|
|
66
|
-
// Hook Execution
|
|
62
|
+
// Hook Execution
|
|
67
63
|
// ================================================================
|
|
68
64
|
/**
|
|
69
65
|
* 运行指定 hook
|
|
70
66
|
*
|
|
71
|
-
*
|
|
67
|
+
* 语义:
|
|
72
68
|
* - 按 priority 降序执行
|
|
73
69
|
* - 支持 per-handler timeout
|
|
74
70
|
* - 拦截语义:返回非 null/undefined 的结果时中断后续 handlers
|
|
@@ -1,10 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Plugin Manifest
|
|
2
|
+
* Plugin Manifest
|
|
3
3
|
*
|
|
4
4
|
* Manifest 是 plugin 的声明式元数据,框架在不执行 plugin 代码的情况下
|
|
5
5
|
* 就能读取和验证。这是 plugin 系统的基础。
|
|
6
|
-
*
|
|
7
|
-
* 参考: https://docs.openclaw.ai/plugins/manifest
|
|
8
6
|
*/
|
|
9
7
|
/**
|
|
10
8
|
* JSON Schema 基础类型(简化版)
|
|
@@ -30,7 +28,6 @@ export interface JsonSchema {
|
|
|
30
28
|
/**
|
|
31
29
|
* Plugin Manifest
|
|
32
30
|
*
|
|
33
|
-
* 对齐 OpenClaw 的 openclaw.plugin.json 格式。
|
|
34
31
|
* 所有字段都是声明式的,不需要执行 plugin 代码。
|
|
35
32
|
*/
|
|
36
33
|
export interface PluginManifest {
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Allowlisted argv runner — shared by dedicated tools (git / package).
|
|
3
|
+
*
|
|
4
|
+
* Not a shell: fixed executable + argv array, no interpolation. Spawns via
|
|
5
|
+
* ProcessSandbox (L1 supervised; L4 jail when probed). Optional §5.6 shell
|
|
6
|
+
* journal snapshot so write ops stay turn-undoable like the shell tool.
|
|
7
|
+
*/
|
|
8
|
+
import type { ToolExecutionContext } from '@octopi-agent/core/types.js';
|
|
9
|
+
export interface AllowlistedRunOptions {
|
|
10
|
+
/** Absolute executable path (from findExecutable) */
|
|
11
|
+
executable: string;
|
|
12
|
+
/** argv after the executable — caller builds a fixed allowlist */
|
|
13
|
+
args: string[];
|
|
14
|
+
cwd: string;
|
|
15
|
+
context?: ToolExecutionContext;
|
|
16
|
+
/** Extra env (merged over the scrubbed baseline) */
|
|
17
|
+
env?: Record<string, string>;
|
|
18
|
+
timeoutMs?: number;
|
|
19
|
+
/** Journal write effects via shell-journal (default true for mutating tools) */
|
|
20
|
+
journal?: boolean;
|
|
21
|
+
}
|
|
22
|
+
export interface AllowlistedRunResult {
|
|
23
|
+
stdout: string;
|
|
24
|
+
stderr: string;
|
|
25
|
+
exitCode: number;
|
|
26
|
+
durationMs: number;
|
|
27
|
+
truncated: boolean;
|
|
28
|
+
rawStdoutLength: number;
|
|
29
|
+
terminated: boolean;
|
|
30
|
+
terminateReason?: string;
|
|
31
|
+
isolation: import('../../execution-environment/types.js').SandboxResult['isolation'];
|
|
32
|
+
}
|
|
33
|
+
/** Resolve an executable or throw a typed error the model can act on. */
|
|
34
|
+
export declare function requireExecutable(name: string): string;
|
|
35
|
+
/**
|
|
36
|
+
* Run a fixed argv vector through ProcessSandbox with journal + L1 output gate.
|
|
37
|
+
*
|
|
38
|
+
* @param options - executable/args/cwd/context
|
|
39
|
+
* @returns capped stdout/stderr + honest isolation
|
|
40
|
+
*/
|
|
41
|
+
export declare function runAllowlistedArgv(options: AllowlistedRunOptions): Promise<AllowlistedRunResult>;
|
|
42
|
+
/** Safe git revision / branch token (no shell metacharacters, no leading dash). */
|
|
43
|
+
export declare const SAFE_REF_RE: RegExp;
|
|
44
|
+
/** Validate a git ref/branch token; throws on injection-shaped input. */
|
|
45
|
+
export declare function assertSafeRef(value: string, label: string): string;
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
import { defaultChildEnv, findExecutable } from './platform.js';
|
|
2
|
+
/** Resolve an executable or throw a typed error the model can act on. */
|
|
3
|
+
export function requireExecutable(name) {
|
|
4
|
+
const found = findExecutable(name);
|
|
5
|
+
if (!found) {
|
|
6
|
+
throw new Error(`${name}_not_found: "${name}" is not on PATH. Install it or use the dedicated file tools instead of shell.`);
|
|
7
|
+
}
|
|
8
|
+
return found;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Run a fixed argv vector through ProcessSandbox with journal + L1 output gate.
|
|
12
|
+
*
|
|
13
|
+
* @param options - executable/args/cwd/context
|
|
14
|
+
* @returns capped stdout/stderr + honest isolation
|
|
15
|
+
*/
|
|
16
|
+
export async function runAllowlistedArgv(options) {
|
|
17
|
+
const { executable, args, cwd, context, timeoutMs = 60_000, journal = true } = options;
|
|
18
|
+
const journalMode = context?.shellJournal ?? 'snapshot';
|
|
19
|
+
const journalRoots = (context?.pathRoots ?? []).filter(Boolean);
|
|
20
|
+
let shellBefore;
|
|
21
|
+
let notReversedPayload;
|
|
22
|
+
if (journal) {
|
|
23
|
+
if (journalMode === 'snapshot') {
|
|
24
|
+
if (journalRoots.length === 0) {
|
|
25
|
+
notReversedPayload = { reason: 'no_roots' };
|
|
26
|
+
}
|
|
27
|
+
else {
|
|
28
|
+
const sj = await import('../../execution-environment/shell-journal.js');
|
|
29
|
+
shellBefore = await sj.snapshotShellRoots({
|
|
30
|
+
roots: journalRoots,
|
|
31
|
+
limit: context?.shellJournalLimit,
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
else {
|
|
36
|
+
notReversedPayload = { reason: 'shell_journal_off' };
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
const { createProcessSandbox } = await import('../../execution-environment/sandbox.js');
|
|
40
|
+
// Force-include every key we explicitly set (GIT_*, npm_config_* sit outside
|
|
41
|
+
// scrubEnv's allowlist and would silently vanish otherwise).
|
|
42
|
+
const childEnv = {
|
|
43
|
+
...defaultChildEnv(),
|
|
44
|
+
...options.env,
|
|
45
|
+
};
|
|
46
|
+
const forceEnvKeys = Object.keys(childEnv);
|
|
47
|
+
const sandbox = await createProcessSandbox({ forceEnvKeys });
|
|
48
|
+
const sandboxResult = await sandbox.executeArgv([executable, ...args], {
|
|
49
|
+
cwd,
|
|
50
|
+
env: childEnv,
|
|
51
|
+
allowRoots: [cwd, ...journalRoots],
|
|
52
|
+
networkPolicy: context?.networkPolicy ?? 'deny',
|
|
53
|
+
requireJail: context?.requireJail,
|
|
54
|
+
homeWrite: context?.homeWrite,
|
|
55
|
+
noteSecurityDegraded: context?.noteSecurityDegraded,
|
|
56
|
+
signal: context?.abortSignal,
|
|
57
|
+
limits: {
|
|
58
|
+
timeoutMs,
|
|
59
|
+
maxOutputBytes: 16 * 1024 * 1024,
|
|
60
|
+
},
|
|
61
|
+
});
|
|
62
|
+
// Journal after-diff (same contract as shell tool §5.6)
|
|
63
|
+
try {
|
|
64
|
+
const sj = await import('../../execution-environment/shell-journal.js');
|
|
65
|
+
const effects = context?.fileEffects;
|
|
66
|
+
if (shellBefore && effects) {
|
|
67
|
+
const afterCap = await sj.captureShellInventory({
|
|
68
|
+
roots: journalRoots,
|
|
69
|
+
limit: context?.shellJournalLimit,
|
|
70
|
+
});
|
|
71
|
+
const diff = await sj.journalShellDiff(effects, shellBefore.capture, afterCap, shellBefore.store);
|
|
72
|
+
if (shellBefore.capture.truncated || afterCap.truncated || diff.notInventable.length > 0) {
|
|
73
|
+
await effects.noteNotReversed({
|
|
74
|
+
reason: 'budget_truncated',
|
|
75
|
+
created: diff.notInventable,
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
else if (notReversedPayload && effects && journal) {
|
|
80
|
+
await effects.noteNotReversed(notReversedPayload);
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
catch {
|
|
84
|
+
// Journal failure must not drop the business result (matches shell tool).
|
|
85
|
+
}
|
|
86
|
+
try {
|
|
87
|
+
const { applyToolOutputGate, resolveSupportBinding } = await import('../../../context/capabilities/summary/index.js');
|
|
88
|
+
const binding = resolveSupportBinding('shell', undefined, 8000);
|
|
89
|
+
const applied = await applyToolOutputGate({
|
|
90
|
+
tool: 'shell',
|
|
91
|
+
rawBody: sandboxResult.stdout,
|
|
92
|
+
support: { binding },
|
|
93
|
+
truncateHint: 'Re-run with a narrower command, or write large output to a file and file_read it.',
|
|
94
|
+
});
|
|
95
|
+
const stderrApplied = await applyToolOutputGate({
|
|
96
|
+
tool: 'shell',
|
|
97
|
+
rawBody: sandboxResult.stderr,
|
|
98
|
+
support: { binding: { ...binding, maxReturnChars: Math.min(binding.maxReturnChars, 4000) } },
|
|
99
|
+
truncateHint: 'stderr truncated.',
|
|
100
|
+
});
|
|
101
|
+
return {
|
|
102
|
+
stdout: applied.body,
|
|
103
|
+
stderr: stderrApplied.body,
|
|
104
|
+
exitCode: sandboxResult.exitCode,
|
|
105
|
+
durationMs: sandboxResult.usage.elapsedMs,
|
|
106
|
+
truncated: applied.bodyTruncated || stderrApplied.bodyTruncated,
|
|
107
|
+
rawStdoutLength: applied.rawLength,
|
|
108
|
+
terminated: sandboxResult.terminated,
|
|
109
|
+
terminateReason: sandboxResult.terminateReason,
|
|
110
|
+
isolation: sandboxResult.isolation,
|
|
111
|
+
};
|
|
112
|
+
}
|
|
113
|
+
catch {
|
|
114
|
+
return {
|
|
115
|
+
stdout: sandboxResult.stdout.slice(0, 8000),
|
|
116
|
+
stderr: sandboxResult.stderr.slice(0, 4000),
|
|
117
|
+
exitCode: sandboxResult.exitCode,
|
|
118
|
+
durationMs: sandboxResult.usage.elapsedMs,
|
|
119
|
+
truncated: sandboxResult.stdout.length > 8000 || sandboxResult.stderr.length > 4000,
|
|
120
|
+
rawStdoutLength: sandboxResult.stdout.length,
|
|
121
|
+
terminated: sandboxResult.terminated,
|
|
122
|
+
terminateReason: sandboxResult.terminateReason,
|
|
123
|
+
isolation: sandboxResult.isolation,
|
|
124
|
+
};
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
/** Safe git revision / branch token (no shell metacharacters, no leading dash). */
|
|
128
|
+
export const SAFE_REF_RE = /^[A-Za-z0-9][A-Za-z0-9._/@{}^~:-]*$/;
|
|
129
|
+
/** Validate a git ref/branch token; throws on injection-shaped input. */
|
|
130
|
+
export function assertSafeRef(value, label) {
|
|
131
|
+
const t = value.trim();
|
|
132
|
+
if (!t || !SAFE_REF_RE.test(t) || t.includes('..') || t.startsWith('-')) {
|
|
133
|
+
throw new Error(`unsafe_${label}: "${value}" is not a safe git ref token`);
|
|
134
|
+
}
|
|
135
|
+
return t;
|
|
136
|
+
}
|
|
@@ -21,6 +21,7 @@ export function createAskUserTool(callback, options) {
|
|
|
21
21
|
return {
|
|
22
22
|
definition: {
|
|
23
23
|
name: 'ask_user',
|
|
24
|
+
capabilities: [],
|
|
24
25
|
description: 'Ask the user a question and wait for their response. Use when you need clarification, confirmation, or a choice from the user. Optionally provide a list of suggested options. Do not use for things you can look up yourself.',
|
|
25
26
|
parameters: {
|
|
26
27
|
question: {
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
*
|
|
4
4
|
* 提供框架默认的纯工具实现(零外部依赖,所有环境可用):
|
|
5
5
|
* - shell: 执行 shell 命令
|
|
6
|
-
* - file_read / file_write / file_list:
|
|
6
|
+
* - file_read / file_write / file_list / file_delete: 文件读写删列目录
|
|
7
7
|
* - file_edit: 结构化文件编辑(局部替换)
|
|
8
8
|
* - file_search: 跨文件内容搜索
|
|
9
9
|
* - http_request: HTTP 请求
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
*
|
|
14
14
|
* 安全注意事项:
|
|
15
15
|
* - shell 工具可以执行任意命令,生产环境应限制命令白名单
|
|
16
|
-
* - file_read/file_write/file_edit 应限制可访问的目录范围
|
|
16
|
+
* - file_read/file_write/file_edit/file_delete 应限制可访问的目录范围
|
|
17
17
|
* - http_request 应限制可访问的域名
|
|
18
18
|
* - 建议在 ToolPolicy 的 deny 列表中禁用不需要的工具
|
|
19
19
|
*/
|
|
@@ -24,7 +24,7 @@ import type { RegisteredTool } from '@octopi-agent/core/types.js';
|
|
|
24
24
|
* 参数:
|
|
25
25
|
* - command (string, required): 要执行的 shell 命令
|
|
26
26
|
* - cwd (string, optional): 工作目录
|
|
27
|
-
* - timeout (number, optional): 超时时间(毫秒,默认
|
|
27
|
+
* - timeout (number, optional): 超时时间(毫秒,默认 60000)
|
|
28
28
|
*
|
|
29
29
|
* 返回:
|
|
30
30
|
* - stdout: 标准输出
|
|
@@ -73,6 +73,15 @@ export declare function createFileReadTool(options?: {
|
|
|
73
73
|
* - bytesWritten: 写入的字节数
|
|
74
74
|
*/
|
|
75
75
|
export declare function createFileWriteTool(): RegisteredTool;
|
|
76
|
+
/**
|
|
77
|
+
* File Delete 工具 — 删除单个文件(不可删目录)
|
|
78
|
+
*
|
|
79
|
+
* 参数:
|
|
80
|
+
* - path (string, required): 文件路径
|
|
81
|
+
*
|
|
82
|
+
* 走 ToolFileEffects.recordDelete:记 before,编辑重发可恢复。
|
|
83
|
+
*/
|
|
84
|
+
export declare function createFileDeleteTool(): RegisteredTool;
|
|
76
85
|
/**
|
|
77
86
|
* File List 工具 — 列出目录内容
|
|
78
87
|
*
|
|
@@ -99,4 +108,10 @@ export declare function createFileListTool(options?: {
|
|
|
99
108
|
export declare function getBuiltinTools(options?: {
|
|
100
109
|
summary?: import('../../../context/capabilities/summary/index.js').ToolSummarySupport;
|
|
101
110
|
documentPort?: import('./document-tools.js').DocumentToolOptions['documentPort'];
|
|
111
|
+
/** CredentialStore for http_request.credential(SEC-3c 接线) */
|
|
112
|
+
credentials?: import('../../../governance/credentials/store.js').CredentialStore | null;
|
|
113
|
+
/** http_request SSRF 门(allowPrivateNetwork 等) */
|
|
114
|
+
network?: import('../../../knowledge/network-guard.js').NetworkGuardOptions;
|
|
115
|
+
/** 无绑定凭证拒绝(部署/untrusted) */
|
|
116
|
+
requireCredentialBindings?: boolean;
|
|
102
117
|
}): RegisteredTool[];
|