@octopi-agent/engine 0.70.7 → 0.90.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +201 -201
- package/NOTICE +7 -7
- package/README.md +64 -26
- package/dist/config-schema/agent.d.ts +89 -1
- package/dist/config-schema/agent.js +81 -5
- package/dist/config-schema/context.d.ts +24 -5
- package/dist/config-schema/context.js +28 -1
- package/dist/config-schema/engine.d.ts +205 -13
- package/dist/config-schema/engine.js +31 -2
- package/dist/config-schema/governance.d.ts +95 -0
- package/dist/config-schema/governance.js +93 -1
- package/dist/config-schema/models.d.ts +3 -3
- package/dist/config-schema/observability.d.ts +6 -0
- package/dist/config-schema/observability.js +16 -0
- package/dist/config-schema/run.d.ts +10 -0
- package/dist/config-schema/run.js +18 -0
- package/dist/config-schema/shared.d.ts +13 -0
- package/dist/config-schema/shared.js +22 -0
- package/dist/config-schema/substrate.d.ts +2 -2
- package/dist/config-schema/subsystems.d.ts +1 -1
- package/dist/config-schema/subsystems.js +2 -1
- package/dist/config.d.ts +201 -8
- package/dist/config.js +105 -3
- package/dist/harness/activation/compiler.js +3 -0
- package/dist/harness/activation/runtime.d.ts +7 -0
- package/dist/harness/activation/runtime.js +60 -2
- package/dist/harness/activation/sources/agent-signal.d.ts +11 -0
- package/dist/harness/activation/sources/agent-signal.js +33 -0
- package/dist/harness/activation/types.d.ts +6 -1
- package/dist/harness/agent/builder.d.ts +50 -5
- package/dist/harness/agent/builder.js +189 -59
- package/dist/harness/agent/config-bridge.d.ts +33 -25
- package/dist/harness/agent/config-bridge.js +84 -291
- package/dist/harness/agent/index.d.ts +3 -1
- package/dist/harness/agent/index.js +2 -1
- package/dist/harness/agent/tool-purpose.d.ts +46 -0
- package/dist/harness/agent/tool-purpose.js +127 -0
- package/dist/harness/agent/wire-agent-builder.d.ts +133 -0
- package/dist/harness/agent/wire-agent-builder.js +370 -0
- package/dist/harness/collaboration/autonomous-subsystem/boundary/validator.d.ts +11 -1
- package/dist/harness/collaboration/autonomous-subsystem/boundary/validator.js +11 -1
- package/dist/harness/collaboration/autonomous-subsystem/loader.d.ts +13 -0
- package/dist/harness/collaboration/autonomous-subsystem/loader.js +16 -1
- package/dist/harness/collaboration/autonomous-subsystem/runtime.d.ts +8 -1
- package/dist/harness/collaboration/autonomous-subsystem/runtime.js +17 -9
- package/dist/harness/collaboration/autonomous-subsystem/sense/metrics.d.ts +12 -0
- package/dist/harness/collaboration/autonomous-subsystem/sense/metrics.js +19 -0
- package/dist/harness/collaboration/autonomous-subsystem/sense/session-lifecycle-bridge.d.ts +6 -0
- package/dist/harness/collaboration/autonomous-subsystem/sense/session-lifecycle-bridge.js +24 -7
- package/dist/harness/collaboration/autonomous-subsystem/think/executor.d.ts +5 -2
- package/dist/harness/collaboration/autonomous-subsystem/think/executor.js +11 -3
- package/dist/harness/collaboration/autonomous-subsystem/think/index.d.ts +1 -1
- package/dist/harness/collaboration/autonomous-subsystem/think/index.js +1 -1
- package/dist/harness/collaboration/autonomous-subsystem/think/llm-port.d.ts +7 -4
- package/dist/harness/collaboration/autonomous-subsystem/think/llm-port.js +8 -9
- package/dist/harness/collaboration/autonomous-subsystem/think/model-resolver.d.ts +36 -10
- package/dist/harness/collaboration/autonomous-subsystem/think/model-resolver.js +60 -7
- package/dist/harness/collaboration/delegation/child-run.d.ts +144 -0
- package/dist/harness/collaboration/delegation/child-run.js +241 -0
- package/dist/harness/collaboration/delegation/index.d.ts +26 -0
- package/dist/harness/collaboration/delegation/index.js +25 -0
- package/dist/harness/collaboration/delegation/notifier.d.ts +46 -0
- package/dist/harness/collaboration/delegation/notifier.js +84 -0
- package/dist/harness/collaboration/delegation/registry-types.d.ts +200 -0
- package/dist/harness/collaboration/delegation/registry-types.js +61 -0
- package/dist/harness/collaboration/delegation/registry.d.ts +110 -0
- package/dist/harness/collaboration/delegation/registry.js +220 -0
- package/dist/harness/collaboration/delegation/service.d.ts +249 -0
- package/dist/harness/collaboration/delegation/service.js +499 -0
- package/dist/harness/collaboration/delegation/store.d.ts +155 -0
- package/dist/harness/collaboration/delegation/store.js +271 -0
- package/dist/harness/collaboration/delegation/transport.d.ts +73 -0
- package/dist/harness/collaboration/delegation/transport.js +61 -0
- package/dist/harness/collaboration/delegation/types.d.ts +231 -0
- package/dist/harness/collaboration/delegation/types.js +70 -0
- package/dist/harness/collaboration/delegation/wiring.d.ts +111 -0
- package/dist/harness/collaboration/delegation/wiring.js +145 -0
- package/dist/harness/collaboration/orchestration/index.d.ts +11 -13
- package/dist/harness/collaboration/orchestration/index.js +11 -11
- package/dist/harness/context/assembler.d.ts +2 -2
- package/dist/harness/context/assembler.js +12 -7
- package/dist/harness/context/capabilities/compact/engine.js +80 -38
- package/dist/harness/context/capabilities/compact/types.d.ts +12 -1
- package/dist/harness/context/capabilities/summary/registry.js +10 -0
- package/dist/harness/context/constitution/default-agents.md +230 -228
- package/dist/harness/context/default-context-engine.d.ts +101 -23
- package/dist/harness/context/default-context-engine.js +483 -172
- package/dist/harness/context/hybrid-compressor.d.ts +3 -3
- package/dist/harness/context/hybrid-compressor.js +18 -23
- package/dist/harness/context/index.d.ts +5 -1
- package/dist/harness/context/index.js +2 -0
- package/dist/harness/context/layer-snapshot.d.ts +4 -0
- package/dist/harness/context/layer-snapshot.js +30 -18
- package/dist/harness/context/layer-types.d.ts +85 -1
- package/dist/harness/context/layer-types.js +110 -4
- package/dist/harness/context/layers.d.ts +5 -2
- package/dist/harness/context/layers.js +11 -5
- package/dist/harness/context/llm-summarizer.d.ts +15 -1
- package/dist/harness/context/llm-summarizer.js +107 -56
- package/dist/harness/context/message-selector.js +6 -2
- package/dist/harness/context/root-instructions.d.ts +72 -0
- package/dist/harness/context/root-instructions.js +227 -0
- package/dist/harness/context/runtime-datetime.d.ts +34 -7
- package/dist/harness/context/runtime-datetime.js +66 -10
- package/dist/harness/context/smart-router.d.ts +1 -1
- package/dist/harness/context/smart-router.js +1 -1
- package/dist/harness/context/system-prompt-assembler.d.ts +30 -0
- package/dist/harness/context/system-prompt-assembler.js +73 -6
- package/dist/harness/context/token-constants.d.ts +2 -2
- package/dist/harness/context/token-constants.js +2 -2
- package/dist/harness/context/token-estimate-fns.d.ts +1 -3
- package/dist/harness/context/token-estimate-fns.js +2 -4
- package/dist/harness/context/token-estimator.d.ts +1 -1
- package/dist/harness/context/token-estimator.js +14 -6
- package/dist/harness/context/tool-result-aging.d.ts +140 -0
- package/dist/harness/context/tool-result-aging.js +331 -0
- package/dist/harness/context/tool-result-body.d.ts +10 -0
- package/dist/harness/context/tool-result-body.js +27 -0
- package/dist/harness/context/turn-envelope.d.ts +123 -0
- package/dist/harness/context/turn-envelope.js +188 -0
- package/dist/harness/context/types.d.ts +35 -47
- package/dist/harness/extension/execution-environment/effect-policy.d.ts +258 -0
- package/dist/harness/extension/execution-environment/effect-policy.js +358 -0
- package/dist/harness/extension/execution-environment/index.d.ts +18 -2
- package/dist/harness/extension/execution-environment/index.js +11 -2
- package/dist/harness/extension/execution-environment/isolation.js +5 -1
- package/dist/harness/extension/execution-environment/memory-undo.d.ts +101 -0
- package/dist/harness/extension/execution-environment/memory-undo.js +192 -0
- package/dist/harness/extension/execution-environment/process-isolation.d.ts +84 -0
- package/dist/harness/extension/execution-environment/process-isolation.js +315 -0
- package/dist/harness/extension/execution-environment/resource-limits.d.ts +36 -0
- package/dist/harness/extension/execution-environment/resource-limits.js +84 -0
- package/dist/harness/extension/execution-environment/sandbox.d.ts +125 -4
- package/dist/harness/extension/execution-environment/sandbox.js +521 -51
- package/dist/harness/extension/execution-environment/shell-journal.d.ts +100 -0
- package/dist/harness/extension/execution-environment/shell-journal.js +299 -0
- package/dist/harness/extension/execution-environment/tool-capabilities.d.ts +45 -0
- package/dist/harness/extension/execution-environment/tool-capabilities.js +126 -0
- package/dist/harness/extension/execution-environment/types.d.ts +67 -39
- package/dist/harness/extension/execution-environment/types.js +2 -2
- package/dist/harness/extension/execution-environment/undo-log.d.ts +203 -0
- package/dist/harness/extension/execution-environment/undo-log.js +627 -0
- package/dist/harness/extension/execution-environment/undo-merge.d.ts +40 -0
- package/dist/harness/extension/execution-environment/undo-merge.js +167 -0
- package/dist/harness/extension/plugin-ecosystem/client-tools/index.d.ts +1 -1
- package/dist/harness/extension/plugin-ecosystem/client-tools/types.d.ts +9 -0
- package/dist/harness/extension/plugin-ecosystem/mcp/bridge.js +2 -0
- package/dist/harness/extension/plugin-ecosystem/plugins/api.d.ts +1 -6
- package/dist/harness/extension/plugin-ecosystem/plugins/api.js +3 -8
- package/dist/harness/extension/plugin-ecosystem/plugins/capability.d.ts +0 -3
- package/dist/harness/extension/plugin-ecosystem/plugins/capability.js +0 -3
- package/dist/harness/extension/plugin-ecosystem/plugins/entry.d.ts +2 -10
- package/dist/harness/extension/plugin-ecosystem/plugins/entry.js +2 -9
- package/dist/harness/extension/plugin-ecosystem/plugins/index.d.ts +1 -3
- package/dist/harness/extension/plugin-ecosystem/plugins/index.js +1 -3
- package/dist/harness/extension/plugin-ecosystem/plugins/loader.d.ts +2 -4
- package/dist/harness/extension/plugin-ecosystem/plugins/loader.js +4 -21
- package/dist/harness/extension/plugin-ecosystem/plugins/manager.d.ts +3 -9
- package/dist/harness/extension/plugin-ecosystem/plugins/manager.js +4 -8
- package/dist/harness/extension/plugin-ecosystem/plugins/manifest.d.ts +1 -4
- package/dist/harness/extension/plugin-ecosystem/plugins/manifest.js +1 -3
- package/dist/harness/extension/plugin-ecosystem/skills/manager.d.ts +1 -1
- package/dist/harness/extension/plugin-ecosystem/skills/manager.js +1 -1
- package/dist/harness/extension/plugin-ecosystem/tools/allowlisted-run.d.ts +51 -0
- package/dist/harness/extension/plugin-ecosystem/tools/allowlisted-run.js +153 -0
- package/dist/harness/extension/plugin-ecosystem/tools/ask-user.js +1 -0
- package/dist/harness/extension/plugin-ecosystem/tools/builtin.d.ts +18 -3
- package/dist/harness/extension/plugin-ecosystem/tools/builtin.js +277 -81
- package/dist/harness/extension/plugin-ecosystem/tools/delegation.d.ts +31 -0
- package/dist/harness/extension/plugin-ecosystem/tools/delegation.js +291 -0
- package/dist/harness/extension/plugin-ecosystem/tools/document-tools.js +10 -2
- package/dist/harness/extension/plugin-ecosystem/tools/env-info.js +1 -0
- package/dist/harness/extension/plugin-ecosystem/tools/eol.d.ts +35 -0
- package/dist/harness/extension/plugin-ecosystem/tools/eol.js +43 -0
- package/dist/harness/extension/plugin-ecosystem/tools/file-edit.js +40 -9
- package/dist/harness/extension/plugin-ecosystem/tools/file-ops.d.ts +33 -0
- package/dist/harness/extension/plugin-ecosystem/tools/file-ops.js +376 -0
- package/dist/harness/extension/plugin-ecosystem/tools/file-search.d.ts +12 -2
- package/dist/harness/extension/plugin-ecosystem/tools/file-search.js +241 -70
- package/dist/harness/extension/plugin-ecosystem/tools/git-runner.d.ts +31 -0
- package/dist/harness/extension/plugin-ecosystem/tools/git-runner.js +104 -0
- package/dist/harness/extension/plugin-ecosystem/tools/git-status-snapshot.d.ts +111 -0
- package/dist/harness/extension/plugin-ecosystem/tools/git-status-snapshot.js +197 -0
- package/dist/harness/extension/plugin-ecosystem/tools/git-tools.d.ts +27 -0
- package/dist/harness/extension/plugin-ecosystem/tools/git-tools.js +463 -0
- package/dist/harness/extension/plugin-ecosystem/tools/http.d.ts +10 -6
- package/dist/harness/extension/plugin-ecosystem/tools/http.js +41 -47
- package/dist/harness/extension/plugin-ecosystem/tools/index.d.ts +6 -0
- package/dist/harness/extension/plugin-ecosystem/tools/index.js +4 -0
- package/dist/harness/extension/plugin-ecosystem/tools/knowledge.js +4 -0
- package/dist/harness/extension/plugin-ecosystem/tools/memory.js +25 -1
- package/dist/harness/extension/plugin-ecosystem/tools/package-tools.d.ts +13 -0
- package/dist/harness/extension/plugin-ecosystem/tools/package-tools.js +391 -0
- package/dist/harness/extension/plugin-ecosystem/tools/platform.d.ts +51 -2
- package/dist/harness/extension/plugin-ecosystem/tools/platform.js +151 -12
- package/dist/harness/extension/plugin-ecosystem/tools/session-history.js +2 -0
- package/dist/harness/extension/plugin-ecosystem/tools/tool-bus.d.ts +10 -1
- package/dist/harness/extension/plugin-ecosystem/tools/tool-bus.js +35 -19
- package/dist/harness/extension/plugin-ecosystem/tools/tool-set.d.ts +8 -0
- package/dist/harness/extension/plugin-ecosystem/tools/tool-set.js +5 -0
- package/dist/harness/extension/plugin-ecosystem/tools/web-search.js +1 -0
- package/dist/harness/governance/credentials/index.d.ts +1 -1
- package/dist/harness/governance/credentials/store.d.ts +16 -4
- package/dist/harness/governance/credentials/store.js +33 -6
- package/dist/harness/governance/credentials/types.d.ts +11 -0
- package/dist/harness/governance/human-in-the-loop/decision-cache.d.ts +105 -0
- package/dist/harness/governance/human-in-the-loop/decision-cache.js +184 -0
- package/dist/harness/governance/human-in-the-loop/index.d.ts +5 -5
- package/dist/harness/governance/human-in-the-loop/index.js +3 -3
- package/dist/harness/governance/human-in-the-loop/types.d.ts +7 -62
- package/dist/harness/governance/human-in-the-loop/types.js +6 -2
- package/dist/harness/governance/security/capability-enforcer.d.ts +9 -1
- package/dist/harness/governance/security/capability-enforcer.js +31 -8
- package/dist/harness/governance/security/degradation.js +5 -7
- package/dist/harness/governance/security/risk-evaluator.d.ts +1 -1
- package/dist/harness/governance/security/risk-evaluator.js +4 -82
- package/dist/harness/governance/security/temp-path.d.ts +41 -0
- package/dist/harness/governance/security/temp-path.js +117 -0
- package/dist/harness/governance/session-acl/index.d.ts +1 -0
- package/dist/harness/governance/session-acl/index.js +1 -0
- package/dist/harness/governance/session-acl/rights.d.ts +12 -0
- package/dist/harness/governance/session-acl/rights.js +89 -7
- package/dist/harness/governance/session-acl/seed-roles.js +9 -1
- package/dist/harness/governance/session-acl/service.js +21 -29
- package/dist/harness/governance/session-acl/tool-rights.d.ts +81 -0
- package/dist/harness/governance/session-acl/tool-rights.js +238 -0
- package/dist/harness/governance/session-acl/types.d.ts +22 -0
- package/dist/harness/index.d.ts +16 -12
- package/dist/harness/index.js +10 -6
- package/dist/harness/knowledge/file-identity.d.ts +8 -0
- package/dist/harness/knowledge/file-identity.js +26 -1
- package/dist/harness/knowledge/file-index-store.js +11 -11
- package/dist/harness/knowledge/grounding.d.ts +2 -1
- package/dist/harness/knowledge/grounding.js +8 -5
- package/dist/harness/knowledge/index-store.d.ts +31 -4
- package/dist/harness/knowledge/index-store.js +121 -39
- package/dist/harness/knowledge/index.d.ts +2 -2
- package/dist/harness/knowledge/index.js +1 -1
- package/dist/harness/knowledge/ingest.d.ts +115 -115
- package/dist/harness/knowledge/ingest.js +154 -151
- package/dist/harness/knowledge/job-control-state.js +4 -4
- package/dist/harness/knowledge/job-control.js +11 -11
- package/dist/harness/knowledge/knowledge-serve-child.js +1 -1
- package/dist/harness/knowledge/membership-store.js +11 -11
- package/dist/harness/knowledge/network-guard.d.ts +61 -4
- package/dist/harness/knowledge/network-guard.js +390 -113
- package/dist/harness/knowledge/purge.js +4 -1
- package/dist/harness/knowledge/query-service.js +3 -3
- package/dist/harness/knowledge/writer-service.d.ts +2 -0
- package/dist/harness/knowledge/writer-service.js +14 -13
- package/dist/harness/memory/backfill-coverage.js +3 -1
- package/dist/harness/memory/backfill-trigger.d.ts +2 -2
- package/dist/harness/memory/backfill-trigger.js +4 -4
- package/dist/harness/memory/index.d.ts +1 -0
- package/dist/harness/memory/index.js +1 -0
- package/dist/harness/memory/sqlite/agent-db.js +2 -0
- package/dist/harness/memory/sqlite/memory-store.d.ts +1 -0
- package/dist/harness/memory/sqlite/memory-store.js +14 -4
- package/dist/harness/memory/sqlite/wisdom-store.js +9 -9
- package/dist/harness/memory/store.d.ts +1 -0
- package/dist/harness/memory/store.js +3 -0
- package/dist/harness/memory/time-format.d.ts +28 -0
- package/dist/harness/memory/time-format.js +52 -0
- package/dist/harness/memory/types.d.ts +12 -0
- package/dist/harness/observability/observer/hub.js +53 -2
- package/dist/harness/observability/observer/index.d.ts +2 -2
- package/dist/harness/observability/observer/index.js +1 -1
- package/dist/harness/observability/observer/types.d.ts +80 -0
- package/dist/harness/observability/observer/types.js +118 -9
- package/dist/harness/run/agent/agent.d.ts +18 -0
- package/dist/harness/run/agent/agent.js +26 -0
- package/dist/harness/run/concurrency/tool-loop-detection-core.d.ts +1 -1
- package/dist/harness/run/concurrency/tool-loop-detection-core.js +1 -1
- package/dist/harness/run/reliability/harness-events.d.ts +4 -0
- package/dist/harness/run/reliability/run-agent.js +110 -18
- package/dist/harness/run/reliability/run-metrics-collector.d.ts +28 -2
- package/dist/harness/run/reliability/run-metrics-collector.js +92 -2
- package/dist/harness/run/run-guard/default-run-guard.d.ts +0 -5
- package/dist/harness/run/run-guard/default-run-guard.js +104 -44
- package/dist/harness/run/run-scope.d.ts +52 -0
- package/dist/harness/run/runner.d.ts +117 -16
- package/dist/harness/run/runner.js +668 -157
- package/dist/harness/session/attachments/llm-intent.js +17 -17
- package/dist/harness/session/history/port.js +16 -5
- package/dist/harness/session/in-memory-store.d.ts +6 -0
- package/dist/harness/session/in-memory-store.js +55 -3
- package/dist/harness/session/schedules/index.d.ts +10 -0
- package/dist/harness/session/schedules/index.js +10 -0
- package/dist/harness/session/schedules/render.d.ts +13 -0
- package/dist/harness/session/schedules/render.js +63 -0
- package/dist/harness/session/schedules/service.d.ts +179 -0
- package/dist/harness/session/schedules/service.js +695 -0
- package/dist/harness/session/schedules/store.d.ts +119 -0
- package/dist/harness/session/schedules/store.js +323 -0
- package/dist/harness/session/schedules/tools.d.ts +39 -0
- package/dist/harness/session/schedules/tools.js +442 -0
- package/dist/harness/session/schedules/types.d.ts +104 -0
- package/dist/harness/session/schedules/types.js +97 -0
- package/dist/harness/session/tasks/tools.js +22 -0
- package/dist/harness/session/title.js +25 -9
- package/dist/harness/session/types.d.ts +35 -0
- package/dist/harness/shared/events/agent-event-map.d.ts +39 -0
- package/dist/harness/shared/events/agent-event-map.js +2 -0
- package/dist/harness/shared/types/agent-definition.d.ts +23 -0
- package/dist/index.d.ts +25 -9
- package/dist/index.js +11 -2
- package/dist/integration/observability/run-telemetry.d.ts +8 -0
- package/dist/integration/observability/run-telemetry.js +31 -8
- package/dist/integration/observability/trace-collector.js +26 -4
- package/dist/integration/observability/trace-events.d.ts +1 -0
- package/dist/integration/observability/trace-events.js +2 -0
- package/dist/integration/observability/trace-logger.js +27 -17
- package/dist/integration/providers/anthropic.d.ts +10 -0
- package/dist/integration/providers/anthropic.js +44 -1
- package/dist/integration/providers/openai.d.ts +10 -0
- package/dist/integration/providers/openai.js +58 -2
- package/dist/integration/providers/wire-dump-diff.d.ts +191 -0
- package/dist/integration/providers/wire-dump-diff.js +351 -0
- package/dist/integration/providers/wire-dump.d.ts +178 -0
- package/dist/integration/providers/wire-dump.js +396 -0
- package/dist/integration/storage/jsonl.d.ts +29 -0
- package/dist/integration/storage/jsonl.js +243 -41
- package/dist/integration/storage/session-index.js +63 -8
- package/dist/paths.d.ts +19 -0
- package/dist/paths.js +38 -1
- package/dist/subsystems/cognition-steward/conceptualize/SUBSYSTEM.md +43 -43
- package/dist/subsystems/cognition-steward/conceptualize/config.yaml +50 -50
- package/dist/subsystems/cognition-steward/consolidate/SUBSYSTEM.md +6 -6
- package/dist/subsystems/cognition-steward/consolidate/config.yaml +54 -54
- package/dist/subsystems/memory-steward/backfill/handler.js +9 -0
- package/dist/subsystems/safety-guard/config.yaml +3 -1
- package/dist/subsystems/wisdom-steward/evaluate/config.yaml +50 -50
- package/dist/subsystems/wisdom-steward/formation/SUBSYSTEM.md +42 -42
- package/dist/subsystems/wisdom-steward/formation/config.yaml +54 -54
- package/dist/subsystems/wisdom-steward/govern/config.yaml +55 -55
- package/package.json +115 -115
- package/dist/harness/collaboration/multi-agent/agent-registry-types.d.ts +0 -144
- package/dist/harness/collaboration/multi-agent/agent-registry-types.js +0 -25
- package/dist/harness/collaboration/multi-agent/index.d.ts +0 -17
- package/dist/harness/collaboration/multi-agent/index.js +0 -15
- package/dist/harness/collaboration/multi-agent/process.d.ts +0 -167
- package/dist/harness/collaboration/multi-agent/process.js +0 -256
- package/dist/harness/collaboration/multi-agent/registry.d.ts +0 -36
- package/dist/harness/collaboration/multi-agent/registry.js +0 -137
- package/dist/harness/collaboration/multi-agent/swarm.d.ts +0 -135
- package/dist/harness/collaboration/multi-agent/swarm.js +0 -317
- package/dist/harness/collaboration/multi-agent/types.d.ts +0 -66
- package/dist/harness/collaboration/multi-agent/types.js +0 -15
- package/dist/harness/collaboration/orchestration/async-task-store.d.ts +0 -107
- package/dist/harness/collaboration/orchestration/async-task-store.js +0 -12
- package/dist/harness/collaboration/orchestration/async-task.d.ts +0 -156
- package/dist/harness/collaboration/orchestration/async-task.js +0 -359
- package/dist/harness/collaboration/orchestration/planner/hybrid-planner.d.ts +0 -47
- package/dist/harness/collaboration/orchestration/planner/hybrid-planner.js +0 -61
- package/dist/harness/collaboration/orchestration/planner/index.d.ts +0 -9
- package/dist/harness/collaboration/orchestration/planner/index.js +0 -6
- package/dist/harness/collaboration/orchestration/planner/llm-planner.d.ts +0 -54
- package/dist/harness/collaboration/orchestration/planner/llm-planner.js +0 -167
- package/dist/harness/collaboration/orchestration/planner/rule-planner.d.ts +0 -85
- package/dist/harness/collaboration/orchestration/planner/rule-planner.js +0 -175
- package/dist/harness/collaboration/orchestration/quality/classifier.d.ts +0 -21
- package/dist/harness/collaboration/orchestration/quality/classifier.js +0 -235
- package/dist/harness/collaboration/orchestration/quality/gate.d.ts +0 -29
- package/dist/harness/collaboration/orchestration/quality/gate.js +0 -409
- package/dist/harness/collaboration/orchestration/quality/index.d.ts +0 -9
- package/dist/harness/collaboration/orchestration/quality/index.js +0 -8
- package/dist/harness/collaboration/orchestration/quality/types.d.ts +0 -159
- package/dist/harness/collaboration/orchestration/quality/types.js +0 -33
- package/dist/harness/collaboration/orchestration/scheduler/index.d.ts +0 -5
- package/dist/harness/collaboration/orchestration/scheduler/index.js +0 -4
- package/dist/harness/collaboration/orchestration/scheduler/task-scheduler.d.ts +0 -143
- package/dist/harness/collaboration/orchestration/scheduler/task-scheduler.js +0 -297
- package/dist/harness/collaboration/orchestration/strategy/classifier.d.ts +0 -12
- package/dist/harness/collaboration/orchestration/strategy/classifier.js +0 -81
- package/dist/harness/collaboration/orchestration/strategy/index.d.ts +0 -3
- package/dist/harness/collaboration/orchestration/strategy/index.js +0 -2
- package/dist/harness/collaboration/orchestration/strategy/router.d.ts +0 -28
- package/dist/harness/collaboration/orchestration/strategy/router.js +0 -105
- package/dist/harness/collaboration/orchestration/strategy/types.d.ts +0 -49
- package/dist/harness/collaboration/orchestration/strategy/types.js +0 -4
- package/dist/harness/collaboration/orchestration/workflow/engine.d.ts +0 -86
- package/dist/harness/collaboration/orchestration/workflow/engine.js +0 -298
- package/dist/harness/collaboration/orchestration/workflow/index.d.ts +0 -9
- package/dist/harness/collaboration/orchestration/workflow/index.js +0 -7
- package/dist/harness/collaboration/orchestration/workflow/types.d.ts +0 -143
- package/dist/harness/collaboration/orchestration/workflow/types.js +0 -7
- package/dist/harness/governance/human-in-the-loop/approval-manager.d.ts +0 -32
- package/dist/harness/governance/human-in-the-loop/approval-manager.js +0 -93
- /package/dist/harness/collaboration/{multi-agent → delegation}/message-channel-types.d.ts +0 -0
- /package/dist/harness/collaboration/{multi-agent → delegation}/message-channel-types.js +0 -0
|
@@ -1,256 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* AgentProcess — Agent 进程运行时
|
|
3
|
-
*
|
|
4
|
-
* 将 Agent 的一次运行包装为可追踪的进程。
|
|
5
|
-
* 支持父子关系、完成通知(announce)、上下文分叉(fork)。
|
|
6
|
-
*
|
|
7
|
-
* 设计原则:
|
|
8
|
-
* - 独立状态机(pending/running/completed/failed/aborted),不继承任何进程壳
|
|
9
|
-
* - 结果通过 EventBus 推送给父进程(announce 模式)
|
|
10
|
-
* - 支持 context fork:子进程继承父进程的消息历史
|
|
11
|
-
* - 进程完成后不可重用(completed/failed/aborted 终态)
|
|
12
|
-
*/
|
|
13
|
-
import { randomUUID } from 'node:crypto';
|
|
14
|
-
// ── 事件常量 ──
|
|
15
|
-
export const AgentProcessEvents = {
|
|
16
|
-
/** 进程启动 */
|
|
17
|
-
STARTED: 'agent_process.started',
|
|
18
|
-
/** 进程完成(announce 核心事件) */
|
|
19
|
-
COMPLETED: 'agent_process.completed',
|
|
20
|
-
/** 进程失败 */
|
|
21
|
-
FAILED: 'agent_process.failed',
|
|
22
|
-
/** 进程中止 */
|
|
23
|
-
ABORTED: 'agent_process.aborted',
|
|
24
|
-
/** 子进程 spawn */
|
|
25
|
-
CHILD_SPAWNED: 'agent_process.child_spawned',
|
|
26
|
-
};
|
|
27
|
-
// ── AgentProcess ──
|
|
28
|
-
/**
|
|
29
|
-
* AgentProcess — Agent 进程运行时
|
|
30
|
-
*
|
|
31
|
-
* 用法:
|
|
32
|
-
* ```ts
|
|
33
|
-
* const process = new AgentProcess({
|
|
34
|
-
* agentInfo: coderAgent,
|
|
35
|
-
* engine: coderEngine,
|
|
36
|
-
* events: eventBus,
|
|
37
|
-
* systemPrompt: 'You are a coding assistant...',
|
|
38
|
-
* });
|
|
39
|
-
*
|
|
40
|
-
* // 非阻塞启动
|
|
41
|
-
* process.start(userMessages);
|
|
42
|
-
*
|
|
43
|
-
* // 监听完成事件
|
|
44
|
-
* events.on(AgentProcessEvents.COMPLETED, (event) => {
|
|
45
|
-
* console.log(event.data.result);
|
|
46
|
-
* });
|
|
47
|
-
*
|
|
48
|
-
* // 或等待完成
|
|
49
|
-
* const result = await process.waitForCompletion();
|
|
50
|
-
* ```
|
|
51
|
-
*/
|
|
52
|
-
export class AgentProcess {
|
|
53
|
-
id;
|
|
54
|
-
parentId;
|
|
55
|
-
agentInfo;
|
|
56
|
-
_agent;
|
|
57
|
-
_harness;
|
|
58
|
-
_events;
|
|
59
|
-
_systemPrompt;
|
|
60
|
-
_timeoutMs;
|
|
61
|
-
_forkContext;
|
|
62
|
-
_state = 'pending';
|
|
63
|
-
_result;
|
|
64
|
-
_error;
|
|
65
|
-
_startedAt;
|
|
66
|
-
_completedAt;
|
|
67
|
-
_abortController;
|
|
68
|
-
_completionResolvers = [];
|
|
69
|
-
constructor(config) {
|
|
70
|
-
this.id = config.id ?? `proc-${randomUUID().slice(0, 8)}`;
|
|
71
|
-
this.parentId = config.parentId;
|
|
72
|
-
this.agentInfo = config.agentInfo;
|
|
73
|
-
this._agent = config.agent;
|
|
74
|
-
this._harness = config.harness;
|
|
75
|
-
this._events = config.events;
|
|
76
|
-
this._systemPrompt = config.systemPrompt;
|
|
77
|
-
this._timeoutMs = config.timeoutMs ?? 0;
|
|
78
|
-
this._forkContext = config.forkContext ?? false;
|
|
79
|
-
}
|
|
80
|
-
/** 当前状态 */
|
|
81
|
-
get state() { return this._state; }
|
|
82
|
-
/** 完成结果 */
|
|
83
|
-
get result() { return this._result; }
|
|
84
|
-
/** 错误信息 */
|
|
85
|
-
get error() { return this._error; }
|
|
86
|
-
/** 运行时长(毫秒) */
|
|
87
|
-
get durationMs() {
|
|
88
|
-
if (!this._startedAt)
|
|
89
|
-
return undefined;
|
|
90
|
-
const end = this._completedAt ?? Date.now();
|
|
91
|
-
return end - this._startedAt;
|
|
92
|
-
}
|
|
93
|
-
/**
|
|
94
|
-
* 启动进程(非阻塞)
|
|
95
|
-
*
|
|
96
|
-
* @param messages - 输入消息
|
|
97
|
-
* @param parentMessages - 父进程的消息历史(用于 context fork)
|
|
98
|
-
* @returns this(链式调用)
|
|
99
|
-
*/
|
|
100
|
-
start(messages, parentMessages) {
|
|
101
|
-
if (this._state !== 'pending') {
|
|
102
|
-
throw new Error(`Process ${this.id} already started (state: ${this._state})`);
|
|
103
|
-
}
|
|
104
|
-
this._state = 'running';
|
|
105
|
-
this._startedAt = Date.now();
|
|
106
|
-
this._abortController = new AbortController();
|
|
107
|
-
// 构建输入消息
|
|
108
|
-
let inputMessages = [...messages];
|
|
109
|
-
// Context fork:继承父进程的消息历史
|
|
110
|
-
if (this._forkContext && parentMessages && parentMessages.length > 0) {
|
|
111
|
-
inputMessages = [
|
|
112
|
-
...parentMessages,
|
|
113
|
-
{
|
|
114
|
-
role: 'system',
|
|
115
|
-
content: `[Context Fork] 以下是从父会话分叉的上下文。你继承了完整的对话历史,可以在此基础上继续工作。`,
|
|
116
|
-
timestamp: Date.now(),
|
|
117
|
-
},
|
|
118
|
-
...messages,
|
|
119
|
-
];
|
|
120
|
-
}
|
|
121
|
-
// 发射启动事件
|
|
122
|
-
this._emit(AgentProcessEvents.STARTED, {
|
|
123
|
-
processId: this.id,
|
|
124
|
-
parentId: this.parentId,
|
|
125
|
-
agentId: this.agentInfo.id,
|
|
126
|
-
});
|
|
127
|
-
// 异步运行(不 await,非阻塞)
|
|
128
|
-
this._runAsync(inputMessages);
|
|
129
|
-
return this;
|
|
130
|
-
}
|
|
131
|
-
/**
|
|
132
|
-
* 中止进程
|
|
133
|
-
*/
|
|
134
|
-
abort() {
|
|
135
|
-
if (this._state !== 'running')
|
|
136
|
-
return;
|
|
137
|
-
this._abortController?.abort();
|
|
138
|
-
this._state = 'aborted';
|
|
139
|
-
this._completedAt = Date.now();
|
|
140
|
-
this._emit(AgentProcessEvents.ABORTED, { processId: this.id });
|
|
141
|
-
this._resolveCompletion();
|
|
142
|
-
}
|
|
143
|
-
/**
|
|
144
|
-
* 等待进程完成(Promise 模式)
|
|
145
|
-
*/
|
|
146
|
-
waitForCompletion() {
|
|
147
|
-
if (this._state !== 'running' && this._state !== 'pending') {
|
|
148
|
-
return Promise.resolve(this._buildAnnounce());
|
|
149
|
-
}
|
|
150
|
-
return new Promise((resolve) => {
|
|
151
|
-
this._completionResolvers.push(resolve);
|
|
152
|
-
});
|
|
153
|
-
}
|
|
154
|
-
// ── 内部方法 ──
|
|
155
|
-
async _runAsync(messages) {
|
|
156
|
-
try {
|
|
157
|
-
// 带超时的运行
|
|
158
|
-
const runPromise = this._collectRun(messages);
|
|
159
|
-
const result = this._timeoutMs > 0
|
|
160
|
-
? await this._withTimeout(runPromise, this._timeoutMs)
|
|
161
|
-
: await runPromise;
|
|
162
|
-
this._result = {
|
|
163
|
-
content: result.content,
|
|
164
|
-
messages: result.messages,
|
|
165
|
-
usage: result.usage,
|
|
166
|
-
durationMs: this.durationMs ?? 0,
|
|
167
|
-
};
|
|
168
|
-
this._state = 'completed';
|
|
169
|
-
this._completedAt = Date.now();
|
|
170
|
-
// Announce:推送完成事件
|
|
171
|
-
const announce = this._buildAnnounce();
|
|
172
|
-
this._emit(AgentProcessEvents.COMPLETED, { announce });
|
|
173
|
-
this._resolveCompletion();
|
|
174
|
-
}
|
|
175
|
-
catch (err) {
|
|
176
|
-
if (this._state === 'aborted')
|
|
177
|
-
return; // 已经处理过
|
|
178
|
-
this._state = 'failed';
|
|
179
|
-
this._completedAt = Date.now();
|
|
180
|
-
this._error = err instanceof Error ? err.message : String(err);
|
|
181
|
-
const announce = this._buildAnnounce();
|
|
182
|
-
this._emit(AgentProcessEvents.FAILED, { announce });
|
|
183
|
-
this._resolveCompletion();
|
|
184
|
-
}
|
|
185
|
-
}
|
|
186
|
-
async _collectRun(messages) {
|
|
187
|
-
let content = '';
|
|
188
|
-
let usage;
|
|
189
|
-
let errorReason;
|
|
190
|
-
// 同步消息到 Agent 上下文
|
|
191
|
-
this._agent.context.messages = messages;
|
|
192
|
-
for await (const event of this._agent.run(this._abortController?.signal, this._harness)) {
|
|
193
|
-
if (event.type === 'assistant_message') {
|
|
194
|
-
content = typeof event.message.content === 'string' ? event.message.content : '';
|
|
195
|
-
}
|
|
196
|
-
// 检测错误退出
|
|
197
|
-
if (event.type === 'agent_end' && event.reason === 'error') {
|
|
198
|
-
errorReason = event.error instanceof Error ? event.error.message : String(event.error ?? 'Unknown error');
|
|
199
|
-
}
|
|
200
|
-
}
|
|
201
|
-
if (errorReason) {
|
|
202
|
-
throw new Error(errorReason);
|
|
203
|
-
}
|
|
204
|
-
return { content, messages: this._agent.context.messages, usage };
|
|
205
|
-
}
|
|
206
|
-
_buildAnnounce() {
|
|
207
|
-
return {
|
|
208
|
-
processId: this.id,
|
|
209
|
-
parentId: this.parentId,
|
|
210
|
-
agentInfo: this.agentInfo,
|
|
211
|
-
state: this._state === 'completed' ? 'completed' : this._state === 'aborted' ? 'aborted' : 'failed',
|
|
212
|
-
result: this._result,
|
|
213
|
-
error: this._error,
|
|
214
|
-
timestamp: Date.now(),
|
|
215
|
-
};
|
|
216
|
-
}
|
|
217
|
-
_resolveCompletion() {
|
|
218
|
-
const announce = this._buildAnnounce();
|
|
219
|
-
for (const resolver of this._completionResolvers) {
|
|
220
|
-
resolver(announce);
|
|
221
|
-
}
|
|
222
|
-
this._completionResolvers = [];
|
|
223
|
-
}
|
|
224
|
-
_emit(type, data) {
|
|
225
|
-
this._events.emit({
|
|
226
|
-
type,
|
|
227
|
-
timestamp: Date.now(),
|
|
228
|
-
agentId: this.agentInfo.id,
|
|
229
|
-
sessionId: this.id,
|
|
230
|
-
data,
|
|
231
|
-
});
|
|
232
|
-
}
|
|
233
|
-
_withTimeout(promise, ms) {
|
|
234
|
-
return new Promise((resolve, reject) => {
|
|
235
|
-
const timer = setTimeout(() => reject(new Error(`Process ${this.id} timeout after ${ms}ms`)), ms);
|
|
236
|
-
promise.then((result) => { clearTimeout(timer); resolve(result); }, (err) => { clearTimeout(timer); reject(err); });
|
|
237
|
-
});
|
|
238
|
-
}
|
|
239
|
-
}
|
|
240
|
-
// ── 工厂函数 ──
|
|
241
|
-
/**
|
|
242
|
-
* 创建并启动 AgentProcess
|
|
243
|
-
*/
|
|
244
|
-
export function spawnAgentProcess(config, messages, parentMessages) {
|
|
245
|
-
const process = new AgentProcess(config);
|
|
246
|
-
process.start(messages, parentMessages);
|
|
247
|
-
return process;
|
|
248
|
-
}
|
|
249
|
-
/**
|
|
250
|
-
* 创建 context fork 子进程
|
|
251
|
-
*
|
|
252
|
-
* 从父进程的消息历史创建子进程,子进程继承父上下文。
|
|
253
|
-
*/
|
|
254
|
-
export function forkAgentProcess(config, messages, parentMessages) {
|
|
255
|
-
return spawnAgentProcess({ ...config, forkContext: true }, messages, parentMessages);
|
|
256
|
-
}
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* DefaultAgentRegistry — Agent 注册与发现的默认实现
|
|
3
|
-
*
|
|
4
|
-
* Harness 层组件。实现本域 `agent-registry-types.ts` 的 AgentRegistry。
|
|
5
|
-
* 基于内存存储,支持按能力发现、状态管理、关系管理。
|
|
6
|
-
*
|
|
7
|
-
* 设计原则:
|
|
8
|
-
* - 不依赖外部存储
|
|
9
|
-
* - 事件驱动:所有变更通过 EventBus 通知
|
|
10
|
-
* - 线程安全:操作是同步的,适合单进程场景
|
|
11
|
-
*/
|
|
12
|
-
import type { AgentRegistry, AgentInfo, AgentQuery, AgentRelation, AgentRelationType } from './agent-registry-types.js';
|
|
13
|
-
import type { EventBus } from '@octopi-agent/core/primitives/event-bus.js';
|
|
14
|
-
/**
|
|
15
|
-
* DefaultAgentRegistry
|
|
16
|
-
*
|
|
17
|
-
* 基于内存的 Agent 注册表实现。
|
|
18
|
-
*/
|
|
19
|
-
export declare class DefaultAgentRegistry implements AgentRegistry {
|
|
20
|
-
private _agents;
|
|
21
|
-
private _relations;
|
|
22
|
-
private _events?;
|
|
23
|
-
constructor(events?: EventBus);
|
|
24
|
-
register(info: Omit<AgentInfo, 'registeredAt' | 'lastActiveAt'>): void;
|
|
25
|
-
unregister(agentId: string): boolean;
|
|
26
|
-
get(agentId: string): AgentInfo | undefined;
|
|
27
|
-
query(query: AgentQuery): AgentInfo[];
|
|
28
|
-
list(): AgentInfo[];
|
|
29
|
-
findByCapability(capability: string): AgentInfo[];
|
|
30
|
-
updateStatus(agentId: string, status: AgentInfo['status']): void;
|
|
31
|
-
touch(agentId: string): void;
|
|
32
|
-
addRelation(relation: AgentRelation): void;
|
|
33
|
-
removeRelation(from: string, to: string, type?: AgentRelationType): void;
|
|
34
|
-
getRelations(agentId: string): AgentRelation[];
|
|
35
|
-
private _emit;
|
|
36
|
-
}
|
|
@@ -1,137 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* DefaultAgentRegistry — Agent 注册与发现的默认实现
|
|
3
|
-
*
|
|
4
|
-
* Harness 层组件。实现本域 `agent-registry-types.ts` 的 AgentRegistry。
|
|
5
|
-
* 基于内存存储,支持按能力发现、状态管理、关系管理。
|
|
6
|
-
*
|
|
7
|
-
* 设计原则:
|
|
8
|
-
* - 不依赖外部存储
|
|
9
|
-
* - 事件驱动:所有变更通过 EventBus 通知
|
|
10
|
-
* - 线程安全:操作是同步的,适合单进程场景
|
|
11
|
-
*/
|
|
12
|
-
import { AgentRegistryEvents } from './agent-registry-types.js';
|
|
13
|
-
/**
|
|
14
|
-
* DefaultAgentRegistry
|
|
15
|
-
*
|
|
16
|
-
* 基于内存的 Agent 注册表实现。
|
|
17
|
-
*/
|
|
18
|
-
export class DefaultAgentRegistry {
|
|
19
|
-
_agents = new Map();
|
|
20
|
-
_relations = [];
|
|
21
|
-
_events;
|
|
22
|
-
constructor(events) {
|
|
23
|
-
this._events = events;
|
|
24
|
-
}
|
|
25
|
-
// ── 注册 / 注销 ──
|
|
26
|
-
register(info) {
|
|
27
|
-
const now = Date.now();
|
|
28
|
-
const agentInfo = {
|
|
29
|
-
...info,
|
|
30
|
-
registeredAt: now,
|
|
31
|
-
lastActiveAt: now,
|
|
32
|
-
};
|
|
33
|
-
this._agents.set(info.id, agentInfo);
|
|
34
|
-
this._emit(AgentRegistryEvents.AGENT_REGISTERED, {
|
|
35
|
-
agentId: info.id,
|
|
36
|
-
name: info.name,
|
|
37
|
-
capabilities: info.capabilities,
|
|
38
|
-
});
|
|
39
|
-
}
|
|
40
|
-
unregister(agentId) {
|
|
41
|
-
const existed = this._agents.delete(agentId);
|
|
42
|
-
if (existed) {
|
|
43
|
-
// 清理相关关系
|
|
44
|
-
this._relations = this._relations.filter(r => r.from !== agentId && r.to !== agentId);
|
|
45
|
-
this._emit(AgentRegistryEvents.AGENT_UNREGISTERED, { agentId });
|
|
46
|
-
}
|
|
47
|
-
return existed;
|
|
48
|
-
}
|
|
49
|
-
// ── 查询 ──
|
|
50
|
-
get(agentId) {
|
|
51
|
-
return this._agents.get(agentId);
|
|
52
|
-
}
|
|
53
|
-
query(query) {
|
|
54
|
-
let results = Array.from(this._agents.values());
|
|
55
|
-
if (query.capabilities && query.capabilities.length > 0) {
|
|
56
|
-
results = results.filter(agent => query.capabilities.some(cap => agent.capabilities.includes(cap)));
|
|
57
|
-
}
|
|
58
|
-
if (query.status) {
|
|
59
|
-
results = results.filter(agent => agent.status === query.status);
|
|
60
|
-
}
|
|
61
|
-
if (query.metadata) {
|
|
62
|
-
results = results.filter(agent => {
|
|
63
|
-
if (!agent.metadata)
|
|
64
|
-
return false;
|
|
65
|
-
return Object.entries(query.metadata).every(([key, value]) => agent.metadata[key] === value);
|
|
66
|
-
});
|
|
67
|
-
}
|
|
68
|
-
return results;
|
|
69
|
-
}
|
|
70
|
-
list() {
|
|
71
|
-
return Array.from(this._agents.values());
|
|
72
|
-
}
|
|
73
|
-
findByCapability(capability) {
|
|
74
|
-
return Array.from(this._agents.values()).filter(agent => agent.capabilities.includes(capability));
|
|
75
|
-
}
|
|
76
|
-
// ── 状态管理 ──
|
|
77
|
-
updateStatus(agentId, status) {
|
|
78
|
-
const agent = this._agents.get(agentId);
|
|
79
|
-
if (!agent)
|
|
80
|
-
return;
|
|
81
|
-
const oldStatus = agent.status;
|
|
82
|
-
agent.status = status;
|
|
83
|
-
agent.lastActiveAt = Date.now();
|
|
84
|
-
if (oldStatus !== status) {
|
|
85
|
-
this._emit(AgentRegistryEvents.AGENT_STATUS_CHANGED, {
|
|
86
|
-
agentId,
|
|
87
|
-
oldStatus,
|
|
88
|
-
newStatus: status,
|
|
89
|
-
});
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
touch(agentId) {
|
|
93
|
-
const agent = this._agents.get(agentId);
|
|
94
|
-
if (agent) {
|
|
95
|
-
agent.lastActiveAt = Date.now();
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
// ── 关系管理 ──
|
|
99
|
-
addRelation(relation) {
|
|
100
|
-
// 去重
|
|
101
|
-
const exists = this._relations.some(r => r.from === relation.from && r.to === relation.to && r.type === relation.type);
|
|
102
|
-
if (exists)
|
|
103
|
-
return;
|
|
104
|
-
this._relations.push(relation);
|
|
105
|
-
this._emit(AgentRegistryEvents.RELATION_ADDED, {
|
|
106
|
-
from: relation.from,
|
|
107
|
-
to: relation.to,
|
|
108
|
-
type: relation.type,
|
|
109
|
-
});
|
|
110
|
-
}
|
|
111
|
-
removeRelation(from, to, type) {
|
|
112
|
-
const before = this._relations.length;
|
|
113
|
-
this._relations = this._relations.filter(r => {
|
|
114
|
-
if (r.from !== from || r.to !== to)
|
|
115
|
-
return true;
|
|
116
|
-
if (type && r.type !== type)
|
|
117
|
-
return true;
|
|
118
|
-
return false;
|
|
119
|
-
});
|
|
120
|
-
if (this._relations.length < before) {
|
|
121
|
-
this._emit(AgentRegistryEvents.RELATION_REMOVED, { from, to, type });
|
|
122
|
-
}
|
|
123
|
-
}
|
|
124
|
-
getRelations(agentId) {
|
|
125
|
-
return this._relations.filter(r => r.from === agentId || r.to === agentId);
|
|
126
|
-
}
|
|
127
|
-
// ── 内部方法 ──
|
|
128
|
-
_emit(type, data) {
|
|
129
|
-
if (this._events) {
|
|
130
|
-
this._events.emit({
|
|
131
|
-
type,
|
|
132
|
-
timestamp: Date.now(),
|
|
133
|
-
data,
|
|
134
|
-
});
|
|
135
|
-
}
|
|
136
|
-
}
|
|
137
|
-
}
|
|
@@ -1,135 +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 type { EventBus } from '@octopi-agent/core/primitives/event-bus.js';
|
|
19
|
-
import type { AgentRegistry } from './agent-registry-types.js';
|
|
20
|
-
import type { SwarmConfig, SwarmAgent, SwarmTask } from './types.js';
|
|
21
|
-
/**
|
|
22
|
-
* 编排策略
|
|
23
|
-
*
|
|
24
|
-
* 决定如何将任务分配给 Agent。
|
|
25
|
-
* 不同的拓扑有不同的策略实现。
|
|
26
|
-
*/
|
|
27
|
-
export interface OrchestrationStrategy {
|
|
28
|
-
/** 策略名称 */
|
|
29
|
-
readonly name: string;
|
|
30
|
-
/**
|
|
31
|
-
* 选择执行任务的 Agent
|
|
32
|
-
*
|
|
33
|
-
* @param task - 待执行的任务
|
|
34
|
-
* @param agents - 可用的 Agent 列表
|
|
35
|
-
* @param registry - Agent 注册表
|
|
36
|
-
* @returns 选中的 Agent ID,null 表示没有合适的 Agent
|
|
37
|
-
*/
|
|
38
|
-
selectAgent(task: SwarmTask, agents: Map<string, SwarmAgent>, registry: AgentRegistry): string | null;
|
|
39
|
-
/**
|
|
40
|
-
* 处理任务结果
|
|
41
|
-
*
|
|
42
|
-
* @param task - 已完成的任务
|
|
43
|
-
* @param result - 任务结果
|
|
44
|
-
* @param agents - 所有 Agent
|
|
45
|
-
* @returns 后续任务列表(可选)
|
|
46
|
-
*/
|
|
47
|
-
onTaskComplete?(task: SwarmTask, result: string, agents: Map<string, SwarmAgent>): SwarmTask[];
|
|
48
|
-
}
|
|
49
|
-
/** 轮询策略:依次分配给可用 Agent */
|
|
50
|
-
export declare class RoundRobinStrategy implements OrchestrationStrategy {
|
|
51
|
-
readonly name = "round-robin";
|
|
52
|
-
private _index;
|
|
53
|
-
selectAgent(_task: SwarmTask, agents: Map<string, SwarmAgent>): string | null;
|
|
54
|
-
}
|
|
55
|
-
/** 能力匹配策略:根据任务描述匹配 Agent 能力 */
|
|
56
|
-
export declare class CapabilityStrategy implements OrchestrationStrategy {
|
|
57
|
-
readonly name = "capability-match";
|
|
58
|
-
selectAgent(task: SwarmTask, agents: Map<string, SwarmAgent>, registry: AgentRegistry): string | null;
|
|
59
|
-
}
|
|
60
|
-
/** 流水线策略:按注册顺序依次传递 */
|
|
61
|
-
export declare class PipelineStrategy implements OrchestrationStrategy {
|
|
62
|
-
readonly name = "pipeline";
|
|
63
|
-
private _agentOrder;
|
|
64
|
-
constructor(agentOrder?: string[]);
|
|
65
|
-
setOrder(agentIds: string[]): void;
|
|
66
|
-
selectAgent(task: SwarmTask, agents: Map<string, SwarmAgent>): string | null;
|
|
67
|
-
onTaskComplete(task: SwarmTask, result: string, agents: Map<string, SwarmAgent>): SwarmTask[];
|
|
68
|
-
}
|
|
69
|
-
/**
|
|
70
|
-
* AgentSwarm — 多 Agent 编排器
|
|
71
|
-
*
|
|
72
|
-
* 管理多个 Agent 的生命周期和任务分配。
|
|
73
|
-
*/
|
|
74
|
-
export declare class AgentSwarm {
|
|
75
|
-
readonly id: string;
|
|
76
|
-
readonly name: string;
|
|
77
|
-
readonly topology: SwarmConfig['topology'];
|
|
78
|
-
private _agents;
|
|
79
|
-
private _tasks;
|
|
80
|
-
private _strategy;
|
|
81
|
-
private _registry;
|
|
82
|
-
private _events;
|
|
83
|
-
private _maxConcurrency;
|
|
84
|
-
private _taskTimeoutMs;
|
|
85
|
-
private _running;
|
|
86
|
-
constructor(config: SwarmConfig, registry: AgentRegistry, events: EventBus, strategy?: OrchestrationStrategy);
|
|
87
|
-
/**
|
|
88
|
-
* 添加 Agent 到 Swarm
|
|
89
|
-
*/
|
|
90
|
-
addAgent(agent: SwarmAgent): void;
|
|
91
|
-
/**
|
|
92
|
-
* 从 Swarm 移除 Agent
|
|
93
|
-
*/
|
|
94
|
-
removeAgent(agentId: string): void;
|
|
95
|
-
/**
|
|
96
|
-
* 获取 Agent
|
|
97
|
-
*/
|
|
98
|
-
getAgent(agentId: string): SwarmAgent | undefined;
|
|
99
|
-
/**
|
|
100
|
-
* 列出所有 Agent
|
|
101
|
-
*/
|
|
102
|
-
listAgents(): SwarmAgent[];
|
|
103
|
-
/**
|
|
104
|
-
* 提交任务
|
|
105
|
-
*/
|
|
106
|
-
submitTask(description: string, input: string): SwarmTask;
|
|
107
|
-
/**
|
|
108
|
-
* 执行任务
|
|
109
|
-
*
|
|
110
|
-
* 根据编排策略选择 Agent 并执行任务。
|
|
111
|
-
*/
|
|
112
|
-
executeTask(task: SwarmTask): Promise<SwarmTask>;
|
|
113
|
-
/**
|
|
114
|
-
* 广播任务给所有 Agent
|
|
115
|
-
*/
|
|
116
|
-
broadcastTask(description: string, input: string): Promise<SwarmTask[]>;
|
|
117
|
-
/**
|
|
118
|
-
* 获取任务
|
|
119
|
-
*/
|
|
120
|
-
getTask(taskId: string): SwarmTask | undefined;
|
|
121
|
-
/**
|
|
122
|
-
* 列出所有任务
|
|
123
|
-
*/
|
|
124
|
-
listTasks(): SwarmTask[];
|
|
125
|
-
/**
|
|
126
|
-
* 设置编排策略
|
|
127
|
-
*/
|
|
128
|
-
setStrategy(strategy: OrchestrationStrategy): void;
|
|
129
|
-
/**
|
|
130
|
-
* 获取当前策略
|
|
131
|
-
*/
|
|
132
|
-
getStrategy(): OrchestrationStrategy;
|
|
133
|
-
private _createDefaultStrategy;
|
|
134
|
-
private _emit;
|
|
135
|
-
}
|