@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
|
@@ -1,317 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* AgentSwarm — 多 Agent 编排器
|
|
3
|
-
*
|
|
4
|
-
* Harness 层组件。管理多个 Agent 的协作。
|
|
5
|
-
*
|
|
6
|
-
* 支持的拓扑:
|
|
7
|
-
* - hierarchical: 协调者分配任务给工作者 Agent
|
|
8
|
-
* - peer-to-peer: Agent 之间直接通信
|
|
9
|
-
* - pipeline: Agent 按顺序处理(前一个的输出是后一个的输入)
|
|
10
|
-
* - broadcast: 一个 Agent 的输出广播给所有其他 Agent
|
|
11
|
-
*
|
|
12
|
-
* 设计原则:
|
|
13
|
-
* - 基于 AgentRegistry 发现和管理 Agent
|
|
14
|
-
* - 基于 EventBus 进行事件驱动通信
|
|
15
|
-
* - 每个 Agent 有独立的运行时作用域
|
|
16
|
-
* - 编排是策略,不是机制 — 可替换的编排逻辑
|
|
17
|
-
*/
|
|
18
|
-
import { randomUUID } from 'node:crypto';
|
|
19
|
-
import { SwarmEvents } from './types.js';
|
|
20
|
-
// ── 内置策略 ──
|
|
21
|
-
/** 轮询策略:依次分配给可用 Agent */
|
|
22
|
-
export class RoundRobinStrategy {
|
|
23
|
-
name = 'round-robin';
|
|
24
|
-
_index = 0;
|
|
25
|
-
selectAgent(_task, agents) {
|
|
26
|
-
const agentIds = Array.from(agents.keys()).filter(id => {
|
|
27
|
-
const agent = agents.get(id);
|
|
28
|
-
return agent?.info.status === 'active' || agent?.info.status === 'idle';
|
|
29
|
-
});
|
|
30
|
-
if (agentIds.length === 0)
|
|
31
|
-
return null;
|
|
32
|
-
const selected = agentIds[this._index % agentIds.length];
|
|
33
|
-
this._index++;
|
|
34
|
-
return selected;
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
/** 能力匹配策略:根据任务描述匹配 Agent 能力 */
|
|
38
|
-
export class CapabilityStrategy {
|
|
39
|
-
name = 'capability-match';
|
|
40
|
-
selectAgent(task, agents, registry) {
|
|
41
|
-
// 从任务描述中提取关键词作为能力需求
|
|
42
|
-
const keywords = task.description.toLowerCase().split(/\s+/);
|
|
43
|
-
let bestAgent = null;
|
|
44
|
-
let bestScore = 0;
|
|
45
|
-
for (const [id, agent] of agents) {
|
|
46
|
-
if (agent.info.status !== 'active' && agent.info.status !== 'idle')
|
|
47
|
-
continue;
|
|
48
|
-
// 计算能力匹配分数
|
|
49
|
-
const score = agent.info.capabilities.reduce((acc, cap) => {
|
|
50
|
-
const capLower = cap.toLowerCase();
|
|
51
|
-
return acc + keywords.filter(kw => capLower.includes(kw) || kw.includes(capLower)).length;
|
|
52
|
-
}, 0);
|
|
53
|
-
if (score > bestScore) {
|
|
54
|
-
bestScore = score;
|
|
55
|
-
bestAgent = id;
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
// 没有匹配时回退到轮询
|
|
59
|
-
if (bestAgent === null) {
|
|
60
|
-
const activeAgents = Array.from(agents.entries()).filter(([, a]) => a.info.status === 'active' || a.info.status === 'idle');
|
|
61
|
-
if (activeAgents.length > 0) {
|
|
62
|
-
bestAgent = activeAgents[0][0];
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
return bestAgent;
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
/** 流水线策略:按注册顺序依次传递 */
|
|
69
|
-
export class PipelineStrategy {
|
|
70
|
-
name = 'pipeline';
|
|
71
|
-
_agentOrder = [];
|
|
72
|
-
constructor(agentOrder) {
|
|
73
|
-
this._agentOrder = agentOrder ?? [];
|
|
74
|
-
}
|
|
75
|
-
setOrder(agentIds) {
|
|
76
|
-
this._agentOrder = [...agentIds];
|
|
77
|
-
}
|
|
78
|
-
selectAgent(task, agents) {
|
|
79
|
-
// 如果任务还没有分配过,分配给第一个 Agent
|
|
80
|
-
if (!task.assignedTo) {
|
|
81
|
-
return this._agentOrder[0] ?? null;
|
|
82
|
-
}
|
|
83
|
-
// 否则分配给下一个
|
|
84
|
-
const currentIndex = this._agentOrder.indexOf(task.assignedTo);
|
|
85
|
-
if (currentIndex < 0 || currentIndex >= this._agentOrder.length - 1)
|
|
86
|
-
return null;
|
|
87
|
-
return this._agentOrder[currentIndex + 1];
|
|
88
|
-
}
|
|
89
|
-
onTaskComplete(task, result, agents) {
|
|
90
|
-
// 检查是否还有下一个 Agent
|
|
91
|
-
const currentIndex = this._agentOrder.indexOf(task.assignedTo);
|
|
92
|
-
if (currentIndex < 0 || currentIndex >= this._agentOrder.length - 1)
|
|
93
|
-
return [];
|
|
94
|
-
// 创建传递给下一个 Agent 的任务
|
|
95
|
-
return [{
|
|
96
|
-
id: `task-${randomUUID().slice(0, 8)}`,
|
|
97
|
-
description: task.description,
|
|
98
|
-
input: result,
|
|
99
|
-
assignedTo: this._agentOrder[currentIndex + 1],
|
|
100
|
-
status: 'pending',
|
|
101
|
-
createdAt: Date.now(),
|
|
102
|
-
}];
|
|
103
|
-
}
|
|
104
|
-
}
|
|
105
|
-
// ── AgentSwarm ──
|
|
106
|
-
/**
|
|
107
|
-
* AgentSwarm — 多 Agent 编排器
|
|
108
|
-
*
|
|
109
|
-
* 管理多个 Agent 的生命周期和任务分配。
|
|
110
|
-
*/
|
|
111
|
-
export class AgentSwarm {
|
|
112
|
-
id;
|
|
113
|
-
name;
|
|
114
|
-
topology;
|
|
115
|
-
_agents = new Map();
|
|
116
|
-
_tasks = new Map();
|
|
117
|
-
_strategy;
|
|
118
|
-
_registry;
|
|
119
|
-
_events;
|
|
120
|
-
_maxConcurrency;
|
|
121
|
-
_taskTimeoutMs;
|
|
122
|
-
_running = false;
|
|
123
|
-
constructor(config, registry, events, strategy) {
|
|
124
|
-
this.id = `swarm-${randomUUID().slice(0, 8)}`;
|
|
125
|
-
this.name = config.name;
|
|
126
|
-
this.topology = config.topology;
|
|
127
|
-
this._registry = registry;
|
|
128
|
-
this._events = events;
|
|
129
|
-
this._maxConcurrency = config.maxConcurrency ?? 5;
|
|
130
|
-
this._taskTimeoutMs = config.taskTimeoutMs ?? 60_000;
|
|
131
|
-
this._strategy = strategy ?? this._createDefaultStrategy(config);
|
|
132
|
-
}
|
|
133
|
-
// ── Agent 管理 ──
|
|
134
|
-
/**
|
|
135
|
-
* 添加 Agent 到 Swarm
|
|
136
|
-
*/
|
|
137
|
-
addAgent(agent) {
|
|
138
|
-
this._agents.set(agent.info.id, agent);
|
|
139
|
-
this._registry.register(agent.info);
|
|
140
|
-
this._emit(SwarmEvents.AGENT_ADDED, {
|
|
141
|
-
agentId: agent.info.id,
|
|
142
|
-
name: agent.info.name,
|
|
143
|
-
capabilities: agent.info.capabilities,
|
|
144
|
-
});
|
|
145
|
-
}
|
|
146
|
-
/**
|
|
147
|
-
* 从 Swarm 移除 Agent
|
|
148
|
-
*/
|
|
149
|
-
removeAgent(agentId) {
|
|
150
|
-
this._agents.delete(agentId);
|
|
151
|
-
this._registry.unregister(agentId);
|
|
152
|
-
this._emit(SwarmEvents.AGENT_REMOVED, { agentId });
|
|
153
|
-
}
|
|
154
|
-
/**
|
|
155
|
-
* 获取 Agent
|
|
156
|
-
*/
|
|
157
|
-
getAgent(agentId) {
|
|
158
|
-
return this._agents.get(agentId);
|
|
159
|
-
}
|
|
160
|
-
/**
|
|
161
|
-
* 列出所有 Agent
|
|
162
|
-
*/
|
|
163
|
-
listAgents() {
|
|
164
|
-
return Array.from(this._agents.values());
|
|
165
|
-
}
|
|
166
|
-
// ── 任务管理 ──
|
|
167
|
-
/**
|
|
168
|
-
* 提交任务
|
|
169
|
-
*/
|
|
170
|
-
submitTask(description, input) {
|
|
171
|
-
const task = {
|
|
172
|
-
id: `task-${randomUUID().slice(0, 8)}`,
|
|
173
|
-
description,
|
|
174
|
-
input,
|
|
175
|
-
status: 'pending',
|
|
176
|
-
createdAt: Date.now(),
|
|
177
|
-
};
|
|
178
|
-
this._tasks.set(task.id, task);
|
|
179
|
-
this._emit(SwarmEvents.TASK_CREATED, { taskId: task.id, description });
|
|
180
|
-
return task;
|
|
181
|
-
}
|
|
182
|
-
/**
|
|
183
|
-
* 执行任务
|
|
184
|
-
*
|
|
185
|
-
* 根据编排策略选择 Agent 并执行任务。
|
|
186
|
-
*/
|
|
187
|
-
async executeTask(task) {
|
|
188
|
-
// 选择 Agent
|
|
189
|
-
const agentId = this._strategy.selectAgent(task, this._agents, this._registry);
|
|
190
|
-
if (!agentId) {
|
|
191
|
-
task.status = 'failed';
|
|
192
|
-
task.error = 'No suitable agent found';
|
|
193
|
-
task.completedAt = Date.now();
|
|
194
|
-
this._emit(SwarmEvents.TASK_FAILED, { taskId: task.id, error: task.error });
|
|
195
|
-
return task;
|
|
196
|
-
}
|
|
197
|
-
const agent = this._agents.get(agentId);
|
|
198
|
-
if (!agent) {
|
|
199
|
-
task.status = 'failed';
|
|
200
|
-
task.error = `Agent ${agentId} not found in swarm`;
|
|
201
|
-
task.completedAt = Date.now();
|
|
202
|
-
return task;
|
|
203
|
-
}
|
|
204
|
-
// 分配任务
|
|
205
|
-
task.assignedTo = agentId;
|
|
206
|
-
task.status = 'assigned';
|
|
207
|
-
this._emit(SwarmEvents.TASK_ASSIGNED, { taskId: task.id, agentId });
|
|
208
|
-
// 更新 Agent 状态
|
|
209
|
-
this._registry.updateStatus(agentId, 'busy');
|
|
210
|
-
try {
|
|
211
|
-
// 执行任务
|
|
212
|
-
task.status = 'running';
|
|
213
|
-
const messages = [{
|
|
214
|
-
role: 'user',
|
|
215
|
-
content: task.input,
|
|
216
|
-
timestamp: Date.now(),
|
|
217
|
-
}];
|
|
218
|
-
const systemPrompt = `You are agent "${agent.info.name}" in a multi-agent swarm. Your capabilities: ${agent.info.capabilities.join(', ')}. Execute the following task:\n\n${task.description}`;
|
|
219
|
-
// 同步 systemPrompt 到 Agent 上下文
|
|
220
|
-
agent.agent.context.systemPrompt = systemPrompt;
|
|
221
|
-
agent.agent.context.messages = messages;
|
|
222
|
-
let result = '';
|
|
223
|
-
for await (const event of agent.agent.run(undefined, agent.harness)) {
|
|
224
|
-
if (event.type === 'assistant_message') {
|
|
225
|
-
result = typeof event.message.content === 'string' ? event.message.content : '';
|
|
226
|
-
}
|
|
227
|
-
}
|
|
228
|
-
task.result = result;
|
|
229
|
-
task.status = 'completed';
|
|
230
|
-
task.completedAt = Date.now();
|
|
231
|
-
this._emit(SwarmEvents.TASK_COMPLETED, { taskId: task.id, agentId, result });
|
|
232
|
-
// 处理后续任务(如流水线)
|
|
233
|
-
if (this._strategy.onTaskComplete) {
|
|
234
|
-
const followUpTasks = this._strategy.onTaskComplete(task, result, this._agents);
|
|
235
|
-
for (const followUp of followUpTasks) {
|
|
236
|
-
this._tasks.set(followUp.id, followUp);
|
|
237
|
-
// 递归执行后续任务
|
|
238
|
-
await this.executeTask(followUp);
|
|
239
|
-
}
|
|
240
|
-
}
|
|
241
|
-
// 恢复 Agent 状态
|
|
242
|
-
this._registry.updateStatus(agentId, 'idle');
|
|
243
|
-
return task;
|
|
244
|
-
}
|
|
245
|
-
catch (err) {
|
|
246
|
-
task.status = 'failed';
|
|
247
|
-
task.error = err instanceof Error ? err.message : String(err);
|
|
248
|
-
task.completedAt = Date.now();
|
|
249
|
-
this._emit(SwarmEvents.TASK_FAILED, { taskId: task.id, agentId, error: task.error });
|
|
250
|
-
this._registry.updateStatus(agentId, 'idle');
|
|
251
|
-
return task;
|
|
252
|
-
}
|
|
253
|
-
}
|
|
254
|
-
/**
|
|
255
|
-
* 广播任务给所有 Agent
|
|
256
|
-
*/
|
|
257
|
-
async broadcastTask(description, input) {
|
|
258
|
-
const tasks = [];
|
|
259
|
-
for (const [agentId, agent] of this._agents) {
|
|
260
|
-
if (agent.info.status !== 'active' && agent.info.status !== 'idle')
|
|
261
|
-
continue;
|
|
262
|
-
const task = this.submitTask(description, input);
|
|
263
|
-
task.assignedTo = agentId;
|
|
264
|
-
tasks.push(task);
|
|
265
|
-
}
|
|
266
|
-
// 并发执行所有任务
|
|
267
|
-
const results = await Promise.all(tasks.map(task => this.executeTask(task)));
|
|
268
|
-
return results;
|
|
269
|
-
}
|
|
270
|
-
/**
|
|
271
|
-
* 获取任务
|
|
272
|
-
*/
|
|
273
|
-
getTask(taskId) {
|
|
274
|
-
return this._tasks.get(taskId);
|
|
275
|
-
}
|
|
276
|
-
/**
|
|
277
|
-
* 列出所有任务
|
|
278
|
-
*/
|
|
279
|
-
listTasks() {
|
|
280
|
-
return Array.from(this._tasks.values());
|
|
281
|
-
}
|
|
282
|
-
// ── 策略管理 ──
|
|
283
|
-
/**
|
|
284
|
-
* 设置编排策略
|
|
285
|
-
*/
|
|
286
|
-
setStrategy(strategy) {
|
|
287
|
-
this._strategy = strategy;
|
|
288
|
-
}
|
|
289
|
-
/**
|
|
290
|
-
* 获取当前策略
|
|
291
|
-
*/
|
|
292
|
-
getStrategy() {
|
|
293
|
-
return this._strategy;
|
|
294
|
-
}
|
|
295
|
-
// ── 内部方法 ──
|
|
296
|
-
_createDefaultStrategy(config) {
|
|
297
|
-
switch (config.topology) {
|
|
298
|
-
case 'hierarchical':
|
|
299
|
-
return new CapabilityStrategy();
|
|
300
|
-
case 'pipeline':
|
|
301
|
-
return new PipelineStrategy();
|
|
302
|
-
case 'broadcast':
|
|
303
|
-
return new RoundRobinStrategy();
|
|
304
|
-
case 'peer-to-peer':
|
|
305
|
-
return new CapabilityStrategy();
|
|
306
|
-
default:
|
|
307
|
-
return new RoundRobinStrategy();
|
|
308
|
-
}
|
|
309
|
-
}
|
|
310
|
-
_emit(type, data) {
|
|
311
|
-
this._events.emit({
|
|
312
|
-
type,
|
|
313
|
-
timestamp: Date.now(),
|
|
314
|
-
data,
|
|
315
|
-
});
|
|
316
|
-
}
|
|
317
|
-
}
|
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Multi-Agent 系统类型定义
|
|
3
|
-
*
|
|
4
|
-
* Harness 层的多 Agent 编排类型。
|
|
5
|
-
*/
|
|
6
|
-
import type { Agent } from '../../run/agent/index.js';
|
|
7
|
-
import type { ReliabilityHarness } from '../../run/reliability/index.js';
|
|
8
|
-
import type { AgentInfo } from './agent-registry-types.js';
|
|
9
|
-
import type { SessionAwareRunner } from '../../run/runner.js';
|
|
10
|
-
/** Swarm 拓扑类型 */
|
|
11
|
-
export type SwarmTopology = 'hierarchical' | 'peer-to-peer' | 'pipeline' | 'broadcast';
|
|
12
|
-
/** Swarm 配置 */
|
|
13
|
-
export interface SwarmConfig {
|
|
14
|
-
/** Swarm 名称 */
|
|
15
|
-
name: string;
|
|
16
|
-
/** 拓扑类型 */
|
|
17
|
-
topology: SwarmTopology;
|
|
18
|
-
/** 协调者 Agent ID(hierarchical 模式必需) */
|
|
19
|
-
coordinatorId?: string;
|
|
20
|
-
/** 最大并发 Agent 数 */
|
|
21
|
-
maxConcurrency?: number;
|
|
22
|
-
/** 任务超时(毫秒) */
|
|
23
|
-
taskTimeoutMs?: number;
|
|
24
|
-
}
|
|
25
|
-
/** Swarm 中的 Agent 节点 */
|
|
26
|
-
export interface SwarmAgent {
|
|
27
|
-
/** Agent 注册信息 */
|
|
28
|
-
info: AgentInfo;
|
|
29
|
-
/** Agent 实例 */
|
|
30
|
-
agent: Agent;
|
|
31
|
-
/** 可靠性 Harness */
|
|
32
|
-
harness: ReliabilityHarness;
|
|
33
|
-
/** Session 运行器(可选) */
|
|
34
|
-
runner?: SessionAwareRunner;
|
|
35
|
-
}
|
|
36
|
-
/** Swarm 任务 */
|
|
37
|
-
export interface SwarmTask {
|
|
38
|
-
/** 任务 ID */
|
|
39
|
-
id: string;
|
|
40
|
-
/** 任务描述 */
|
|
41
|
-
description: string;
|
|
42
|
-
/** 任务输入 */
|
|
43
|
-
input: string;
|
|
44
|
-
/** 分配给的 Agent ID */
|
|
45
|
-
assignedTo?: string;
|
|
46
|
-
/** 任务状态 */
|
|
47
|
-
status: 'pending' | 'assigned' | 'running' | 'completed' | 'failed';
|
|
48
|
-
/** 任务结果 */
|
|
49
|
-
result?: string;
|
|
50
|
-
/** 错误信息 */
|
|
51
|
-
error?: string;
|
|
52
|
-
/** 创建时间 */
|
|
53
|
-
createdAt: number;
|
|
54
|
-
/** 完成时间 */
|
|
55
|
-
completedAt?: number;
|
|
56
|
-
}
|
|
57
|
-
/** Swarm 事件 */
|
|
58
|
-
export declare const SwarmEvents: {
|
|
59
|
-
readonly AGENT_ADDED: "swarm.agent.added";
|
|
60
|
-
readonly AGENT_REMOVED: "swarm.agent.removed";
|
|
61
|
-
readonly TASK_CREATED: "swarm.task.created";
|
|
62
|
-
readonly TASK_ASSIGNED: "swarm.task.assigned";
|
|
63
|
-
readonly TASK_COMPLETED: "swarm.task.completed";
|
|
64
|
-
readonly TASK_FAILED: "swarm.task.failed";
|
|
65
|
-
readonly TOPOLOGY_CHANGED: "swarm.topology.changed";
|
|
66
|
-
};
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Multi-Agent 系统类型定义
|
|
3
|
-
*
|
|
4
|
-
* Harness 层的多 Agent 编排类型。
|
|
5
|
-
*/
|
|
6
|
-
/** Swarm 事件 */
|
|
7
|
-
export const SwarmEvents = {
|
|
8
|
-
AGENT_ADDED: 'swarm.agent.added',
|
|
9
|
-
AGENT_REMOVED: 'swarm.agent.removed',
|
|
10
|
-
TASK_CREATED: 'swarm.task.created',
|
|
11
|
-
TASK_ASSIGNED: 'swarm.task.assigned',
|
|
12
|
-
TASK_COMPLETED: 'swarm.task.completed',
|
|
13
|
-
TASK_FAILED: 'swarm.task.failed',
|
|
14
|
-
TOPOLOGY_CHANGED: 'swarm.topology.changed',
|
|
15
|
-
};
|
|
@@ -1,107 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* AsyncTaskStore — 异步任务持久化协议
|
|
3
|
-
*
|
|
4
|
-
* @layer harness/collaboration/orchestration — AsyncTask 的状态持久化和检索。
|
|
5
|
-
* 实现方:内存(开发)、文件、Redis、数据库等。
|
|
6
|
-
*
|
|
7
|
-
* 设计要点:
|
|
8
|
-
* - 支持任务查询和过滤(dashboard/监控)
|
|
9
|
-
* - 状态机:pending → running → completed | failed | cancelled
|
|
10
|
-
* - 禁止依赖 Session.tasks
|
|
11
|
-
*/
|
|
12
|
-
/** AsyncTask 状态 */
|
|
13
|
-
export type AsyncTaskStatus = 'pending' | 'running' | 'completed' | 'failed' | 'cancelled';
|
|
14
|
-
/** AsyncTask 优先级 */
|
|
15
|
-
export type AsyncTaskPriority = 'low' | 'normal' | 'high' | 'critical';
|
|
16
|
-
/** AsyncTask 记录 */
|
|
17
|
-
export interface AsyncTaskRecord {
|
|
18
|
-
/** 任务唯一 ID */
|
|
19
|
-
id: string;
|
|
20
|
-
/** 所属 Agent ID */
|
|
21
|
-
agentId: string;
|
|
22
|
-
/** 所属 Session ID(可选) */
|
|
23
|
-
sessionId?: string;
|
|
24
|
-
/** 任务类型 */
|
|
25
|
-
type: string;
|
|
26
|
-
/** 任务状态 */
|
|
27
|
-
status: AsyncTaskStatus;
|
|
28
|
-
/** 任务优先级 */
|
|
29
|
-
priority: AsyncTaskPriority;
|
|
30
|
-
/** 任务输入 */
|
|
31
|
-
input: unknown;
|
|
32
|
-
/** 任务输出(完成后有值) */
|
|
33
|
-
output?: unknown;
|
|
34
|
-
/** 错误信息(失败时有值) */
|
|
35
|
-
error?: string;
|
|
36
|
-
/** 创建时间 */
|
|
37
|
-
createdAt: number;
|
|
38
|
-
/** 开始执行时间 */
|
|
39
|
-
startedAt?: number;
|
|
40
|
-
/** 完成时间 */
|
|
41
|
-
completedAt?: number;
|
|
42
|
-
/** 重试次数 */
|
|
43
|
-
retryCount: number;
|
|
44
|
-
/** 最大重试次数 */
|
|
45
|
-
maxRetries: number;
|
|
46
|
-
/** 超时时间(毫秒) */
|
|
47
|
-
timeoutMs?: number;
|
|
48
|
-
/** 父任务 ID(子任务场景) */
|
|
49
|
-
parentId?: string;
|
|
50
|
-
/** 扩展元数据 */
|
|
51
|
-
metadata?: Record<string, unknown>;
|
|
52
|
-
}
|
|
53
|
-
/** AsyncTask 查询过滤器 */
|
|
54
|
-
export interface AsyncTaskFilter {
|
|
55
|
-
/** 按 Agent ID 过滤 */
|
|
56
|
-
agentId?: string;
|
|
57
|
-
/** 按 Session ID 过滤 */
|
|
58
|
-
sessionId?: string;
|
|
59
|
-
/** 按状态过滤 */
|
|
60
|
-
status?: AsyncTaskStatus | AsyncTaskStatus[];
|
|
61
|
-
/** 按类型过滤 */
|
|
62
|
-
type?: string;
|
|
63
|
-
/** 按父任务 ID 过滤 */
|
|
64
|
-
parentId?: string;
|
|
65
|
-
/** 创建时间范围 */
|
|
66
|
-
createdAfter?: number;
|
|
67
|
-
createdBefore?: number;
|
|
68
|
-
/** 返回数量限制 */
|
|
69
|
-
limit?: number;
|
|
70
|
-
/** 偏移量 */
|
|
71
|
-
offset?: number;
|
|
72
|
-
}
|
|
73
|
-
/**
|
|
74
|
-
* AsyncTaskStore 接口
|
|
75
|
-
*
|
|
76
|
-
* orchestration 域内 AsyncTask 的持久化契约(非 Core)。
|
|
77
|
-
* 默认实现为内存;持久化实现可放在 integration/storage。
|
|
78
|
-
*/
|
|
79
|
-
export interface AsyncTaskStore {
|
|
80
|
-
/**
|
|
81
|
-
* 创建任务记录
|
|
82
|
-
* @param task - 完整的任务记录(包含 id)
|
|
83
|
-
* @returns 创建的任务 ID
|
|
84
|
-
*/
|
|
85
|
-
create(task: AsyncTaskRecord): Promise<string>;
|
|
86
|
-
/**
|
|
87
|
-
* 更新任务记录(部分更新)
|
|
88
|
-
*/
|
|
89
|
-
update(taskId: string, patch: Partial<AsyncTaskRecord>): Promise<void>;
|
|
90
|
-
/**
|
|
91
|
-
* 获取任务记录
|
|
92
|
-
*/
|
|
93
|
-
get(taskId: string): Promise<AsyncTaskRecord | null>;
|
|
94
|
-
/**
|
|
95
|
-
* 查询任务
|
|
96
|
-
*/
|
|
97
|
-
query(filter: AsyncTaskFilter): Promise<AsyncTaskRecord[]>;
|
|
98
|
-
/**
|
|
99
|
-
* 删除任务记录
|
|
100
|
-
*/
|
|
101
|
-
delete(taskId: string): Promise<void>;
|
|
102
|
-
/**
|
|
103
|
-
* 清理过期任务
|
|
104
|
-
* @param olderThanMs - 清理此时间之前完成的任务
|
|
105
|
-
*/
|
|
106
|
-
cleanup(olderThanMs: number): Promise<number>;
|
|
107
|
-
}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* AsyncTaskStore — 异步任务持久化协议
|
|
3
|
-
*
|
|
4
|
-
* @layer harness/collaboration/orchestration — AsyncTask 的状态持久化和检索。
|
|
5
|
-
* 实现方:内存(开发)、文件、Redis、数据库等。
|
|
6
|
-
*
|
|
7
|
-
* 设计要点:
|
|
8
|
-
* - 支持任务查询和过滤(dashboard/监控)
|
|
9
|
-
* - 状态机:pending → running → completed | failed | cancelled
|
|
10
|
-
* - 禁止依赖 Session.tasks
|
|
11
|
-
*/
|
|
12
|
-
export {};
|
|
@@ -1,156 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* AsyncTask — 异步任务单元(Harness / orchestration)
|
|
3
|
-
*
|
|
4
|
-
* 调度与后台工作单元:超时、取消、重试、可选持久化。
|
|
5
|
-
* **不是 Kernel**:Loop 与裸 Agent.run 不依赖;主消费方 TaskScheduler。
|
|
6
|
-
*
|
|
7
|
-
* 边界说明:
|
|
8
|
-
* - `priority` 仅元数据;调度策略在 TaskScheduler
|
|
9
|
-
* - 重试无退避(退避是策略)
|
|
10
|
-
* - 持久化失败不阻塞执行,但会串行化
|
|
11
|
-
*/
|
|
12
|
-
import type { EventBus } from '@octopi-agent/core/primitives/event-bus.js';
|
|
13
|
-
import type { AsyncTaskStore, AsyncTaskRecord, AsyncTaskStatus, AsyncTaskPriority } from './async-task-store.js';
|
|
14
|
-
/** AsyncTask 事件 */
|
|
15
|
-
export declare const TaskEvents: {
|
|
16
|
-
readonly CREATED: "task.created";
|
|
17
|
-
readonly STARTED: "task.started";
|
|
18
|
-
readonly COMPLETED: "task.completed";
|
|
19
|
-
readonly FAILED: "task.failed";
|
|
20
|
-
readonly CANCELLED: "task.cancelled";
|
|
21
|
-
readonly TIMEOUT: "task.timeout";
|
|
22
|
-
readonly RETRYING: "task.retrying";
|
|
23
|
-
readonly CHILD_SPAWNED: "task.child.spawned";
|
|
24
|
-
};
|
|
25
|
-
/** AsyncTask 创建选项 */
|
|
26
|
-
export interface TaskOptions {
|
|
27
|
-
/** 任务类型(用于路由和日志) */
|
|
28
|
-
type: string;
|
|
29
|
-
/** 任务输入 */
|
|
30
|
-
input?: unknown;
|
|
31
|
-
/**
|
|
32
|
-
* 优先级(仅元数据,Core 不调度)
|
|
33
|
-
*
|
|
34
|
-
* 持久化到 AsyncTaskStore,供上层调度器/过滤使用。
|
|
35
|
-
*/
|
|
36
|
-
priority?: AsyncTaskPriority;
|
|
37
|
-
/** 超时时间(毫秒) */
|
|
38
|
-
timeoutMs?: number;
|
|
39
|
-
/** 最大重试次数 */
|
|
40
|
-
maxRetries?: number;
|
|
41
|
-
/** 父任务 ID */
|
|
42
|
-
parentId?: string;
|
|
43
|
-
/** 所属 Agent ID */
|
|
44
|
-
agentId?: string;
|
|
45
|
-
/** 所属 Session ID */
|
|
46
|
-
sessionId?: string;
|
|
47
|
-
/** 扩展元数据 */
|
|
48
|
-
metadata?: Record<string, unknown>;
|
|
49
|
-
}
|
|
50
|
-
/** 任务执行函数类型 */
|
|
51
|
-
export type TaskExecutor<T = unknown> = (input: unknown, signal: AbortSignal) => Promise<T>;
|
|
52
|
-
/**
|
|
53
|
-
* AsyncTask — 异步任务
|
|
54
|
-
*
|
|
55
|
-
* 封装一个异步执行单元,提供生命周期管理。
|
|
56
|
-
*/
|
|
57
|
-
export declare class AsyncTask<T = unknown> {
|
|
58
|
-
readonly id: string;
|
|
59
|
-
readonly type: string;
|
|
60
|
-
readonly priority: AsyncTaskPriority;
|
|
61
|
-
readonly parentId?: string;
|
|
62
|
-
readonly agentId?: string;
|
|
63
|
-
readonly sessionId?: string;
|
|
64
|
-
readonly createdAt: number;
|
|
65
|
-
private _status;
|
|
66
|
-
private _output?;
|
|
67
|
-
private _error?;
|
|
68
|
-
private _startedAt?;
|
|
69
|
-
private _completedAt?;
|
|
70
|
-
private _retryCount;
|
|
71
|
-
private readonly _maxRetries;
|
|
72
|
-
private readonly _timeoutMs?;
|
|
73
|
-
private readonly _metadata?;
|
|
74
|
-
private readonly _input;
|
|
75
|
-
private _abortController;
|
|
76
|
-
private _resolvePromise;
|
|
77
|
-
private _rejectPromise;
|
|
78
|
-
private _promise;
|
|
79
|
-
private _timeoutHandle?;
|
|
80
|
-
private readonly _events?;
|
|
81
|
-
private readonly _store?;
|
|
82
|
-
private _settled;
|
|
83
|
-
/** 串行化持久化,避免 create/update 乱序 */
|
|
84
|
-
private _persistChain;
|
|
85
|
-
constructor(options: TaskOptions, events?: EventBus, store?: AsyncTaskStore);
|
|
86
|
-
/** 当前状态 */
|
|
87
|
-
get status(): AsyncTaskStatus;
|
|
88
|
-
/** 任务输出(完成后有值) */
|
|
89
|
-
get output(): T | undefined;
|
|
90
|
-
/** 错误信息(失败时有值) */
|
|
91
|
-
get error(): string | undefined;
|
|
92
|
-
/** 重试次数 */
|
|
93
|
-
get retryCount(): number;
|
|
94
|
-
/** 是否已完成(成功、失败或取消) */
|
|
95
|
-
get isDone(): boolean;
|
|
96
|
-
/** AbortSignal,用于取消传递 */
|
|
97
|
-
get signal(): AbortSignal;
|
|
98
|
-
/** 等待结果的 Promise */
|
|
99
|
-
get promise(): Promise<T>;
|
|
100
|
-
/**
|
|
101
|
-
* 启动任务执行
|
|
102
|
-
*
|
|
103
|
-
* @param executor - 任务执行函数
|
|
104
|
-
* @returns 任务结果
|
|
105
|
-
*
|
|
106
|
-
* 内部方法,由 TaskRunner 或直接调用方触发。
|
|
107
|
-
* 重试为迭代实现,避免深递归;无退避(策略在外层)。
|
|
108
|
-
*/
|
|
109
|
-
run(executor: TaskExecutor<T>): Promise<T>;
|
|
110
|
-
/**
|
|
111
|
-
* 取消任务
|
|
112
|
-
*
|
|
113
|
-
* @param reason - 取消原因
|
|
114
|
-
*/
|
|
115
|
-
cancel(reason?: string): void;
|
|
116
|
-
/**
|
|
117
|
-
* 等待任务完成(带超时)
|
|
118
|
-
*
|
|
119
|
-
* @param timeoutMs - 超时时间(毫秒),不传则无限等待
|
|
120
|
-
* @returns 任务结果
|
|
121
|
-
* @throws TaskTimeoutError | TaskCancelledError | Error
|
|
122
|
-
*
|
|
123
|
-
* 调用方超时不会改变任务本身状态;任务超时用 TaskOptions.timeoutMs。
|
|
124
|
-
*/
|
|
125
|
-
wait(timeoutMs?: number): Promise<T>;
|
|
126
|
-
/**
|
|
127
|
-
* 等待所有已排队的持久化完成(测试/优雅退出用)
|
|
128
|
-
*/
|
|
129
|
-
flushPersist(): Promise<void>;
|
|
130
|
-
private _settledError;
|
|
131
|
-
private _complete;
|
|
132
|
-
private _fail;
|
|
133
|
-
private _handleTimeout;
|
|
134
|
-
private _persistAndEmit;
|
|
135
|
-
/** 转换为 AsyncTaskRecord(用于快照/调试/持久化) */
|
|
136
|
-
toRecord(): AsyncTaskRecord;
|
|
137
|
-
}
|
|
138
|
-
/** 任务超时错误 */
|
|
139
|
-
export declare class TaskTimeoutError extends Error {
|
|
140
|
-
readonly taskId: string;
|
|
141
|
-
readonly timeoutMs: number;
|
|
142
|
-
constructor(taskId: string, timeoutMs: number);
|
|
143
|
-
}
|
|
144
|
-
/** 任务取消错误 */
|
|
145
|
-
export declare class TaskCancelledError extends Error {
|
|
146
|
-
readonly taskId: string;
|
|
147
|
-
readonly reason?: string | undefined;
|
|
148
|
-
constructor(taskId: string, reason?: string | undefined);
|
|
149
|
-
}
|
|
150
|
-
/**
|
|
151
|
-
* 创建并立即启动一个 AsyncTask
|
|
152
|
-
*
|
|
153
|
-
* 便捷方法,适用于"发射后不管"的场景。
|
|
154
|
-
* 错误通过 task.promise 和 EventBus 传播,不会被静默吞掉。
|
|
155
|
-
*/
|
|
156
|
-
export declare function spawnTask<T = unknown>(options: TaskOptions, executor: TaskExecutor<T>, events?: EventBus, store?: AsyncTaskStore): AsyncTask<T>;
|