@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
|
@@ -5,21 +5,50 @@
|
|
|
5
5
|
* 或硬编码 `/bin/bash` 导致 Windows 行为分裂。
|
|
6
6
|
*/
|
|
7
7
|
import { accessSync, constants, existsSync, statSync } from 'node:fs';
|
|
8
|
-
import { delimiter, isAbsolute, join, resolve, sep } from 'node:path';
|
|
8
|
+
import { delimiter, dirname, isAbsolute, join, resolve, sep } from 'node:path';
|
|
9
9
|
/**
|
|
10
10
|
* 解析工具入参路径:绝对路径原样返回,相对路径相对 cwd
|
|
11
11
|
*
|
|
12
|
-
* 使用
|
|
13
|
-
* `C:\` / `C:/` 与 UNC `\\server\share`。
|
|
12
|
+
* 使用 path.isAbsolute,同时覆盖 POSIX /foo、Windows 盘符与 UNC。
|
|
14
13
|
*
|
|
15
14
|
* @param rawPath - 工具入参路径
|
|
16
|
-
* @param cwd - 工作目录;缺省为
|
|
15
|
+
* @param cwd - 工作目录;缺省为 process.cwd()
|
|
16
|
+
* @param options - L2 路径包含(ToolEffectPolicy)
|
|
17
17
|
* @returns 规范化后的绝对路径
|
|
18
18
|
*/
|
|
19
|
-
export function resolveToolPath(rawPath, cwd) {
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
19
|
+
export function resolveToolPath(rawPath, cwd, options) {
|
|
20
|
+
const abs = isAbsolute(rawPath) ? resolve(rawPath) : resolve(cwd ?? process.cwd(), rawPath);
|
|
21
|
+
const containment = options?.containment ?? 'none';
|
|
22
|
+
if (containment !== 'none') {
|
|
23
|
+
const roots = options?.allowRoots ?? [];
|
|
24
|
+
if (roots.length === 0) {
|
|
25
|
+
// strict 无 root = fail-closed(与 isPathAllowed 一致);soft 仅审计
|
|
26
|
+
if (containment === 'strict') {
|
|
27
|
+
throw new Error(`path_forbidden: "${rawPath}" effect roots not configured`);
|
|
28
|
+
}
|
|
29
|
+
return abs;
|
|
30
|
+
}
|
|
31
|
+
if (!isPathUnderRoots(abs, roots)) {
|
|
32
|
+
if (containment === 'strict') {
|
|
33
|
+
throw new Error(`path_forbidden: "${rawPath}" escapes effect roots`);
|
|
34
|
+
}
|
|
35
|
+
// soft:放行(审计由调用方/Observer 负责)
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
return abs;
|
|
39
|
+
}
|
|
40
|
+
/** 路径是否落在任一 root 之下(含 root 本身) */
|
|
41
|
+
export function isPathUnderRoots(absPath, roots) {
|
|
42
|
+
const win = process.platform === 'win32';
|
|
43
|
+
const norm = (s) => {
|
|
44
|
+
const r = resolve(s);
|
|
45
|
+
return win ? r.toLowerCase() : r;
|
|
46
|
+
};
|
|
47
|
+
const p = norm(absPath);
|
|
48
|
+
return roots.some((root) => {
|
|
49
|
+
const r = norm(root);
|
|
50
|
+
return p === r || p.startsWith(r.endsWith(sep) ? r : r + sep);
|
|
51
|
+
});
|
|
23
52
|
}
|
|
24
53
|
/**
|
|
25
54
|
* 只读附件根内解析(OP-15):相对名优先贴到 attachmentRoots
|
|
@@ -29,7 +58,7 @@ export function resolveToolPath(rawPath, cwd) {
|
|
|
29
58
|
* @param attachmentRoots - 只读会话附件根
|
|
30
59
|
* @returns 规范化后的绝对路径
|
|
31
60
|
*/
|
|
32
|
-
export function resolveReadableToolPath(rawPath, cwd, attachmentRoots) {
|
|
61
|
+
export function resolveReadableToolPath(rawPath, cwd, attachmentRoots, options) {
|
|
33
62
|
const roots = attachmentRoots ?? [];
|
|
34
63
|
// 绝对路径原样;相对路径先试 attachments 根(文件名直呼)
|
|
35
64
|
if (!isAbsolute(rawPath) && roots.length > 0) {
|
|
@@ -44,7 +73,8 @@ export function resolveReadableToolPath(rawPath, cwd, attachmentRoots) {
|
|
|
44
73
|
}
|
|
45
74
|
}
|
|
46
75
|
}
|
|
47
|
-
|
|
76
|
+
// attachments 命中后返回;其余走 L2
|
|
77
|
+
return resolveToolPath(rawPath, cwd, options);
|
|
48
78
|
}
|
|
49
79
|
/**
|
|
50
80
|
* 是否为会话附件根下的路径(写保护)
|
|
@@ -102,8 +132,16 @@ export function findExecutable(name) {
|
|
|
102
132
|
const lower = name.toLowerCase();
|
|
103
133
|
const hasOwnExt = pathExt.some((e) => lower.endsWith(e.toLowerCase()));
|
|
104
134
|
for (const dir of dirs) {
|
|
105
|
-
|
|
106
|
-
|
|
135
|
+
// Prefer real PE via PATHEXT (.EXE/.COM) over extensionless shims and
|
|
136
|
+
// .CMD/.BAT (Node ≥18.20 refuses spawn of .cmd/.bat — CVE-2024-27980).
|
|
137
|
+
const ordered = hasOwnExt
|
|
138
|
+
? [name]
|
|
139
|
+
: [
|
|
140
|
+
...pathExt.filter((e) => !/^\.(cmd|bat)$/i.test(e)).map((e) => name + e),
|
|
141
|
+
...pathExt.filter((e) => /^\.(cmd|bat)$/i.test(e)).map((e) => name + e),
|
|
142
|
+
name,
|
|
143
|
+
];
|
|
144
|
+
for (const candidate of ordered) {
|
|
107
145
|
const full = join(dir, candidate);
|
|
108
146
|
if (isExecutableFile(full))
|
|
109
147
|
return full;
|
|
@@ -127,6 +165,83 @@ export function findExecutable(name) {
|
|
|
127
165
|
export function commandExists(name) {
|
|
128
166
|
return findExecutable(name) !== null;
|
|
129
167
|
}
|
|
168
|
+
/**
|
|
169
|
+
* Resolve a Node-based CLI (npm / pnpm / yarn) to a spawnable argv head.
|
|
170
|
+
*
|
|
171
|
+
* Windows never spawns `.cmd`/`.bat` directly (Node ≥18.20 throws EINVAL,
|
|
172
|
+
* CVE-2024-27980). Prefer `node <package-cli.js>` when the shim layout is
|
|
173
|
+
* known; otherwise fall back to the resolved path only when it is a real PE.
|
|
174
|
+
*
|
|
175
|
+
* @param name - tool name (`npm` | `pnpm` | `yarn`)
|
|
176
|
+
* @returns executable + prefix args inserted before user args
|
|
177
|
+
*/
|
|
178
|
+
export function resolveNodeToolCommand(name) {
|
|
179
|
+
const found = findExecutable(name);
|
|
180
|
+
if (!found) {
|
|
181
|
+
throw new Error(`${name}_not_found: "${name}" is not on PATH. Install it on the host or use package_edit / file tools instead.`);
|
|
182
|
+
}
|
|
183
|
+
const lower = found.toLowerCase();
|
|
184
|
+
const isCmdShim = lower.endsWith('.cmd') || lower.endsWith('.bat');
|
|
185
|
+
// Extensionless shims on Windows (e.g. the bash `npm` script) are not spawnable as PE.
|
|
186
|
+
const looksLikeScript = process.platform === 'win32' && (isCmdShim || (!lower.endsWith('.exe') && !lower.endsWith('.com')));
|
|
187
|
+
if (!looksLikeScript) {
|
|
188
|
+
return { executable: found, prefixArgs: [] };
|
|
189
|
+
}
|
|
190
|
+
const dir = dirname(found);
|
|
191
|
+
const node = findExecutable('node') ?? process.execPath;
|
|
192
|
+
const jsCandidates = [
|
|
193
|
+
join(dir, 'node_modules', name, 'bin', `${name}-cli.js`),
|
|
194
|
+
join(dir, 'node_modules', name, 'bin', `${name}.js`),
|
|
195
|
+
join(dir, 'node_modules', name, 'bin', `${name}.cjs`),
|
|
196
|
+
join(dir, 'node_modules', name, 'lib', 'cli.js'),
|
|
197
|
+
join(dir, '..', 'node_modules', name, 'bin', `${name}-cli.js`),
|
|
198
|
+
join(dir, '..', 'lib', name, 'bin', `${name}-cli.js`),
|
|
199
|
+
];
|
|
200
|
+
for (const candidate of jsCandidates) {
|
|
201
|
+
if (existsSync(candidate)) {
|
|
202
|
+
return { executable: node, prefixArgs: [candidate] };
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
throw new Error(`${name}_windows_spawn_unsupported: cannot resolve "${found}" to a node JS entry (CVE-2024-27980 forbids spawning .cmd). Run the install manually on the host, or use a ${name} installed as a real PE.`);
|
|
206
|
+
}
|
|
207
|
+
/**
|
|
208
|
+
* Minimal platform env for child processes (allowlist-shaped; no secret inherit).
|
|
209
|
+
* Only keys already accepted by `scrubEnv` are included.
|
|
210
|
+
*
|
|
211
|
+
* @returns env map with PATH plus OS essentials when present
|
|
212
|
+
*/
|
|
213
|
+
export function defaultChildEnv() {
|
|
214
|
+
const keys = [
|
|
215
|
+
'HOME',
|
|
216
|
+
'USERPROFILE',
|
|
217
|
+
'HOMEDRIVE',
|
|
218
|
+
'HOMEPATH',
|
|
219
|
+
'TMP',
|
|
220
|
+
'TEMP',
|
|
221
|
+
'TMPDIR',
|
|
222
|
+
'LANG',
|
|
223
|
+
'LC_ALL',
|
|
224
|
+
'LC_CTYPE',
|
|
225
|
+
'TZ',
|
|
226
|
+
'SHELL',
|
|
227
|
+
'TERM',
|
|
228
|
+
'COMSPEC',
|
|
229
|
+
'PATHEXT',
|
|
230
|
+
'SYSTEMROOT',
|
|
231
|
+
'SystemRoot',
|
|
232
|
+
'WINDIR',
|
|
233
|
+
'windir',
|
|
234
|
+
'USER',
|
|
235
|
+
'LOGNAME',
|
|
236
|
+
];
|
|
237
|
+
const out = { PATH: defaultPathEnv() };
|
|
238
|
+
for (const k of keys) {
|
|
239
|
+
const v = process.env[k];
|
|
240
|
+
if (v !== undefined)
|
|
241
|
+
out[k] = v;
|
|
242
|
+
}
|
|
243
|
+
return out;
|
|
244
|
+
}
|
|
130
245
|
function unixShell() {
|
|
131
246
|
for (const candidate of ['/bin/bash', 'bash']) {
|
|
132
247
|
const found = candidate.startsWith('/')
|
|
@@ -249,3 +364,27 @@ export function defaultPathEnv() {
|
|
|
249
364
|
}
|
|
250
365
|
return process.env.PATH ?? '/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin';
|
|
251
366
|
}
|
|
367
|
+
/**
|
|
368
|
+
* True when `target` is the session undo ledger root or under it (D6-a).
|
|
369
|
+
* Prefers real root comparison against injected `undoRoots`; falls back to an
|
|
370
|
+
* exact `sessions/<id>/undo` path-shape match when the runner did not inject.
|
|
371
|
+
*
|
|
372
|
+
* @param target - absolute or relative path under consideration
|
|
373
|
+
* @param undoRoots - resolveSessionUndoPaths roots (optional)
|
|
374
|
+
* @returns whether the path is protected undo ledger
|
|
375
|
+
*/
|
|
376
|
+
export function isUnderSessionUndoRoot(target, undoRoots) {
|
|
377
|
+
const resolved = resolve(target);
|
|
378
|
+
const roots = (undoRoots ?? []).map((r) => r?.trim()).filter(Boolean);
|
|
379
|
+
const fold = (p) => process.platform === 'win32' ? p.toLowerCase() : p;
|
|
380
|
+
if (roots.length > 0) {
|
|
381
|
+
const norm = (p) => fold(resolve(p).replace(/\\/g, '/'));
|
|
382
|
+
const tNorm = norm(resolved);
|
|
383
|
+
return roots.some((root) => {
|
|
384
|
+
const r = norm(root);
|
|
385
|
+
return tNorm === r || tNorm.startsWith(r.endsWith('/') ? r : r + '/');
|
|
386
|
+
});
|
|
387
|
+
}
|
|
388
|
+
const norm = fold(resolved.replace(/\\/g, '/'));
|
|
389
|
+
return /\/sessions\/[^/]+\/undo(\/|$)/i.test(norm);
|
|
390
|
+
}
|
|
@@ -20,6 +20,7 @@ export function createSessionSearchTool(options) {
|
|
|
20
20
|
return {
|
|
21
21
|
definition: {
|
|
22
22
|
name: 'session_search',
|
|
23
|
+
capabilities: ['fs-read'],
|
|
23
24
|
description: 'Search past session conversations (Information layer, not memory propositions). Returns session-grouped hits with snippet + `ref` for session_read. Prefer concrete entities (paths, error strings, names). Default excludes tool I/O and archived cold storage. Use memory_search for distilled conclusions; use this for original wording / what happened.',
|
|
24
25
|
parameters: {
|
|
25
26
|
query: {
|
|
@@ -98,6 +99,7 @@ export function createSessionReadTool(options) {
|
|
|
98
99
|
return {
|
|
99
100
|
definition: {
|
|
100
101
|
name: 'session_read',
|
|
102
|
+
capabilities: ['fs-read'],
|
|
101
103
|
description: 'Open a window of past session messages around a hit (`ref` from session_search) or index. Returns transcript lines. Read-only. Use after session_search to recover original context.',
|
|
102
104
|
parameters: {
|
|
103
105
|
session_id: { type: 'string', description: 'Session id', required: true },
|
|
@@ -29,7 +29,16 @@ import type { LLMToolDefinition } from '@octopi-agent/core/interfaces/model-prov
|
|
|
29
29
|
export declare class DefaultToolBus implements ToolBus {
|
|
30
30
|
private globalTools;
|
|
31
31
|
private agentTools;
|
|
32
|
-
|
|
32
|
+
/**
|
|
33
|
+
* Register a global tool.
|
|
34
|
+
*
|
|
35
|
+
* Duplicate names throw by default: silent replace lets a later plugin
|
|
36
|
+
* shadow `file_write`/`shell` and bypass L2/undo. Intentional reload uses
|
|
37
|
+
* `{ replace: true }` (audited via console.warn).
|
|
38
|
+
*/
|
|
39
|
+
register(tool: RegisteredTool, options?: {
|
|
40
|
+
replace?: boolean;
|
|
41
|
+
}): void;
|
|
33
42
|
registerAll(tools: RegisteredTool[]): void;
|
|
34
43
|
registerForAgent(agentId: string, tool: RegisteredTool): void;
|
|
35
44
|
unregister(name: string, agentId?: string): boolean;
|
|
@@ -16,6 +16,8 @@
|
|
|
16
16
|
*
|
|
17
17
|
* @module harness/extension/plugin-ecosystem/tools/tool-bus
|
|
18
18
|
*/
|
|
19
|
+
import { registerToolCapabilities } from '../../execution-environment/tool-capabilities.js';
|
|
20
|
+
import { buildToolLlmParameters } from '../../../agent/tool-purpose.js';
|
|
19
21
|
/**
|
|
20
22
|
* DefaultToolBus — 工具总线实现
|
|
21
23
|
*
|
|
@@ -27,12 +29,24 @@ export class DefaultToolBus {
|
|
|
27
29
|
globalTools = new Map();
|
|
28
30
|
agentTools = new Map();
|
|
29
31
|
// ── 注册 ──
|
|
30
|
-
|
|
32
|
+
/**
|
|
33
|
+
* Register a global tool.
|
|
34
|
+
*
|
|
35
|
+
* Duplicate names throw by default: silent replace lets a later plugin
|
|
36
|
+
* shadow `file_write`/`shell` and bypass L2/undo. Intentional reload uses
|
|
37
|
+
* `{ replace: true }` (audited via console.warn).
|
|
38
|
+
*/
|
|
39
|
+
register(tool, options) {
|
|
31
40
|
const { name } = tool.definition;
|
|
32
|
-
|
|
33
|
-
|
|
41
|
+
const exists = this.globalTools.has(name);
|
|
42
|
+
if (exists && !options?.replace) {
|
|
43
|
+
throw new Error(`Global tool "${name}" already registered (pass replace:true to override)`);
|
|
44
|
+
}
|
|
45
|
+
if (exists && options?.replace) {
|
|
46
|
+
console.warn(`[ToolBus] global tool "${name}" explicitly replaced`);
|
|
34
47
|
}
|
|
35
48
|
this.globalTools.set(name, tool);
|
|
49
|
+
registerToolCapabilities(name, tool.definition.capabilities);
|
|
36
50
|
}
|
|
37
51
|
registerAll(tools) {
|
|
38
52
|
for (const tool of tools) {
|
|
@@ -44,6 +58,7 @@ export class DefaultToolBus {
|
|
|
44
58
|
this.agentTools.set(agentId, new Map());
|
|
45
59
|
}
|
|
46
60
|
this.agentTools.get(agentId).set(tool.definition.name, tool);
|
|
61
|
+
registerToolCapabilities(tool.definition.name, tool.definition.capabilities);
|
|
47
62
|
}
|
|
48
63
|
unregister(name, agentId) {
|
|
49
64
|
if (agentId) {
|
|
@@ -87,7 +102,13 @@ export class DefaultToolBus {
|
|
|
87
102
|
}
|
|
88
103
|
if (policy.deny && policy.deny.length > 0) {
|
|
89
104
|
const denySet = new Set(policy.deny);
|
|
90
|
-
|
|
105
|
+
// deny '*' = deny every tool (mirror allow '*')
|
|
106
|
+
if (denySet.has('*')) {
|
|
107
|
+
tools = [];
|
|
108
|
+
}
|
|
109
|
+
else {
|
|
110
|
+
tools = tools.filter(t => !denySet.has(t.definition.name));
|
|
111
|
+
}
|
|
91
112
|
}
|
|
92
113
|
}
|
|
93
114
|
return tools;
|
|
@@ -98,20 +119,8 @@ export class DefaultToolBus {
|
|
|
98
119
|
function: {
|
|
99
120
|
name: definition.definition.name,
|
|
100
121
|
description: definition.definition.description,
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
properties: Object.fromEntries(Object.entries(definition.definition.parameters).map(([key, param]) => [
|
|
104
|
-
key,
|
|
105
|
-
{
|
|
106
|
-
type: param.type,
|
|
107
|
-
description: param.description,
|
|
108
|
-
...(param.enum && { enum: param.enum }),
|
|
109
|
-
},
|
|
110
|
-
])),
|
|
111
|
-
required: Object.entries(definition.definition.parameters)
|
|
112
|
-
.filter(([, param]) => param.required)
|
|
113
|
-
.map(([key]) => key),
|
|
114
|
-
},
|
|
122
|
+
// 与 convertToAgentTool 同构:purpose 统一装配
|
|
123
|
+
parameters: buildToolLlmParameters(definition.definition.parameters),
|
|
115
124
|
},
|
|
116
125
|
}));
|
|
117
126
|
}
|
|
@@ -151,7 +160,14 @@ export class DefaultToolBus {
|
|
|
151
160
|
throw new Error(`Tool "${name}" not found`);
|
|
152
161
|
}
|
|
153
162
|
this.validateArgs(name, args, tool.definition);
|
|
154
|
-
|
|
163
|
+
const { runWithToolLimits, resolveToolTimeoutMs } = await import('../../execution-environment/resource-limits.js');
|
|
164
|
+
return runWithToolLimits((signal) => tool.handler(args, { ...context, abortSignal: signal }), {
|
|
165
|
+
timeoutMs: context.processLimits !== false
|
|
166
|
+
? resolveToolTimeoutMs(tool.definition)
|
|
167
|
+
: undefined,
|
|
168
|
+
abortSignal: context.abortSignal,
|
|
169
|
+
toolName: tool.definition.name,
|
|
170
|
+
});
|
|
155
171
|
}
|
|
156
172
|
/**
|
|
157
173
|
* 获取全局注册的工具名集合(用于 SecurityGuard 的 registeredTools 校验)
|
|
@@ -23,10 +23,18 @@ export interface ToolSetConfig {
|
|
|
23
23
|
};
|
|
24
24
|
/** Summary 公用能力(http_request / file_read L1/L2) */
|
|
25
25
|
summary?: import('../../../context/capabilities/summary/index.js').ToolSummarySupport;
|
|
26
|
+
/** CredentialStore — http_request.credential(绑定强制见 store.resolve) */
|
|
27
|
+
credentials?: import('../../../governance/credentials/store.js').CredentialStore | null;
|
|
28
|
+
/** http_request 网络门禁(默认拒私网) */
|
|
29
|
+
network?: import('../../../knowledge/network-guard.js').NetworkGuardOptions;
|
|
30
|
+
/** 无绑定凭证拒绝(credentials.requireBindings / untrusted) */
|
|
31
|
+
requireCredentialBindings?: boolean;
|
|
26
32
|
/** DocumentPort(document_read / document_probe) */
|
|
27
33
|
documentPort?: import('./document-tools.js').DocumentToolOptions['documentPort'];
|
|
28
34
|
/** Information 历史检索(session_search / session_read) */
|
|
29
35
|
sessionHistory?: SessionHistoryPort;
|
|
36
|
+
/** DelegateService — 委派编排(delegate_* 工具) */
|
|
37
|
+
delegation?: import('../../../collaboration/delegation/service.js').DelegateService;
|
|
30
38
|
}
|
|
31
39
|
export interface ToolSet {
|
|
32
40
|
builtin: RegisteredTool[];
|
|
@@ -4,11 +4,15 @@ import { createSessionTaskTools } from '../../../session/tasks/tools.js';
|
|
|
4
4
|
import { createAskUserTool } from './ask-user.js';
|
|
5
5
|
import { createWebSearchTool } from './web-search.js';
|
|
6
6
|
import { createSessionHistoryTools } from './session-history.js';
|
|
7
|
+
import { createDelegationTools } from './delegation.js';
|
|
7
8
|
export function createToolSet(config) {
|
|
8
9
|
const taskService = config?.sessionTaskService ?? config?.taskTracker;
|
|
9
10
|
const builtin = getBuiltinTools({
|
|
10
11
|
summary: config?.summary,
|
|
11
12
|
documentPort: config?.documentPort,
|
|
13
|
+
credentials: config?.credentials,
|
|
14
|
+
network: config?.network,
|
|
15
|
+
requireCredentialBindings: config?.requireCredentialBindings,
|
|
12
16
|
});
|
|
13
17
|
const extensions = [
|
|
14
18
|
...(config?.memoryStore ? createMemoryTools(config.memoryStore, config?.memory) : []),
|
|
@@ -28,6 +32,7 @@ export function createToolSet(config) {
|
|
|
28
32
|
summary: config?.summary,
|
|
29
33
|
})
|
|
30
34
|
: []),
|
|
35
|
+
...(config?.delegation ? createDelegationTools(config.delegation) : []),
|
|
31
36
|
];
|
|
32
37
|
return { builtin, extensions, all: [...builtin, ...extensions] };
|
|
33
38
|
}
|
|
@@ -17,6 +17,7 @@ export function createWebSearchTool(provider, options = {}) {
|
|
|
17
17
|
return {
|
|
18
18
|
definition: {
|
|
19
19
|
name: 'web_search',
|
|
20
|
+
capabilities: ['egress'],
|
|
20
21
|
description: 'Search the web for current information. Returns titles, URLs, and snippets. ' +
|
|
21
22
|
'Use when you need up-to-date facts, documentation, news, or sources outside the local workspace.',
|
|
22
23
|
parameters: {
|
|
@@ -6,4 +6,4 @@ export type { CredentialDatabaseOptions, CredentialPaths } from './db.js';
|
|
|
6
6
|
export { CredentialStore } from './store.js';
|
|
7
7
|
export { loadCredentialMasterKey, encryptSecret, decryptSecret, } from './crypto.js';
|
|
8
8
|
export { defaultCredentialHeaders } from './types.js';
|
|
9
|
-
export type { CredentialKind, CredentialScopeLevel, CredentialScopeRef, CredentialConsumerKind, CredentialConsumerRef, CredentialMeta, CredentialWrite, ResolvedCredential, SecretMode, } from './types.js';
|
|
9
|
+
export type { CredentialKind, CredentialScopeLevel, CredentialScopeRef, CredentialConsumerKind, CredentialConsumerRef, CredentialMeta, CredentialWrite, ResolvedCredential, ResolveCredentialOptions, SecretMode, } from './types.js';
|
|
@@ -8,14 +8,21 @@ import { CredentialDatabase } from './db.js';
|
|
|
8
8
|
import { type CredentialConsumerRef, type CredentialMeta, type CredentialWrite, type ResolvedCredential } from './types.js';
|
|
9
9
|
export declare class CredentialStore {
|
|
10
10
|
private db;
|
|
11
|
-
|
|
11
|
+
/** true 时无绑定的凭证不可 resolve(部署拧紧 / untrusted) */
|
|
12
|
+
private readonly requireBindings;
|
|
13
|
+
constructor(db: CredentialDatabase, options?: {
|
|
14
|
+
requireBindings?: boolean;
|
|
15
|
+
});
|
|
12
16
|
static open(options?: {
|
|
13
17
|
dbPath?: string;
|
|
18
|
+
requireBindings?: boolean;
|
|
14
19
|
}): Promise<CredentialStore>;
|
|
15
20
|
/**
|
|
16
21
|
* 按 OCTOPI_HOME 打开默认 credentials.db
|
|
17
22
|
*/
|
|
18
|
-
static openDefault(octopiHome: string
|
|
23
|
+
static openDefault(octopiHome: string, options?: {
|
|
24
|
+
requireBindings?: boolean;
|
|
25
|
+
}): Promise<CredentialStore>;
|
|
19
26
|
get database(): CredentialDatabase;
|
|
20
27
|
/**
|
|
21
28
|
* 登记/轮换凭证(元数据 + 密钥引用;不回传密文)
|
|
@@ -32,12 +39,17 @@ export declare class CredentialStore {
|
|
|
32
39
|
list(): CredentialMeta[];
|
|
33
40
|
delete(name: string): boolean;
|
|
34
41
|
/**
|
|
35
|
-
*
|
|
42
|
+
* 用时解析为请求头(短命;调用方禁止日志)。
|
|
43
|
+
* 消费侧强制 `credential_bindings`(SEC-3c):绑定非空须命中 consumer;
|
|
44
|
+
* 绑定为空且 requireBindings 时拒绝。
|
|
36
45
|
*
|
|
37
46
|
* @param name - 凭证名
|
|
47
|
+
* @param consumer - 消费方;绑定非空时必填
|
|
48
|
+
* @param options - requireBindings 覆盖
|
|
38
49
|
* @returns 解析结果;无档或无密钥材料时 null
|
|
50
|
+
* @throws 绑定策略拒绝时抛错(勿静默降级)
|
|
39
51
|
*/
|
|
40
|
-
resolve(name: string): Promise<ResolvedCredential | null>;
|
|
52
|
+
resolve(name: string, consumer?: import('./types.js').CredentialConsumerRef | null, options?: import('./types.js').ResolveCredentialOptions): Promise<ResolvedCredential | null>;
|
|
41
53
|
bind(consumer: CredentialConsumerRef, name: string): void;
|
|
42
54
|
unbind(consumer: CredentialConsumerRef, name: string): void;
|
|
43
55
|
listBindings(name: string): Array<{
|
|
@@ -38,19 +38,25 @@ function rowToMeta(row) {
|
|
|
38
38
|
}
|
|
39
39
|
export class CredentialStore {
|
|
40
40
|
db;
|
|
41
|
-
|
|
41
|
+
/** true 时无绑定的凭证不可 resolve(部署拧紧 / untrusted) */
|
|
42
|
+
requireBindings;
|
|
43
|
+
constructor(db, options) {
|
|
42
44
|
this.db = db;
|
|
45
|
+
this.requireBindings = options?.requireBindings === true;
|
|
43
46
|
}
|
|
44
47
|
static async open(options) {
|
|
45
48
|
const db = await CredentialDatabase.create(options);
|
|
46
|
-
return new CredentialStore(db);
|
|
49
|
+
return new CredentialStore(db, { requireBindings: options?.requireBindings });
|
|
47
50
|
}
|
|
48
51
|
/**
|
|
49
52
|
* 按 OCTOPI_HOME 打开默认 credentials.db
|
|
50
53
|
*/
|
|
51
|
-
static async openDefault(octopiHome) {
|
|
54
|
+
static async openDefault(octopiHome, options) {
|
|
52
55
|
const paths = resolveCredentialPaths(octopiHome);
|
|
53
|
-
return CredentialStore.open({
|
|
56
|
+
return CredentialStore.open({
|
|
57
|
+
dbPath: paths.dbPath,
|
|
58
|
+
requireBindings: options?.requireBindings,
|
|
59
|
+
});
|
|
54
60
|
}
|
|
55
61
|
get database() {
|
|
56
62
|
return this.db;
|
|
@@ -141,12 +147,17 @@ export class CredentialStore {
|
|
|
141
147
|
return Number(res.changes ?? 0) > 0;
|
|
142
148
|
}
|
|
143
149
|
/**
|
|
144
|
-
*
|
|
150
|
+
* 用时解析为请求头(短命;调用方禁止日志)。
|
|
151
|
+
* 消费侧强制 `credential_bindings`(SEC-3c):绑定非空须命中 consumer;
|
|
152
|
+
* 绑定为空且 requireBindings 时拒绝。
|
|
145
153
|
*
|
|
146
154
|
* @param name - 凭证名
|
|
155
|
+
* @param consumer - 消费方;绑定非空时必填
|
|
156
|
+
* @param options - requireBindings 覆盖
|
|
147
157
|
* @returns 解析结果;无档或无密钥材料时 null
|
|
158
|
+
* @throws 绑定策略拒绝时抛错(勿静默降级)
|
|
148
159
|
*/
|
|
149
|
-
async resolve(name) {
|
|
160
|
+
async resolve(name, consumer, options) {
|
|
150
161
|
const row = this.db.raw
|
|
151
162
|
.prepare(`SELECT * FROM credentials WHERE name = ?`)
|
|
152
163
|
.get(name);
|
|
@@ -156,6 +167,22 @@ export class CredentialStore {
|
|
|
156
167
|
if (meta.expiresAt != null && meta.expiresAt < Date.now()) {
|
|
157
168
|
return null;
|
|
158
169
|
}
|
|
170
|
+
// 只紧不松:显式 true 可收紧;false/undefined 不得覆盖 store 级 requireBindings
|
|
171
|
+
const require = options?.requireBindings === true || this.requireBindings === true;
|
|
172
|
+
const bindings = this.listBindings(name);
|
|
173
|
+
if (require && bindings.length === 0) {
|
|
174
|
+
throw new Error(`credential "${name}" has no bindings and requireBindings is enabled`);
|
|
175
|
+
}
|
|
176
|
+
if (bindings.length > 0) {
|
|
177
|
+
const ref = consumer ?? options?.consumer ?? null;
|
|
178
|
+
if (!ref) {
|
|
179
|
+
throw new Error(`credential "${name}" is bound; consumer required to resolve`);
|
|
180
|
+
}
|
|
181
|
+
const hit = bindings.some((b) => b.kind === ref.kind && b.id === ref.id);
|
|
182
|
+
if (!hit) {
|
|
183
|
+
throw new Error(`credential "${name}" is not bound to consumer ${ref.kind}:${ref.id}`);
|
|
184
|
+
}
|
|
185
|
+
}
|
|
159
186
|
const kind = meta.kind;
|
|
160
187
|
let secret = null;
|
|
161
188
|
if (meta.secretMode === 'env' && meta.secretEnv) {
|
|
@@ -58,6 +58,17 @@ export interface ResolvedCredential {
|
|
|
58
58
|
name: string;
|
|
59
59
|
headers: Record<string, string>;
|
|
60
60
|
}
|
|
61
|
+
/**
|
|
62
|
+
* resolve 消费约束(SEC-3c)。
|
|
63
|
+
* - 绑定表非空 → consumer 必须命中,否则拒绝
|
|
64
|
+
* - 绑定表为空 → 默认可解析(兼容);requireBindings=true 时拒绝
|
|
65
|
+
*/
|
|
66
|
+
export interface ResolveCredentialOptions {
|
|
67
|
+
/** 消费方(knowledge_source / tool / …);绑定非空时必填 */
|
|
68
|
+
consumer?: CredentialConsumerRef | null;
|
|
69
|
+
/** 覆盖 store 级 requireBindings(untrusted 严档 / 配置) */
|
|
70
|
+
requireBindings?: boolean;
|
|
71
|
+
}
|
|
61
72
|
export declare function defaultCredentialHeaders(input: {
|
|
62
73
|
kind: CredentialKind;
|
|
63
74
|
username?: string;
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* HITL decision cache (SEC-7 single model).
|
|
3
|
+
*
|
|
4
|
+
* Hosts only *express* a {@link HitlDecision}; the engine remembers
|
|
5
|
+
* `approve_session` / `approve_always` so the confirm hook is not re-entered.
|
|
6
|
+
* `deny` and one-shot `approve` are never cached.
|
|
7
|
+
*
|
|
8
|
+
* Scoping (narrow-only):
|
|
9
|
+
* - `approve_session` → per `sessionId` + tool/effect key
|
|
10
|
+
* - `approve_always` → per `agentId` + tool/effect key(agent 信任级不同则分桶)
|
|
11
|
+
* Missing scope id → degrade to one-shot (never over-grant).
|
|
12
|
+
*/
|
|
13
|
+
import type { HitlDecision } from '@octopi-agent/core/types/tools.js';
|
|
14
|
+
/** Which confirm surface produced the decision */
|
|
15
|
+
export type HitlChannel = 'high_risk' | 'effect';
|
|
16
|
+
/** Cached scope of a remembered approval */
|
|
17
|
+
export type HitlCacheScope = 'session' | 'always';
|
|
18
|
+
/**
|
|
19
|
+
* In-memory HITL approval cache.
|
|
20
|
+
*
|
|
21
|
+
* Session-scoped approvals are keyed by `sessionId` and expire after
|
|
22
|
+
* {@link HitlDecisionCache.sessionTtlMs}. Always-scoped approvals are keyed by
|
|
23
|
+
* `agentId` and live for the process lifetime (not persisted).
|
|
24
|
+
*/
|
|
25
|
+
export declare class HitlDecisionCache {
|
|
26
|
+
/** Session-scope TTL in ms (default 24h) */
|
|
27
|
+
readonly sessionTtlMs: number;
|
|
28
|
+
private session;
|
|
29
|
+
private always;
|
|
30
|
+
/** In-flight resolves, so concurrent same-key confirms share one ask() */
|
|
31
|
+
private inflight;
|
|
32
|
+
/**
|
|
33
|
+
* @param sessionTtlMs - how long `approve_session` stays valid (default 24h)
|
|
34
|
+
*/
|
|
35
|
+
constructor(sessionTtlMs?: number);
|
|
36
|
+
/**
|
|
37
|
+
* Look up a remembered approval.
|
|
38
|
+
*
|
|
39
|
+
* @param channel - high_risk | effect
|
|
40
|
+
* @param key - tool name or effect kind
|
|
41
|
+
* @param options - sessionId (session scope) and/or agentId (always scope)
|
|
42
|
+
* @returns `'approve'` if cached, otherwise `null`
|
|
43
|
+
*/
|
|
44
|
+
get(channel: HitlChannel, key: string, options?: {
|
|
45
|
+
sessionId?: string;
|
|
46
|
+
agentId?: string;
|
|
47
|
+
}): 'approve' | null;
|
|
48
|
+
/**
|
|
49
|
+
* Remember an approval decision. Only `approve_session` / `approve_always`
|
|
50
|
+
* are stored; `deny` and one-shot `approve` are ignored.
|
|
51
|
+
*
|
|
52
|
+
* `approve_session` requires `sessionId`; `approve_always` requires `agentId`.
|
|
53
|
+
* Missing scope id → silently one-shot (fail-safe, never over-grant).
|
|
54
|
+
*
|
|
55
|
+
* @param decision - host decision
|
|
56
|
+
* @param channel - high_risk | effect
|
|
57
|
+
* @param key - tool name or effect kind
|
|
58
|
+
* @param options - sessionId and/or agentId
|
|
59
|
+
*/
|
|
60
|
+
remember(decision: HitlDecision, channel: HitlChannel, key: string, options?: {
|
|
61
|
+
sessionId?: string;
|
|
62
|
+
agentId?: string;
|
|
63
|
+
}): void;
|
|
64
|
+
/**
|
|
65
|
+
* Drop session-scoped approvals for one session (always-scope kept).
|
|
66
|
+
*
|
|
67
|
+
* @param sessionId - session to clear
|
|
68
|
+
*/
|
|
69
|
+
clearSession(sessionId: string): void;
|
|
70
|
+
/** Drop always-scoped approvals for one agent. */
|
|
71
|
+
clearAgent(agentId: string): void;
|
|
72
|
+
/** Drop all cached approvals (tests / host reset). */
|
|
73
|
+
clear(): void;
|
|
74
|
+
/**
|
|
75
|
+
* Resolve through cache + host hook with in-flight de-dup.
|
|
76
|
+
* Concurrent callers for the same key share one `ask()`.
|
|
77
|
+
*/
|
|
78
|
+
resolve(options: {
|
|
79
|
+
channel: HitlChannel;
|
|
80
|
+
key: string;
|
|
81
|
+
sessionId?: string;
|
|
82
|
+
agentId?: string;
|
|
83
|
+
ask: () => Promise<HitlDecision>;
|
|
84
|
+
}): Promise<boolean>;
|
|
85
|
+
private resolveUncached;
|
|
86
|
+
}
|
|
87
|
+
/** Process-wide default cache (keys include sessionId / agentId). */
|
|
88
|
+
export declare const defaultHitlCache: HitlDecisionCache;
|
|
89
|
+
/**
|
|
90
|
+
* Resolve a HITL confirm through cache + host hook (SEC-7).
|
|
91
|
+
*
|
|
92
|
+
* Fail-closed: missing hook, thrown error, or non-approve decision → false.
|
|
93
|
+
* Concurrent same-key callers share one host prompt (in-flight de-dup).
|
|
94
|
+
*
|
|
95
|
+
* @param options - cache, channel, key, sessionId, agentId, and the host ask callback
|
|
96
|
+
* @returns true only when the call is approved (cached or live)
|
|
97
|
+
*/
|
|
98
|
+
export declare function resolveHitlDecision(options: {
|
|
99
|
+
cache?: HitlDecisionCache;
|
|
100
|
+
channel: HitlChannel;
|
|
101
|
+
key: string;
|
|
102
|
+
sessionId?: string;
|
|
103
|
+
agentId?: string;
|
|
104
|
+
ask: () => Promise<HitlDecision>;
|
|
105
|
+
}): Promise<boolean>;
|