@octopi-agent/engine 0.70.7 → 0.86.38
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +201 -201
- package/NOTICE +7 -7
- package/README.md +64 -26
- package/dist/config-schema/agent.d.ts +89 -1
- package/dist/config-schema/agent.js +69 -0
- package/dist/config-schema/context.d.ts +23 -4
- package/dist/config-schema/context.js +28 -1
- package/dist/config-schema/engine.d.ts +201 -9
- package/dist/config-schema/engine.js +31 -2
- package/dist/config-schema/governance.d.ts +95 -0
- package/dist/config-schema/governance.js +91 -0
- package/dist/config-schema/models.d.ts +1 -1
- package/dist/config-schema/observability.d.ts +6 -0
- package/dist/config-schema/observability.js +16 -0
- package/dist/config-schema/run.d.ts +10 -0
- package/dist/config-schema/run.js +18 -0
- package/dist/config-schema/shared.d.ts +10 -0
- package/dist/config-schema/shared.js +10 -0
- package/dist/config-schema/substrate.d.ts +1 -1
- package/dist/config-schema/subsystems.d.ts +1 -1
- package/dist/config-schema/subsystems.js +2 -1
- package/dist/config.d.ts +178 -7
- package/dist/config.js +113 -3
- package/dist/harness/activation/compiler.js +3 -0
- package/dist/harness/activation/runtime.d.ts +7 -0
- package/dist/harness/activation/runtime.js +60 -2
- package/dist/harness/activation/sources/agent-signal.d.ts +11 -0
- package/dist/harness/activation/sources/agent-signal.js +33 -0
- package/dist/harness/activation/types.d.ts +6 -1
- package/dist/harness/agent/builder.d.ts +47 -3
- package/dist/harness/agent/builder.js +180 -54
- package/dist/harness/agent/config-bridge.d.ts +33 -25
- package/dist/harness/agent/config-bridge.js +81 -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 +38 -0
- package/dist/harness/agent/tool-purpose.js +118 -0
- package/dist/harness/agent/wire-agent-builder.d.ts +133 -0
- package/dist/harness/agent/wire-agent-builder.js +363 -0
- package/dist/harness/collaboration/autonomous-subsystem/runtime.d.ts +4 -1
- package/dist/harness/collaboration/autonomous-subsystem/runtime.js +14 -8
- package/dist/harness/collaboration/autonomous-subsystem/sense/metrics.d.ts +12 -0
- package/dist/harness/collaboration/autonomous-subsystem/sense/metrics.js +19 -0
- package/dist/harness/collaboration/autonomous-subsystem/sense/session-lifecycle-bridge.d.ts +6 -0
- package/dist/harness/collaboration/autonomous-subsystem/sense/session-lifecycle-bridge.js +24 -7
- package/dist/harness/collaboration/autonomous-subsystem/think/executor.d.ts +5 -2
- package/dist/harness/collaboration/autonomous-subsystem/think/executor.js +11 -3
- package/dist/harness/collaboration/autonomous-subsystem/think/index.d.ts +1 -1
- package/dist/harness/collaboration/autonomous-subsystem/think/index.js +1 -1
- package/dist/harness/collaboration/autonomous-subsystem/think/llm-port.d.ts +7 -4
- package/dist/harness/collaboration/autonomous-subsystem/think/llm-port.js +8 -9
- package/dist/harness/collaboration/autonomous-subsystem/think/model-resolver.d.ts +36 -10
- package/dist/harness/collaboration/autonomous-subsystem/think/model-resolver.js +60 -7
- package/dist/harness/collaboration/delegation/child-run.d.ts +144 -0
- package/dist/harness/collaboration/delegation/child-run.js +241 -0
- package/dist/harness/collaboration/delegation/index.d.ts +26 -0
- package/dist/harness/collaboration/delegation/index.js +25 -0
- package/dist/harness/collaboration/delegation/notifier.d.ts +46 -0
- package/dist/harness/collaboration/delegation/notifier.js +84 -0
- package/dist/harness/collaboration/delegation/registry-types.d.ts +200 -0
- package/dist/harness/collaboration/delegation/registry-types.js +61 -0
- package/dist/harness/collaboration/delegation/registry.d.ts +110 -0
- package/dist/harness/collaboration/delegation/registry.js +220 -0
- package/dist/harness/collaboration/delegation/service.d.ts +249 -0
- package/dist/harness/collaboration/delegation/service.js +499 -0
- package/dist/harness/collaboration/delegation/store.d.ts +155 -0
- package/dist/harness/collaboration/delegation/store.js +271 -0
- package/dist/harness/collaboration/delegation/transport.d.ts +73 -0
- package/dist/harness/collaboration/delegation/transport.js +61 -0
- package/dist/harness/collaboration/delegation/types.d.ts +231 -0
- package/dist/harness/collaboration/delegation/types.js +70 -0
- package/dist/harness/collaboration/delegation/wiring.d.ts +111 -0
- package/dist/harness/collaboration/delegation/wiring.js +145 -0
- package/dist/harness/collaboration/orchestration/index.d.ts +11 -13
- package/dist/harness/collaboration/orchestration/index.js +11 -11
- package/dist/harness/context/assembler.d.ts +2 -2
- package/dist/harness/context/assembler.js +12 -7
- package/dist/harness/context/capabilities/compact/engine.js +80 -38
- package/dist/harness/context/capabilities/compact/types.d.ts +12 -1
- package/dist/harness/context/capabilities/summary/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 +49 -1
- package/dist/harness/context/layer-types.js +72 -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 +67 -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 +248 -0
- package/dist/harness/extension/execution-environment/effect-policy.js +334 -0
- package/dist/harness/extension/execution-environment/index.d.ts +18 -2
- package/dist/harness/extension/execution-environment/index.js +11 -2
- package/dist/harness/extension/execution-environment/memory-undo.d.ts +101 -0
- package/dist/harness/extension/execution-environment/memory-undo.js +192 -0
- package/dist/harness/extension/execution-environment/process-isolation.d.ts +84 -0
- package/dist/harness/extension/execution-environment/process-isolation.js +315 -0
- package/dist/harness/extension/execution-environment/resource-limits.d.ts +36 -0
- package/dist/harness/extension/execution-environment/resource-limits.js +84 -0
- package/dist/harness/extension/execution-environment/sandbox.d.ts +125 -4
- package/dist/harness/extension/execution-environment/sandbox.js +493 -51
- package/dist/harness/extension/execution-environment/shell-journal.d.ts +100 -0
- package/dist/harness/extension/execution-environment/shell-journal.js +299 -0
- package/dist/harness/extension/execution-environment/tool-capabilities.d.ts +45 -0
- package/dist/harness/extension/execution-environment/tool-capabilities.js +126 -0
- package/dist/harness/extension/execution-environment/types.d.ts +67 -39
- package/dist/harness/extension/execution-environment/types.js +2 -2
- package/dist/harness/extension/execution-environment/undo-log.d.ts +203 -0
- package/dist/harness/extension/execution-environment/undo-log.js +627 -0
- package/dist/harness/extension/execution-environment/undo-merge.d.ts +40 -0
- package/dist/harness/extension/execution-environment/undo-merge.js +167 -0
- package/dist/harness/extension/plugin-ecosystem/client-tools/index.d.ts +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 +45 -0
- package/dist/harness/extension/plugin-ecosystem/tools/allowlisted-run.js +136 -0
- package/dist/harness/extension/plugin-ecosystem/tools/ask-user.js +1 -0
- package/dist/harness/extension/plugin-ecosystem/tools/builtin.d.ts +18 -3
- package/dist/harness/extension/plugin-ecosystem/tools/builtin.js +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 +239 -61
- package/dist/harness/extension/plugin-ecosystem/tools/git-tools.d.ts +27 -0
- package/dist/harness/extension/plugin-ecosystem/tools/git-tools.js +554 -0
- package/dist/harness/extension/plugin-ecosystem/tools/http.d.ts +10 -6
- package/dist/harness/extension/plugin-ecosystem/tools/http.js +41 -47
- package/dist/harness/extension/plugin-ecosystem/tools/index.d.ts +2 -0
- package/dist/harness/extension/plugin-ecosystem/tools/index.js +2 -0
- package/dist/harness/extension/plugin-ecosystem/tools/knowledge.js +4 -0
- package/dist/harness/extension/plugin-ecosystem/tools/memory.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 +14 -12
- package/dist/harness/index.js +9 -6
- package/dist/harness/knowledge/file-index-store.js +11 -11
- package/dist/harness/knowledge/grounding.d.ts +2 -1
- package/dist/harness/knowledge/grounding.js +6 -3
- package/dist/harness/knowledge/index.d.ts +2 -2
- package/dist/harness/knowledge/index.js +1 -1
- package/dist/harness/knowledge/ingest.js +4 -1
- package/dist/harness/knowledge/job-control-state.js +4 -4
- package/dist/harness/knowledge/job-control.js +11 -11
- package/dist/harness/knowledge/membership-store.js +11 -11
- package/dist/harness/knowledge/network-guard.d.ts +61 -4
- package/dist/harness/knowledge/network-guard.js +390 -113
- package/dist/harness/knowledge/query-service.js +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-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 +23 -1
- package/dist/harness/observability/observer/index.d.ts +2 -2
- package/dist/harness/observability/observer/index.js +1 -1
- package/dist/harness/observability/observer/types.d.ts +57 -0
- package/dist/harness/observability/observer/types.js +118 -9
- package/dist/harness/run/agent/agent.d.ts +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 +101 -16
- package/dist/harness/run/runner.js +556 -158
- package/dist/harness/session/attachments/llm-intent.js +17 -17
- package/dist/harness/session/history/port.js +1 -0
- package/dist/harness/session/in-memory-store.d.ts +1 -0
- package/dist/harness/session/in-memory-store.js +22 -1
- package/dist/harness/session/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/types.d.ts +35 -0
- package/dist/harness/shared/events/agent-event-map.d.ts +13 -0
- package/dist/harness/shared/types/agent-definition.d.ts +23 -0
- package/dist/index.d.ts +23 -9
- package/dist/index.js +10 -2
- package/dist/integration/providers/anthropic.d.ts +10 -0
- package/dist/integration/providers/anthropic.js +44 -1
- package/dist/integration/providers/openai.d.ts +10 -0
- package/dist/integration/providers/openai.js +58 -2
- package/dist/integration/providers/wire-dump-diff.d.ts +191 -0
- package/dist/integration/providers/wire-dump-diff.js +351 -0
- package/dist/integration/providers/wire-dump.d.ts +178 -0
- package/dist/integration/providers/wire-dump.js +396 -0
- package/dist/integration/storage/jsonl.d.ts +11 -0
- package/dist/integration/storage/jsonl.js +148 -39
- package/dist/integration/storage/session-index.js +63 -8
- package/dist/subsystems/cognition-steward/conceptualize/SUBSYSTEM.md +43 -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/wisdom-steward/evaluate/config.yaml +50 -50
- package/dist/subsystems/wisdom-steward/formation/SUBSYSTEM.md +42 -42
- package/dist/subsystems/wisdom-steward/formation/config.yaml +54 -54
- package/dist/subsystems/wisdom-steward/govern/config.yaml +55 -55
- package/package.json +115 -115
- package/dist/harness/collaboration/multi-agent/agent-registry-types.d.ts +0 -144
- package/dist/harness/collaboration/multi-agent/agent-registry-types.js +0 -25
- package/dist/harness/collaboration/multi-agent/index.d.ts +0 -17
- package/dist/harness/collaboration/multi-agent/index.js +0 -15
- package/dist/harness/collaboration/multi-agent/process.d.ts +0 -167
- package/dist/harness/collaboration/multi-agent/process.js +0 -256
- package/dist/harness/collaboration/multi-agent/registry.d.ts +0 -36
- package/dist/harness/collaboration/multi-agent/registry.js +0 -137
- package/dist/harness/collaboration/multi-agent/swarm.d.ts +0 -135
- package/dist/harness/collaboration/multi-agent/swarm.js +0 -317
- package/dist/harness/collaboration/multi-agent/types.d.ts +0 -66
- package/dist/harness/collaboration/multi-agent/types.js +0 -15
- package/dist/harness/collaboration/orchestration/async-task-store.d.ts +0 -107
- package/dist/harness/collaboration/orchestration/async-task-store.js +0 -12
- package/dist/harness/collaboration/orchestration/async-task.d.ts +0 -156
- package/dist/harness/collaboration/orchestration/async-task.js +0 -359
- package/dist/harness/collaboration/orchestration/planner/hybrid-planner.d.ts +0 -47
- package/dist/harness/collaboration/orchestration/planner/hybrid-planner.js +0 -61
- package/dist/harness/collaboration/orchestration/planner/index.d.ts +0 -9
- package/dist/harness/collaboration/orchestration/planner/index.js +0 -6
- package/dist/harness/collaboration/orchestration/planner/llm-planner.d.ts +0 -54
- package/dist/harness/collaboration/orchestration/planner/llm-planner.js +0 -167
- package/dist/harness/collaboration/orchestration/planner/rule-planner.d.ts +0 -85
- package/dist/harness/collaboration/orchestration/planner/rule-planner.js +0 -175
- package/dist/harness/collaboration/orchestration/quality/classifier.d.ts +0 -21
- package/dist/harness/collaboration/orchestration/quality/classifier.js +0 -235
- package/dist/harness/collaboration/orchestration/quality/gate.d.ts +0 -29
- package/dist/harness/collaboration/orchestration/quality/gate.js +0 -409
- package/dist/harness/collaboration/orchestration/quality/index.d.ts +0 -9
- package/dist/harness/collaboration/orchestration/quality/index.js +0 -8
- package/dist/harness/collaboration/orchestration/quality/types.d.ts +0 -159
- package/dist/harness/collaboration/orchestration/quality/types.js +0 -33
- package/dist/harness/collaboration/orchestration/scheduler/index.d.ts +0 -5
- package/dist/harness/collaboration/orchestration/scheduler/index.js +0 -4
- package/dist/harness/collaboration/orchestration/scheduler/task-scheduler.d.ts +0 -143
- package/dist/harness/collaboration/orchestration/scheduler/task-scheduler.js +0 -297
- package/dist/harness/collaboration/orchestration/strategy/classifier.d.ts +0 -12
- package/dist/harness/collaboration/orchestration/strategy/classifier.js +0 -81
- package/dist/harness/collaboration/orchestration/strategy/index.d.ts +0 -3
- package/dist/harness/collaboration/orchestration/strategy/index.js +0 -2
- package/dist/harness/collaboration/orchestration/strategy/router.d.ts +0 -28
- package/dist/harness/collaboration/orchestration/strategy/router.js +0 -105
- package/dist/harness/collaboration/orchestration/strategy/types.d.ts +0 -49
- package/dist/harness/collaboration/orchestration/strategy/types.js +0 -4
- package/dist/harness/collaboration/orchestration/workflow/engine.d.ts +0 -86
- package/dist/harness/collaboration/orchestration/workflow/engine.js +0 -298
- package/dist/harness/collaboration/orchestration/workflow/index.d.ts +0 -9
- package/dist/harness/collaboration/orchestration/workflow/index.js +0 -7
- package/dist/harness/collaboration/orchestration/workflow/types.d.ts +0 -143
- package/dist/harness/collaboration/orchestration/workflow/types.js +0 -7
- package/dist/harness/governance/human-in-the-loop/approval-manager.d.ts +0 -32
- package/dist/harness/governance/human-in-the-loop/approval-manager.js +0 -93
- /package/dist/harness/collaboration/{multi-agent → delegation}/message-channel-types.d.ts +0 -0
- /package/dist/harness/collaboration/{multi-agent → delegation}/message-channel-types.js +0 -0
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* wireAgentBuilder — 配置 → AgentBuilder 的唯一组装入口
|
|
3
|
+
*
|
|
4
|
+
* 设计约定:
|
|
5
|
+
* - 产品(Gateway)与库嵌入(config-bridge)**都只调用本函数**,禁止各自维护第二套接线清单。
|
|
6
|
+
* - 本函数覆盖「标准配置」:模型档 / summarize / contextEngine / security / budget /
|
|
7
|
+
* runGuard / persona / skills / memory stores / subsystems / toolIsolation / effectPolicy。
|
|
8
|
+
* - 宿主适配(circuit breaker、WS、approval 门禁、Knowledge Service、委派…)在 wire **之后**
|
|
9
|
+
* 由宿主自己叠加,不进本文件。
|
|
10
|
+
* - 不做双轨/兼容层:漏接线即 bug,由契约测试锁两路径能力一致。
|
|
11
|
+
*
|
|
12
|
+
* @module harness/agent/wire-agent-builder
|
|
13
|
+
*/
|
|
14
|
+
import type { ModelProvider } from '@octopi-agent/core/interfaces/model-provider.js';
|
|
15
|
+
import type { SecurityGuardConfig } from '@octopi-agent/core/security-guard.js';
|
|
16
|
+
import type { ErrorStrategy } from '@octopi-agent/core/interfaces/error-strategy.js';
|
|
17
|
+
import type { ContextEngineConfig, BudgetPolicyJsonConfig, RunGuardJsonConfig, ModelCallConfig, LevelMap, ModelsConfig, HarnessConfig } from '../../config.js';
|
|
18
|
+
import type { SubsystemSpec } from '../collaboration/autonomous-subsystem/types.js';
|
|
19
|
+
import type { BudgetPolicyConfig } from '../run/budget/budget.js';
|
|
20
|
+
import type { SessionAwareRunnerConfig } from '../run/runner.js';
|
|
21
|
+
import type { EffectPolicyConfig } from '../extension/execution-environment/effect-policy.js';
|
|
22
|
+
import { DefaultRunGuard } from '../run/run-guard/default-run-guard.js';
|
|
23
|
+
import type { ContextEngine } from '../context/types.js';
|
|
24
|
+
import type { AgentBuilder } from './builder.js';
|
|
25
|
+
/**
|
|
26
|
+
* 解析子系统审计目录(docs/autonomous-subsystem.md §10)
|
|
27
|
+
*
|
|
28
|
+
* - `false` → 关闭审计(返回 undefined,不接 AuditWriter)
|
|
29
|
+
* - 字符串 → 显式目录
|
|
30
|
+
* - 缺省 → `<OCTOPI_HOME>/audit`(`OCTOPI_HOME` env 可重定向,测试可隔离)
|
|
31
|
+
*
|
|
32
|
+
* @param configured - 配置值(`subsystems.auditDir`)
|
|
33
|
+
* @returns 审计目录;undefined = 显式关闭
|
|
34
|
+
*/
|
|
35
|
+
export declare function resolveSubsystemAuditDir(configured: string | false | undefined): string | undefined;
|
|
36
|
+
/**
|
|
37
|
+
* 从配置中解析安全策略(始终返回;无总开关)
|
|
38
|
+
*
|
|
39
|
+
* 硬边界与 ToolCallRiskPolicy 由 Guard/Builder 保证接线,
|
|
40
|
+
* 这里只归一化处置、范围与灵敏度。
|
|
41
|
+
*
|
|
42
|
+
* @param config - Harness 配置
|
|
43
|
+
* @returns 安全策略
|
|
44
|
+
*/
|
|
45
|
+
export declare function resolveSecurityConfig(config: {
|
|
46
|
+
security?: HarnessConfig['security'];
|
|
47
|
+
}): SecurityGuardConfig;
|
|
48
|
+
/**
|
|
49
|
+
* 从配置中创建 ContextEngine 实例
|
|
50
|
+
*
|
|
51
|
+
* @param config - contextEngine 配置(可空)
|
|
52
|
+
* @returns ContextEngine
|
|
53
|
+
*/
|
|
54
|
+
export declare function resolveContextEngine(config: ContextEngineConfig | undefined): ContextEngine;
|
|
55
|
+
/**
|
|
56
|
+
* 从配置中解析 RunGuard
|
|
57
|
+
*
|
|
58
|
+
* 解析 llmModel 字段:
|
|
59
|
+
* - "model" → 使用主 provider
|
|
60
|
+
* - "provider/model" → 使用指定 provider
|
|
61
|
+
*
|
|
62
|
+
* @param config - runGuard JSON 配置
|
|
63
|
+
* @param providers - 可用 provider 映射
|
|
64
|
+
* @returns RunGuard 或 undefined(禁用时)
|
|
65
|
+
*/
|
|
66
|
+
export declare function resolveRunGuard(config: RunGuardJsonConfig | undefined, providers: Map<string, ModelProvider>): DefaultRunGuard | undefined;
|
|
67
|
+
/**
|
|
68
|
+
* 标准组装输入。宿主先解析好 model provider(可包 circuit breaker / fallback),
|
|
69
|
+
* 再把其余配置块交给本函数。
|
|
70
|
+
*/
|
|
71
|
+
export interface AgentWireSpec {
|
|
72
|
+
/** 已解析/已包装的主模型 provider */
|
|
73
|
+
model: ModelProvider;
|
|
74
|
+
agentId: string;
|
|
75
|
+
workspace?: string;
|
|
76
|
+
/** agent 文件态持久目录(persona/skills) */
|
|
77
|
+
home?: string;
|
|
78
|
+
/** 文件式 persona 目录,或内联 systemPrompt */
|
|
79
|
+
persona?: string | {
|
|
80
|
+
systemPrompt?: string;
|
|
81
|
+
};
|
|
82
|
+
skillDirectory?: string;
|
|
83
|
+
/** SEC-2 / E6 工具策略与会话权利天花板 */
|
|
84
|
+
tools?: import('@octopi-agent/core/types.js').ToolPolicy;
|
|
85
|
+
maxSessionRights?: SessionAwareRunnerConfig['agentMaxSessionRights'];
|
|
86
|
+
effectPolicy?: EffectPolicyConfig;
|
|
87
|
+
toolIsolation?: HarnessConfig['toolIsolation'];
|
|
88
|
+
sessionIdleExpiryMs?: number;
|
|
89
|
+
modelCallTimeouts?: ModelCallConfig;
|
|
90
|
+
/** 可用 provider 映射(summarize / runGuard / subsystems) */
|
|
91
|
+
providers: Map<string, ModelProvider>;
|
|
92
|
+
levelMap?: LevelMap;
|
|
93
|
+
modelsConfig?: {
|
|
94
|
+
providers?: ModelsConfig['providers'];
|
|
95
|
+
embedding?: ModelsConfig['embedding'];
|
|
96
|
+
};
|
|
97
|
+
contextEngineConfig?: ContextEngineConfig;
|
|
98
|
+
contextAssemblerConfig?: HarnessConfig['contextAssembler'];
|
|
99
|
+
constitutionConfig?: HarnessConfig['constitution'];
|
|
100
|
+
memoryConfig?: HarnessConfig['memory'];
|
|
101
|
+
cognitionConfig?: HarnessConfig['cognition'];
|
|
102
|
+
wisdomConfig?: HarnessConfig['wisdom'];
|
|
103
|
+
securityConfig?: SecurityGuardConfig;
|
|
104
|
+
/** budget 旋钮(JSON 面或 Builder BudgetPolicyConfig 局部) */
|
|
105
|
+
budgetConfig?: BudgetPolicyJsonConfig | Partial<BudgetPolicyConfig>;
|
|
106
|
+
runGuardConfig?: RunGuardJsonConfig;
|
|
107
|
+
/** 并发控制(ProviderPool / SessionGate);与 config-bridge 同源 */
|
|
108
|
+
concurrencyConfig?: HarnessConfig['concurrency'];
|
|
109
|
+
subsystemSpecs?: SubsystemSpec[];
|
|
110
|
+
/** 审计目录;缺省 `<OCTOPI_HOME>/audit`,`false` 显式关闭 */
|
|
111
|
+
subsystemAuditDir?: string | false;
|
|
112
|
+
subsystemAllowlist?: string[];
|
|
113
|
+
subsystemDenylist?: string[];
|
|
114
|
+
/**
|
|
115
|
+
* 宿主 runner 附加项(session lease / ACL / attachment 等)。
|
|
116
|
+
* 与标准字段合并;冲突时宿主值覆盖标准值。
|
|
117
|
+
*/
|
|
118
|
+
extraRunnerConfig?: Partial<SessionAwareRunnerConfig>;
|
|
119
|
+
/** 覆盖默认错误策略(缺省不设,用 Builder 内建) */
|
|
120
|
+
errorStrategy?: ErrorStrategy;
|
|
121
|
+
}
|
|
122
|
+
/**
|
|
123
|
+
* 将标准配置接到 AgentBuilder 上。不调用 `build()`——由宿主在叠加完适配层后 build。
|
|
124
|
+
*
|
|
125
|
+
* @param builder - 目标 builder(宿主可已注入 store/events/model)
|
|
126
|
+
* @param spec - 标准组装输入
|
|
127
|
+
*/
|
|
128
|
+
export declare function wireAgentBuilder(builder: AgentBuilder, spec: AgentWireSpec): Promise<{
|
|
129
|
+
memoryStore?: unknown;
|
|
130
|
+
skillManager?: unknown;
|
|
131
|
+
}>;
|
|
132
|
+
/** 显式 specs 时是否仍允许 builder 自动发现(防双载) */
|
|
133
|
+
export declare function shouldAutoLoadSubsystems(spec: Pick<AgentWireSpec, 'subsystemSpecs'>): boolean;
|
|
@@ -0,0 +1,363 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* wireAgentBuilder — 配置 → AgentBuilder 的唯一组装入口
|
|
3
|
+
*
|
|
4
|
+
* 设计约定:
|
|
5
|
+
* - 产品(Gateway)与库嵌入(config-bridge)**都只调用本函数**,禁止各自维护第二套接线清单。
|
|
6
|
+
* - 本函数覆盖「标准配置」:模型档 / summarize / contextEngine / security / budget /
|
|
7
|
+
* runGuard / persona / skills / memory stores / subsystems / toolIsolation / effectPolicy。
|
|
8
|
+
* - 宿主适配(circuit breaker、WS、approval 门禁、Knowledge Service、委派…)在 wire **之后**
|
|
9
|
+
* 由宿主自己叠加,不进本文件。
|
|
10
|
+
* - 不做双轨/兼容层:漏接线即 bug,由契约测试锁两路径能力一致。
|
|
11
|
+
*
|
|
12
|
+
* @module harness/agent/wire-agent-builder
|
|
13
|
+
*/
|
|
14
|
+
import { existsSync } from 'node:fs';
|
|
15
|
+
import { join } from 'node:path';
|
|
16
|
+
import { getOctopiHome } from '../../paths.js';
|
|
17
|
+
import { DefaultRunGuard, } from '../run/run-guard/default-run-guard.js';
|
|
18
|
+
import { DefaultContextEngine } from '../context/default-context-engine.js';
|
|
19
|
+
import { DefaultBudgetAllocator } from '../context/budget-allocator.js';
|
|
20
|
+
// ── 配置解析(唯一实现;供 wire 与公开导出共用) ──
|
|
21
|
+
/**
|
|
22
|
+
* 解析子系统审计目录(docs/autonomous-subsystem.md §10)
|
|
23
|
+
*
|
|
24
|
+
* - `false` → 关闭审计(返回 undefined,不接 AuditWriter)
|
|
25
|
+
* - 字符串 → 显式目录
|
|
26
|
+
* - 缺省 → `<OCTOPI_HOME>/audit`(`OCTOPI_HOME` env 可重定向,测试可隔离)
|
|
27
|
+
*
|
|
28
|
+
* @param configured - 配置值(`subsystems.auditDir`)
|
|
29
|
+
* @returns 审计目录;undefined = 显式关闭
|
|
30
|
+
*/
|
|
31
|
+
export function resolveSubsystemAuditDir(configured) {
|
|
32
|
+
if (configured === false)
|
|
33
|
+
return undefined;
|
|
34
|
+
return configured ?? join(getOctopiHome(), 'audit');
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* 从配置中解析安全策略(始终返回;无总开关)
|
|
38
|
+
*
|
|
39
|
+
* 硬边界与 ToolCallRiskPolicy 由 Guard/Builder 保证接线,
|
|
40
|
+
* 这里只归一化处置、范围与灵敏度。
|
|
41
|
+
*
|
|
42
|
+
* @param config - Harness 配置
|
|
43
|
+
* @returns 安全策略
|
|
44
|
+
*/
|
|
45
|
+
export function resolveSecurityConfig(config) {
|
|
46
|
+
const security = config.security ?? {};
|
|
47
|
+
return {
|
|
48
|
+
enforce: security.enforce ?? 'block',
|
|
49
|
+
injectionSensitivity: security.injectionSensitivity ?? 'medium',
|
|
50
|
+
allowedPaths: security.allowedPaths ?? [],
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* 从配置中创建 ContextEngine 实例
|
|
55
|
+
*
|
|
56
|
+
* @param config - contextEngine 配置(可空)
|
|
57
|
+
* @returns ContextEngine
|
|
58
|
+
*/
|
|
59
|
+
export function resolveContextEngine(config) {
|
|
60
|
+
// 缺省 type = default:只给旋钮(如 proactiveCompactRatio)也必须落到默认引擎
|
|
61
|
+
if (!config || config.type == null || config.type === 'default') {
|
|
62
|
+
return new DefaultContextEngine({
|
|
63
|
+
protectFirstN: config?.protectFirstN ?? 3,
|
|
64
|
+
protectLastN: config?.protectLastN ?? 20,
|
|
65
|
+
proactiveCompactRatio: config?.proactiveCompactRatio ?? 0.6,
|
|
66
|
+
proactiveCooldownMs: config?.proactiveCooldownMs ?? 30_000,
|
|
67
|
+
historyAging: config?.historyAging,
|
|
68
|
+
targetTokens: config?.targetTokens,
|
|
69
|
+
compactFallbackRatio: config?.compactFallbackRatio,
|
|
70
|
+
budgetAllocator: new DefaultBudgetAllocator({
|
|
71
|
+
outputRatio: config?.outputRatio ?? 0.20,
|
|
72
|
+
minOutputReserve: config?.minOutputReserve ?? 2000,
|
|
73
|
+
maxOutputReserve: config?.maxOutputReserve ?? 8000,
|
|
74
|
+
}),
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
throw new Error(`Unknown context engine type: ${config.type}`);
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* 从配置中解析 RunGuard
|
|
81
|
+
*
|
|
82
|
+
* 解析 llmModel 字段:
|
|
83
|
+
* - "model" → 使用主 provider
|
|
84
|
+
* - "provider/model" → 使用指定 provider
|
|
85
|
+
*
|
|
86
|
+
* @param config - runGuard JSON 配置
|
|
87
|
+
* @param providers - 可用 provider 映射
|
|
88
|
+
* @returns RunGuard 或 undefined(禁用时)
|
|
89
|
+
*/
|
|
90
|
+
export function resolveRunGuard(config, providers) {
|
|
91
|
+
if (!config || config.enabled === false)
|
|
92
|
+
return undefined;
|
|
93
|
+
let reviewModel;
|
|
94
|
+
if (config.llmModel) {
|
|
95
|
+
const parts = config.llmModel.split('/');
|
|
96
|
+
if (parts.length === 2) {
|
|
97
|
+
reviewModel = providers.get(parts[0]);
|
|
98
|
+
config = { ...config, llmModel: parts[1] };
|
|
99
|
+
}
|
|
100
|
+
else {
|
|
101
|
+
reviewModel = providers.values().next().value;
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
const runGuardConfig = {
|
|
105
|
+
enabled: true,
|
|
106
|
+
checkpointInterval: config.checkpointInterval,
|
|
107
|
+
minCheckpointInterval: config.minCheckpointInterval,
|
|
108
|
+
maxCheckpointInterval: config.maxCheckpointInterval,
|
|
109
|
+
enableLLMReview: config.enableLLMReview,
|
|
110
|
+
llmReviewInterval: config.llmReviewInterval,
|
|
111
|
+
llmModel: config.llmModel,
|
|
112
|
+
hardLimit: config.hardLimit,
|
|
113
|
+
hardWallClockMs: config.hardWallClockMs,
|
|
114
|
+
};
|
|
115
|
+
return new DefaultRunGuard(runGuardConfig, reviewModel);
|
|
116
|
+
}
|
|
117
|
+
/**
|
|
118
|
+
* 将标准配置接到 AgentBuilder 上。不调用 `build()`——由宿主在叠加完适配层后 build。
|
|
119
|
+
*
|
|
120
|
+
* @param builder - 目标 builder(宿主可已注入 store/events/model)
|
|
121
|
+
* @param spec - 标准组装输入
|
|
122
|
+
*/
|
|
123
|
+
export async function wireAgentBuilder(builder, spec) {
|
|
124
|
+
// ── Model ──
|
|
125
|
+
builder.model(spec.model);
|
|
126
|
+
// ── Model call watchdog ──
|
|
127
|
+
if (spec.modelCallTimeouts) {
|
|
128
|
+
builder.modelCallTimeouts(spec.modelCallTimeouts);
|
|
129
|
+
}
|
|
130
|
+
// ── Model Levels(子系统 think.model / 摘要选型共用) ──
|
|
131
|
+
if (spec.levelMap) {
|
|
132
|
+
builder.withModelLevels(spec.levelMap);
|
|
133
|
+
}
|
|
134
|
+
// ── Providers 映射(子系统 provider/model 解析用;缺 provider 回退主模型) ──
|
|
135
|
+
builder.providers(spec.providers);
|
|
136
|
+
// ── 并发控制(ProviderPool / SessionGate) ──
|
|
137
|
+
if (spec.concurrencyConfig) {
|
|
138
|
+
builder.concurrency(spec.concurrencyConfig);
|
|
139
|
+
}
|
|
140
|
+
// ── Workspace ──
|
|
141
|
+
if (spec.workspace) {
|
|
142
|
+
builder.workspace(spec.workspace);
|
|
143
|
+
}
|
|
144
|
+
// ── Tool isolation (I5) ──
|
|
145
|
+
if (spec.toolIsolation) {
|
|
146
|
+
builder.toolIsolation(spec.toolIsolation);
|
|
147
|
+
}
|
|
148
|
+
// ── EffectPolicy (P3) ──
|
|
149
|
+
if (spec.effectPolicy) {
|
|
150
|
+
builder.effectPolicy(spec.effectPolicy);
|
|
151
|
+
}
|
|
152
|
+
// ── Runner:标准字段 + 宿主附加 ──
|
|
153
|
+
const runnerConfig = {
|
|
154
|
+
...(spec.sessionIdleExpiryMs && spec.sessionIdleExpiryMs > 0
|
|
155
|
+
? { idleExpiryMs: spec.sessionIdleExpiryMs }
|
|
156
|
+
: {}),
|
|
157
|
+
...(spec.tools ? { agentToolPolicy: spec.tools } : {}),
|
|
158
|
+
...(spec.maxSessionRights !== undefined
|
|
159
|
+
? { agentMaxSessionRights: spec.maxSessionRights }
|
|
160
|
+
: {}),
|
|
161
|
+
...(spec.extraRunnerConfig ?? {}),
|
|
162
|
+
};
|
|
163
|
+
if (Object.keys(runnerConfig).length > 0) {
|
|
164
|
+
builder.runnerConfig(runnerConfig);
|
|
165
|
+
}
|
|
166
|
+
// ── Home / Persona / Skills ──
|
|
167
|
+
// stores 只跟显式 home 走;string persona 只作 prompt 目录,不隐式开 agent.db
|
|
168
|
+
//(config-bridge 需要 legacy persona-as-home 时应显式传 home)。
|
|
169
|
+
const agentHome = spec.home;
|
|
170
|
+
// agentId 无条件接线(审计分区 / 工具域对称);home 只决定 agent 文件态目录
|
|
171
|
+
builder.agentId(spec.agentId);
|
|
172
|
+
if (spec.home) {
|
|
173
|
+
builder.agentHome(spec.home);
|
|
174
|
+
}
|
|
175
|
+
if (typeof spec.persona === 'string') {
|
|
176
|
+
builder.persona(spec.persona);
|
|
177
|
+
}
|
|
178
|
+
else if (spec.persona?.systemPrompt) {
|
|
179
|
+
builder.systemPrompt(spec.persona.systemPrompt);
|
|
180
|
+
}
|
|
181
|
+
else if (agentHome) {
|
|
182
|
+
builder.persona(agentHome);
|
|
183
|
+
}
|
|
184
|
+
const skillDir = spec.skillDirectory ?? (agentHome ? join(agentHome, 'skills') : undefined);
|
|
185
|
+
let skillManager;
|
|
186
|
+
if (skillDir && existsSync(skillDir)) {
|
|
187
|
+
try {
|
|
188
|
+
const { DefaultSkillManager } = await import('../extension/plugin-ecosystem/skills/manager.js');
|
|
189
|
+
skillManager = new DefaultSkillManager();
|
|
190
|
+
await skillManager.discover(skillDir);
|
|
191
|
+
builder.skills(skillManager);
|
|
192
|
+
}
|
|
193
|
+
catch (err) {
|
|
194
|
+
console.warn(`[AgentWire] skill discover failed for ${skillDir}: ${err instanceof Error ? err.message : String(err)}`);
|
|
195
|
+
skillManager = undefined;
|
|
196
|
+
}
|
|
197
|
+
// 无 manager 时 builder 仍可用目录兜底
|
|
198
|
+
builder.skillDirectory(skillDir);
|
|
199
|
+
}
|
|
200
|
+
// ── Memory / Wisdom / Cognition(agent home 下 AgentDatabase) ──
|
|
201
|
+
let memoryStore;
|
|
202
|
+
if (agentHome) {
|
|
203
|
+
const stores = await wireContextStores(builder, {
|
|
204
|
+
agentHome,
|
|
205
|
+
modelsConfig: spec.modelsConfig,
|
|
206
|
+
memoryConfig: spec.memoryConfig,
|
|
207
|
+
wisdomConfig: spec.wisdomConfig,
|
|
208
|
+
cognitionConfig: spec.cognitionConfig,
|
|
209
|
+
});
|
|
210
|
+
memoryStore = stores.memoryStore;
|
|
211
|
+
}
|
|
212
|
+
// ── Security(策略与 RiskPolicy 始终接线) ──
|
|
213
|
+
builder.securityPolicy(spec.securityConfig ?? {});
|
|
214
|
+
const { DefaultToolCallRiskPolicy } = await import('../governance/security/default-risk-policy.js');
|
|
215
|
+
builder.withRiskPolicy(new DefaultToolCallRiskPolicy({ cwd: spec.workspace }));
|
|
216
|
+
// ── Budget + wrap-up / policy units ──
|
|
217
|
+
if (spec.budgetConfig) {
|
|
218
|
+
wireBudget(builder, spec.budgetConfig);
|
|
219
|
+
}
|
|
220
|
+
// ── Context Engine(缺省也接线:配置面必须有唯一出口) ──
|
|
221
|
+
builder.contextEngine(resolveContextEngine(spec.contextEngineConfig));
|
|
222
|
+
// ── Context Assembler / Constitution / Memory policy ──
|
|
223
|
+
if (spec.contextAssemblerConfig) {
|
|
224
|
+
builder.contextAssembler(spec.contextAssemblerConfig);
|
|
225
|
+
}
|
|
226
|
+
if (spec.constitutionConfig !== undefined) {
|
|
227
|
+
builder.constitution(spec.constitutionConfig);
|
|
228
|
+
}
|
|
229
|
+
if (spec.memoryConfig) {
|
|
230
|
+
builder.memoryConfig(spec.memoryConfig);
|
|
231
|
+
}
|
|
232
|
+
// ── summarize:与会话同模型(前缀缓存同域)──
|
|
233
|
+
// 不自动切 summary/mini:换 provider/model = 换缓存域,全量历史冷 prefill。
|
|
234
|
+
// 显式 builder.summarize() 仍可覆盖;缺省走 AgentBuilder 的 session 模型路径。
|
|
235
|
+
// ── RunGuard ──
|
|
236
|
+
if (spec.runGuardConfig?.enabled !== false) {
|
|
237
|
+
const guard = resolveRunGuard(spec.runGuardConfig, spec.providers);
|
|
238
|
+
if (guard) {
|
|
239
|
+
builder.runGuard(guard);
|
|
240
|
+
}
|
|
241
|
+
if (spec.runGuardConfig?.checkpointInterval !== undefined) {
|
|
242
|
+
builder.reliability({
|
|
243
|
+
checkpointInterval: spec.runGuardConfig.checkpointInterval,
|
|
244
|
+
});
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
// ── Subsystems ──
|
|
248
|
+
if (spec.subsystemSpecs && spec.subsystemSpecs.length > 0) {
|
|
249
|
+
for (const s of spec.subsystemSpecs) {
|
|
250
|
+
builder.withSubsystem(s);
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
const auditDir = resolveSubsystemAuditDir(spec.subsystemAuditDir);
|
|
254
|
+
if (auditDir) {
|
|
255
|
+
builder.withSubsystemAuditDir(auditDir);
|
|
256
|
+
}
|
|
257
|
+
if (spec.subsystemAllowlist?.length) {
|
|
258
|
+
builder.subsystemAllowlist(...spec.subsystemAllowlist);
|
|
259
|
+
}
|
|
260
|
+
if (spec.subsystemDenylist?.length) {
|
|
261
|
+
builder.subsystemDenylist(...spec.subsystemDenylist);
|
|
262
|
+
}
|
|
263
|
+
if (spec.errorStrategy) {
|
|
264
|
+
builder.errorStrategy(spec.errorStrategy);
|
|
265
|
+
}
|
|
266
|
+
return { memoryStore, skillManager };
|
|
267
|
+
}
|
|
268
|
+
/** 显式 specs 时是否仍允许 builder 自动发现(防双载) */
|
|
269
|
+
export function shouldAutoLoadSubsystems(spec) {
|
|
270
|
+
return (spec.subsystemSpecs?.length ?? 0) === 0;
|
|
271
|
+
}
|
|
272
|
+
// ── 内部 ──
|
|
273
|
+
function wireBudget(builder, budgetConfig) {
|
|
274
|
+
const engineConfig = {
|
|
275
|
+
maxWallClockMs: budgetConfig.maxWallClockMs,
|
|
276
|
+
maxIterations: budgetConfig.maxIterations,
|
|
277
|
+
maxToolCalls: budgetConfig.maxToolCalls,
|
|
278
|
+
};
|
|
279
|
+
builder.budget(engineConfig);
|
|
280
|
+
const wrapUpConfig = {};
|
|
281
|
+
if ('wrapUpTurns' in budgetConfig && budgetConfig.wrapUpTurns !== undefined) {
|
|
282
|
+
wrapUpConfig.turns = budgetConfig.wrapUpTurns;
|
|
283
|
+
}
|
|
284
|
+
if ('onPolicyHit' in budgetConfig && budgetConfig.onPolicyHit !== undefined) {
|
|
285
|
+
wrapUpConfig.onPolicyHit = budgetConfig.onPolicyHit;
|
|
286
|
+
}
|
|
287
|
+
if ('contextWrapUpRatio' in budgetConfig && budgetConfig.contextWrapUpRatio !== undefined) {
|
|
288
|
+
wrapUpConfig.contextRatio = budgetConfig.contextWrapUpRatio;
|
|
289
|
+
}
|
|
290
|
+
const policyUnits = 'units' in budgetConfig ? budgetConfig.units : undefined;
|
|
291
|
+
const policyPricing = 'pricing' in budgetConfig ? budgetConfig.pricing : undefined;
|
|
292
|
+
const advisory = 'advisory' in budgetConfig ? budgetConfig.advisory : undefined;
|
|
293
|
+
if (Object.keys(wrapUpConfig).length > 0 || policyUnits || policyPricing || advisory) {
|
|
294
|
+
builder.reliability({
|
|
295
|
+
wrapUp: Object.keys(wrapUpConfig).length > 0
|
|
296
|
+
? wrapUpConfig
|
|
297
|
+
: undefined,
|
|
298
|
+
policyUnits: policyUnits
|
|
299
|
+
? {
|
|
300
|
+
maxCost: policyUnits.maxCost,
|
|
301
|
+
maxUncachedInputTokens: policyUnits.maxUncachedInputTokens,
|
|
302
|
+
maxOutputTokens: policyUnits.maxOutputTokens,
|
|
303
|
+
maxLlmCalls: policyUnits.maxLlmCalls,
|
|
304
|
+
}
|
|
305
|
+
: undefined,
|
|
306
|
+
policyPricing,
|
|
307
|
+
advisory: advisory,
|
|
308
|
+
});
|
|
309
|
+
}
|
|
310
|
+
}
|
|
311
|
+
async function wireContextStores(builder, input) {
|
|
312
|
+
try {
|
|
313
|
+
const { AgentDatabase } = await import('../memory/sqlite/agent-db.js');
|
|
314
|
+
const { SqliteMemoryStore } = await import('../memory/sqlite/memory-store.js');
|
|
315
|
+
const { SqliteWisdomStore } = await import('../memory/sqlite/wisdom-store.js');
|
|
316
|
+
const { SqliteConceptGraph } = await import('../memory/sqlite/cognition-store.js');
|
|
317
|
+
const { resolveEmbeddingRuntime } = await import('../memory/sqlite/embedding-from-models.js');
|
|
318
|
+
const embRuntime = resolveEmbeddingRuntime({
|
|
319
|
+
providers: input.modelsConfig?.providers ?? {},
|
|
320
|
+
embedding: input.modelsConfig?.embedding,
|
|
321
|
+
});
|
|
322
|
+
const useVec = embRuntime && embRuntime.vectorEngine !== 'js';
|
|
323
|
+
const db = await AgentDatabase.create({
|
|
324
|
+
dbPath: join(input.agentHome, 'agent.db'),
|
|
325
|
+
sqliteVec: useVec
|
|
326
|
+
? { extensionPath: embRuntime?.sqliteVecExtensionPath }
|
|
327
|
+
: false,
|
|
328
|
+
vectorDimensions: useVec ? embRuntime?.dimensions : undefined,
|
|
329
|
+
});
|
|
330
|
+
const memoryStore = new SqliteMemoryStore(db, {
|
|
331
|
+
embeddingProvider: embRuntime?.provider ?? null,
|
|
332
|
+
vectorEngine: embRuntime?.vectorEngine ?? 'auto',
|
|
333
|
+
minSimilarity: input.memoryConfig?.retrieval?.minSimilarity,
|
|
334
|
+
similarityWeight: input.memoryConfig?.retrieval?.similarityWeight,
|
|
335
|
+
minKeywordScore: input.memoryConfig?.retrieval?.minKeywordScore,
|
|
336
|
+
});
|
|
337
|
+
builder.memoryStore(memoryStore);
|
|
338
|
+
const wis = input.wisdomConfig;
|
|
339
|
+
if (wis?.enabled !== false) {
|
|
340
|
+
builder.wisdomStore(new SqliteWisdomStore(db, { hardCap: wis?.capacity?.hardCap }));
|
|
341
|
+
}
|
|
342
|
+
const cog = input.cognitionConfig;
|
|
343
|
+
if (cog?.enabled !== false) {
|
|
344
|
+
builder.cognitionStore(new SqliteConceptGraph(db, {
|
|
345
|
+
embeddingProvider: embRuntime?.provider ?? null,
|
|
346
|
+
mergeThreshold: cog?.identity?.mergeThreshold,
|
|
347
|
+
candidateBandHi: cog?.identity?.candidateBandHi,
|
|
348
|
+
stopNodes: cog?.capacity?.stopNodes,
|
|
349
|
+
stopEdges: cog?.capacity?.stopEdges,
|
|
350
|
+
causesMinIndependentMemories: cog?.relations?.causesMinIndependentMemories,
|
|
351
|
+
}));
|
|
352
|
+
}
|
|
353
|
+
return { memoryStore };
|
|
354
|
+
}
|
|
355
|
+
catch (err) {
|
|
356
|
+
const msg = err instanceof Error ? err.message : String(err);
|
|
357
|
+
console.warn(`[AgentWire] memory/wisdom/cognition stores unavailable for agent home ${input.agentHome}: ${msg}`);
|
|
358
|
+
if (/node:sqlite|ERR_UNKNOWN_BUILTIN_MODULE|ERR_DLOPEN|NODE_MODULE_VERSION/i.test(msg)) {
|
|
359
|
+
console.warn(`[AgentWire] hint: SQLite backend requires Node.js >= 24 with built-in node:sqlite (process.version=${process.version})`);
|
|
360
|
+
}
|
|
361
|
+
return {};
|
|
362
|
+
}
|
|
363
|
+
}
|
|
@@ -29,12 +29,14 @@ export type SubsystemTriggerResult = {
|
|
|
29
29
|
status: SubsystemRunStatus;
|
|
30
30
|
};
|
|
31
31
|
export interface SharedDeps {
|
|
32
|
+
/** 主 provider 实例(resolved 未指名 provider / 未命中时回退) */
|
|
32
33
|
model: ModelProvider;
|
|
33
34
|
events: EventBus;
|
|
34
35
|
errorStrategy: ErrorStrategy;
|
|
35
36
|
mainTools: import('@octopi-agent/core/interfaces/tool-bus.js').ToolBus;
|
|
36
37
|
modelLevels?: ModelLevelMap;
|
|
37
|
-
|
|
38
|
+
/** 按名选择 provider(`think.model: "provider/model"` / levels.primary 的 provider 段) */
|
|
39
|
+
providers?: Map<string, ModelProvider>;
|
|
38
40
|
/** 依赖注入注册表:名称 → 实现实例,供 runtimeInject.requires 解析 */
|
|
39
41
|
injectRegistry?: Map<string, unknown>;
|
|
40
42
|
}
|
|
@@ -49,6 +51,7 @@ export declare class SubsystemRuntime {
|
|
|
49
51
|
private thinkExecutor;
|
|
50
52
|
private signalBus;
|
|
51
53
|
private sessionManager;
|
|
54
|
+
private sessionLifecycleBridge;
|
|
52
55
|
private auditWriter?;
|
|
53
56
|
private modelResolver;
|
|
54
57
|
private subsystems;
|
|
@@ -10,6 +10,7 @@ import { SubsystemTimeoutError } from './errors.js';
|
|
|
10
10
|
import { TokenBudgetExceededError } from './think/executor.js';
|
|
11
11
|
import { randomUUID } from 'node:crypto';
|
|
12
12
|
import { SenseEngine } from './sense/engine.js';
|
|
13
|
+
import { SessionLifecycleBridge } from './sense/session-lifecycle-bridge.js';
|
|
13
14
|
import { ThinkExecutor } from './think/executor.js';
|
|
14
15
|
import { ModelResolver } from './think/model-resolver.js';
|
|
15
16
|
import { createSubsystemLLMPort, DEP_LLM_PORT, DEP_RESOLVED_MODEL, DEP_RESOLVED_MODELS, DEP_SUBSYSTEM_PROMPT, } from './think/llm-port.js';
|
|
@@ -26,6 +27,7 @@ export class SubsystemRuntime {
|
|
|
26
27
|
thinkExecutor;
|
|
27
28
|
signalBus;
|
|
28
29
|
sessionManager;
|
|
30
|
+
sessionLifecycleBridge;
|
|
29
31
|
auditWriter;
|
|
30
32
|
modelResolver;
|
|
31
33
|
subsystems = new Map();
|
|
@@ -38,21 +40,23 @@ export class SubsystemRuntime {
|
|
|
38
40
|
this.senseEngine = new SenseEngine({
|
|
39
41
|
events: config.deps.events,
|
|
40
42
|
});
|
|
43
|
+
// levels 缺省为空:think.model 引用未配置的级别名时 fail-loud(见 ModelResolver),
|
|
44
|
+
// 不再用 'default/mini' 这类假缺省静默打错模型。
|
|
41
45
|
this.modelResolver = new ModelResolver({
|
|
42
|
-
levels: config.deps.modelLevels ?? {
|
|
43
|
-
mini: { primary: 'default/mini' },
|
|
44
|
-
standard: { primary: 'default/standard' },
|
|
45
|
-
pro: { primary: 'default/pro' },
|
|
46
|
-
},
|
|
47
|
-
defaultProvider: config.deps.defaultModelProvider,
|
|
46
|
+
levels: config.deps.modelLevels ?? {},
|
|
48
47
|
});
|
|
49
48
|
this.thinkExecutor = new ThinkExecutor({
|
|
50
49
|
modelResolver: this.modelResolver,
|
|
51
50
|
modelProvider: config.deps.model,
|
|
51
|
+
providers: config.deps.providers,
|
|
52
52
|
errorStrategy: config.deps.errorStrategy,
|
|
53
53
|
});
|
|
54
54
|
this.signalBus = new SignalBus({ events: config.deps.events });
|
|
55
55
|
this.sessionManager = new SubsystemSessionManager();
|
|
56
|
+
// 会话生命周期 → metrics(session.lifecycle.* / session.idle.ms / session.extraction.*),
|
|
57
|
+
// schedule 模式条件(ctx 只有 metrics)依赖这些键感知空闲/生命周期。
|
|
58
|
+
// agentId 绑定:共享总线上多 agent 事件不互相污染。
|
|
59
|
+
this.sessionLifecycleBridge = new SessionLifecycleBridge(config.deps.events, this.senseEngine.metricsStore, { agentId: config.agentId });
|
|
56
60
|
config.deps.events.on('session.ended', (event) => {
|
|
57
61
|
const data = (event.data ?? {});
|
|
58
62
|
const agentId = event.agentId ?? data.agentId;
|
|
@@ -257,6 +261,7 @@ export class SubsystemRuntime {
|
|
|
257
261
|
* 清理所有资源
|
|
258
262
|
*/
|
|
259
263
|
dispose() {
|
|
264
|
+
this.sessionLifecycleBridge.dispose();
|
|
260
265
|
this.cancelPendingAbortTimers();
|
|
261
266
|
this.senseEngine.dispose();
|
|
262
267
|
this.sessionManager.dispose();
|
|
@@ -361,13 +366,14 @@ export class SubsystemRuntime {
|
|
|
361
366
|
if (entry.spec.think.systemPrompt) {
|
|
362
367
|
injectDeps[DEP_SUBSYSTEM_PROMPT] = entry.spec.think.systemPrompt;
|
|
363
368
|
}
|
|
364
|
-
const resolved = this.modelResolver.
|
|
369
|
+
const resolved = this.modelResolver.resolveRef(entry.spec.think.model);
|
|
365
370
|
injectDeps[DEP_RESOLVED_MODEL] = resolved.primary.model;
|
|
366
371
|
injectDeps[DEP_RESOLVED_MODELS] = resolved;
|
|
367
372
|
injectDeps[DEP_LLM_PORT] = createSubsystemLLMPort({
|
|
368
373
|
provider: this.deps.model,
|
|
374
|
+
providers: this.deps.providers,
|
|
369
375
|
modelResolver: this.modelResolver,
|
|
370
|
-
modelRef: entry.spec.think.model
|
|
376
|
+
modelRef: entry.spec.think.model,
|
|
371
377
|
cognitivePrompt: entry.spec.think.systemPrompt,
|
|
372
378
|
});
|
|
373
379
|
const result = await this.thinkExecutor.execute(entry.spec.think, input, entry.spec.act.mode, tools, injectDeps, { abortSignal: abortController.signal, tokenBudget: maxTokens });
|
|
@@ -35,6 +35,18 @@ export declare class MetricsStore {
|
|
|
35
35
|
* @returns 指标值,不存在返回 undefined
|
|
36
36
|
*/
|
|
37
37
|
get(key: string): number | undefined;
|
|
38
|
+
/**
|
|
39
|
+
* 删除指标
|
|
40
|
+
*
|
|
41
|
+
* @param key - 指标名
|
|
42
|
+
*/
|
|
43
|
+
delete(key: string): void;
|
|
44
|
+
/**
|
|
45
|
+
* 删除某前缀下的全部指标(如「最新状态」类标志换值时清旧值)
|
|
46
|
+
*
|
|
47
|
+
* @param prefix - 指标名前缀
|
|
48
|
+
*/
|
|
49
|
+
deletePrefix(prefix: string): void;
|
|
38
50
|
/**
|
|
39
51
|
* 获取当前指标快照
|
|
40
52
|
*/
|
|
@@ -42,6 +42,25 @@ export class MetricsStore {
|
|
|
42
42
|
get(key) {
|
|
43
43
|
return this.metrics.get(key);
|
|
44
44
|
}
|
|
45
|
+
/**
|
|
46
|
+
* 删除指标
|
|
47
|
+
*
|
|
48
|
+
* @param key - 指标名
|
|
49
|
+
*/
|
|
50
|
+
delete(key) {
|
|
51
|
+
this.metrics.delete(key);
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* 删除某前缀下的全部指标(如「最新状态」类标志换值时清旧值)
|
|
55
|
+
*
|
|
56
|
+
* @param prefix - 指标名前缀
|
|
57
|
+
*/
|
|
58
|
+
deletePrefix(prefix) {
|
|
59
|
+
for (const key of this.metrics.keys()) {
|
|
60
|
+
if (key.startsWith(prefix))
|
|
61
|
+
this.metrics.delete(key);
|
|
62
|
+
}
|
|
63
|
+
}
|
|
45
64
|
/**
|
|
46
65
|
* 获取当前指标快照
|
|
47
66
|
*/
|
|
@@ -18,6 +18,11 @@ export interface SessionLifecycleBridgeOptions {
|
|
|
18
18
|
enableIdle?: boolean;
|
|
19
19
|
/** idle 更新间隔(毫秒,默认 15_000) */
|
|
20
20
|
idleTickMs?: number;
|
|
21
|
+
/**
|
|
22
|
+
* 只跟踪该 agent 的会话事件(SubsystemRuntime 按 agentId 绑定)。
|
|
23
|
+
* 缺省不过滤(嵌入宿主单 agent 场景)。
|
|
24
|
+
*/
|
|
25
|
+
agentId?: string;
|
|
21
26
|
}
|
|
22
27
|
/**
|
|
23
28
|
* SessionLifecycleBridge
|
|
@@ -30,6 +35,7 @@ export declare class SessionLifecycleBridge {
|
|
|
30
35
|
private tick?;
|
|
31
36
|
private enableIdle;
|
|
32
37
|
private idleTickMs;
|
|
38
|
+
private agentId?;
|
|
33
39
|
constructor(events: EventBus, metrics: MetricsStore, options?: SessionLifecycleBridgeOptions);
|
|
34
40
|
/** 更新主会话状态(外部调用:Runner / SessionManager / PluginManager) */
|
|
35
41
|
updateState(input: {
|