@agimon-ai/doompi-workflow 0.0.1-alpha.76 → 0.0.1-alpha.78
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/dist/_virtual/_rolldown/runtime.cjs +23 -0
- package/dist/api-contracts.cjs +7 -0
- package/dist/api-contracts.d.cts +2 -0
- package/dist/api-contracts.d.mts +2 -0
- package/dist/api-contracts.mjs +2 -0
- package/dist/extensions/pi.cjs +63 -0
- package/dist/extensions/pi.cjs.map +1 -0
- package/dist/extensions/pi.d.cts +6 -0
- package/dist/extensions/pi.d.cts.map +1 -0
- package/dist/extensions/pi.d.mts +6 -0
- package/dist/extensions/pi.d.mts.map +1 -0
- package/dist/extensions/pi.mjs +58 -0
- package/dist/extensions/pi.mjs.map +1 -0
- package/dist/extensions/server.cjs +96 -0
- package/dist/extensions/server.cjs.map +1 -0
- package/dist/extensions/server.d.cts +5 -0
- package/dist/extensions/server.d.cts.map +1 -0
- package/dist/extensions/server.d.mts +5 -0
- package/dist/extensions/server.d.mts.map +1 -0
- package/dist/extensions/server.mjs +91 -0
- package/dist/extensions/server.mjs.map +1 -0
- package/dist/extensions/web.mjs +3219 -0
- package/dist/extensions/web.mjs.map +1 -0
- package/dist/index.cjs +4 -0
- package/dist/index.d.cts +2 -0
- package/dist/index.d.mts +2 -0
- package/dist/index.mjs +2 -0
- package/dist/src/constants/workflow.cjs +32 -0
- package/dist/src/constants/workflow.cjs.map +1 -0
- package/dist/src/constants/workflow.mjs +21 -0
- package/dist/src/constants/workflow.mjs.map +1 -0
- package/dist/src/extensions/(backend)/_lib/index.server.cjs +12 -0
- package/dist/src/extensions/(backend)/_lib/index.server.cjs.map +1 -0
- package/dist/src/extensions/(backend)/_lib/index.server.mjs +12 -0
- package/dist/src/extensions/(backend)/_lib/index.server.mjs.map +1 -0
- package/dist/src/extensions/(backend)/api/workflow/route.server.cjs +7 -0
- package/dist/src/extensions/(backend)/api/workflow/route.server.cjs.map +1 -0
- package/dist/src/extensions/(backend)/api/workflow/route.server.mjs +8 -0
- package/dist/src/extensions/(backend)/api/workflow/route.server.mjs.map +1 -0
- package/dist/src/extensions/(backend)/channel/workflow-catalog.server.cjs +7 -0
- package/dist/src/extensions/(backend)/channel/workflow-catalog.server.cjs.map +1 -0
- package/dist/src/extensions/(backend)/channel/workflow-catalog.server.mjs +8 -0
- package/dist/src/extensions/(backend)/channel/workflow-catalog.server.mjs.map +1 -0
- package/dist/src/extensions/(backend)/channel/workflows.server.cjs +7 -0
- package/dist/src/extensions/(backend)/channel/workflows.server.cjs.map +1 -0
- package/dist/src/extensions/(backend)/channel/workflows.server.mjs +8 -0
- package/dist/src/extensions/(backend)/channel/workflows.server.mjs.map +1 -0
- package/dist/src/extensions/workspaces/sessions/(backend)/_lib/index.cli.cjs +100 -0
- package/dist/src/extensions/workspaces/sessions/(backend)/_lib/index.cli.cjs.map +1 -0
- package/dist/src/extensions/workspaces/sessions/(backend)/_lib/index.cli.mjs +100 -0
- package/dist/src/extensions/workspaces/sessions/(backend)/_lib/index.cli.mjs.map +1 -0
- package/dist/src/extensions/workspaces/sessions/(backend)/_lib/index.server.cjs +11 -0
- package/dist/src/extensions/workspaces/sessions/(backend)/_lib/index.server.cjs.map +1 -0
- package/dist/src/extensions/workspaces/sessions/(backend)/_lib/index.server.mjs +11 -0
- package/dist/src/extensions/workspaces/sessions/(backend)/_lib/index.server.mjs.map +1 -0
- package/dist/src/extensions/workspaces/sessions/(backend)/_lib/workflowSkillsResource.cjs +12 -0
- package/dist/src/extensions/workspaces/sessions/(backend)/_lib/workflowSkillsResource.cjs.map +1 -0
- package/dist/src/extensions/workspaces/sessions/(backend)/_lib/workflowSkillsResource.mjs +12 -0
- package/dist/src/extensions/workspaces/sessions/(backend)/_lib/workflowSkillsResource.mjs.map +1 -0
- package/dist/src/extensions/workspaces/sessions/(backend)/api/workflow/route.server.cjs +6 -0
- package/dist/src/extensions/workspaces/sessions/(backend)/api/workflow/route.server.cjs.map +1 -0
- package/dist/src/extensions/workspaces/sessions/(backend)/api/workflow/route.server.mjs +7 -0
- package/dist/src/extensions/workspaces/sessions/(backend)/api/workflow/route.server.mjs.map +1 -0
- package/dist/src/extensions/workspaces/sessions/(backend)/command/workflow-launch.cli.cjs +6 -0
- package/dist/src/extensions/workspaces/sessions/(backend)/command/workflow-launch.cli.cjs.map +1 -0
- package/dist/src/extensions/workspaces/sessions/(backend)/command/workflow-launch.cli.mjs +7 -0
- package/dist/src/extensions/workspaces/sessions/(backend)/command/workflow-launch.cli.mjs.map +1 -0
- package/dist/src/extensions/workspaces/sessions/(backend)/command/workflow-launch.server.cjs +6 -0
- package/dist/src/extensions/workspaces/sessions/(backend)/command/workflow-launch.server.cjs.map +1 -0
- package/dist/src/extensions/workspaces/sessions/(backend)/command/workflow-launch.server.mjs +7 -0
- package/dist/src/extensions/workspaces/sessions/(backend)/command/workflow-launch.server.mjs.map +1 -0
- package/dist/src/extensions/workspaces/sessions/(backend)/hook/resources-discover.cli.cjs +6 -0
- package/dist/src/extensions/workspaces/sessions/(backend)/hook/resources-discover.cli.cjs.map +1 -0
- package/dist/src/extensions/workspaces/sessions/(backend)/hook/resources-discover.cli.mjs +7 -0
- package/dist/src/extensions/workspaces/sessions/(backend)/hook/resources-discover.cli.mjs.map +1 -0
- package/dist/src/extensions/workspaces/sessions/(backend)/hook/session-shutdown.server.cjs +6 -0
- package/dist/src/extensions/workspaces/sessions/(backend)/hook/session-shutdown.server.cjs.map +1 -0
- package/dist/src/extensions/workspaces/sessions/(backend)/hook/session-shutdown.server.mjs +7 -0
- package/dist/src/extensions/workspaces/sessions/(backend)/hook/session-shutdown.server.mjs.map +1 -0
- package/dist/src/extensions/workspaces/sessions/(backend)/hook/session-start.cli.cjs +6 -0
- package/dist/src/extensions/workspaces/sessions/(backend)/hook/session-start.cli.cjs.map +1 -0
- package/dist/src/extensions/workspaces/sessions/(backend)/hook/session-start.cli.mjs +7 -0
- package/dist/src/extensions/workspaces/sessions/(backend)/hook/session-start.cli.mjs.map +1 -0
- package/dist/src/extensions/workspaces/sessions/(backend)/hook/tool-execution-end.server.cjs +6 -0
- package/dist/src/extensions/workspaces/sessions/(backend)/hook/tool-execution-end.server.cjs.map +1 -0
- package/dist/src/extensions/workspaces/sessions/(backend)/hook/tool-execution-end.server.mjs +7 -0
- package/dist/src/extensions/workspaces/sessions/(backend)/hook/tool-execution-end.server.mjs.map +1 -0
- package/dist/src/extensions/workspaces/sessions/(backend)/resource/doompi-author-workflow.server.cjs +6 -0
- package/dist/src/extensions/workspaces/sessions/(backend)/resource/doompi-author-workflow.server.cjs.map +1 -0
- package/dist/src/extensions/workspaces/sessions/(backend)/resource/doompi-author-workflow.server.mjs +7 -0
- package/dist/src/extensions/workspaces/sessions/(backend)/resource/doompi-author-workflow.server.mjs.map +1 -0
- package/dist/src/extensions/workspaces/sessions/(backend)/resource/doompi-use-workflow.server.cjs +6 -0
- package/dist/src/extensions/workspaces/sessions/(backend)/resource/doompi-use-workflow.server.cjs.map +1 -0
- package/dist/src/extensions/workspaces/sessions/(backend)/resource/doompi-use-workflow.server.mjs +7 -0
- package/dist/src/extensions/workspaces/sessions/(backend)/resource/doompi-use-workflow.server.mjs.map +1 -0
- package/dist/src/extensions/workspaces/sessions/(backend)/resource/workflow-recovery.server.cjs +6 -0
- package/dist/src/extensions/workspaces/sessions/(backend)/resource/workflow-recovery.server.cjs.map +1 -0
- package/dist/src/extensions/workspaces/sessions/(backend)/resource/workflow-recovery.server.mjs +7 -0
- package/dist/src/extensions/workspaces/sessions/(backend)/resource/workflow-recovery.server.mjs.map +1 -0
- package/dist/src/extensions/workspaces/sessions/(backend)/resource/workflow-skills.cli.cjs +7 -0
- package/dist/src/extensions/workspaces/sessions/(backend)/resource/workflow-skills.cli.cjs.map +1 -0
- package/dist/src/extensions/workspaces/sessions/(backend)/resource/workflow-skills.cli.mjs +8 -0
- package/dist/src/extensions/workspaces/sessions/(backend)/resource/workflow-skills.cli.mjs.map +1 -0
- package/dist/src/extensions/workspaces/sessions/(backend)/root.cli.cjs +15 -0
- package/dist/src/extensions/workspaces/sessions/(backend)/root.cli.cjs.map +1 -0
- package/dist/src/extensions/workspaces/sessions/(backend)/root.cli.mjs +16 -0
- package/dist/src/extensions/workspaces/sessions/(backend)/root.cli.mjs.map +1 -0
- package/dist/src/extensions/workspaces/sessions/(backend)/root.server.cjs +17 -0
- package/dist/src/extensions/workspaces/sessions/(backend)/root.server.cjs.map +1 -0
- package/dist/src/extensions/workspaces/sessions/(backend)/root.server.mjs +18 -0
- package/dist/src/extensions/workspaces/sessions/(backend)/root.server.mjs.map +1 -0
- package/dist/src/extensions/workspaces/sessions/(backend)/shortcut/workflow-panel.cli.cjs +6 -0
- package/dist/src/extensions/workspaces/sessions/(backend)/shortcut/workflow-panel.cli.cjs.map +1 -0
- package/dist/src/extensions/workspaces/sessions/(backend)/shortcut/workflow-panel.cli.mjs +7 -0
- package/dist/src/extensions/workspaces/sessions/(backend)/shortcut/workflow-panel.cli.mjs.map +1 -0
- package/dist/src/extensions/workspaces/sessions/(backend)/shortcut/workflow-view-close.cli.cjs +6 -0
- package/dist/src/extensions/workspaces/sessions/(backend)/shortcut/workflow-view-close.cli.cjs.map +1 -0
- package/dist/src/extensions/workspaces/sessions/(backend)/shortcut/workflow-view-close.cli.mjs +7 -0
- package/dist/src/extensions/workspaces/sessions/(backend)/shortcut/workflow-view-close.cli.mjs.map +1 -0
- package/dist/src/extensions/workspaces/sessions/(backend)/tool/launch-workflow.server.cjs +6 -0
- package/dist/src/extensions/workspaces/sessions/(backend)/tool/launch-workflow.server.cjs.map +1 -0
- package/dist/src/extensions/workspaces/sessions/(backend)/tool/launch-workflow.server.mjs +7 -0
- package/dist/src/extensions/workspaces/sessions/(backend)/tool/launch-workflow.server.mjs.map +1 -0
- package/dist/src/extensions/workspaces/sessions/(backend)/tool/list-workflows.server.cjs +6 -0
- package/dist/src/extensions/workspaces/sessions/(backend)/tool/list-workflows.server.cjs.map +1 -0
- package/dist/src/extensions/workspaces/sessions/(backend)/tool/list-workflows.server.mjs +7 -0
- package/dist/src/extensions/workspaces/sessions/(backend)/tool/list-workflows.server.mjs.map +1 -0
- package/dist/src/extensions/workspaces/sessions/(backend)/tool/workflow-run.server.cjs +6 -0
- package/dist/src/extensions/workspaces/sessions/(backend)/tool/workflow-run.server.cjs.map +1 -0
- package/dist/src/extensions/workspaces/sessions/(backend)/tool/workflow-run.server.mjs +7 -0
- package/dist/src/extensions/workspaces/sessions/(backend)/tool/workflow-run.server.mjs.map +1 -0
- package/dist/src/extensions/workspaces/sessions/(backend)/tool/workflow.cli.cjs +6 -0
- package/dist/src/extensions/workspaces/sessions/(backend)/tool/workflow.cli.cjs.map +1 -0
- package/dist/src/extensions/workspaces/sessions/(backend)/tool/workflow.cli.mjs +7 -0
- package/dist/src/extensions/workspaces/sessions/(backend)/tool/workflow.cli.mjs.map +1 -0
- package/dist/src/extensions/workspaces/sessions/(backend)/tool-restriction/workflow.cli.cjs +6 -0
- package/dist/src/extensions/workspaces/sessions/(backend)/tool-restriction/workflow.cli.cjs.map +1 -0
- package/dist/src/extensions/workspaces/sessions/(backend)/tool-restriction/workflow.cli.mjs +7 -0
- package/dist/src/extensions/workspaces/sessions/(backend)/tool-restriction/workflow.cli.mjs.map +1 -0
- package/dist/src/extensions/workspaces/sessions/(backend)/tool-restriction/workflow.server.cjs +6 -0
- package/dist/src/extensions/workspaces/sessions/(backend)/tool-restriction/workflow.server.cjs.map +1 -0
- package/dist/src/extensions/workspaces/sessions/(backend)/tool-restriction/workflow.server.mjs +7 -0
- package/dist/src/extensions/workspaces/sessions/(backend)/tool-restriction/workflow.server.mjs.map +1 -0
- package/dist/src/extensions/workspaces/sessions/(frontend)/message/_lib/workflowFinishedRenderer.cjs +50 -0
- package/dist/src/extensions/workspaces/sessions/(frontend)/message/_lib/workflowFinishedRenderer.cjs.map +1 -0
- package/dist/src/extensions/workspaces/sessions/(frontend)/message/_lib/workflowFinishedRenderer.mjs +47 -0
- package/dist/src/extensions/workspaces/sessions/(frontend)/message/_lib/workflowFinishedRenderer.mjs.map +1 -0
- package/dist/src/extensions/workspaces/sessions/(frontend)/message/_lib/workflowStepRenderer.cjs +36 -0
- package/dist/src/extensions/workspaces/sessions/(frontend)/message/_lib/workflowStepRenderer.cjs.map +1 -0
- package/dist/src/extensions/workspaces/sessions/(frontend)/message/_lib/workflowStepRenderer.mjs +35 -0
- package/dist/src/extensions/workspaces/sessions/(frontend)/message/_lib/workflowStepRenderer.mjs.map +1 -0
- package/dist/src/extensions/workspaces/sessions/(frontend)/message/workflow-finished.cli.cjs +7 -0
- package/dist/src/extensions/workspaces/sessions/(frontend)/message/workflow-finished.cli.cjs.map +1 -0
- package/dist/src/extensions/workspaces/sessions/(frontend)/message/workflow-finished.cli.mjs +8 -0
- package/dist/src/extensions/workspaces/sessions/(frontend)/message/workflow-finished.cli.mjs.map +1 -0
- package/dist/src/extensions/workspaces/sessions/(frontend)/message/workflow-step.cli.cjs +7 -0
- package/dist/src/extensions/workspaces/sessions/(frontend)/message/workflow-step.cli.cjs.map +1 -0
- package/dist/src/extensions/workspaces/sessions/(frontend)/message/workflow-step.cli.mjs +8 -0
- package/dist/src/extensions/workspaces/sessions/(frontend)/message/workflow-step.cli.mjs.map +1 -0
- package/dist/src/schemas/apiContracts.cjs +330 -0
- package/dist/src/schemas/apiContracts.cjs.map +1 -0
- package/dist/src/schemas/apiContracts.d.cts +53 -0
- package/dist/src/schemas/apiContracts.d.cts.map +1 -0
- package/dist/src/schemas/apiContracts.d.mts +53 -0
- package/dist/src/schemas/apiContracts.d.mts.map +1 -0
- package/dist/src/schemas/apiContracts.mjs +327 -0
- package/dist/src/schemas/apiContracts.mjs.map +1 -0
- package/dist/src/schemas/workflowPi.cjs +77 -0
- package/dist/src/schemas/workflowPi.cjs.map +1 -0
- package/dist/src/schemas/workflowPi.d.cts +1 -0
- package/dist/src/schemas/workflowPi.d.mts +1 -0
- package/dist/src/schemas/workflowPi.mjs +74 -0
- package/dist/src/schemas/workflowPi.mjs.map +1 -0
- package/dist/src/services/backgroundWork/index.cjs +61 -0
- package/dist/src/services/backgroundWork/index.cjs.map +1 -0
- package/dist/src/services/backgroundWork/index.mjs +61 -0
- package/dist/src/services/backgroundWork/index.mjs.map +1 -0
- package/dist/src/services/piToolBridge/index.cjs +205 -0
- package/dist/src/services/piToolBridge/index.cjs.map +1 -0
- package/dist/src/services/piToolBridge/index.mjs +195 -0
- package/dist/src/services/piToolBridge/index.mjs.map +1 -0
- package/dist/src/services/serverRuntime/index.cjs +387 -0
- package/dist/src/services/serverRuntime/index.cjs.map +1 -0
- package/dist/src/services/serverRuntime/index.mjs +387 -0
- package/dist/src/services/serverRuntime/index.mjs.map +1 -0
- package/dist/src/services/webWorkflowCatalog/index.cjs +53 -0
- package/dist/src/services/webWorkflowCatalog/index.cjs.map +1 -0
- package/dist/src/services/webWorkflowCatalog/index.mjs +52 -0
- package/dist/src/services/webWorkflowCatalog/index.mjs.map +1 -0
- package/dist/src/services/workflowCatalogChannel/index.cjs +74 -0
- package/dist/src/services/workflowCatalogChannel/index.cjs.map +1 -0
- package/dist/src/services/workflowCatalogChannel/index.mjs +74 -0
- package/dist/src/services/workflowCatalogChannel/index.mjs.map +1 -0
- package/dist/src/services/workflowCatalogDeps/index.cjs +25 -0
- package/dist/src/services/workflowCatalogDeps/index.cjs.map +1 -0
- package/dist/src/services/workflowCatalogDeps/index.mjs +25 -0
- package/dist/src/services/workflowCatalogDeps/index.mjs.map +1 -0
- package/dist/src/services/workflowExecution/index.cjs +205 -0
- package/dist/src/services/workflowExecution/index.cjs.map +1 -0
- package/dist/src/services/workflowExecution/index.d.cts +6 -0
- package/dist/src/services/workflowExecution/index.d.mts +6 -0
- package/dist/src/services/workflowExecution/index.mjs +200 -0
- package/dist/src/services/workflowExecution/index.mjs.map +1 -0
- package/dist/src/services/workflowFence/index.cjs +170 -0
- package/dist/src/services/workflowFence/index.cjs.map +1 -0
- package/dist/src/services/workflowFence/index.mjs +166 -0
- package/dist/src/services/workflowFence/index.mjs.map +1 -0
- package/dist/src/services/workflowHubApi/index.cjs +415 -0
- package/dist/src/services/workflowHubApi/index.cjs.map +1 -0
- package/dist/src/services/workflowHubApi/index.mjs +411 -0
- package/dist/src/services/workflowHubApi/index.mjs.map +1 -0
- package/dist/src/services/workflowLaunchCommand/index.cjs +121 -0
- package/dist/src/services/workflowLaunchCommand/index.cjs.map +1 -0
- package/dist/src/services/workflowLaunchCommand/index.d.cts +52 -0
- package/dist/src/services/workflowLaunchCommand/index.d.cts.map +1 -0
- package/dist/src/services/workflowLaunchCommand/index.d.mts +52 -0
- package/dist/src/services/workflowLaunchCommand/index.d.mts.map +1 -0
- package/dist/src/services/workflowLaunchCommand/index.mjs +118 -0
- package/dist/src/services/workflowLaunchCommand/index.mjs.map +1 -0
- package/dist/src/services/workflowLauncher/index.cjs +181 -0
- package/dist/src/services/workflowLauncher/index.cjs.map +1 -0
- package/dist/src/services/workflowLauncher/index.mjs +177 -0
- package/dist/src/services/workflowLauncher/index.mjs.map +1 -0
- package/dist/src/services/workflowNarration/index.cjs +19 -0
- package/dist/src/services/workflowNarration/index.cjs.map +1 -0
- package/dist/src/services/workflowNarration/index.mjs +19 -0
- package/dist/src/services/workflowNarration/index.mjs.map +1 -0
- package/dist/src/services/workflowResource/index.cjs +27 -0
- package/dist/src/services/workflowResource/index.cjs.map +1 -0
- package/dist/src/services/workflowResource/index.mjs +24 -0
- package/dist/src/services/workflowResource/index.mjs.map +1 -0
- package/dist/src/services/workflowRuns/index.cjs +333 -0
- package/dist/src/services/workflowRuns/index.cjs.map +1 -0
- package/dist/src/services/workflowRuns/index.mjs +319 -0
- package/dist/src/services/workflowRuns/index.mjs.map +1 -0
- package/dist/src/services/workflowTerminal/index.cjs +69 -0
- package/dist/src/services/workflowTerminal/index.cjs.map +1 -0
- package/dist/src/services/workflowTerminal/index.mjs +69 -0
- package/dist/src/services/workflowTerminal/index.mjs.map +1 -0
- package/dist/src/services/workflowTools/index.cjs +221 -0
- package/dist/src/services/workflowTools/index.cjs.map +1 -0
- package/dist/src/services/workflowTools/index.mjs +221 -0
- package/dist/src/services/workflowTools/index.mjs.map +1 -0
- package/dist/src/services/workflowWatcher/index.cjs +78 -0
- package/dist/src/services/workflowWatcher/index.cjs.map +1 -0
- package/dist/src/services/workflowWatcher/index.mjs +74 -0
- package/dist/src/services/workflowWatcher/index.mjs.map +1 -0
- package/dist/src/services/workflowsHubChannel/index.cjs +58 -0
- package/dist/src/services/workflowsHubChannel/index.cjs.map +1 -0
- package/dist/src/services/workflowsHubChannel/index.mjs +58 -0
- package/dist/src/services/workflowsHubChannel/index.mjs.map +1 -0
- package/dist/src/tui/leader.cjs +84 -0
- package/dist/src/tui/leader.cjs.map +1 -0
- package/dist/src/tui/leader.mjs +83 -0
- package/dist/src/tui/leader.mjs.map +1 -0
- package/dist/src/tui/workflow/doomOverlay.cjs +159 -0
- package/dist/src/tui/workflow/doomOverlay.cjs.map +1 -0
- package/dist/src/tui/workflow/doomOverlay.mjs +157 -0
- package/dist/src/tui/workflow/doomOverlay.mjs.map +1 -0
- package/dist/src/tui/workflow/overlayText.cjs +83 -0
- package/dist/src/tui/workflow/overlayText.cjs.map +1 -0
- package/dist/src/tui/workflow/overlayText.mjs +78 -0
- package/dist/src/tui/workflow/overlayText.mjs.map +1 -0
- package/dist/src/tui/workflow/rendering.cjs +22 -0
- package/dist/src/tui/workflow/rendering.cjs.map +1 -0
- package/dist/src/tui/workflow/rendering.mjs +20 -0
- package/dist/src/tui/workflow/rendering.mjs.map +1 -0
- package/dist/src/tui/workflow/workflowCatalog.cjs +336 -0
- package/dist/src/tui/workflow/workflowCatalog.cjs.map +1 -0
- package/dist/src/tui/workflow/workflowCatalog.mjs +333 -0
- package/dist/src/tui/workflow/workflowCatalog.mjs.map +1 -0
- package/dist/src/tui/workflow/workflowFinishedMessage.cjs +50 -0
- package/dist/src/tui/workflow/workflowFinishedMessage.cjs.map +1 -0
- package/dist/src/tui/workflow/workflowFinishedMessage.mjs +47 -0
- package/dist/src/tui/workflow/workflowFinishedMessage.mjs.map +1 -0
- package/dist/src/tui/workflow/workflowInspector.cjs +276 -0
- package/dist/src/tui/workflow/workflowInspector.cjs.map +1 -0
- package/dist/src/tui/workflow/workflowInspector.mjs +276 -0
- package/dist/src/tui/workflow/workflowInspector.mjs.map +1 -0
- package/dist/src/tui/workflow/workflowOverlay.cjs +126 -0
- package/dist/src/tui/workflow/workflowOverlay.cjs.map +1 -0
- package/dist/src/tui/workflow/workflowOverlay.mjs +125 -0
- package/dist/src/tui/workflow/workflowOverlay.mjs.map +1 -0
- package/dist/src/tui/workflow/workflowPicker.cjs +138 -0
- package/dist/src/tui/workflow/workflowPicker.cjs.map +1 -0
- package/dist/src/tui/workflow/workflowPicker.mjs +136 -0
- package/dist/src/tui/workflow/workflowPicker.mjs.map +1 -0
- package/dist/src/tui/workflow/workflowProgressOverlay.cjs +197 -0
- package/dist/src/tui/workflow/workflowProgressOverlay.cjs.map +1 -0
- package/dist/src/tui/workflow/workflowProgressOverlay.mjs +192 -0
- package/dist/src/tui/workflow/workflowProgressOverlay.mjs.map +1 -0
- package/dist/src/tui/workflow/workflowPrompt.cjs +142 -0
- package/dist/src/tui/workflow/workflowPrompt.cjs.map +1 -0
- package/dist/src/tui/workflow/workflowPrompt.mjs +139 -0
- package/dist/src/tui/workflow/workflowPrompt.mjs.map +1 -0
- package/dist/src/tui/workflow/workflowRunPanel.cjs +95 -0
- package/dist/src/tui/workflow/workflowRunPanel.cjs.map +1 -0
- package/dist/src/tui/workflow/workflowRunPanel.mjs +94 -0
- package/dist/src/tui/workflow/workflowRunPanel.mjs.map +1 -0
- package/dist/src/tui/workflow/workflowStatusRow.cjs +20 -0
- package/dist/src/tui/workflow/workflowStatusRow.cjs.map +1 -0
- package/dist/src/tui/workflow/workflowStatusRow.mjs +20 -0
- package/dist/src/tui/workflow/workflowStatusRow.mjs.map +1 -0
- package/dist/src/tui/workflow/workflowStepMessage.cjs +32 -0
- package/dist/src/tui/workflow/workflowStepMessage.cjs.map +1 -0
- package/dist/src/tui/workflow/workflowStepMessage.mjs +31 -0
- package/dist/src/tui/workflow/workflowStepMessage.mjs.map +1 -0
- package/dist/src/tui/workflow/workflowToolRender.cjs +491 -0
- package/dist/src/tui/workflow/workflowToolRender.cjs.map +1 -0
- package/dist/src/tui/workflow/workflowToolRender.mjs +490 -0
- package/dist/src/tui/workflow/workflowToolRender.mjs.map +1 -0
- package/dist/src/tui/workflowRuntime.cjs +1934 -0
- package/dist/src/tui/workflowRuntime.cjs.map +1 -0
- package/dist/src/tui/workflowRuntime.d.cts +33 -0
- package/dist/src/tui/workflowRuntime.d.cts.map +1 -0
- package/dist/src/tui/workflowRuntime.d.mts +33 -0
- package/dist/src/tui/workflowRuntime.d.mts.map +1 -0
- package/dist/src/tui/workflowRuntime.mjs +1930 -0
- package/dist/src/tui/workflowRuntime.mjs.map +1 -0
- package/dist/src/types/apiRoutes.cjs +82 -0
- package/dist/src/types/apiRoutes.cjs.map +1 -0
- package/dist/src/types/apiRoutes.mjs +80 -0
- package/dist/src/types/apiRoutes.mjs.map +1 -0
- package/dist/src/types/webWorkflowTerminal.cjs +23 -0
- package/dist/src/types/webWorkflowTerminal.cjs.map +1 -0
- package/dist/src/types/webWorkflowTerminal.mjs +22 -0
- package/dist/src/types/webWorkflowTerminal.mjs.map +1 -0
- package/dist/src/types/webWorkflows.cjs +8 -0
- package/dist/src/types/webWorkflows.cjs.map +1 -0
- package/dist/src/types/webWorkflows.mjs +7 -0
- package/dist/src/types/webWorkflows.mjs.map +1 -0
- package/package.json +8 -8
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { createWorkflowCatalogReader, presentWorkflowCatalog } from "../webWorkflowCatalog/index.mjs";
|
|
2
|
+
import { defaultCatalogDeps } from "../workflowCatalogDeps/index.mjs";
|
|
3
|
+
import { WORKFLOW_CATALOG_TYPE } from "../../types/webWorkflows.mjs";
|
|
4
|
+
//#region src/services/workflowCatalogChannel/index.ts
|
|
5
|
+
/**
|
|
6
|
+
* The workflow catalog channel. Durable state seeds a session once, then
|
|
7
|
+
* session lifecycle events deliver updates over the direct event bus.
|
|
8
|
+
*/
|
|
9
|
+
function createWorkflowCatalogChannel(options = {}) {
|
|
10
|
+
const reader = createWorkflowCatalogReader(options.deps ?? defaultCatalogDeps());
|
|
11
|
+
return {
|
|
12
|
+
frameType: WORKFLOW_CATALOG_TYPE,
|
|
13
|
+
start(host) {
|
|
14
|
+
const scopes = /* @__PURE__ */ new Map();
|
|
15
|
+
const latest = /* @__PURE__ */ new Map();
|
|
16
|
+
const subscriptions = /* @__PURE__ */ new Map();
|
|
17
|
+
const publish = (scope, payload) => {
|
|
18
|
+
latest.set(scope.sessionId, payload);
|
|
19
|
+
host.publish(scope.sessionId, payload);
|
|
20
|
+
};
|
|
21
|
+
const readInitial = async (scope) => {
|
|
22
|
+
let payload;
|
|
23
|
+
try {
|
|
24
|
+
payload = {
|
|
25
|
+
cwd: scope.cwd,
|
|
26
|
+
workflows: presentWorkflowCatalog(await reader.read(scope.cwd))
|
|
27
|
+
};
|
|
28
|
+
} catch (error) {
|
|
29
|
+
const warning = error instanceof Error ? error.message : String(error);
|
|
30
|
+
payload = {
|
|
31
|
+
cwd: scope.cwd,
|
|
32
|
+
workflows: [],
|
|
33
|
+
warning
|
|
34
|
+
};
|
|
35
|
+
host.onNotice(`workflow catalog for ${scope.cwd} is unavailable (${warning})`);
|
|
36
|
+
}
|
|
37
|
+
if (scopes.get(scope.sessionId) === scope) publish(scope, payload);
|
|
38
|
+
};
|
|
39
|
+
return {
|
|
40
|
+
payloadFor(scope) {
|
|
41
|
+
return scopes.has(scope.sessionId) ? latest.get(scope.sessionId) : void 0;
|
|
42
|
+
},
|
|
43
|
+
sessionAdded(scope) {
|
|
44
|
+
scopes.set(scope.sessionId, scope);
|
|
45
|
+
subscriptions.get(scope.sessionId)?.();
|
|
46
|
+
const unsubscribe = host.directEvents.subscribe(WORKFLOW_CATALOG_TYPE, scope.sessionId, (value) => {
|
|
47
|
+
if (isWorkflowCatalogPayload(value)) publish(scope, value);
|
|
48
|
+
}, { replayLatest: true });
|
|
49
|
+
subscriptions.set(scope.sessionId, unsubscribe);
|
|
50
|
+
readInitial(scope);
|
|
51
|
+
},
|
|
52
|
+
sessionRemoved(sessionId) {
|
|
53
|
+
subscriptions.get(sessionId)?.();
|
|
54
|
+
subscriptions.delete(sessionId);
|
|
55
|
+
scopes.delete(sessionId);
|
|
56
|
+
latest.delete(sessionId);
|
|
57
|
+
},
|
|
58
|
+
close() {
|
|
59
|
+
for (const unsubscribe of subscriptions.values()) unsubscribe();
|
|
60
|
+
subscriptions.clear();
|
|
61
|
+
scopes.clear();
|
|
62
|
+
latest.clear();
|
|
63
|
+
}
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
function isWorkflowCatalogPayload(value) {
|
|
69
|
+
return typeof value === "object" && value !== null && typeof value.cwd === "string" && Array.isArray(value.workflows);
|
|
70
|
+
}
|
|
71
|
+
//#endregion
|
|
72
|
+
export { createWorkflowCatalogChannel };
|
|
73
|
+
|
|
74
|
+
//# sourceMappingURL=index.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.mjs","names":[],"sources":["../../../../src/services/workflowCatalogChannel/index.ts"],"sourcesContent":["import type { DoomHubChannelSource, DoomHubSessionScope, DoomHubChannel } from '@agimon-ai/doompi-core/hub-channel';\n\nimport {\n createWorkflowCatalogReader,\n presentWorkflowCatalog,\n type WorkflowCatalogReaderDeps,\n} from '../../services/webWorkflowCatalog';\nimport { defaultCatalogDeps } from '../../services/workflowCatalogDeps';\nimport { WORKFLOW_CATALOG_TYPE, type WorkflowCatalogPayload } from '../../types/webWorkflows';\n\nexport interface WorkflowCatalogChannelOptions {\n deps?: WorkflowCatalogReaderDeps;\n}\n\n/**\n * The workflow catalog channel. Durable state seeds a session once, then\n * session lifecycle events deliver updates over the direct event bus.\n */\nexport function createWorkflowCatalogChannel(options: WorkflowCatalogChannelOptions = {}): DoomHubChannel {\n const reader = createWorkflowCatalogReader(options.deps ?? defaultCatalogDeps());\n return {\n frameType: WORKFLOW_CATALOG_TYPE,\n start(host) {\n const scopes = new Map<string, DoomHubSessionScope>();\n const latest = new Map<string, WorkflowCatalogPayload>();\n const subscriptions = new Map<string, () => void>();\n const publish = (scope: DoomHubSessionScope, payload: WorkflowCatalogPayload): void => {\n latest.set(scope.sessionId, payload);\n host.publish(scope.sessionId, payload);\n };\n const readInitial = async (scope: DoomHubSessionScope): Promise<void> => {\n let payload: WorkflowCatalogPayload;\n try {\n payload = {\n cwd: scope.cwd,\n workflows: presentWorkflowCatalog(await reader.read(scope.cwd)),\n };\n } catch (error) {\n const warning = error instanceof Error ? error.message : String(error);\n payload = { cwd: scope.cwd, workflows: [], warning };\n host.onNotice(`workflow catalog for ${scope.cwd} is unavailable (${warning})`);\n }\n if (scopes.get(scope.sessionId) === scope) publish(scope, payload);\n };\n const source: DoomHubChannelSource = {\n payloadFor(scope) {\n return scopes.has(scope.sessionId) ? latest.get(scope.sessionId) : undefined;\n },\n sessionAdded(scope) {\n scopes.set(scope.sessionId, scope);\n subscriptions.get(scope.sessionId)?.();\n const unsubscribe = host.directEvents.subscribe(\n WORKFLOW_CATALOG_TYPE,\n scope.sessionId,\n (value) => {\n if (isWorkflowCatalogPayload(value)) publish(scope, value);\n },\n { replayLatest: true },\n );\n subscriptions.set(scope.sessionId, unsubscribe);\n void readInitial(scope);\n },\n sessionRemoved(sessionId) {\n subscriptions.get(sessionId)?.();\n subscriptions.delete(sessionId);\n scopes.delete(sessionId);\n latest.delete(sessionId);\n },\n close() {\n for (const unsubscribe of subscriptions.values()) unsubscribe();\n subscriptions.clear();\n scopes.clear();\n latest.clear();\n },\n };\n return source;\n },\n };\n}\n\nfunction isWorkflowCatalogPayload(value: unknown): value is WorkflowCatalogPayload {\n return (\n typeof value === 'object' &&\n value !== null &&\n typeof (value as { cwd?: unknown }).cwd === 'string' &&\n Array.isArray((value as { workflows?: unknown }).workflows)\n );\n}\n"],"mappings":";;;;;;;;AAkBA,SAAgB,6BAA6B,UAAyC,CAAC,GAAmB;CACxG,MAAM,SAAS,4BAA4B,QAAQ,QAAQ,mBAAmB,CAAC;CAC/E,OAAO;EACL,WAAW;EACX,MAAM,MAAM;GACV,MAAM,yBAAS,IAAI,IAAiC;GACpD,MAAM,yBAAS,IAAI,IAAoC;GACvD,MAAM,gCAAgB,IAAI,IAAwB;GAClD,MAAM,WAAW,OAA4B,YAA0C;IACrF,OAAO,IAAI,MAAM,WAAW,OAAO;IACnC,KAAK,QAAQ,MAAM,WAAW,OAAO;GACvC;GACA,MAAM,cAAc,OAAO,UAA8C;IACvE,IAAI;IACJ,IAAI;KACF,UAAU;MACR,KAAK,MAAM;MACX,WAAW,uBAAuB,MAAM,OAAO,KAAK,MAAM,GAAG,CAAC;KAChE;IACF,SAAS,OAAO;KACd,MAAM,UAAU,iBAAiB,QAAQ,MAAM,UAAU,OAAO,KAAK;KACrE,UAAU;MAAE,KAAK,MAAM;MAAK,WAAW,CAAC;MAAG;KAAQ;KACnD,KAAK,SAAS,wBAAwB,MAAM,IAAI,mBAAmB,QAAQ,EAAE;IAC/E;IACA,IAAI,OAAO,IAAI,MAAM,SAAS,MAAM,OAAO,QAAQ,OAAO,OAAO;GACnE;GAgCA,OAAO;IA9BL,WAAW,OAAO;KAChB,OAAO,OAAO,IAAI,MAAM,SAAS,IAAI,OAAO,IAAI,MAAM,SAAS,IAAI,KAAA;IACrE;IACA,aAAa,OAAO;KAClB,OAAO,IAAI,MAAM,WAAW,KAAK;KACjC,cAAc,IAAI,MAAM,SAAS,CAAC,GAAG;KACrC,MAAM,cAAc,KAAK,aAAa,UACpC,uBACA,MAAM,YACL,UAAU;MACT,IAAI,yBAAyB,KAAK,GAAG,QAAQ,OAAO,KAAK;KAC3D,GACA,EAAE,cAAc,KAAK,CACvB;KACA,cAAc,IAAI,MAAM,WAAW,WAAW;KAC9C,YAAiB,KAAK;IACxB;IACA,eAAe,WAAW;KACxB,cAAc,IAAI,SAAS,CAAC,GAAG;KAC/B,cAAc,OAAO,SAAS;KAC9B,OAAO,OAAO,SAAS;KACvB,OAAO,OAAO,SAAS;IACzB;IACA,QAAQ;KACN,KAAK,MAAM,eAAe,cAAc,OAAO,GAAG,YAAY;KAC9D,cAAc,MAAM;KACpB,OAAO,MAAM;KACb,OAAO,MAAM;IACf;GAEU;EACd;CACF;AACF;AAEA,SAAS,yBAAyB,OAAiD;CACjF,OACE,OAAO,UAAU,YACjB,UAAU,QACV,OAAQ,MAA4B,QAAQ,YAC5C,MAAM,QAAS,MAAkC,SAAS;AAE9D"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
let node_fs = require("node:fs");
|
|
2
|
+
let _agimon_ai_workflow_mcp = require("@agimon-ai/workflow-mcp");
|
|
3
|
+
//#region src/services/workflowCatalogDeps/index.ts
|
|
4
|
+
/** Connect the pure catalog projection service to the workflow engine and filesystem. */
|
|
5
|
+
function defaultCatalogDeps() {
|
|
6
|
+
return {
|
|
7
|
+
list: (directory) => (0, _agimon_ai_workflow_mcp.readWorkflowCatalog)(directory),
|
|
8
|
+
summarize: (workflowPath) => (0, _agimon_ai_workflow_mcp.summarizeWorkflow)(workflowPath),
|
|
9
|
+
stamp: (workflowPath) => {
|
|
10
|
+
try {
|
|
11
|
+
const stats = (0, node_fs.statSync)(workflowPath);
|
|
12
|
+
return {
|
|
13
|
+
size: stats.size,
|
|
14
|
+
modifiedAt: stats.mtimeMs
|
|
15
|
+
};
|
|
16
|
+
} catch {
|
|
17
|
+
return;
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
//#endregion
|
|
23
|
+
exports.defaultCatalogDeps = defaultCatalogDeps;
|
|
24
|
+
|
|
25
|
+
//# sourceMappingURL=index.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.cjs","names":["readWorkflowCatalog","summarizeWorkflow","statSync"],"sources":["../../../../src/services/workflowCatalogDeps/index.ts"],"sourcesContent":["import { statSync } from 'node:fs';\n\nimport { readWorkflowCatalog, summarizeWorkflow } from '@agimon-ai/workflow-mcp';\n\nimport type { WorkflowCatalogReaderDeps } from '../webWorkflowCatalog';\n\n/** Connect the pure catalog projection service to the workflow engine and filesystem. */\nexport function defaultCatalogDeps(): WorkflowCatalogReaderDeps {\n return {\n list: (directory) => readWorkflowCatalog(directory),\n summarize: (workflowPath) => summarizeWorkflow(workflowPath),\n stamp: (workflowPath) => {\n try {\n const stats = statSync(workflowPath);\n return { size: stats.size, modifiedAt: stats.mtimeMs };\n } catch {\n return undefined;\n }\n },\n };\n}\n"],"mappings":";;;;AAOA,SAAgB,qBAAgD;CAC9D,OAAO;EACL,OAAO,eAAA,GAAcA,wBAAAA,oBAAAA,CAAoB,SAAS;EAClD,YAAY,kBAAA,GAAiBC,wBAAAA,kBAAAA,CAAkB,YAAY;EAC3D,QAAQ,iBAAiB;GACvB,IAAI;IACF,MAAM,SAAA,GAAQC,QAAAA,SAAAA,CAAS,YAAY;IACnC,OAAO;KAAE,MAAM,MAAM;KAAM,YAAY,MAAM;IAAQ;GACvD,QAAQ;IACN;GACF;EACF;CACF;AACF"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { statSync } from "node:fs";
|
|
2
|
+
import { readWorkflowCatalog, summarizeWorkflow } from "@agimon-ai/workflow-mcp";
|
|
3
|
+
//#region src/services/workflowCatalogDeps/index.ts
|
|
4
|
+
/** Connect the pure catalog projection service to the workflow engine and filesystem. */
|
|
5
|
+
function defaultCatalogDeps() {
|
|
6
|
+
return {
|
|
7
|
+
list: (directory) => readWorkflowCatalog(directory),
|
|
8
|
+
summarize: (workflowPath) => summarizeWorkflow(workflowPath),
|
|
9
|
+
stamp: (workflowPath) => {
|
|
10
|
+
try {
|
|
11
|
+
const stats = statSync(workflowPath);
|
|
12
|
+
return {
|
|
13
|
+
size: stats.size,
|
|
14
|
+
modifiedAt: stats.mtimeMs
|
|
15
|
+
};
|
|
16
|
+
} catch {
|
|
17
|
+
return;
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
//#endregion
|
|
23
|
+
export { defaultCatalogDeps };
|
|
24
|
+
|
|
25
|
+
//# sourceMappingURL=index.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.mjs","names":[],"sources":["../../../../src/services/workflowCatalogDeps/index.ts"],"sourcesContent":["import { statSync } from 'node:fs';\n\nimport { readWorkflowCatalog, summarizeWorkflow } from '@agimon-ai/workflow-mcp';\n\nimport type { WorkflowCatalogReaderDeps } from '../webWorkflowCatalog';\n\n/** Connect the pure catalog projection service to the workflow engine and filesystem. */\nexport function defaultCatalogDeps(): WorkflowCatalogReaderDeps {\n return {\n list: (directory) => readWorkflowCatalog(directory),\n summarize: (workflowPath) => summarizeWorkflow(workflowPath),\n stamp: (workflowPath) => {\n try {\n const stats = statSync(workflowPath);\n return { size: stats.size, modifiedAt: stats.mtimeMs };\n } catch {\n return undefined;\n }\n },\n };\n}\n"],"mappings":";;;;AAOA,SAAgB,qBAAgD;CAC9D,OAAO;EACL,OAAO,cAAc,oBAAoB,SAAS;EAClD,YAAY,iBAAiB,kBAAkB,YAAY;EAC3D,QAAQ,iBAAiB;GACvB,IAAI;IACF,MAAM,QAAQ,SAAS,YAAY;IACnC,OAAO;KAAE,MAAM,MAAM;KAAM,YAAY,MAAM;IAAQ;GACvD,QAAQ;IACN;GACF;EACF;CACF;AACF"}
|
|
@@ -0,0 +1,205 @@
|
|
|
1
|
+
const require_workflow = require("../../constants/workflow.cjs");
|
|
2
|
+
const require_index = require("../piToolBridge/index.cjs");
|
|
3
|
+
let _agimon_ai_doompi_core_child_process = require("@agimon-ai/doompi-core/child-process");
|
|
4
|
+
//#region src/services/workflowExecution/index.ts
|
|
5
|
+
const AGIFLOW_JOB_ID_ENV = "AGIFLOW_JOB_ID";
|
|
6
|
+
const AGIFLOW_JOB_KIND_ENV = "AGIFLOW_JOB_KIND";
|
|
7
|
+
const AGIFLOW_PROJECT_ID_ENV = "AGIFLOW_PROJECT_ID";
|
|
8
|
+
/**
|
|
9
|
+
* What workflow mode does to the tool surface: nothing but hide its own tools.
|
|
10
|
+
*
|
|
11
|
+
* The tools are registered for the whole session because Pi has no other way to
|
|
12
|
+
* add one later, so the mode is expressed as a restriction rather than as a
|
|
13
|
+
* registration.
|
|
14
|
+
*/
|
|
15
|
+
function workflowToolRestriction(enabled) {
|
|
16
|
+
const hidden = new Set(require_workflow.WORKFLOW_PI_TOOL_NAMES);
|
|
17
|
+
return (incoming) => enabled ? incoming : incoming.filter((name) => !hidden.has(name));
|
|
18
|
+
}
|
|
19
|
+
/** How often the registry is asked whether the launch has produced a run. */
|
|
20
|
+
const LAUNCH_ACK_POLL_MS = 500;
|
|
21
|
+
/**
|
|
22
|
+
* How long to wait for that before answering without a run key.
|
|
23
|
+
*
|
|
24
|
+
* Long enough to cover a launcher that is merely slow, short enough that a
|
|
25
|
+
* caller is never left holding a turn open for a launcher that will not answer.
|
|
26
|
+
*/
|
|
27
|
+
const LAUNCH_ACK_TIMEOUT_MS = 15e3;
|
|
28
|
+
function reportProgress(onUpdate, tool, message) {
|
|
29
|
+
onUpdate?.({
|
|
30
|
+
content: [{
|
|
31
|
+
type: "text",
|
|
32
|
+
text: message
|
|
33
|
+
}],
|
|
34
|
+
details: { tool }
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
function appendGuidance(result, guidance) {
|
|
38
|
+
return {
|
|
39
|
+
...result,
|
|
40
|
+
content: [...result.content, {
|
|
41
|
+
type: "text",
|
|
42
|
+
text: guidance
|
|
43
|
+
}]
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
function statusAction(runKey) {
|
|
47
|
+
return `workflow_run {"action":"status","runKey":${JSON.stringify(runKey)}}`;
|
|
48
|
+
}
|
|
49
|
+
function actionGuidance(action, runKey) {
|
|
50
|
+
const status = statusAction(runKey);
|
|
51
|
+
if (action === "stop") return [`Next: call ${status} to confirm the run reached a terminal stage.`];
|
|
52
|
+
if (action === "recover") return [`Report the recovery failure and do not retry it blindly: call ${status} first.`, "Ask the user before launching fresh work when the recorded recovery is no longer valid."];
|
|
53
|
+
return [`Next: call ${status} to verify the recorded execution state.`];
|
|
54
|
+
}
|
|
55
|
+
const launchFailureOptions = [
|
|
56
|
+
"Report the failure to the user with the error above. A launch failure is usually a bad workflow path, a missing launcher, or a workflow whose own pre-conditions refused.",
|
|
57
|
+
"list_workflows: confirm the workflow path exists and its description matches the work, if the path may be wrong.",
|
|
58
|
+
"workflow_run with action status: check whether an earlier attempt is already running before launching again."
|
|
59
|
+
];
|
|
60
|
+
/**
|
|
61
|
+
* An Error, whatever the launch rejected with.
|
|
62
|
+
*
|
|
63
|
+
* A rejection reaches here as `unknown` because it crossed a promise boundary,
|
|
64
|
+
* and rethrowing that as-is hands Pi's tool layer something it cannot read a
|
|
65
|
+
* message or a stack off. The original is kept as the cause rather than
|
|
66
|
+
* flattened into a string.
|
|
67
|
+
*/
|
|
68
|
+
function asError(value) {
|
|
69
|
+
return value instanceof Error ? value : new Error(String(value), { cause: value });
|
|
70
|
+
}
|
|
71
|
+
/** Resolves to undefined, so a race against it reads as "nothing settled yet". */
|
|
72
|
+
function sleep(ms) {
|
|
73
|
+
return new Promise((settle) => {
|
|
74
|
+
setTimeout(() => settle(void 0), ms).unref?.();
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* Wait for whichever answer arrives first: the launch settling, the run
|
|
79
|
+
* appearing in the registry, or the budget running out.
|
|
80
|
+
*
|
|
81
|
+
* A launch that delegates to a terminal launcher settles when that launcher's
|
|
82
|
+
* whole process chain closes, which on a loaded machine has been measured
|
|
83
|
+
* minutes after the run itself was registered and working. The registry is the
|
|
84
|
+
* earlier and more truthful signal: a run recorded there is a run that started.
|
|
85
|
+
*/
|
|
86
|
+
async function awaitLaunchAck(settled, dependencies, query) {
|
|
87
|
+
const findLaunchedRun = dependencies.findLaunchedRun;
|
|
88
|
+
if (!findLaunchedRun) return {
|
|
89
|
+
kind: "settled",
|
|
90
|
+
outcome: await settled
|
|
91
|
+
};
|
|
92
|
+
const pollMs = dependencies.launchAckPollMs ?? LAUNCH_ACK_POLL_MS;
|
|
93
|
+
const deadline = Date.now() + (dependencies.launchAckTimeoutMs ?? LAUNCH_ACK_TIMEOUT_MS);
|
|
94
|
+
for (;;) {
|
|
95
|
+
const outcome = await Promise.race([settled, sleep(pollMs)]);
|
|
96
|
+
if (outcome) return {
|
|
97
|
+
kind: "settled",
|
|
98
|
+
outcome
|
|
99
|
+
};
|
|
100
|
+
const record = await findLaunchedRun(query).catch(() => void 0);
|
|
101
|
+
if (record) return {
|
|
102
|
+
kind: "record",
|
|
103
|
+
record
|
|
104
|
+
};
|
|
105
|
+
if (Date.now() >= deadline) return { kind: "handoff" };
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* Carry a failure that lands after the caller was told the run started.
|
|
110
|
+
*
|
|
111
|
+
* Answering early trades the launcher's exit code for timeliness. Dropping that
|
|
112
|
+
* code entirely is not part of the trade: a launch that fails a minute later
|
|
113
|
+
* would otherwise leave a user waiting on a run that never existed.
|
|
114
|
+
*/
|
|
115
|
+
function reportLateFailure(settled, dependencies, ctx) {
|
|
116
|
+
settled.then((outcome) => {
|
|
117
|
+
if (outcome.kind === "error") {
|
|
118
|
+
dependencies.onLateFailure?.(asError(outcome.error), ctx);
|
|
119
|
+
return;
|
|
120
|
+
}
|
|
121
|
+
if (outcome.result.isError) dependencies.onLateFailure?.(new Error(require_index.toolResultText(outcome.result) || "Workflow launch failed."), ctx);
|
|
122
|
+
});
|
|
123
|
+
}
|
|
124
|
+
function createWorkflowLaunchExecutor(dependencies) {
|
|
125
|
+
return { async execute(input, ctx, onUpdate) {
|
|
126
|
+
const sessionId = (0, _agimon_ai_doompi_core_child_process.resolveRootSessionId)(ctx.sessionManager.getSessionId(), dependencies.environment);
|
|
127
|
+
dependencies.observeSession?.(sessionId);
|
|
128
|
+
const agiflowJobKind = input.env?.[AGIFLOW_JOB_KIND_ENV]?.trim();
|
|
129
|
+
const agiflowJobId = input.env?.[AGIFLOW_JOB_ID_ENV]?.trim();
|
|
130
|
+
const explicitProjectId = input.env?.[AGIFLOW_PROJECT_ID_ENV]?.trim();
|
|
131
|
+
if (Boolean(agiflowJobKind) !== Boolean(agiflowJobId)) throw new Error("Agiflow workflow launches require AGIFLOW_JOB_KIND and AGIFLOW_JOB_ID together.");
|
|
132
|
+
if (agiflowJobKind && agiflowJobKind !== "task" && agiflowJobKind !== "work-unit") throw new Error("Agiflow workflow launches require AGIFLOW_JOB_KIND to be task or work-unit.");
|
|
133
|
+
if (agiflowJobKind && !explicitProjectId) throw new Error("Agiflow workflow launches require AGIFLOW_PROJECT_ID with the job identity.");
|
|
134
|
+
if (agiflowJobKind && !input.prompt?.trim()) throw new Error("Agiflow workflow launches require a non-empty prompt so user_prompt runs do not wait for terminal input.");
|
|
135
|
+
reportProgress(onUpdate, require_workflow.LAUNCH_WORKFLOW_TOOL_NAME, "Checking workflow capacity...");
|
|
136
|
+
const maxConcurrent = require_index.resolveMaxConcurrent(dependencies.environment);
|
|
137
|
+
const active = await dependencies.activeRunCount?.() ?? 0;
|
|
138
|
+
if (active >= maxConcurrent) throw new Error(require_index.withOptions(`This session is at capacity: ${active}/${maxConcurrent} workflows running.`, [
|
|
139
|
+
"Wait for a running workflow to finish, then launch again. The extension reports each one as it ends.",
|
|
140
|
+
"workflow_run with action status: show what is running, so the user can judge whether something is stuck.",
|
|
141
|
+
"workflow_run with action stop: free a slot by stopping a run the user no longer wants."
|
|
142
|
+
]));
|
|
143
|
+
if (input.runner) {
|
|
144
|
+
const rejection = dependencies.rejectRunner?.(input.workflowPath, input.runner);
|
|
145
|
+
if (rejection) throw new Error(rejection);
|
|
146
|
+
}
|
|
147
|
+
reportProgress(onUpdate, require_workflow.LAUNCH_WORKFLOW_TOOL_NAME, `Launching workflow ${input.workflowPath}...`);
|
|
148
|
+
const workflowEnv = { ...input.env };
|
|
149
|
+
const dispatcherContextFile = dependencies.environment.AGIFLOW_DISPATCH_CONTEXT_FILE;
|
|
150
|
+
const dispatcherProjectId = dependencies.environment[AGIFLOW_PROJECT_ID_ENV]?.trim();
|
|
151
|
+
if (dispatcherContextFile && agiflowJobKind && dispatcherProjectId && explicitProjectId && dispatcherProjectId !== explicitProjectId) throw new Error(`Agiflow workflow project identity conflicts with the dispatcher context (${explicitProjectId} versus ${dispatcherProjectId}).`);
|
|
152
|
+
if (dispatcherContextFile) for (const key of [
|
|
153
|
+
"AGIFLOW_ORGANIZATION_ID",
|
|
154
|
+
"AGIFLOW_PROJECT_ID",
|
|
155
|
+
"AGIFLOW_DEVICE_ID",
|
|
156
|
+
"BACKEND_AGIFLOW_API_ENDPOINT",
|
|
157
|
+
"AGIFLOW_DISPATCH_SECRET_FILE"
|
|
158
|
+
]) {
|
|
159
|
+
const hostValue = dependencies.environment[key];
|
|
160
|
+
if (hostValue) workflowEnv[key] = hostValue;
|
|
161
|
+
}
|
|
162
|
+
const since = Date.now();
|
|
163
|
+
const settled = dependencies.trackPendingRun(dependencies.runTool.execute({
|
|
164
|
+
...input,
|
|
165
|
+
env: {
|
|
166
|
+
...workflowEnv,
|
|
167
|
+
[require_index.PI_SESSION_ENV]: sessionId
|
|
168
|
+
}
|
|
169
|
+
})).then((value) => ({
|
|
170
|
+
kind: "value",
|
|
171
|
+
result: value
|
|
172
|
+
}), (error) => ({
|
|
173
|
+
kind: "error",
|
|
174
|
+
error
|
|
175
|
+
}));
|
|
176
|
+
const ack = await awaitLaunchAck(settled, dependencies, {
|
|
177
|
+
sessionId,
|
|
178
|
+
since,
|
|
179
|
+
workflowPath: input.workflowPath
|
|
180
|
+
});
|
|
181
|
+
if (ack.kind === "settled") {
|
|
182
|
+
const outcome = ack.outcome;
|
|
183
|
+
if (outcome.kind === "error") throw asError(outcome.error);
|
|
184
|
+
const result = outcome.result;
|
|
185
|
+
if (result.isError) throw new Error(require_index.withOptions(require_index.toolResultText(result) || "Workflow launch failed.", launchFailureOptions));
|
|
186
|
+
await dependencies.onLaunch?.(ctx);
|
|
187
|
+
return result;
|
|
188
|
+
}
|
|
189
|
+
reportLateFailure(settled, dependencies, ctx);
|
|
190
|
+
await dependencies.onLaunch?.(ctx);
|
|
191
|
+
return { content: [{
|
|
192
|
+
type: "text",
|
|
193
|
+
text: ack.kind === "record" ? require_index.launchedRunSummary(ack.record) : require_index.launchHandoffSummary(input.workflowPath)
|
|
194
|
+
}] };
|
|
195
|
+
} };
|
|
196
|
+
}
|
|
197
|
+
//#endregion
|
|
198
|
+
exports.actionGuidance = actionGuidance;
|
|
199
|
+
exports.appendGuidance = appendGuidance;
|
|
200
|
+
exports.createWorkflowLaunchExecutor = createWorkflowLaunchExecutor;
|
|
201
|
+
exports.launchFailureOptions = launchFailureOptions;
|
|
202
|
+
exports.reportProgress = reportProgress;
|
|
203
|
+
exports.workflowToolRestriction = workflowToolRestriction;
|
|
204
|
+
|
|
205
|
+
//# sourceMappingURL=index.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.cjs","names":["WORKFLOW_PI_TOOL_NAMES","toolResultText","resolveRootSessionId","LAUNCH_WORKFLOW_TOOL_NAME","resolveMaxConcurrent","withOptions","PI_SESSION_ENV","launchedRunSummary","launchHandoffSummary"],"sources":["../../../../src/services/workflowExecution/index.ts"],"sourcesContent":["import { resolveRootSessionId } from '@agimon-ai/doompi-core/child-process';\nimport type { DoomToolRestriction } from '@agimon-ai/doompi-core/tool-surface';\nimport { type EmbeddedWorkflowFeature, type WorkflowRunRecord } from '@agimon-ai/workflow-mcp';\nimport type { AgentToolResult, AgentToolUpdateCallback, ExtensionContext } from '@earendil-works/pi-coding-agent';\nimport type { CallToolResult } from '@modelcontextprotocol/sdk/types.js';\nimport { z } from 'zod';\n\nimport { type WorkflowRunInput } from '../../schemas/workflowPi';\nimport {\n launchedRunSummary,\n launchHandoffSummary,\n PI_SESSION_ENV,\n resolveMaxConcurrent,\n toolResultText,\n withOptions,\n} from '../piToolBridge';\n\nconst AGIFLOW_JOB_ID_ENV = 'AGIFLOW_JOB_ID';\nconst AGIFLOW_JOB_KIND_ENV = 'AGIFLOW_JOB_KIND';\nconst AGIFLOW_PROJECT_ID_ENV = 'AGIFLOW_PROJECT_ID';\n\nimport { WORKFLOW_PI_TOOL_NAMES, LAUNCH_WORKFLOW_TOOL_NAME } from '../../constants/workflow';\n\n/**\n * What workflow mode does to the tool surface: nothing but hide its own tools.\n *\n * The tools are registered for the whole session because Pi has no other way to\n * add one later, so the mode is expressed as a restriction rather than as a\n * registration.\n */\nexport function workflowToolRestriction(enabled: boolean): DoomToolRestriction {\n const hidden = new Set<string>(WORKFLOW_PI_TOOL_NAMES);\n return (incoming) => (enabled ? incoming : incoming.filter((name) => !hidden.has(name)));\n}\n\nexport type WorkflowRunSelector = Pick<WorkflowRunInput, 'runKey' | 'workspace'>;\n\nexport type WorkflowLaunchInput = z.infer<ReturnType<EmbeddedWorkflowFeature['runTool']['getInputSchema']>>;\n\n/**\n * Where a launch was answered from, which decides what the caller is told.\n *\n * Tagged rather than inferred from an absent field: the failure carries an\n * `unknown`, and `unknown` includes `undefined`, so only a tag can tell a\n * rejection apart from a result.\n */\ntype LaunchOutcome = { kind: 'value'; result: CallToolResult } | { kind: 'error'; error: unknown };\ntype LaunchAck =\n | { kind: 'settled'; outcome: LaunchOutcome }\n | { kind: 'record'; record: WorkflowRunRecord }\n | { kind: 'handoff' };\n\n/** How often the registry is asked whether the launch has produced a run. */\nconst LAUNCH_ACK_POLL_MS = 500;\n/**\n * How long to wait for that before answering without a run key.\n *\n * Long enough to cover a launcher that is merely slow, short enough that a\n * caller is never left holding a turn open for a launcher that will not answer.\n */\nconst LAUNCH_ACK_TIMEOUT_MS = 15_000;\n\nexport interface LaunchedRunQuery {\n sessionId: string | undefined;\n /** Epoch milliseconds the launch began, so an earlier run cannot match. */\n since: number;\n workflowPath: string;\n}\n\nexport interface WorkflowLaunchExecutorDependencies {\n readonly environment: Readonly<Record<string, string | undefined>>;\n activeRunCount?: () => Promise<number>;\n onLaunch?: (ctx: ExtensionContext) => Promise<void> | void;\n observeSession?: (sessionId: string | undefined) => void;\n rejectRunner?: (workflowPath: string, runner: string) => string | undefined;\n runTool: EmbeddedWorkflowFeature['runTool'];\n trackPendingRun: <T>(run: Promise<T>) => Promise<T>;\n /**\n * The run this launch registered, or undefined while none has appeared.\n *\n * Its presence is what lets a launch answer on the registry instead of on the\n * launcher process exiting. Left out, the launch waits for the process, which\n * is the behaviour every caller had before.\n */\n findLaunchedRun?: (query: LaunchedRunQuery) => Promise<WorkflowRunRecord | undefined>;\n /** Report a launch that fails after this call already answered \"started\". */\n onLateFailure?: (error: unknown, ctx: ExtensionContext) => void;\n launchAckPollMs?: number;\n launchAckTimeoutMs?: number;\n}\n\nexport interface WorkflowLaunchExecutor {\n execute(\n input: WorkflowLaunchInput,\n ctx: ExtensionContext,\n onUpdate?: AgentToolUpdateCallback<{ tool: string }>,\n ): Promise<CallToolResult>;\n}\n\nexport interface WorkflowPiToolDependencies {\n readonly environment: Readonly<Record<string, string | undefined>>;\n launchExecutor?: WorkflowLaunchExecutor;\n onLaunch?: (ctx: ExtensionContext) => Promise<void> | void;\n activeRunCount?: () => Promise<number>;\n followRun?: (input: WorkflowRunSelector, ctx: ExtensionContext) => Promise<string>;\n tailRun?: (input: WorkflowRunSelector, ctx: ExtensionContext) => Promise<string>;\n openRun?: (input: WorkflowRunSelector, ctx: ExtensionContext) => Promise<string>;\n rejectRunner?: (workflowPath: string, runner: string) => string | undefined;\n requireSessionRun?: (input: WorkflowRunSelector, sessionId: string | undefined) => Promise<WorkflowRunRecord>;\n /**\n * Resolve a failed recovery target globally.\n *\n * Recovery is the one ownership-transferring action: a replacement Pi\n * session must be able to adopt a terminal run whose launching session is\n * gone. Every non-recovery action remains session-scoped.\n */\n requireRecoverableRun?: (input: WorkflowRunSelector) => Promise<WorkflowRunRecord>;\n readRecoveryEvidence?: (input: WorkflowRunSelector, ctx: ExtensionContext) => Promise<string>;\n /**\n * Hand a recovery to a terminal launcher, returning what to tell the caller.\n *\n * Undefined means this recovery cannot be delegated, and the in-process\n * replay below is used instead.\n */\n delegateRecovery?: (\n input: { runKey: string; workspace?: string; runner?: string },\n ctx: ExtensionContext,\n ) => Promise<string | undefined>;\n observeSession?: (sessionId: string | undefined) => void;\n trackPendingRun?: <T>(run: Promise<T>) => Promise<T>;\n feature?: EmbeddedWorkflowFeature;\n recoverTool?: {\n execute(input: {\n dryRun?: boolean;\n job?: string;\n runKey: string;\n runner?: string;\n workspace?: string;\n }): Promise<CallToolResult>;\n };\n controlTool?: ReturnType<EmbeddedWorkflowFeature['createControlTool']>;\n runTool?: EmbeddedWorkflowFeature['runTool'];\n listWorkflowsTool?: EmbeddedWorkflowFeature['listWorkflowsTool'];\n}\n\nexport function reportProgress(\n onUpdate: AgentToolUpdateCallback<{ tool: string }> | undefined,\n tool: string,\n message: string,\n): void {\n onUpdate?.({ content: [{ type: 'text', text: message }], details: { tool } });\n}\n\nexport function appendGuidance(\n result: AgentToolResult<{ tool: string }>,\n guidance: string,\n): AgentToolResult<{ tool: string }> {\n return { ...result, content: [...result.content, { type: 'text', text: guidance }] };\n}\n\nfunction statusAction(runKey: string): string {\n return `workflow_run {\"action\":\"status\",\"runKey\":${JSON.stringify(runKey)}}`;\n}\n\nexport function actionGuidance(action: WorkflowRunInput['action'], runKey: string): string[] {\n const status = statusAction(runKey);\n if (action === 'stop') return [`Next: call ${status} to confirm the run reached a terminal stage.`];\n if (action === 'recover') {\n return [\n `Report the recovery failure and do not retry it blindly: call ${status} first.`,\n 'Ask the user before launching fresh work when the recorded recovery is no longer valid.',\n ];\n }\n return [`Next: call ${status} to verify the recorded execution state.`];\n}\n\nexport const launchFailureOptions = [\n 'Report the failure to the user with the error above. A launch failure is usually a bad workflow path, a missing launcher, or a workflow whose own pre-conditions refused.',\n 'list_workflows: confirm the workflow path exists and its description matches the work, if the path may be wrong.',\n 'workflow_run with action status: check whether an earlier attempt is already running before launching again.',\n];\n\n/**\n * An Error, whatever the launch rejected with.\n *\n * A rejection reaches here as `unknown` because it crossed a promise boundary,\n * and rethrowing that as-is hands Pi's tool layer something it cannot read a\n * message or a stack off. The original is kept as the cause rather than\n * flattened into a string.\n */\nfunction asError(value: unknown): Error {\n return value instanceof Error ? value : new Error(String(value), { cause: value });\n}\n\n/** Resolves to undefined, so a race against it reads as \"nothing settled yet\". */\nfunction sleep(ms: number): Promise<undefined> {\n return new Promise((settle) => {\n const timer = setTimeout(() => settle(undefined), ms);\n timer.unref?.();\n });\n}\n\n/**\n * Wait for whichever answer arrives first: the launch settling, the run\n * appearing in the registry, or the budget running out.\n *\n * A launch that delegates to a terminal launcher settles when that launcher's\n * whole process chain closes, which on a loaded machine has been measured\n * minutes after the run itself was registered and working. The registry is the\n * earlier and more truthful signal: a run recorded there is a run that started.\n */\nasync function awaitLaunchAck(\n settled: Promise<LaunchOutcome>,\n dependencies: WorkflowLaunchExecutorDependencies,\n query: LaunchedRunQuery,\n): Promise<LaunchAck> {\n const findLaunchedRun = dependencies.findLaunchedRun;\n if (!findLaunchedRun) return { kind: 'settled', outcome: await settled };\n\n const pollMs = dependencies.launchAckPollMs ?? LAUNCH_ACK_POLL_MS;\n const deadline = Date.now() + (dependencies.launchAckTimeoutMs ?? LAUNCH_ACK_TIMEOUT_MS);\n for (;;) {\n const outcome = await Promise.race([settled, sleep(pollMs)]);\n if (outcome) return { kind: 'settled', outcome };\n // A registry read that throws must not fail the launch: the run may be\n // perfectly healthy, and the settled promise is still the fallback.\n const record = await findLaunchedRun(query).catch(() => undefined);\n if (record) return { kind: 'record', record };\n if (Date.now() >= deadline) return { kind: 'handoff' };\n }\n}\n\n/**\n * Carry a failure that lands after the caller was told the run started.\n *\n * Answering early trades the launcher's exit code for timeliness. Dropping that\n * code entirely is not part of the trade: a launch that fails a minute later\n * would otherwise leave a user waiting on a run that never existed.\n */\nfunction reportLateFailure(\n settled: Promise<LaunchOutcome>,\n dependencies: WorkflowLaunchExecutorDependencies,\n ctx: ExtensionContext,\n): void {\n void settled.then((outcome) => {\n if (outcome.kind === 'error') {\n dependencies.onLateFailure?.(asError(outcome.error), ctx);\n return;\n }\n if (outcome.result.isError) {\n dependencies.onLateFailure?.(new Error(toolResultText(outcome.result) || 'Workflow launch failed.'), ctx);\n }\n });\n}\n\nexport function createWorkflowLaunchExecutor(dependencies: WorkflowLaunchExecutorDependencies): WorkflowLaunchExecutor {\n return {\n async execute(input, ctx, onUpdate) {\n const sessionId = resolveRootSessionId(ctx.sessionManager.getSessionId(), dependencies.environment);\n dependencies.observeSession?.(sessionId);\n const agiflowJobKind = input.env?.[AGIFLOW_JOB_KIND_ENV]?.trim();\n const agiflowJobId = input.env?.[AGIFLOW_JOB_ID_ENV]?.trim();\n const explicitProjectId = input.env?.[AGIFLOW_PROJECT_ID_ENV]?.trim();\n if (Boolean(agiflowJobKind) !== Boolean(agiflowJobId)) {\n throw new Error('Agiflow workflow launches require AGIFLOW_JOB_KIND and AGIFLOW_JOB_ID together.');\n }\n if (agiflowJobKind && agiflowJobKind !== 'task' && agiflowJobKind !== 'work-unit') {\n throw new Error('Agiflow workflow launches require AGIFLOW_JOB_KIND to be task or work-unit.');\n }\n if (agiflowJobKind && !explicitProjectId) {\n throw new Error('Agiflow workflow launches require AGIFLOW_PROJECT_ID with the job identity.');\n }\n if (agiflowJobKind && !input.prompt?.trim()) {\n throw new Error(\n 'Agiflow workflow launches require a non-empty prompt so user_prompt runs do not wait for terminal input.',\n );\n }\n reportProgress(onUpdate, LAUNCH_WORKFLOW_TOOL_NAME, 'Checking workflow capacity...');\n const maxConcurrent = resolveMaxConcurrent(dependencies.environment);\n const active = (await dependencies.activeRunCount?.()) ?? 0;\n if (active >= maxConcurrent) {\n throw new Error(\n withOptions(`This session is at capacity: ${active}/${maxConcurrent} workflows running.`, [\n 'Wait for a running workflow to finish, then launch again. The extension reports each one as it ends.',\n 'workflow_run with action status: show what is running, so the user can judge whether something is stuck.',\n 'workflow_run with action stop: free a slot by stopping a run the user no longer wants.',\n ]),\n );\n }\n\n if (input.runner) {\n const rejection = dependencies.rejectRunner?.(input.workflowPath, input.runner);\n if (rejection) throw new Error(rejection);\n }\n reportProgress(onUpdate, LAUNCH_WORKFLOW_TOOL_NAME, `Launching workflow ${input.workflowPath}...`);\n const workflowEnv = { ...input.env };\n const dispatcherContextFile = dependencies.environment.AGIFLOW_DISPATCH_CONTEXT_FILE;\n const dispatcherProjectId = dependencies.environment[AGIFLOW_PROJECT_ID_ENV]?.trim();\n if (\n dispatcherContextFile &&\n agiflowJobKind &&\n dispatcherProjectId &&\n explicitProjectId &&\n dispatcherProjectId !== explicitProjectId\n ) {\n throw new Error(\n `Agiflow workflow project identity conflicts with the dispatcher context (${explicitProjectId} versus ${dispatcherProjectId}).`,\n );\n }\n if (dispatcherContextFile) {\n for (const key of [\n 'AGIFLOW_ORGANIZATION_ID',\n 'AGIFLOW_PROJECT_ID',\n 'AGIFLOW_DEVICE_ID',\n 'BACKEND_AGIFLOW_API_ENDPOINT',\n 'AGIFLOW_DISPATCH_SECRET_FILE',\n ] as const) {\n const hostValue = dependencies.environment[key];\n if (hostValue) workflowEnv[key] = hostValue;\n }\n }\n const since = Date.now();\n const launch = dependencies.trackPendingRun(\n dependencies.runTool.execute({\n ...input,\n env: { ...workflowEnv, [PI_SESSION_ENV]: sessionId },\n }),\n );\n // Folded into a value before anything races it. A promise this function\n // may stop awaiting must never be able to reject unobserved, which in\n // Node ends the whole process, Pi's TUI included.\n const settled: Promise<LaunchOutcome> = launch.then(\n (value): LaunchOutcome => ({ kind: 'value', result: value }),\n (error: unknown): LaunchOutcome => ({ kind: 'error', error }),\n );\n\n const ack = await awaitLaunchAck(settled, dependencies, {\n sessionId,\n since,\n workflowPath: input.workflowPath,\n });\n\n if (ack.kind === 'settled') {\n const outcome = ack.outcome;\n if (outcome.kind === 'error') throw asError(outcome.error);\n const result = outcome.result;\n if (result.isError)\n throw new Error(withOptions(toolResultText(result) || 'Workflow launch failed.', launchFailureOptions));\n await dependencies.onLaunch?.(ctx);\n return result;\n }\n\n reportLateFailure(settled, dependencies, ctx);\n await dependencies.onLaunch?.(ctx);\n return {\n content: [\n {\n type: 'text',\n text: ack.kind === 'record' ? launchedRunSummary(ack.record) : launchHandoffSummary(input.workflowPath),\n },\n ],\n };\n },\n };\n}\n"],"mappings":"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"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import "../../schemas/workflowPi.mjs";
|
|
2
|
+
import { EmbeddedWorkflowFeature } from "@agimon-ai/workflow-mcp";
|
|
3
|
+
import { z } from "zod";
|
|
4
|
+
import "@earendil-works/pi-coding-agent";
|
|
5
|
+
import "@agimon-ai/doompi-core/tool-surface";
|
|
6
|
+
import "@modelcontextprotocol/sdk/types.js";
|
|
@@ -0,0 +1,200 @@
|
|
|
1
|
+
import { LAUNCH_WORKFLOW_TOOL_NAME, WORKFLOW_PI_TOOL_NAMES } from "../../constants/workflow.mjs";
|
|
2
|
+
import { PI_SESSION_ENV, launchHandoffSummary, launchedRunSummary, resolveMaxConcurrent, toolResultText, withOptions } from "../piToolBridge/index.mjs";
|
|
3
|
+
import { resolveRootSessionId } from "@agimon-ai/doompi-core/child-process";
|
|
4
|
+
//#region src/services/workflowExecution/index.ts
|
|
5
|
+
const AGIFLOW_JOB_ID_ENV = "AGIFLOW_JOB_ID";
|
|
6
|
+
const AGIFLOW_JOB_KIND_ENV = "AGIFLOW_JOB_KIND";
|
|
7
|
+
const AGIFLOW_PROJECT_ID_ENV = "AGIFLOW_PROJECT_ID";
|
|
8
|
+
/**
|
|
9
|
+
* What workflow mode does to the tool surface: nothing but hide its own tools.
|
|
10
|
+
*
|
|
11
|
+
* The tools are registered for the whole session because Pi has no other way to
|
|
12
|
+
* add one later, so the mode is expressed as a restriction rather than as a
|
|
13
|
+
* registration.
|
|
14
|
+
*/
|
|
15
|
+
function workflowToolRestriction(enabled) {
|
|
16
|
+
const hidden = new Set(WORKFLOW_PI_TOOL_NAMES);
|
|
17
|
+
return (incoming) => enabled ? incoming : incoming.filter((name) => !hidden.has(name));
|
|
18
|
+
}
|
|
19
|
+
/** How often the registry is asked whether the launch has produced a run. */
|
|
20
|
+
const LAUNCH_ACK_POLL_MS = 500;
|
|
21
|
+
/**
|
|
22
|
+
* How long to wait for that before answering without a run key.
|
|
23
|
+
*
|
|
24
|
+
* Long enough to cover a launcher that is merely slow, short enough that a
|
|
25
|
+
* caller is never left holding a turn open for a launcher that will not answer.
|
|
26
|
+
*/
|
|
27
|
+
const LAUNCH_ACK_TIMEOUT_MS = 15e3;
|
|
28
|
+
function reportProgress(onUpdate, tool, message) {
|
|
29
|
+
onUpdate?.({
|
|
30
|
+
content: [{
|
|
31
|
+
type: "text",
|
|
32
|
+
text: message
|
|
33
|
+
}],
|
|
34
|
+
details: { tool }
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
function appendGuidance(result, guidance) {
|
|
38
|
+
return {
|
|
39
|
+
...result,
|
|
40
|
+
content: [...result.content, {
|
|
41
|
+
type: "text",
|
|
42
|
+
text: guidance
|
|
43
|
+
}]
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
function statusAction(runKey) {
|
|
47
|
+
return `workflow_run {"action":"status","runKey":${JSON.stringify(runKey)}}`;
|
|
48
|
+
}
|
|
49
|
+
function actionGuidance(action, runKey) {
|
|
50
|
+
const status = statusAction(runKey);
|
|
51
|
+
if (action === "stop") return [`Next: call ${status} to confirm the run reached a terminal stage.`];
|
|
52
|
+
if (action === "recover") return [`Report the recovery failure and do not retry it blindly: call ${status} first.`, "Ask the user before launching fresh work when the recorded recovery is no longer valid."];
|
|
53
|
+
return [`Next: call ${status} to verify the recorded execution state.`];
|
|
54
|
+
}
|
|
55
|
+
const launchFailureOptions = [
|
|
56
|
+
"Report the failure to the user with the error above. A launch failure is usually a bad workflow path, a missing launcher, or a workflow whose own pre-conditions refused.",
|
|
57
|
+
"list_workflows: confirm the workflow path exists and its description matches the work, if the path may be wrong.",
|
|
58
|
+
"workflow_run with action status: check whether an earlier attempt is already running before launching again."
|
|
59
|
+
];
|
|
60
|
+
/**
|
|
61
|
+
* An Error, whatever the launch rejected with.
|
|
62
|
+
*
|
|
63
|
+
* A rejection reaches here as `unknown` because it crossed a promise boundary,
|
|
64
|
+
* and rethrowing that as-is hands Pi's tool layer something it cannot read a
|
|
65
|
+
* message or a stack off. The original is kept as the cause rather than
|
|
66
|
+
* flattened into a string.
|
|
67
|
+
*/
|
|
68
|
+
function asError(value) {
|
|
69
|
+
return value instanceof Error ? value : new Error(String(value), { cause: value });
|
|
70
|
+
}
|
|
71
|
+
/** Resolves to undefined, so a race against it reads as "nothing settled yet". */
|
|
72
|
+
function sleep(ms) {
|
|
73
|
+
return new Promise((settle) => {
|
|
74
|
+
setTimeout(() => settle(void 0), ms).unref?.();
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* Wait for whichever answer arrives first: the launch settling, the run
|
|
79
|
+
* appearing in the registry, or the budget running out.
|
|
80
|
+
*
|
|
81
|
+
* A launch that delegates to a terminal launcher settles when that launcher's
|
|
82
|
+
* whole process chain closes, which on a loaded machine has been measured
|
|
83
|
+
* minutes after the run itself was registered and working. The registry is the
|
|
84
|
+
* earlier and more truthful signal: a run recorded there is a run that started.
|
|
85
|
+
*/
|
|
86
|
+
async function awaitLaunchAck(settled, dependencies, query) {
|
|
87
|
+
const findLaunchedRun = dependencies.findLaunchedRun;
|
|
88
|
+
if (!findLaunchedRun) return {
|
|
89
|
+
kind: "settled",
|
|
90
|
+
outcome: await settled
|
|
91
|
+
};
|
|
92
|
+
const pollMs = dependencies.launchAckPollMs ?? LAUNCH_ACK_POLL_MS;
|
|
93
|
+
const deadline = Date.now() + (dependencies.launchAckTimeoutMs ?? LAUNCH_ACK_TIMEOUT_MS);
|
|
94
|
+
for (;;) {
|
|
95
|
+
const outcome = await Promise.race([settled, sleep(pollMs)]);
|
|
96
|
+
if (outcome) return {
|
|
97
|
+
kind: "settled",
|
|
98
|
+
outcome
|
|
99
|
+
};
|
|
100
|
+
const record = await findLaunchedRun(query).catch(() => void 0);
|
|
101
|
+
if (record) return {
|
|
102
|
+
kind: "record",
|
|
103
|
+
record
|
|
104
|
+
};
|
|
105
|
+
if (Date.now() >= deadline) return { kind: "handoff" };
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* Carry a failure that lands after the caller was told the run started.
|
|
110
|
+
*
|
|
111
|
+
* Answering early trades the launcher's exit code for timeliness. Dropping that
|
|
112
|
+
* code entirely is not part of the trade: a launch that fails a minute later
|
|
113
|
+
* would otherwise leave a user waiting on a run that never existed.
|
|
114
|
+
*/
|
|
115
|
+
function reportLateFailure(settled, dependencies, ctx) {
|
|
116
|
+
settled.then((outcome) => {
|
|
117
|
+
if (outcome.kind === "error") {
|
|
118
|
+
dependencies.onLateFailure?.(asError(outcome.error), ctx);
|
|
119
|
+
return;
|
|
120
|
+
}
|
|
121
|
+
if (outcome.result.isError) dependencies.onLateFailure?.(new Error(toolResultText(outcome.result) || "Workflow launch failed."), ctx);
|
|
122
|
+
});
|
|
123
|
+
}
|
|
124
|
+
function createWorkflowLaunchExecutor(dependencies) {
|
|
125
|
+
return { async execute(input, ctx, onUpdate) {
|
|
126
|
+
const sessionId = resolveRootSessionId(ctx.sessionManager.getSessionId(), dependencies.environment);
|
|
127
|
+
dependencies.observeSession?.(sessionId);
|
|
128
|
+
const agiflowJobKind = input.env?.[AGIFLOW_JOB_KIND_ENV]?.trim();
|
|
129
|
+
const agiflowJobId = input.env?.[AGIFLOW_JOB_ID_ENV]?.trim();
|
|
130
|
+
const explicitProjectId = input.env?.[AGIFLOW_PROJECT_ID_ENV]?.trim();
|
|
131
|
+
if (Boolean(agiflowJobKind) !== Boolean(agiflowJobId)) throw new Error("Agiflow workflow launches require AGIFLOW_JOB_KIND and AGIFLOW_JOB_ID together.");
|
|
132
|
+
if (agiflowJobKind && agiflowJobKind !== "task" && agiflowJobKind !== "work-unit") throw new Error("Agiflow workflow launches require AGIFLOW_JOB_KIND to be task or work-unit.");
|
|
133
|
+
if (agiflowJobKind && !explicitProjectId) throw new Error("Agiflow workflow launches require AGIFLOW_PROJECT_ID with the job identity.");
|
|
134
|
+
if (agiflowJobKind && !input.prompt?.trim()) throw new Error("Agiflow workflow launches require a non-empty prompt so user_prompt runs do not wait for terminal input.");
|
|
135
|
+
reportProgress(onUpdate, LAUNCH_WORKFLOW_TOOL_NAME, "Checking workflow capacity...");
|
|
136
|
+
const maxConcurrent = resolveMaxConcurrent(dependencies.environment);
|
|
137
|
+
const active = await dependencies.activeRunCount?.() ?? 0;
|
|
138
|
+
if (active >= maxConcurrent) throw new Error(withOptions(`This session is at capacity: ${active}/${maxConcurrent} workflows running.`, [
|
|
139
|
+
"Wait for a running workflow to finish, then launch again. The extension reports each one as it ends.",
|
|
140
|
+
"workflow_run with action status: show what is running, so the user can judge whether something is stuck.",
|
|
141
|
+
"workflow_run with action stop: free a slot by stopping a run the user no longer wants."
|
|
142
|
+
]));
|
|
143
|
+
if (input.runner) {
|
|
144
|
+
const rejection = dependencies.rejectRunner?.(input.workflowPath, input.runner);
|
|
145
|
+
if (rejection) throw new Error(rejection);
|
|
146
|
+
}
|
|
147
|
+
reportProgress(onUpdate, LAUNCH_WORKFLOW_TOOL_NAME, `Launching workflow ${input.workflowPath}...`);
|
|
148
|
+
const workflowEnv = { ...input.env };
|
|
149
|
+
const dispatcherContextFile = dependencies.environment.AGIFLOW_DISPATCH_CONTEXT_FILE;
|
|
150
|
+
const dispatcherProjectId = dependencies.environment[AGIFLOW_PROJECT_ID_ENV]?.trim();
|
|
151
|
+
if (dispatcherContextFile && agiflowJobKind && dispatcherProjectId && explicitProjectId && dispatcherProjectId !== explicitProjectId) throw new Error(`Agiflow workflow project identity conflicts with the dispatcher context (${explicitProjectId} versus ${dispatcherProjectId}).`);
|
|
152
|
+
if (dispatcherContextFile) for (const key of [
|
|
153
|
+
"AGIFLOW_ORGANIZATION_ID",
|
|
154
|
+
"AGIFLOW_PROJECT_ID",
|
|
155
|
+
"AGIFLOW_DEVICE_ID",
|
|
156
|
+
"BACKEND_AGIFLOW_API_ENDPOINT",
|
|
157
|
+
"AGIFLOW_DISPATCH_SECRET_FILE"
|
|
158
|
+
]) {
|
|
159
|
+
const hostValue = dependencies.environment[key];
|
|
160
|
+
if (hostValue) workflowEnv[key] = hostValue;
|
|
161
|
+
}
|
|
162
|
+
const since = Date.now();
|
|
163
|
+
const settled = dependencies.trackPendingRun(dependencies.runTool.execute({
|
|
164
|
+
...input,
|
|
165
|
+
env: {
|
|
166
|
+
...workflowEnv,
|
|
167
|
+
[PI_SESSION_ENV]: sessionId
|
|
168
|
+
}
|
|
169
|
+
})).then((value) => ({
|
|
170
|
+
kind: "value",
|
|
171
|
+
result: value
|
|
172
|
+
}), (error) => ({
|
|
173
|
+
kind: "error",
|
|
174
|
+
error
|
|
175
|
+
}));
|
|
176
|
+
const ack = await awaitLaunchAck(settled, dependencies, {
|
|
177
|
+
sessionId,
|
|
178
|
+
since,
|
|
179
|
+
workflowPath: input.workflowPath
|
|
180
|
+
});
|
|
181
|
+
if (ack.kind === "settled") {
|
|
182
|
+
const outcome = ack.outcome;
|
|
183
|
+
if (outcome.kind === "error") throw asError(outcome.error);
|
|
184
|
+
const result = outcome.result;
|
|
185
|
+
if (result.isError) throw new Error(withOptions(toolResultText(result) || "Workflow launch failed.", launchFailureOptions));
|
|
186
|
+
await dependencies.onLaunch?.(ctx);
|
|
187
|
+
return result;
|
|
188
|
+
}
|
|
189
|
+
reportLateFailure(settled, dependencies, ctx);
|
|
190
|
+
await dependencies.onLaunch?.(ctx);
|
|
191
|
+
return { content: [{
|
|
192
|
+
type: "text",
|
|
193
|
+
text: ack.kind === "record" ? launchedRunSummary(ack.record) : launchHandoffSummary(input.workflowPath)
|
|
194
|
+
}] };
|
|
195
|
+
} };
|
|
196
|
+
}
|
|
197
|
+
//#endregion
|
|
198
|
+
export { actionGuidance, appendGuidance, createWorkflowLaunchExecutor, launchFailureOptions, reportProgress, workflowToolRestriction };
|
|
199
|
+
|
|
200
|
+
//# sourceMappingURL=index.mjs.map
|