@octopi-agent/engine 0.65.0 → 0.86.38
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +201 -201
- package/NOTICE +7 -7
- package/README.md +64 -26
- package/dist/config-schema/agent.d.ts +89 -1
- package/dist/config-schema/agent.js +69 -0
- package/dist/config-schema/context.d.ts +23 -4
- package/dist/config-schema/context.js +28 -1
- package/dist/config-schema/engine.d.ts +285 -9
- package/dist/config-schema/engine.js +35 -3
- package/dist/config-schema/governance.d.ts +95 -0
- package/dist/config-schema/governance.js +91 -0
- package/dist/config-schema/models.d.ts +1 -1
- package/dist/config-schema/observability.d.ts +6 -0
- package/dist/config-schema/observability.js +16 -0
- package/dist/config-schema/run.d.ts +10 -0
- package/dist/config-schema/run.js +18 -0
- package/dist/config-schema/shared.d.ts +10 -0
- package/dist/config-schema/shared.js +10 -0
- package/dist/config-schema/substrate.d.ts +87 -1
- package/dist/config-schema/substrate.js +114 -0
- package/dist/config-schema/subsystems.d.ts +1 -1
- package/dist/config-schema/subsystems.js +2 -1
- package/dist/config.d.ts +249 -7
- package/dist/config.js +113 -3
- package/dist/harness/activation/compiler.js +3 -0
- package/dist/harness/activation/runtime.d.ts +7 -0
- package/dist/harness/activation/runtime.js +60 -2
- package/dist/harness/activation/sources/agent-signal.d.ts +11 -0
- package/dist/harness/activation/sources/agent-signal.js +33 -0
- package/dist/harness/activation/types.d.ts +6 -1
- package/dist/harness/agent/builder.d.ts +48 -4
- package/dist/harness/agent/builder.js +206 -55
- package/dist/harness/agent/config-bridge.d.ts +33 -25
- package/dist/harness/agent/config-bridge.js +83 -280
- package/dist/harness/agent/index.d.ts +3 -1
- package/dist/harness/agent/index.js +2 -1
- package/dist/harness/agent/tool-purpose.d.ts +38 -0
- package/dist/harness/agent/tool-purpose.js +118 -0
- package/dist/harness/agent/wire-agent-builder.d.ts +133 -0
- package/dist/harness/agent/wire-agent-builder.js +363 -0
- package/dist/harness/collaboration/autonomous-subsystem/runtime.d.ts +4 -1
- package/dist/harness/collaboration/autonomous-subsystem/runtime.js +14 -8
- package/dist/harness/collaboration/autonomous-subsystem/sense/metrics.d.ts +12 -0
- package/dist/harness/collaboration/autonomous-subsystem/sense/metrics.js +19 -0
- package/dist/harness/collaboration/autonomous-subsystem/sense/session-lifecycle-bridge.d.ts +6 -0
- package/dist/harness/collaboration/autonomous-subsystem/sense/session-lifecycle-bridge.js +24 -7
- package/dist/harness/collaboration/autonomous-subsystem/think/executor.d.ts +5 -2
- package/dist/harness/collaboration/autonomous-subsystem/think/executor.js +11 -3
- package/dist/harness/collaboration/autonomous-subsystem/think/index.d.ts +1 -1
- package/dist/harness/collaboration/autonomous-subsystem/think/index.js +1 -1
- package/dist/harness/collaboration/autonomous-subsystem/think/llm-port.d.ts +7 -4
- package/dist/harness/collaboration/autonomous-subsystem/think/llm-port.js +8 -9
- package/dist/harness/collaboration/autonomous-subsystem/think/model-resolver.d.ts +36 -10
- package/dist/harness/collaboration/autonomous-subsystem/think/model-resolver.js +60 -7
- package/dist/harness/collaboration/delegation/child-run.d.ts +144 -0
- package/dist/harness/collaboration/delegation/child-run.js +241 -0
- package/dist/harness/collaboration/delegation/index.d.ts +26 -0
- package/dist/harness/collaboration/delegation/index.js +25 -0
- package/dist/harness/collaboration/delegation/notifier.d.ts +46 -0
- package/dist/harness/collaboration/delegation/notifier.js +84 -0
- package/dist/harness/collaboration/delegation/registry-types.d.ts +200 -0
- package/dist/harness/collaboration/delegation/registry-types.js +61 -0
- package/dist/harness/collaboration/delegation/registry.d.ts +110 -0
- package/dist/harness/collaboration/delegation/registry.js +220 -0
- package/dist/harness/collaboration/delegation/service.d.ts +249 -0
- package/dist/harness/collaboration/delegation/service.js +499 -0
- package/dist/harness/collaboration/delegation/store.d.ts +155 -0
- package/dist/harness/collaboration/delegation/store.js +271 -0
- package/dist/harness/collaboration/delegation/transport.d.ts +73 -0
- package/dist/harness/collaboration/delegation/transport.js +61 -0
- package/dist/harness/collaboration/delegation/types.d.ts +231 -0
- package/dist/harness/collaboration/delegation/types.js +70 -0
- package/dist/harness/collaboration/delegation/wiring.d.ts +111 -0
- package/dist/harness/collaboration/delegation/wiring.js +145 -0
- package/dist/harness/collaboration/orchestration/index.d.ts +11 -13
- package/dist/harness/collaboration/orchestration/index.js +11 -11
- package/dist/harness/context/assembler.d.ts +2 -2
- package/dist/harness/context/assembler.js +12 -7
- package/dist/harness/context/capabilities/compact/engine.js +80 -38
- package/dist/harness/context/capabilities/compact/types.d.ts +12 -1
- package/dist/harness/context/capabilities/summary/gate.js +2 -2
- package/dist/harness/context/capabilities/summary/policies.js +5 -5
- package/dist/harness/context/capabilities/summary/registry.js +39 -24
- package/dist/harness/context/constitution/default-agents.md +230 -228
- package/dist/harness/context/default-context-engine.d.ts +101 -23
- package/dist/harness/context/default-context-engine.js +483 -172
- package/dist/harness/context/hybrid-compressor.d.ts +3 -3
- package/dist/harness/context/hybrid-compressor.js +18 -23
- package/dist/harness/context/index.d.ts +5 -1
- package/dist/harness/context/index.js +2 -0
- package/dist/harness/context/layer-health.js +3 -2
- package/dist/harness/context/layer-snapshot.d.ts +4 -0
- package/dist/harness/context/layer-snapshot.js +30 -18
- package/dist/harness/context/layer-types.d.ts +49 -1
- package/dist/harness/context/layer-types.js +72 -4
- package/dist/harness/context/layers.d.ts +32 -15
- package/dist/harness/context/layers.js +87 -71
- package/dist/harness/context/llm-summarizer.d.ts +15 -1
- package/dist/harness/context/llm-summarizer.js +107 -56
- package/dist/harness/context/message-selector.js +6 -2
- package/dist/harness/context/root-instructions.d.ts +72 -0
- package/dist/harness/context/root-instructions.js +227 -0
- package/dist/harness/context/runtime-datetime.d.ts +34 -7
- package/dist/harness/context/runtime-datetime.js +66 -10
- package/dist/harness/context/smart-router.d.ts +1 -1
- package/dist/harness/context/smart-router.js +1 -1
- package/dist/harness/context/system-prompt-assembler.d.ts +33 -0
- package/dist/harness/context/system-prompt-assembler.js +78 -7
- package/dist/harness/context/token-constants.d.ts +2 -2
- package/dist/harness/context/token-constants.js +2 -2
- package/dist/harness/context/token-estimate-fns.d.ts +1 -3
- package/dist/harness/context/token-estimate-fns.js +2 -4
- package/dist/harness/context/token-estimator.d.ts +1 -1
- package/dist/harness/context/token-estimator.js +14 -6
- package/dist/harness/context/tool-result-aging.d.ts +140 -0
- package/dist/harness/context/tool-result-aging.js +331 -0
- package/dist/harness/context/tool-result-body.d.ts +10 -0
- package/dist/harness/context/tool-result-body.js +27 -0
- package/dist/harness/context/turn-envelope.d.ts +123 -0
- package/dist/harness/context/turn-envelope.js +188 -0
- package/dist/harness/context/types.d.ts +35 -47
- package/dist/harness/extension/execution-environment/effect-policy.d.ts +248 -0
- package/dist/harness/extension/execution-environment/effect-policy.js +334 -0
- package/dist/harness/extension/execution-environment/index.d.ts +18 -2
- package/dist/harness/extension/execution-environment/index.js +11 -2
- package/dist/harness/extension/execution-environment/memory-undo.d.ts +101 -0
- package/dist/harness/extension/execution-environment/memory-undo.js +192 -0
- package/dist/harness/extension/execution-environment/process-isolation.d.ts +84 -0
- package/dist/harness/extension/execution-environment/process-isolation.js +315 -0
- package/dist/harness/extension/execution-environment/resource-limits.d.ts +36 -0
- package/dist/harness/extension/execution-environment/resource-limits.js +84 -0
- package/dist/harness/extension/execution-environment/sandbox.d.ts +125 -4
- package/dist/harness/extension/execution-environment/sandbox.js +493 -51
- package/dist/harness/extension/execution-environment/shell-journal.d.ts +100 -0
- package/dist/harness/extension/execution-environment/shell-journal.js +299 -0
- package/dist/harness/extension/execution-environment/tool-capabilities.d.ts +45 -0
- package/dist/harness/extension/execution-environment/tool-capabilities.js +126 -0
- package/dist/harness/extension/execution-environment/types.d.ts +67 -39
- package/dist/harness/extension/execution-environment/types.js +2 -2
- package/dist/harness/extension/execution-environment/undo-log.d.ts +203 -0
- package/dist/harness/extension/execution-environment/undo-log.js +627 -0
- package/dist/harness/extension/execution-environment/undo-merge.d.ts +40 -0
- package/dist/harness/extension/execution-environment/undo-merge.js +167 -0
- package/dist/harness/extension/plugin-ecosystem/client-tools/index.d.ts +4 -0
- package/dist/harness/extension/plugin-ecosystem/client-tools/index.js +3 -0
- package/dist/harness/extension/plugin-ecosystem/client-tools/invoke.d.ts +56 -0
- package/dist/harness/extension/plugin-ecosystem/client-tools/invoke.js +281 -0
- package/dist/harness/extension/plugin-ecosystem/client-tools/registry.d.ts +98 -0
- package/dist/harness/extension/plugin-ecosystem/client-tools/registry.js +250 -0
- package/dist/harness/extension/plugin-ecosystem/client-tools/stream.d.ts +124 -0
- package/dist/harness/extension/plugin-ecosystem/client-tools/stream.js +372 -0
- package/dist/harness/extension/plugin-ecosystem/client-tools/types.d.ts +118 -0
- package/dist/harness/extension/plugin-ecosystem/client-tools/types.js +8 -0
- package/dist/harness/extension/plugin-ecosystem/index.d.ts +1 -0
- package/dist/harness/extension/plugin-ecosystem/index.js +1 -0
- package/dist/harness/extension/plugin-ecosystem/mcp/bridge.js +2 -0
- package/dist/harness/extension/plugin-ecosystem/plugins/api.d.ts +1 -6
- package/dist/harness/extension/plugin-ecosystem/plugins/api.js +3 -8
- package/dist/harness/extension/plugin-ecosystem/plugins/capability.d.ts +0 -3
- package/dist/harness/extension/plugin-ecosystem/plugins/capability.js +0 -3
- package/dist/harness/extension/plugin-ecosystem/plugins/entry.d.ts +2 -10
- package/dist/harness/extension/plugin-ecosystem/plugins/entry.js +2 -9
- package/dist/harness/extension/plugin-ecosystem/plugins/index.d.ts +1 -3
- package/dist/harness/extension/plugin-ecosystem/plugins/index.js +1 -3
- package/dist/harness/extension/plugin-ecosystem/plugins/loader.d.ts +2 -4
- package/dist/harness/extension/plugin-ecosystem/plugins/loader.js +4 -21
- package/dist/harness/extension/plugin-ecosystem/plugins/manager.d.ts +3 -9
- package/dist/harness/extension/plugin-ecosystem/plugins/manager.js +4 -8
- package/dist/harness/extension/plugin-ecosystem/plugins/manifest.d.ts +1 -4
- package/dist/harness/extension/plugin-ecosystem/plugins/manifest.js +1 -3
- package/dist/harness/extension/plugin-ecosystem/skills/manager.d.ts +1 -1
- package/dist/harness/extension/plugin-ecosystem/skills/manager.js +1 -1
- package/dist/harness/extension/plugin-ecosystem/tools/allowlisted-run.d.ts +45 -0
- package/dist/harness/extension/plugin-ecosystem/tools/allowlisted-run.js +136 -0
- package/dist/harness/extension/plugin-ecosystem/tools/ask-user.js +1 -0
- package/dist/harness/extension/plugin-ecosystem/tools/builtin.d.ts +18 -3
- package/dist/harness/extension/plugin-ecosystem/tools/builtin.js +278 -82
- package/dist/harness/extension/plugin-ecosystem/tools/delegation.d.ts +31 -0
- package/dist/harness/extension/plugin-ecosystem/tools/delegation.js +291 -0
- package/dist/harness/extension/plugin-ecosystem/tools/document-tools.js +10 -2
- package/dist/harness/extension/plugin-ecosystem/tools/env-info.js +1 -0
- package/dist/harness/extension/plugin-ecosystem/tools/eol.d.ts +35 -0
- package/dist/harness/extension/plugin-ecosystem/tools/eol.js +43 -0
- package/dist/harness/extension/plugin-ecosystem/tools/file-edit.js +40 -9
- package/dist/harness/extension/plugin-ecosystem/tools/file-ops.d.ts +33 -0
- package/dist/harness/extension/plugin-ecosystem/tools/file-ops.js +376 -0
- package/dist/harness/extension/plugin-ecosystem/tools/file-search.d.ts +12 -2
- package/dist/harness/extension/plugin-ecosystem/tools/file-search.js +239 -61
- package/dist/harness/extension/plugin-ecosystem/tools/git-tools.d.ts +27 -0
- package/dist/harness/extension/plugin-ecosystem/tools/git-tools.js +554 -0
- package/dist/harness/extension/plugin-ecosystem/tools/http.d.ts +10 -6
- package/dist/harness/extension/plugin-ecosystem/tools/http.js +41 -47
- package/dist/harness/extension/plugin-ecosystem/tools/index.d.ts +2 -0
- package/dist/harness/extension/plugin-ecosystem/tools/index.js +2 -0
- package/dist/harness/extension/plugin-ecosystem/tools/knowledge.js +4 -0
- package/dist/harness/extension/plugin-ecosystem/tools/memory.d.ts +11 -1
- package/dist/harness/extension/plugin-ecosystem/tools/memory.js +39 -1
- package/dist/harness/extension/plugin-ecosystem/tools/package-tools.d.ts +13 -0
- package/dist/harness/extension/plugin-ecosystem/tools/package-tools.js +391 -0
- package/dist/harness/extension/plugin-ecosystem/tools/platform.d.ts +51 -2
- package/dist/harness/extension/plugin-ecosystem/tools/platform.js +151 -12
- package/dist/harness/extension/plugin-ecosystem/tools/session-history.js +2 -0
- package/dist/harness/extension/plugin-ecosystem/tools/tool-bus.d.ts +10 -1
- package/dist/harness/extension/plugin-ecosystem/tools/tool-bus.js +35 -19
- package/dist/harness/extension/plugin-ecosystem/tools/tool-set.d.ts +8 -0
- package/dist/harness/extension/plugin-ecosystem/tools/tool-set.js +5 -0
- package/dist/harness/extension/plugin-ecosystem/tools/web-search.js +1 -0
- package/dist/harness/governance/credentials/index.d.ts +1 -1
- package/dist/harness/governance/credentials/store.d.ts +16 -4
- package/dist/harness/governance/credentials/store.js +33 -6
- package/dist/harness/governance/credentials/types.d.ts +11 -0
- package/dist/harness/governance/human-in-the-loop/decision-cache.d.ts +105 -0
- package/dist/harness/governance/human-in-the-loop/decision-cache.js +184 -0
- package/dist/harness/governance/human-in-the-loop/index.d.ts +5 -5
- package/dist/harness/governance/human-in-the-loop/index.js +3 -3
- package/dist/harness/governance/human-in-the-loop/types.d.ts +7 -62
- package/dist/harness/governance/human-in-the-loop/types.js +6 -2
- package/dist/harness/governance/security/capability-enforcer.d.ts +9 -1
- package/dist/harness/governance/security/capability-enforcer.js +31 -8
- package/dist/harness/governance/security/degradation.js +5 -7
- package/dist/harness/governance/security/risk-evaluator.d.ts +1 -1
- package/dist/harness/governance/security/risk-evaluator.js +4 -82
- package/dist/harness/governance/security/temp-path.d.ts +41 -0
- package/dist/harness/governance/security/temp-path.js +117 -0
- package/dist/harness/governance/session-acl/index.d.ts +1 -0
- package/dist/harness/governance/session-acl/index.js +1 -0
- package/dist/harness/governance/session-acl/rights.d.ts +12 -0
- package/dist/harness/governance/session-acl/rights.js +89 -7
- package/dist/harness/governance/session-acl/seed-roles.js +9 -1
- package/dist/harness/governance/session-acl/service.js +21 -29
- package/dist/harness/governance/session-acl/tool-rights.d.ts +81 -0
- package/dist/harness/governance/session-acl/tool-rights.js +238 -0
- package/dist/harness/governance/session-acl/types.d.ts +22 -0
- package/dist/harness/index.d.ts +18 -15
- package/dist/harness/index.js +11 -7
- package/dist/harness/knowledge/file-index-store.js +11 -11
- package/dist/harness/knowledge/grounding.d.ts +2 -1
- package/dist/harness/knowledge/grounding.js +6 -3
- package/dist/harness/knowledge/index.d.ts +2 -2
- package/dist/harness/knowledge/index.js +1 -1
- package/dist/harness/knowledge/ingest.js +4 -1
- package/dist/harness/knowledge/job-control-state.js +4 -4
- package/dist/harness/knowledge/job-control.js +11 -11
- package/dist/harness/knowledge/membership-store.js +11 -11
- package/dist/harness/knowledge/network-guard.d.ts +61 -4
- package/dist/harness/knowledge/network-guard.js +390 -113
- package/dist/harness/knowledge/query-service.js +8 -8
- package/dist/harness/knowledge/retriever.js +1 -1
- package/dist/harness/knowledge/source-store.d.ts +17 -2
- package/dist/harness/knowledge/source-store.js +6 -5
- package/dist/harness/knowledge/writer-service.d.ts +2 -0
- package/dist/harness/knowledge/writer-service.js +14 -13
- package/dist/harness/memory/backfill-trigger.d.ts +2 -2
- package/dist/harness/memory/backfill-trigger.js +4 -4
- package/dist/harness/memory/cognition-decay.d.ts +36 -0
- package/dist/harness/memory/cognition-decay.js +55 -0
- package/dist/harness/memory/cognition-gates.d.ts +60 -0
- package/dist/harness/memory/cognition-gates.js +191 -0
- package/dist/harness/memory/cognition-trigger.d.ts +30 -0
- package/dist/harness/memory/cognition-trigger.js +41 -0
- package/dist/harness/memory/cognition-types.d.ts +1 -1
- package/dist/harness/memory/cognition.d.ts +40 -8
- package/dist/harness/memory/cognition.js +432 -79
- package/dist/harness/memory/conceptualizer.d.ts +66 -0
- package/dist/harness/memory/conceptualizer.js +246 -0
- package/dist/harness/memory/index.d.ts +17 -2
- package/dist/harness/memory/index.js +12 -1
- package/dist/harness/memory/sqlite/agent-db.d.ts +9 -0
- package/dist/harness/memory/sqlite/agent-db.js +120 -15
- package/dist/harness/memory/sqlite/cognition-store.d.ts +55 -16
- package/dist/harness/memory/sqlite/cognition-store.js +591 -144
- package/dist/harness/memory/sqlite/memory-store.d.ts +1 -0
- package/dist/harness/memory/sqlite/memory-store.js +14 -4
- package/dist/harness/memory/sqlite/wisdom-store.d.ts +33 -14
- package/dist/harness/memory/sqlite/wisdom-store.js +257 -44
- package/dist/harness/memory/store.d.ts +1 -0
- package/dist/harness/memory/store.js +3 -0
- package/dist/harness/memory/time-format.d.ts +28 -0
- package/dist/harness/memory/time-format.js +52 -0
- package/dist/harness/memory/types.d.ts +343 -16
- package/dist/harness/memory/types.js +49 -0
- package/dist/harness/memory/wisdom-formation.d.ts +101 -0
- package/dist/harness/memory/wisdom-formation.js +304 -0
- package/dist/harness/memory/wisdom-gates.d.ts +50 -0
- package/dist/harness/memory/wisdom-gates.js +204 -0
- package/dist/harness/memory/wisdom-policy.d.ts +107 -0
- package/dist/harness/memory/wisdom-policy.js +220 -0
- package/dist/harness/memory/wisdom-types.d.ts +3 -2
- package/dist/harness/memory/wisdom-types.js +2 -2
- package/dist/harness/memory/wisdom.d.ts +27 -0
- package/dist/harness/memory/wisdom.js +181 -0
- package/dist/harness/observability/observer/hub.js +23 -1
- package/dist/harness/observability/observer/index.d.ts +2 -2
- package/dist/harness/observability/observer/index.js +1 -1
- package/dist/harness/observability/observer/types.d.ts +57 -0
- package/dist/harness/observability/observer/types.js +118 -9
- package/dist/harness/run/agent/agent.d.ts +27 -0
- package/dist/harness/run/agent/agent.js +45 -0
- package/dist/harness/run/concurrency/tool-loop-detection-core.d.ts +1 -1
- package/dist/harness/run/concurrency/tool-loop-detection-core.js +1 -1
- package/dist/harness/run/reliability/harness-events.d.ts +4 -0
- package/dist/harness/run/reliability/run-agent.js +116 -20
- package/dist/harness/run/reliability/run-metrics-collector.d.ts +28 -2
- package/dist/harness/run/reliability/run-metrics-collector.js +92 -2
- package/dist/harness/run/run-guard/default-run-guard.d.ts +0 -5
- package/dist/harness/run/run-guard/default-run-guard.js +104 -44
- package/dist/harness/run/run-scope.d.ts +52 -0
- package/dist/harness/run/runner.d.ts +101 -16
- package/dist/harness/run/runner.js +557 -158
- package/dist/harness/session/attachments/llm-intent.js +17 -17
- package/dist/harness/session/history/port.js +1 -0
- package/dist/harness/session/in-memory-store.d.ts +1 -0
- package/dist/harness/session/in-memory-store.js +22 -1
- package/dist/harness/session/index.d.ts +1 -0
- package/dist/harness/session/index.js +1 -0
- package/dist/harness/session/schedules/index.d.ts +10 -0
- package/dist/harness/session/schedules/index.js +10 -0
- package/dist/harness/session/schedules/render.d.ts +13 -0
- package/dist/harness/session/schedules/render.js +63 -0
- package/dist/harness/session/schedules/service.d.ts +179 -0
- package/dist/harness/session/schedules/service.js +695 -0
- package/dist/harness/session/schedules/store.d.ts +119 -0
- package/dist/harness/session/schedules/store.js +323 -0
- package/dist/harness/session/schedules/tools.d.ts +39 -0
- package/dist/harness/session/schedules/tools.js +442 -0
- package/dist/harness/session/schedules/types.d.ts +104 -0
- package/dist/harness/session/schedules/types.js +97 -0
- package/dist/harness/session/tasks/tools.js +22 -0
- package/dist/harness/session/title.d.ts +86 -0
- package/dist/harness/session/title.js +268 -0
- package/dist/harness/session/types.d.ts +35 -0
- package/dist/harness/shared/events/agent-event-map.d.ts +21 -0
- package/dist/harness/shared/events/agent-event-map.js +1 -0
- package/dist/harness/shared/types/agent-definition.d.ts +23 -0
- package/dist/index.d.ts +25 -9
- package/dist/index.js +11 -2
- package/dist/integration/providers/anthropic.d.ts +10 -0
- package/dist/integration/providers/anthropic.js +44 -1
- package/dist/integration/providers/openai.d.ts +10 -0
- package/dist/integration/providers/openai.js +58 -2
- package/dist/integration/providers/wire-dump-diff.d.ts +191 -0
- package/dist/integration/providers/wire-dump-diff.js +351 -0
- package/dist/integration/providers/wire-dump.d.ts +178 -0
- package/dist/integration/providers/wire-dump.js +396 -0
- package/dist/integration/storage/jsonl.d.ts +11 -0
- package/dist/integration/storage/jsonl.js +148 -39
- package/dist/integration/storage/session-index.js +63 -8
- package/dist/subsystems/cognition-steward/conceptualize/SUBSYSTEM.md +43 -0
- package/dist/subsystems/cognition-steward/conceptualize/config.yaml +50 -0
- package/dist/subsystems/cognition-steward/conceptualize/handler.d.ts +9 -0
- package/dist/subsystems/cognition-steward/conceptualize/handler.js +125 -0
- package/dist/subsystems/cognition-steward/consolidate/SUBSYSTEM.md +6 -0
- package/dist/subsystems/cognition-steward/consolidate/config.yaml +54 -0
- package/dist/subsystems/cognition-steward/consolidate/handler.d.ts +12 -0
- package/dist/subsystems/cognition-steward/consolidate/handler.js +93 -0
- package/dist/subsystems/memory-steward/backfill/handler.js +9 -0
- package/dist/subsystems/wisdom-steward/evaluate/config.yaml +50 -0
- package/dist/subsystems/wisdom-steward/evaluate/handler.d.ts +18 -0
- package/dist/subsystems/wisdom-steward/evaluate/handler.js +91 -0
- package/dist/subsystems/wisdom-steward/formation/SUBSYSTEM.md +42 -0
- package/dist/subsystems/wisdom-steward/formation/config.yaml +54 -0
- package/dist/subsystems/wisdom-steward/formation/handler.d.ts +18 -0
- package/dist/subsystems/wisdom-steward/formation/handler.js +212 -0
- package/dist/subsystems/wisdom-steward/govern/config.yaml +55 -0
- package/dist/subsystems/wisdom-steward/govern/handler.d.ts +17 -0
- package/dist/subsystems/wisdom-steward/govern/handler.js +68 -0
- package/package.json +115 -115
- package/dist/harness/collaboration/multi-agent/agent-registry-types.d.ts +0 -144
- package/dist/harness/collaboration/multi-agent/agent-registry-types.js +0 -25
- package/dist/harness/collaboration/multi-agent/index.d.ts +0 -17
- package/dist/harness/collaboration/multi-agent/index.js +0 -15
- package/dist/harness/collaboration/multi-agent/process.d.ts +0 -167
- package/dist/harness/collaboration/multi-agent/process.js +0 -256
- package/dist/harness/collaboration/multi-agent/registry.d.ts +0 -36
- package/dist/harness/collaboration/multi-agent/registry.js +0 -137
- package/dist/harness/collaboration/multi-agent/swarm.d.ts +0 -135
- package/dist/harness/collaboration/multi-agent/swarm.js +0 -317
- package/dist/harness/collaboration/multi-agent/types.d.ts +0 -66
- package/dist/harness/collaboration/multi-agent/types.js +0 -15
- package/dist/harness/collaboration/orchestration/async-task-store.d.ts +0 -107
- package/dist/harness/collaboration/orchestration/async-task-store.js +0 -12
- package/dist/harness/collaboration/orchestration/async-task.d.ts +0 -156
- package/dist/harness/collaboration/orchestration/async-task.js +0 -359
- package/dist/harness/collaboration/orchestration/planner/hybrid-planner.d.ts +0 -47
- package/dist/harness/collaboration/orchestration/planner/hybrid-planner.js +0 -61
- package/dist/harness/collaboration/orchestration/planner/index.d.ts +0 -9
- package/dist/harness/collaboration/orchestration/planner/index.js +0 -6
- package/dist/harness/collaboration/orchestration/planner/llm-planner.d.ts +0 -54
- package/dist/harness/collaboration/orchestration/planner/llm-planner.js +0 -167
- package/dist/harness/collaboration/orchestration/planner/rule-planner.d.ts +0 -85
- package/dist/harness/collaboration/orchestration/planner/rule-planner.js +0 -175
- package/dist/harness/collaboration/orchestration/quality/classifier.d.ts +0 -21
- package/dist/harness/collaboration/orchestration/quality/classifier.js +0 -235
- package/dist/harness/collaboration/orchestration/quality/gate.d.ts +0 -29
- package/dist/harness/collaboration/orchestration/quality/gate.js +0 -409
- package/dist/harness/collaboration/orchestration/quality/index.d.ts +0 -9
- package/dist/harness/collaboration/orchestration/quality/index.js +0 -8
- package/dist/harness/collaboration/orchestration/quality/types.d.ts +0 -159
- package/dist/harness/collaboration/orchestration/quality/types.js +0 -33
- package/dist/harness/collaboration/orchestration/scheduler/index.d.ts +0 -5
- package/dist/harness/collaboration/orchestration/scheduler/index.js +0 -4
- package/dist/harness/collaboration/orchestration/scheduler/task-scheduler.d.ts +0 -143
- package/dist/harness/collaboration/orchestration/scheduler/task-scheduler.js +0 -297
- package/dist/harness/collaboration/orchestration/strategy/classifier.d.ts +0 -12
- package/dist/harness/collaboration/orchestration/strategy/classifier.js +0 -81
- package/dist/harness/collaboration/orchestration/strategy/index.d.ts +0 -3
- package/dist/harness/collaboration/orchestration/strategy/index.js +0 -2
- package/dist/harness/collaboration/orchestration/strategy/router.d.ts +0 -28
- package/dist/harness/collaboration/orchestration/strategy/router.js +0 -105
- package/dist/harness/collaboration/orchestration/strategy/types.d.ts +0 -49
- package/dist/harness/collaboration/orchestration/strategy/types.js +0 -4
- package/dist/harness/collaboration/orchestration/workflow/engine.d.ts +0 -86
- package/dist/harness/collaboration/orchestration/workflow/engine.js +0 -298
- package/dist/harness/collaboration/orchestration/workflow/index.d.ts +0 -9
- package/dist/harness/collaboration/orchestration/workflow/index.js +0 -7
- package/dist/harness/collaboration/orchestration/workflow/types.d.ts +0 -143
- package/dist/harness/collaboration/orchestration/workflow/types.js +0 -7
- package/dist/harness/governance/human-in-the-loop/approval-manager.d.ts +0 -32
- package/dist/harness/governance/human-in-the-loop/approval-manager.js +0 -93
- /package/dist/harness/collaboration/{multi-agent → delegation}/message-channel-types.d.ts +0 -0
- /package/dist/harness/collaboration/{multi-agent → delegation}/message-channel-types.js +0 -0
|
@@ -13,16 +13,13 @@
|
|
|
13
13
|
* // agents.get('assistant') → { engine, runner }
|
|
14
14
|
* ```
|
|
15
15
|
*/
|
|
16
|
-
import { createProviderFromConfig, resolveModelConfig } from '../../config.js';
|
|
16
|
+
import { createProviderFromConfig, createWireDumpSinkFromConfig, resolveModelConfig } from '../../config.js';
|
|
17
17
|
import { SubsystemLoader } from '../collaboration/autonomous-subsystem/loader.js';
|
|
18
18
|
import { homedir } from 'node:os';
|
|
19
19
|
import { resolve, join } from 'node:path';
|
|
20
|
-
import { existsSync } from 'node:fs';
|
|
21
20
|
import { AgentBuilder } from './builder.js';
|
|
22
|
-
import {
|
|
23
|
-
import {
|
|
24
|
-
import { DefaultBudgetAllocator } from '../context/budget-allocator.js';
|
|
25
|
-
import { createProviderSummarize, pickSummarizeProvider } from '../context/summarize.js';
|
|
21
|
+
import { resolveSecurityConfig, shouldAutoLoadSubsystems, wireAgentBuilder, } from './wire-agent-builder.js';
|
|
22
|
+
import { wireDelegation } from '../collaboration/delegation/wiring.js';
|
|
26
23
|
// ── Provider 解析 ──
|
|
27
24
|
/**
|
|
28
25
|
* 从配置中创建所有 Provider 实例
|
|
@@ -31,9 +28,11 @@ import { createProviderSummarize, pickSummarizeProvider } from '../context/summa
|
|
|
31
28
|
*/
|
|
32
29
|
export async function resolveProviders(config) {
|
|
33
30
|
const providers = new Map();
|
|
31
|
+
// wire dump 是纯观测:未启用时 undefined,启用后 sink 在该层共享(单一写队列 + 单一环形计数)
|
|
32
|
+
const wireDump = await createWireDumpSinkFromConfig(config.observability?.llmRequestDump);
|
|
34
33
|
for (const [name, pc] of Object.entries(config.models?.providers ?? {})) {
|
|
35
34
|
try {
|
|
36
|
-
const provider = await createProviderFromConfig(name, pc);
|
|
35
|
+
const provider = await createProviderFromConfig(name, pc, { wireDump });
|
|
37
36
|
providers.set(name, provider);
|
|
38
37
|
}
|
|
39
38
|
catch (err) {
|
|
@@ -43,84 +42,6 @@ export async function resolveProviders(config) {
|
|
|
43
42
|
return providers;
|
|
44
43
|
}
|
|
45
44
|
// ── 安全配置解析 ──
|
|
46
|
-
/**
|
|
47
|
-
* 从配置中解析安全策略(始终返回;无总开关)
|
|
48
|
-
*
|
|
49
|
-
* 硬边界与 ToolCallRiskPolicy 由 Guard/Builder 保证接线,
|
|
50
|
-
* 这里只归一化处置、范围与灵敏度。
|
|
51
|
-
*/
|
|
52
|
-
export function resolveSecurityConfig(config) {
|
|
53
|
-
const security = config.security ?? {};
|
|
54
|
-
return {
|
|
55
|
-
enforce: security.enforce ?? 'block',
|
|
56
|
-
injectionSensitivity: security.injectionSensitivity ?? 'medium',
|
|
57
|
-
allowedPaths: security.allowedPaths ?? [],
|
|
58
|
-
};
|
|
59
|
-
}
|
|
60
|
-
// ── 上下文引擎解析 ──
|
|
61
|
-
/**
|
|
62
|
-
* 从配置中创建 ContextEngine 实例
|
|
63
|
-
*/
|
|
64
|
-
export function resolveContextEngine(config) {
|
|
65
|
-
if (!config || config.type === 'default') {
|
|
66
|
-
// 默认配置
|
|
67
|
-
return new DefaultContextEngine({
|
|
68
|
-
protectFirstN: config?.protectFirstN ?? 3,
|
|
69
|
-
protectLastN: config?.protectLastN ?? 20,
|
|
70
|
-
compactThreshold: config?.compactThreshold ?? 0.5,
|
|
71
|
-
proactiveCompactRatio: config?.proactiveCompactRatio ?? 0.6,
|
|
72
|
-
proactiveCooldownMs: config?.proactiveCooldownMs ?? 30_000,
|
|
73
|
-
budgetAllocator: new DefaultBudgetAllocator({
|
|
74
|
-
outputRatio: config?.outputRatio ?? 0.20,
|
|
75
|
-
minOutputReserve: config?.minOutputReserve ?? 2000,
|
|
76
|
-
maxOutputReserve: config?.maxOutputReserve ?? 8000,
|
|
77
|
-
}),
|
|
78
|
-
});
|
|
79
|
-
}
|
|
80
|
-
// 自定义类型(未来扩展)
|
|
81
|
-
throw new Error(`Unknown context engine type: ${config.type}`);
|
|
82
|
-
}
|
|
83
|
-
// ── RunGuard 解析 ──
|
|
84
|
-
/**
|
|
85
|
-
* 从配置中解析 RunGuard
|
|
86
|
-
*
|
|
87
|
-
* 解析 llmModel 字段:
|
|
88
|
-
* - "model" → 使用主 provider
|
|
89
|
-
* - "provider/model" → 使用指定 provider
|
|
90
|
-
*/
|
|
91
|
-
export function resolveRunGuard(config, providers) {
|
|
92
|
-
if (!config || config.enabled === false)
|
|
93
|
-
return undefined;
|
|
94
|
-
// 解析审查用模型
|
|
95
|
-
let reviewModel;
|
|
96
|
-
if (config.llmModel) {
|
|
97
|
-
const parts = config.llmModel.split('/');
|
|
98
|
-
if (parts.length === 2) {
|
|
99
|
-
// 格式: "provider/model"
|
|
100
|
-
const providerName = parts[0];
|
|
101
|
-
reviewModel = providers.get(providerName);
|
|
102
|
-
// 将 llmModel 改为只保留 model 部分
|
|
103
|
-
config = { ...config, llmModel: parts[1] };
|
|
104
|
-
}
|
|
105
|
-
else {
|
|
106
|
-
// 格式: "model" → 使用第一个 provider
|
|
107
|
-
reviewModel = providers.values().next().value;
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
// 构建 RunGuardConfig
|
|
111
|
-
const runGuardConfig = {
|
|
112
|
-
enabled: true,
|
|
113
|
-
checkpointInterval: config.checkpointInterval,
|
|
114
|
-
minCheckpointInterval: config.minCheckpointInterval,
|
|
115
|
-
maxCheckpointInterval: config.maxCheckpointInterval,
|
|
116
|
-
enableLLMReview: config.enableLLMReview,
|
|
117
|
-
llmReviewInterval: config.llmReviewInterval,
|
|
118
|
-
llmModel: config.llmModel,
|
|
119
|
-
hardLimit: config.hardLimit,
|
|
120
|
-
hardWallClockMs: config.hardWallClockMs,
|
|
121
|
-
};
|
|
122
|
-
return new DefaultRunGuard(runGuardConfig, reviewModel);
|
|
123
|
-
}
|
|
124
45
|
// ── 子系统加载 ──
|
|
125
46
|
/**
|
|
126
47
|
* 按架构文档 4.9 的三级搜索路径加载子系统
|
|
@@ -171,7 +92,7 @@ export async function resolveSubsystemSpecs(projectRoot) {
|
|
|
171
92
|
* @param config - 完整配置
|
|
172
93
|
* @returns agent id → BuiltAgent 的映射
|
|
173
94
|
*/
|
|
174
|
-
export async function buildFromConfig(config) {
|
|
95
|
+
export async function buildFromConfig(config, options) {
|
|
175
96
|
const flatModels = config.flatModels ?? [];
|
|
176
97
|
// 1. 解析共享资源
|
|
177
98
|
const providers = await resolveProviders(config);
|
|
@@ -196,6 +117,8 @@ export async function buildFromConfig(config) {
|
|
|
196
117
|
contextAssemblerConfig,
|
|
197
118
|
constitutionConfig,
|
|
198
119
|
memoryConfig: config.memory,
|
|
120
|
+
cognitionConfig: config.cognition,
|
|
121
|
+
wisdomConfig: config.wisdom,
|
|
199
122
|
flatModels,
|
|
200
123
|
levelMap: config.levelMap,
|
|
201
124
|
modelsConfig: config.models,
|
|
@@ -204,6 +127,9 @@ export async function buildFromConfig(config) {
|
|
|
204
127
|
subsystemAllowlist: config.subsystems?.allowlist,
|
|
205
128
|
subsystemDenylist: config.subsystems?.denylist,
|
|
206
129
|
toolIsolation: config.toolIsolation,
|
|
130
|
+
sessionIdleExpiryMs: config.session?.idleExpiryMs,
|
|
131
|
+
modelCallConfig: config.modelCall,
|
|
132
|
+
concurrencyConfig: config.concurrency,
|
|
207
133
|
});
|
|
208
134
|
agents.set(agentConfig.id, built);
|
|
209
135
|
}
|
|
@@ -212,6 +138,31 @@ export async function buildFromConfig(config) {
|
|
|
212
138
|
throw err;
|
|
213
139
|
}
|
|
214
140
|
}
|
|
141
|
+
// 4. 委派编排(arch/delegation.md §7/§14)
|
|
142
|
+
// 只有存在 agent 声明 delegation 策略时才接线;接线失败不阻断 agent 构建。
|
|
143
|
+
if (options?.delegation !== false) {
|
|
144
|
+
try {
|
|
145
|
+
wireDelegation(config.agents.map((agentConfig) => {
|
|
146
|
+
const built = agents.get(agentConfig.id);
|
|
147
|
+
return {
|
|
148
|
+
agentId: agentConfig.id,
|
|
149
|
+
agent: built.agent,
|
|
150
|
+
runner: built.runner,
|
|
151
|
+
store: built.store,
|
|
152
|
+
traits: agentConfig.traits,
|
|
153
|
+
delegation: agentConfig.delegation,
|
|
154
|
+
persona: typeof agentConfig.persona === 'string' ? agentConfig.persona : undefined,
|
|
155
|
+
registerTools: built.registerTools,
|
|
156
|
+
};
|
|
157
|
+
}), {
|
|
158
|
+
events: options?.events,
|
|
159
|
+
maxActiveDelegationsPerSession: config.delegation?.maxActiveDelegationsPerSession,
|
|
160
|
+
});
|
|
161
|
+
}
|
|
162
|
+
catch (err) {
|
|
163
|
+
console.warn('[ConfigBridge] delegation wiring skipped:', err);
|
|
164
|
+
}
|
|
165
|
+
}
|
|
215
166
|
return agents;
|
|
216
167
|
}
|
|
217
168
|
/**
|
|
@@ -219,209 +170,61 @@ export async function buildFromConfig(config) {
|
|
|
219
170
|
*/
|
|
220
171
|
async function buildAgent(agentConfig, shared) {
|
|
221
172
|
const builder = new AgentBuilder();
|
|
222
|
-
//
|
|
173
|
+
// 解析主模型 provider(宿主可在此包装 circuit breaker;config-bridge 用原始 provider)
|
|
223
174
|
const resolvedModel = resolveModelConfig(agentConfig.model, shared.flatModels);
|
|
224
175
|
const provider = shared.providers.get(resolvedModel.provider);
|
|
225
176
|
if (!provider) {
|
|
226
177
|
throw new Error(`Agent "${agentConfig.id}" references unknown provider "${resolvedModel.provider}". ` +
|
|
227
178
|
`Available: ${Array.from(shared.providers.keys()).join(', ') || '(none)'}`);
|
|
228
179
|
}
|
|
229
|
-
builder
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
}
|
|
262
|
-
else if (agentHome) {
|
|
263
|
-
// 没有显式 persona,从 home 目录加载
|
|
264
|
-
builder.persona(agentHome);
|
|
265
|
-
}
|
|
266
|
-
// ── Skills ──
|
|
267
|
-
const skillDir = agentConfig.skillDirectory ??
|
|
268
|
-
(agentHome ? join(agentHome, 'skills') : undefined);
|
|
269
|
-
if (skillDir && existsSync(skillDir)) {
|
|
270
|
-
builder.skillDirectory(skillDir);
|
|
271
|
-
}
|
|
272
|
-
// ── Memory / Wisdom / Cognition / Knowledge(system prompt 层) ──
|
|
273
|
-
// 优先挂 agent home 下的 AgentDatabase;失败则跳过(不阻断 build)
|
|
274
|
-
if (agentHome) {
|
|
275
|
-
try {
|
|
276
|
-
const { AgentDatabase } = await import('../memory/sqlite/agent-db.js');
|
|
277
|
-
const { SqliteMemoryStore } = await import('../memory/sqlite/memory-store.js');
|
|
278
|
-
const { SqliteWisdomStore } = await import('../memory/sqlite/wisdom-store.js');
|
|
279
|
-
const { SqliteConceptGraph } = await import('../memory/sqlite/cognition-store.js');
|
|
280
|
-
const { resolveEmbeddingRuntime } = await import('../memory/sqlite/embedding-from-models.js');
|
|
281
|
-
const embRuntime = resolveEmbeddingRuntime(shared.modelsConfig);
|
|
282
|
-
const useVec = embRuntime && embRuntime.vectorEngine !== 'js';
|
|
283
|
-
const db = await AgentDatabase.create({
|
|
284
|
-
dbPath: join(agentHome, 'agent.db'),
|
|
285
|
-
sqliteVec: useVec
|
|
286
|
-
? { extensionPath: embRuntime?.sqliteVecExtensionPath }
|
|
287
|
-
: false,
|
|
288
|
-
vectorDimensions: useVec ? embRuntime?.dimensions : undefined,
|
|
289
|
-
});
|
|
290
|
-
builder.memoryStore(new SqliteMemoryStore(db, {
|
|
291
|
-
embeddingProvider: embRuntime?.provider ?? null,
|
|
292
|
-
vectorEngine: embRuntime?.vectorEngine ?? 'auto',
|
|
293
|
-
minSimilarity: shared.memoryConfig?.retrieval?.minSimilarity,
|
|
294
|
-
similarityWeight: shared.memoryConfig?.retrieval?.similarityWeight,
|
|
295
|
-
minKeywordScore: shared.memoryConfig?.retrieval?.minKeywordScore,
|
|
296
|
-
}));
|
|
297
|
-
builder.wisdomStore(new SqliteWisdomStore(db));
|
|
298
|
-
builder.cognitionStore(new SqliteConceptGraph(db, {
|
|
299
|
-
embeddingProvider: embRuntime?.provider ?? null,
|
|
300
|
-
}));
|
|
301
|
-
// Knowledge catalog / 索引归独立 Knowledge 服务(arch/knowledge-layer.md);P1 前不挂
|
|
302
|
-
}
|
|
303
|
-
catch (err) {
|
|
304
|
-
const msg = err instanceof Error ? err.message : String(err);
|
|
305
|
-
console.warn(`[ConfigBridge] memory/wisdom/cognition stores unavailable for agent home ${agentHome}: ${msg}`);
|
|
306
|
-
if (/node:sqlite|ERR_UNKNOWN_BUILTIN_MODULE|ERR_DLOPEN|NODE_MODULE_VERSION/i.test(msg)) {
|
|
307
|
-
console.warn(`[ConfigBridge] hint: SQLite backend requires Node.js >= 24 with built-in node:sqlite (process.version=${process.version})`);
|
|
308
|
-
}
|
|
309
|
-
}
|
|
310
|
-
}
|
|
311
|
-
// ── Security(安全不可绕过:策略与 RiskPolicy 始终接线) ──
|
|
312
|
-
builder.securityPolicy(shared.securityConfig ?? {});
|
|
313
|
-
// 规则引擎:产生 tool_call.risk_unknown 后,由子系统目录加载的 safety-guard 兜底。
|
|
314
|
-
// 子系统自身参数(model/maxDurationMs 等)只写在其 config.yaml,不在本文件配置。
|
|
315
|
-
const { DefaultToolCallRiskPolicy } = await import('../governance/security/default-risk-policy.js');
|
|
316
|
-
builder.withRiskPolicy(new DefaultToolCallRiskPolicy({ cwd: agentConfig.workspace }));
|
|
317
|
-
// ── Budget + P2/P3 配置接线 ──
|
|
318
|
-
if (shared.budgetConfig) {
|
|
319
|
-
// 提取 BudgetPolicyEngine 配置(wall-clock / iteration / tool 上限)
|
|
320
|
-
const engineConfig = {
|
|
321
|
-
maxWallClockMs: shared.budgetConfig.maxWallClockMs,
|
|
322
|
-
maxIterations: shared.budgetConfig.maxIterations,
|
|
323
|
-
maxToolCalls: shared.budgetConfig.maxToolCalls,
|
|
324
|
-
};
|
|
325
|
-
builder.budget(engineConfig);
|
|
326
|
-
// P2: wrap-up 配置
|
|
327
|
-
const wrapUpConfig = {};
|
|
328
|
-
if (shared.budgetConfig.wrapUpTurns !== undefined) {
|
|
329
|
-
wrapUpConfig.turns = shared.budgetConfig.wrapUpTurns;
|
|
330
|
-
}
|
|
331
|
-
if (shared.budgetConfig.onPolicyHit !== undefined) {
|
|
332
|
-
wrapUpConfig.onPolicyHit = shared.budgetConfig.onPolicyHit;
|
|
333
|
-
}
|
|
334
|
-
if (shared.budgetConfig.contextWrapUpRatio !== undefined) {
|
|
335
|
-
wrapUpConfig.contextRatio = shared.budgetConfig.contextWrapUpRatio;
|
|
336
|
-
}
|
|
337
|
-
// P3: policy 单位配置
|
|
338
|
-
const policyUnits = shared.budgetConfig.units;
|
|
339
|
-
const policyPricing = shared.budgetConfig.pricing;
|
|
340
|
-
const advisory = shared.budgetConfig.advisory;
|
|
341
|
-
// 如果有 P2/P3 配置,注入到 reliability
|
|
342
|
-
if (Object.keys(wrapUpConfig).length > 0 || policyUnits || policyPricing || advisory) {
|
|
343
|
-
builder.reliability({
|
|
344
|
-
wrapUp: Object.keys(wrapUpConfig).length > 0 ? wrapUpConfig : undefined,
|
|
345
|
-
policyUnits: policyUnits ? {
|
|
346
|
-
maxCost: policyUnits.maxCost,
|
|
347
|
-
maxUncachedInputTokens: policyUnits.maxUncachedInputTokens,
|
|
348
|
-
maxOutputTokens: policyUnits.maxOutputTokens,
|
|
349
|
-
maxLlmCalls: policyUnits.maxLlmCalls,
|
|
350
|
-
} : undefined,
|
|
351
|
-
policyPricing,
|
|
352
|
-
advisory: advisory,
|
|
353
|
-
});
|
|
354
|
-
}
|
|
355
|
-
}
|
|
356
|
-
// ── Context Engine ──
|
|
357
|
-
const contextEngine = resolveContextEngine(shared.contextEngineConfig);
|
|
358
|
-
builder.contextEngine(contextEngine);
|
|
359
|
-
// ── Context Assembler(七层 system 装配) ──
|
|
360
|
-
if (shared.contextAssemblerConfig) {
|
|
361
|
-
builder.contextAssembler(shared.contextAssemblerConfig);
|
|
362
|
-
}
|
|
363
|
-
if (shared.constitutionConfig !== undefined) {
|
|
364
|
-
builder.constitution(shared.constitutionConfig);
|
|
365
|
-
}
|
|
366
|
-
if (shared.memoryConfig) {
|
|
367
|
-
builder.memoryConfig(shared.memoryConfig);
|
|
368
|
-
}
|
|
369
|
-
// ── 默认 summarize:capabilities 解析链(summary → mini → standard → 主模型)──
|
|
370
|
-
// 与 harness/context/capabilities/summary/resolver.ts 口径一致;legacy contextEngine.summaryModel 由 pick 之外路径覆盖时优先
|
|
371
|
-
if (provider) {
|
|
372
|
-
const { provider: summarizeProvider, model: summarizeModel } = pickSummarizeProvider(shared.providers, shared.levelMap, provider);
|
|
373
|
-
builder.summarize(createProviderSummarize(summarizeProvider, { model: summarizeModel }));
|
|
374
|
-
}
|
|
375
|
-
// ── RunGuard ──
|
|
376
|
-
if (shared.runGuardConfig?.enabled !== false) {
|
|
377
|
-
const guard = resolveRunGuard(shared.runGuardConfig, shared.providers);
|
|
378
|
-
if (guard) {
|
|
379
|
-
builder.runGuard(guard);
|
|
380
|
-
}
|
|
381
|
-
}
|
|
382
|
-
// checkpointInterval:从 runGuard JSON 配置打通到 reliability 初始间隔
|
|
383
|
-
if (shared.runGuardConfig?.checkpointInterval !== undefined) {
|
|
384
|
-
builder.reliability({
|
|
385
|
-
checkpointInterval: shared.runGuardConfig.checkpointInterval,
|
|
386
|
-
});
|
|
387
|
-
}
|
|
388
|
-
// ── Subsystems ──
|
|
389
|
-
// 注册范围由 allow/deny 列表控制;builder.build 统一装配,此处只透传显式 specs / audit。
|
|
390
|
-
if (shared.subsystemSpecs && shared.subsystemSpecs.length > 0) {
|
|
391
|
-
for (const spec of shared.subsystemSpecs) {
|
|
392
|
-
builder.withSubsystem(spec);
|
|
393
|
-
}
|
|
394
|
-
}
|
|
395
|
-
if (shared.subsystemAuditDir) {
|
|
396
|
-
builder.withSubsystemAuditDir(shared.subsystemAuditDir);
|
|
397
|
-
}
|
|
398
|
-
if (shared.subsystemAllowlist?.length) {
|
|
399
|
-
builder.subsystemAllowlist(...shared.subsystemAllowlist);
|
|
400
|
-
}
|
|
401
|
-
if (shared.subsystemDenylist?.length) {
|
|
402
|
-
builder.subsystemDenylist(...shared.subsystemDenylist);
|
|
403
|
-
}
|
|
180
|
+
await wireAgentBuilder(builder, {
|
|
181
|
+
model: provider,
|
|
182
|
+
agentId: agentConfig.id,
|
|
183
|
+
workspace: agentConfig.workspace,
|
|
184
|
+
// legacy:string persona 等价 home(config-bridge 显式决定,不进 wire 隐式规则)
|
|
185
|
+
home: agentConfig.home ??
|
|
186
|
+
(typeof agentConfig.persona === 'string' ? agentConfig.persona : undefined),
|
|
187
|
+
persona: agentConfig.persona,
|
|
188
|
+
skillDirectory: agentConfig.skillDirectory,
|
|
189
|
+
tools: agentConfig.tools,
|
|
190
|
+
maxSessionRights: agentConfig.maxSessionRights,
|
|
191
|
+
effectPolicy: agentConfig.effectPolicy ?? shared.effectPolicy,
|
|
192
|
+
toolIsolation: shared.toolIsolation,
|
|
193
|
+
sessionIdleExpiryMs: shared.sessionIdleExpiryMs,
|
|
194
|
+
modelCallTimeouts: shared.modelCallConfig,
|
|
195
|
+
providers: shared.providers,
|
|
196
|
+
levelMap: shared.levelMap,
|
|
197
|
+
modelsConfig: shared.modelsConfig,
|
|
198
|
+
contextEngineConfig: shared.contextEngineConfig,
|
|
199
|
+
contextAssemblerConfig: shared.contextAssemblerConfig,
|
|
200
|
+
constitutionConfig: shared.constitutionConfig,
|
|
201
|
+
memoryConfig: shared.memoryConfig,
|
|
202
|
+
cognitionConfig: shared.cognitionConfig,
|
|
203
|
+
wisdomConfig: shared.wisdomConfig,
|
|
204
|
+
securityConfig: shared.securityConfig,
|
|
205
|
+
budgetConfig: shared.budgetConfig,
|
|
206
|
+
runGuardConfig: shared.runGuardConfig,
|
|
207
|
+
subsystemSpecs: shared.subsystemSpecs,
|
|
208
|
+
subsystemAuditDir: shared.subsystemAuditDir,
|
|
209
|
+
subsystemAllowlist: shared.subsystemAllowlist,
|
|
210
|
+
subsystemDenylist: shared.subsystemDenylist,
|
|
211
|
+
concurrencyConfig: shared.concurrencyConfig,
|
|
212
|
+
});
|
|
404
213
|
// ── Build ──
|
|
405
|
-
// 已有显式 specs 时不再重复自动发现,避免与 resolveSubsystemSpecs 双载
|
|
406
214
|
const built = await builder.build({
|
|
407
|
-
autoLoadSubsystems: (shared
|
|
215
|
+
autoLoadSubsystems: shouldAutoLoadSubsystems(shared),
|
|
408
216
|
});
|
|
409
|
-
//
|
|
410
|
-
|
|
411
|
-
// 注入 modelProvider(取第一个可用的 provider)
|
|
412
|
-
const firstProvider = shared.providers.values().next().value;
|
|
413
|
-
if (firstProvider) {
|
|
414
|
-
built.runtime.registerDependency('modelProvider', firstProvider);
|
|
415
|
-
}
|
|
416
|
-
// memoryStore 已在 AgentBuilder.build 内注入;此处不重复 register
|
|
417
|
-
}
|
|
217
|
+
// 子系统运行时依赖(modelProvider / memoryStore / …)统一在 AgentBuilder.build 内注入;
|
|
218
|
+
// 此处不重复 register,避免两路径出现第二套接线清单。
|
|
418
219
|
const agent = built.agent;
|
|
419
220
|
const runner = built.runner;
|
|
420
|
-
return {
|
|
221
|
+
return {
|
|
222
|
+
agent,
|
|
223
|
+
runner,
|
|
224
|
+
agentConfig,
|
|
225
|
+
runtime: built.runtime,
|
|
226
|
+
events: built.events,
|
|
227
|
+
store: built.store,
|
|
228
|
+
registerTools: built.registerTools,
|
|
229
|
+
};
|
|
421
230
|
}
|
|
422
|
-
/**
|
|
423
|
-
* 快捷函数:从配置文件路径构建
|
|
424
|
-
*
|
|
425
|
-
* @remarks 文件 IO / `loadConfig` 属于套件侧(arch/npm-package-split.md §10.3)。
|
|
426
|
-
* 根包 `octopi` 提供 `buildFromConfigFile`;库嵌入请用 {@link buildFromConfig}。
|
|
427
|
-
*/
|
|
@@ -11,5 +11,7 @@ export { AgentBuilder, createAgent, isSubsystemAllowed, discoverSubsystemSpecs }
|
|
|
11
11
|
export type { AgentTraceOptions, CreateAgentConfig } from './builder.js';
|
|
12
12
|
export type { AgentBuildOptions, AgentBuildResult, AgentBuildCoreResult, } from './builder.js';
|
|
13
13
|
export { loadPersona, composePersonas, PersonaSource } from './persona.js';
|
|
14
|
-
export { buildFromConfig, resolveProviders
|
|
14
|
+
export { buildFromConfig, resolveProviders } from './config-bridge.js';
|
|
15
15
|
export type { BuiltAgent } from './config-bridge.js';
|
|
16
|
+
export { wireAgentBuilder, resolveSecurityConfig, resolveContextEngine, resolveRunGuard, } from './wire-agent-builder.js';
|
|
17
|
+
export type { AgentWireSpec } from './wire-agent-builder.js';
|
|
@@ -9,4 +9,5 @@
|
|
|
9
9
|
*/
|
|
10
10
|
export { AgentBuilder, createAgent, isSubsystemAllowed, discoverSubsystemSpecs } from './builder.js';
|
|
11
11
|
export { loadPersona, composePersonas, PersonaSource } from './persona.js';
|
|
12
|
-
export { buildFromConfig, resolveProviders
|
|
12
|
+
export { buildFromConfig, resolveProviders } from './config-bridge.js';
|
|
13
|
+
export { wireAgentBuilder, resolveSecurityConfig, resolveContextEngine, resolveRunGuard, } from './wire-agent-builder.js';
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Tool Call purpose — 统一 schema 装配(arch/tool-call-purpose.md)
|
|
3
|
+
*
|
|
4
|
+
* 注入点唯一:RegisteredTool → LLM/AgentTool parameters 必须经此模块,
|
|
5
|
+
* 禁止 builder / gateway / tool-bus 各自拼一套(否则模型看到的 required 不一致)。
|
|
6
|
+
*/
|
|
7
|
+
import type { ToolDefinition, ToolParameter } from '@octopi-agent/core/types.js';
|
|
8
|
+
/** 统一注入的行动简述参数 */
|
|
9
|
+
export declare const TOOL_PURPOSE_PARAM: {
|
|
10
|
+
type: "string";
|
|
11
|
+
description: string;
|
|
12
|
+
};
|
|
13
|
+
/** 仅保留 OpenAI function calling 可识别的 JSON Schema 关键字 */
|
|
14
|
+
export declare function sanitizeToolJsonSchema(node: unknown): unknown;
|
|
15
|
+
/**
|
|
16
|
+
* RegisteredTool 参数面 → LLM JSON Schema,并统一注入 purpose。
|
|
17
|
+
*
|
|
18
|
+
* - purpose 始终存在且 required 一次(工具自带 purpose 时同名同义覆盖,不得重复 required)
|
|
19
|
+
* - purpose 放在 properties 首位,降低模型漏填
|
|
20
|
+
* - 其余字段只保留 wire 关键字
|
|
21
|
+
*/
|
|
22
|
+
export declare function buildToolLlmParameters(parameters: Record<string, ToolParameter> | undefined): Record<string, unknown>;
|
|
23
|
+
/** 工具定义是否把 purpose 声明为业务入参(如 photo_capture 同意理由) */
|
|
24
|
+
export declare function toolDeclaresPurpose(definition: ToolDefinition): boolean;
|
|
25
|
+
/** 从 tool call args 读取 purpose(缺省/空串 → '') */
|
|
26
|
+
export declare function readToolCallPurpose(args: unknown): string;
|
|
27
|
+
/**
|
|
28
|
+
* 解析本次调用的 purpose。
|
|
29
|
+
*
|
|
30
|
+
* schema 已标 required,但部分模型仍会漏填。purpose 只作人读/审批标题,
|
|
31
|
+
* 漏填时从工具名 + 关键参数推导一条,保证调用可执行且 UI 仍有标题;
|
|
32
|
+
* 不因此中断业务(否则 web_search 等会整批 purpose_required)。
|
|
33
|
+
*/
|
|
34
|
+
export declare function resolveToolCallPurpose(toolName: string, args: unknown): string;
|
|
35
|
+
/**
|
|
36
|
+
* 进 handler 的 args:注入型 purpose 剥离;工具自带 purpose 保留(device 同意/审计需要)。
|
|
37
|
+
*/
|
|
38
|
+
export declare function prepareHandlerArgs(args: Record<string, unknown>, definition: ToolDefinition): Record<string, unknown>;
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
/** 统一注入的行动简述参数 */
|
|
2
|
+
export const TOOL_PURPOSE_PARAM = {
|
|
3
|
+
type: 'string',
|
|
4
|
+
description: 'One short honest line for humans and approvers: what this call does and why (verb + object + goal, max 120 chars). Example: "overwrite src/a.ts to fix timeout".',
|
|
5
|
+
};
|
|
6
|
+
/** 仅保留 OpenAI function calling 可识别的 JSON Schema 关键字 */
|
|
7
|
+
export function sanitizeToolJsonSchema(node) {
|
|
8
|
+
if (Array.isArray(node))
|
|
9
|
+
return node.map(sanitizeToolJsonSchema);
|
|
10
|
+
if (!node || typeof node !== 'object')
|
|
11
|
+
return node;
|
|
12
|
+
const src = node;
|
|
13
|
+
const out = {};
|
|
14
|
+
if (typeof src.type === 'string')
|
|
15
|
+
out.type = src.type;
|
|
16
|
+
if (typeof src.description === 'string')
|
|
17
|
+
out.description = src.description;
|
|
18
|
+
if (Array.isArray(src.enum))
|
|
19
|
+
out.enum = src.enum;
|
|
20
|
+
if (src.properties && typeof src.properties === 'object') {
|
|
21
|
+
const props = {};
|
|
22
|
+
for (const [k, v] of Object.entries(src.properties)) {
|
|
23
|
+
props[k] = sanitizeToolJsonSchema(v);
|
|
24
|
+
}
|
|
25
|
+
out.properties = props;
|
|
26
|
+
}
|
|
27
|
+
if (Array.isArray(src.required))
|
|
28
|
+
out.required = src.required.filter((x) => typeof x === 'string');
|
|
29
|
+
if (src.items !== undefined)
|
|
30
|
+
out.items = sanitizeToolJsonSchema(src.items);
|
|
31
|
+
return out;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* RegisteredTool 参数面 → LLM JSON Schema,并统一注入 purpose。
|
|
35
|
+
*
|
|
36
|
+
* - purpose 始终存在且 required 一次(工具自带 purpose 时同名同义覆盖,不得重复 required)
|
|
37
|
+
* - purpose 放在 properties 首位,降低模型漏填
|
|
38
|
+
* - 其余字段只保留 wire 关键字
|
|
39
|
+
*/
|
|
40
|
+
export function buildToolLlmParameters(parameters) {
|
|
41
|
+
const own = parameters ?? {};
|
|
42
|
+
// purpose 置首:部分模型只扫 schema 开头的必填项
|
|
43
|
+
const props = {
|
|
44
|
+
purpose: { ...TOOL_PURPOSE_PARAM },
|
|
45
|
+
};
|
|
46
|
+
for (const [key, param] of Object.entries(own)) {
|
|
47
|
+
if (key === 'purpose')
|
|
48
|
+
continue;
|
|
49
|
+
props[key] = {
|
|
50
|
+
type: param.type,
|
|
51
|
+
description: param.description,
|
|
52
|
+
...(param.enum && { enum: param.enum }),
|
|
53
|
+
...(param.properties && { properties: param.properties }),
|
|
54
|
+
...(param.items && { items: param.items }),
|
|
55
|
+
...(param.required && { required: param.required }),
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
const required = ['purpose'];
|
|
59
|
+
for (const [key, param] of Object.entries(own)) {
|
|
60
|
+
if (key === 'purpose')
|
|
61
|
+
continue;
|
|
62
|
+
if (param.required && !required.includes(key))
|
|
63
|
+
required.push(key);
|
|
64
|
+
}
|
|
65
|
+
return sanitizeToolJsonSchema({
|
|
66
|
+
type: 'object',
|
|
67
|
+
properties: props,
|
|
68
|
+
required,
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
/** 工具定义是否把 purpose 声明为业务入参(如 photo_capture 同意理由) */
|
|
72
|
+
export function toolDeclaresPurpose(definition) {
|
|
73
|
+
return Object.prototype.hasOwnProperty.call(definition.parameters ?? {}, 'purpose');
|
|
74
|
+
}
|
|
75
|
+
/** 从 tool call args 读取 purpose(缺省/空串 → '') */
|
|
76
|
+
export function readToolCallPurpose(args) {
|
|
77
|
+
if (!args || typeof args !== 'object')
|
|
78
|
+
return '';
|
|
79
|
+
const purpose = args.purpose;
|
|
80
|
+
return typeof purpose === 'string' ? purpose.trim() : '';
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* 解析本次调用的 purpose。
|
|
84
|
+
*
|
|
85
|
+
* schema 已标 required,但部分模型仍会漏填。purpose 只作人读/审批标题,
|
|
86
|
+
* 漏填时从工具名 + 关键参数推导一条,保证调用可执行且 UI 仍有标题;
|
|
87
|
+
* 不因此中断业务(否则 web_search 等会整批 purpose_required)。
|
|
88
|
+
*/
|
|
89
|
+
export function resolveToolCallPurpose(toolName, args) {
|
|
90
|
+
const explicit = readToolCallPurpose(args);
|
|
91
|
+
if (explicit)
|
|
92
|
+
return explicit;
|
|
93
|
+
return deriveFallbackPurpose(toolName, args);
|
|
94
|
+
}
|
|
95
|
+
function deriveFallbackPurpose(toolName, args) {
|
|
96
|
+
if (!args || typeof args !== 'object')
|
|
97
|
+
return `call ${toolName}`;
|
|
98
|
+
const record = args;
|
|
99
|
+
const hints = [];
|
|
100
|
+
for (const key of ['query', 'path', 'command', 'url', 'question', 'description', 'text', 'content', 'goal_id', 'task_id', 'session_id', 'chunk_id']) {
|
|
101
|
+
const v = record[key];
|
|
102
|
+
if (typeof v === 'string' && v.trim()) {
|
|
103
|
+
hints.push(v.trim().replace(/\s+/g, ' ').slice(0, 80));
|
|
104
|
+
break;
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
return hints.length > 0 ? `${toolName}: ${hints[0]}` : `call ${toolName}`;
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* 进 handler 的 args:注入型 purpose 剥离;工具自带 purpose 保留(device 同意/审计需要)。
|
|
111
|
+
*/
|
|
112
|
+
export function prepareHandlerArgs(args, definition) {
|
|
113
|
+
if (toolDeclaresPurpose(definition))
|
|
114
|
+
return { ...args };
|
|
115
|
+
const handlerArgs = { ...args };
|
|
116
|
+
delete handlerArgs.purpose;
|
|
117
|
+
return handlerArgs;
|
|
118
|
+
}
|