@octopi-agent/engine 0.70.7 → 0.90.11
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 +81 -5
- package/dist/config-schema/context.d.ts +24 -5
- package/dist/config-schema/context.js +28 -1
- package/dist/config-schema/engine.d.ts +205 -13
- package/dist/config-schema/engine.js +31 -2
- package/dist/config-schema/governance.d.ts +95 -0
- package/dist/config-schema/governance.js +93 -1
- package/dist/config-schema/models.d.ts +3 -3
- 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 +13 -0
- package/dist/config-schema/shared.js +22 -0
- package/dist/config-schema/substrate.d.ts +2 -2
- package/dist/config-schema/subsystems.d.ts +1 -1
- package/dist/config-schema/subsystems.js +2 -1
- package/dist/config.d.ts +201 -8
- package/dist/config.js +105 -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 +50 -5
- package/dist/harness/agent/builder.js +189 -59
- package/dist/harness/agent/config-bridge.d.ts +33 -25
- package/dist/harness/agent/config-bridge.js +84 -291
- 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 +46 -0
- package/dist/harness/agent/tool-purpose.js +127 -0
- package/dist/harness/agent/wire-agent-builder.d.ts +133 -0
- package/dist/harness/agent/wire-agent-builder.js +370 -0
- package/dist/harness/collaboration/autonomous-subsystem/boundary/validator.d.ts +11 -1
- package/dist/harness/collaboration/autonomous-subsystem/boundary/validator.js +11 -1
- package/dist/harness/collaboration/autonomous-subsystem/loader.d.ts +13 -0
- package/dist/harness/collaboration/autonomous-subsystem/loader.js +16 -1
- package/dist/harness/collaboration/autonomous-subsystem/runtime.d.ts +8 -1
- package/dist/harness/collaboration/autonomous-subsystem/runtime.js +17 -9
- 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/registry.js +10 -0
- 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-snapshot.d.ts +4 -0
- package/dist/harness/context/layer-snapshot.js +30 -18
- package/dist/harness/context/layer-types.d.ts +85 -1
- package/dist/harness/context/layer-types.js +110 -4
- package/dist/harness/context/layers.d.ts +5 -2
- package/dist/harness/context/layers.js +11 -5
- 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 +30 -0
- package/dist/harness/context/system-prompt-assembler.js +73 -6
- 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 +258 -0
- package/dist/harness/extension/execution-environment/effect-policy.js +358 -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/isolation.js +5 -1
- 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 +521 -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 +1 -1
- package/dist/harness/extension/plugin-ecosystem/client-tools/types.d.ts +9 -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 +51 -0
- package/dist/harness/extension/plugin-ecosystem/tools/allowlisted-run.js +153 -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 +277 -81
- 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 +241 -70
- package/dist/harness/extension/plugin-ecosystem/tools/git-runner.d.ts +31 -0
- package/dist/harness/extension/plugin-ecosystem/tools/git-runner.js +104 -0
- package/dist/harness/extension/plugin-ecosystem/tools/git-status-snapshot.d.ts +111 -0
- package/dist/harness/extension/plugin-ecosystem/tools/git-status-snapshot.js +197 -0
- package/dist/harness/extension/plugin-ecosystem/tools/git-tools.d.ts +27 -0
- package/dist/harness/extension/plugin-ecosystem/tools/git-tools.js +463 -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 +6 -0
- package/dist/harness/extension/plugin-ecosystem/tools/index.js +4 -0
- package/dist/harness/extension/plugin-ecosystem/tools/knowledge.js +4 -0
- package/dist/harness/extension/plugin-ecosystem/tools/memory.js +25 -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 +16 -12
- package/dist/harness/index.js +10 -6
- package/dist/harness/knowledge/file-identity.d.ts +8 -0
- package/dist/harness/knowledge/file-identity.js +26 -1
- 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 +8 -5
- package/dist/harness/knowledge/index-store.d.ts +31 -4
- package/dist/harness/knowledge/index-store.js +121 -39
- package/dist/harness/knowledge/index.d.ts +2 -2
- package/dist/harness/knowledge/index.js +1 -1
- package/dist/harness/knowledge/ingest.d.ts +115 -115
- package/dist/harness/knowledge/ingest.js +154 -151
- package/dist/harness/knowledge/job-control-state.js +4 -4
- package/dist/harness/knowledge/job-control.js +11 -11
- package/dist/harness/knowledge/knowledge-serve-child.js +1 -1
- 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/purge.js +4 -1
- package/dist/harness/knowledge/query-service.js +3 -3
- package/dist/harness/knowledge/writer-service.d.ts +2 -0
- package/dist/harness/knowledge/writer-service.js +14 -13
- package/dist/harness/memory/backfill-coverage.js +3 -1
- package/dist/harness/memory/backfill-trigger.d.ts +2 -2
- package/dist/harness/memory/backfill-trigger.js +4 -4
- package/dist/harness/memory/index.d.ts +1 -0
- package/dist/harness/memory/index.js +1 -0
- package/dist/harness/memory/sqlite/agent-db.js +2 -0
- 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.js +9 -9
- 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 +12 -0
- package/dist/harness/observability/observer/hub.js +53 -2
- 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 +80 -0
- package/dist/harness/observability/observer/types.js +118 -9
- package/dist/harness/run/agent/agent.d.ts +18 -0
- package/dist/harness/run/agent/agent.js +26 -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 +110 -18
- 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 +117 -16
- package/dist/harness/run/runner.js +668 -157
- package/dist/harness/session/attachments/llm-intent.js +17 -17
- package/dist/harness/session/history/port.js +16 -5
- package/dist/harness/session/in-memory-store.d.ts +6 -0
- package/dist/harness/session/in-memory-store.js +55 -3
- 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.js +25 -9
- package/dist/harness/session/types.d.ts +35 -0
- package/dist/harness/shared/events/agent-event-map.d.ts +39 -0
- package/dist/harness/shared/events/agent-event-map.js +2 -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/observability/run-telemetry.d.ts +8 -0
- package/dist/integration/observability/run-telemetry.js +31 -8
- package/dist/integration/observability/trace-collector.js +26 -4
- package/dist/integration/observability/trace-events.d.ts +1 -0
- package/dist/integration/observability/trace-events.js +2 -0
- package/dist/integration/observability/trace-logger.js +27 -17
- 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 +29 -0
- package/dist/integration/storage/jsonl.js +243 -41
- package/dist/integration/storage/session-index.js +63 -8
- package/dist/paths.d.ts +19 -0
- package/dist/paths.js +38 -1
- package/dist/subsystems/cognition-steward/conceptualize/SUBSYSTEM.md +43 -43
- package/dist/subsystems/cognition-steward/conceptualize/config.yaml +50 -50
- package/dist/subsystems/cognition-steward/consolidate/SUBSYSTEM.md +6 -6
- package/dist/subsystems/cognition-steward/consolidate/config.yaml +54 -54
- package/dist/subsystems/memory-steward/backfill/handler.js +9 -0
- package/dist/subsystems/safety-guard/config.yaml +3 -1
- package/dist/subsystems/wisdom-steward/evaluate/config.yaml +50 -50
- package/dist/subsystems/wisdom-steward/formation/SUBSYSTEM.md +42 -42
- package/dist/subsystems/wisdom-steward/formation/config.yaml +54 -54
- package/dist/subsystems/wisdom-steward/govern/config.yaml +55 -55
- 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,463 @@
|
|
|
1
|
+
import { gateEffect } from '../../execution-environment/effect-policy.js';
|
|
2
|
+
import { resolveToolPath, isUnderAttachmentRoot, isUnderSessionUndoRoot } from './platform.js';
|
|
3
|
+
import { detectEol, toEol } from './eol.js';
|
|
4
|
+
import { assertSafeRef } from './allowlisted-run.js';
|
|
5
|
+
import { runGit } from './git-runner.js';
|
|
6
|
+
function resolveCwd(context, raw) {
|
|
7
|
+
const cwd = raw ?? context?.cwd ?? process.cwd();
|
|
8
|
+
const abs = resolveToolPath(cwd, context?.cwd, {
|
|
9
|
+
allowRoots: context?.pathRoots,
|
|
10
|
+
containment: context?.pathContainment,
|
|
11
|
+
});
|
|
12
|
+
if (isUnderAttachmentRoot(abs, context?.attachmentRoots)) {
|
|
13
|
+
throw new Error('session attachments are read-only; cannot run git under attachments root');
|
|
14
|
+
}
|
|
15
|
+
if (isUnderSessionUndoRoot(abs, context?.undoRoots)) {
|
|
16
|
+
throw new Error('session undo ledger is protected; cannot run git under sessions undo dir');
|
|
17
|
+
}
|
|
18
|
+
return abs;
|
|
19
|
+
}
|
|
20
|
+
function assertPathSafe(raw, context, label) {
|
|
21
|
+
const abs = resolveToolPath(raw, context?.cwd, {
|
|
22
|
+
allowRoots: context?.pathRoots,
|
|
23
|
+
containment: context?.pathContainment,
|
|
24
|
+
});
|
|
25
|
+
if (isUnderAttachmentRoot(abs, context?.attachmentRoots)) {
|
|
26
|
+
throw new Error(`session attachments are read-only; cannot ${label} under attachments root`);
|
|
27
|
+
}
|
|
28
|
+
if (isUnderSessionUndoRoot(abs, context?.undoRoots)) {
|
|
29
|
+
throw new Error(`session undo ledger is protected; cannot ${label} under sessions undo dir`);
|
|
30
|
+
}
|
|
31
|
+
return abs;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Pathspec for git porcelain.
|
|
35
|
+
*
|
|
36
|
+
* Simple paths are L2-resolved (absolute + roots-checked). Glob/magic specs
|
|
37
|
+
* (src/*.ts, :(exclude)...) must stay relative - absolute-resolving them
|
|
38
|
+
* turns the pattern into a literal path and silently matches nothing. Those
|
|
39
|
+
* pass through after a .. / absolute / NUL ban; cwd is already L2-contained.
|
|
40
|
+
*/
|
|
41
|
+
function toGitPathspec(raw, context, label) {
|
|
42
|
+
const isMagic = raw.startsWith(':(') || /[*?\[]/.test(raw);
|
|
43
|
+
if (!isMagic) {
|
|
44
|
+
return assertPathSafe(raw, context, label);
|
|
45
|
+
}
|
|
46
|
+
if (raw.startsWith('/') ||
|
|
47
|
+
raw.startsWith('\\\\') ||
|
|
48
|
+
(process.platform === 'win32' && /^[A-Za-z]:[\\/]/.test(raw))) {
|
|
49
|
+
throw new Error(`pathspec_glob_unsupported: absolute glob "${raw}" is not supported; use a relative glob (e.g. src/*.ts)`);
|
|
50
|
+
}
|
|
51
|
+
if (raw.split(/[\\/]/).some((seg) => seg === '..')) {
|
|
52
|
+
throw new Error(`pathspec_glob_forbidden: ".." is not allowed in glob pathspec "${raw}"`);
|
|
53
|
+
}
|
|
54
|
+
if (raw.includes('\0')) {
|
|
55
|
+
throw new Error(`pathspec_invalid: "${raw}" contains a NUL byte`);
|
|
56
|
+
}
|
|
57
|
+
return raw;
|
|
58
|
+
}
|
|
59
|
+
function toText(result) {
|
|
60
|
+
return {
|
|
61
|
+
stdout: result.stdout,
|
|
62
|
+
stderr: result.stderr,
|
|
63
|
+
exitCode: result.exitCode,
|
|
64
|
+
durationMs: result.durationMs,
|
|
65
|
+
truncated: result.truncated,
|
|
66
|
+
terminated: result.terminated,
|
|
67
|
+
terminateReason: result.terminateReason,
|
|
68
|
+
isolation: result.isolation,
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
/** git_status — porcelain working tree status */
|
|
72
|
+
export function createGitStatusTool() {
|
|
73
|
+
return {
|
|
74
|
+
definition: {
|
|
75
|
+
name: 'git_status',
|
|
76
|
+
capabilities: ['vcs', 'fs-read'],
|
|
77
|
+
description: 'Show git working tree status (porcelain v1 + branch header). Prefer this over shell git status. Read-only.',
|
|
78
|
+
parameters: {
|
|
79
|
+
cwd: { type: 'string', description: 'Repository path (defaults to workspace cwd)' },
|
|
80
|
+
paths: {
|
|
81
|
+
type: 'array',
|
|
82
|
+
description: 'Optional pathspecs to limit the status',
|
|
83
|
+
items: { type: 'string', description: 'Path or pathspec' },
|
|
84
|
+
},
|
|
85
|
+
},
|
|
86
|
+
},
|
|
87
|
+
handler: async (args, context) => {
|
|
88
|
+
const cwd = resolveCwd(context, args.cwd);
|
|
89
|
+
const paths = Array.isArray(args.paths) ? args.paths : [];
|
|
90
|
+
const pathArgs = paths.length > 0 ? ['--', ...paths.map((p) => toGitPathspec(p, context, 'status'))] : [];
|
|
91
|
+
const result = await runGit(context, cwd, [
|
|
92
|
+
'status',
|
|
93
|
+
'--porcelain=v1',
|
|
94
|
+
'--branch',
|
|
95
|
+
'--untracked-files=all',
|
|
96
|
+
...pathArgs,
|
|
97
|
+
]);
|
|
98
|
+
return { ...toText(result), cwd };
|
|
99
|
+
},
|
|
100
|
+
};
|
|
101
|
+
}
|
|
102
|
+
/** git_diff — unstaged / staged / vs-ref diff */
|
|
103
|
+
export function createGitDiffTool() {
|
|
104
|
+
return {
|
|
105
|
+
definition: {
|
|
106
|
+
name: 'git_diff',
|
|
107
|
+
capabilities: ['vcs', 'fs-read'],
|
|
108
|
+
description: 'Show a git diff. mode: unstaged (default) | staged | commit (vs a revision). Prefer this over shell git diff. Read-only.',
|
|
109
|
+
parameters: {
|
|
110
|
+
cwd: { type: 'string', description: 'Repository path' },
|
|
111
|
+
mode: {
|
|
112
|
+
type: 'string',
|
|
113
|
+
description: 'Diff mode',
|
|
114
|
+
enum: ['unstaged', 'staged', 'commit'],
|
|
115
|
+
default: 'unstaged',
|
|
116
|
+
},
|
|
117
|
+
revision: {
|
|
118
|
+
type: 'string',
|
|
119
|
+
description: 'Revision for mode=commit (e.g. HEAD~1, main)',
|
|
120
|
+
},
|
|
121
|
+
stat: { type: 'boolean', description: 'Show diffstat instead of full patch' },
|
|
122
|
+
paths: {
|
|
123
|
+
type: 'array',
|
|
124
|
+
description: 'Optional pathspecs',
|
|
125
|
+
items: { type: 'string', description: 'Path or pathspec' },
|
|
126
|
+
},
|
|
127
|
+
},
|
|
128
|
+
},
|
|
129
|
+
handler: async (args, context) => {
|
|
130
|
+
const cwd = resolveCwd(context, args.cwd);
|
|
131
|
+
const modeRaw = args.mode ?? 'unstaged';
|
|
132
|
+
if (!['unstaged', 'staged', 'commit'].includes(modeRaw)) {
|
|
133
|
+
throw new Error(`git_diff: unsupported mode "${modeRaw}" (use unstaged|staged|commit)`);
|
|
134
|
+
}
|
|
135
|
+
const mode = modeRaw;
|
|
136
|
+
const gitArgs = ['diff', '--no-color', '--no-ext-diff'];
|
|
137
|
+
if (mode === 'staged')
|
|
138
|
+
gitArgs.push('--cached');
|
|
139
|
+
if (mode === 'commit') {
|
|
140
|
+
const rev = assertSafeRef(String(args.revision ?? 'HEAD'), 'revision');
|
|
141
|
+
gitArgs.push(rev);
|
|
142
|
+
}
|
|
143
|
+
if (args.stat === true)
|
|
144
|
+
gitArgs.push('--stat');
|
|
145
|
+
const paths = Array.isArray(args.paths) ? args.paths : [];
|
|
146
|
+
if (paths.length > 0) {
|
|
147
|
+
gitArgs.push('--', ...paths.map((p) => toGitPathspec(p, context, 'diff')));
|
|
148
|
+
}
|
|
149
|
+
const result = await runGit(context, cwd, gitArgs, { timeoutMs: 120_000 });
|
|
150
|
+
return { ...toText(result), cwd, mode };
|
|
151
|
+
},
|
|
152
|
+
};
|
|
153
|
+
}
|
|
154
|
+
/** git_log — commit history */
|
|
155
|
+
export function createGitLogTool() {
|
|
156
|
+
return {
|
|
157
|
+
definition: {
|
|
158
|
+
name: 'git_log',
|
|
159
|
+
capabilities: ['vcs', 'fs-read'],
|
|
160
|
+
description: 'Show commit history (oneline by default). Prefer this over shell git log. Read-only.',
|
|
161
|
+
parameters: {
|
|
162
|
+
cwd: { type: 'string', description: 'Repository path' },
|
|
163
|
+
limit: {
|
|
164
|
+
type: 'number',
|
|
165
|
+
description: 'Max commits (default 20, max 200)',
|
|
166
|
+
minimum: 1,
|
|
167
|
+
maximum: 200,
|
|
168
|
+
},
|
|
169
|
+
revision: { type: 'string', description: 'Starting revision (default HEAD)' },
|
|
170
|
+
oneline: { type: 'boolean', description: 'Compact one-line format (default true)' },
|
|
171
|
+
paths: {
|
|
172
|
+
type: 'array',
|
|
173
|
+
description: 'Optional pathspecs',
|
|
174
|
+
items: { type: 'string', description: 'Path or pathspec' },
|
|
175
|
+
},
|
|
176
|
+
},
|
|
177
|
+
},
|
|
178
|
+
handler: async (args, context) => {
|
|
179
|
+
const cwd = resolveCwd(context, args.cwd);
|
|
180
|
+
const rawLimit = Number(args.limit);
|
|
181
|
+
const limit = Number.isFinite(rawLimit) ? Math.min(Math.max(Math.trunc(rawLimit), 1), 200) : 20;
|
|
182
|
+
const rev = assertSafeRef(String(args.revision ?? 'HEAD'), 'revision');
|
|
183
|
+
const oneline = args.oneline !== false;
|
|
184
|
+
const gitArgs = ['log', '--no-ext-diff', `--max-count=${limit}`];
|
|
185
|
+
if (oneline)
|
|
186
|
+
gitArgs.push('--oneline', '--decorate');
|
|
187
|
+
gitArgs.push(rev);
|
|
188
|
+
const paths = Array.isArray(args.paths) ? args.paths : [];
|
|
189
|
+
if (paths.length > 0) {
|
|
190
|
+
gitArgs.push('--', ...paths.map((p) => toGitPathspec(p, context, 'log')));
|
|
191
|
+
}
|
|
192
|
+
const result = await runGit(context, cwd, gitArgs);
|
|
193
|
+
return { ...toText(result), cwd, limit, revision: rev };
|
|
194
|
+
},
|
|
195
|
+
};
|
|
196
|
+
}
|
|
197
|
+
/** git_show — show a commit / tree / blob */
|
|
198
|
+
export function createGitShowTool() {
|
|
199
|
+
return {
|
|
200
|
+
definition: {
|
|
201
|
+
name: 'git_show',
|
|
202
|
+
capabilities: ['vcs', 'fs-read'],
|
|
203
|
+
description: 'Show a git object (commit, tag, or tree). Read-only.',
|
|
204
|
+
parameters: {
|
|
205
|
+
cwd: { type: 'string', description: 'Repository path' },
|
|
206
|
+
revision: { type: 'string', description: 'Revision to show (default HEAD)', default: 'HEAD' },
|
|
207
|
+
stat: { type: 'boolean', description: 'Show diffstat instead of full patch' },
|
|
208
|
+
},
|
|
209
|
+
},
|
|
210
|
+
handler: async (args, context) => {
|
|
211
|
+
const cwd = resolveCwd(context, args.cwd);
|
|
212
|
+
const rev = assertSafeRef(String(args.revision ?? 'HEAD'), 'revision');
|
|
213
|
+
const gitArgs = ['show', '--no-color', '--no-ext-diff'];
|
|
214
|
+
if (args.stat === true)
|
|
215
|
+
gitArgs.push('--stat');
|
|
216
|
+
gitArgs.push(rev);
|
|
217
|
+
const result = await runGit(context, cwd, gitArgs, { timeoutMs: 120_000 });
|
|
218
|
+
return { ...toText(result), cwd, revision: rev };
|
|
219
|
+
},
|
|
220
|
+
};
|
|
221
|
+
}
|
|
222
|
+
/** git_commit — add paths + commit (hooks disabled) */
|
|
223
|
+
export function createGitCommitTool() {
|
|
224
|
+
return {
|
|
225
|
+
definition: {
|
|
226
|
+
name: 'git_commit',
|
|
227
|
+
capabilities: ['vcs', 'fs-write'],
|
|
228
|
+
description: 'Stage paths and create a commit. Hooks and gpg signing disabled (--no-verify --no-gpg-sign); filters neutralized. Prefer this over shell git commit.',
|
|
229
|
+
parameters: {
|
|
230
|
+
cwd: { type: 'string', description: 'Repository path' },
|
|
231
|
+
message: { type: 'string', description: 'Commit message', required: true },
|
|
232
|
+
paths: {
|
|
233
|
+
type: 'array',
|
|
234
|
+
description: 'Paths to stage and commit (omit to commit already-staged changes)',
|
|
235
|
+
items: { type: 'string', description: 'Path' },
|
|
236
|
+
},
|
|
237
|
+
all: {
|
|
238
|
+
type: 'boolean',
|
|
239
|
+
description: 'Stage all tracked modifications (git add -A on given paths or repo)',
|
|
240
|
+
},
|
|
241
|
+
amend: { type: 'boolean', description: 'Amend the previous commit' },
|
|
242
|
+
eol: {
|
|
243
|
+
type: 'string',
|
|
244
|
+
description: 'EOL handling for staged text files: "normalize" (default; rewrite each staged file to the EOL convention of its HEAD blob before commit, avoiding whole-file line-ending churn) | "keep" (commit bytes as-is)',
|
|
245
|
+
enum: ['normalize', 'keep'],
|
|
246
|
+
},
|
|
247
|
+
},
|
|
248
|
+
},
|
|
249
|
+
handler: async (args, context) => {
|
|
250
|
+
const cwd = resolveCwd(context, args.cwd);
|
|
251
|
+
const message = String(args.message ?? '').trim();
|
|
252
|
+
if (!message)
|
|
253
|
+
throw new Error('git_commit: message is required');
|
|
254
|
+
await gateEffect({
|
|
255
|
+
kind: 'vcs',
|
|
256
|
+
operation: 'commit',
|
|
257
|
+
cwd,
|
|
258
|
+
description: `git commit: ${message.slice(0, 80)}`,
|
|
259
|
+
}, {
|
|
260
|
+
effects: context?.effectChannel ?? 'engine',
|
|
261
|
+
confirmEffect: context?.confirmEffect,
|
|
262
|
+
sessionId: context?.sessionId,
|
|
263
|
+
agentId: context?.agentId,
|
|
264
|
+
});
|
|
265
|
+
const paths = Array.isArray(args.paths) ? args.paths : [];
|
|
266
|
+
const resolvedPaths = paths.map((p) => toGitPathspec(p, context, 'commit'));
|
|
267
|
+
const useAll = args.all === true;
|
|
268
|
+
if (resolvedPaths.length > 0 || useAll) {
|
|
269
|
+
const addArgs = ['add'];
|
|
270
|
+
if (useAll)
|
|
271
|
+
addArgs.push('-A');
|
|
272
|
+
if (resolvedPaths.length > 0)
|
|
273
|
+
addArgs.push('--', ...resolvedPaths);
|
|
274
|
+
const addResult = await runGit(context, cwd, addArgs, { journal: true });
|
|
275
|
+
if (addResult.exitCode !== 0) {
|
|
276
|
+
return { ...toText(addResult), stage: 'add', cwd };
|
|
277
|
+
}
|
|
278
|
+
}
|
|
279
|
+
// EOL 归一:工具 git 隔离全局配置(autocrlf 不可见),worktree 的 CRLF 会被
|
|
280
|
+
// 原样入库,与 HEAD blob 的行尾约定相悖时产生整文件 churn。跟随 HEAD blob 的
|
|
281
|
+
// 行尾约定重写已暂存文本文件(新文件 / 删除 / 二进制 / 非 UTF-8 不动)。
|
|
282
|
+
const eolNormalized = [];
|
|
283
|
+
if (args.eol !== 'keep') {
|
|
284
|
+
const staged = await runGit(context, cwd, ['diff', '--cached', '--name-only', '-z', 'HEAD']);
|
|
285
|
+
if (staged.exitCode === 0) {
|
|
286
|
+
const { readFile, writeFile } = await import('node:fs/promises');
|
|
287
|
+
const { join: joinPath } = await import('node:path');
|
|
288
|
+
for (const rel of staged.stdout.split('\0').map((s) => s.trim()).filter(Boolean)) {
|
|
289
|
+
const abs = joinPath(cwd, rel);
|
|
290
|
+
const workBuf = await readFile(abs).catch(() => undefined);
|
|
291
|
+
if (!workBuf || workBuf.includes(0))
|
|
292
|
+
continue;
|
|
293
|
+
let workText;
|
|
294
|
+
try {
|
|
295
|
+
workText = new TextDecoder('utf-8', { fatal: true }).decode(workBuf);
|
|
296
|
+
}
|
|
297
|
+
catch {
|
|
298
|
+
continue;
|
|
299
|
+
}
|
|
300
|
+
const head = await runGit(context, cwd, ['show', `HEAD:${rel}`]);
|
|
301
|
+
if (head.exitCode !== 0)
|
|
302
|
+
continue;
|
|
303
|
+
const normalized = toEol(workText, detectEol(head.stdout));
|
|
304
|
+
if (normalized === workText)
|
|
305
|
+
continue;
|
|
306
|
+
await writeFile(abs, normalized);
|
|
307
|
+
await runGit(context, cwd, ['add', '--', rel]);
|
|
308
|
+
eolNormalized.push(rel);
|
|
309
|
+
}
|
|
310
|
+
}
|
|
311
|
+
}
|
|
312
|
+
const commitArgs = ['commit', '--no-verify', '--no-gpg-sign', '-m', message];
|
|
313
|
+
if (args.amend === true)
|
|
314
|
+
commitArgs.push('--amend');
|
|
315
|
+
if (resolvedPaths.length > 0) {
|
|
316
|
+
// Limit the commit to the given paths (working-tree state).
|
|
317
|
+
commitArgs.push('--', ...resolvedPaths);
|
|
318
|
+
}
|
|
319
|
+
const result = await runGit(context, cwd, commitArgs, {
|
|
320
|
+
journal: true,
|
|
321
|
+
timeoutMs: 60_000,
|
|
322
|
+
});
|
|
323
|
+
return { ...toText(result), stage: 'commit', cwd, message, eolNormalized };
|
|
324
|
+
},
|
|
325
|
+
};
|
|
326
|
+
}
|
|
327
|
+
/** git_branch — list / create / switch / delete */
|
|
328
|
+
export function createGitBranchTool() {
|
|
329
|
+
return {
|
|
330
|
+
definition: {
|
|
331
|
+
name: 'git_branch',
|
|
332
|
+
capabilities: ['vcs', 'fs-write'],
|
|
333
|
+
description: 'List, create, switch, or delete local branches. action: list (default) | create | switch | delete.',
|
|
334
|
+
parameters: {
|
|
335
|
+
cwd: { type: 'string', description: 'Repository path' },
|
|
336
|
+
action: {
|
|
337
|
+
type: 'string',
|
|
338
|
+
description: 'Branch action',
|
|
339
|
+
enum: ['list', 'create', 'switch', 'delete'],
|
|
340
|
+
default: 'list',
|
|
341
|
+
},
|
|
342
|
+
name: {
|
|
343
|
+
type: 'string',
|
|
344
|
+
description: 'Branch name (required for create/switch/delete)',
|
|
345
|
+
},
|
|
346
|
+
startPoint: {
|
|
347
|
+
type: 'string',
|
|
348
|
+
description: 'Start point for create (e.g. HEAD~1)',
|
|
349
|
+
},
|
|
350
|
+
},
|
|
351
|
+
},
|
|
352
|
+
handler: async (args, context) => {
|
|
353
|
+
const cwd = resolveCwd(context, args.cwd);
|
|
354
|
+
const action = args.action ?? 'list';
|
|
355
|
+
const name = args.name !== undefined ? assertSafeRef(String(args.name), 'branch') : undefined;
|
|
356
|
+
if (action === 'list') {
|
|
357
|
+
const result = await runGit(context, cwd, ['branch', '--list', '--verbose']);
|
|
358
|
+
return { ...toText(result), cwd, action };
|
|
359
|
+
}
|
|
360
|
+
if (!name)
|
|
361
|
+
throw new Error(`git_branch: name is required for action=${action}`);
|
|
362
|
+
await gateEffect({
|
|
363
|
+
kind: 'vcs',
|
|
364
|
+
operation: `branch.${action}`,
|
|
365
|
+
cwd,
|
|
366
|
+
description: `git branch ${action} ${name}`,
|
|
367
|
+
}, {
|
|
368
|
+
effects: context?.effectChannel ?? 'engine',
|
|
369
|
+
confirmEffect: context?.confirmEffect,
|
|
370
|
+
sessionId: context?.sessionId,
|
|
371
|
+
agentId: context?.agentId,
|
|
372
|
+
});
|
|
373
|
+
let gitArgs;
|
|
374
|
+
if (action === 'create') {
|
|
375
|
+
gitArgs = ['branch', name];
|
|
376
|
+
if (args.startPoint !== undefined) {
|
|
377
|
+
gitArgs.push(assertSafeRef(String(args.startPoint), 'startPoint'));
|
|
378
|
+
}
|
|
379
|
+
}
|
|
380
|
+
else if (action === 'switch') {
|
|
381
|
+
gitArgs = ['switch', name];
|
|
382
|
+
}
|
|
383
|
+
else if (action === 'delete') {
|
|
384
|
+
gitArgs = ['branch', '-d', name];
|
|
385
|
+
}
|
|
386
|
+
else {
|
|
387
|
+
throw new Error(`git_branch: unsupported action "${action}"`);
|
|
388
|
+
}
|
|
389
|
+
const result = await runGit(context, cwd, gitArgs, { journal: true });
|
|
390
|
+
return { ...toText(result), cwd, action, name };
|
|
391
|
+
},
|
|
392
|
+
};
|
|
393
|
+
}
|
|
394
|
+
/** git_restore — restore working tree / index paths */
|
|
395
|
+
export function createGitRestoreTool() {
|
|
396
|
+
return {
|
|
397
|
+
definition: {
|
|
398
|
+
name: 'git_restore',
|
|
399
|
+
capabilities: ['vcs', 'fs-write'],
|
|
400
|
+
description: 'Restore files from a source revision (or unstage them). Prefer this over shell git checkout/restore.',
|
|
401
|
+
parameters: {
|
|
402
|
+
cwd: { type: 'string', description: 'Repository path' },
|
|
403
|
+
paths: {
|
|
404
|
+
type: 'array',
|
|
405
|
+
description: 'Paths to restore',
|
|
406
|
+
items: { type: 'string', description: 'Path' },
|
|
407
|
+
required: true,
|
|
408
|
+
},
|
|
409
|
+
source: {
|
|
410
|
+
type: 'string',
|
|
411
|
+
description: 'Source revision (default: keep current index/worktree rules)',
|
|
412
|
+
},
|
|
413
|
+
staged: { type: 'boolean', description: 'Unstage paths (restore index only)' },
|
|
414
|
+
worktree: { type: 'boolean', description: 'Restore working tree (default true when not staged-only)' },
|
|
415
|
+
},
|
|
416
|
+
},
|
|
417
|
+
// 覆写工作树文件(index):所在 tool_call 批次整体串行,防与同路径写交错
|
|
418
|
+
executionMode: 'sequential',
|
|
419
|
+
handler: async (args, context) => {
|
|
420
|
+
const cwd = resolveCwd(context, args.cwd);
|
|
421
|
+
const paths = Array.isArray(args.paths) ? args.paths : [];
|
|
422
|
+
if (paths.length === 0)
|
|
423
|
+
throw new Error('git_restore: paths is required');
|
|
424
|
+
const resolvedPaths = paths.map((p) => toGitPathspec(p, context, 'restore'));
|
|
425
|
+
await gateEffect({
|
|
426
|
+
kind: 'vcs',
|
|
427
|
+
operation: 'restore',
|
|
428
|
+
cwd,
|
|
429
|
+
description: `git restore ${resolvedPaths.join(' ')}`,
|
|
430
|
+
}, {
|
|
431
|
+
effects: context?.effectChannel ?? 'engine',
|
|
432
|
+
confirmEffect: context?.confirmEffect,
|
|
433
|
+
sessionId: context?.sessionId,
|
|
434
|
+
agentId: context?.agentId,
|
|
435
|
+
});
|
|
436
|
+
const gitArgs = ['restore'];
|
|
437
|
+
if (args.staged === true)
|
|
438
|
+
gitArgs.push('--staged');
|
|
439
|
+
if (args.worktree !== false && args.staged !== true)
|
|
440
|
+
gitArgs.push('--worktree');
|
|
441
|
+
if (args.staged === true && args.worktree === true)
|
|
442
|
+
gitArgs.push('--worktree');
|
|
443
|
+
if (args.source !== undefined) {
|
|
444
|
+
gitArgs.push(`--source=${assertSafeRef(String(args.source), 'source')}`);
|
|
445
|
+
}
|
|
446
|
+
gitArgs.push('--', ...resolvedPaths);
|
|
447
|
+
const result = await runGit(context, cwd, gitArgs, { journal: true });
|
|
448
|
+
return { ...toText(result), cwd, paths: resolvedPaths };
|
|
449
|
+
},
|
|
450
|
+
};
|
|
451
|
+
}
|
|
452
|
+
/** All git_* tools (read + write). */
|
|
453
|
+
export function createGitTools() {
|
|
454
|
+
return [
|
|
455
|
+
createGitStatusTool(),
|
|
456
|
+
createGitDiffTool(),
|
|
457
|
+
createGitLogTool(),
|
|
458
|
+
createGitShowTool(),
|
|
459
|
+
createGitCommitTool(),
|
|
460
|
+
createGitBranchTool(),
|
|
461
|
+
createGitRestoreTool(),
|
|
462
|
+
];
|
|
463
|
+
}
|
|
@@ -2,27 +2,31 @@
|
|
|
2
2
|
* http_request 工具 — HTTP 请求
|
|
3
3
|
*
|
|
4
4
|
* 让 Agent 能够主动发起 HTTP 请求,调用 REST API、获取网页内容。
|
|
5
|
-
* 使用 Node.js 20+ 内置 fetch,零额外依赖。
|
|
6
5
|
*
|
|
7
|
-
*
|
|
6
|
+
* 出站:经 knowledge/network-guard SSRF 门(默认拒私网/环回/metadata;
|
|
7
|
+
* connect 时 lookup 再校验)。内网目标需 `network.allowPrivateNetwork` 显式开。
|
|
8
|
+
* 重定向每跳复验。shell `curl` 不经此路径(见 docs/KNOWN-ISSUES)。
|
|
8
9
|
*
|
|
9
|
-
*
|
|
10
|
-
* - 生产环境应通过 ToolPolicy 限制可访问的域名
|
|
11
|
-
* - 内网访问默认允许,可通过 security guard 拦截
|
|
10
|
+
* 超长响应:经 capabilities SummaryPort 做 L2 软净化 + L1 硬顶(见 arch/summary-compact.md §3.6)。
|
|
12
11
|
*/
|
|
13
12
|
import type { RegisteredTool } from '@octopi-agent/core/types.js';
|
|
14
13
|
import { type ToolSummarySupport } from '../../../context/capabilities/summary/index.js';
|
|
15
14
|
import type { CredentialStore } from '../../../governance/credentials/store.js';
|
|
15
|
+
import { type NetworkGuardOptions } from '../../../knowledge/network-guard.js';
|
|
16
16
|
export interface HttpRequestToolOptions {
|
|
17
17
|
/** Summary L1/L2 支持;未提供时仅使用内置 L1 binding */
|
|
18
18
|
summary?: ToolSummarySupport;
|
|
19
19
|
/** 凭证库(credential 参数按名注入 header,模型不见明文) */
|
|
20
20
|
credentials?: CredentialStore | null;
|
|
21
|
+
/** SSRF 门选项(allowPrivateNetwork / timeout / maxRedirects…) */
|
|
22
|
+
network?: NetworkGuardOptions;
|
|
23
|
+
/** 强制 credential_bindings(空绑定即拒);缺省随 store / Run 上下文 */
|
|
24
|
+
requireBindings?: boolean;
|
|
21
25
|
}
|
|
22
26
|
/**
|
|
23
27
|
* 创建 http_request 工具
|
|
24
28
|
*
|
|
25
|
-
* @param options - 可选 SummaryPort /
|
|
29
|
+
* @param options - 可选 SummaryPort / CredentialStore / network 门禁
|
|
26
30
|
* @returns RegisteredTool
|
|
27
31
|
*/
|
|
28
32
|
export declare function createHttpRequestTool(options?: HttpRequestToolOptions): RegisteredTool;
|
|
@@ -2,26 +2,28 @@
|
|
|
2
2
|
* http_request 工具 — HTTP 请求
|
|
3
3
|
*
|
|
4
4
|
* 让 Agent 能够主动发起 HTTP 请求,调用 REST API、获取网页内容。
|
|
5
|
-
* 使用 Node.js 20+ 内置 fetch,零额外依赖。
|
|
6
5
|
*
|
|
7
|
-
*
|
|
6
|
+
* 出站:经 knowledge/network-guard SSRF 门(默认拒私网/环回/metadata;
|
|
7
|
+
* connect 时 lookup 再校验)。内网目标需 `network.allowPrivateNetwork` 显式开。
|
|
8
|
+
* 重定向每跳复验。shell `curl` 不经此路径(见 docs/KNOWN-ISSUES)。
|
|
8
9
|
*
|
|
9
|
-
*
|
|
10
|
-
* - 生产环境应通过 ToolPolicy 限制可访问的域名
|
|
11
|
-
* - 内网访问默认允许,可通过 security guard 拦截
|
|
10
|
+
* 超长响应:经 capabilities SummaryPort 做 L2 软净化 + L1 硬顶(见 arch/summary-compact.md §3.6)。
|
|
12
11
|
*/
|
|
13
12
|
import { applyToolOutputGate, resolveSupportBinding, } from '../../../context/capabilities/summary/index.js';
|
|
13
|
+
import { guardedRequest, } from '../../../knowledge/network-guard.js';
|
|
14
|
+
const HTTP_CONSUMER = { kind: 'tool', id: 'http_request' };
|
|
14
15
|
/**
|
|
15
16
|
* 创建 http_request 工具
|
|
16
17
|
*
|
|
17
|
-
* @param options - 可选 SummaryPort /
|
|
18
|
+
* @param options - 可选 SummaryPort / CredentialStore / network 门禁
|
|
18
19
|
* @returns RegisteredTool
|
|
19
20
|
*/
|
|
20
21
|
export function createHttpRequestTool(options) {
|
|
21
22
|
return {
|
|
22
23
|
definition: {
|
|
23
24
|
name: 'http_request',
|
|
24
|
-
|
|
25
|
+
capabilities: ['egress'],
|
|
26
|
+
description: 'Make an HTTP request to a URL. Supports GET, POST, PUT, PATCH, DELETE. Returns status, headers, and body (large bodies may be summarized). Useful for API calls, web scraping, and webhook testing. Private/loopback/metadata addresses are blocked unless explicitly allowed.',
|
|
25
27
|
parameters: {
|
|
26
28
|
url: {
|
|
27
29
|
type: 'string',
|
|
@@ -40,7 +42,7 @@ export function createHttpRequestTool(options) {
|
|
|
40
42
|
},
|
|
41
43
|
credential: {
|
|
42
44
|
type: 'string',
|
|
43
|
-
description: 'Named credential from the credential store (auth headers injected server-side; secret never returned)',
|
|
45
|
+
description: 'Named credential from the credential store (auth headers injected server-side; secret never returned). Subject to credential_bindings when bindings exist.',
|
|
44
46
|
},
|
|
45
47
|
body: {
|
|
46
48
|
type: 'string',
|
|
@@ -74,23 +76,34 @@ export function createHttpRequestTool(options) {
|
|
|
74
76
|
},
|
|
75
77
|
timeoutMs: 120_000,
|
|
76
78
|
},
|
|
77
|
-
handler: async (args,
|
|
79
|
+
handler: async (args, context) => {
|
|
78
80
|
const url = args.url;
|
|
79
|
-
const method = args.method ?? 'GET';
|
|
81
|
+
const method = (args.method ?? 'GET').toUpperCase();
|
|
80
82
|
const headers = args.headers ?? {};
|
|
81
83
|
const credentialName = args.credential;
|
|
84
|
+
// jail network deny(workspace/untrusted)时强制不放行私网
|
|
85
|
+
const allowPrivateNetwork = context?.networkPolicy === 'deny'
|
|
86
|
+
? false
|
|
87
|
+
: (options?.network?.allowPrivateNetwork ?? false);
|
|
82
88
|
if (credentialName) {
|
|
83
89
|
const store = options?.credentials;
|
|
84
90
|
if (!store) {
|
|
85
91
|
throw new Error('credential parameter requires a configured CredentialStore');
|
|
86
92
|
}
|
|
87
|
-
|
|
93
|
+
// 只紧不松:config/tool/context/untrusted 任一为 true 即强制
|
|
94
|
+
const requireBindings = context?.requireCredentialBindings === true ||
|
|
95
|
+
options?.requireBindings === true;
|
|
96
|
+
const resolved = await store.resolve(credentialName, HTTP_CONSUMER, {
|
|
97
|
+
requireBindings: requireBindings ? true : undefined,
|
|
98
|
+
});
|
|
88
99
|
if (!resolved) {
|
|
89
100
|
throw new Error(`credential not found or secret unavailable: ${credentialName}`);
|
|
90
101
|
}
|
|
91
|
-
// 凭证作底,显式 headers
|
|
102
|
+
// 凭证作底,显式 headers 可覆盖(头名统一小写,避免大小写双写)
|
|
92
103
|
for (const [k, v] of Object.entries(resolved.headers)) {
|
|
93
|
-
|
|
104
|
+
const lk = k.toLowerCase();
|
|
105
|
+
const has = Object.keys(headers).some((h) => h.toLowerCase() === lk);
|
|
106
|
+
if (!has)
|
|
94
107
|
headers[k] = v;
|
|
95
108
|
}
|
|
96
109
|
}
|
|
@@ -98,40 +111,21 @@ export function createHttpRequestTool(options) {
|
|
|
98
111
|
const timeout = Math.min(args.timeout ?? 30_000, 120_000);
|
|
99
112
|
const maxResponseSize = args.max_response_size ?? 1_048_576;
|
|
100
113
|
const summarizeArg = args.summarize;
|
|
101
|
-
const controller = new AbortController();
|
|
102
|
-
const timer = setTimeout(() => controller.abort(), timeout);
|
|
103
114
|
try {
|
|
104
|
-
const response = await
|
|
115
|
+
const response = await guardedRequest(url, {
|
|
116
|
+
...options?.network,
|
|
117
|
+
allowPrivateNetwork,
|
|
105
118
|
method,
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
let totalBytes = 0;
|
|
117
|
-
while (true) {
|
|
118
|
-
const { done, value } = await reader.read();
|
|
119
|
-
if (done)
|
|
120
|
-
break;
|
|
121
|
-
totalBytes += value.byteLength;
|
|
122
|
-
responseBody += decoder.decode(value, { stream: true });
|
|
123
|
-
if (totalBytes >= maxResponseSize) {
|
|
124
|
-
truncated = true;
|
|
125
|
-
reader.cancel();
|
|
126
|
-
break;
|
|
127
|
-
}
|
|
128
|
-
}
|
|
129
|
-
}
|
|
130
|
-
const responseHeaders = {};
|
|
131
|
-
response.headers.forEach((value, key) => {
|
|
132
|
-
responseHeaders[key] = value;
|
|
133
|
-
});
|
|
134
|
-
const contentType = responseHeaders['content-type'] ?? responseHeaders['Content-Type'];
|
|
119
|
+
body,
|
|
120
|
+
timeoutMs: timeout,
|
|
121
|
+
maxResponseBytes: maxResponseSize,
|
|
122
|
+
headers: {
|
|
123
|
+
...headers,
|
|
124
|
+
},
|
|
125
|
+
}, { headers });
|
|
126
|
+
const responseBody = response.body;
|
|
127
|
+
const truncated = response.bodyTruncated === true;
|
|
128
|
+
const contentType = response.headers['content-type'] ?? response.headers['Content-Type'];
|
|
135
129
|
const support = options?.summary;
|
|
136
130
|
// 统一从 support(含配置 toolBindings)解析,避免 tools 再写死默认 binding
|
|
137
131
|
const binding = resolveSupportBinding('http_request', support, 8000);
|
|
@@ -149,7 +143,7 @@ export function createHttpRequestTool(options) {
|
|
|
149
143
|
return {
|
|
150
144
|
status: response.status,
|
|
151
145
|
statusText: response.statusText,
|
|
152
|
-
headers:
|
|
146
|
+
headers: response.headers,
|
|
153
147
|
body: applied.body,
|
|
154
148
|
bodyTruncated: truncated || applied.bodyTruncated,
|
|
155
149
|
bodySizeBytes: applied.rawSizeBytes,
|
|
@@ -160,7 +154,7 @@ export function createHttpRequestTool(options) {
|
|
|
160
154
|
};
|
|
161
155
|
}
|
|
162
156
|
catch (error) {
|
|
163
|
-
if (error instanceof Error && error.
|
|
157
|
+
if (error instanceof Error && /timeout/i.test(error.message)) {
|
|
164
158
|
throw new Error(`Request to "${url}" timed out after ${timeout}ms`);
|
|
165
159
|
}
|
|
166
160
|
throw new Error(`HTTP request failed: ${error instanceof Error ? error.message : String(error)}`);
|
|
@@ -1,4 +1,10 @@
|
|
|
1
1
|
export { getBuiltinTools } from './builtin.js';
|
|
2
|
+
export { createGitTools } from './git-tools.js';
|
|
3
|
+
export { runGit } from './git-runner.js';
|
|
4
|
+
export type { RunGitOptions } from './git-runner.js';
|
|
5
|
+
export { readGitStatusSnapshot, parsePorcelainV2 } from './git-status-snapshot.js';
|
|
6
|
+
export type { GitStatusSnapshot, GitStatusSnapshotBody, GitStatusSnapshotOptions, GitStatusEntry, GitStatusBranch, GitStatusCounts, GitStatusGroup, GitStatusKind, } from './git-status-snapshot.js';
|
|
7
|
+
export { createPackageTools } from './package-tools.js';
|
|
2
8
|
export { createDocumentReadTool, createDocumentProbeTool } from './document-tools.js';
|
|
3
9
|
export { createFileEditTool } from './file-edit.js';
|
|
4
10
|
export { createFileSearchTool } from './file-search.js';
|