@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,49 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* StrategyRouter 类型定义
|
|
3
|
-
*/
|
|
4
|
-
/** 任务复杂度 */
|
|
5
|
-
export type TaskComplexity = 'simple' | 'moderate' | 'complex';
|
|
6
|
-
/** 任务类型 */
|
|
7
|
-
export type TaskCategory = 'question' | 'lookup' | 'analysis' | 'creation' | 'coding' | 'planning' | 'conversation' | 'unknown';
|
|
8
|
-
/** 任务分类结果 */
|
|
9
|
-
export interface TaskClassification {
|
|
10
|
-
/** 任务类型 */
|
|
11
|
-
category: TaskCategory;
|
|
12
|
-
/** 复杂度 */
|
|
13
|
-
complexity: TaskComplexity;
|
|
14
|
-
/** 置信度 0-1 */
|
|
15
|
-
confidence: number;
|
|
16
|
-
/** 是否需要工具 */
|
|
17
|
-
needsTools: boolean;
|
|
18
|
-
/** 是否需要规划 */
|
|
19
|
-
needsPlanning: boolean;
|
|
20
|
-
/** 推理 */
|
|
21
|
-
reasoning?: string;
|
|
22
|
-
}
|
|
23
|
-
/** 推理策略类型 */
|
|
24
|
-
export type StrategyKind = 'direct' | 'chain_of_thought' | 'plan_and_execute' | 'tool_use' | 'reflect' | 'multi_agent';
|
|
25
|
-
/** 推理策略 */
|
|
26
|
-
export interface Strategy {
|
|
27
|
-
/** 策略类型 */
|
|
28
|
-
kind: StrategyKind;
|
|
29
|
-
/** 策略名称 */
|
|
30
|
-
name: string;
|
|
31
|
-
/** 策略描述 */
|
|
32
|
-
description: string;
|
|
33
|
-
/** 系统提示词补充 */
|
|
34
|
-
systemPromptAddition?: string;
|
|
35
|
-
/** 最大迭代次数 */
|
|
36
|
-
maxIterations?: number;
|
|
37
|
-
/** 是否需要反思 */
|
|
38
|
-
needsReflection?: boolean;
|
|
39
|
-
/** 温度调整 */
|
|
40
|
-
temperature?: number;
|
|
41
|
-
}
|
|
42
|
-
export interface TaskClassifier {
|
|
43
|
-
readonly name: string;
|
|
44
|
-
classify(input: string, context?: Record<string, unknown>): Promise<TaskClassification>;
|
|
45
|
-
}
|
|
46
|
-
export interface StrategyRouter {
|
|
47
|
-
readonly name: string;
|
|
48
|
-
select(classification: TaskClassification): Strategy;
|
|
49
|
-
}
|
|
@@ -1,86 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* WorkflowEngine — Workflow 执行引擎
|
|
3
|
-
*
|
|
4
|
-
* 确定性多步骤编排(experimental)。
|
|
5
|
-
* 支持顺序执行、条件分支、循环、并行、错误处理。
|
|
6
|
-
* 与 SessionTask 状态机无关;长流水线如需用户可见任务,经 SessionTaskService 单向登记。
|
|
7
|
-
*/
|
|
8
|
-
import type { WorkflowDefinition, WorkflowStep, WorkflowInstance, WorkflowContext, WorkflowEvent, StepExecutor } from './types.js';
|
|
9
|
-
/** WorkflowEngine 配置 */
|
|
10
|
-
export interface WorkflowEngineConfig {
|
|
11
|
-
/** 步骤执行器 */
|
|
12
|
-
stepExecutor: StepExecutor;
|
|
13
|
-
/** 最大并发步骤数(用于并行) */
|
|
14
|
-
maxConcurrency?: number;
|
|
15
|
-
}
|
|
16
|
-
/**
|
|
17
|
-
* WorkflowEngine
|
|
18
|
-
*
|
|
19
|
-
* 执行 Workflow 定义,管理实例生命周期。
|
|
20
|
-
*/
|
|
21
|
-
export declare class WorkflowEngine {
|
|
22
|
-
private config;
|
|
23
|
-
private definitions;
|
|
24
|
-
private instances;
|
|
25
|
-
constructor(config: WorkflowEngineConfig);
|
|
26
|
-
/**
|
|
27
|
-
* 注册 Workflow 定义
|
|
28
|
-
*/
|
|
29
|
-
register(definition: WorkflowDefinition): void;
|
|
30
|
-
/**
|
|
31
|
-
* 获取 Workflow 定义
|
|
32
|
-
*/
|
|
33
|
-
getDefinition(id: string): WorkflowDefinition | undefined;
|
|
34
|
-
/**
|
|
35
|
-
* 列出所有已注册的 Workflow
|
|
36
|
-
*/
|
|
37
|
-
listDefinitions(): WorkflowDefinition[];
|
|
38
|
-
/**
|
|
39
|
-
* 创建执行实例
|
|
40
|
-
*/
|
|
41
|
-
createInstance(workflowId: string, variables?: Record<string, unknown>): WorkflowInstance;
|
|
42
|
-
/**
|
|
43
|
-
* 获取实例
|
|
44
|
-
*/
|
|
45
|
-
getInstance(id: string): WorkflowInstance | undefined;
|
|
46
|
-
/**
|
|
47
|
-
* 列出所有实例
|
|
48
|
-
*/
|
|
49
|
-
listInstances(): WorkflowInstance[];
|
|
50
|
-
/**
|
|
51
|
-
* 执行 Workflow
|
|
52
|
-
*
|
|
53
|
-
* @param instanceId - 实例 ID
|
|
54
|
-
* @yields WorkflowEvent 事件流
|
|
55
|
-
*/
|
|
56
|
-
execute(instanceId: string): AsyncGenerator<WorkflowEvent>;
|
|
57
|
-
/**
|
|
58
|
-
* 暂停实例
|
|
59
|
-
*/
|
|
60
|
-
pause(instanceId: string): void;
|
|
61
|
-
/**
|
|
62
|
-
* 恢复实例
|
|
63
|
-
*/
|
|
64
|
-
resume(instanceId: string): void;
|
|
65
|
-
/**
|
|
66
|
-
* 取消实例
|
|
67
|
-
*/
|
|
68
|
-
cancel(instanceId: string): void;
|
|
69
|
-
/**
|
|
70
|
-
* 执行步骤(带重试)
|
|
71
|
-
*/
|
|
72
|
-
private executeWithRetry;
|
|
73
|
-
/**
|
|
74
|
-
* 解析下一步
|
|
75
|
-
*/
|
|
76
|
-
private resolveNext;
|
|
77
|
-
}
|
|
78
|
-
/**
|
|
79
|
-
* 简单步骤执行器
|
|
80
|
-
*
|
|
81
|
-
* 用于测试和简单场景。
|
|
82
|
-
* 实际使用时应替换为集成 Agent 的执行器。
|
|
83
|
-
*/
|
|
84
|
-
export declare class SimpleStepExecutor implements StepExecutor {
|
|
85
|
-
execute(step: WorkflowStep, context: WorkflowContext): Promise<unknown>;
|
|
86
|
-
}
|
|
@@ -1,298 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* WorkflowEngine — Workflow 执行引擎
|
|
3
|
-
*
|
|
4
|
-
* 确定性多步骤编排(experimental)。
|
|
5
|
-
* 支持顺序执行、条件分支、循环、并行、错误处理。
|
|
6
|
-
* 与 SessionTask 状态机无关;长流水线如需用户可见任务,经 SessionTaskService 单向登记。
|
|
7
|
-
*/
|
|
8
|
-
import { randomUUID } from 'node:crypto';
|
|
9
|
-
/**
|
|
10
|
-
* WorkflowEngine
|
|
11
|
-
*
|
|
12
|
-
* 执行 Workflow 定义,管理实例生命周期。
|
|
13
|
-
*/
|
|
14
|
-
export class WorkflowEngine {
|
|
15
|
-
config;
|
|
16
|
-
definitions = new Map();
|
|
17
|
-
instances = new Map();
|
|
18
|
-
constructor(config) {
|
|
19
|
-
this.config = config;
|
|
20
|
-
}
|
|
21
|
-
// ================================================================
|
|
22
|
-
// 定义管理
|
|
23
|
-
// ================================================================
|
|
24
|
-
/**
|
|
25
|
-
* 注册 Workflow 定义
|
|
26
|
-
*/
|
|
27
|
-
register(definition) {
|
|
28
|
-
this.definitions.set(definition.id, definition);
|
|
29
|
-
}
|
|
30
|
-
/**
|
|
31
|
-
* 获取 Workflow 定义
|
|
32
|
-
*/
|
|
33
|
-
getDefinition(id) {
|
|
34
|
-
return this.definitions.get(id);
|
|
35
|
-
}
|
|
36
|
-
/**
|
|
37
|
-
* 列出所有已注册的 Workflow
|
|
38
|
-
*/
|
|
39
|
-
listDefinitions() {
|
|
40
|
-
return Array.from(this.definitions.values());
|
|
41
|
-
}
|
|
42
|
-
// ================================================================
|
|
43
|
-
// 实例管理
|
|
44
|
-
// ================================================================
|
|
45
|
-
/**
|
|
46
|
-
* 创建执行实例
|
|
47
|
-
*/
|
|
48
|
-
createInstance(workflowId, variables) {
|
|
49
|
-
const def = this.definitions.get(workflowId);
|
|
50
|
-
if (!def) {
|
|
51
|
-
throw new Error(`Workflow "${workflowId}" not found`);
|
|
52
|
-
}
|
|
53
|
-
const instance = {
|
|
54
|
-
id: `wf-${randomUUID().slice(0, 8)}`,
|
|
55
|
-
definitionId: workflowId,
|
|
56
|
-
status: 'pending',
|
|
57
|
-
currentStep: def.startStep,
|
|
58
|
-
variables: new Map(Object.entries(def.variables ?? {})),
|
|
59
|
-
history: [],
|
|
60
|
-
startedAt: Date.now(),
|
|
61
|
-
};
|
|
62
|
-
// 合并调用方提供的变量
|
|
63
|
-
if (variables) {
|
|
64
|
-
for (const [key, value] of Object.entries(variables)) {
|
|
65
|
-
instance.variables.set(key, value);
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
this.instances.set(instance.id, instance);
|
|
69
|
-
return instance;
|
|
70
|
-
}
|
|
71
|
-
/**
|
|
72
|
-
* 获取实例
|
|
73
|
-
*/
|
|
74
|
-
getInstance(id) {
|
|
75
|
-
return this.instances.get(id);
|
|
76
|
-
}
|
|
77
|
-
/**
|
|
78
|
-
* 列出所有实例
|
|
79
|
-
*/
|
|
80
|
-
listInstances() {
|
|
81
|
-
return Array.from(this.instances.values());
|
|
82
|
-
}
|
|
83
|
-
// ================================================================
|
|
84
|
-
// 执行
|
|
85
|
-
// ================================================================
|
|
86
|
-
/**
|
|
87
|
-
* 执行 Workflow
|
|
88
|
-
*
|
|
89
|
-
* @param instanceId - 实例 ID
|
|
90
|
-
* @yields WorkflowEvent 事件流
|
|
91
|
-
*/
|
|
92
|
-
async *execute(instanceId) {
|
|
93
|
-
const instance = this.instances.get(instanceId);
|
|
94
|
-
if (!instance) {
|
|
95
|
-
throw new Error(`Workflow instance "${instanceId}" not found`);
|
|
96
|
-
}
|
|
97
|
-
const def = this.definitions.get(instance.definitionId);
|
|
98
|
-
if (!def) {
|
|
99
|
-
throw new Error(`Workflow definition "${instance.definitionId}" not found`);
|
|
100
|
-
}
|
|
101
|
-
instance.status = 'running';
|
|
102
|
-
while (instance.currentStep) {
|
|
103
|
-
const step = def.steps.find(s => s.id === instance.currentStep);
|
|
104
|
-
if (!step) {
|
|
105
|
-
yield { type: 'workflow.fail', instanceId, data: { error: `Step "${instance.currentStep}" not found` } };
|
|
106
|
-
instance.status = 'failed';
|
|
107
|
-
return;
|
|
108
|
-
}
|
|
109
|
-
yield { type: 'step.start', instanceId, stepId: step.id };
|
|
110
|
-
const startTime = Date.now();
|
|
111
|
-
step.status = 'running';
|
|
112
|
-
try {
|
|
113
|
-
// 创建执行上下文
|
|
114
|
-
const context = {
|
|
115
|
-
variables: instance.variables,
|
|
116
|
-
history: instance.history,
|
|
117
|
-
};
|
|
118
|
-
// 执行步骤(支持重试)
|
|
119
|
-
const result = await this.executeWithRetry(step, context);
|
|
120
|
-
// 记录执行历史
|
|
121
|
-
const execution = {
|
|
122
|
-
stepId: step.id,
|
|
123
|
-
taskId: step.taskId,
|
|
124
|
-
status: 'completed',
|
|
125
|
-
output: result,
|
|
126
|
-
duration: Date.now() - startTime,
|
|
127
|
-
};
|
|
128
|
-
instance.history.push(execution);
|
|
129
|
-
step.status = 'completed';
|
|
130
|
-
yield { type: 'step.complete', instanceId, stepId: step.id, data: result };
|
|
131
|
-
// 确定下一步
|
|
132
|
-
const nextStep = this.resolveNext(step, result, { variables: instance.variables, history: instance.history });
|
|
133
|
-
instance.currentStep = nextStep ?? '';
|
|
134
|
-
}
|
|
135
|
-
catch (error) {
|
|
136
|
-
const errorMsg = error instanceof Error ? error.message : String(error);
|
|
137
|
-
// 记录失败
|
|
138
|
-
const execution = {
|
|
139
|
-
stepId: step.id,
|
|
140
|
-
taskId: step.taskId,
|
|
141
|
-
status: 'failed',
|
|
142
|
-
error: errorMsg,
|
|
143
|
-
duration: Date.now() - startTime,
|
|
144
|
-
};
|
|
145
|
-
instance.history.push(execution);
|
|
146
|
-
step.status = 'failed';
|
|
147
|
-
yield { type: 'step.fail', instanceId, stepId: step.id, data: { error: errorMsg } };
|
|
148
|
-
// 错误处理
|
|
149
|
-
if (step.onError === 'skip') {
|
|
150
|
-
// 跳过当前步骤,继续下一步
|
|
151
|
-
const nextStep = this.resolveNext(step, undefined, { variables: instance.variables, history: instance.history });
|
|
152
|
-
instance.currentStep = nextStep ?? '';
|
|
153
|
-
continue;
|
|
154
|
-
}
|
|
155
|
-
else if (step.onError === 'abort' || !step.onError) {
|
|
156
|
-
// 中止 Workflow
|
|
157
|
-
instance.status = 'failed';
|
|
158
|
-
instance.completedAt = Date.now();
|
|
159
|
-
yield { type: 'workflow.fail', instanceId, data: { error: errorMsg } };
|
|
160
|
-
return;
|
|
161
|
-
}
|
|
162
|
-
else {
|
|
163
|
-
// 跳转到指定步骤
|
|
164
|
-
instance.currentStep = step.onError;
|
|
165
|
-
continue;
|
|
166
|
-
}
|
|
167
|
-
}
|
|
168
|
-
}
|
|
169
|
-
// 所有步骤完成
|
|
170
|
-
instance.status = 'completed';
|
|
171
|
-
instance.completedAt = Date.now();
|
|
172
|
-
yield { type: 'workflow.complete', instanceId };
|
|
173
|
-
}
|
|
174
|
-
/**
|
|
175
|
-
* 暂停实例
|
|
176
|
-
*/
|
|
177
|
-
pause(instanceId) {
|
|
178
|
-
const instance = this.instances.get(instanceId);
|
|
179
|
-
if (!instance)
|
|
180
|
-
throw new Error(`Instance "${instanceId}" not found`);
|
|
181
|
-
if (instance.status !== 'running') {
|
|
182
|
-
throw new Error(`Instance "${instanceId}" is not running`);
|
|
183
|
-
}
|
|
184
|
-
instance.status = 'paused';
|
|
185
|
-
}
|
|
186
|
-
/**
|
|
187
|
-
* 恢复实例
|
|
188
|
-
*/
|
|
189
|
-
resume(instanceId) {
|
|
190
|
-
const instance = this.instances.get(instanceId);
|
|
191
|
-
if (!instance)
|
|
192
|
-
throw new Error(`Instance "${instanceId}" not found`);
|
|
193
|
-
if (instance.status !== 'paused') {
|
|
194
|
-
throw new Error(`Instance "${instanceId}" is not paused`);
|
|
195
|
-
}
|
|
196
|
-
instance.status = 'running';
|
|
197
|
-
}
|
|
198
|
-
/**
|
|
199
|
-
* 取消实例
|
|
200
|
-
*/
|
|
201
|
-
cancel(instanceId) {
|
|
202
|
-
const instance = this.instances.get(instanceId);
|
|
203
|
-
if (!instance)
|
|
204
|
-
throw new Error(`Instance "${instanceId}" not found`);
|
|
205
|
-
instance.status = 'cancelled';
|
|
206
|
-
instance.completedAt = Date.now();
|
|
207
|
-
}
|
|
208
|
-
// ================================================================
|
|
209
|
-
// 内部方法
|
|
210
|
-
// ================================================================
|
|
211
|
-
/**
|
|
212
|
-
* 执行步骤(带重试)
|
|
213
|
-
*/
|
|
214
|
-
async executeWithRetry(step, context) {
|
|
215
|
-
const maxRetries = step.retryPolicy?.maxRetries ?? 0;
|
|
216
|
-
const delayMs = step.retryPolicy?.delayMs ?? 0;
|
|
217
|
-
let lastError;
|
|
218
|
-
for (let attempt = 0; attempt <= maxRetries; attempt++) {
|
|
219
|
-
try {
|
|
220
|
-
return await this.config.stepExecutor.execute(step, context);
|
|
221
|
-
}
|
|
222
|
-
catch (error) {
|
|
223
|
-
lastError = error instanceof Error ? error : new Error(String(error));
|
|
224
|
-
if (attempt < maxRetries && delayMs > 0) {
|
|
225
|
-
await new Promise(r => setTimeout(r, delayMs));
|
|
226
|
-
}
|
|
227
|
-
}
|
|
228
|
-
}
|
|
229
|
-
throw lastError;
|
|
230
|
-
}
|
|
231
|
-
/**
|
|
232
|
-
* 解析下一步
|
|
233
|
-
*/
|
|
234
|
-
resolveNext(step, result, context) {
|
|
235
|
-
if (!step.next)
|
|
236
|
-
return undefined;
|
|
237
|
-
// 顺序执行
|
|
238
|
-
if (typeof step.next === 'string')
|
|
239
|
-
return step.next;
|
|
240
|
-
// 条件分支
|
|
241
|
-
for (const branch of step.next) {
|
|
242
|
-
let conditionResult = false;
|
|
243
|
-
if (typeof branch.condition === 'function') {
|
|
244
|
-
conditionResult = branch.condition({ ...context, currentResult: result });
|
|
245
|
-
}
|
|
246
|
-
else if (typeof branch.condition === 'string') {
|
|
247
|
-
// 简单表达式求值(安全限制)
|
|
248
|
-
try {
|
|
249
|
-
const fn = new Function('context', `return ${branch.condition}`);
|
|
250
|
-
conditionResult = fn({ ...context, currentResult: result });
|
|
251
|
-
}
|
|
252
|
-
catch {
|
|
253
|
-
conditionResult = false;
|
|
254
|
-
}
|
|
255
|
-
}
|
|
256
|
-
if (conditionResult) {
|
|
257
|
-
return branch.target;
|
|
258
|
-
}
|
|
259
|
-
}
|
|
260
|
-
return undefined;
|
|
261
|
-
}
|
|
262
|
-
}
|
|
263
|
-
// ================================================================
|
|
264
|
-
// 内置步骤执行器
|
|
265
|
-
// ================================================================
|
|
266
|
-
/**
|
|
267
|
-
* 简单步骤执行器
|
|
268
|
-
*
|
|
269
|
-
* 用于测试和简单场景。
|
|
270
|
-
* 实际使用时应替换为集成 Agent 的执行器。
|
|
271
|
-
*/
|
|
272
|
-
export class SimpleStepExecutor {
|
|
273
|
-
async execute(step, context) {
|
|
274
|
-
switch (step.type) {
|
|
275
|
-
case 'agent':
|
|
276
|
-
return { type: 'agent', result: `Agent executed: ${step.config.prompt ?? step.name}` };
|
|
277
|
-
case 'tool':
|
|
278
|
-
return { type: 'tool', result: `Tool executed: ${step.config.toolName}` };
|
|
279
|
-
case 'condition':
|
|
280
|
-
if (typeof step.config.expression === 'string') {
|
|
281
|
-
try {
|
|
282
|
-
const fn = new Function('context', `return ${step.config.expression}`);
|
|
283
|
-
return { type: 'condition', result: fn(context) };
|
|
284
|
-
}
|
|
285
|
-
catch {
|
|
286
|
-
return { type: 'condition', result: false };
|
|
287
|
-
}
|
|
288
|
-
}
|
|
289
|
-
return { type: 'condition', result: false };
|
|
290
|
-
case 'loop':
|
|
291
|
-
return { type: 'loop', result: 'Loop completed' };
|
|
292
|
-
case 'human':
|
|
293
|
-
return { type: 'human', result: 'Human approval required' };
|
|
294
|
-
default:
|
|
295
|
-
return { type: step.type, result: 'Executed' };
|
|
296
|
-
}
|
|
297
|
-
}
|
|
298
|
-
}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Workflow 引擎
|
|
3
|
-
*
|
|
4
|
-
* 确定性多步骤编排(experimental)。
|
|
5
|
-
* 支持顺序执行、条件分支、循环、并行、错误处理。
|
|
6
|
-
*/
|
|
7
|
-
export { WorkflowEngine, SimpleStepExecutor } from './engine.js';
|
|
8
|
-
export type { WorkflowEngineConfig } from './engine.js';
|
|
9
|
-
export type { WorkflowDefinition, WorkflowStep, WorkflowInstance, WorkflowContext, WorkflowEvent, WorkflowStatus, StepType, StepStatus, StepExecution, StepExecutor, StepConfig, ConditionalNext, RetryPolicy, } from './types.js';
|
|
@@ -1,143 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Workflow 引擎 — 类型定义
|
|
3
|
-
*
|
|
4
|
-
* 确定性多步骤编排(experimental)。
|
|
5
|
-
* Workflow 定义执行顺序和条件分支;与 SessionTask 状态机无关。
|
|
6
|
-
*/
|
|
7
|
-
/** Workflow 步骤类型 */
|
|
8
|
-
export type StepType = 'agent' | 'tool' | 'condition' | 'loop' | 'parallel' | 'human' | 'subworkflow';
|
|
9
|
-
/** 步骤状态 */
|
|
10
|
-
export type StepStatus = 'pending' | 'running' | 'completed' | 'failed' | 'skipped' | 'cancelled';
|
|
11
|
-
/** Workflow 状态 */
|
|
12
|
-
export type WorkflowStatus = 'pending' | 'running' | 'paused' | 'completed' | 'failed' | 'cancelled';
|
|
13
|
-
/** 条件分支 */
|
|
14
|
-
export interface ConditionalNext {
|
|
15
|
-
/** 条件表达式(返回 boolean) */
|
|
16
|
-
condition: string | ((context: WorkflowContext) => boolean);
|
|
17
|
-
/** 目标步骤 ID */
|
|
18
|
-
target: string;
|
|
19
|
-
}
|
|
20
|
-
/** Workflow 步骤 */
|
|
21
|
-
export interface WorkflowStep {
|
|
22
|
-
/** 步骤 ID */
|
|
23
|
-
id: string;
|
|
24
|
-
/** 步骤类型 */
|
|
25
|
-
type: StepType;
|
|
26
|
-
/** 步骤名称 */
|
|
27
|
-
name: string;
|
|
28
|
-
/** 步骤配置 */
|
|
29
|
-
config: StepConfig;
|
|
30
|
-
/** 下一步(字符串表示顺序执行,数组表示条件分支) */
|
|
31
|
-
next?: string | ConditionalNext[];
|
|
32
|
-
/** 错误处理策略 */
|
|
33
|
-
onError?: 'retry' | 'skip' | 'abort' | string;
|
|
34
|
-
/** 重试策略 */
|
|
35
|
-
retryPolicy?: RetryPolicy;
|
|
36
|
-
/** 步骤状态(运行时) */
|
|
37
|
-
status?: StepStatus;
|
|
38
|
-
/** 关联的 Task ID(运行时) */
|
|
39
|
-
taskId?: string;
|
|
40
|
-
}
|
|
41
|
-
/** 重试策略 */
|
|
42
|
-
export interface RetryPolicy {
|
|
43
|
-
/** 最大重试次数 */
|
|
44
|
-
maxRetries: number;
|
|
45
|
-
/** 重试间隔(毫秒) */
|
|
46
|
-
delayMs: number;
|
|
47
|
-
}
|
|
48
|
-
/** 步骤配置 */
|
|
49
|
-
export interface StepConfig {
|
|
50
|
-
agentId?: string;
|
|
51
|
-
prompt?: string;
|
|
52
|
-
systemPrompt?: string;
|
|
53
|
-
toolName?: string;
|
|
54
|
-
toolArgs?: Record<string, unknown>;
|
|
55
|
-
expression?: string;
|
|
56
|
-
llmJudge?: boolean;
|
|
57
|
-
maxIterations?: number;
|
|
58
|
-
until?: string | ((context: WorkflowContext) => boolean);
|
|
59
|
-
approvalRequired?: boolean;
|
|
60
|
-
approver?: string;
|
|
61
|
-
timeout?: number;
|
|
62
|
-
metadata?: Record<string, unknown>;
|
|
63
|
-
}
|
|
64
|
-
/** Workflow 定义 */
|
|
65
|
-
export interface WorkflowDefinition {
|
|
66
|
-
/** Workflow ID */
|
|
67
|
-
id: string;
|
|
68
|
-
/** Workflow 名称 */
|
|
69
|
-
name: string;
|
|
70
|
-
/** 描述 */
|
|
71
|
-
description: string;
|
|
72
|
-
/** 版本 */
|
|
73
|
-
version: string;
|
|
74
|
-
/** 步骤列表 */
|
|
75
|
-
steps: WorkflowStep[];
|
|
76
|
-
/** 起始步骤 ID */
|
|
77
|
-
startStep: string;
|
|
78
|
-
/** 初始变量 */
|
|
79
|
-
variables?: Record<string, unknown>;
|
|
80
|
-
}
|
|
81
|
-
/** Workflow 执行上下文 */
|
|
82
|
-
export interface WorkflowContext {
|
|
83
|
-
/** 变量 */
|
|
84
|
-
variables: Map<string, unknown>;
|
|
85
|
-
/** 当前步骤结果 */
|
|
86
|
-
currentResult?: unknown;
|
|
87
|
-
/** 步骤历史 */
|
|
88
|
-
history: StepExecution[];
|
|
89
|
-
}
|
|
90
|
-
/** Workflow 执行实例 */
|
|
91
|
-
export interface WorkflowInstance {
|
|
92
|
-
/** 实例 ID */
|
|
93
|
-
id: string;
|
|
94
|
-
/** Workflow 定义 ID */
|
|
95
|
-
definitionId: string;
|
|
96
|
-
/** 状态 */
|
|
97
|
-
status: WorkflowStatus;
|
|
98
|
-
/** 当前步骤 ID */
|
|
99
|
-
currentStep: string;
|
|
100
|
-
/** 变量 */
|
|
101
|
-
variables: Map<string, unknown>;
|
|
102
|
-
/** 步骤执行历史 */
|
|
103
|
-
history: StepExecution[];
|
|
104
|
-
/** 开始时间 */
|
|
105
|
-
startedAt: number;
|
|
106
|
-
/** 完成时间 */
|
|
107
|
-
completedAt?: number;
|
|
108
|
-
}
|
|
109
|
-
/** 步骤执行记录 */
|
|
110
|
-
export interface StepExecution {
|
|
111
|
-
/** 步骤 ID */
|
|
112
|
-
stepId: string;
|
|
113
|
-
/** 关联的任务 ID */
|
|
114
|
-
taskId?: string;
|
|
115
|
-
/** 执行状态 */
|
|
116
|
-
status: StepStatus;
|
|
117
|
-
/** 输入 */
|
|
118
|
-
input?: unknown;
|
|
119
|
-
/** 输出 */
|
|
120
|
-
output?: unknown;
|
|
121
|
-
/** 耗时(毫秒) */
|
|
122
|
-
duration: number;
|
|
123
|
-
/** 错误信息 */
|
|
124
|
-
error?: string;
|
|
125
|
-
}
|
|
126
|
-
/** Workflow 事件 */
|
|
127
|
-
export interface WorkflowEvent {
|
|
128
|
-
type: 'step.start' | 'step.complete' | 'step.fail' | 'workflow.complete' | 'workflow.fail' | 'human.required';
|
|
129
|
-
instanceId: string;
|
|
130
|
-
stepId?: string;
|
|
131
|
-
data?: unknown;
|
|
132
|
-
}
|
|
133
|
-
/** 步骤执行器接口 */
|
|
134
|
-
export interface StepExecutor {
|
|
135
|
-
/**
|
|
136
|
-
* 执行步骤
|
|
137
|
-
*
|
|
138
|
-
* @param step - 步骤定义
|
|
139
|
-
* @param context - 执行上下文
|
|
140
|
-
* @returns 执行结果
|
|
141
|
-
*/
|
|
142
|
-
execute(step: WorkflowStep, context: WorkflowContext): Promise<unknown>;
|
|
143
|
-
}
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* ApprovalManager — 审批管理器
|
|
3
|
-
*
|
|
4
|
-
* 管理审批请求的生命周期:创建 → 等待决策 → 应用结果。
|
|
5
|
-
* 支持决策缓存(session 级 / 永久)。
|
|
6
|
-
*/
|
|
7
|
-
import type { ToolCall } from '@octopi-agent/core/types/messages.js';
|
|
8
|
-
import type { ApprovalProvider, ApprovalPolicy, ApprovalLevel } from './types.js';
|
|
9
|
-
/** ApprovalManager 配置 */
|
|
10
|
-
export interface ApprovalManagerConfig {
|
|
11
|
-
/** 全局审批级别 */
|
|
12
|
-
level: ApprovalLevel;
|
|
13
|
-
/** 请求超时(毫秒,默认 60s) */
|
|
14
|
-
timeoutMs?: number;
|
|
15
|
-
/** 审批提供者(TUI/Gateway 实现) */
|
|
16
|
-
provider?: ApprovalProvider;
|
|
17
|
-
}
|
|
18
|
-
export declare class ApprovalManager {
|
|
19
|
-
private config;
|
|
20
|
-
private decisionCache;
|
|
21
|
-
constructor(config: ApprovalManagerConfig);
|
|
22
|
-
/**
|
|
23
|
-
* 判断是否需要审批,需要时请求审批
|
|
24
|
-
*
|
|
25
|
-
* @returns true 表示放行,false 表示拒绝
|
|
26
|
-
*/
|
|
27
|
-
check(toolCall: ToolCall, riskLevel: string, riskDescription: string): Promise<boolean>;
|
|
28
|
-
private needsApproval;
|
|
29
|
-
private getCachedDecision;
|
|
30
|
-
}
|
|
31
|
-
/** 创建默认审批策略 */
|
|
32
|
-
export declare function createApprovalPolicy(level: ApprovalLevel): ApprovalPolicy;
|