@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,221 @@
|
|
|
1
|
+
const require_workflow = require("../../constants/workflow.cjs");
|
|
2
|
+
const require_workflowPi = require("../../schemas/workflowPi.cjs");
|
|
3
|
+
const require_index = require("../piToolBridge/index.cjs");
|
|
4
|
+
const require_index$1 = require("../workflowExecution/index.cjs");
|
|
5
|
+
let _agimon_ai_doompi_core_child_process = require("@agimon-ai/doompi-core/child-process");
|
|
6
|
+
let _agimon_ai_workflow_mcp = require("@agimon-ai/workflow-mcp");
|
|
7
|
+
let zod = require("zod");
|
|
8
|
+
//#region src/services/workflowTools/index.ts
|
|
9
|
+
const PI_LAUNCH_FIELDS = {
|
|
10
|
+
workflowPath: true,
|
|
11
|
+
workspace: true,
|
|
12
|
+
runner: true,
|
|
13
|
+
name: true,
|
|
14
|
+
env: true,
|
|
15
|
+
prompt: true,
|
|
16
|
+
job: true,
|
|
17
|
+
inputs: true
|
|
18
|
+
};
|
|
19
|
+
function createWorkflowTools(dependencies, renderers = () => ({})) {
|
|
20
|
+
const feature = dependencies.feature ?? (0, _agimon_ai_workflow_mcp.createEmbeddedWorkflowFeature)();
|
|
21
|
+
const runTool = dependencies.runTool ?? feature.runTool;
|
|
22
|
+
const listWorkflowsTool = dependencies.listWorkflowsTool ?? feature.listWorkflowsTool;
|
|
23
|
+
const recoverTool = dependencies.recoverTool ?? feature.createRecoverTool();
|
|
24
|
+
const controlTool = dependencies.controlTool ?? feature.createControlTool();
|
|
25
|
+
const trackPendingRun = dependencies.trackPendingRun ?? ((run) => run);
|
|
26
|
+
const launchExecutor = dependencies.launchExecutor ?? require_index$1.createWorkflowLaunchExecutor({
|
|
27
|
+
environment: dependencies.environment,
|
|
28
|
+
activeRunCount: dependencies.activeRunCount,
|
|
29
|
+
onLaunch: dependencies.onLaunch,
|
|
30
|
+
observeSession: dependencies.observeSession,
|
|
31
|
+
rejectRunner: dependencies.rejectRunner,
|
|
32
|
+
runTool,
|
|
33
|
+
trackPendingRun
|
|
34
|
+
});
|
|
35
|
+
return [
|
|
36
|
+
{
|
|
37
|
+
name: require_workflow.LIST_WORKFLOWS_TOOL_NAME,
|
|
38
|
+
label: "List Workflows",
|
|
39
|
+
description: "List the workflow definitions available in this repository.",
|
|
40
|
+
promptSnippet: "List available workflow definitions",
|
|
41
|
+
parameters: zod.z.toJSONSchema(listWorkflowsTool.getInputSchema()),
|
|
42
|
+
renderShell: "self",
|
|
43
|
+
...renderers(require_workflow.LIST_WORKFLOWS_TOOL_NAME),
|
|
44
|
+
async execute(_toolCallId, params) {
|
|
45
|
+
return require_index.toAgentToolResult(require_workflow.LIST_WORKFLOWS_TOOL_NAME, await listWorkflowsTool.execute(params));
|
|
46
|
+
}
|
|
47
|
+
},
|
|
48
|
+
{
|
|
49
|
+
name: require_workflow.LAUNCH_WORKFLOW_TOOL_NAME,
|
|
50
|
+
label: "Launch Workflow",
|
|
51
|
+
description: "Start a workflow run. Returns once the run has started, not once it finishes; use workflow_run with action status or wait for the completion notice.",
|
|
52
|
+
promptSnippet: "Start a workflow run and return its identifier",
|
|
53
|
+
promptGuidelines: [
|
|
54
|
+
"Before launching, call list_workflows and pick the workflow whose own description matches the work. A workflow description is the source of truth; never infer one from its filename. If nothing matches, say so and stop rather than launching an approximate fit.",
|
|
55
|
+
"launch_workflow returns when the run has STARTED, not when it has finished. Never report success from its result. Poll workflow_run with action status, or wait for the completion notice the extension delivers on its own.",
|
|
56
|
+
"When dispatching Agiflow work, pass AGIFLOW_PROJECT_ID, AGIFLOW_JOB_KIND, and AGIFLOW_JOB_ID through env plus a non-empty prompt. Kind must be task or work-unit. The id alone is not a key, and omitting prompt leaves user_prompt workflows waiting for terminal input.",
|
|
57
|
+
"A workflow claims its own job in its pre step. Never claim a job yourself. JOB_ALREADY_CLAIMED or HTTP 409 means another worker won the race, so report contention and do not unlock, release, or retry automatically.",
|
|
58
|
+
"If a result says WORKFLOW_NOT_OWNED or a release failed, inspect current ownership and ask the user before any release or unlock. Never force another worker’s lock.",
|
|
59
|
+
"If a running workflow is not found, call workflow_run with action status to re-check current state before retrying.",
|
|
60
|
+
"The per-session concurrency ceiling is a real limit. If launch_workflow refuses, wait for a run to finish; do not launch through the shell to get around it."
|
|
61
|
+
],
|
|
62
|
+
parameters: zod.z.toJSONSchema(runTool.getInputSchema().pick(PI_LAUNCH_FIELDS)),
|
|
63
|
+
renderShell: "self",
|
|
64
|
+
...renderers(require_workflow.LAUNCH_WORKFLOW_TOOL_NAME),
|
|
65
|
+
async execute(_toolCallId, params, _signal, onUpdate, ctx) {
|
|
66
|
+
const input = params;
|
|
67
|
+
const result = await launchExecutor.execute(input, ctx, onUpdate);
|
|
68
|
+
const adapted = require_index.toAgentToolResult(require_workflow.LAUNCH_WORKFLOW_TOOL_NAME, result, require_index$1.launchFailureOptions);
|
|
69
|
+
return require_index$1.appendGuidance(adapted, "Next: call workflow_run with action status and verify the recorded stage before reporting the workflow outcome.");
|
|
70
|
+
}
|
|
71
|
+
},
|
|
72
|
+
{
|
|
73
|
+
name: require_workflow.WORKFLOW_RUN_TOOL_NAME,
|
|
74
|
+
label: "Workflow Run",
|
|
75
|
+
description: "Inspect or control one workflow run. Use action status, tail, recovery-evidence, follow, open, pause, resume, stop, or recover. Every action requires an exact run key.",
|
|
76
|
+
promptSnippet: "Inspect or control a workflow run",
|
|
77
|
+
promptGuidelines: [
|
|
78
|
+
"Use action status as the authority for stage, outcome, execution state, and pause cursor. A run that started is not a run that succeeded.",
|
|
79
|
+
"Use action pause or resume for cooperative lifecycle control. Pause is not stop: the run keeps its stage running, capacity, services, and heartbeat while paused.",
|
|
80
|
+
"Use action stop only when the user requests stopping a run. A user-requested stop is not a failure and needs no failure diagnosis.",
|
|
81
|
+
"Do not use follow or tail merely to wait for a healthy run; use status or the completion notice. Tail returns chat-safe status without raw PTY frames. Use follow only when the user asks to pin live progress, and open only when a human wants the recorded launcher foregrounded.",
|
|
82
|
+
"Use action recovery-evidence for terminal-only, durable status and artifacts before recovery. It is the only inspection path that may read a failed run from an earlier session and it never reads a live launcher.",
|
|
83
|
+
"Use action recover only after loading the `workflow-recovery` skill and gathering its required evidence. Recovery may adopt a terminal failed run from an earlier Pi session; it never grants cross-session control of running work. Never edit issue.md or repair.json, and verify real process and registry progress before recovery.",
|
|
84
|
+
"Never unlock or force-release an Agiflow claim from this tool."
|
|
85
|
+
],
|
|
86
|
+
parameters: zod.z.toJSONSchema(require_workflowPi.workflowRunInputSchema),
|
|
87
|
+
renderShell: "self",
|
|
88
|
+
...renderers(require_workflow.WORKFLOW_RUN_TOOL_NAME),
|
|
89
|
+
async execute(_toolCallId, rawParams, _signal, onUpdate, ctx) {
|
|
90
|
+
const input = require_workflowPi.workflowRunInputSchema.parse(rawParams);
|
|
91
|
+
const sessionId = (0, _agimon_ai_doompi_core_child_process.resolveRootSessionId)(ctx.sessionManager.getSessionId(), dependencies.environment);
|
|
92
|
+
dependencies.observeSession?.(sessionId);
|
|
93
|
+
const selector = {
|
|
94
|
+
runKey: input.runKey,
|
|
95
|
+
workspace: input.workspace
|
|
96
|
+
};
|
|
97
|
+
const requireOwnedRun = async () => {
|
|
98
|
+
if (!dependencies.requireSessionRun) throw new Error("Workflow run ownership is not available in this session.");
|
|
99
|
+
return dependencies.requireSessionRun(selector, sessionId);
|
|
100
|
+
};
|
|
101
|
+
if (input.action === "status") {
|
|
102
|
+
const record = await requireOwnedRun();
|
|
103
|
+
return {
|
|
104
|
+
content: [{
|
|
105
|
+
type: "text",
|
|
106
|
+
text: JSON.stringify(record, null, 2)
|
|
107
|
+
}],
|
|
108
|
+
details: { tool: require_workflow.WORKFLOW_RUN_TOOL_NAME }
|
|
109
|
+
};
|
|
110
|
+
}
|
|
111
|
+
if (input.action === "tail") {
|
|
112
|
+
if (!dependencies.tailRun) throw new Error("Reading workflow output is not available in this session.");
|
|
113
|
+
const record = await requireOwnedRun();
|
|
114
|
+
require_index$1.reportProgress(onUpdate, require_workflow.WORKFLOW_RUN_TOOL_NAME, `Reading output for workflow ${input.runKey}...`);
|
|
115
|
+
await dependencies.tailRun(selector, ctx);
|
|
116
|
+
return {
|
|
117
|
+
content: [{
|
|
118
|
+
type: "text",
|
|
119
|
+
text: [
|
|
120
|
+
`Workflow: ${record.displayName} (${record.runKey})`,
|
|
121
|
+
`Stage: ${record.effectiveStage ?? record.stage}`,
|
|
122
|
+
"Raw launcher output is hidden from chat. Use action follow or open to view it."
|
|
123
|
+
].join("\n")
|
|
124
|
+
}],
|
|
125
|
+
details: { tool: require_workflow.WORKFLOW_RUN_TOOL_NAME }
|
|
126
|
+
};
|
|
127
|
+
}
|
|
128
|
+
if (input.action === "recovery-evidence") {
|
|
129
|
+
if (!dependencies.readRecoveryEvidence) throw new Error("Reading workflow recovery evidence is not available in this session.");
|
|
130
|
+
require_index$1.reportProgress(onUpdate, require_workflow.WORKFLOW_RUN_TOOL_NAME, `Reading recovery evidence for workflow ${input.runKey}...`);
|
|
131
|
+
return {
|
|
132
|
+
content: [{
|
|
133
|
+
type: "text",
|
|
134
|
+
text: await dependencies.readRecoveryEvidence(selector, ctx)
|
|
135
|
+
}],
|
|
136
|
+
details: { tool: require_workflow.WORKFLOW_RUN_TOOL_NAME }
|
|
137
|
+
};
|
|
138
|
+
}
|
|
139
|
+
if (input.action === "follow") {
|
|
140
|
+
if (!dependencies.followRun) throw new Error("Following workflow output is not available in this session.");
|
|
141
|
+
await requireOwnedRun();
|
|
142
|
+
require_index$1.reportProgress(onUpdate, require_workflow.WORKFLOW_RUN_TOOL_NAME, `Following workflow ${input.runKey}...`);
|
|
143
|
+
return {
|
|
144
|
+
content: [{
|
|
145
|
+
type: "text",
|
|
146
|
+
text: await dependencies.followRun(selector, ctx)
|
|
147
|
+
}],
|
|
148
|
+
details: { tool: require_workflow.WORKFLOW_RUN_TOOL_NAME }
|
|
149
|
+
};
|
|
150
|
+
}
|
|
151
|
+
if (input.action === "open") {
|
|
152
|
+
if (!dependencies.openRun) throw new Error("Opening a workflow launcher is not available in this session.");
|
|
153
|
+
await requireOwnedRun();
|
|
154
|
+
require_index$1.reportProgress(onUpdate, require_workflow.WORKFLOW_RUN_TOOL_NAME, `Opening workflow ${input.runKey}...`);
|
|
155
|
+
return {
|
|
156
|
+
content: [{
|
|
157
|
+
type: "text",
|
|
158
|
+
text: await dependencies.openRun(selector, ctx)
|
|
159
|
+
}],
|
|
160
|
+
details: { tool: require_workflow.WORKFLOW_RUN_TOOL_NAME }
|
|
161
|
+
};
|
|
162
|
+
}
|
|
163
|
+
if (input.action === "recover") {
|
|
164
|
+
if (!dependencies.requireRecoverableRun) throw new Error("Workflow recovery ownership transfer is not available in this session.");
|
|
165
|
+
const recoverable = await dependencies.requireRecoverableRun(selector);
|
|
166
|
+
const recoverySelector = {
|
|
167
|
+
runKey: recoverable.runKey,
|
|
168
|
+
workspace: recoverable.workspace
|
|
169
|
+
};
|
|
170
|
+
require_index$1.reportProgress(onUpdate, require_workflow.WORKFLOW_RUN_TOOL_NAME, `Recovering workflow ${input.runKey}...`);
|
|
171
|
+
if (!input.dryRun) {
|
|
172
|
+
const delegated = await dependencies.delegateRecovery?.({
|
|
173
|
+
...recoverySelector,
|
|
174
|
+
runner: input.runner
|
|
175
|
+
}, ctx);
|
|
176
|
+
if (delegated) {
|
|
177
|
+
const guidance = require_index$1.actionGuidance(input.action, input.runKey);
|
|
178
|
+
await dependencies.onLaunch?.(ctx);
|
|
179
|
+
return {
|
|
180
|
+
content: [{
|
|
181
|
+
type: "text",
|
|
182
|
+
text: [delegated, guidance[0]].join("\n\n")
|
|
183
|
+
}],
|
|
184
|
+
details: { tool: require_workflow.WORKFLOW_RUN_TOOL_NAME }
|
|
185
|
+
};
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
const recoverInput = {
|
|
189
|
+
dryRun: input.dryRun,
|
|
190
|
+
job: input.job,
|
|
191
|
+
runKey: recoverySelector.runKey,
|
|
192
|
+
runner: input.runner,
|
|
193
|
+
workspace: recoverySelector.workspace
|
|
194
|
+
};
|
|
195
|
+
const result = await trackPendingRun(recoverTool.execute(recoverInput));
|
|
196
|
+
const guidance = require_index$1.actionGuidance(input.action, input.runKey);
|
|
197
|
+
const adapted = require_index.toAgentToolResult(require_workflow.WORKFLOW_RUN_TOOL_NAME, result, guidance);
|
|
198
|
+
await dependencies.onLaunch?.(ctx);
|
|
199
|
+
return require_index$1.appendGuidance(adapted, guidance[0]);
|
|
200
|
+
}
|
|
201
|
+
const ownedRun = await requireOwnedRun();
|
|
202
|
+
if (!ownedRun.runId) throw new Error(`Workflow ${input.runKey} has no controllable run generation.`);
|
|
203
|
+
require_index$1.reportProgress(onUpdate, require_workflow.WORKFLOW_RUN_TOOL_NAME, `Requesting ${input.action} for workflow ${input.runKey}...`);
|
|
204
|
+
const result = await controlTool.execute({
|
|
205
|
+
action: input.action,
|
|
206
|
+
expectedRunId: ownedRun.runId,
|
|
207
|
+
reason: input.reason,
|
|
208
|
+
runKey: input.runKey,
|
|
209
|
+
workspace: input.workspace
|
|
210
|
+
});
|
|
211
|
+
const guidance = require_index$1.actionGuidance(input.action, input.runKey);
|
|
212
|
+
const adapted = require_index.toAgentToolResult(require_workflow.WORKFLOW_RUN_TOOL_NAME, result, guidance);
|
|
213
|
+
return require_index$1.appendGuidance(adapted, guidance[0]);
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
];
|
|
217
|
+
}
|
|
218
|
+
//#endregion
|
|
219
|
+
exports.createWorkflowTools = createWorkflowTools;
|
|
220
|
+
|
|
221
|
+
//# sourceMappingURL=index.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.cjs","names":["createEmbeddedWorkflowFeature","createWorkflowLaunchExecutor","LIST_WORKFLOWS_TOOL_NAME","z","toAgentToolResult","LAUNCH_WORKFLOW_TOOL_NAME","launchFailureOptions","appendGuidance","WORKFLOW_RUN_TOOL_NAME","workflowRunInputSchema","resolveRootSessionId","actionGuidance"],"sources":["../../../../src/services/workflowTools/index.ts"],"sourcesContent":["import { resolveRootSessionId } from '@agimon-ai/doompi-core/child-process';\nimport {\n createEmbeddedWorkflowFeature,\n type WorkflowRunRecord,\n type EmbeddedWorkflowFeature,\n} from '@agimon-ai/workflow-mcp';\nimport type { ExtensionAPI, ToolDefinition } from '@earendil-works/pi-coding-agent';\nimport { z } from 'zod';\n\nimport { workflowRunInputSchema } from '../../schemas/workflowPi';\nimport { toAgentToolResult, type WorkflowToolDetails } from '../../services/piToolBridge';\nimport {\n type WorkflowLaunchInput,\n type WorkflowRunSelector,\n launchFailureOptions,\n} from '../../services/workflowExecution';\nimport {\n createWorkflowLaunchExecutor,\n reportProgress,\n appendGuidance,\n actionGuidance,\n type WorkflowPiToolDependencies,\n} from '../../services/workflowExecution';\ntype WorkflowToolSchema = Parameters<ExtensionAPI['registerTool']>[0]['parameters'];\nimport {\n WORKFLOW_PI_TOOL_NAMES,\n LIST_WORKFLOWS_TOOL_NAME,\n LAUNCH_WORKFLOW_TOOL_NAME,\n WORKFLOW_RUN_TOOL_NAME,\n} from '../../constants/workflow';\nconst PI_LAUNCH_FIELDS = {\n workflowPath: true,\n workspace: true,\n runner: true,\n name: true,\n env: true,\n prompt: true,\n job: true,\n inputs: true,\n} as const;\nexport type WorkflowNativeTool = ToolDefinition<WorkflowToolSchema, WorkflowToolDetails>;\nexport type WorkflowToolRenderers = Pick<WorkflowNativeTool, 'renderCall' | 'renderResult'>;\nexport function createWorkflowTools(\n dependencies: WorkflowPiToolDependencies,\n renderers: (name: (typeof WORKFLOW_PI_TOOL_NAMES)[number]) => WorkflowToolRenderers = () => ({}),\n): WorkflowNativeTool[] {\n const feature = dependencies.feature ?? createEmbeddedWorkflowFeature();\n const runTool = dependencies.runTool ?? feature.runTool;\n const listWorkflowsTool = dependencies.listWorkflowsTool ?? feature.listWorkflowsTool;\n const recoverTool = dependencies.recoverTool ?? feature.createRecoverTool();\n const controlTool = dependencies.controlTool ?? feature.createControlTool();\n const trackPendingRun = dependencies.trackPendingRun ?? (<T>(run: Promise<T>): Promise<T> => run);\n const launchExecutor =\n dependencies.launchExecutor ??\n createWorkflowLaunchExecutor({\n environment: dependencies.environment,\n activeRunCount: dependencies.activeRunCount,\n onLaunch: dependencies.onLaunch,\n observeSession: dependencies.observeSession,\n rejectRunner: dependencies.rejectRunner,\n runTool,\n trackPendingRun,\n });\n\n return [\n {\n name: LIST_WORKFLOWS_TOOL_NAME,\n label: 'List Workflows',\n description: 'List the workflow definitions available in this repository.',\n promptSnippet: 'List available workflow definitions',\n parameters: z.toJSONSchema(listWorkflowsTool.getInputSchema()),\n renderShell: 'self',\n ...renderers(LIST_WORKFLOWS_TOOL_NAME),\n async execute(_toolCallId, params) {\n return toAgentToolResult(\n LIST_WORKFLOWS_TOOL_NAME,\n await listWorkflowsTool.execute(\n params as Parameters<EmbeddedWorkflowFeature['listWorkflowsTool']['execute']>[0],\n ),\n );\n },\n },\n\n {\n name: LAUNCH_WORKFLOW_TOOL_NAME,\n label: 'Launch Workflow',\n description:\n 'Start a workflow run. Returns once the run has started, not once it finishes; use workflow_run with action status or wait for the completion notice.',\n promptSnippet: 'Start a workflow run and return its identifier',\n promptGuidelines: [\n 'Before launching, call list_workflows and pick the workflow whose own description matches the work. A workflow description is the source of truth; never infer one from its filename. If nothing matches, say so and stop rather than launching an approximate fit.',\n 'launch_workflow returns when the run has STARTED, not when it has finished. Never report success from its result. Poll workflow_run with action status, or wait for the completion notice the extension delivers on its own.',\n 'When dispatching Agiflow work, pass AGIFLOW_PROJECT_ID, AGIFLOW_JOB_KIND, and AGIFLOW_JOB_ID through env plus a non-empty prompt. Kind must be task or work-unit. The id alone is not a key, and omitting prompt leaves user_prompt workflows waiting for terminal input.',\n 'A workflow claims its own job in its pre step. Never claim a job yourself. JOB_ALREADY_CLAIMED or HTTP 409 means another worker won the race, so report contention and do not unlock, release, or retry automatically.',\n 'If a result says WORKFLOW_NOT_OWNED or a release failed, inspect current ownership and ask the user before any release or unlock. Never force another worker’s lock.',\n 'If a running workflow is not found, call workflow_run with action status to re-check current state before retrying.',\n 'The per-session concurrency ceiling is a real limit. If launch_workflow refuses, wait for a run to finish; do not launch through the shell to get around it.',\n ],\n parameters: z.toJSONSchema(runTool.getInputSchema().pick(PI_LAUNCH_FIELDS)),\n renderShell: 'self',\n ...renderers(LAUNCH_WORKFLOW_TOOL_NAME),\n async execute(_toolCallId, params, _signal, onUpdate, ctx) {\n const input = params as WorkflowLaunchInput;\n const result = await launchExecutor.execute(input, ctx, onUpdate);\n const adapted = toAgentToolResult(LAUNCH_WORKFLOW_TOOL_NAME, result, launchFailureOptions);\n return appendGuidance(\n adapted,\n 'Next: call workflow_run with action status and verify the recorded stage before reporting the workflow outcome.',\n );\n },\n },\n\n {\n name: WORKFLOW_RUN_TOOL_NAME,\n label: 'Workflow Run',\n description:\n 'Inspect or control one workflow run. Use action status, tail, recovery-evidence, follow, open, pause, resume, stop, or recover. Every action requires an exact run key.',\n promptSnippet: 'Inspect or control a workflow run',\n promptGuidelines: [\n 'Use action status as the authority for stage, outcome, execution state, and pause cursor. A run that started is not a run that succeeded.',\n 'Use action pause or resume for cooperative lifecycle control. Pause is not stop: the run keeps its stage running, capacity, services, and heartbeat while paused.',\n 'Use action stop only when the user requests stopping a run. A user-requested stop is not a failure and needs no failure diagnosis.',\n 'Do not use follow or tail merely to wait for a healthy run; use status or the completion notice. Tail returns chat-safe status without raw PTY frames. Use follow only when the user asks to pin live progress, and open only when a human wants the recorded launcher foregrounded.',\n 'Use action recovery-evidence for terminal-only, durable status and artifacts before recovery. It is the only inspection path that may read a failed run from an earlier session and it never reads a live launcher.',\n 'Use action recover only after loading the `workflow-recovery` skill and gathering its required evidence. Recovery may adopt a terminal failed run from an earlier Pi session; it never grants cross-session control of running work. Never edit issue.md or repair.json, and verify real process and registry progress before recovery.',\n 'Never unlock or force-release an Agiflow claim from this tool.',\n ],\n parameters: z.toJSONSchema(workflowRunInputSchema),\n renderShell: 'self',\n ...renderers(WORKFLOW_RUN_TOOL_NAME),\n async execute(_toolCallId, rawParams, _signal, onUpdate, ctx) {\n const input = workflowRunInputSchema.parse(rawParams);\n const sessionId = resolveRootSessionId(ctx.sessionManager.getSessionId(), dependencies.environment);\n dependencies.observeSession?.(sessionId);\n const selector: WorkflowRunSelector = { runKey: input.runKey, workspace: input.workspace };\n const requireOwnedRun = async (): Promise<WorkflowRunRecord> => {\n if (!dependencies.requireSessionRun) {\n throw new Error('Workflow run ownership is not available in this session.');\n }\n return dependencies.requireSessionRun(selector, sessionId);\n };\n\n if (input.action === 'status') {\n const record = await requireOwnedRun();\n return {\n content: [{ type: 'text', text: JSON.stringify(record, null, 2) }],\n details: { tool: WORKFLOW_RUN_TOOL_NAME },\n };\n }\n if (input.action === 'tail') {\n if (!dependencies.tailRun) throw new Error('Reading workflow output is not available in this session.');\n const record = await requireOwnedRun();\n reportProgress(onUpdate, WORKFLOW_RUN_TOOL_NAME, `Reading output for workflow ${input.runKey}...`);\n await dependencies.tailRun(selector, ctx);\n return {\n content: [\n {\n type: 'text',\n text: [\n `Workflow: ${record.displayName} (${record.runKey})`,\n `Stage: ${record.effectiveStage ?? record.stage}`,\n 'Raw launcher output is hidden from chat. Use action follow or open to view it.',\n ].join('\\n'),\n },\n ],\n details: { tool: WORKFLOW_RUN_TOOL_NAME },\n };\n }\n if (input.action === 'recovery-evidence') {\n if (!dependencies.readRecoveryEvidence) {\n throw new Error('Reading workflow recovery evidence is not available in this session.');\n }\n reportProgress(onUpdate, WORKFLOW_RUN_TOOL_NAME, `Reading recovery evidence for workflow ${input.runKey}...`);\n return {\n content: [{ type: 'text', text: await dependencies.readRecoveryEvidence(selector, ctx) }],\n details: { tool: WORKFLOW_RUN_TOOL_NAME },\n };\n }\n if (input.action === 'follow') {\n if (!dependencies.followRun) throw new Error('Following workflow output is not available in this session.');\n await requireOwnedRun();\n reportProgress(onUpdate, WORKFLOW_RUN_TOOL_NAME, `Following workflow ${input.runKey}...`);\n return {\n content: [{ type: 'text', text: await dependencies.followRun(selector, ctx) }],\n details: { tool: WORKFLOW_RUN_TOOL_NAME },\n };\n }\n if (input.action === 'open') {\n if (!dependencies.openRun) throw new Error('Opening a workflow launcher is not available in this session.');\n await requireOwnedRun();\n reportProgress(onUpdate, WORKFLOW_RUN_TOOL_NAME, `Opening workflow ${input.runKey}...`);\n return {\n content: [{ type: 'text', text: await dependencies.openRun(selector, ctx) }],\n details: { tool: WORKFLOW_RUN_TOOL_NAME },\n };\n }\n\n if (input.action === 'recover') {\n if (!dependencies.requireRecoverableRun) {\n throw new Error('Workflow recovery ownership transfer is not available in this session.');\n }\n const recoverable = await dependencies.requireRecoverableRun(selector);\n const recoverySelector = { runKey: recoverable.runKey, workspace: recoverable.workspace };\n reportProgress(onUpdate, WORKFLOW_RUN_TOOL_NAME, `Recovering workflow ${input.runKey}...`);\n // A recovery replays the workflow, and the replay skips the launch\n // step, so every job runs in THIS process. For a workflow whose steps\n // are interactive that means an agent TUI spawned onto this process's\n // own terminal. Hand it to a launcher instead, where the workflow says\n // how. A dry run prints rather than executes, so it stays here.\n if (!input.dryRun) {\n const delegated = await dependencies.delegateRecovery?.({ ...recoverySelector, runner: input.runner }, ctx);\n if (delegated) {\n const guidance = actionGuidance(input.action, input.runKey);\n await dependencies.onLaunch?.(ctx);\n return {\n content: [{ type: 'text', text: [delegated, guidance[0]].join('\\n\\n') }],\n details: { tool: WORKFLOW_RUN_TOOL_NAME },\n };\n }\n }\n const recoverInput = {\n dryRun: input.dryRun,\n job: input.job,\n runKey: recoverySelector.runKey,\n runner: input.runner,\n workspace: recoverySelector.workspace,\n };\n const result = await trackPendingRun(recoverTool.execute(recoverInput));\n const guidance = actionGuidance(input.action, input.runKey);\n const adapted = toAgentToolResult(WORKFLOW_RUN_TOOL_NAME, result, guidance);\n await dependencies.onLaunch?.(ctx);\n return appendGuidance(adapted, guidance[0]!);\n }\n\n const ownedRun = await requireOwnedRun();\n if (!ownedRun.runId) throw new Error(`Workflow ${input.runKey} has no controllable run generation.`);\n reportProgress(onUpdate, WORKFLOW_RUN_TOOL_NAME, `Requesting ${input.action} for workflow ${input.runKey}...`);\n const result = await controlTool.execute({\n action: input.action,\n expectedRunId: ownedRun.runId,\n reason: input.reason,\n runKey: input.runKey,\n workspace: input.workspace,\n });\n const guidance = actionGuidance(input.action, input.runKey);\n const adapted = toAgentToolResult(WORKFLOW_RUN_TOOL_NAME, result, guidance);\n return appendGuidance(adapted, guidance[0]!);\n },\n },\n ];\n}\n"],"mappings":";;;;;;;;AA8BA,MAAM,mBAAmB;CACv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,eAAe,SAAS;KACxB,QAAQ,MAAM;KACd,QAAQ,MAAM;KACd,WAAW,MAAM;IACnB,CAAC;IACD,MAAM,WAAWG,gBAAAA,eAAe,MAAM,QAAQ,MAAM,MAAM;IAC1D,MAAM,UAAUP,cAAAA,kBAAkBI,iBAAAA,wBAAwB,QAAQ,QAAQ;IAC1E,OAAOD,gBAAAA,eAAe,SAAS,SAAS,EAAG;GAC7C;EACF;CACF;AACF"}
|
|
@@ -0,0 +1,221 @@
|
|
|
1
|
+
import { LAUNCH_WORKFLOW_TOOL_NAME, LIST_WORKFLOWS_TOOL_NAME, WORKFLOW_RUN_TOOL_NAME } from "../../constants/workflow.mjs";
|
|
2
|
+
import { workflowRunInputSchema } from "../../schemas/workflowPi.mjs";
|
|
3
|
+
import { toAgentToolResult } from "../piToolBridge/index.mjs";
|
|
4
|
+
import { actionGuidance, appendGuidance, createWorkflowLaunchExecutor, launchFailureOptions, reportProgress } from "../workflowExecution/index.mjs";
|
|
5
|
+
import { resolveRootSessionId } from "@agimon-ai/doompi-core/child-process";
|
|
6
|
+
import { createEmbeddedWorkflowFeature } from "@agimon-ai/workflow-mcp";
|
|
7
|
+
import { z } from "zod";
|
|
8
|
+
//#region src/services/workflowTools/index.ts
|
|
9
|
+
const PI_LAUNCH_FIELDS = {
|
|
10
|
+
workflowPath: true,
|
|
11
|
+
workspace: true,
|
|
12
|
+
runner: true,
|
|
13
|
+
name: true,
|
|
14
|
+
env: true,
|
|
15
|
+
prompt: true,
|
|
16
|
+
job: true,
|
|
17
|
+
inputs: true
|
|
18
|
+
};
|
|
19
|
+
function createWorkflowTools(dependencies, renderers = () => ({})) {
|
|
20
|
+
const feature = dependencies.feature ?? createEmbeddedWorkflowFeature();
|
|
21
|
+
const runTool = dependencies.runTool ?? feature.runTool;
|
|
22
|
+
const listWorkflowsTool = dependencies.listWorkflowsTool ?? feature.listWorkflowsTool;
|
|
23
|
+
const recoverTool = dependencies.recoverTool ?? feature.createRecoverTool();
|
|
24
|
+
const controlTool = dependencies.controlTool ?? feature.createControlTool();
|
|
25
|
+
const trackPendingRun = dependencies.trackPendingRun ?? ((run) => run);
|
|
26
|
+
const launchExecutor = dependencies.launchExecutor ?? createWorkflowLaunchExecutor({
|
|
27
|
+
environment: dependencies.environment,
|
|
28
|
+
activeRunCount: dependencies.activeRunCount,
|
|
29
|
+
onLaunch: dependencies.onLaunch,
|
|
30
|
+
observeSession: dependencies.observeSession,
|
|
31
|
+
rejectRunner: dependencies.rejectRunner,
|
|
32
|
+
runTool,
|
|
33
|
+
trackPendingRun
|
|
34
|
+
});
|
|
35
|
+
return [
|
|
36
|
+
{
|
|
37
|
+
name: LIST_WORKFLOWS_TOOL_NAME,
|
|
38
|
+
label: "List Workflows",
|
|
39
|
+
description: "List the workflow definitions available in this repository.",
|
|
40
|
+
promptSnippet: "List available workflow definitions",
|
|
41
|
+
parameters: z.toJSONSchema(listWorkflowsTool.getInputSchema()),
|
|
42
|
+
renderShell: "self",
|
|
43
|
+
...renderers(LIST_WORKFLOWS_TOOL_NAME),
|
|
44
|
+
async execute(_toolCallId, params) {
|
|
45
|
+
return toAgentToolResult(LIST_WORKFLOWS_TOOL_NAME, await listWorkflowsTool.execute(params));
|
|
46
|
+
}
|
|
47
|
+
},
|
|
48
|
+
{
|
|
49
|
+
name: LAUNCH_WORKFLOW_TOOL_NAME,
|
|
50
|
+
label: "Launch Workflow",
|
|
51
|
+
description: "Start a workflow run. Returns once the run has started, not once it finishes; use workflow_run with action status or wait for the completion notice.",
|
|
52
|
+
promptSnippet: "Start a workflow run and return its identifier",
|
|
53
|
+
promptGuidelines: [
|
|
54
|
+
"Before launching, call list_workflows and pick the workflow whose own description matches the work. A workflow description is the source of truth; never infer one from its filename. If nothing matches, say so and stop rather than launching an approximate fit.",
|
|
55
|
+
"launch_workflow returns when the run has STARTED, not when it has finished. Never report success from its result. Poll workflow_run with action status, or wait for the completion notice the extension delivers on its own.",
|
|
56
|
+
"When dispatching Agiflow work, pass AGIFLOW_PROJECT_ID, AGIFLOW_JOB_KIND, and AGIFLOW_JOB_ID through env plus a non-empty prompt. Kind must be task or work-unit. The id alone is not a key, and omitting prompt leaves user_prompt workflows waiting for terminal input.",
|
|
57
|
+
"A workflow claims its own job in its pre step. Never claim a job yourself. JOB_ALREADY_CLAIMED or HTTP 409 means another worker won the race, so report contention and do not unlock, release, or retry automatically.",
|
|
58
|
+
"If a result says WORKFLOW_NOT_OWNED or a release failed, inspect current ownership and ask the user before any release or unlock. Never force another worker’s lock.",
|
|
59
|
+
"If a running workflow is not found, call workflow_run with action status to re-check current state before retrying.",
|
|
60
|
+
"The per-session concurrency ceiling is a real limit. If launch_workflow refuses, wait for a run to finish; do not launch through the shell to get around it."
|
|
61
|
+
],
|
|
62
|
+
parameters: z.toJSONSchema(runTool.getInputSchema().pick(PI_LAUNCH_FIELDS)),
|
|
63
|
+
renderShell: "self",
|
|
64
|
+
...renderers(LAUNCH_WORKFLOW_TOOL_NAME),
|
|
65
|
+
async execute(_toolCallId, params, _signal, onUpdate, ctx) {
|
|
66
|
+
const input = params;
|
|
67
|
+
const result = await launchExecutor.execute(input, ctx, onUpdate);
|
|
68
|
+
const adapted = toAgentToolResult(LAUNCH_WORKFLOW_TOOL_NAME, result, launchFailureOptions);
|
|
69
|
+
return appendGuidance(adapted, "Next: call workflow_run with action status and verify the recorded stage before reporting the workflow outcome.");
|
|
70
|
+
}
|
|
71
|
+
},
|
|
72
|
+
{
|
|
73
|
+
name: WORKFLOW_RUN_TOOL_NAME,
|
|
74
|
+
label: "Workflow Run",
|
|
75
|
+
description: "Inspect or control one workflow run. Use action status, tail, recovery-evidence, follow, open, pause, resume, stop, or recover. Every action requires an exact run key.",
|
|
76
|
+
promptSnippet: "Inspect or control a workflow run",
|
|
77
|
+
promptGuidelines: [
|
|
78
|
+
"Use action status as the authority for stage, outcome, execution state, and pause cursor. A run that started is not a run that succeeded.",
|
|
79
|
+
"Use action pause or resume for cooperative lifecycle control. Pause is not stop: the run keeps its stage running, capacity, services, and heartbeat while paused.",
|
|
80
|
+
"Use action stop only when the user requests stopping a run. A user-requested stop is not a failure and needs no failure diagnosis.",
|
|
81
|
+
"Do not use follow or tail merely to wait for a healthy run; use status or the completion notice. Tail returns chat-safe status without raw PTY frames. Use follow only when the user asks to pin live progress, and open only when a human wants the recorded launcher foregrounded.",
|
|
82
|
+
"Use action recovery-evidence for terminal-only, durable status and artifacts before recovery. It is the only inspection path that may read a failed run from an earlier session and it never reads a live launcher.",
|
|
83
|
+
"Use action recover only after loading the `workflow-recovery` skill and gathering its required evidence. Recovery may adopt a terminal failed run from an earlier Pi session; it never grants cross-session control of running work. Never edit issue.md or repair.json, and verify real process and registry progress before recovery.",
|
|
84
|
+
"Never unlock or force-release an Agiflow claim from this tool."
|
|
85
|
+
],
|
|
86
|
+
parameters: z.toJSONSchema(workflowRunInputSchema),
|
|
87
|
+
renderShell: "self",
|
|
88
|
+
...renderers(WORKFLOW_RUN_TOOL_NAME),
|
|
89
|
+
async execute(_toolCallId, rawParams, _signal, onUpdate, ctx) {
|
|
90
|
+
const input = workflowRunInputSchema.parse(rawParams);
|
|
91
|
+
const sessionId = resolveRootSessionId(ctx.sessionManager.getSessionId(), dependencies.environment);
|
|
92
|
+
dependencies.observeSession?.(sessionId);
|
|
93
|
+
const selector = {
|
|
94
|
+
runKey: input.runKey,
|
|
95
|
+
workspace: input.workspace
|
|
96
|
+
};
|
|
97
|
+
const requireOwnedRun = async () => {
|
|
98
|
+
if (!dependencies.requireSessionRun) throw new Error("Workflow run ownership is not available in this session.");
|
|
99
|
+
return dependencies.requireSessionRun(selector, sessionId);
|
|
100
|
+
};
|
|
101
|
+
if (input.action === "status") {
|
|
102
|
+
const record = await requireOwnedRun();
|
|
103
|
+
return {
|
|
104
|
+
content: [{
|
|
105
|
+
type: "text",
|
|
106
|
+
text: JSON.stringify(record, null, 2)
|
|
107
|
+
}],
|
|
108
|
+
details: { tool: WORKFLOW_RUN_TOOL_NAME }
|
|
109
|
+
};
|
|
110
|
+
}
|
|
111
|
+
if (input.action === "tail") {
|
|
112
|
+
if (!dependencies.tailRun) throw new Error("Reading workflow output is not available in this session.");
|
|
113
|
+
const record = await requireOwnedRun();
|
|
114
|
+
reportProgress(onUpdate, WORKFLOW_RUN_TOOL_NAME, `Reading output for workflow ${input.runKey}...`);
|
|
115
|
+
await dependencies.tailRun(selector, ctx);
|
|
116
|
+
return {
|
|
117
|
+
content: [{
|
|
118
|
+
type: "text",
|
|
119
|
+
text: [
|
|
120
|
+
`Workflow: ${record.displayName} (${record.runKey})`,
|
|
121
|
+
`Stage: ${record.effectiveStage ?? record.stage}`,
|
|
122
|
+
"Raw launcher output is hidden from chat. Use action follow or open to view it."
|
|
123
|
+
].join("\n")
|
|
124
|
+
}],
|
|
125
|
+
details: { tool: WORKFLOW_RUN_TOOL_NAME }
|
|
126
|
+
};
|
|
127
|
+
}
|
|
128
|
+
if (input.action === "recovery-evidence") {
|
|
129
|
+
if (!dependencies.readRecoveryEvidence) throw new Error("Reading workflow recovery evidence is not available in this session.");
|
|
130
|
+
reportProgress(onUpdate, WORKFLOW_RUN_TOOL_NAME, `Reading recovery evidence for workflow ${input.runKey}...`);
|
|
131
|
+
return {
|
|
132
|
+
content: [{
|
|
133
|
+
type: "text",
|
|
134
|
+
text: await dependencies.readRecoveryEvidence(selector, ctx)
|
|
135
|
+
}],
|
|
136
|
+
details: { tool: WORKFLOW_RUN_TOOL_NAME }
|
|
137
|
+
};
|
|
138
|
+
}
|
|
139
|
+
if (input.action === "follow") {
|
|
140
|
+
if (!dependencies.followRun) throw new Error("Following workflow output is not available in this session.");
|
|
141
|
+
await requireOwnedRun();
|
|
142
|
+
reportProgress(onUpdate, WORKFLOW_RUN_TOOL_NAME, `Following workflow ${input.runKey}...`);
|
|
143
|
+
return {
|
|
144
|
+
content: [{
|
|
145
|
+
type: "text",
|
|
146
|
+
text: await dependencies.followRun(selector, ctx)
|
|
147
|
+
}],
|
|
148
|
+
details: { tool: WORKFLOW_RUN_TOOL_NAME }
|
|
149
|
+
};
|
|
150
|
+
}
|
|
151
|
+
if (input.action === "open") {
|
|
152
|
+
if (!dependencies.openRun) throw new Error("Opening a workflow launcher is not available in this session.");
|
|
153
|
+
await requireOwnedRun();
|
|
154
|
+
reportProgress(onUpdate, WORKFLOW_RUN_TOOL_NAME, `Opening workflow ${input.runKey}...`);
|
|
155
|
+
return {
|
|
156
|
+
content: [{
|
|
157
|
+
type: "text",
|
|
158
|
+
text: await dependencies.openRun(selector, ctx)
|
|
159
|
+
}],
|
|
160
|
+
details: { tool: WORKFLOW_RUN_TOOL_NAME }
|
|
161
|
+
};
|
|
162
|
+
}
|
|
163
|
+
if (input.action === "recover") {
|
|
164
|
+
if (!dependencies.requireRecoverableRun) throw new Error("Workflow recovery ownership transfer is not available in this session.");
|
|
165
|
+
const recoverable = await dependencies.requireRecoverableRun(selector);
|
|
166
|
+
const recoverySelector = {
|
|
167
|
+
runKey: recoverable.runKey,
|
|
168
|
+
workspace: recoverable.workspace
|
|
169
|
+
};
|
|
170
|
+
reportProgress(onUpdate, WORKFLOW_RUN_TOOL_NAME, `Recovering workflow ${input.runKey}...`);
|
|
171
|
+
if (!input.dryRun) {
|
|
172
|
+
const delegated = await dependencies.delegateRecovery?.({
|
|
173
|
+
...recoverySelector,
|
|
174
|
+
runner: input.runner
|
|
175
|
+
}, ctx);
|
|
176
|
+
if (delegated) {
|
|
177
|
+
const guidance = actionGuidance(input.action, input.runKey);
|
|
178
|
+
await dependencies.onLaunch?.(ctx);
|
|
179
|
+
return {
|
|
180
|
+
content: [{
|
|
181
|
+
type: "text",
|
|
182
|
+
text: [delegated, guidance[0]].join("\n\n")
|
|
183
|
+
}],
|
|
184
|
+
details: { tool: WORKFLOW_RUN_TOOL_NAME }
|
|
185
|
+
};
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
const recoverInput = {
|
|
189
|
+
dryRun: input.dryRun,
|
|
190
|
+
job: input.job,
|
|
191
|
+
runKey: recoverySelector.runKey,
|
|
192
|
+
runner: input.runner,
|
|
193
|
+
workspace: recoverySelector.workspace
|
|
194
|
+
};
|
|
195
|
+
const result = await trackPendingRun(recoverTool.execute(recoverInput));
|
|
196
|
+
const guidance = actionGuidance(input.action, input.runKey);
|
|
197
|
+
const adapted = toAgentToolResult(WORKFLOW_RUN_TOOL_NAME, result, guidance);
|
|
198
|
+
await dependencies.onLaunch?.(ctx);
|
|
199
|
+
return appendGuidance(adapted, guidance[0]);
|
|
200
|
+
}
|
|
201
|
+
const ownedRun = await requireOwnedRun();
|
|
202
|
+
if (!ownedRun.runId) throw new Error(`Workflow ${input.runKey} has no controllable run generation.`);
|
|
203
|
+
reportProgress(onUpdate, WORKFLOW_RUN_TOOL_NAME, `Requesting ${input.action} for workflow ${input.runKey}...`);
|
|
204
|
+
const result = await controlTool.execute({
|
|
205
|
+
action: input.action,
|
|
206
|
+
expectedRunId: ownedRun.runId,
|
|
207
|
+
reason: input.reason,
|
|
208
|
+
runKey: input.runKey,
|
|
209
|
+
workspace: input.workspace
|
|
210
|
+
});
|
|
211
|
+
const guidance = actionGuidance(input.action, input.runKey);
|
|
212
|
+
const adapted = toAgentToolResult(WORKFLOW_RUN_TOOL_NAME, result, guidance);
|
|
213
|
+
return appendGuidance(adapted, guidance[0]);
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
];
|
|
217
|
+
}
|
|
218
|
+
//#endregion
|
|
219
|
+
export { createWorkflowTools };
|
|
220
|
+
|
|
221
|
+
//# sourceMappingURL=index.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.mjs","names":[],"sources":["../../../../src/services/workflowTools/index.ts"],"sourcesContent":["import { resolveRootSessionId } from '@agimon-ai/doompi-core/child-process';\nimport {\n createEmbeddedWorkflowFeature,\n type WorkflowRunRecord,\n type EmbeddedWorkflowFeature,\n} from '@agimon-ai/workflow-mcp';\nimport type { ExtensionAPI, ToolDefinition } from '@earendil-works/pi-coding-agent';\nimport { z } from 'zod';\n\nimport { workflowRunInputSchema } from '../../schemas/workflowPi';\nimport { toAgentToolResult, type WorkflowToolDetails } from '../../services/piToolBridge';\nimport {\n type WorkflowLaunchInput,\n type WorkflowRunSelector,\n launchFailureOptions,\n} from '../../services/workflowExecution';\nimport {\n createWorkflowLaunchExecutor,\n reportProgress,\n appendGuidance,\n actionGuidance,\n type WorkflowPiToolDependencies,\n} from '../../services/workflowExecution';\ntype WorkflowToolSchema = Parameters<ExtensionAPI['registerTool']>[0]['parameters'];\nimport {\n WORKFLOW_PI_TOOL_NAMES,\n LIST_WORKFLOWS_TOOL_NAME,\n LAUNCH_WORKFLOW_TOOL_NAME,\n WORKFLOW_RUN_TOOL_NAME,\n} from '../../constants/workflow';\nconst PI_LAUNCH_FIELDS = {\n workflowPath: true,\n workspace: true,\n runner: true,\n name: true,\n env: true,\n prompt: true,\n job: true,\n inputs: true,\n} as const;\nexport type WorkflowNativeTool = ToolDefinition<WorkflowToolSchema, WorkflowToolDetails>;\nexport type WorkflowToolRenderers = Pick<WorkflowNativeTool, 'renderCall' | 'renderResult'>;\nexport function createWorkflowTools(\n dependencies: WorkflowPiToolDependencies,\n renderers: (name: (typeof WORKFLOW_PI_TOOL_NAMES)[number]) => WorkflowToolRenderers = () => ({}),\n): WorkflowNativeTool[] {\n const feature = dependencies.feature ?? createEmbeddedWorkflowFeature();\n const runTool = dependencies.runTool ?? feature.runTool;\n const listWorkflowsTool = dependencies.listWorkflowsTool ?? feature.listWorkflowsTool;\n const recoverTool = dependencies.recoverTool ?? feature.createRecoverTool();\n const controlTool = dependencies.controlTool ?? feature.createControlTool();\n const trackPendingRun = dependencies.trackPendingRun ?? (<T>(run: Promise<T>): Promise<T> => run);\n const launchExecutor =\n dependencies.launchExecutor ??\n createWorkflowLaunchExecutor({\n environment: dependencies.environment,\n activeRunCount: dependencies.activeRunCount,\n onLaunch: dependencies.onLaunch,\n observeSession: dependencies.observeSession,\n rejectRunner: dependencies.rejectRunner,\n runTool,\n trackPendingRun,\n });\n\n return [\n {\n name: LIST_WORKFLOWS_TOOL_NAME,\n label: 'List Workflows',\n description: 'List the workflow definitions available in this repository.',\n promptSnippet: 'List available workflow definitions',\n parameters: z.toJSONSchema(listWorkflowsTool.getInputSchema()),\n renderShell: 'self',\n ...renderers(LIST_WORKFLOWS_TOOL_NAME),\n async execute(_toolCallId, params) {\n return toAgentToolResult(\n LIST_WORKFLOWS_TOOL_NAME,\n await listWorkflowsTool.execute(\n params as Parameters<EmbeddedWorkflowFeature['listWorkflowsTool']['execute']>[0],\n ),\n );\n },\n },\n\n {\n name: LAUNCH_WORKFLOW_TOOL_NAME,\n label: 'Launch Workflow',\n description:\n 'Start a workflow run. Returns once the run has started, not once it finishes; use workflow_run with action status or wait for the completion notice.',\n promptSnippet: 'Start a workflow run and return its identifier',\n promptGuidelines: [\n 'Before launching, call list_workflows and pick the workflow whose own description matches the work. A workflow description is the source of truth; never infer one from its filename. If nothing matches, say so and stop rather than launching an approximate fit.',\n 'launch_workflow returns when the run has STARTED, not when it has finished. Never report success from its result. Poll workflow_run with action status, or wait for the completion notice the extension delivers on its own.',\n 'When dispatching Agiflow work, pass AGIFLOW_PROJECT_ID, AGIFLOW_JOB_KIND, and AGIFLOW_JOB_ID through env plus a non-empty prompt. Kind must be task or work-unit. The id alone is not a key, and omitting prompt leaves user_prompt workflows waiting for terminal input.',\n 'A workflow claims its own job in its pre step. Never claim a job yourself. JOB_ALREADY_CLAIMED or HTTP 409 means another worker won the race, so report contention and do not unlock, release, or retry automatically.',\n 'If a result says WORKFLOW_NOT_OWNED or a release failed, inspect current ownership and ask the user before any release or unlock. Never force another worker’s lock.',\n 'If a running workflow is not found, call workflow_run with action status to re-check current state before retrying.',\n 'The per-session concurrency ceiling is a real limit. If launch_workflow refuses, wait for a run to finish; do not launch through the shell to get around it.',\n ],\n parameters: z.toJSONSchema(runTool.getInputSchema().pick(PI_LAUNCH_FIELDS)),\n renderShell: 'self',\n ...renderers(LAUNCH_WORKFLOW_TOOL_NAME),\n async execute(_toolCallId, params, _signal, onUpdate, ctx) {\n const input = params as WorkflowLaunchInput;\n const result = await launchExecutor.execute(input, ctx, onUpdate);\n const adapted = toAgentToolResult(LAUNCH_WORKFLOW_TOOL_NAME, result, launchFailureOptions);\n return appendGuidance(\n adapted,\n 'Next: call workflow_run with action status and verify the recorded stage before reporting the workflow outcome.',\n );\n },\n },\n\n {\n name: WORKFLOW_RUN_TOOL_NAME,\n label: 'Workflow Run',\n description:\n 'Inspect or control one workflow run. Use action status, tail, recovery-evidence, follow, open, pause, resume, stop, or recover. Every action requires an exact run key.',\n promptSnippet: 'Inspect or control a workflow run',\n promptGuidelines: [\n 'Use action status as the authority for stage, outcome, execution state, and pause cursor. A run that started is not a run that succeeded.',\n 'Use action pause or resume for cooperative lifecycle control. Pause is not stop: the run keeps its stage running, capacity, services, and heartbeat while paused.',\n 'Use action stop only when the user requests stopping a run. A user-requested stop is not a failure and needs no failure diagnosis.',\n 'Do not use follow or tail merely to wait for a healthy run; use status or the completion notice. Tail returns chat-safe status without raw PTY frames. Use follow only when the user asks to pin live progress, and open only when a human wants the recorded launcher foregrounded.',\n 'Use action recovery-evidence for terminal-only, durable status and artifacts before recovery. It is the only inspection path that may read a failed run from an earlier session and it never reads a live launcher.',\n 'Use action recover only after loading the `workflow-recovery` skill and gathering its required evidence. Recovery may adopt a terminal failed run from an earlier Pi session; it never grants cross-session control of running work. Never edit issue.md or repair.json, and verify real process and registry progress before recovery.',\n 'Never unlock or force-release an Agiflow claim from this tool.',\n ],\n parameters: z.toJSONSchema(workflowRunInputSchema),\n renderShell: 'self',\n ...renderers(WORKFLOW_RUN_TOOL_NAME),\n async execute(_toolCallId, rawParams, _signal, onUpdate, ctx) {\n const input = workflowRunInputSchema.parse(rawParams);\n const sessionId = resolveRootSessionId(ctx.sessionManager.getSessionId(), dependencies.environment);\n dependencies.observeSession?.(sessionId);\n const selector: WorkflowRunSelector = { runKey: input.runKey, workspace: input.workspace };\n const requireOwnedRun = async (): Promise<WorkflowRunRecord> => {\n if (!dependencies.requireSessionRun) {\n throw new Error('Workflow run ownership is not available in this session.');\n }\n return dependencies.requireSessionRun(selector, sessionId);\n };\n\n if (input.action === 'status') {\n const record = await requireOwnedRun();\n return {\n content: [{ type: 'text', text: JSON.stringify(record, null, 2) }],\n details: { tool: WORKFLOW_RUN_TOOL_NAME },\n };\n }\n if (input.action === 'tail') {\n if (!dependencies.tailRun) throw new Error('Reading workflow output is not available in this session.');\n const record = await requireOwnedRun();\n reportProgress(onUpdate, WORKFLOW_RUN_TOOL_NAME, `Reading output for workflow ${input.runKey}...`);\n await dependencies.tailRun(selector, ctx);\n return {\n content: [\n {\n type: 'text',\n text: [\n `Workflow: ${record.displayName} (${record.runKey})`,\n `Stage: ${record.effectiveStage ?? record.stage}`,\n 'Raw launcher output is hidden from chat. Use action follow or open to view it.',\n ].join('\\n'),\n },\n ],\n details: { tool: WORKFLOW_RUN_TOOL_NAME },\n };\n }\n if (input.action === 'recovery-evidence') {\n if (!dependencies.readRecoveryEvidence) {\n throw new Error('Reading workflow recovery evidence is not available in this session.');\n }\n reportProgress(onUpdate, WORKFLOW_RUN_TOOL_NAME, `Reading recovery evidence for workflow ${input.runKey}...`);\n return {\n content: [{ type: 'text', text: await dependencies.readRecoveryEvidence(selector, ctx) }],\n details: { tool: WORKFLOW_RUN_TOOL_NAME },\n };\n }\n if (input.action === 'follow') {\n if (!dependencies.followRun) throw new Error('Following workflow output is not available in this session.');\n await requireOwnedRun();\n reportProgress(onUpdate, WORKFLOW_RUN_TOOL_NAME, `Following workflow ${input.runKey}...`);\n return {\n content: [{ type: 'text', text: await dependencies.followRun(selector, ctx) }],\n details: { tool: WORKFLOW_RUN_TOOL_NAME },\n };\n }\n if (input.action === 'open') {\n if (!dependencies.openRun) throw new Error('Opening a workflow launcher is not available in this session.');\n await requireOwnedRun();\n reportProgress(onUpdate, WORKFLOW_RUN_TOOL_NAME, `Opening workflow ${input.runKey}...`);\n return {\n content: [{ type: 'text', text: await dependencies.openRun(selector, ctx) }],\n details: { tool: WORKFLOW_RUN_TOOL_NAME },\n };\n }\n\n if (input.action === 'recover') {\n if (!dependencies.requireRecoverableRun) {\n throw new Error('Workflow recovery ownership transfer is not available in this session.');\n }\n const recoverable = await dependencies.requireRecoverableRun(selector);\n const recoverySelector = { runKey: recoverable.runKey, workspace: recoverable.workspace };\n reportProgress(onUpdate, WORKFLOW_RUN_TOOL_NAME, `Recovering workflow ${input.runKey}...`);\n // A recovery replays the workflow, and the replay skips the launch\n // step, so every job runs in THIS process. For a workflow whose steps\n // are interactive that means an agent TUI spawned onto this process's\n // own terminal. Hand it to a launcher instead, where the workflow says\n // how. A dry run prints rather than executes, so it stays here.\n if (!input.dryRun) {\n const delegated = await dependencies.delegateRecovery?.({ ...recoverySelector, runner: input.runner }, ctx);\n if (delegated) {\n const guidance = actionGuidance(input.action, input.runKey);\n await dependencies.onLaunch?.(ctx);\n return {\n content: [{ type: 'text', text: [delegated, guidance[0]].join('\\n\\n') }],\n details: { tool: WORKFLOW_RUN_TOOL_NAME },\n };\n }\n }\n const recoverInput = {\n dryRun: input.dryRun,\n job: input.job,\n runKey: recoverySelector.runKey,\n runner: input.runner,\n workspace: recoverySelector.workspace,\n };\n const result = await trackPendingRun(recoverTool.execute(recoverInput));\n const guidance = actionGuidance(input.action, input.runKey);\n const adapted = toAgentToolResult(WORKFLOW_RUN_TOOL_NAME, result, guidance);\n await dependencies.onLaunch?.(ctx);\n return appendGuidance(adapted, guidance[0]!);\n }\n\n const ownedRun = await requireOwnedRun();\n if (!ownedRun.runId) throw new Error(`Workflow ${input.runKey} has no controllable run generation.`);\n reportProgress(onUpdate, WORKFLOW_RUN_TOOL_NAME, `Requesting ${input.action} for workflow ${input.runKey}...`);\n const result = await controlTool.execute({\n action: input.action,\n expectedRunId: ownedRun.runId,\n reason: input.reason,\n runKey: input.runKey,\n workspace: input.workspace,\n });\n const guidance = actionGuidance(input.action, input.runKey);\n const adapted = toAgentToolResult(WORKFLOW_RUN_TOOL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
|
|
2
|
+
const require_index = require("../workflowRuns/index.cjs");
|
|
3
|
+
let node_fs = require("node:fs");
|
|
4
|
+
node_fs = require_runtime.__toESM(node_fs, 1);
|
|
5
|
+
let node_path = require("node:path");
|
|
6
|
+
node_path = require_runtime.__toESM(node_path, 1);
|
|
7
|
+
let node_os = require("node:os");
|
|
8
|
+
node_os = require_runtime.__toESM(node_os, 1);
|
|
9
|
+
//#region src/services/workflowWatcher/index.ts
|
|
10
|
+
/**
|
|
11
|
+
* Read the durable workflow registry once.
|
|
12
|
+
*
|
|
13
|
+
* The registry is an initial snapshot only. Live delivery belongs to the
|
|
14
|
+
* session lifecycle and is routed through the host-owned direct event bus.
|
|
15
|
+
*/
|
|
16
|
+
function readWorkflowRuns(options = {}) {
|
|
17
|
+
const environment = options.environment;
|
|
18
|
+
const homeDir = options.homeDir ?? require_index.resolveWorkflowHome({
|
|
19
|
+
envValue: environment?.["WORKFLOW_MCP_HOME"],
|
|
20
|
+
homeDir: node_os.default.homedir()
|
|
21
|
+
});
|
|
22
|
+
const workspacesDir = node_path.default.join(homeDir, require_index.WORKSPACES_DIR_NAME);
|
|
23
|
+
const recordCache = /* @__PURE__ */ new Map();
|
|
24
|
+
const progressCache = /* @__PURE__ */ new Map();
|
|
25
|
+
const cachedParse = (cache, filePath, parse, empty) => {
|
|
26
|
+
let stat;
|
|
27
|
+
try {
|
|
28
|
+
stat = node_fs.default.statSync(filePath);
|
|
29
|
+
} catch {
|
|
30
|
+
cache.delete(filePath);
|
|
31
|
+
return empty;
|
|
32
|
+
}
|
|
33
|
+
const cached = cache.get(filePath);
|
|
34
|
+
if (cached && cached.size === stat.size && cached.mtimeMs === stat.mtimeMs) return cached.value;
|
|
35
|
+
let raw;
|
|
36
|
+
try {
|
|
37
|
+
raw = node_fs.default.readFileSync(filePath, "utf8");
|
|
38
|
+
} catch {
|
|
39
|
+
cache.delete(filePath);
|
|
40
|
+
return empty;
|
|
41
|
+
}
|
|
42
|
+
const value = parse(raw);
|
|
43
|
+
cache.set(filePath, {
|
|
44
|
+
size: stat.size,
|
|
45
|
+
mtimeMs: stat.mtimeMs,
|
|
46
|
+
value
|
|
47
|
+
});
|
|
48
|
+
return value;
|
|
49
|
+
};
|
|
50
|
+
const listDir = (directory) => {
|
|
51
|
+
try {
|
|
52
|
+
return node_fs.default.readdirSync(directory).sort();
|
|
53
|
+
} catch {
|
|
54
|
+
return [];
|
|
55
|
+
}
|
|
56
|
+
};
|
|
57
|
+
const runs = [];
|
|
58
|
+
for (const workspace of listDir(workspacesDir)) for (const stage of require_index.WORKFLOW_STAGES) {
|
|
59
|
+
const stageDir = node_path.default.join(workspacesDir, workspace, stage);
|
|
60
|
+
for (const runKey of listDir(stageDir)) {
|
|
61
|
+
const runDir = node_path.default.join(stageDir, runKey);
|
|
62
|
+
const recordPath = node_path.default.join(runDir, require_index.RUN_RECORD_FILE_NAME);
|
|
63
|
+
const progressPath = node_path.default.join(runDir, require_index.PROGRESS_FILE_NAME);
|
|
64
|
+
const parsed = cachedParse(recordCache, recordPath, require_index.parseWorkflowRunRecord, void 0);
|
|
65
|
+
if (parsed === void 0) continue;
|
|
66
|
+
const jobs = cachedParse(progressCache, progressPath, (raw) => require_index.foldWorkflowProgress(require_index.parseWorkflowProgress(raw)), []);
|
|
67
|
+
runs.push({
|
|
68
|
+
...parsed,
|
|
69
|
+
view: require_index.completeWorkflowRunView(parsed.view, jobs)
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
return runs;
|
|
74
|
+
}
|
|
75
|
+
//#endregion
|
|
76
|
+
exports.readWorkflowRuns = readWorkflowRuns;
|
|
77
|
+
|
|
78
|
+
//# sourceMappingURL=index.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.cjs","names":["resolveWorkflowHome","os","path","WORKSPACES_DIR_NAME","fs","WORKFLOW_STAGES","RUN_RECORD_FILE_NAME","PROGRESS_FILE_NAME","parseWorkflowRunRecord","foldWorkflowProgress","parseWorkflowProgress","completeWorkflowRunView"],"sources":["../../../../src/services/workflowWatcher/index.ts"],"sourcesContent":["import fs from 'node:fs';\nimport os from 'node:os';\nimport path from 'node:path';\n\nimport {\n completeWorkflowRunView,\n foldWorkflowProgress,\n type ParsedWorkflowRun,\n parseWorkflowProgress,\n parseWorkflowRunRecord,\n PROGRESS_FILE_NAME,\n resolveWorkflowHome,\n RUN_RECORD_FILE_NAME,\n WORKFLOW_HOME_ENV,\n WORKFLOW_STAGES,\n WORKSPACES_DIR_NAME,\n} from '../workflowRuns';\n\nexport interface ReadWorkflowRunsOptions {\n /** Registry home override, primarily for tests. */\n homeDir?: string;\n /** Admitted session environment used to resolve the registry home. */\n environment?: Readonly<Record<string, string | undefined>>;\n}\n\n/**\n * Read the durable workflow registry once.\n *\n * The registry is an initial snapshot only. Live delivery belongs to the\n * session lifecycle and is routed through the host-owned direct event bus.\n */\nexport function readWorkflowRuns(options: ReadWorkflowRunsOptions = {}): ParsedWorkflowRun[] {\n const environment = options.environment;\n const homeDir =\n options.homeDir ??\n resolveWorkflowHome({\n envValue: environment?.[WORKFLOW_HOME_ENV],\n homeDir: os.homedir(),\n });\n const workspacesDir = path.join(homeDir, WORKSPACES_DIR_NAME);\n const recordCache = new Map<string, { size: number; mtimeMs: number; value: ParsedWorkflowRun | undefined }>();\n const progressCache = new Map<\n string,\n { size: number; mtimeMs: number; value: ReturnType<typeof foldWorkflowProgress> }\n >();\n\n const cachedParse = <T>(\n cache: Map<string, { size: number; mtimeMs: number; value: T }>,\n filePath: string,\n parse: (raw: string) => T,\n empty: T,\n ): T => {\n let stat: fs.Stats;\n try {\n stat = fs.statSync(filePath);\n } catch {\n cache.delete(filePath);\n return empty;\n }\n const cached = cache.get(filePath);\n if (cached && cached.size === stat.size && cached.mtimeMs === stat.mtimeMs) return cached.value;\n let raw: string;\n try {\n raw = fs.readFileSync(filePath, 'utf8');\n } catch {\n cache.delete(filePath);\n return empty;\n }\n const value = parse(raw);\n cache.set(filePath, { size: stat.size, mtimeMs: stat.mtimeMs, value });\n return value;\n };\n\n const listDir = (directory: string): string[] => {\n try {\n return fs.readdirSync(directory).sort();\n } catch {\n return [];\n }\n };\n\n const runs: ParsedWorkflowRun[] = [];\n for (const workspace of listDir(workspacesDir)) {\n for (const stage of WORKFLOW_STAGES) {\n const stageDir = path.join(workspacesDir, workspace, stage);\n for (const runKey of listDir(stageDir)) {\n const runDir = path.join(stageDir, runKey);\n const recordPath = path.join(runDir, RUN_RECORD_FILE_NAME);\n const progressPath = path.join(runDir, PROGRESS_FILE_NAME);\n const parsed = cachedParse(recordCache, recordPath, parseWorkflowRunRecord, undefined);\n if (parsed === undefined) continue;\n const jobs = cachedParse(\n progressCache,\n progressPath,\n (raw) => foldWorkflowProgress(parseWorkflowProgress(raw)),\n [],\n );\n runs.push({ ...parsed, view: completeWorkflowRunView(parsed.view, jobs) });\n }\n }\n }\n return runs;\n}\n"],"mappings":";;;;;;;;;;;;;;;AA+BA,SAAgB,iBAAiB,UAAmC,CAAC,GAAwB;CAC3F,MAAM,cAAc,QAAQ;CAC5B,MAAM,UACJ,QAAQ,WACRA,cAAAA,oBAAoB;EAClB,UAAU,cAAA;EACV,SAASC,QAAAA,QAAG,QAAQ;CACtB,CAAC;CACH,MAAM,gBAAgBC,UAAAA,QAAK,KAAK,SAASC,cAAAA,mBAAmB;CAC5D,MAAM,8BAAc,IAAI,IAAqF;CAC7G,MAAM,gCAAgB,IAAI,IAGxB;CAEF,MAAM,eACJ,OACA,UACA,OACA,UACM;EACN,IAAI;EACJ,IAAI;GACF,OAAOC,QAAAA,QAAG,SAAS,QAAQ;EAC7B,QAAQ;GACN,MAAM,OAAO,QAAQ;GACrB,OAAO;EACT;EACA,MAAM,SAAS,MAAM,IAAI,QAAQ;EACjC,IAAI,UAAU,OAAO,SAAS,KAAK,QAAQ,OAAO,YAAY,KAAK,SAAS,OAAO,OAAO;EAC1F,IAAI;EACJ,IAAI;GACF,MAAMA,QAAAA,QAAG,aAAa,UA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