@excitedjs/dreamux 0.26.0-beta.265 → 0.26.0
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/CHANGELOG.json +393 -0
- package/CHANGELOG.md +71 -1
- package/README.md +47 -34
- package/dist/admin/client.js +18 -7
- package/dist/admin/client.js.map +1 -1
- package/dist/admin/socket.js +15 -104
- package/dist/admin/socket.js.map +1 -1
- package/dist/agent-runtime/capabilities.js +4 -17
- package/dist/agent-runtime/capabilities.js.map +1 -1
- package/dist/agent-runtime/catalog.js.map +1 -1
- package/dist/agent-runtime/external-provider.js.map +1 -1
- package/dist/agent-runtime/host-context.js +1 -12
- package/dist/agent-runtime/host-context.js.map +1 -1
- package/dist/agent-runtime/host-paths.js +1 -1
- package/dist/agent-runtime/host-paths.js.map +1 -1
- package/dist/agent-runtime/index.js +7 -0
- package/dist/agent-runtime/index.js.map +1 -1
- package/dist/agent-runtime/skill-sources.js +23 -6
- package/dist/agent-runtime/skill-sources.js.map +1 -1
- package/dist/channel/catalog.js.map +1 -1
- package/dist/channel/external-channel-provider.js.map +1 -1
- package/dist/cli/commands/daemon.js +5 -8
- package/dist/cli/commands/daemon.js.map +1 -1
- package/dist/cli/commands/dispatcher.js +11 -15
- package/dist/cli/commands/dispatcher.js.map +1 -1
- package/dist/cli/commands/index.js +4 -4
- package/dist/cli/commands/index.js.map +1 -1
- package/dist/cli/commands/mcp.js +2 -4
- package/dist/cli/commands/mcp.js.map +1 -1
- package/dist/cli/commands/onboard.js +0 -4
- package/dist/cli/commands/onboard.js.map +1 -1
- package/dist/cli/commands/parse.js +1 -1
- package/dist/cli/commands/parse.js.map +1 -1
- package/dist/cli/commands/serve.js +3 -2
- package/dist/cli/commands/serve.js.map +1 -1
- package/dist/cli/commands/status.js +3 -3
- package/dist/cli/commands/status.js.map +1 -1
- package/dist/cli/commands/types.js +25 -3
- package/dist/cli/commands/types.js.map +1 -1
- package/dist/cli/commands/uninstall.js +2 -8
- package/dist/cli/commands/uninstall.js.map +1 -1
- package/dist/cli/doctor-plugins.js +44 -0
- package/dist/cli/doctor-plugins.js.map +1 -0
- package/dist/cli/doctor-types.js +2 -0
- package/dist/cli/doctor-types.js.map +1 -0
- package/dist/cli/doctor.js +48 -125
- package/dist/cli/doctor.js.map +1 -1
- package/dist/cli/dreamux.js +2 -30
- package/dist/cli/dreamux.js.map +1 -1
- package/dist/cli/server.js +55 -70
- package/dist/cli/server.js.map +1 -1
- package/dist/command/errors.js +43 -2
- package/dist/command/errors.js.map +1 -1
- package/dist/command/host.js +10 -17
- package/dist/command/host.js.map +1 -1
- package/dist/command/payload.js +0 -9
- package/dist/command/payload.js.map +1 -1
- package/dist/command/port.js +0 -4
- package/dist/command/port.js.map +1 -1
- package/dist/command/registry.js +0 -4
- package/dist/command/registry.js.map +1 -1
- package/dist/command/schema.js.map +1 -1
- package/dist/command/types.js.map +1 -0
- package/dist/command/validate.js +22 -41
- package/dist/command/validate.js.map +1 -1
- package/dist/config/commands.js +46 -0
- package/dist/config/commands.js.map +1 -0
- package/dist/config/config.js +155 -169
- package/dist/config/config.js.map +1 -1
- package/dist/config/load.js +138 -0
- package/dist/config/load.js.map +1 -0
- package/dist/config/service.js +196 -0
- package/dist/config/service.js.map +1 -0
- package/dist/daemon/{service-control.js → control.js} +15 -16
- package/dist/daemon/control.js.map +1 -0
- package/dist/daemon/environment.js +353 -0
- package/dist/daemon/environment.js.map +1 -0
- package/dist/daemon/host.js +16 -0
- package/dist/daemon/host.js.map +1 -0
- package/dist/daemon/install.js +167 -69
- package/dist/daemon/install.js.map +1 -1
- package/dist/daemon/status.js +87 -0
- package/dist/daemon/status.js.map +1 -0
- package/dist/{cli/service-status-parse.js → daemon/unit.js} +90 -12
- package/dist/daemon/unit.js.map +1 -0
- package/dist/{service/mcp/descriptor.js → mcp/launch.js} +3 -7
- package/dist/mcp/launch.js.map +1 -0
- package/dist/mcp/server.js +9 -5
- package/dist/mcp/server.js.map +1 -1
- package/dist/mcp/shim.js +18 -16
- package/dist/mcp/shim.js.map +1 -1
- package/dist/onboard/config-files.js +12 -26
- package/dist/onboard/config-files.js.map +1 -1
- package/dist/onboard/run.js +47 -66
- package/dist/onboard/run.js.map +1 -1
- package/dist/onboard/uninstall.js +59 -42
- package/dist/onboard/uninstall.js.map +1 -1
- package/dist/onboard/wizard.js +33 -18
- package/dist/onboard/wizard.js.map +1 -1
- package/dist/{onboard/commands.js → platform/command-runner.js} +7 -3
- package/dist/platform/command-runner.js.map +1 -0
- package/dist/platform/deduplicate.js +32 -0
- package/dist/platform/deduplicate.js.map +1 -0
- package/dist/{state → platform}/dispatcher-id.js +1 -1
- package/dist/platform/dispatcher-id.js.map +1 -0
- package/dist/platform/errors.js +23 -23
- package/dist/platform/errors.js.map +1 -1
- package/dist/{onboard/ledger.js → platform/file-ledger.js} +13 -38
- package/dist/platform/file-ledger.js.map +1 -0
- package/dist/platform/history-page.js +62 -0
- package/dist/platform/history-page.js.map +1 -0
- package/dist/platform/in-flight-work.js.map +1 -0
- package/dist/platform/instance-lock.js +95 -0
- package/dist/platform/instance-lock.js.map +1 -0
- package/dist/platform/json-value.js +26 -15
- package/dist/platform/json-value.js.map +1 -1
- package/dist/platform/jsonl.js.map +1 -1
- package/dist/platform/logger.js +5 -5
- package/dist/platform/logger.js.map +1 -1
- package/dist/platform/package-bin.js +3 -1
- package/dist/platform/package-bin.js.map +1 -1
- package/dist/platform/paths.js +42 -69
- package/dist/platform/paths.js.map +1 -1
- package/dist/platform/runtime-sockets.js +7 -2
- package/dist/platform/runtime-sockets.js.map +1 -1
- package/dist/platform/serial-queue.js +22 -0
- package/dist/platform/serial-queue.js.map +1 -0
- package/dist/platform/shutdown-errors.js.map +1 -0
- package/dist/platform/work-fence.js +30 -0
- package/dist/platform/work-fence.js.map +1 -0
- package/dist/plugin/hooks.js +407 -0
- package/dist/plugin/hooks.js.map +1 -0
- package/dist/plugin/host.js +97 -0
- package/dist/plugin/host.js.map +1 -0
- package/dist/plugin/loader.js +250 -0
- package/dist/plugin/loader.js.map +1 -0
- package/dist/provider-diagnostics.js +12 -8
- package/dist/provider-diagnostics.js.map +1 -1
- package/dist/registry/builtins.js +49 -45
- package/dist/registry/builtins.js.map +1 -1
- package/dist/registry/index.js +10 -2
- package/dist/registry/index.js.map +1 -1
- package/dist/registry/provider-loader.js +41 -61
- package/dist/registry/provider-loader.js.map +1 -1
- package/dist/registry/provider-ref.js.map +1 -1
- package/dist/registry/registry.js +14 -22
- package/dist/registry/registry.js.map +1 -1
- package/dist/{command/catalog.js → server/command-catalog.js} +14 -5
- package/dist/server/command-catalog.js.map +1 -0
- package/dist/server/command-host.js +2 -0
- package/dist/server/command-host.js.map +1 -0
- package/dist/server-commands.js +1 -1
- package/dist/server-commands.js.map +1 -1
- package/dist/server.js +70 -129
- package/dist/server.js.map +1 -1
- package/dist/service/{agent-entity/activity-reader.js → agent/activity.js} +86 -34
- package/dist/service/agent/activity.js.map +1 -0
- package/dist/service/{teammate-service/admission-ledger.js → agent/admission.js} +66 -1
- package/dist/service/agent/admission.js.map +1 -0
- package/dist/service/{channel-submission.js → agent/channel-submission.js} +5 -5
- package/dist/service/agent/channel-submission.js.map +1 -0
- package/dist/service/{teammate-collection → agent}/commands.js +38 -50
- package/dist/service/agent/commands.js.map +1 -0
- package/dist/service/{teammate-service → agent}/completion-renderer.js +30 -5
- package/dist/service/agent/completion-renderer.js.map +1 -0
- package/dist/service/agent/errors.js.map +1 -0
- package/dist/service/agent/factory.js +78 -0
- package/dist/service/agent/factory.js.map +1 -0
- package/dist/service/{agent-entity/types.js → agent/identity.js} +28 -34
- package/dist/service/agent/identity.js.map +1 -0
- package/dist/service/agent/index.js +769 -0
- package/dist/service/agent/index.js.map +1 -0
- package/dist/service/agent/mcp.js +420 -0
- package/dist/service/agent/mcp.js.map +1 -0
- package/dist/service/agent/records.js +74 -0
- package/dist/service/agent/records.js.map +1 -0
- package/dist/service/agent/requests.js +172 -0
- package/dist/service/agent/requests.js.map +1 -0
- package/dist/service/{teammate-service/runtime-owner.js → agent/runtime-generation.js} +81 -79
- package/dist/service/agent/runtime-generation.js.map +1 -0
- package/dist/service/agent/runtime-id.js +22 -0
- package/dist/service/agent/runtime-id.js.map +1 -0
- package/dist/service/{agent-entity → agent}/runtime-state.js +33 -40
- package/dist/service/agent/runtime-state.js.map +1 -0
- package/dist/service/agent/service-types.js +28 -0
- package/dist/service/agent/service-types.js.map +1 -0
- package/dist/service/{teammate-service/index.js → agent/service.js} +236 -102
- package/dist/service/agent/service.js.map +1 -0
- package/dist/service/{agent-entity/identity-store.js → agent/store.js} +175 -96
- package/dist/service/agent/store.js.map +1 -0
- package/dist/service/agent/submission.js.map +1 -0
- package/dist/service/{teammate-collection → agent}/system-prompt.js +7 -3
- package/dist/service/agent/system-prompt.js.map +1 -0
- package/dist/service/agent/turn.js +89 -0
- package/dist/service/agent/turn.js.map +1 -0
- package/dist/service/agent/types.js.map +1 -0
- package/dist/service/channel-service/commands.js +7 -3
- package/dist/service/channel-service/commands.js.map +1 -1
- package/dist/{channel → service/channel-service}/core-port.js +6 -5
- package/dist/service/channel-service/core-port.js.map +1 -0
- package/dist/service/channel-service/index.js +211 -93
- package/dist/service/channel-service/index.js.map +1 -1
- package/dist/service/channel-service/mcp-delegate.js +8 -9
- package/dist/service/channel-service/mcp-delegate.js.map +1 -1
- package/dist/service/completion-router/index.js +27 -27
- package/dist/service/completion-router/index.js.map +1 -1
- package/dist/{channel → service/dispatcher-core-events}/conversation-projection.js +9 -7
- package/dist/service/dispatcher-core-events/conversation-projection.js.map +1 -0
- package/dist/service/dispatcher-core-events/index.js +76 -68
- package/dist/service/dispatcher-core-events/index.js.map +1 -1
- package/dist/service/dispatcher-core-events/seal.js +1 -24
- package/dist/service/dispatcher-core-events/seal.js.map +1 -1
- package/dist/service/dispatcher-service/agent.js +267 -45
- package/dist/service/dispatcher-service/agent.js.map +1 -1
- package/dist/service/dispatcher-service/base-prompt.js +2 -2
- package/dist/service/dispatcher-service/base-prompt.js.map +1 -1
- package/dist/service/dispatcher-service/index.js +139 -378
- package/dist/service/dispatcher-service/index.js.map +1 -1
- package/dist/service/dispatcher-service/lifecycle.js +230 -0
- package/dist/service/dispatcher-service/lifecycle.js.map +1 -0
- package/dist/{daemon → service/dispatcher-service}/restart-intent.js +17 -38
- package/dist/service/dispatcher-service/restart-intent.js.map +1 -0
- package/dist/service/dispatcher-workspace.js +10 -23
- package/dist/service/dispatcher-workspace.js.map +1 -1
- package/dist/service/dispatchers/commands.js +30 -31
- package/dist/service/dispatchers/commands.js.map +1 -1
- package/dist/service/dispatchers/index.js +92 -64
- package/dist/service/dispatchers/index.js.map +1 -1
- package/dist/service/index.js +2 -2
- package/dist/service/index.js.map +1 -1
- package/dist/{mcp → service/mcp}/catalog.js +11 -48
- package/dist/service/mcp/catalog.js.map +1 -0
- package/dist/service/mcp/commands.js +3 -3
- package/dist/service/mcp/commands.js.map +1 -1
- package/dist/service/mcp/dispatch-reminders.js +1 -1
- package/dist/service/mcp/dispatch-reminders.js.map +1 -1
- package/dist/service/mcp/identity-version.js +14 -0
- package/dist/service/mcp/identity-version.js.map +1 -1
- package/dist/service/mcp/leases.js +12 -33
- package/dist/service/mcp/leases.js.map +1 -1
- package/dist/service/mcp/tool-metadata.js +15 -76
- package/dist/service/mcp/tool-metadata.js.map +1 -1
- package/dist/service/name-allocator.js +2 -3
- package/dist/service/name-allocator.js.map +1 -1
- package/dist/service/scheduler/commands.js +7 -19
- package/dist/service/scheduler/commands.js.map +1 -1
- package/dist/service/scheduler/errors.js +1 -1
- package/dist/service/scheduler/errors.js.map +1 -1
- package/dist/service/scheduler/{service.js → index.js} +175 -142
- package/dist/service/scheduler/index.js.map +1 -0
- package/dist/service/scheduler/{mcp-delegate.js → mcp.js} +61 -58
- package/dist/service/scheduler/mcp.js.map +1 -0
- package/dist/service/scheduler/requests.js +60 -0
- package/dist/service/scheduler/requests.js.map +1 -0
- package/dist/service/scheduler/store.js +183 -151
- package/dist/service/scheduler/store.js.map +1 -1
- package/dist/service/scheduler/types.js +1 -33
- package/dist/service/scheduler/types.js.map +1 -1
- package/dist/service/{team-collection → team}/commands.js +45 -59
- package/dist/service/team/commands.js.map +1 -0
- package/dist/service/{team-collection → team}/create-request.js +8 -20
- package/dist/service/team/create-request.js.map +1 -0
- package/dist/service/{team-collection → team}/errors.js +7 -10
- package/dist/service/team/errors.js.map +1 -0
- package/dist/service/team/index.js +817 -0
- package/dist/service/team/index.js.map +1 -0
- package/dist/service/team/leader-mcp.js +42 -0
- package/dist/service/team/leader-mcp.js.map +1 -0
- package/dist/service/team/leader.js +157 -0
- package/dist/service/team/leader.js.map +1 -0
- package/dist/service/team/mcp.js +328 -0
- package/dist/service/team/mcp.js.map +1 -0
- package/dist/service/{team-collection/types.js → team/requests.js} +64 -15
- package/dist/service/team/requests.js.map +1 -0
- package/dist/service/team/service.js +903 -0
- package/dist/service/team/service.js.map +1 -0
- package/dist/service/team/store.js +373 -0
- package/dist/service/team/store.js.map +1 -0
- package/dist/service/team/team-summary.js.map +1 -0
- package/dist/service/team/teams-port.js +2 -0
- package/dist/service/team/teams-port.js.map +1 -0
- package/dist/service/team/types.js +22 -0
- package/dist/service/team/types.js.map +1 -0
- package/dist/service/workflow-service/commands.js +5 -6
- package/dist/service/workflow-service/commands.js.map +1 -1
- package/dist/service/workflow-service/errors.js +2 -0
- package/dist/service/workflow-service/errors.js.map +1 -1
- package/dist/service/workflow-service/index.js +80 -112
- package/dist/service/workflow-service/index.js.map +1 -1
- package/dist/service/workflow-service/journal.js +90 -6
- package/dist/service/workflow-service/journal.js.map +1 -1
- package/dist/service/workflow-service/limits.js +20 -9
- package/dist/service/workflow-service/limits.js.map +1 -1
- package/dist/service/workflow-service/mcp.js +171 -0
- package/dist/service/workflow-service/mcp.js.map +1 -0
- package/dist/service/workflow-service/protocol.js +72 -1
- package/dist/service/workflow-service/protocol.js.map +1 -1
- package/dist/service/workflow-service/requests.js +70 -0
- package/dist/service/workflow-service/requests.js.map +1 -0
- package/dist/service/workflow-service/run.js +258 -145
- package/dist/service/workflow-service/run.js.map +1 -1
- package/dist/service/workflow-service/runner-process.js +0 -19
- package/dist/service/workflow-service/runner-process.js.map +1 -1
- package/dist/service/workflow-service/runner.js +6 -30
- package/dist/service/workflow-service/runner.js.map +1 -1
- package/dist/service/workflow-service/script-compiler.js +7 -9
- package/dist/service/workflow-service/script-compiler.js.map +1 -1
- package/dist/service/workflow-service/{run-support.js → semaphore.js} +1 -30
- package/dist/service/workflow-service/semaphore.js.map +1 -0
- package/dist/service/workflow-service/store.js +105 -25
- package/dist/service/workflow-service/store.js.map +1 -1
- package/dist/service/workflow-service/types.js +1 -77
- package/dist/service/workflow-service/types.js.map +1 -1
- package/dist/service/worktree/manager.js +29 -62
- package/dist/service/worktree/manager.js.map +1 -1
- package/dist/service/worktree/paths.js +4 -1
- package/dist/service/worktree/paths.js.map +1 -1
- package/dist/service/worktree/repo-request.js +38 -14
- package/dist/service/worktree/repo-request.js.map +1 -1
- package/dist/service/worktree/types.js +2 -0
- package/dist/service/worktree/types.js.map +1 -0
- package/dist/service/worktree/workspaces.js +27 -34
- package/dist/service/worktree/workspaces.js.map +1 -1
- package/package.json +13 -8
- package/skills/dispatcher/dreamux-maintenance/SKILL.md +5 -4
- package/skills/dispatcher/dreamux-maintenance/references/builtin-bootstrap.md +50 -0
- package/skills/dispatcher/dreamux-maintenance/references/builtin-codex.md +4 -5
- package/skills/dispatcher/dreamux-maintenance/references/builtin-feishu.md +69 -11
- package/skills/dispatcher/dreamux-maintenance/references/config-envelope.md +77 -12
- package/skills/dispatcher/dreamux-maintenance/references/feishu-access-v3.md +39 -24
- package/skills/dispatcher/dreamux-maintenance/references/service-lifecycle.md +105 -37
- package/dist/channel/conversation-projection.js.map +0 -1
- package/dist/channel/core-port.js.map +0 -1
- package/dist/cli/server-ctl.js +0 -163
- package/dist/cli/server-ctl.js.map +0 -1
- package/dist/cli/service-status-parse.js.map +0 -1
- package/dist/command/catalog.js.map +0 -1
- package/dist/config/config-helpers.js +0 -100
- package/dist/config/config-helpers.js.map +0 -1
- package/dist/daemon/restart-intent.js.map +0 -1
- package/dist/daemon/service-control.js.map +0 -1
- package/dist/mcp/catalog.js.map +0 -1
- package/dist/mcp/failure-text.js +0 -46
- package/dist/mcp/failure-text.js.map +0 -1
- package/dist/onboard/commands.js.map +0 -1
- package/dist/onboard/ledger.js.map +0 -1
- package/dist/onboard/service-node.js +0 -183
- package/dist/onboard/service-node.js.map +0 -1
- package/dist/onboard/service.js +0 -310
- package/dist/onboard/service.js.map +0 -1
- package/dist/platform/atomic-write.js +0 -63
- package/dist/platform/atomic-write.js.map +0 -1
- package/dist/platform/error-info.js +0 -11
- package/dist/platform/error-info.js.map +0 -1
- package/dist/platform/json-document-store.js +0 -54
- package/dist/platform/json-document-store.js.map +0 -1
- package/dist/service/agent-entity/activity-errors.js +0 -71
- package/dist/service/agent-entity/activity-errors.js.map +0 -1
- package/dist/service/agent-entity/activity-reader.js.map +0 -1
- package/dist/service/agent-entity/agent-config.js +0 -48
- package/dist/service/agent-entity/agent-config.js.map +0 -1
- package/dist/service/agent-entity/history-query.js +0 -60
- package/dist/service/agent-entity/history-query.js.map +0 -1
- package/dist/service/agent-entity/identity-store.js.map +0 -1
- package/dist/service/agent-entity/read-helpers.js +0 -172
- package/dist/service/agent-entity/read-helpers.js.map +0 -1
- package/dist/service/agent-entity/runtime-profile.js +0 -53
- package/dist/service/agent-entity/runtime-profile.js.map +0 -1
- package/dist/service/agent-entity/runtime-state.js.map +0 -1
- package/dist/service/agent-entity/types.js.map +0 -1
- package/dist/service/channel-service/mcp-delegates.js +0 -21
- package/dist/service/channel-service/mcp-delegates.js.map +0 -1
- package/dist/service/channel-service/types.js.map +0 -1
- package/dist/service/channel-submission.js.map +0 -1
- package/dist/service/closed-fact.js +0 -49
- package/dist/service/closed-fact.js.map +0 -1
- package/dist/service/deduplicate.js +0 -42
- package/dist/service/deduplicate.js.map +0 -1
- package/dist/service/dispatcher-core-events/scoped-source.js +0 -59
- package/dist/service/dispatcher-core-events/scoped-source.js.map +0 -1
- package/dist/service/dispatcher-service/dispatcher-workflows.js +0 -50
- package/dist/service/dispatcher-service/dispatcher-workflows.js.map +0 -1
- package/dist/service/dispatcher-service/identity.js +0 -97
- package/dist/service/dispatcher-service/identity.js.map +0 -1
- package/dist/service/dispatcher-service/inbound-task-drain.js +0 -37
- package/dist/service/dispatcher-service/inbound-task-drain.js.map +0 -1
- package/dist/service/dispatcher-service/input-source-lifecycle.js +0 -312
- package/dist/service/dispatcher-service/input-source-lifecycle.js.map +0 -1
- package/dist/service/dispatcher-service/input-source-start-rollback.js +0 -53
- package/dist/service/dispatcher-service/input-source-start-rollback.js.map +0 -1
- package/dist/service/dispatcher-service/mcp-delegates.js +0 -67
- package/dist/service/dispatcher-service/mcp-delegates.js.map +0 -1
- package/dist/service/dispatcher-service/restart-notice.js +0 -27
- package/dist/service/dispatcher-service/restart-notice.js.map +0 -1
- package/dist/service/dispatcher-service/runnable-channel.js +0 -13
- package/dist/service/dispatcher-service/runnable-channel.js.map +0 -1
- package/dist/service/dispatcher-service/runtime-helpers.js +0 -11
- package/dist/service/dispatcher-service/runtime-helpers.js.map +0 -1
- package/dist/service/dispatcher-service/runtime-status.js +0 -35
- package/dist/service/dispatcher-service/runtime-status.js.map +0 -1
- package/dist/service/dispatcher-service/team-leader-handle.js +0 -29
- package/dist/service/dispatcher-service/team-leader-handle.js.map +0 -1
- package/dist/service/dispatcher-service/team-runtime-stop.js +0 -13
- package/dist/service/dispatcher-service/team-runtime-stop.js.map +0 -1
- package/dist/service/dispatcher-service/teammate-ops.js +0 -14
- package/dist/service/dispatcher-service/teammate-ops.js.map +0 -1
- package/dist/service/frozen-snapshot.js +0 -16
- package/dist/service/frozen-snapshot.js.map +0 -1
- package/dist/service/in-flight-work.js.map +0 -1
- package/dist/service/legacy-state.js +0 -119
- package/dist/service/legacy-state.js.map +0 -1
- package/dist/service/mcp/descriptor.js.map +0 -1
- package/dist/service/scheduler/mcp-delegate.js.map +0 -1
- package/dist/service/scheduler/service.js.map +0 -1
- package/dist/service/serial-queue.js +0 -64
- package/dist/service/serial-queue.js.map +0 -1
- package/dist/service/shutdown-errors.js.map +0 -1
- package/dist/service/team-collection/commands.js.map +0 -1
- package/dist/service/team-collection/create-request.js.map +0 -1
- package/dist/service/team-collection/errors.js.map +0 -1
- package/dist/service/team-collection/index.js +0 -304
- package/dist/service/team-collection/index.js.map +0 -1
- package/dist/service/team-collection/mcp-delegate.js +0 -389
- package/dist/service/team-collection/mcp-delegate.js.map +0 -1
- package/dist/service/team-collection/read-helpers.js +0 -66
- package/dist/service/team-collection/read-helpers.js.map +0 -1
- package/dist/service/team-collection/read-model.js +0 -120
- package/dist/service/team-collection/read-model.js.map +0 -1
- package/dist/service/team-collection/roster-reader.js +0 -52
- package/dist/service/team-collection/roster-reader.js.map +0 -1
- package/dist/service/team-collection/runtime-registry.js +0 -369
- package/dist/service/team-collection/runtime-registry.js.map +0 -1
- package/dist/service/team-collection/store.js +0 -320
- package/dist/service/team-collection/store.js.map +0 -1
- package/dist/service/team-collection/types.js.map +0 -1
- package/dist/service/team-collection/worktree-cleanup.js +0 -45
- package/dist/service/team-collection/worktree-cleanup.js.map +0 -1
- package/dist/service/team-service/closing.js +0 -279
- package/dist/service/team-service/closing.js.map +0 -1
- package/dist/service/team-service/collaborators.js +0 -82
- package/dist/service/team-service/collaborators.js.map +0 -1
- package/dist/service/team-service/completion-targets.js +0 -72
- package/dist/service/team-service/completion-targets.js.map +0 -1
- package/dist/service/team-service/index.js +0 -559
- package/dist/service/team-service/index.js.map +0 -1
- package/dist/service/team-service/leader-agent.js +0 -170
- package/dist/service/team-service/leader-agent.js.map +0 -1
- package/dist/service/team-service/roster-projection.js +0 -69
- package/dist/service/team-service/roster-projection.js.map +0 -1
- package/dist/service/team-service/team-summary.js.map +0 -1
- package/dist/service/team-service/types.js +0 -61
- package/dist/service/team-service/types.js.map +0 -1
- package/dist/service/teammate-collection/commands.js.map +0 -1
- package/dist/service/teammate-collection/dissolve-members.js +0 -44
- package/dist/service/teammate-collection/dissolve-members.js.map +0 -1
- package/dist/service/teammate-collection/errors.js.map +0 -1
- package/dist/service/teammate-collection/index.js +0 -497
- package/dist/service/teammate-collection/index.js.map +0 -1
- package/dist/service/teammate-collection/mcp-delegate.js +0 -210
- package/dist/service/teammate-collection/mcp-delegate.js.map +0 -1
- package/dist/service/teammate-collection/mcp-tool-descriptors.js +0 -421
- package/dist/service/teammate-collection/mcp-tool-descriptors.js.map +0 -1
- package/dist/service/teammate-collection/system-prompt.js.map +0 -1
- package/dist/service/teammate-collection/types.js.map +0 -1
- package/dist/service/teammate-service/admission-ledger.js.map +0 -1
- package/dist/service/teammate-service/completion-renderer.js.map +0 -1
- package/dist/service/teammate-service/factory.js +0 -5
- package/dist/service/teammate-service/factory.js.map +0 -1
- package/dist/service/teammate-service/index.js.map +0 -1
- package/dist/service/teammate-service/runtime-owner.js.map +0 -1
- package/dist/service/teammate-service/submission.js.map +0 -1
- package/dist/service/teammate-service/turn-coordinator.js +0 -93
- package/dist/service/teammate-service/turn-coordinator.js.map +0 -1
- package/dist/service/teammate-service/turn-recording.js +0 -178
- package/dist/service/teammate-service/turn-recording.js.map +0 -1
- package/dist/service/teammate-service/types.js +0 -12
- package/dist/service/teammate-service/types.js.map +0 -1
- package/dist/service/workflow-service/agent-policy.js +0 -6
- package/dist/service/workflow-service/agent-policy.js.map +0 -1
- package/dist/service/workflow-service/json-args.js +0 -72
- package/dist/service/workflow-service/json-args.js.map +0 -1
- package/dist/service/workflow-service/run-support.js.map +0 -1
- package/dist/service/workflow-service/run-terminal.js +0 -111
- package/dist/service/workflow-service/run-terminal.js.map +0 -1
- package/dist/state/dispatcher-id.js.map +0 -1
- package/dist/state/dispatcher-store.js +0 -73
- package/dist/state/dispatcher-store.js.map +0 -1
- /package/dist/{service/channel-service → command}/types.js +0 -0
- /package/dist/{service → platform}/in-flight-work.js +0 -0
- /package/dist/{service → platform}/shutdown-errors.js +0 -0
- /package/dist/service/{teammate-collection → agent}/errors.js +0 -0
- /package/dist/service/{teammate-service → agent}/submission.js +0 -0
- /package/dist/service/{teammate-collection → agent}/types.js +0 -0
- /package/dist/service/{team-service → team}/team-summary.js +0 -0
|
@@ -1,43 +1,90 @@
|
|
|
1
|
-
import { isUnsupportedFeatureError } from '@excitedjs/dreamux-utils';
|
|
2
|
-
import {
|
|
3
|
-
import { InFlightWork } from '
|
|
4
|
-
import {
|
|
1
|
+
import { errorInfo, errorMessage, isUnsupportedFeatureError, } from '@excitedjs/dreamux-utils';
|
|
2
|
+
import { ForkedWorkflowRunner } from './runner-process.js';
|
|
3
|
+
import { InFlightWork } from '../../platform/in-flight-work.js';
|
|
4
|
+
import { workflowRunJournalPath } from '../../platform/paths.js';
|
|
5
|
+
import { throwSettledFailures } from '../../platform/shutdown-errors.js';
|
|
5
6
|
import { AGENT_TASK_SOURCE } from '../submission-sources.js';
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
|
|
7
|
+
import { WorkflowPersistenceError } from './errors.js';
|
|
8
|
+
import { WorkflowJournal, } from './journal.js';
|
|
9
|
+
import { MAX_AGENTS } from './limits.js';
|
|
10
|
+
import { isWorkflowRunnerChildMessage, normalizeAgentOptions, } from './protocol.js';
|
|
11
|
+
import { WorkflowSemaphore } from './semaphore.js';
|
|
12
|
+
/** Appended to every agent's system prompt: this call's output is consumed
|
|
13
|
+
* by the workflow, not shown to a human. */
|
|
14
|
+
export const WORKFLOW_AGENT_SYSTEM_PROMPT = 'You are executing one agent call inside a Dreamux workflow. Your final ' +
|
|
15
|
+
'response is the return value consumed by the workflow, not a human-facing ' +
|
|
16
|
+
'progress message. Return only the requested value. When an output schema is ' +
|
|
17
|
+
"provided, use the runtime's structured-output mechanism and satisfy the " +
|
|
18
|
+
'schema exactly.';
|
|
19
|
+
/** `value` when it is a non-empty (after trimming) string, otherwise `null`. */
|
|
20
|
+
function nonEmpty(value) {
|
|
21
|
+
if (value === undefined || value.trim() === '')
|
|
22
|
+
return null;
|
|
23
|
+
return value;
|
|
24
|
+
}
|
|
11
25
|
/** One live Workflow entity with direct locked TeamMate and Turn ownership. */
|
|
12
26
|
export class WorkflowRun {
|
|
13
27
|
deps;
|
|
14
28
|
record;
|
|
29
|
+
/** This run's own durability journal, bound from its own scope and run id
|
|
30
|
+
* — no owner hands one in. */
|
|
31
|
+
journal;
|
|
15
32
|
runner;
|
|
16
33
|
semaphore;
|
|
17
|
-
terminal;
|
|
18
34
|
calls = new Map();
|
|
19
35
|
materializations = new InFlightWork();
|
|
20
36
|
runnerMessageTasks = new InFlightWork();
|
|
21
37
|
agentTasks = new InFlightWork();
|
|
22
38
|
unlockedHandles = new Set();
|
|
23
|
-
mutationTail = Promise.resolve();
|
|
24
39
|
runnerMessageTail = Promise.resolve();
|
|
40
|
+
/** Flips at *receipt* of a `run_result` message, before it is queued behind
|
|
41
|
+
* `runnerMessageTail` — distinct from `terminalIntent`, which is set only
|
|
42
|
+
* once that queued message is actually processed. Guards the receive-time
|
|
43
|
+
* window between the two: a second `run_result` or an `onExit` racing in
|
|
44
|
+
* it must still be dropped. */
|
|
25
45
|
runnerTerminalMessageSeen = false;
|
|
46
|
+
/** The full record {@link finalize} will commit, computed once after
|
|
47
|
+
* teardown and memoized so a retried finalize reuses the same `ended_at`
|
|
48
|
+
* instead of recomputing a different one — unlike `terminalIntent`, which
|
|
49
|
+
* is reserved before teardown even starts. */
|
|
26
50
|
terminalCandidate = null;
|
|
27
|
-
terminalJournalCommitted = false;
|
|
28
51
|
/**
|
|
29
52
|
* The terminal report this run still owes its initiator; `null` once it is
|
|
30
53
|
* delivered, or once a stop made it not news: the initiator or its own scope
|
|
31
54
|
* fence asked for the stop, so the party that ended the run would read it.
|
|
32
55
|
*/
|
|
33
|
-
|
|
34
|
-
|
|
56
|
+
recipient;
|
|
57
|
+
/** Set once, by whichever of {@link reserveStop}/{@link requestTerminal}
|
|
58
|
+
* wins. */
|
|
59
|
+
terminalIntent = null;
|
|
60
|
+
/** Memoized {@link finalize} task; cleared on failure so a retry re-runs
|
|
61
|
+
* it. */
|
|
62
|
+
terminalTask = null;
|
|
63
|
+
announceSettled;
|
|
64
|
+
/**
|
|
65
|
+
* Resolves once this run is durably over: terminal record written, terminal
|
|
66
|
+
* completion delivered, nothing left to retry.
|
|
67
|
+
*
|
|
68
|
+
* It is a fact the run states about itself, not an instruction. The owner
|
|
69
|
+
* that holds the run decides what being over means for its own bookkeeping;
|
|
70
|
+
* the run does not reach up and remove itself from a collection it is not
|
|
71
|
+
* allowed to know about.
|
|
72
|
+
*/
|
|
73
|
+
settled;
|
|
35
74
|
constructor(deps) {
|
|
36
75
|
this.deps = deps;
|
|
37
76
|
this.record = deps.record;
|
|
38
|
-
this.
|
|
77
|
+
this.journal = new WorkflowJournal(workflowRunJournalPath({
|
|
78
|
+
dispatcherId: deps.record.dispatcher_id,
|
|
79
|
+
teamId: deps.record.team_id,
|
|
80
|
+
runId: deps.record.run_id,
|
|
81
|
+
}));
|
|
82
|
+
this.recipient = deps.recipient;
|
|
39
83
|
this.semaphore = new WorkflowSemaphore(deps.record.max_concurrency);
|
|
40
|
-
this.
|
|
84
|
+
this.settled = new Promise((resolve) => {
|
|
85
|
+
this.announceSettled = resolve;
|
|
86
|
+
});
|
|
87
|
+
this.runner = new ForkedWorkflowRunner(deps.runnerEntryPath, {
|
|
41
88
|
onMessage: (message) => this.receiveRunnerMessage(message),
|
|
42
89
|
onExit: (exit) => {
|
|
43
90
|
deps.log.info({
|
|
@@ -46,41 +93,35 @@ export class WorkflowRun {
|
|
|
46
93
|
signal: exit.signal,
|
|
47
94
|
}, 'workflow runner exited');
|
|
48
95
|
if (!this.runnerTerminalMessageSeen &&
|
|
49
|
-
this.
|
|
50
|
-
this.
|
|
96
|
+
this.terminalRequested === null) {
|
|
97
|
+
this.observeTerminal('failed', null, `workflow runner exited before reporting a result (code=${String(exit.code)}, signal=${String(exit.signal)})`);
|
|
51
98
|
}
|
|
52
99
|
},
|
|
53
100
|
onError: (error) => {
|
|
54
101
|
deps.log.error({ run_id: this.record.run_id, err: errorInfo(error) }, 'workflow runner error');
|
|
55
|
-
if (this.
|
|
56
|
-
this.
|
|
102
|
+
if (this.terminalRequested === null) {
|
|
103
|
+
this.observeTerminal('failed', null, error.message);
|
|
57
104
|
}
|
|
58
105
|
},
|
|
59
106
|
});
|
|
60
|
-
this.terminal = new WorkflowRunTerminal({
|
|
61
|
-
runId: this.record.run_id,
|
|
62
|
-
status: () => this.record.status,
|
|
63
|
-
abortRunner: () => this.runner.send({ type: 'abort' }),
|
|
64
|
-
closeAdmission: (status) => {
|
|
65
|
-
this.semaphore.close(new Error(`workflow ${status}`));
|
|
66
|
-
// Reached once, when the first terminal intent is reserved. Only a
|
|
67
|
-
// stop reserves `stopped`; a completed or failed intent that won first
|
|
68
|
-
// keeps its report, and a delivery already under way is never behind
|
|
69
|
-
// this call.
|
|
70
|
-
if (status === 'stopped')
|
|
71
|
-
this.deliverTerminal = null;
|
|
72
|
-
},
|
|
73
|
-
finalize: (status, result, error) => this.finalize(status, result, error),
|
|
74
|
-
log: deps.log,
|
|
75
|
-
});
|
|
76
107
|
}
|
|
77
|
-
/**
|
|
78
|
-
|
|
108
|
+
/**
|
|
109
|
+
* The run's last *committed* value — what `workflow_status`/`workflow_list`
|
|
110
|
+
* read — never the in-progress draft `this.record` becomes between a
|
|
111
|
+
* mutation and the {@link persist} call that publishes it. Reachable only
|
|
112
|
+
* after `initialize()` has published this run's first committed record
|
|
113
|
+
* (the owner does not register this `WorkflowRun` until then), so the
|
|
114
|
+
* handle is always loaded here.
|
|
115
|
+
*/
|
|
79
116
|
snapshot() {
|
|
80
|
-
|
|
117
|
+
const current = this.deps.store.handle(this.record.run_id).current;
|
|
118
|
+
if (current === null) {
|
|
119
|
+
throw new Error(`workflow run ${JSON.stringify(this.record.run_id)} has no committed record`);
|
|
120
|
+
}
|
|
121
|
+
return structuredClone(current);
|
|
81
122
|
}
|
|
82
123
|
async initialize() {
|
|
83
|
-
await this.
|
|
124
|
+
await this.journal.create({
|
|
84
125
|
kind: 'run',
|
|
85
126
|
version: 1,
|
|
86
127
|
run_id: this.record.run_id,
|
|
@@ -94,41 +135,117 @@ export class WorkflowRun {
|
|
|
94
135
|
}
|
|
95
136
|
async start(script, args) {
|
|
96
137
|
try {
|
|
97
|
-
if (this.
|
|
98
|
-
await this.
|
|
138
|
+
if (this.terminalRequested !== null) {
|
|
139
|
+
await this.stop();
|
|
99
140
|
return;
|
|
100
141
|
}
|
|
101
142
|
await this.runner.start();
|
|
102
|
-
if (this.
|
|
103
|
-
await this.
|
|
143
|
+
if (this.terminalRequested !== null) {
|
|
144
|
+
await this.stop();
|
|
104
145
|
return;
|
|
105
146
|
}
|
|
106
147
|
await this.runner.send({ type: 'run_start', script, args });
|
|
107
148
|
}
|
|
108
149
|
catch (error) {
|
|
109
|
-
await this.
|
|
150
|
+
await this.requestTerminal('failed', null, errorMessage(error));
|
|
110
151
|
}
|
|
111
152
|
}
|
|
112
153
|
async stop() {
|
|
113
|
-
|
|
154
|
+
if (this.terminalIntent === null && this.record.status !== 'running') {
|
|
155
|
+
return this.record.status;
|
|
156
|
+
}
|
|
157
|
+
this.reserveStop();
|
|
158
|
+
await this.ensureTerminalTask();
|
|
159
|
+
return (this.terminalRequested ?? this.record.status);
|
|
160
|
+
}
|
|
161
|
+
requestStop() {
|
|
162
|
+
this.reserveStop();
|
|
163
|
+
}
|
|
164
|
+
get terminalRequested() {
|
|
165
|
+
return this.terminalIntent?.status ?? null;
|
|
166
|
+
}
|
|
167
|
+
/** Gates a new `agent_start` and an `emit` phase/log update: no terminal
|
|
168
|
+
* intent reserved, and `record.status` — the committed fact, kept even
|
|
169
|
+
* though a live run cannot leave `running` without first reserving one —
|
|
170
|
+
* still says `running`. */
|
|
171
|
+
get terminalAccepting() {
|
|
172
|
+
return this.terminalIntent === null && this.record.status === 'running';
|
|
114
173
|
}
|
|
115
|
-
|
|
116
|
-
this.
|
|
174
|
+
get terminalSuppressDelivery() {
|
|
175
|
+
return this.terminalIntent !== null;
|
|
176
|
+
}
|
|
177
|
+
/** Reserve the `stopped` intent and signal the runner; a no-op once an
|
|
178
|
+
* intent is already reserved or the run is no longer `running`. */
|
|
179
|
+
reserveStop() {
|
|
180
|
+
if (this.terminalIntent !== null || this.record.status !== 'running') {
|
|
181
|
+
return;
|
|
182
|
+
}
|
|
183
|
+
this.terminalIntent = { status: 'stopped', result: null, error: null };
|
|
184
|
+
this.closeOnTerminalIntent('stopped');
|
|
185
|
+
this.deps.log.info({ run_id: this.record.run_id }, 'stopping workflow run');
|
|
186
|
+
void this.runner.send({ type: 'abort' }).catch((error) => {
|
|
187
|
+
this.deps.log.warn({ run_id: this.record.run_id, err: errorInfo(error) }, 'workflow abort IPC failed; killing runner');
|
|
188
|
+
});
|
|
189
|
+
}
|
|
190
|
+
/** Reserve an already-known status/result/error, then return the shared
|
|
191
|
+
* {@link finalize} task; a no-op reservation once an intent exists, but the
|
|
192
|
+
* task is still returned so every caller converges on the same wait. */
|
|
193
|
+
requestTerminal(status, result, error) {
|
|
194
|
+
if (this.terminalIntent === null) {
|
|
195
|
+
this.terminalIntent = { status, result, error };
|
|
196
|
+
this.closeOnTerminalIntent(status);
|
|
197
|
+
}
|
|
198
|
+
return this.ensureTerminalTask();
|
|
199
|
+
}
|
|
200
|
+
/** Fire-and-forget {@link requestTerminal}, for an observed terminal fact
|
|
201
|
+
* (a runner exit) rather than one the caller itself caused. */
|
|
202
|
+
observeTerminal(status, result, error) {
|
|
203
|
+
void this.requestTerminal(status, result, error).catch((terminalError) => {
|
|
204
|
+
this.deps.log.error({ run_id: this.record.run_id, err: errorInfo(terminalError) }, 'workflow terminal transition failed');
|
|
205
|
+
});
|
|
206
|
+
}
|
|
207
|
+
/** Reached once, when the first terminal intent is reserved: no further
|
|
208
|
+
* Agent may acquire a concurrency slot, and — only for a stop — the
|
|
209
|
+
* initiator no longer gets a completion push, since the party that ended
|
|
210
|
+
* the run would read it itself. A completed or failed intent that won the
|
|
211
|
+
* race keeps its report. */
|
|
212
|
+
closeOnTerminalIntent(status) {
|
|
213
|
+
this.semaphore.close(new Error(`workflow ${status}`));
|
|
214
|
+
if (status === 'stopped')
|
|
215
|
+
this.recipient = null;
|
|
216
|
+
}
|
|
217
|
+
/** The one retryable {@link finalize} task, shared by every caller. */
|
|
218
|
+
ensureTerminalTask() {
|
|
219
|
+
if (this.terminalTask !== null)
|
|
220
|
+
return this.terminalTask;
|
|
221
|
+
const intent = this.terminalIntent;
|
|
222
|
+
if (intent === null)
|
|
223
|
+
return Promise.resolve();
|
|
224
|
+
const task = this.finalize(intent.status, intent.result, intent.error)
|
|
225
|
+
.then(() => {
|
|
226
|
+
this.announceSettled();
|
|
227
|
+
})
|
|
228
|
+
.catch((error) => {
|
|
229
|
+
if (this.terminalTask === task)
|
|
230
|
+
this.terminalTask = null;
|
|
231
|
+
throw error;
|
|
232
|
+
});
|
|
233
|
+
this.terminalTask = task;
|
|
234
|
+
return task;
|
|
117
235
|
}
|
|
118
236
|
receiveRunnerMessage(message) {
|
|
119
237
|
if (!isWorkflowRunnerChildMessage(message)) {
|
|
120
238
|
this.deps.log.warn({ run_id: this.record.run_id }, 'ignoring malformed workflow runner message');
|
|
121
239
|
return;
|
|
122
240
|
}
|
|
123
|
-
if (this.runnerTerminalMessageSeen ||
|
|
124
|
-
this.terminal.requested !== null)
|
|
241
|
+
if (this.runnerTerminalMessageSeen || this.terminalRequested !== null)
|
|
125
242
|
return;
|
|
126
243
|
if (message.type === 'run_result')
|
|
127
244
|
this.runnerTerminalMessageSeen = true;
|
|
128
245
|
const task = this.runnerMessageTail
|
|
129
246
|
.then(() => this.handleRunnerMessage(message))
|
|
130
247
|
.catch((error) => {
|
|
131
|
-
this.
|
|
248
|
+
this.observeTerminal('failed', null, errorMessage(error));
|
|
132
249
|
});
|
|
133
250
|
this.runnerMessageTail = task;
|
|
134
251
|
if (message.type !== 'run_result')
|
|
@@ -140,16 +257,15 @@ export class WorkflowRun {
|
|
|
140
257
|
await this.handleAgentStart(message);
|
|
141
258
|
return;
|
|
142
259
|
case 'emit':
|
|
143
|
-
if (this.
|
|
144
|
-
this.terminal.requested !== null)
|
|
260
|
+
if (!this.terminalAccepting)
|
|
145
261
|
return;
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
await this.
|
|
262
|
+
if (message.kind === 'phase')
|
|
263
|
+
this.record.phase = message.message;
|
|
264
|
+
else
|
|
265
|
+
this.record.last_log = message.message;
|
|
266
|
+
this.record.updated_at = Date.now();
|
|
267
|
+
await this.persist(async () => {
|
|
268
|
+
await this.journal.append({
|
|
153
269
|
kind: message.kind,
|
|
154
270
|
message: message.message,
|
|
155
271
|
created_at: this.record.updated_at,
|
|
@@ -158,16 +274,14 @@ export class WorkflowRun {
|
|
|
158
274
|
});
|
|
159
275
|
return;
|
|
160
276
|
case 'run_result':
|
|
161
|
-
if (this.
|
|
277
|
+
if (this.terminalRequested !== null)
|
|
162
278
|
return;
|
|
163
|
-
await this.
|
|
279
|
+
await this.requestTerminal(message.status === 'completed' ? 'completed' : 'failed', message.status === 'completed' ? (message.result ?? null) : null, message.status === 'completed' ? null : message.error);
|
|
164
280
|
return;
|
|
165
281
|
}
|
|
166
282
|
}
|
|
167
283
|
async handleAgentStart(message) {
|
|
168
|
-
if (!this.
|
|
169
|
-
this.record.status !== 'running' ||
|
|
170
|
-
this.terminal.requested !== null) {
|
|
284
|
+
if (!this.terminalAccepting) {
|
|
171
285
|
await this.sendAgentError(message.index, 'workflow is no longer running');
|
|
172
286
|
return;
|
|
173
287
|
}
|
|
@@ -187,7 +301,7 @@ export class WorkflowRun {
|
|
|
187
301
|
await this.sendAgentError(message.index, errorMessage(error));
|
|
188
302
|
return;
|
|
189
303
|
}
|
|
190
|
-
const createdAt =
|
|
304
|
+
const createdAt = Date.now();
|
|
191
305
|
const record = {
|
|
192
306
|
index: message.index,
|
|
193
307
|
name: null,
|
|
@@ -206,13 +320,12 @@ export class WorkflowRun {
|
|
|
206
320
|
handle: null,
|
|
207
321
|
turn: null,
|
|
208
322
|
resultCandidate: null,
|
|
209
|
-
resultJournalCommitted: false,
|
|
210
323
|
completed: false,
|
|
211
324
|
};
|
|
212
325
|
this.calls.set(message.index, call);
|
|
213
326
|
this.record.agents.push(record);
|
|
214
327
|
this.record.updated_at = createdAt;
|
|
215
|
-
await this.
|
|
328
|
+
await this.persist(() => this.deps.store.write(this.record));
|
|
216
329
|
this.deps.log.info({
|
|
217
330
|
run_id: this.record.run_id,
|
|
218
331
|
index: message.index,
|
|
@@ -227,30 +340,26 @@ export class WorkflowRun {
|
|
|
227
340
|
let releaseSlot = null;
|
|
228
341
|
try {
|
|
229
342
|
releaseSlot = await this.semaphore.acquire();
|
|
230
|
-
if (this.
|
|
343
|
+
if (this.terminalRequested !== null) {
|
|
231
344
|
await this.completeAgent(call, 'stopped', null, null);
|
|
232
345
|
return;
|
|
233
346
|
}
|
|
234
347
|
call.record.status = 'running';
|
|
235
348
|
call.record.phase = call.options.phase ?? this.record.phase;
|
|
236
|
-
this.record.updated_at =
|
|
237
|
-
await this.
|
|
238
|
-
if (this.
|
|
349
|
+
this.record.updated_at = Date.now();
|
|
350
|
+
await this.persist(() => this.deps.store.write(this.record));
|
|
351
|
+
if (this.terminalRequested !== null) {
|
|
239
352
|
await this.completeAgent(call, 'stopped', null, null);
|
|
240
353
|
return;
|
|
241
354
|
}
|
|
242
|
-
const materialization = this.deps.createLocked({
|
|
355
|
+
const materialization = this.deps.teammates.createLocked({
|
|
243
356
|
name: nonEmpty(call.options.label) ??
|
|
244
357
|
`workflow-${this.record.run_id}-${call.record.index + 1}`,
|
|
245
358
|
prompt,
|
|
246
359
|
intent: call.options.intent ??
|
|
247
360
|
`Workflow ${this.record.run_id} agent ${call.record.index + 1}`,
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
: {}),
|
|
251
|
-
...(call.options.identity !== undefined
|
|
252
|
-
? { identity: call.options.identity }
|
|
253
|
-
: {}),
|
|
361
|
+
agentRuntime: call.options.agentType,
|
|
362
|
+
identity: call.options.identity,
|
|
254
363
|
}, {
|
|
255
364
|
systemPromptAppend: [WORKFLOW_AGENT_SYSTEM_PROMPT],
|
|
256
365
|
outputSchema: call.options.schema,
|
|
@@ -260,10 +369,10 @@ export class WorkflowRun {
|
|
|
260
369
|
const handle = await materialization;
|
|
261
370
|
call.handle = handle;
|
|
262
371
|
call.record.name = handle.name;
|
|
263
|
-
const submittedAt =
|
|
372
|
+
const submittedAt = Date.now();
|
|
264
373
|
this.record.updated_at = submittedAt;
|
|
265
|
-
await this.
|
|
266
|
-
await this.
|
|
374
|
+
await this.persist(async () => {
|
|
375
|
+
await this.journal.append({
|
|
267
376
|
kind: 'submit',
|
|
268
377
|
index: call.record.index,
|
|
269
378
|
name: handle.name,
|
|
@@ -271,7 +380,7 @@ export class WorkflowRun {
|
|
|
271
380
|
});
|
|
272
381
|
await this.deps.store.write(this.record);
|
|
273
382
|
});
|
|
274
|
-
if (this.
|
|
383
|
+
if (this.terminalRequested !== null) {
|
|
275
384
|
await this.completeAgent(call, 'stopped', null, null);
|
|
276
385
|
return;
|
|
277
386
|
}
|
|
@@ -279,10 +388,10 @@ export class WorkflowRun {
|
|
|
279
388
|
prompt,
|
|
280
389
|
// A Workflow step is work one Agent handed to another, exactly like an
|
|
281
390
|
// MCP spawn; who scheduled it is already the turn's own identity.
|
|
391
|
+
// The step's output schema is already bound at creation time (above,
|
|
392
|
+
// via CreateLockedTeammateOptions) and cannot vary per submission —
|
|
393
|
+
// WorkflowTeammateSubmitInput carries no outputSchema field.
|
|
282
394
|
source: AGENT_TASK_SOURCE,
|
|
283
|
-
...(call.options.schema !== undefined
|
|
284
|
-
? { outputSchema: call.options.schema }
|
|
285
|
-
: {}),
|
|
286
395
|
});
|
|
287
396
|
this.deps.log.info({
|
|
288
397
|
run_id: this.record.run_id,
|
|
@@ -294,16 +403,16 @@ export class WorkflowRun {
|
|
|
294
403
|
}
|
|
295
404
|
catch (error) {
|
|
296
405
|
if (error instanceof WorkflowPersistenceError) {
|
|
297
|
-
this.
|
|
406
|
+
this.observeTerminal('failed', null, error.message);
|
|
298
407
|
return;
|
|
299
408
|
}
|
|
300
409
|
if (!call.completed) {
|
|
301
|
-
const stopped = this.
|
|
410
|
+
const stopped = this.terminalRequested !== null;
|
|
302
411
|
const publicError = errorMessage(error);
|
|
303
412
|
await this.completeAgent(call, stopped ? 'stopped' : 'failed', null, stopped ? null : publicError, !stopped && isUnsupportedFeatureError(error, 'outputSchema')
|
|
304
413
|
? publicError
|
|
305
414
|
: undefined).catch((persistenceError) => {
|
|
306
|
-
this.
|
|
415
|
+
this.observeTerminal('failed', null, errorMessage(persistenceError));
|
|
307
416
|
});
|
|
308
417
|
}
|
|
309
418
|
}
|
|
@@ -327,15 +436,10 @@ export class WorkflowRun {
|
|
|
327
436
|
return;
|
|
328
437
|
}
|
|
329
438
|
call.turn = admission.turn;
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
catch (error) {
|
|
335
|
-
const persistenceError = errorMessage(error);
|
|
336
|
-
await this.terminal.failAfterNotification(persistenceError, () => this.completeAgent(call, 'failed', null, persistenceError, persistenceError, true));
|
|
337
|
-
return;
|
|
338
|
-
}
|
|
439
|
+
// Never rejects: EntityTurn.settled folds every rejection into a
|
|
440
|
+
// `{status: 'failed', ...}` outcome (service/agent/turn.ts) before it
|
|
441
|
+
// resolves.
|
|
442
|
+
const outcome = await admission.turn.settled;
|
|
339
443
|
if (outcome.status !== 'completed') {
|
|
340
444
|
await this.completeAgent(call, outcome.status, null, outcome.status === 'failed' ? outcome.error.message : null);
|
|
341
445
|
return;
|
|
@@ -363,7 +467,7 @@ export class WorkflowRun {
|
|
|
363
467
|
}
|
|
364
468
|
await this.completeAgent(call, error === null ? 'completed' : 'failed', result, error, runnerError);
|
|
365
469
|
}
|
|
366
|
-
async completeAgent(call, status, result, error, runnerError
|
|
470
|
+
async completeAgent(call, status, result, error, runnerError) {
|
|
367
471
|
if (call.completed)
|
|
368
472
|
return;
|
|
369
473
|
call.resultCandidate ??= {
|
|
@@ -372,7 +476,7 @@ export class WorkflowRun {
|
|
|
372
476
|
status,
|
|
373
477
|
result: status === 'completed' ? result : null,
|
|
374
478
|
error,
|
|
375
|
-
settled_at: call.record.settled_at ??
|
|
479
|
+
settled_at: call.record.settled_at ?? Date.now(),
|
|
376
480
|
};
|
|
377
481
|
const candidate = call.resultCandidate;
|
|
378
482
|
call.record.status = candidate.status;
|
|
@@ -380,11 +484,8 @@ export class WorkflowRun {
|
|
|
380
484
|
call.record.error = candidate.error;
|
|
381
485
|
call.record.settled_at = candidate.settled_at;
|
|
382
486
|
this.record.updated_at = candidate.settled_at;
|
|
383
|
-
await this.
|
|
384
|
-
|
|
385
|
-
await this.deps.journal.ensureAgentResult(candidate);
|
|
386
|
-
call.resultJournalCommitted = true;
|
|
387
|
-
}
|
|
487
|
+
await this.persist(async () => {
|
|
488
|
+
await this.journal.ensureAgentResult(candidate);
|
|
388
489
|
await this.deps.store.write(this.record);
|
|
389
490
|
});
|
|
390
491
|
call.completed = true;
|
|
@@ -394,7 +495,7 @@ export class WorkflowRun {
|
|
|
394
495
|
producer: call.record.name,
|
|
395
496
|
status: candidate.status,
|
|
396
497
|
}, 'workflow agent settled');
|
|
397
|
-
if (this.
|
|
498
|
+
if (this.terminalSuppressDelivery)
|
|
398
499
|
return;
|
|
399
500
|
if (runnerError !== undefined) {
|
|
400
501
|
await this.runner.send({
|
|
@@ -412,34 +513,44 @@ export class WorkflowRun {
|
|
|
412
513
|
}
|
|
413
514
|
}
|
|
414
515
|
async sendAgentError(index, error) {
|
|
415
|
-
if (this.
|
|
516
|
+
if (this.terminalSuppressDelivery)
|
|
416
517
|
return;
|
|
417
518
|
await this.runner.send({ type: 'agent_result', index, error });
|
|
418
519
|
}
|
|
419
520
|
async finalize(requestedStatus, result, requestedError) {
|
|
420
521
|
const runnerStopResults = await Promise.allSettled([this.runner.stop()]);
|
|
522
|
+
// Admission-bookkeeping convergence, not a wait on an Agent's own turn:
|
|
523
|
+
// this waits only for createLocked() (registering the locked handle) to
|
|
524
|
+
// resolve, so the `handles` list read just below is complete before the
|
|
525
|
+
// close pass runs, not for a still-running turn to finish naturally.
|
|
421
526
|
await this.materializations.drain();
|
|
422
|
-
const handles = [
|
|
527
|
+
const handles = [
|
|
528
|
+
...new Set([...this.calls.values()]
|
|
423
529
|
.map((call) => call.handle)
|
|
424
|
-
.filter((handle) => handle !== null))
|
|
530
|
+
.filter((handle) => handle !== null)),
|
|
531
|
+
].filter((handle) => !this.unlockedHandles.has(handle));
|
|
425
532
|
const closeResults = await Promise.allSettled(handles.map(async (handle) => handle.close({
|
|
426
533
|
note: `Workflow ${this.record.run_id} ${requestedStatus}`,
|
|
427
534
|
})));
|
|
428
535
|
if (closeResults.some((close) => close.status === 'rejected')) {
|
|
429
536
|
throwSettledFailures([...runnerStopResults, ...closeResults], `workflow ${JSON.stringify(this.record.run_id)} runner or TeamMates failed to stop`);
|
|
430
537
|
}
|
|
538
|
+
// Each of these three waits for this run's own already-admitted write
|
|
539
|
+
// (a queued runner message, a completeAgent call, a store write) to land
|
|
540
|
+
// truthfully — never for an Agent's own turn to finish naturally, which
|
|
541
|
+
// a stop must never wait on.
|
|
431
542
|
await this.runnerMessageTasks.drain();
|
|
432
543
|
await this.agentTasks.drain();
|
|
433
|
-
await this.
|
|
544
|
+
await this.deps.store.handle(this.record.run_id).drain();
|
|
434
545
|
for (const call of this.calls.values()) {
|
|
435
546
|
if (!call.completed) {
|
|
436
547
|
await this.completeAgent(call, 'stopped', null, requestedError);
|
|
437
548
|
}
|
|
438
549
|
}
|
|
439
|
-
await this.
|
|
550
|
+
await this.deps.store.handle(this.record.run_id).drain();
|
|
440
551
|
throwSettledFailures(runnerStopResults, `workflow ${JSON.stringify(this.record.run_id)} runner failed to stop`);
|
|
441
552
|
if (this.terminalCandidate === null) {
|
|
442
|
-
const endedAt =
|
|
553
|
+
const endedAt = Date.now();
|
|
443
554
|
this.terminalCandidate = {
|
|
444
555
|
...structuredClone(this.record),
|
|
445
556
|
status: requestedStatus,
|
|
@@ -450,16 +561,13 @@ export class WorkflowRun {
|
|
|
450
561
|
};
|
|
451
562
|
}
|
|
452
563
|
const candidate = this.terminalCandidate;
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
});
|
|
461
|
-
this.terminalJournalCommitted = true;
|
|
462
|
-
}
|
|
564
|
+
await this.journal.ensureTerminal({
|
|
565
|
+
kind: 'end',
|
|
566
|
+
status: candidate.status,
|
|
567
|
+
result: candidate.result,
|
|
568
|
+
error: candidate.error,
|
|
569
|
+
ended_at: candidate.ended_at,
|
|
570
|
+
});
|
|
463
571
|
await this.deps.store.write(candidate);
|
|
464
572
|
Object.assign(this.record, structuredClone(candidate));
|
|
465
573
|
for (const handle of handles) {
|
|
@@ -468,9 +576,9 @@ export class WorkflowRun {
|
|
|
468
576
|
handle.unlock();
|
|
469
577
|
this.unlockedHandles.add(handle);
|
|
470
578
|
}
|
|
471
|
-
const
|
|
472
|
-
if (
|
|
473
|
-
await
|
|
579
|
+
const recipient = this.recipient;
|
|
580
|
+
if (recipient !== null) {
|
|
581
|
+
await this.deps.completionDelivery.deliver(recipient, {
|
|
474
582
|
kind: 'workflow',
|
|
475
583
|
source: 'workflow',
|
|
476
584
|
runId: this.record.run_id,
|
|
@@ -485,29 +593,34 @@ export class WorkflowRun {
|
|
|
485
593
|
.map((agent) => ({ index: agent.index, name: agent.name })),
|
|
486
594
|
}, null, 2),
|
|
487
595
|
});
|
|
488
|
-
this.
|
|
489
|
-
}
|
|
490
|
-
if (!this.terminalLogged) {
|
|
491
|
-
this.terminalLogged = true;
|
|
492
|
-
this.deps.log.info({
|
|
493
|
-
run_id: this.record.run_id,
|
|
494
|
-
status: candidate.status,
|
|
495
|
-
agent_count: candidate.agents.length,
|
|
496
|
-
err: candidate.error === null
|
|
497
|
-
? undefined
|
|
498
|
-
: { message: candidate.error },
|
|
499
|
-
}, 'workflow run terminal');
|
|
596
|
+
this.recipient = null;
|
|
500
597
|
}
|
|
598
|
+
this.deps.log.info({
|
|
599
|
+
run_id: this.record.run_id,
|
|
600
|
+
status: candidate.status,
|
|
601
|
+
agent_count: candidate.agents.length,
|
|
602
|
+
err: candidate.error === null ? undefined : { message: candidate.error },
|
|
603
|
+
}, 'workflow run terminal');
|
|
501
604
|
}
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
605
|
+
/**
|
|
606
|
+
* Run a durable write (journal append and/or `store.write`) and reclassify
|
|
607
|
+
* any failure as a {@link WorkflowPersistenceError}. Ordering between two
|
|
608
|
+
* durable writes from this same `WorkflowRun` instance comes from awaiting
|
|
609
|
+
* them in sequence, not from a queue here: each per-run `TransactionalStore`
|
|
610
|
+
* already serializes concurrent writers on its own file.
|
|
611
|
+
* Result- and terminal-bearing writes await their matching journal fact
|
|
612
|
+
* before the corresponding store write is enqueued.
|
|
613
|
+
* `executeAgent`'s catch depends on this classification to tell "this run's
|
|
614
|
+
* own storage failed" (a terminal failure) apart from "this Agent's runtime
|
|
615
|
+
* work failed" (an ordinary agent failure another write can still record).
|
|
616
|
+
*/
|
|
617
|
+
async persist(work) {
|
|
618
|
+
try {
|
|
619
|
+
return await work();
|
|
620
|
+
}
|
|
621
|
+
catch (error) {
|
|
506
622
|
throw new WorkflowPersistenceError(errorMessage(error));
|
|
507
|
-
}
|
|
508
|
-
}
|
|
509
|
-
now() {
|
|
510
|
-
return this.deps.now?.() ?? Date.now();
|
|
623
|
+
}
|
|
511
624
|
}
|
|
512
625
|
}
|
|
513
626
|
//# sourceMappingURL=run.js.map
|