@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
|
@@ -14,12 +14,18 @@
|
|
|
14
14
|
* ```
|
|
15
15
|
*/
|
|
16
16
|
import { DefaultToolBus } from '../extension/plugin-ecosystem/tools/tool-bus.js';
|
|
17
|
+
import { expandHomePath } from '../../paths.js';
|
|
18
|
+
import { createUnconfiguredFileEffects, createUnconfiguredMemoryEffects, } from '../extension/execution-environment/undo-log.js';
|
|
19
|
+
import { JournaledMemoryStore } from '../extension/execution-environment/memory-undo.js';
|
|
20
|
+
import { buildToolLlmParameters, prepareHandlerArgs, resolveToolCallPurpose, sanitizeToolJsonSchema, } from './tool-purpose.js';
|
|
17
21
|
import { Agent } from '../run/agent/index.js';
|
|
18
22
|
import { DEFAULT_RELIABILITY_CONFIG } from '../run/reliability/run-agent.js';
|
|
19
23
|
import { DefaultRunGuard } from '../run/run-guard/default-run-guard.js';
|
|
20
24
|
import { summarizeLlmMessages } from '../observability/observer/types.js';
|
|
21
25
|
import { SessionTaskService } from '../session/tasks/service.js';
|
|
22
26
|
import { createSessionTaskTools } from '../session/tasks/tools.js';
|
|
27
|
+
import { SessionScheduleService } from '../session/schedules/service.js';
|
|
28
|
+
import { createSessionScheduleTools } from '../session/schedules/tools.js';
|
|
23
29
|
import { InMemorySessionStore } from '../session/in-memory-store.js';
|
|
24
30
|
import { DefaultEventBus, } from '@octopi-agent/core/primitives/event-bus.js';
|
|
25
31
|
import { DefaultSecurityGuard, } from '../governance/security/default-security-guard.js';
|
|
@@ -93,52 +99,95 @@ class RuntimeToolContextProvider {
|
|
|
93
99
|
get() {
|
|
94
100
|
// I1:优先 RunScope ALS(并发 session 下不可依赖单槽 setRuntime)
|
|
95
101
|
const scope = getRunScope();
|
|
102
|
+
const unconfigured = createUnconfiguredFileEffects();
|
|
103
|
+
const unconfiguredMemory = createUnconfiguredMemoryEffects();
|
|
96
104
|
if (scope?.toolRuntime) {
|
|
97
105
|
return {
|
|
98
106
|
sessionId: scope.toolRuntime.sessionId,
|
|
99
107
|
agentId: scope.toolRuntime.agentId,
|
|
108
|
+
runId: scope.runId,
|
|
100
109
|
messages: scope.toolRuntime.messages,
|
|
101
110
|
cwd: scope.toolRuntime.cwd ?? this.cwd,
|
|
102
111
|
attachmentRoots: scope.toolRuntime.attachmentRoots,
|
|
112
|
+
fileEffects: scope.toolRuntime.fileEffects ?? unconfigured,
|
|
113
|
+
memoryEffects: scope.toolRuntime.memoryEffects ?? unconfiguredMemory,
|
|
114
|
+
pathRoots: scope.toolRuntime.pathRoots,
|
|
115
|
+
undoRoots: scope.toolRuntime.undoRoots,
|
|
116
|
+
networkPolicy: scope.toolRuntime.networkPolicy,
|
|
117
|
+
requireCredentialBindings: scope.toolRuntime.requireCredentialBindings,
|
|
118
|
+
requireJail: scope.toolRuntime.requireJail,
|
|
119
|
+
homeWrite: scope.toolRuntime.homeWrite,
|
|
120
|
+
noteSecurityDegraded: scope.toolRuntime.noteSecurityDegraded,
|
|
121
|
+
pathContainment: scope.toolRuntime.pathContainment,
|
|
122
|
+
confirmEffect: scope.toolRuntime.confirmEffect,
|
|
123
|
+
effectChannel: scope.toolRuntime.effectChannel,
|
|
124
|
+
processLimits: scope.toolRuntime.processLimits,
|
|
125
|
+
shellEscape: scope.toolRuntime.shellEscape,
|
|
126
|
+
shellJournal: scope.toolRuntime.shellJournal,
|
|
127
|
+
shellJournalLimit: scope.toolRuntime.shellJournalLimit,
|
|
103
128
|
};
|
|
104
129
|
}
|
|
105
130
|
if (scope) {
|
|
106
131
|
return {
|
|
107
132
|
sessionId: scope.sessionId,
|
|
108
133
|
agentId: scope.agentId,
|
|
134
|
+
runId: scope.runId,
|
|
109
135
|
messages: this.messages,
|
|
110
136
|
cwd: this.cwd,
|
|
137
|
+
fileEffects: unconfigured,
|
|
138
|
+
memoryEffects: unconfiguredMemory,
|
|
111
139
|
};
|
|
112
140
|
}
|
|
113
|
-
return {
|
|
141
|
+
return {
|
|
142
|
+
sessionId: this.sessionId,
|
|
143
|
+
agentId: this.agentId,
|
|
144
|
+
messages: this.messages,
|
|
145
|
+
cwd: this.cwd,
|
|
146
|
+
fileEffects: unconfigured,
|
|
147
|
+
memoryEffects: unconfiguredMemory,
|
|
148
|
+
};
|
|
114
149
|
}
|
|
115
150
|
}
|
|
151
|
+
/**
|
|
152
|
+
* 发给 LLM 的 JSON Schema 净化 + purpose 统一装配见 tool-purpose.ts(arch/tool-call-purpose.md)。
|
|
153
|
+
* 此处仅保留兼容别名。
|
|
154
|
+
*/
|
|
155
|
+
const sanitizeLlmJsonSchema = sanitizeToolJsonSchema;
|
|
116
156
|
/**
|
|
117
157
|
* 将 RegisteredTool 转换为 AgentTool(新循环格式)
|
|
158
|
+
*
|
|
159
|
+
* purpose schema 必须经 buildToolLlmParameters 统一装配,
|
|
160
|
+
* 与 gateway 热更新路径(registeredToolToAgentTool)同构。
|
|
118
161
|
*/
|
|
119
162
|
function convertToAgentTool(tool, contextProvider) {
|
|
120
163
|
return {
|
|
121
164
|
name: tool.definition.name,
|
|
122
165
|
description: tool.definition.description,
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
properties: Object.fromEntries(Object.entries(tool.definition.parameters).map(([key, param]) => [
|
|
126
|
-
key,
|
|
127
|
-
{ type: param.type, description: param.description, ...(param.enum && { enum: param.enum }) },
|
|
128
|
-
])),
|
|
129
|
-
required: Object.entries(tool.definition.parameters)
|
|
130
|
-
.filter(([, param]) => param.required)
|
|
131
|
-
.map(([key]) => key),
|
|
132
|
-
},
|
|
166
|
+
executionMode: tool.executionMode,
|
|
167
|
+
parameters: buildToolLlmParameters(tool.definition.parameters),
|
|
133
168
|
execute: async (toolCallId, args, signal) => {
|
|
134
169
|
const startTime = Date.now();
|
|
135
170
|
try {
|
|
136
171
|
const context = contextProvider.get();
|
|
137
|
-
const
|
|
172
|
+
const rawArgs = (args ?? {});
|
|
173
|
+
// schema 已 required purpose;模型漏填时推导,不中断调用
|
|
174
|
+
const purpose = resolveToolCallPurpose(tool.definition.name, rawArgs);
|
|
175
|
+
// 注入型 purpose 只为人读/审批;工具自带 purpose 是真实入参,必须进 handler
|
|
176
|
+
const handlerArgs = prepareHandlerArgs(rawArgs, tool.definition);
|
|
177
|
+
const { runWithToolLimits, resolveToolTimeoutMs } = await import('../extension/execution-environment/resource-limits.js');
|
|
178
|
+
const processLimitsEnabled = context.processLimits !== false;
|
|
179
|
+
const result = await runWithToolLimits((sig) => tool.handler(handlerArgs, { ...context, abortSignal: sig }), {
|
|
180
|
+
timeoutMs: processLimitsEnabled
|
|
181
|
+
? resolveToolTimeoutMs(tool.definition)
|
|
182
|
+
: undefined,
|
|
183
|
+
abortSignal: signal,
|
|
184
|
+
toolName: tool.definition.name,
|
|
185
|
+
});
|
|
138
186
|
return {
|
|
139
187
|
toolCallId,
|
|
140
188
|
name: tool.definition.name,
|
|
141
189
|
content: result,
|
|
190
|
+
purpose,
|
|
142
191
|
durationMs: Date.now() - startTime,
|
|
143
192
|
};
|
|
144
193
|
}
|
|
@@ -148,6 +197,9 @@ function convertToAgentTool(tool, contextProvider) {
|
|
|
148
197
|
name: tool.definition.name,
|
|
149
198
|
content: `Error: ${error instanceof Error ? error.message : String(error)}`,
|
|
150
199
|
isError: true,
|
|
200
|
+
purpose: typeof args?.purpose === 'string'
|
|
201
|
+
? String(args.purpose)
|
|
202
|
+
: '',
|
|
151
203
|
durationMs: Date.now() - startTime,
|
|
152
204
|
};
|
|
153
205
|
}
|
|
@@ -297,6 +349,8 @@ export class AgentBuilder {
|
|
|
297
349
|
_runGuard;
|
|
298
350
|
_runGuardConfig;
|
|
299
351
|
_checkpointInterval;
|
|
352
|
+
/** 模型调用 watchdog 超时(undefined = 引擎默认) */
|
|
353
|
+
_modelCallTimeouts;
|
|
300
354
|
_reliabilityConfig;
|
|
301
355
|
// Harness 组件
|
|
302
356
|
_personaWorkspaces = [];
|
|
@@ -344,6 +398,8 @@ export class AgentBuilder {
|
|
|
344
398
|
_observerHub;
|
|
345
399
|
/** 工具效应隔离(I5);Runner 解析 toolRuntime.cwd */
|
|
346
400
|
_toolIsolation;
|
|
401
|
+
_effectPolicy;
|
|
402
|
+
_confirmEffect;
|
|
347
403
|
// MCP 配置
|
|
348
404
|
_mcpConfigs = [];
|
|
349
405
|
/** MCP client 工厂(Integration 适配器由宿主注入) */
|
|
@@ -382,15 +438,28 @@ export class AgentBuilder {
|
|
|
382
438
|
}
|
|
383
439
|
return this;
|
|
384
440
|
}
|
|
385
|
-
/**
|
|
441
|
+
/** 注册工具(同名默认拒绝;单工具失败不中断其余注册) */
|
|
386
442
|
tool(tool) {
|
|
387
443
|
this._toolBus.register(tool);
|
|
388
444
|
return this;
|
|
389
445
|
}
|
|
390
|
-
/**
|
|
446
|
+
/**
|
|
447
|
+
* 覆盖注册(显式)。用于热更新/替换同名工具,不可默默发生。
|
|
448
|
+
*/
|
|
449
|
+
toolReplace(tool) {
|
|
450
|
+
this._toolBus.register(tool, { replace: true });
|
|
451
|
+
return this;
|
|
452
|
+
}
|
|
453
|
+
/** 批量注册:逐个 try/catch,避免一个工具失败拖垮整表 */
|
|
391
454
|
tools(...tools) {
|
|
392
|
-
for (const t of tools)
|
|
393
|
-
|
|
455
|
+
for (const t of tools) {
|
|
456
|
+
try {
|
|
457
|
+
this.tool(t);
|
|
458
|
+
}
|
|
459
|
+
catch (err) {
|
|
460
|
+
console.warn(`[AgentBuilder] tool register failed (${t.definition.name}): ${err instanceof Error ? err.message : String(err)}`);
|
|
461
|
+
}
|
|
462
|
+
}
|
|
394
463
|
return this;
|
|
395
464
|
}
|
|
396
465
|
_contextProvider = new RuntimeToolContextProvider();
|
|
@@ -477,9 +546,10 @@ export class AgentBuilder {
|
|
|
477
546
|
* 设置 Skill 目录(子目录内含 SKILL.md)
|
|
478
547
|
*
|
|
479
548
|
* build 时 discover,每轮以索引形式注入 system prompt(formatForPrompt)。
|
|
549
|
+
* `~` 形态在此展开(与 workspace / agentHome 同规,幂等)。
|
|
480
550
|
*/
|
|
481
551
|
skillDirectory(dir) {
|
|
482
|
-
this._skillDirectory = dir;
|
|
552
|
+
this._skillDirectory = expandHomePath(dir.trim());
|
|
483
553
|
return this;
|
|
484
554
|
}
|
|
485
555
|
/** 直接注入 SkillManager(跳过目录 discover) */
|
|
@@ -489,7 +559,8 @@ export class AgentBuilder {
|
|
|
489
559
|
}
|
|
490
560
|
/** 注入 MemoryStore(每轮按 query 召回进 system prompt) */
|
|
491
561
|
memoryStore(store) {
|
|
492
|
-
|
|
562
|
+
// L3:写口记 turn journal(RunScope ALS);turn 外(steward)无 journal 则直写
|
|
563
|
+
this._memoryStore = new JournaledMemoryStore(store, () => getRunScope()?.toolRuntime?.memoryEffects);
|
|
493
564
|
return this;
|
|
494
565
|
}
|
|
495
566
|
/** 注入补录覆盖表(默认:SqliteMemoryStore→agent.db,否则内存) */
|
|
@@ -684,18 +755,23 @@ export class AgentBuilder {
|
|
|
684
755
|
this._checkpointInterval = checkpointInterval;
|
|
685
756
|
return this;
|
|
686
757
|
}
|
|
758
|
+
/** 设置模型调用 watchdog 超时(流式 idle + 绝对上限;缺省用引擎默认) */
|
|
759
|
+
modelCallTimeouts(timeouts) {
|
|
760
|
+
this._modelCallTimeouts = timeouts;
|
|
761
|
+
return this;
|
|
762
|
+
}
|
|
687
763
|
persona(...workspaces) {
|
|
688
764
|
this._personaWorkspaces.push(...workspaces);
|
|
689
765
|
return this;
|
|
690
766
|
}
|
|
691
|
-
/** 设置 Agent 沙箱工作目录(注入到内置工具的 cwd) */
|
|
767
|
+
/** 设置 Agent 沙箱工作目录(注入到内置工具的 cwd);`~` 形态在此展开(trim → expand) */
|
|
692
768
|
workspace(dir) {
|
|
693
|
-
this._workspace = dir;
|
|
769
|
+
this._workspace = expandHomePath(dir.trim());
|
|
694
770
|
return this;
|
|
695
771
|
}
|
|
696
|
-
/** agent 文件态 home:extract 落盘、与 persona
|
|
772
|
+
/** agent 文件态 home:extract 落盘、与 persona 目录解耦;`~` 形态在此展开(与 workspace 同规) */
|
|
697
773
|
agentHome(dir) {
|
|
698
|
-
this._agentHome = dir;
|
|
774
|
+
this._agentHome = expandHomePath(dir.trim());
|
|
699
775
|
return this;
|
|
700
776
|
}
|
|
701
777
|
/** 逻辑 agentId(extract pending 扫描 / 观测) */
|
|
@@ -714,9 +790,9 @@ export class AgentBuilder {
|
|
|
714
790
|
this._store = store;
|
|
715
791
|
return this;
|
|
716
792
|
}
|
|
717
|
-
/** 设置 Runner
|
|
793
|
+
/** 设置 Runner 配置(浅合并,便于多次补充字段) */
|
|
718
794
|
runnerConfig(config) {
|
|
719
|
-
this._runnerConfig = config;
|
|
795
|
+
this._runnerConfig = { ...this._runnerConfig, ...config };
|
|
720
796
|
if (config.observerHub) {
|
|
721
797
|
this._observerHub = config.observerHub;
|
|
722
798
|
}
|
|
@@ -732,6 +808,16 @@ export class AgentBuilder {
|
|
|
732
808
|
*
|
|
733
809
|
* @param mode - `none` | `session-subdir` | `session-lock`
|
|
734
810
|
*/
|
|
811
|
+
/** P3:注入 ToolEffectPolicy */
|
|
812
|
+
effectPolicy(config) {
|
|
813
|
+
this._effectPolicy = config;
|
|
814
|
+
return this;
|
|
815
|
+
}
|
|
816
|
+
/** P4:宿主 confirmEffect(host-gate) */
|
|
817
|
+
confirmEffect(fn) {
|
|
818
|
+
this._confirmEffect = fn;
|
|
819
|
+
return this;
|
|
820
|
+
}
|
|
735
821
|
toolIsolation(mode) {
|
|
736
822
|
this._toolIsolation = mode;
|
|
737
823
|
return this;
|
|
@@ -771,6 +857,22 @@ export class AgentBuilder {
|
|
|
771
857
|
this._toolBus.register(t);
|
|
772
858
|
}
|
|
773
859
|
}
|
|
860
|
+
// 会话日程:与 task_* 同构;进程内共用实例时经 runnerConfig 注入
|
|
861
|
+
let sessionScheduleService = this._runnerConfig?.sessionScheduleService;
|
|
862
|
+
if (!sessionScheduleService) {
|
|
863
|
+
sessionScheduleService = new SessionScheduleService({ events });
|
|
864
|
+
// 默认实例必须 open,否则 runner 注入 list() 会抛 not opened
|
|
865
|
+
await sessionScheduleService.open();
|
|
866
|
+
}
|
|
867
|
+
this._runnerConfig = {
|
|
868
|
+
...this._runnerConfig,
|
|
869
|
+
sessionScheduleService,
|
|
870
|
+
};
|
|
871
|
+
if (!this._toolBus.getTool('schedule_set')) {
|
|
872
|
+
for (const t of createSessionScheduleTools(sessionScheduleService)) {
|
|
873
|
+
this._toolBus.register(t);
|
|
874
|
+
}
|
|
875
|
+
}
|
|
774
876
|
// memory 工具必须在 buildCore 之前注册:Agent 构造时从 ToolBus 快照 tools
|
|
775
877
|
if (this._memoryStore && !this._toolBus.getTool('memory_store')) {
|
|
776
878
|
const { createMemoryTools } = await import('../extension/plugin-ecosystem/tools/memory.js');
|
|
@@ -856,12 +958,16 @@ export class AgentBuilder {
|
|
|
856
958
|
const runner = new SessionAwareRunner(agent, harness, store, {
|
|
857
959
|
...this._runnerConfig,
|
|
858
960
|
toolIsolation: this._toolIsolation ?? this._runnerConfig?.toolIsolation,
|
|
961
|
+
effectPolicy: this._effectPolicy ?? this._runnerConfig?.effectPolicy,
|
|
962
|
+
confirmEffect: this._confirmEffect ?? this._runnerConfig?.confirmEffect,
|
|
859
963
|
agentWorkspace: this._workspace?.trim() ? this._workspace : this._runnerConfig?.agentWorkspace,
|
|
860
964
|
sessionLease: this._runnerConfig?.sessionLease,
|
|
861
965
|
sessionAcl: this._runnerConfig?.sessionAcl,
|
|
862
966
|
agentMaxSessionRights: this._runnerConfig?.agentMaxSessionRights,
|
|
967
|
+
agentToolPolicy: this._runnerConfig?.agentToolPolicy,
|
|
863
968
|
observerHub: this._observerHub ?? this._runnerConfig?.observerHub,
|
|
864
969
|
sessionTaskService,
|
|
970
|
+
sessionScheduleService,
|
|
865
971
|
events,
|
|
866
972
|
eventSink: this._telemetry?.onEvent
|
|
867
973
|
? (event, ctx) => this._telemetry?.onEvent?.(event, ctx)
|
|
@@ -893,6 +999,7 @@ export class AgentBuilder {
|
|
|
893
999
|
cognitionStore,
|
|
894
1000
|
systemBudgetRatio: assemblerCfg?.systemBudgetRatio,
|
|
895
1001
|
systemBudgetTokens: assemblerCfg?.systemBudgetTokens,
|
|
1002
|
+
snapshotBudgetTokens: assemblerCfg?.snapshotBudgetTokens,
|
|
896
1003
|
constitution: constitutionCfg,
|
|
897
1004
|
assemblerConfig: {
|
|
898
1005
|
layerShares: assemblerCfg?.layerShares,
|
|
@@ -957,6 +1064,9 @@ export class AgentBuilder {
|
|
|
957
1064
|
let subsystemRuntime;
|
|
958
1065
|
if (candidateSpecs.length > 0 || this._subsystemDir) {
|
|
959
1066
|
const { SubsystemRuntime } = await import('../collaboration/autonomous-subsystem/runtime.js');
|
|
1067
|
+
const { probeProcessIsolation, assessL4ProcessMinimum } = await import('../extension/execution-environment/process-isolation.js');
|
|
1068
|
+
const isolationProfile = await probeProcessIsolation();
|
|
1069
|
+
const securityEnforcement = { l4Available: assessL4ProcessMinimum(isolationProfile).ok };
|
|
960
1070
|
subsystemRuntime = new SubsystemRuntime({
|
|
961
1071
|
deps: {
|
|
962
1072
|
model: agent.model,
|
|
@@ -964,8 +1074,11 @@ export class AgentBuilder {
|
|
|
964
1074
|
errorStrategy: this._errorStrategy ?? new DefaultErrorStrategy(),
|
|
965
1075
|
mainTools: this._toolBus,
|
|
966
1076
|
modelLevels: this._modelLevels,
|
|
1077
|
+
providers: this._namedProviders.size > 0 ? this._namedProviders : undefined,
|
|
967
1078
|
},
|
|
968
1079
|
auditDir: this._subsystemAuditDir,
|
|
1080
|
+
agentId: this._agentId,
|
|
1081
|
+
securityEnforcement,
|
|
969
1082
|
});
|
|
970
1083
|
const registeredIds = new Set();
|
|
971
1084
|
const tryRegister = (spec) => {
|
|
@@ -993,7 +1106,11 @@ export class AgentBuilder {
|
|
|
993
1106
|
tryRegister(spec);
|
|
994
1107
|
}
|
|
995
1108
|
}
|
|
996
|
-
// 依赖注入:memoryStore / wisdomStore / conceptGraphStore / sessionStore / constitution / backfillCoverage
|
|
1109
|
+
// 依赖注入:modelProvider / memoryStore / wisdomStore / conceptGraphStore / sessionStore / constitution / backfillCoverage
|
|
1110
|
+
// modelProvider = 主 provider 实例(legacy runtimeInject.requires;新代码用 llmPort)
|
|
1111
|
+
if (this._model) {
|
|
1112
|
+
subsystemRuntime.registerDependency('modelProvider', this._model);
|
|
1113
|
+
}
|
|
997
1114
|
if (this._memoryStore) {
|
|
998
1115
|
subsystemRuntime.registerDependency('memoryStore', this._memoryStore);
|
|
999
1116
|
}
|
|
@@ -1089,6 +1206,15 @@ export class AgentBuilder {
|
|
|
1089
1206
|
const personaLoadedForHealth = Boolean((this._systemPrompt ?? '').trim() ||
|
|
1090
1207
|
(this._initialPersonaContent ?? '').trim() ||
|
|
1091
1208
|
this._personaResolver);
|
|
1209
|
+
// 后置注册工具:走 convertToAgentTool + Agent.registerTool(自带 security 名单同步)
|
|
1210
|
+
const registerTools = (tools) => {
|
|
1211
|
+
for (const t of tools) {
|
|
1212
|
+
if (this._toolBus.getTool(t.definition.name))
|
|
1213
|
+
continue;
|
|
1214
|
+
this._toolBus.register(t);
|
|
1215
|
+
agent.registerTool(convertToAgentTool(t, this._contextProvider));
|
|
1216
|
+
}
|
|
1217
|
+
};
|
|
1092
1218
|
return {
|
|
1093
1219
|
agent,
|
|
1094
1220
|
harness,
|
|
@@ -1096,6 +1222,8 @@ export class AgentBuilder {
|
|
|
1096
1222
|
mcpManager,
|
|
1097
1223
|
runtime: subsystemRuntime,
|
|
1098
1224
|
events,
|
|
1225
|
+
store,
|
|
1226
|
+
registerTools,
|
|
1099
1227
|
contextEngine,
|
|
1100
1228
|
contextHealth: async (agentId) => {
|
|
1101
1229
|
const { probeContextLayerHealth } = await import('../context/layer-health.js');
|
|
@@ -1156,7 +1284,7 @@ export class AgentBuilder {
|
|
|
1156
1284
|
this._initialPersonaContent = await this._personaResolver();
|
|
1157
1285
|
systemPrompt = this._initialPersonaContent;
|
|
1158
1286
|
}
|
|
1159
|
-
if (!systemPrompt && this._toolBus.listForAgent('default').length > 0) {
|
|
1287
|
+
if (!systemPrompt && this._toolBus.listForAgent(this._agentId ?? 'default').length > 0) {
|
|
1160
1288
|
systemPrompt = this.buildDefaultSystemPrompt();
|
|
1161
1289
|
}
|
|
1162
1290
|
// Skill:目录 discover(或外部注入的 manager)
|
|
@@ -1177,9 +1305,13 @@ export class AgentBuilder {
|
|
|
1177
1305
|
this._contextProvider = new RuntimeToolContextProvider({
|
|
1178
1306
|
cwd: this._workspace?.trim() ? this._workspace : undefined,
|
|
1179
1307
|
});
|
|
1180
|
-
const
|
|
1308
|
+
const busAgentId = this._agentId ?? 'default';
|
|
1309
|
+
const agentTools = this._toolBus.listForAgent(busAgentId).map(t => convertToAgentTool(t, this._contextProvider));
|
|
1310
|
+
console.log(`[AgentBuilder] agent tools (${agentTools.length}): ${agentTools.map((t) => t.name).join(', ')}`);
|
|
1181
1311
|
// 创建 Agent
|
|
1182
1312
|
const agentOptions = {
|
|
1313
|
+
modelCallIdleTimeoutMs: this._modelCallTimeouts?.idleTimeoutMs,
|
|
1314
|
+
modelCallAbsoluteTimeoutMs: this._modelCallTimeouts?.absoluteTimeoutMs,
|
|
1183
1315
|
model: this._model,
|
|
1184
1316
|
systemPrompt,
|
|
1185
1317
|
tools: agentTools,
|
|
@@ -1198,8 +1330,11 @@ export class AgentBuilder {
|
|
|
1198
1330
|
const summarizeFn = this._summarize ??
|
|
1199
1331
|
(!this._disableAutoSummarize && this._model
|
|
1200
1332
|
? async (messages, opts) => {
|
|
1201
|
-
|
|
1202
|
-
|
|
1333
|
+
// 与会话同 provider+model:前缀缓存同域。禁止自动切 summary/mini。
|
|
1334
|
+
const snap = getResolvedModel();
|
|
1335
|
+
const provider = snap?.provider ?? this._model;
|
|
1336
|
+
const model = snap?.modelName;
|
|
1337
|
+
return createProviderSummarize(provider, { model })(messages, opts);
|
|
1203
1338
|
}
|
|
1204
1339
|
: undefined);
|
|
1205
1340
|
agent.setConvertToLlm(async (messages) => {
|
|
@@ -1213,7 +1348,7 @@ export class AgentBuilder {
|
|
|
1213
1348
|
function: {
|
|
1214
1349
|
name: t.name,
|
|
1215
1350
|
description: t.description,
|
|
1216
|
-
parameters: t.parameters ?? { type: 'object', properties: {} },
|
|
1351
|
+
parameters: sanitizeLlmJsonSchema(t.parameters ?? { type: 'object', properties: {} }),
|
|
1217
1352
|
},
|
|
1218
1353
|
}));
|
|
1219
1354
|
// 方案 B:只读 snapshot.contextWindow;未知则 undefined(跳过自动压缩)
|
|
@@ -1292,24 +1427,9 @@ export class AgentBuilder {
|
|
|
1292
1427
|
estimatedTokens: result.estimatedTokens,
|
|
1293
1428
|
contextWindow,
|
|
1294
1429
|
};
|
|
1295
|
-
// droppedSummary
|
|
1296
|
-
|
|
1297
|
-
|
|
1298
|
-
const note = `[Context compacted] ${result.droppedSummary}`;
|
|
1299
|
-
const sysIdx = llmMessages.findIndex((m) => m.role === 'system');
|
|
1300
|
-
if (sysIdx >= 0) {
|
|
1301
|
-
const sys = llmMessages[sysIdx];
|
|
1302
|
-
const prev = typeof sys.content === 'string' ? sys.content : '';
|
|
1303
|
-
llmMessages[sysIdx] = {
|
|
1304
|
-
...sys,
|
|
1305
|
-
content: prev ? `${prev}\n\n${note}` : note,
|
|
1306
|
-
};
|
|
1307
|
-
}
|
|
1308
|
-
else {
|
|
1309
|
-
llmMessages.unshift({ role: 'system', content: note });
|
|
1310
|
-
}
|
|
1311
|
-
}
|
|
1312
|
-
return llmMessages;
|
|
1430
|
+
// droppedSummary 不得进 system(动态注记打穿前缀缓存)。
|
|
1431
|
+
// 本轮直接不投递;压缩语义由消息侧 contextSummary 承载。
|
|
1432
|
+
return result.messages;
|
|
1313
1433
|
});
|
|
1314
1434
|
agent.setOnAfterTurn(async (usage, turn) => {
|
|
1315
1435
|
const scope = getRunScope();
|
|
@@ -1339,7 +1459,7 @@ export class AgentBuilder {
|
|
|
1339
1459
|
}
|
|
1340
1460
|
// 未注册工具硬边界:灌入工具面快照(空集 = 不校验,必须在 build 时接线)
|
|
1341
1461
|
if (security.setRegisteredTools) {
|
|
1342
|
-
security.setRegisteredTools(new Set(this._toolBus.listForAgent('default').map((t) => t.definition.name)));
|
|
1462
|
+
security.setRegisteredTools(new Set(this._toolBus.listForAgent(this._agentId ?? 'default').map((t) => t.definition.name)));
|
|
1343
1463
|
}
|
|
1344
1464
|
const errorStrategy = this._errorStrategy ?? new DefaultErrorStrategy();
|
|
1345
1465
|
// 自动创建 RunGuard(如果通过 config 配置但未手动传入实例)
|
|
@@ -1409,7 +1529,7 @@ export class AgentBuilder {
|
|
|
1409
1529
|
* 生成默认 systemPrompt,包含可用工具说明
|
|
1410
1530
|
*/
|
|
1411
1531
|
buildDefaultSystemPrompt() {
|
|
1412
|
-
const toolList = this._toolBus.listForAgent('default')
|
|
1532
|
+
const toolList = this._toolBus.listForAgent(this._agentId ?? 'default')
|
|
1413
1533
|
.map(t => `- ${t.definition.name}: ${t.definition.description}`)
|
|
1414
1534
|
.join('\n');
|
|
1415
1535
|
return `You are a helpful AI assistant with access to the following tools:
|
|
@@ -1417,7 +1537,7 @@ export class AgentBuilder {
|
|
|
1417
1537
|
${toolList}
|
|
1418
1538
|
|
|
1419
1539
|
Tool selection (strict):
|
|
1420
|
-
1. Prefer a dedicated tool when one covers the job (file_read / file_list / file_write / file_edit / file_search / env_info, and any task-specific tool).
|
|
1540
|
+
1. Prefer a dedicated tool when one covers the job (file_read / file_list / file_write / file_edit / file_delete / file_mkdir / file_rename / file_copy / file_stat / file_rmdir / file_search / env_info, and any task-specific tool).
|
|
1421
1541
|
2. If a dedicated-tool call fails because your arguments were wrong (bad path, bad params), fix the call and retry that tool — do not switch to shell for a call you can fix.
|
|
1422
1542
|
3. Use shell only when: (a) no dedicated tool covers the operation, or (b) the dedicated tool is unavailable, or (c) it still fails after a correct retry and shell is the only remaining way to make progress.
|
|
1423
1543
|
4. Do not prefer shell over a working dedicated tool for the same job.
|
|
@@ -1426,26 +1546,36 @@ Examples:
|
|
|
1426
1546
|
- Read a file → file_read first (shell cat only if file_read is unavailable or still fails after a correct retry)
|
|
1427
1547
|
- List directory → file_list first
|
|
1428
1548
|
- Write/edit a file → file_write / file_edit first
|
|
1549
|
+
- Delete a file → file_delete first (not shell rm)
|
|
1550
|
+
- Create a folder → file_mkdir first
|
|
1551
|
+
- Rename/move → file_rename first
|
|
1552
|
+
- Copy a file → file_copy first
|
|
1553
|
+
- File info → file_stat first
|
|
1554
|
+
- Remove empty folder → file_rmdir first
|
|
1429
1555
|
- Search file contents → file_search first
|
|
1430
1556
|
- Operation with no dedicated tool → shell is acceptable`;
|
|
1431
1557
|
}
|
|
1432
1558
|
}
|
|
1433
1559
|
export async function createAgent(config) {
|
|
1434
|
-
const builder = new AgentBuilder()
|
|
1435
|
-
.model(config.model);
|
|
1436
|
-
if (config.persona)
|
|
1437
|
-
builder.persona(config.persona);
|
|
1438
|
-
if (config.tools)
|
|
1439
|
-
builder.tools(...config.tools);
|
|
1560
|
+
const builder = new AgentBuilder();
|
|
1440
1561
|
if (config.store)
|
|
1441
1562
|
builder.store(config.store);
|
|
1442
|
-
if (config.budget)
|
|
1443
|
-
builder.budget(config.budget);
|
|
1444
1563
|
if (config.mcpClientFactory)
|
|
1445
1564
|
builder.mcpClientFactory(config.mcpClientFactory);
|
|
1446
1565
|
if (config.mcp) {
|
|
1447
1566
|
for (const mcpConfig of config.mcp)
|
|
1448
1567
|
builder.mcp(mcpConfig);
|
|
1449
1568
|
}
|
|
1569
|
+
if (config.tools)
|
|
1570
|
+
builder.tools(...config.tools);
|
|
1571
|
+
// 标准组装与 Gateway / config-bridge 同源;嵌入路径未给 levelMap/contextEngine 时走 wire 缺省
|
|
1572
|
+
const { wireAgentBuilder } = await import('./wire-agent-builder.js');
|
|
1573
|
+
await wireAgentBuilder(builder, {
|
|
1574
|
+
model: config.model,
|
|
1575
|
+
agentId: 'default',
|
|
1576
|
+
persona: config.persona,
|
|
1577
|
+
providers: new Map([['default', config.model]]),
|
|
1578
|
+
budgetConfig: config.budget,
|
|
1579
|
+
});
|
|
1450
1580
|
return builder.build();
|
|
1451
1581
|
}
|
|
@@ -13,20 +13,28 @@
|
|
|
13
13
|
* // agents.get('assistant') → { engine, runner }
|
|
14
14
|
* ```
|
|
15
15
|
*/
|
|
16
|
-
import type {
|
|
16
|
+
import type { AgentConfig, NormalizedHarnessConfig } from '../../config.js';
|
|
17
17
|
import type { SubsystemSpec } from '../collaboration/autonomous-subsystem/types.js';
|
|
18
18
|
import type { ModelProvider } from '@octopi-agent/core/interfaces/model-provider.js';
|
|
19
19
|
import type { SessionAwareRunner } from '../run/runner.js';
|
|
20
|
-
import type { SecurityGuardConfig } from '@octopi-agent/core/security-guard.js';
|
|
21
|
-
import type { RunGuardJsonConfig } from '../../config.js';
|
|
22
|
-
import { DefaultRunGuard } from '../run/run-guard/default-run-guard.js';
|
|
23
|
-
import type { ContextEngine } from '../context/types.js';
|
|
24
20
|
import type { Agent } from '../run/agent/index.js';
|
|
25
21
|
export interface BuiltAgent {
|
|
26
22
|
agent: Agent;
|
|
27
23
|
runner: SessionAwareRunner;
|
|
28
24
|
agentConfig: AgentConfig;
|
|
29
25
|
runtime?: import('../collaboration/autonomous-subsystem/runtime.js').SubsystemRuntime;
|
|
26
|
+
/**
|
|
27
|
+
* 该 Agent 的事件总线。
|
|
28
|
+
*
|
|
29
|
+
* 跨 agent 的 notify(`arch/delegation.md` §7.1)必须落在**同一条**总线上,
|
|
30
|
+
* 否则 `AgentSignalSource` 收不到;跨 agent 场景请用 `buildFromConfig` 的
|
|
31
|
+
* `options.events` 提供共享总线,或自行 `builder.events(bus)` 注入。
|
|
32
|
+
*/
|
|
33
|
+
events: import('@octopi-agent/core/primitives/event-bus.js').EventBus;
|
|
34
|
+
/** SessionStore(委派子 Run 预创建 child session 用;`arch/delegation.md` D7) */
|
|
35
|
+
store: import('@octopi-agent/core/interfaces/session-store.js').SessionStore<import('../session/types.js').SessionData>;
|
|
36
|
+
/** 后置注册工具(`delegate_*` 等运行期才可构造的工具) */
|
|
37
|
+
registerTools: (tools: import('@octopi-agent/core/types.js').RegisteredTool[]) => void;
|
|
30
38
|
}
|
|
31
39
|
/**
|
|
32
40
|
* 从配置中创建所有 Provider 实例
|
|
@@ -34,25 +42,6 @@ export interface BuiltAgent {
|
|
|
34
42
|
* 返回 provider name → ModelProvider 的映射。
|
|
35
43
|
*/
|
|
36
44
|
export declare function resolveProviders(config: NormalizedHarnessConfig): Promise<Map<string, ModelProvider>>;
|
|
37
|
-
/**
|
|
38
|
-
* 从配置中解析安全策略(始终返回;无总开关)
|
|
39
|
-
*
|
|
40
|
-
* 硬边界与 ToolCallRiskPolicy 由 Guard/Builder 保证接线,
|
|
41
|
-
* 这里只归一化处置、范围与灵敏度。
|
|
42
|
-
*/
|
|
43
|
-
export declare function resolveSecurityConfig(config: HarnessConfig): SecurityGuardConfig;
|
|
44
|
-
/**
|
|
45
|
-
* 从配置中创建 ContextEngine 实例
|
|
46
|
-
*/
|
|
47
|
-
export declare function resolveContextEngine(config: ContextEngineConfig | undefined): ContextEngine;
|
|
48
|
-
/**
|
|
49
|
-
* 从配置中解析 RunGuard
|
|
50
|
-
*
|
|
51
|
-
* 解析 llmModel 字段:
|
|
52
|
-
* - "model" → 使用主 provider
|
|
53
|
-
* - "provider/model" → 使用指定 provider
|
|
54
|
-
*/
|
|
55
|
-
export declare function resolveRunGuard(config: RunGuardJsonConfig | undefined, providers: Map<string, ModelProvider>): DefaultRunGuard | undefined;
|
|
56
45
|
/**
|
|
57
46
|
* 按架构文档 4.9 的三级搜索路径加载子系统
|
|
58
47
|
*
|
|
@@ -71,10 +60,29 @@ export declare function resolveSubsystemSpecs(projectRoot?: string): Promise<Sub
|
|
|
71
60
|
* @param config - 完整配置
|
|
72
61
|
* @returns agent id → BuiltAgent 的映射
|
|
73
62
|
*/
|
|
74
|
-
export declare function buildFromConfig(config: NormalizedHarnessConfig): Promise<Map<string, BuiltAgent>>;
|
|
63
|
+
export declare function buildFromConfig(config: NormalizedHarnessConfig, options?: BuildFromConfigOptions): Promise<Map<string, BuiltAgent>>;
|
|
75
64
|
/**
|
|
76
65
|
* 快捷函数:从配置文件路径构建
|
|
77
66
|
*
|
|
78
67
|
* @remarks 文件 IO / `loadConfig` 属于套件侧(arch/npm-package-split.md §10.3)。
|
|
79
68
|
* 根包 `octopi` 提供 `buildFromConfigFile`;库嵌入请用 {@link buildFromConfig}。
|
|
80
69
|
*/
|
|
70
|
+
/**
|
|
71
|
+
* `buildFromConfig` 可选项
|
|
72
|
+
*
|
|
73
|
+
* @remarks 定义置于文件尾亦生效(TS interface 提升);保持单点定义。
|
|
74
|
+
*/
|
|
75
|
+
export interface BuildFromConfigOptions {
|
|
76
|
+
/**
|
|
77
|
+
* 跨 agent **共享**的事件总线。
|
|
78
|
+
*
|
|
79
|
+
* 委派 notify(`arch/delegation.md` §7.1)必须落在 `AgentSignalSource`
|
|
80
|
+
* 所监听的同一条总线上;多 agent 场景请传入共享总线。
|
|
81
|
+
* 缺省 = 各用自己 builder 建的总线,此时 **notify 不接线**(poll 通道仍可用)。
|
|
82
|
+
*/
|
|
83
|
+
events?: import('@octopi-agent/core/primitives/event-bus.js').EventBus;
|
|
84
|
+
/**
|
|
85
|
+
* 委派编排开关。缺省 = 只要有 agent 声明 `delegation` 策略就接线。
|
|
86
|
+
*/
|
|
87
|
+
delegation?: boolean;
|
|
88
|
+
}
|