@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
|
@@ -14,12 +14,17 @@
|
|
|
14
14
|
* ```
|
|
15
15
|
*/
|
|
16
16
|
import { DefaultToolBus } from '../extension/plugin-ecosystem/tools/tool-bus.js';
|
|
17
|
+
import { createUnconfiguredFileEffects, createUnconfiguredMemoryEffects, } from '../extension/execution-environment/undo-log.js';
|
|
18
|
+
import { JournaledMemoryStore } from '../extension/execution-environment/memory-undo.js';
|
|
19
|
+
import { buildToolLlmParameters, prepareHandlerArgs, resolveToolCallPurpose, sanitizeToolJsonSchema, } from './tool-purpose.js';
|
|
17
20
|
import { Agent } from '../run/agent/index.js';
|
|
18
21
|
import { DEFAULT_RELIABILITY_CONFIG } from '../run/reliability/run-agent.js';
|
|
19
22
|
import { DefaultRunGuard } from '../run/run-guard/default-run-guard.js';
|
|
20
23
|
import { summarizeLlmMessages } from '../observability/observer/types.js';
|
|
21
24
|
import { SessionTaskService } from '../session/tasks/service.js';
|
|
22
25
|
import { createSessionTaskTools } from '../session/tasks/tools.js';
|
|
26
|
+
import { SessionScheduleService } from '../session/schedules/service.js';
|
|
27
|
+
import { createSessionScheduleTools } from '../session/schedules/tools.js';
|
|
23
28
|
import { InMemorySessionStore } from '../session/in-memory-store.js';
|
|
24
29
|
import { DefaultEventBus, } from '@octopi-agent/core/primitives/event-bus.js';
|
|
25
30
|
import { DefaultSecurityGuard, } from '../governance/security/default-security-guard.js';
|
|
@@ -93,52 +98,95 @@ class RuntimeToolContextProvider {
|
|
|
93
98
|
get() {
|
|
94
99
|
// I1:优先 RunScope ALS(并发 session 下不可依赖单槽 setRuntime)
|
|
95
100
|
const scope = getRunScope();
|
|
101
|
+
const unconfigured = createUnconfiguredFileEffects();
|
|
102
|
+
const unconfiguredMemory = createUnconfiguredMemoryEffects();
|
|
96
103
|
if (scope?.toolRuntime) {
|
|
97
104
|
return {
|
|
98
105
|
sessionId: scope.toolRuntime.sessionId,
|
|
99
106
|
agentId: scope.toolRuntime.agentId,
|
|
107
|
+
runId: scope.runId,
|
|
100
108
|
messages: scope.toolRuntime.messages,
|
|
101
109
|
cwd: scope.toolRuntime.cwd ?? this.cwd,
|
|
102
110
|
attachmentRoots: scope.toolRuntime.attachmentRoots,
|
|
111
|
+
fileEffects: scope.toolRuntime.fileEffects ?? unconfigured,
|
|
112
|
+
memoryEffects: scope.toolRuntime.memoryEffects ?? unconfiguredMemory,
|
|
113
|
+
pathRoots: scope.toolRuntime.pathRoots,
|
|
114
|
+
undoRoots: scope.toolRuntime.undoRoots,
|
|
115
|
+
networkPolicy: scope.toolRuntime.networkPolicy,
|
|
116
|
+
requireCredentialBindings: scope.toolRuntime.requireCredentialBindings,
|
|
117
|
+
requireJail: scope.toolRuntime.requireJail,
|
|
118
|
+
homeWrite: scope.toolRuntime.homeWrite,
|
|
119
|
+
noteSecurityDegraded: scope.toolRuntime.noteSecurityDegraded,
|
|
120
|
+
pathContainment: scope.toolRuntime.pathContainment,
|
|
121
|
+
confirmEffect: scope.toolRuntime.confirmEffect,
|
|
122
|
+
effectChannel: scope.toolRuntime.effectChannel,
|
|
123
|
+
processLimits: scope.toolRuntime.processLimits,
|
|
124
|
+
shellEscape: scope.toolRuntime.shellEscape,
|
|
125
|
+
shellJournal: scope.toolRuntime.shellJournal,
|
|
126
|
+
shellJournalLimit: scope.toolRuntime.shellJournalLimit,
|
|
103
127
|
};
|
|
104
128
|
}
|
|
105
129
|
if (scope) {
|
|
106
130
|
return {
|
|
107
131
|
sessionId: scope.sessionId,
|
|
108
132
|
agentId: scope.agentId,
|
|
133
|
+
runId: scope.runId,
|
|
109
134
|
messages: this.messages,
|
|
110
135
|
cwd: this.cwd,
|
|
136
|
+
fileEffects: unconfigured,
|
|
137
|
+
memoryEffects: unconfiguredMemory,
|
|
111
138
|
};
|
|
112
139
|
}
|
|
113
|
-
return {
|
|
140
|
+
return {
|
|
141
|
+
sessionId: this.sessionId,
|
|
142
|
+
agentId: this.agentId,
|
|
143
|
+
messages: this.messages,
|
|
144
|
+
cwd: this.cwd,
|
|
145
|
+
fileEffects: unconfigured,
|
|
146
|
+
memoryEffects: unconfiguredMemory,
|
|
147
|
+
};
|
|
114
148
|
}
|
|
115
149
|
}
|
|
150
|
+
/**
|
|
151
|
+
* 发给 LLM 的 JSON Schema 净化 + purpose 统一装配见 tool-purpose.ts(arch/tool-call-purpose.md)。
|
|
152
|
+
* 此处仅保留兼容别名。
|
|
153
|
+
*/
|
|
154
|
+
const sanitizeLlmJsonSchema = sanitizeToolJsonSchema;
|
|
116
155
|
/**
|
|
117
156
|
* 将 RegisteredTool 转换为 AgentTool(新循环格式)
|
|
157
|
+
*
|
|
158
|
+
* purpose schema 必须经 buildToolLlmParameters 统一装配,
|
|
159
|
+
* 与 gateway 热更新路径(registeredToolToAgentTool)同构。
|
|
118
160
|
*/
|
|
119
161
|
function convertToAgentTool(tool, contextProvider) {
|
|
120
162
|
return {
|
|
121
163
|
name: tool.definition.name,
|
|
122
164
|
description: tool.definition.description,
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
properties: Object.fromEntries(Object.entries(tool.definition.parameters).map(([key, param]) => [
|
|
126
|
-
key,
|
|
127
|
-
{ type: param.type, description: param.description, ...(param.enum && { enum: param.enum }) },
|
|
128
|
-
])),
|
|
129
|
-
required: Object.entries(tool.definition.parameters)
|
|
130
|
-
.filter(([, param]) => param.required)
|
|
131
|
-
.map(([key]) => key),
|
|
132
|
-
},
|
|
165
|
+
executionMode: tool.executionMode,
|
|
166
|
+
parameters: buildToolLlmParameters(tool.definition.parameters),
|
|
133
167
|
execute: async (toolCallId, args, signal) => {
|
|
134
168
|
const startTime = Date.now();
|
|
135
169
|
try {
|
|
136
170
|
const context = contextProvider.get();
|
|
137
|
-
const
|
|
171
|
+
const rawArgs = (args ?? {});
|
|
172
|
+
// schema 已 required purpose;模型漏填时推导,不中断调用
|
|
173
|
+
const purpose = resolveToolCallPurpose(tool.definition.name, rawArgs);
|
|
174
|
+
// 注入型 purpose 只为人读/审批;工具自带 purpose 是真实入参,必须进 handler
|
|
175
|
+
const handlerArgs = prepareHandlerArgs(rawArgs, tool.definition);
|
|
176
|
+
const { runWithToolLimits, resolveToolTimeoutMs } = await import('../extension/execution-environment/resource-limits.js');
|
|
177
|
+
const processLimitsEnabled = context.processLimits !== false;
|
|
178
|
+
const result = await runWithToolLimits((sig) => tool.handler(handlerArgs, { ...context, abortSignal: sig }), {
|
|
179
|
+
timeoutMs: processLimitsEnabled
|
|
180
|
+
? resolveToolTimeoutMs(tool.definition)
|
|
181
|
+
: undefined,
|
|
182
|
+
abortSignal: signal,
|
|
183
|
+
toolName: tool.definition.name,
|
|
184
|
+
});
|
|
138
185
|
return {
|
|
139
186
|
toolCallId,
|
|
140
187
|
name: tool.definition.name,
|
|
141
188
|
content: result,
|
|
189
|
+
purpose,
|
|
142
190
|
durationMs: Date.now() - startTime,
|
|
143
191
|
};
|
|
144
192
|
}
|
|
@@ -148,6 +196,9 @@ function convertToAgentTool(tool, contextProvider) {
|
|
|
148
196
|
name: tool.definition.name,
|
|
149
197
|
content: `Error: ${error instanceof Error ? error.message : String(error)}`,
|
|
150
198
|
isError: true,
|
|
199
|
+
purpose: typeof args?.purpose === 'string'
|
|
200
|
+
? String(args.purpose)
|
|
201
|
+
: '',
|
|
151
202
|
durationMs: Date.now() - startTime,
|
|
152
203
|
};
|
|
153
204
|
}
|
|
@@ -297,6 +348,8 @@ export class AgentBuilder {
|
|
|
297
348
|
_runGuard;
|
|
298
349
|
_runGuardConfig;
|
|
299
350
|
_checkpointInterval;
|
|
351
|
+
/** 模型调用 watchdog 超时(undefined = 引擎默认) */
|
|
352
|
+
_modelCallTimeouts;
|
|
300
353
|
_reliabilityConfig;
|
|
301
354
|
// Harness 组件
|
|
302
355
|
_personaWorkspaces = [];
|
|
@@ -344,6 +397,8 @@ export class AgentBuilder {
|
|
|
344
397
|
_observerHub;
|
|
345
398
|
/** 工具效应隔离(I5);Runner 解析 toolRuntime.cwd */
|
|
346
399
|
_toolIsolation;
|
|
400
|
+
_effectPolicy;
|
|
401
|
+
_confirmEffect;
|
|
347
402
|
// MCP 配置
|
|
348
403
|
_mcpConfigs = [];
|
|
349
404
|
/** MCP client 工厂(Integration 适配器由宿主注入) */
|
|
@@ -382,15 +437,28 @@ export class AgentBuilder {
|
|
|
382
437
|
}
|
|
383
438
|
return this;
|
|
384
439
|
}
|
|
385
|
-
/**
|
|
440
|
+
/** 注册工具(同名默认拒绝;单工具失败不中断其余注册) */
|
|
386
441
|
tool(tool) {
|
|
387
442
|
this._toolBus.register(tool);
|
|
388
443
|
return this;
|
|
389
444
|
}
|
|
390
|
-
/**
|
|
445
|
+
/**
|
|
446
|
+
* 覆盖注册(显式)。用于热更新/替换同名工具,不可默默发生。
|
|
447
|
+
*/
|
|
448
|
+
toolReplace(tool) {
|
|
449
|
+
this._toolBus.register(tool, { replace: true });
|
|
450
|
+
return this;
|
|
451
|
+
}
|
|
452
|
+
/** 批量注册:逐个 try/catch,避免一个工具失败拖垮整表 */
|
|
391
453
|
tools(...tools) {
|
|
392
|
-
for (const t of tools)
|
|
393
|
-
|
|
454
|
+
for (const t of tools) {
|
|
455
|
+
try {
|
|
456
|
+
this.tool(t);
|
|
457
|
+
}
|
|
458
|
+
catch (err) {
|
|
459
|
+
console.warn(`[AgentBuilder] tool register failed (${t.definition.name}): ${err instanceof Error ? err.message : String(err)}`);
|
|
460
|
+
}
|
|
461
|
+
}
|
|
394
462
|
return this;
|
|
395
463
|
}
|
|
396
464
|
_contextProvider = new RuntimeToolContextProvider();
|
|
@@ -489,7 +557,8 @@ export class AgentBuilder {
|
|
|
489
557
|
}
|
|
490
558
|
/** 注入 MemoryStore(每轮按 query 召回进 system prompt) */
|
|
491
559
|
memoryStore(store) {
|
|
492
|
-
|
|
560
|
+
// L3:写口记 turn journal(RunScope ALS);turn 外(steward)无 journal 则直写
|
|
561
|
+
this._memoryStore = new JournaledMemoryStore(store, () => getRunScope()?.toolRuntime?.memoryEffects);
|
|
493
562
|
return this;
|
|
494
563
|
}
|
|
495
564
|
/** 注入补录覆盖表(默认:SqliteMemoryStore→agent.db,否则内存) */
|
|
@@ -538,7 +607,7 @@ export class AgentBuilder {
|
|
|
538
607
|
this._wisdomStore = store;
|
|
539
608
|
return this;
|
|
540
609
|
}
|
|
541
|
-
/** 注入 ConceptGraphStore
|
|
610
|
+
/** 注入 ConceptGraphStore(spreadingActivate 召回概念子图,进 system prompt CognitionLayer) */
|
|
542
611
|
cognitionStore(store) {
|
|
543
612
|
this._cognitionStore = store;
|
|
544
613
|
return this;
|
|
@@ -684,6 +753,11 @@ export class AgentBuilder {
|
|
|
684
753
|
this._checkpointInterval = checkpointInterval;
|
|
685
754
|
return this;
|
|
686
755
|
}
|
|
756
|
+
/** 设置模型调用 watchdog 超时(流式 idle + 绝对上限;缺省用引擎默认) */
|
|
757
|
+
modelCallTimeouts(timeouts) {
|
|
758
|
+
this._modelCallTimeouts = timeouts;
|
|
759
|
+
return this;
|
|
760
|
+
}
|
|
687
761
|
persona(...workspaces) {
|
|
688
762
|
this._personaWorkspaces.push(...workspaces);
|
|
689
763
|
return this;
|
|
@@ -714,9 +788,9 @@ export class AgentBuilder {
|
|
|
714
788
|
this._store = store;
|
|
715
789
|
return this;
|
|
716
790
|
}
|
|
717
|
-
/** 设置 Runner
|
|
791
|
+
/** 设置 Runner 配置(浅合并,便于多次补充字段) */
|
|
718
792
|
runnerConfig(config) {
|
|
719
|
-
this._runnerConfig = config;
|
|
793
|
+
this._runnerConfig = { ...this._runnerConfig, ...config };
|
|
720
794
|
if (config.observerHub) {
|
|
721
795
|
this._observerHub = config.observerHub;
|
|
722
796
|
}
|
|
@@ -732,6 +806,16 @@ export class AgentBuilder {
|
|
|
732
806
|
*
|
|
733
807
|
* @param mode - `none` | `session-subdir` | `session-lock`
|
|
734
808
|
*/
|
|
809
|
+
/** P3:注入 ToolEffectPolicy */
|
|
810
|
+
effectPolicy(config) {
|
|
811
|
+
this._effectPolicy = config;
|
|
812
|
+
return this;
|
|
813
|
+
}
|
|
814
|
+
/** P4:宿主 confirmEffect(host-gate) */
|
|
815
|
+
confirmEffect(fn) {
|
|
816
|
+
this._confirmEffect = fn;
|
|
817
|
+
return this;
|
|
818
|
+
}
|
|
735
819
|
toolIsolation(mode) {
|
|
736
820
|
this._toolIsolation = mode;
|
|
737
821
|
return this;
|
|
@@ -771,6 +855,22 @@ export class AgentBuilder {
|
|
|
771
855
|
this._toolBus.register(t);
|
|
772
856
|
}
|
|
773
857
|
}
|
|
858
|
+
// 会话日程:与 task_* 同构;进程内共用实例时经 runnerConfig 注入
|
|
859
|
+
let sessionScheduleService = this._runnerConfig?.sessionScheduleService;
|
|
860
|
+
if (!sessionScheduleService) {
|
|
861
|
+
sessionScheduleService = new SessionScheduleService({ events });
|
|
862
|
+
// 默认实例必须 open,否则 runner 注入 list() 会抛 not opened
|
|
863
|
+
await sessionScheduleService.open();
|
|
864
|
+
}
|
|
865
|
+
this._runnerConfig = {
|
|
866
|
+
...this._runnerConfig,
|
|
867
|
+
sessionScheduleService,
|
|
868
|
+
};
|
|
869
|
+
if (!this._toolBus.getTool('schedule_set')) {
|
|
870
|
+
for (const t of createSessionScheduleTools(sessionScheduleService)) {
|
|
871
|
+
this._toolBus.register(t);
|
|
872
|
+
}
|
|
873
|
+
}
|
|
774
874
|
// memory 工具必须在 buildCore 之前注册:Agent 构造时从 ToolBus 快照 tools
|
|
775
875
|
if (this._memoryStore && !this._toolBus.getTool('memory_store')) {
|
|
776
876
|
const { createMemoryTools } = await import('../extension/plugin-ecosystem/tools/memory.js');
|
|
@@ -785,6 +885,25 @@ export class AgentBuilder {
|
|
|
785
885
|
gates: memCfg?.gates?.maxLength
|
|
786
886
|
? { maxLength: memCfg.gates.maxLength }
|
|
787
887
|
: undefined,
|
|
888
|
+
onStored: this._cognitionStore && events
|
|
889
|
+
? (info) => {
|
|
890
|
+
void import('../memory/cognition-trigger.js')
|
|
891
|
+
.then(({ emitConceptualizeRequest }) => {
|
|
892
|
+
emitConceptualizeRequest(events, {
|
|
893
|
+
memoryId: info.id,
|
|
894
|
+
proposition: info.proposition,
|
|
895
|
+
evidence: info.evidence,
|
|
896
|
+
memoryType: info.type,
|
|
897
|
+
memoryStatus: info.status,
|
|
898
|
+
channel: info.channel,
|
|
899
|
+
sessionId: info.sessionId,
|
|
900
|
+
});
|
|
901
|
+
})
|
|
902
|
+
.catch(() => {
|
|
903
|
+
// 动态加载失败不阻断 memory 写
|
|
904
|
+
});
|
|
905
|
+
}
|
|
906
|
+
: undefined,
|
|
788
907
|
})) {
|
|
789
908
|
this._toolBus.register(tool);
|
|
790
909
|
}
|
|
@@ -837,12 +956,16 @@ export class AgentBuilder {
|
|
|
837
956
|
const runner = new SessionAwareRunner(agent, harness, store, {
|
|
838
957
|
...this._runnerConfig,
|
|
839
958
|
toolIsolation: this._toolIsolation ?? this._runnerConfig?.toolIsolation,
|
|
959
|
+
effectPolicy: this._effectPolicy ?? this._runnerConfig?.effectPolicy,
|
|
960
|
+
confirmEffect: this._confirmEffect ?? this._runnerConfig?.confirmEffect,
|
|
840
961
|
agentWorkspace: this._workspace?.trim() ? this._workspace : this._runnerConfig?.agentWorkspace,
|
|
841
962
|
sessionLease: this._runnerConfig?.sessionLease,
|
|
842
963
|
sessionAcl: this._runnerConfig?.sessionAcl,
|
|
843
964
|
agentMaxSessionRights: this._runnerConfig?.agentMaxSessionRights,
|
|
965
|
+
agentToolPolicy: this._runnerConfig?.agentToolPolicy,
|
|
844
966
|
observerHub: this._observerHub ?? this._runnerConfig?.observerHub,
|
|
845
967
|
sessionTaskService,
|
|
968
|
+
sessionScheduleService,
|
|
846
969
|
events,
|
|
847
970
|
eventSink: this._telemetry?.onEvent
|
|
848
971
|
? (event, ctx) => this._telemetry?.onEvent?.(event, ctx)
|
|
@@ -874,6 +997,7 @@ export class AgentBuilder {
|
|
|
874
997
|
cognitionStore,
|
|
875
998
|
systemBudgetRatio: assemblerCfg?.systemBudgetRatio,
|
|
876
999
|
systemBudgetTokens: assemblerCfg?.systemBudgetTokens,
|
|
1000
|
+
snapshotBudgetTokens: assemblerCfg?.snapshotBudgetTokens,
|
|
877
1001
|
constitution: constitutionCfg,
|
|
878
1002
|
assemblerConfig: {
|
|
879
1003
|
layerShares: assemblerCfg?.layerShares,
|
|
@@ -945,8 +1069,10 @@ export class AgentBuilder {
|
|
|
945
1069
|
errorStrategy: this._errorStrategy ?? new DefaultErrorStrategy(),
|
|
946
1070
|
mainTools: this._toolBus,
|
|
947
1071
|
modelLevels: this._modelLevels,
|
|
1072
|
+
providers: this._namedProviders.size > 0 ? this._namedProviders : undefined,
|
|
948
1073
|
},
|
|
949
1074
|
auditDir: this._subsystemAuditDir,
|
|
1075
|
+
agentId: this._agentId,
|
|
950
1076
|
});
|
|
951
1077
|
const registeredIds = new Set();
|
|
952
1078
|
const tryRegister = (spec) => {
|
|
@@ -974,10 +1100,20 @@ export class AgentBuilder {
|
|
|
974
1100
|
tryRegister(spec);
|
|
975
1101
|
}
|
|
976
1102
|
}
|
|
977
|
-
// 依赖注入:memoryStore / sessionStore / constitution / backfillCoverage
|
|
1103
|
+
// 依赖注入:modelProvider / memoryStore / wisdomStore / conceptGraphStore / sessionStore / constitution / backfillCoverage
|
|
1104
|
+
// modelProvider = 主 provider 实例(legacy runtimeInject.requires;新代码用 llmPort)
|
|
1105
|
+
if (this._model) {
|
|
1106
|
+
subsystemRuntime.registerDependency('modelProvider', this._model);
|
|
1107
|
+
}
|
|
978
1108
|
if (this._memoryStore) {
|
|
979
1109
|
subsystemRuntime.registerDependency('memoryStore', this._memoryStore);
|
|
980
1110
|
}
|
|
1111
|
+
if (this._wisdomStore) {
|
|
1112
|
+
subsystemRuntime.registerDependency('wisdomStore', this._wisdomStore);
|
|
1113
|
+
}
|
|
1114
|
+
if (this._cognitionStore) {
|
|
1115
|
+
subsystemRuntime.registerDependency('conceptGraphStore', this._cognitionStore);
|
|
1116
|
+
}
|
|
981
1117
|
{
|
|
982
1118
|
const { InMemoryBackfillCoverageStore } = await import('../memory/backfill-coverage.js');
|
|
983
1119
|
let coverage = this._backfillCoverage;
|
|
@@ -1064,6 +1200,15 @@ export class AgentBuilder {
|
|
|
1064
1200
|
const personaLoadedForHealth = Boolean((this._systemPrompt ?? '').trim() ||
|
|
1065
1201
|
(this._initialPersonaContent ?? '').trim() ||
|
|
1066
1202
|
this._personaResolver);
|
|
1203
|
+
// 后置注册工具:走 convertToAgentTool + Agent.registerTool(自带 security 名单同步)
|
|
1204
|
+
const registerTools = (tools) => {
|
|
1205
|
+
for (const t of tools) {
|
|
1206
|
+
if (this._toolBus.getTool(t.definition.name))
|
|
1207
|
+
continue;
|
|
1208
|
+
this._toolBus.register(t);
|
|
1209
|
+
agent.registerTool(convertToAgentTool(t, this._contextProvider));
|
|
1210
|
+
}
|
|
1211
|
+
};
|
|
1067
1212
|
return {
|
|
1068
1213
|
agent,
|
|
1069
1214
|
harness,
|
|
@@ -1071,6 +1216,8 @@ export class AgentBuilder {
|
|
|
1071
1216
|
mcpManager,
|
|
1072
1217
|
runtime: subsystemRuntime,
|
|
1073
1218
|
events,
|
|
1219
|
+
store,
|
|
1220
|
+
registerTools,
|
|
1074
1221
|
contextEngine,
|
|
1075
1222
|
contextHealth: async (agentId) => {
|
|
1076
1223
|
const { probeContextLayerHealth } = await import('../context/layer-health.js');
|
|
@@ -1131,7 +1278,7 @@ export class AgentBuilder {
|
|
|
1131
1278
|
this._initialPersonaContent = await this._personaResolver();
|
|
1132
1279
|
systemPrompt = this._initialPersonaContent;
|
|
1133
1280
|
}
|
|
1134
|
-
if (!systemPrompt && this._toolBus.listForAgent('default').length > 0) {
|
|
1281
|
+
if (!systemPrompt && this._toolBus.listForAgent(this._agentId ?? 'default').length > 0) {
|
|
1135
1282
|
systemPrompt = this.buildDefaultSystemPrompt();
|
|
1136
1283
|
}
|
|
1137
1284
|
// Skill:目录 discover(或外部注入的 manager)
|
|
@@ -1152,9 +1299,13 @@ export class AgentBuilder {
|
|
|
1152
1299
|
this._contextProvider = new RuntimeToolContextProvider({
|
|
1153
1300
|
cwd: this._workspace?.trim() ? this._workspace : undefined,
|
|
1154
1301
|
});
|
|
1155
|
-
const
|
|
1302
|
+
const busAgentId = this._agentId ?? 'default';
|
|
1303
|
+
const agentTools = this._toolBus.listForAgent(busAgentId).map(t => convertToAgentTool(t, this._contextProvider));
|
|
1304
|
+
console.log(`[AgentBuilder] agent tools (${agentTools.length}): ${agentTools.map((t) => t.name).join(', ')}`);
|
|
1156
1305
|
// 创建 Agent
|
|
1157
1306
|
const agentOptions = {
|
|
1307
|
+
modelCallIdleTimeoutMs: this._modelCallTimeouts?.idleTimeoutMs,
|
|
1308
|
+
modelCallAbsoluteTimeoutMs: this._modelCallTimeouts?.absoluteTimeoutMs,
|
|
1158
1309
|
model: this._model,
|
|
1159
1310
|
systemPrompt,
|
|
1160
1311
|
tools: agentTools,
|
|
@@ -1173,8 +1324,11 @@ export class AgentBuilder {
|
|
|
1173
1324
|
const summarizeFn = this._summarize ??
|
|
1174
1325
|
(!this._disableAutoSummarize && this._model
|
|
1175
1326
|
? async (messages, opts) => {
|
|
1176
|
-
|
|
1177
|
-
|
|
1327
|
+
// 与会话同 provider+model:前缀缓存同域。禁止自动切 summary/mini。
|
|
1328
|
+
const snap = getResolvedModel();
|
|
1329
|
+
const provider = snap?.provider ?? this._model;
|
|
1330
|
+
const model = snap?.modelName;
|
|
1331
|
+
return createProviderSummarize(provider, { model })(messages, opts);
|
|
1178
1332
|
}
|
|
1179
1333
|
: undefined);
|
|
1180
1334
|
agent.setConvertToLlm(async (messages) => {
|
|
@@ -1188,7 +1342,7 @@ export class AgentBuilder {
|
|
|
1188
1342
|
function: {
|
|
1189
1343
|
name: t.name,
|
|
1190
1344
|
description: t.description,
|
|
1191
|
-
parameters: t.parameters ?? { type: 'object', properties: {} },
|
|
1345
|
+
parameters: sanitizeLlmJsonSchema(t.parameters ?? { type: 'object', properties: {} }),
|
|
1192
1346
|
},
|
|
1193
1347
|
}));
|
|
1194
1348
|
// 方案 B:只读 snapshot.contextWindow;未知则 undefined(跳过自动压缩)
|
|
@@ -1267,24 +1421,9 @@ export class AgentBuilder {
|
|
|
1267
1421
|
estimatedTokens: result.estimatedTokens,
|
|
1268
1422
|
contextWindow,
|
|
1269
1423
|
};
|
|
1270
|
-
// droppedSummary
|
|
1271
|
-
|
|
1272
|
-
|
|
1273
|
-
const note = `[Context compacted] ${result.droppedSummary}`;
|
|
1274
|
-
const sysIdx = llmMessages.findIndex((m) => m.role === 'system');
|
|
1275
|
-
if (sysIdx >= 0) {
|
|
1276
|
-
const sys = llmMessages[sysIdx];
|
|
1277
|
-
const prev = typeof sys.content === 'string' ? sys.content : '';
|
|
1278
|
-
llmMessages[sysIdx] = {
|
|
1279
|
-
...sys,
|
|
1280
|
-
content: prev ? `${prev}\n\n${note}` : note,
|
|
1281
|
-
};
|
|
1282
|
-
}
|
|
1283
|
-
else {
|
|
1284
|
-
llmMessages.unshift({ role: 'system', content: note });
|
|
1285
|
-
}
|
|
1286
|
-
}
|
|
1287
|
-
return llmMessages;
|
|
1424
|
+
// droppedSummary 不得进 system(动态注记打穿前缀缓存)。
|
|
1425
|
+
// 本轮直接不投递;压缩语义由消息侧 contextSummary 承载。
|
|
1426
|
+
return result.messages;
|
|
1288
1427
|
});
|
|
1289
1428
|
agent.setOnAfterTurn(async (usage, turn) => {
|
|
1290
1429
|
const scope = getRunScope();
|
|
@@ -1314,7 +1453,7 @@ export class AgentBuilder {
|
|
|
1314
1453
|
}
|
|
1315
1454
|
// 未注册工具硬边界:灌入工具面快照(空集 = 不校验,必须在 build 时接线)
|
|
1316
1455
|
if (security.setRegisteredTools) {
|
|
1317
|
-
security.setRegisteredTools(new Set(this._toolBus.listForAgent('default').map((t) => t.definition.name)));
|
|
1456
|
+
security.setRegisteredTools(new Set(this._toolBus.listForAgent(this._agentId ?? 'default').map((t) => t.definition.name)));
|
|
1318
1457
|
}
|
|
1319
1458
|
const errorStrategy = this._errorStrategy ?? new DefaultErrorStrategy();
|
|
1320
1459
|
// 自动创建 RunGuard(如果通过 config 配置但未手动传入实例)
|
|
@@ -1384,15 +1523,17 @@ export class AgentBuilder {
|
|
|
1384
1523
|
* 生成默认 systemPrompt,包含可用工具说明
|
|
1385
1524
|
*/
|
|
1386
1525
|
buildDefaultSystemPrompt() {
|
|
1387
|
-
const toolList = this._toolBus.listForAgent('default')
|
|
1526
|
+
const toolList = this._toolBus.listForAgent(this._agentId ?? 'default')
|
|
1388
1527
|
.map(t => `- ${t.definition.name}: ${t.definition.description}`)
|
|
1389
1528
|
.join('\n');
|
|
1390
1529
|
return `You are a helpful AI assistant with access to the following tools:
|
|
1391
1530
|
|
|
1392
1531
|
${toolList}
|
|
1393
1532
|
|
|
1533
|
+
Every tool call must include a short honest purpose field (verb + object + goal, e.g. "read package.json to find test script") — humans and approvers see it as the call title.
|
|
1534
|
+
|
|
1394
1535
|
Tool selection (strict):
|
|
1395
|
-
1. Prefer a dedicated tool when one covers the job (file_read / file_list / file_write / file_edit / file_search / env_info, and any task-specific tool).
|
|
1536
|
+
1. Prefer a dedicated tool when one covers the job (file_read / file_list / file_write / file_edit / file_delete / file_mkdir / file_rename / file_copy / file_stat / file_rmdir / file_search / env_info, and any task-specific tool).
|
|
1396
1537
|
2. If a dedicated-tool call fails because your arguments were wrong (bad path, bad params), fix the call and retry that tool — do not switch to shell for a call you can fix.
|
|
1397
1538
|
3. Use shell only when: (a) no dedicated tool covers the operation, or (b) the dedicated tool is unavailable, or (c) it still fails after a correct retry and shell is the only remaining way to make progress.
|
|
1398
1539
|
4. Do not prefer shell over a working dedicated tool for the same job.
|
|
@@ -1401,26 +1542,36 @@ Examples:
|
|
|
1401
1542
|
- Read a file → file_read first (shell cat only if file_read is unavailable or still fails after a correct retry)
|
|
1402
1543
|
- List directory → file_list first
|
|
1403
1544
|
- Write/edit a file → file_write / file_edit first
|
|
1545
|
+
- Delete a file → file_delete first (not shell rm)
|
|
1546
|
+
- Create a folder → file_mkdir first
|
|
1547
|
+
- Rename/move → file_rename first
|
|
1548
|
+
- Copy a file → file_copy first
|
|
1549
|
+
- File info → file_stat first
|
|
1550
|
+
- Remove empty folder → file_rmdir first
|
|
1404
1551
|
- Search file contents → file_search first
|
|
1405
1552
|
- Operation with no dedicated tool → shell is acceptable`;
|
|
1406
1553
|
}
|
|
1407
1554
|
}
|
|
1408
1555
|
export async function createAgent(config) {
|
|
1409
|
-
const builder = new AgentBuilder()
|
|
1410
|
-
.model(config.model);
|
|
1411
|
-
if (config.persona)
|
|
1412
|
-
builder.persona(config.persona);
|
|
1413
|
-
if (config.tools)
|
|
1414
|
-
builder.tools(...config.tools);
|
|
1556
|
+
const builder = new AgentBuilder();
|
|
1415
1557
|
if (config.store)
|
|
1416
1558
|
builder.store(config.store);
|
|
1417
|
-
if (config.budget)
|
|
1418
|
-
builder.budget(config.budget);
|
|
1419
1559
|
if (config.mcpClientFactory)
|
|
1420
1560
|
builder.mcpClientFactory(config.mcpClientFactory);
|
|
1421
1561
|
if (config.mcp) {
|
|
1422
1562
|
for (const mcpConfig of config.mcp)
|
|
1423
1563
|
builder.mcp(mcpConfig);
|
|
1424
1564
|
}
|
|
1565
|
+
if (config.tools)
|
|
1566
|
+
builder.tools(...config.tools);
|
|
1567
|
+
// 标准组装与 Gateway / config-bridge 同源;嵌入路径未给 levelMap/contextEngine 时走 wire 缺省
|
|
1568
|
+
const { wireAgentBuilder } = await import('./wire-agent-builder.js');
|
|
1569
|
+
await wireAgentBuilder(builder, {
|
|
1570
|
+
model: config.model,
|
|
1571
|
+
agentId: 'default',
|
|
1572
|
+
persona: config.persona,
|
|
1573
|
+
providers: new Map([['default', config.model]]),
|
|
1574
|
+
budgetConfig: config.budget,
|
|
1575
|
+
});
|
|
1425
1576
|
return builder.build();
|
|
1426
1577
|
}
|
|
@@ -13,20 +13,28 @@
|
|
|
13
13
|
* // agents.get('assistant') → { engine, runner }
|
|
14
14
|
* ```
|
|
15
15
|
*/
|
|
16
|
-
import type {
|
|
16
|
+
import type { AgentConfig, NormalizedHarnessConfig } from '../../config.js';
|
|
17
17
|
import type { SubsystemSpec } from '../collaboration/autonomous-subsystem/types.js';
|
|
18
18
|
import type { ModelProvider } from '@octopi-agent/core/interfaces/model-provider.js';
|
|
19
19
|
import type { SessionAwareRunner } from '../run/runner.js';
|
|
20
|
-
import type { SecurityGuardConfig } from '@octopi-agent/core/security-guard.js';
|
|
21
|
-
import type { RunGuardJsonConfig } from '../../config.js';
|
|
22
|
-
import { DefaultRunGuard } from '../run/run-guard/default-run-guard.js';
|
|
23
|
-
import type { ContextEngine } from '../context/types.js';
|
|
24
20
|
import type { Agent } from '../run/agent/index.js';
|
|
25
21
|
export interface BuiltAgent {
|
|
26
22
|
agent: Agent;
|
|
27
23
|
runner: SessionAwareRunner;
|
|
28
24
|
agentConfig: AgentConfig;
|
|
29
25
|
runtime?: import('../collaboration/autonomous-subsystem/runtime.js').SubsystemRuntime;
|
|
26
|
+
/**
|
|
27
|
+
* 该 Agent 的事件总线。
|
|
28
|
+
*
|
|
29
|
+
* 跨 agent 的 notify(`arch/delegation.md` §7.1)必须落在**同一条**总线上,
|
|
30
|
+
* 否则 `AgentSignalSource` 收不到;跨 agent 场景请用 `buildFromConfig` 的
|
|
31
|
+
* `options.events` 提供共享总线,或自行 `builder.events(bus)` 注入。
|
|
32
|
+
*/
|
|
33
|
+
events: import('@octopi-agent/core/primitives/event-bus.js').EventBus;
|
|
34
|
+
/** SessionStore(委派子 Run 预创建 child session 用;`arch/delegation.md` D7) */
|
|
35
|
+
store: import('@octopi-agent/core/interfaces/session-store.js').SessionStore<import('../session/types.js').SessionData>;
|
|
36
|
+
/** 后置注册工具(`delegate_*` 等运行期才可构造的工具) */
|
|
37
|
+
registerTools: (tools: import('@octopi-agent/core/types.js').RegisteredTool[]) => void;
|
|
30
38
|
}
|
|
31
39
|
/**
|
|
32
40
|
* 从配置中创建所有 Provider 实例
|
|
@@ -34,25 +42,6 @@ export interface BuiltAgent {
|
|
|
34
42
|
* 返回 provider name → ModelProvider 的映射。
|
|
35
43
|
*/
|
|
36
44
|
export declare function resolveProviders(config: NormalizedHarnessConfig): Promise<Map<string, ModelProvider>>;
|
|
37
|
-
/**
|
|
38
|
-
* 从配置中解析安全策略(始终返回;无总开关)
|
|
39
|
-
*
|
|
40
|
-
* 硬边界与 ToolCallRiskPolicy 由 Guard/Builder 保证接线,
|
|
41
|
-
* 这里只归一化处置、范围与灵敏度。
|
|
42
|
-
*/
|
|
43
|
-
export declare function resolveSecurityConfig(config: HarnessConfig): SecurityGuardConfig;
|
|
44
|
-
/**
|
|
45
|
-
* 从配置中创建 ContextEngine 实例
|
|
46
|
-
*/
|
|
47
|
-
export declare function resolveContextEngine(config: ContextEngineConfig | undefined): ContextEngine;
|
|
48
|
-
/**
|
|
49
|
-
* 从配置中解析 RunGuard
|
|
50
|
-
*
|
|
51
|
-
* 解析 llmModel 字段:
|
|
52
|
-
* - "model" → 使用主 provider
|
|
53
|
-
* - "provider/model" → 使用指定 provider
|
|
54
|
-
*/
|
|
55
|
-
export declare function resolveRunGuard(config: RunGuardJsonConfig | undefined, providers: Map<string, ModelProvider>): DefaultRunGuard | undefined;
|
|
56
45
|
/**
|
|
57
46
|
* 按架构文档 4.9 的三级搜索路径加载子系统
|
|
58
47
|
*
|
|
@@ -71,10 +60,29 @@ export declare function resolveSubsystemSpecs(projectRoot?: string): Promise<Sub
|
|
|
71
60
|
* @param config - 完整配置
|
|
72
61
|
* @returns agent id → BuiltAgent 的映射
|
|
73
62
|
*/
|
|
74
|
-
export declare function buildFromConfig(config: NormalizedHarnessConfig): Promise<Map<string, BuiltAgent>>;
|
|
63
|
+
export declare function buildFromConfig(config: NormalizedHarnessConfig, options?: BuildFromConfigOptions): Promise<Map<string, BuiltAgent>>;
|
|
75
64
|
/**
|
|
76
65
|
* 快捷函数:从配置文件路径构建
|
|
77
66
|
*
|
|
78
67
|
* @remarks 文件 IO / `loadConfig` 属于套件侧(arch/npm-package-split.md §10.3)。
|
|
79
68
|
* 根包 `octopi` 提供 `buildFromConfigFile`;库嵌入请用 {@link buildFromConfig}。
|
|
80
69
|
*/
|
|
70
|
+
/**
|
|
71
|
+
* `buildFromConfig` 可选项
|
|
72
|
+
*
|
|
73
|
+
* @remarks 定义置于文件尾亦生效(TS interface 提升);保持单点定义。
|
|
74
|
+
*/
|
|
75
|
+
export interface BuildFromConfigOptions {
|
|
76
|
+
/**
|
|
77
|
+
* 跨 agent **共享**的事件总线。
|
|
78
|
+
*
|
|
79
|
+
* 委派 notify(`arch/delegation.md` §7.1)必须落在 `AgentSignalSource`
|
|
80
|
+
* 所监听的同一条总线上;多 agent 场景请传入共享总线。
|
|
81
|
+
* 缺省 = 各用自己 builder 建的总线,此时 **notify 不接线**(poll 通道仍可用)。
|
|
82
|
+
*/
|
|
83
|
+
events?: import('@octopi-agent/core/primitives/event-bus.js').EventBus;
|
|
84
|
+
/**
|
|
85
|
+
* 委派编排开关。缺省 = 只要有 agent 声明 `delegation` 策略就接线。
|
|
86
|
+
*/
|
|
87
|
+
delegation?: boolean;
|
|
88
|
+
}
|