@agimon-ai/po-workflow 0.0.0-alpha.13 → 0.0.0-alpha.131
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +149 -29
- package/README.md +175 -17
- package/dist/RecoverWorkflowService-C60pnmub.mjs +13701 -0
- package/dist/RecoverWorkflowService-C60pnmub.mjs.map +1 -0
- package/dist/RecoverWorkflowService-DJ9dzZmJ.cjs +14046 -0
- package/dist/RecoverWorkflowService-DJ9dzZmJ.cjs.map +1 -0
- package/dist/apiContracts.cjs +197 -35
- package/dist/apiContracts.cjs.map +1 -1
- package/dist/apiContracts.d.mts.map +1 -1
- package/dist/apiContracts.mjs +197 -35
- package/dist/apiContracts.mjs.map +1 -1
- package/dist/cli.cjs +1153 -0
- package/dist/cli.cjs.map +1 -0
- package/dist/cli.d.mts +1 -0
- package/dist/cli.mjs +1154 -0
- package/dist/cli.mjs.map +1 -0
- package/dist/extensions/native.mjs +3757 -686
- package/dist/extensions/native.mjs.map +1 -1
- package/dist/extensions/server.cjs +7756 -2945
- package/dist/extensions/server.cjs.map +1 -1
- package/dist/extensions/server.d.mts +2 -2
- package/dist/extensions/server.d.mts.map +1 -1
- package/dist/extensions/server.mjs +7750 -2916
- package/dist/extensions/server.mjs.map +1 -1
- package/dist/extensions/web.mjs +4451 -2829
- package/dist/extensions/web.mjs.map +1 -1
- package/dist/index.cjs +3 -1
- package/dist/index.d.mts +72 -4
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +3 -1
- package/dist/rolldown-runtime-VH7oDXx4.cjs +28 -0
- package/dist/workflowCommandTemplate-r57z3b46.mjs +79 -0
- package/dist/workflowCommandTemplate-r57z3b46.mjs.map +1 -0
- package/dist/workflowCommandTemplate-w6rOCJpw.cjs +102 -0
- package/dist/workflowCommandTemplate-w6rOCJpw.cjs.map +1 -0
- package/dist/{workflowLaunchCommand-C69Nn3k5.cjs → workflowLaunchCommand-Cm2_aoJ3.cjs} +21 -5
- package/dist/workflowLaunchCommand-Cm2_aoJ3.cjs.map +1 -0
- package/dist/{workflowLaunchCommand-GGqimmTC.mjs → workflowLaunchCommand-USS3q-Px.mjs} +21 -5
- package/dist/workflowLaunchCommand-USS3q-Px.mjs.map +1 -0
- package/llms.txt +8 -7
- package/package.json +105 -25
- package/src/prompts/codemode-how-to-workflow/SKILL.md +175 -0
- package/src/prompts/help-how-to-workflow/SKILL.md +174 -0
- package/src/types/webWorkflows.ts +31 -1
- package/LICENSE.web +0 -29
- package/dist/workflowLaunchCommand-C69Nn3k5.cjs.map +0 -1
- package/dist/workflowLaunchCommand-GGqimmTC.mjs.map +0 -1
- package/skills/workflow-recovery/SKILL.md +0 -85
- package/src/prompts/po-author-workflow/SKILL.md +0 -64
- package/src/prompts/po-use-workflow/SKILL.md +0 -21
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@agimon-ai/po-workflow",
|
|
3
|
-
"version": "0.0.0-alpha.
|
|
3
|
+
"version": "0.0.0-alpha.131",
|
|
4
4
|
"description": "GitHub Actions-style workflow graphs, artifacts, recovery, and asynchronous runs for Po.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"ai",
|
|
@@ -18,19 +18,22 @@
|
|
|
18
18
|
"bugs": {
|
|
19
19
|
"url": "https://github.com/AgiFlow/po/issues"
|
|
20
20
|
},
|
|
21
|
-
"license": "
|
|
21
|
+
"license": "BUSL-1.1",
|
|
22
22
|
"author": "Vuong Ngo",
|
|
23
23
|
"repository": {
|
|
24
24
|
"type": "git",
|
|
25
25
|
"url": "git+https://github.com/AgiFlow/po.git",
|
|
26
|
-
"directory": "
|
|
26
|
+
"directory": "layers/workflow/po-workflow"
|
|
27
|
+
},
|
|
28
|
+
"bin": {
|
|
29
|
+
"po-workflow-mcp": "./dist/cli.mjs",
|
|
30
|
+
"workflow-mcp": "./dist/cli.mjs"
|
|
27
31
|
},
|
|
28
32
|
"files": [
|
|
29
33
|
"dist",
|
|
30
34
|
"llms.txt",
|
|
31
35
|
"README.md",
|
|
32
36
|
"src/prompts",
|
|
33
|
-
"skills/workflow-recovery/SKILL.md",
|
|
34
37
|
"src/types/webWorkflows.ts",
|
|
35
38
|
"src/types/webWorkflowTerminal.ts"
|
|
36
39
|
],
|
|
@@ -56,59 +59,109 @@
|
|
|
56
59
|
"./extensions/web": {
|
|
57
60
|
"import": "./dist/extensions/web.mjs"
|
|
58
61
|
},
|
|
59
|
-
"./skills/workflow-recovery/SKILL.md": "./skills/workflow-recovery/SKILL.md",
|
|
60
62
|
"./package.json": "./package.json"
|
|
61
63
|
},
|
|
62
64
|
"publishConfig": {
|
|
63
65
|
"access": "public"
|
|
64
66
|
},
|
|
65
67
|
"dependencies": {
|
|
66
|
-
"@agimon-ai/
|
|
67
|
-
"@agimon-ai/
|
|
68
|
-
"@agimon-ai/po-
|
|
69
|
-
"@agimon-ai/po-
|
|
70
|
-
"@agimon-ai/po-
|
|
71
|
-
"@agimon-ai/po-web-
|
|
72
|
-
"@agimon-ai/
|
|
73
|
-
"@deepseek-ai/cordis": "4.0.
|
|
68
|
+
"@agimon-ai/foundation-port-registry": "0.30.14",
|
|
69
|
+
"@agimon-ai/foundation-process-registry": "0.30.14",
|
|
70
|
+
"@agimon-ai/po-core": "0.0.0-alpha.131",
|
|
71
|
+
"@agimon-ai/po-logsink": "0.0.1-alpha.113",
|
|
72
|
+
"@agimon-ai/po-ui": "0.0.0-alpha.131",
|
|
73
|
+
"@agimon-ai/po-web-components": "0.0.0-alpha.131",
|
|
74
|
+
"@agimon-ai/po-web-security": "0.0.0-alpha.131",
|
|
75
|
+
"@deepseek-ai/cordis": "4.0.5",
|
|
76
|
+
"@mastra/core": "1.78.0",
|
|
74
77
|
"@modelcontextprotocol/server": "2.3.1",
|
|
78
|
+
"@rmux/sdk": "0.6.5",
|
|
79
|
+
"chalk": "6.0.1",
|
|
80
|
+
"commander": "15.0.0",
|
|
75
81
|
"hono": "4.13.13",
|
|
76
|
-
"
|
|
77
|
-
"
|
|
82
|
+
"js-yaml": "5.5.0",
|
|
83
|
+
"liquidjs": "10.30.0",
|
|
84
|
+
"proper-lockfile": "4.1.2",
|
|
85
|
+
"typebox": "1.4.2"
|
|
78
86
|
},
|
|
79
87
|
"devDependencies": {
|
|
80
|
-
"@agimon-ai/po-build": "0.0.0-alpha.
|
|
81
|
-
"@agimon-ai/po-native-components": "0.0.0-alpha.
|
|
88
|
+
"@agimon-ai/po-build": "0.0.0-alpha.131",
|
|
89
|
+
"@agimon-ai/po-native-components": "0.0.0-alpha.131",
|
|
82
90
|
"@babel/core": "7.29.7",
|
|
83
|
-
"@earendil-works/pi-coding-agent": "1.
|
|
91
|
+
"@earendil-works/pi-coding-agent": "1.5.0",
|
|
84
92
|
"@tanstack/react-store": "0.11.2",
|
|
85
93
|
"@tanstack/store": "0.11.2",
|
|
94
|
+
"@types/js-yaml": "4.0.9",
|
|
86
95
|
"@types/node": "26.6.5",
|
|
96
|
+
"@types/proper-lockfile": "4.1.4",
|
|
87
97
|
"@types/react": "19.3.0",
|
|
88
98
|
"@types/react-dom": "19.3.0",
|
|
89
99
|
"@vitest/coverage-v8": "5.0.4",
|
|
90
|
-
"react": "19.3.
|
|
91
|
-
"react-dom": "19.3.
|
|
92
|
-
"react-native": "0.
|
|
93
|
-
"react-native-unistyles": "3.
|
|
100
|
+
"react": "19.3.1",
|
|
101
|
+
"react-dom": "19.3.1",
|
|
102
|
+
"react-native": "0.88.1",
|
|
103
|
+
"react-native-unistyles": "3.7.0",
|
|
94
104
|
"tsdown": "0.23.1",
|
|
95
105
|
"typescript": "7.0.2",
|
|
96
|
-
"vitest": "5.0.4"
|
|
106
|
+
"vitest": "5.0.4",
|
|
107
|
+
"zod": "4.6.7"
|
|
97
108
|
},
|
|
98
109
|
"peerDependencies": {
|
|
99
|
-
"@earendil-works/pi-coding-agent": "1.
|
|
110
|
+
"@earendil-works/pi-coding-agent": "1.5.0",
|
|
111
|
+
"zod": "^4.4.3"
|
|
100
112
|
},
|
|
101
113
|
"peerDependenciesMeta": {
|
|
102
114
|
"@earendil-works/pi-coding-agent": {
|
|
103
115
|
"optional": true
|
|
104
116
|
}
|
|
105
117
|
},
|
|
118
|
+
"optionalDependencies": {
|
|
119
|
+
"@agimon-ai/rmux-darwin-arm64": "0.10.14",
|
|
120
|
+
"@agimon-ai/rmux-darwin-x64": "0.10.14",
|
|
121
|
+
"@agimon-ai/rmux-linux-arm64": "0.10.14",
|
|
122
|
+
"@agimon-ai/rmux-linux-x64": "0.10.14"
|
|
123
|
+
},
|
|
106
124
|
"engines": {
|
|
107
125
|
"node": ">=24"
|
|
108
126
|
},
|
|
109
127
|
"poNative": {
|
|
110
128
|
"pluginId": "workflows",
|
|
129
|
+
"brain": {
|
|
130
|
+
"version": 1,
|
|
131
|
+
"slots": [
|
|
132
|
+
{
|
|
133
|
+
"name": "activity.workflows",
|
|
134
|
+
"scope": "session",
|
|
135
|
+
"parent": "activity",
|
|
136
|
+
"kind": "component"
|
|
137
|
+
}
|
|
138
|
+
],
|
|
139
|
+
"fills": [
|
|
140
|
+
{
|
|
141
|
+
"id": "workflows",
|
|
142
|
+
"slot": "home",
|
|
143
|
+
"scope": "workspace",
|
|
144
|
+
"placement": "verified"
|
|
145
|
+
},
|
|
146
|
+
{
|
|
147
|
+
"id": "workflow-launcher",
|
|
148
|
+
"slot": "overlay",
|
|
149
|
+
"scope": "session",
|
|
150
|
+
"placement": "verified"
|
|
151
|
+
},
|
|
152
|
+
{
|
|
153
|
+
"id": "workflows",
|
|
154
|
+
"slot": "activity.workflows",
|
|
155
|
+
"scope": "session",
|
|
156
|
+
"placement": "verified"
|
|
157
|
+
}
|
|
158
|
+
],
|
|
159
|
+
"diagnostics": [
|
|
160
|
+
"activity.workflows: parent activity unavailable locally (may be supplied by host or another package)"
|
|
161
|
+
]
|
|
162
|
+
},
|
|
111
163
|
"channels": [
|
|
164
|
+
"dynamic_workflow_runs",
|
|
112
165
|
"workflow_catalog",
|
|
113
166
|
"workflow_runs"
|
|
114
167
|
],
|
|
@@ -129,11 +182,38 @@
|
|
|
129
182
|
"contracts": {
|
|
130
183
|
"entry": "./src/exports/apiContracts.ts",
|
|
131
184
|
"dist": "./dist/apiContracts.mjs"
|
|
185
|
+
},
|
|
186
|
+
"brain": {
|
|
187
|
+
"version": 1,
|
|
188
|
+
"provides": {}
|
|
132
189
|
}
|
|
133
190
|
},
|
|
134
191
|
"poWeb": {
|
|
135
192
|
"pluginId": "workflows",
|
|
193
|
+
"brain": {
|
|
194
|
+
"version": 1,
|
|
195
|
+
"slots": [],
|
|
196
|
+
"fills": [
|
|
197
|
+
{
|
|
198
|
+
"id": "workflow-launcher",
|
|
199
|
+
"slot": "overlay",
|
|
200
|
+
"scope": "session",
|
|
201
|
+
"placement": "verified"
|
|
202
|
+
},
|
|
203
|
+
{
|
|
204
|
+
"id": "workflows",
|
|
205
|
+
"slot": null,
|
|
206
|
+
"scope": "session",
|
|
207
|
+
"placement": "unverified"
|
|
208
|
+
}
|
|
209
|
+
],
|
|
210
|
+
"diagnostics": [
|
|
211
|
+
"src/extensions/workspaces/sessions/(frontend)/activity-group/workflows.web.ts: activity-group metadata unavailable (dynamic declaration)",
|
|
212
|
+
"src/extensions/workspaces/sessions/(frontend)/fill/Workflows.activity.workflows.web.tsx: fill identity unverified (spread or dynamic declaration); path is not placement evidence"
|
|
213
|
+
]
|
|
214
|
+
},
|
|
136
215
|
"channels": [
|
|
216
|
+
"dynamic_workflow_runs",
|
|
137
217
|
"workflow_catalog",
|
|
138
218
|
"workflow_runs"
|
|
139
219
|
],
|
|
@@ -145,7 +225,7 @@
|
|
|
145
225
|
"scripts": {
|
|
146
226
|
"build": "tsdown",
|
|
147
227
|
"test": "vitest --run",
|
|
148
|
-
"typecheck": "
|
|
228
|
+
"typecheck": "tsrs --noEmit && tsrs --noEmit -p tsconfig.web.json && tsrs --noEmit -p tsconfig.native.json",
|
|
149
229
|
"lint": "oxlint . && oxfmt . --check",
|
|
150
230
|
"fixcode": "oxlint . --fix && oxfmt ."
|
|
151
231
|
}
|
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: codemode-how-to-workflow
|
|
3
|
+
description: Discover, launch, monitor and recover YAML workflows, use selected jobTools, or track dynamic script graphs and child transcripts in Activity.
|
|
4
|
+
pinned: true
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# Workflows in code mode
|
|
8
|
+
|
|
9
|
+
Use `workflow` for persisted YAML runs and `dynamicWorkflow` for tracked script graphs with a durable step journal. A managed step may also receive workflow-selected `jobTools`. Discover each namespace for current signatures. Workflow is available whenever its package is selected, with no minor-mode activation.
|
|
10
|
+
|
|
11
|
+
## Discover, launch, monitor
|
|
12
|
+
|
|
13
|
+
1. `workflow.list` discovers definitions, tags and pages, not existing runs. Inspect the definition and its imports before launching. Call `workflow.requirements({ workflowPath, job? })` to read effective roles, same-profile groups and safe eligible profile candidates before choosing assignments. It includes reachable allowed child jobs and repair triage, needs no selected profile or saved team, and creates no admission or run. Role-bound discovery requires an admitted workspace and an allocation-aware identity provider. Its candidates are read-only evidence, not launch authorization. Do not pass product, workspace, profile, team or assignments to discovery.
|
|
14
|
+
2. Call `workflow.validate({ workflowPath, inputs, env, runner, command, choice, profile, job })` with the settings you intend to launch. This read-only check reuses the parser/doctor and actual command resolver: imports, references, required/default inputs, declared input options/types, command/choice/runConfig bindings, environment interpolation phases and host injections. It never launches steps or reads a secret file. Supply only the optional settings you need.
|
|
15
|
+
3. Inspect `valid`, every diagnostic's `code`, `location` and corrective `message`, and the separate `deferred` list. Fix errors and revalidate after every edit or launch-setting change. `valid: true` means no detected errors, not 100% runtime coverage. Run identities, assembled prompts, child invocation inputs, conditional context files, host selection/authentication and shell/artifact behavior may need execution-time checks. Never replace deferred values with invented data or claim they were verified. Binding values are omitted from reports and call cards.
|
|
16
|
+
4. `workflow.launch` starts a run only when authorized. Prefer a declared in-process Pi command, for example `command: "pi"` when that name is declared. `pi`, `po` and `claude` are literal workflow command names, not aliases. Never rewrite a declared command to match an example. `runner` selects the runner, not the command; `runner: "codex"` does not imply `command: "pi"`. Without `command`, each step uses its first command. An acknowledgement `{ message, run? }` is not completion. The run reference may be absent until an identity exists. Use `workflow.status({ runKey, workspace })`, terminal notifications, and final job/step states before reporting success.
|
|
17
|
+
Pass a descriptive `sessionName`, for example `sessionName: "Release verification"`, to identify a newly created workflow session in the rail. Omit it to use the workflow's name or filename. This does not change `name` (the run context directory) or rename an existing owner session.
|
|
18
|
+
A definition whose `validate` result reports `isolation: 'checkout'` expects its own checkout. The engine never creates one: start it through an isolating launcher such as po-sparo `worktrees.startWorkflow`, not `workflow.launch` from a shared checkout.
|
|
19
|
+
5. Pause, resume and stop only at the person's request or an explicit launcher delegation. Pass `expectedRunId` from the inspected run so a replacement generation cannot be controlled accidentally. Keep the exact `runKey` and separate `workspace`.
|
|
20
|
+
|
|
21
|
+
Shell steps, child scripts and background services use executable `/bin/zsh` when available, otherwise `/bin/sh`. Prefer POSIX shell syntax for workflows that must run on minimal Linux hosts.
|
|
22
|
+
|
|
23
|
+
Dispatcher sessions can list, discover requirements, validate and launch definitions; inspect, control or recover runs in the owner's session. Closing an exec binding does not stop a successfully launched YAML workflow; existing owner-session shutdown rules still apply. Calls are bound to the current session and reject abort, disposal and inactive package ownership.
|
|
24
|
+
|
|
25
|
+
List, requirements, validate, status, listFailed and recoveryEvidence are reads. Launch, pause, resume, stop and recover are effects serialized per session. Workflow steps consume quota and may repeat external effects: quiet progress is not a reason to replay. Inspect live ownership and persisted state first.
|
|
26
|
+
|
|
27
|
+
## Recover safely
|
|
28
|
+
|
|
29
|
+
Recovery resumes an existing terminal failed or interrupted run from its active repair, in the checkout it ran in, preserving completed work. It is not a fresh launch or permission to control another session's live run. Runs recorded with an engine-owned worktree predate its removal and cannot be recovered; launch them fresh. `workflow.listFailed` accepts workspace/runKey and exact-match `env` filters; summaries omit environment data.
|
|
30
|
+
|
|
31
|
+
A run launched by a plugin (such as Agiflow) may hold a lock for its job. The engine tells the plugin how each run ended: success releases the lock, while a failed or interrupted run keeps it so recovery reuses it and no one else picks up the job. Recover with `workflow.recover` as usual. Never release a held lock by hand or launch a fresh duplicate. When the person decides not to recover a failed run, `workflow.abandon` (with their approval) releases its lock and the run can never be recovered. `lockReleased: false` means the plugin that holds the lock is not loaded; it is released when it is.
|
|
32
|
+
|
|
33
|
+
Before `workflow.recover`, call `workflow.recoveryEvidence` with the exact run key and workspace. Read every relevant log source, process state, the recorded run.json and only the repair referenced by activeRepairId. Evidence is terminal-only and read-only; it does not scrape an earlier session's live launcher.
|
|
34
|
+
|
|
35
|
+
Choose exactly one outcome: recover when the recorded target remains valid and failure was transient; launch fresh when it cannot resume or the branch has diverged materially; defer when a named prerequisite remains unresolved. An empty failed-job target cannot be recovered. Never manufacture a target, edit issue.md or repair.json, or discard the active repair or the run's checkout. Prepare run.json only when verified recovery state requires it. Treat an already-claimed result as another recovery winning, not permission to retry or launch fresh. Do not use dryRun for a real recovery.
|
|
36
|
+
|
|
37
|
+
Under a dispatch contract only: enforce its pass budget (recover and fresh launch each cost one launch), do not recover terminal repair-triage runs, do not act on jobs in blocked columns, and report manually launched runs without a job id rather than adopting them. These job-id and board rules do not apply to ordinary manually launched workflows.
|
|
38
|
+
|
|
39
|
+
After recovery, verify real process and registry progress with workflow.status before reporting an outcome. In server sessions replay belongs to the recovering session, whose closure requests a stop. Recovery cannot make external effects idempotent or guarantee survival of parent shutdown. User-requested stops do not trigger diagnosis or automatic restart.
|
|
40
|
+
|
|
41
|
+
## Repair a stuck run (needs the person)
|
|
42
|
+
|
|
43
|
+
Use this only when recovery cannot proceed: run.json is invalid so the run is missing from listings, a dead run still sits in running, the fix budget is spent, or a repair triage locks recovery until a person unblocks it. Otherwise recover.
|
|
44
|
+
|
|
45
|
+
1. `workflow.inspectRun({ runKey, workspace })` returns every stage directory the run occupies: raw run.json and control files, the parsed record or its validation error, whether its pid is alive, and a `revision`.
|
|
46
|
+
2. Ask the person what to change before calling `workflow.repairRun`. It always needs their approval and is refused where nobody can answer. It throws `ApprovalPendingError` while they decide. Keep working; the outcome arrives later as a message. Do not call it again while one is pending.
|
|
47
|
+
3. Pass the exact `revision`, a short `reason`, and only the change you need. `record` is a full replacement run.json (copy it from the inspection and edit it), checked against the schema; workspace and run key cannot change. A record stage of `error` moves a dead running run to error. A repair never moves a run into running: repair it to error, then `workflow.recover`. `fix` rewrites fix.md (front matter `restart-from: <job>` picks where recovery restarts) or removes it with null. `remove` drops stale control files such as `recovery-claim.json`.
|
|
48
|
+
4. To lift a spent fix budget, lower or drop `fixLoopCycle` in the record. To unblock a triage lock, set the stated restart target in fix.md as the person directs. Never edit issue.md or repair.json.
|
|
49
|
+
5. A running run with a live pid is refused. Stop it first; pass `force` only when the person confirms it is hung. A run owned by another live session must be repaired there. A changed revision means inspect again, not retry.
|
|
50
|
+
|
|
51
|
+
Every repair keeps the replaced files under `repair-backups/` in the run directory. After a repair, recover and verify with `workflow.status`.
|
|
52
|
+
|
|
53
|
+
## Managed child jobs and independent checks
|
|
54
|
+
|
|
55
|
+
A managed lead sees its main job's trusted acceptance table before its first turn: each criterion,
|
|
56
|
+
its description, authorised `verified-by` child definition, current state and latest feedback. The
|
|
57
|
+
lead knows the requirements but cannot attest them. `children` is the allowlist of reusable job
|
|
58
|
+
definitions, not a fixed chain. Discover `workflow` again inside managed sessions for role-scoped methods.
|
|
59
|
+
|
|
60
|
+
- Lead: call `workflow.spawnChild({ job, prompt, inputs })` when that child has useful work. The
|
|
61
|
+
assignment is task text only; configuration and verifier authority come from the captured YAML.
|
|
62
|
+
Inputs must match the child's declaration. Keep secrets out of assignments, input values and feedback.
|
|
63
|
+
- Inspect `workflow.children()` or `workflow.childStatus({ invocationId })` for linked session ids,
|
|
64
|
+
states, checks and usage coverage. Unknown token/cost values are not zero. Route native intercom
|
|
65
|
+
sends by exact session id, never a bare name. Full-session ask/reply is not provided.
|
|
66
|
+
- Child verifier: use `workflow.reviewArtifacts()` to obtain the immutable review snapshot, then
|
|
67
|
+
`workflow.reportCriteria({ results: { criterionKey: { status: 'checked' | 'not-met', feedback } } })`.
|
|
68
|
+
Only criteria that authorise this invocation's definition can be reported. Reports commit after
|
|
69
|
+
successful invocation settlement; edits to reviewed artifacts invalidate their checks. Do not
|
|
70
|
+
change an artifact yourself and certify different bytes from the snapshot.
|
|
71
|
+
- `not-met` is successful feedback, not a failed step or repair request. The lead chooses how to
|
|
72
|
+
address it and which children to call again. The workflow never auto-spawns children by default.
|
|
73
|
+
- At settlement, unresolved children hold the lead open. Unchecked/not-met criteria prevent
|
|
74
|
+
completion and return the criteria table and bounded feedback to the SAME lead session.
|
|
75
|
+
`completion.max-continuations: 3` permits three additional prompts after the initial settled
|
|
76
|
+
attempt, not three total attempts. Child-wait notifications consume no continuations. Exhaustion
|
|
77
|
+
fails explicitly with outstanding criteria. Decision files and exit code 0 cannot bypass this guard.
|
|
78
|
+
- A person's stop cancels owned children and stays stopped. Host restart may create a replacement
|
|
79
|
+
lead conversation seeded from the durable ledger; it does not promise the same conversation id.
|
|
80
|
+
|
|
81
|
+
## Selected job tools
|
|
82
|
+
|
|
83
|
+
When the session lists the pinned `workflow-job-tools` skill, read it before using its methods. Then
|
|
84
|
+
call `discover({ namespace: 'jobTools' })` for the exact declarations and use `exec` to call them.
|
|
85
|
+
The skill teaches judgement and ordering; discovery supplies signatures. Do not invent methods or
|
|
86
|
+
assume tools selected for another job are present here. Ordinary sessions and external Claude/Codex
|
|
87
|
+
CLI runners do not receive this namespace, and there is no direct-tool fallback for it.
|
|
88
|
+
|
|
89
|
+
The workflow's optional `tools` folder is the default; a job's `tools` overrides it for its main steps,
|
|
90
|
+
`preJob` and `postJob`. Repair triage uses `repair.tools` or the default. Global phases use the default.
|
|
91
|
+
Selection comes from this session's captured config, never step `cwd` or environment values. Paths
|
|
92
|
+
retain the declaring YAML's origin through imports and job-template inheritance.
|
|
93
|
+
|
|
94
|
+
Methods are flat named async functions with JSON inputs/results. Follow the skill's input validation
|
|
95
|
+
and effect rules. Approval-gated methods use the normal code-mode approval flow; never bypass it or
|
|
96
|
+
retry an effect merely because an exec was cancelled. Bindings refuse foreign sessions, abort and
|
|
97
|
+
disposal. Exec cleanup does not stop the owning YAML workflow or change recovery ownership.
|
|
98
|
+
|
|
99
|
+
Authors provide trusted JavaScript `index.mjs` plus non-empty `SKILL.md`, not TypeScript or sandboxed
|
|
100
|
+
agent code. A per-session default-export factory receives `{ sessionId, cwd, workflow, fs, shell,
|
|
101
|
+
signal, acceptedArtifacts? }` and returns the existing namespace contract named `jobTools`: summary, declarations and
|
|
102
|
+
`bind(run)`. Validate method inputs, honour `run.signal` for work and register exec cleanup through
|
|
103
|
+
`run.onDispose`. Keep per-session state inside the factory. Optional approval policies must name a
|
|
104
|
+
returned method. Native modules are cached by file URL; restart the host after same-path module
|
|
105
|
+
edits. There is no hot reload or external CLI bridge. Missing or malformed selected tools fail the
|
|
106
|
+
managed session before its first prompt. See the package README's **Job-specific tools** section for
|
|
107
|
+
a runnable module and skill example.
|
|
108
|
+
|
|
109
|
+
An authorised downstream consumer's trusted factory can receive `acceptedArtifacts({ job })`.
|
|
110
|
+
It rechecks the runtime ledger and current revision and returns the accepted immutable bytes.
|
|
111
|
+
A task-writing adapter must fail closed when this capability is absent or stale, and construct its
|
|
112
|
+
writes from those bytes. Inside `bind(run)`, use `run.runJson({ command, args, input? })` for
|
|
113
|
+
shell-free argv plus JSON stdin/stdout. It inherits the session cwd/environment, is bounded to 15
|
|
114
|
+
seconds and the process bridge byte limits, and cancels with this exec/session. It returns
|
|
115
|
+
`{ exitCode, output, stderr }`; successful exit alone never certifies acceptance. Do not interpolate
|
|
116
|
+
input JSON or assignments into commands. Environment flags, PASS files and caller-provided acceptance booleans are
|
|
117
|
+
not authority. This adapter guards its own write path only: neither jobTools nor the acceptance
|
|
118
|
+
capability sandboxes an unrestricted agent's raw shell or other external tools.
|
|
119
|
+
|
|
120
|
+
## Hosts without code mode
|
|
121
|
+
|
|
122
|
+
Use list_workflows and launch_workflow for discovery/launch; workflow_requirements for read-only role and eligible-profile discovery; workflow_run for status/pause/resume/stop; workflow_tools for list-failed, recovery-evidence and recover. These tools share the same operations and safety checks. Managed leads receive workflow_spawn_child,
|
|
123
|
+
workflow_child_status and workflow_children; child verifiers receive workflow_review_artifacts and
|
|
124
|
+
workflow_report_criteria. Those pairs are main-agent-only and withdrawn when code mode is bound.
|
|
125
|
+
scaffold_workflow stays a separate Help-only direct tool.
|
|
126
|
+
|
|
127
|
+
# Dynamic script graphs
|
|
128
|
+
|
|
129
|
+
Use `dynamicWorkflow` when a script has multiple steps or bounded item fan-out and the person should see progress in Activity. Mastra 1.78.0 executes the workflow. Po observes lifecycle and `team.run` child transcripts; it is not another scheduler. Discover `dynamicWorkflow` for the current signatures.
|
|
130
|
+
|
|
131
|
+
Use the supplied `z` (the Zod 3 API), `createStep`, and `createWorkflow`, not raw npm imports. Build, commit, create a run, then await `start({inputData})`. Run long work inside `exec_background` so the parent remains responsive; cancellation and disposal stop active runs.
|
|
132
|
+
|
|
133
|
+
```ts
|
|
134
|
+
const { z, createStep, createWorkflow } = dynamicWorkflow;
|
|
135
|
+
const phase = (id) =>
|
|
136
|
+
createStep({
|
|
137
|
+
id,
|
|
138
|
+
inputSchema: z.string(),
|
|
139
|
+
outputSchema: z.string(),
|
|
140
|
+
execute: async ({ inputData }) => {
|
|
141
|
+
const child = await team.run({ task: inputData, systemPrompt: 'Complete this item and report your findings.' });
|
|
142
|
+
// The script owns its failure policy: inspect child.status and decide
|
|
143
|
+
// whether to throw, retry, or return failure data for another phase.
|
|
144
|
+
return inputData;
|
|
145
|
+
},
|
|
146
|
+
});
|
|
147
|
+
const item = createWorkflow({ id: 'item', inputSchema: z.string(), outputSchema: z.string() })
|
|
148
|
+
.then(phase('gather'))
|
|
149
|
+
.then(phase('check'))
|
|
150
|
+
.commit();
|
|
151
|
+
const workflow = createWorkflow({ id: 'items', inputSchema: z.array(z.string()), outputSchema: z.array(z.string()) })
|
|
152
|
+
.foreach(item, { concurrency: 3 })
|
|
153
|
+
.commit();
|
|
154
|
+
return await (await workflow.createRun()).start({ inputData: ['first', 'second'] });
|
|
155
|
+
```
|
|
156
|
+
|
|
157
|
+
Supported composition: `.then(step)`, `.parallel([step,...])`, `.branch([[predicate,step],...])`, and `.foreach(committedTrackedItemWorkflow,{concurrency:positiveInteger})`. Branch predicates receive execution parameters and must return a boolean. Every matched branch can execute. Commit each nested workflow before adding it. Create every nested handle within the same exec binding. Use distinct step ids in a workflow. Handles are not durable and cannot be shared between exec calls.
|
|
158
|
+
|
|
159
|
+
Not supported: bare-step foreach, dynamic concurrency callbacks, raw Mastra instances, custom engines or storage, streams, Mastra suspend/resume, time travel, retries configured through workflow options, startAsync, or private methods. Only `id`, optional `description`, `inputSchema`, `outputSchema`, and step `execute` options are accepted. `createRun()` takes no options; `start` accepts only `inputData`; `cancel()` stops that run.
|
|
160
|
+
|
|
161
|
+
Return `null`, not `undefined`, when a callback intentionally has no output. The code-mode membrane converts guest callback exceptions to undefined; Po reports that as failed and directs you to exec diagnostics, rather than inventing the original error. A normal returned failure object is data, not an automatic exception. Mastra's own failure/queue behavior still applies. Mastra 1.78 validates step input but does not enforce step output schemas at runtime. Po preserves that behavior rather than adding a second validation engine. A child-agent failure remains visible even if the script handles it and Mastra finishes successfully. Po keeps execution status separate from this application outcome.
|
|
162
|
+
|
|
163
|
+
Activity snapshots are metadata only: names, topology, status, timing, bounded errors and child run ids. They omit prompts, schemas, callback source, input and output. Keep sensitive data out of ids and error messages. At most 20 finished root runs remain in memory, active roots are never evicted, and groups publish up to 1000 rows with true totals and aggregate counts.
|
|
164
|
+
|
|
165
|
+
## Resume after a restart
|
|
166
|
+
|
|
167
|
+
Po saves the exact outer exec source and JSON-serializable successful step outputs under the session's workflow artifacts. On restart or release, the owner agent receives a prompt to arm `await dynamicWorkflow.resume(recordId)` and import the returned `specifier`. Resume is scoped to that exec binding. Use the exact saved script, root workflow ids, root order and input. A source or root mismatch throws before that root's callbacks run; there is no uncached fallback.
|
|
168
|
+
|
|
169
|
+
- Code outside steps re-runs. Put effects you want memoized inside steps.
|
|
170
|
+
- Step outputs must be JSON-serializable. Other outputs are not saved and those steps re-run.
|
|
171
|
+
- Branch predicates must be pure because they run again during replay.
|
|
172
|
+
- A step interrupted before its output was saved repeats its side effects.
|
|
173
|
+
- Imported scripts are not copied. Keep their definitions stable for replay.
|
|
174
|
+
|
|
175
|
+
A person's stop does not resume automatically. Interrupted runs appear stopped with the restart note, not a separate UI status.
|
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: help-how-to-workflow
|
|
3
|
+
description: Author and maintain Po workflow graphs, validate commands and artifacts, and scaffold definitions in Help mode.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Workflow authoring and maintenance
|
|
7
|
+
|
|
8
|
+
`@agimon-ai/po-workflow` owns persisted YAML execution and the `workflow` and `dynamicWorkflow` code-mode namespaces. Select the workflow layer in modes.yaml. There is no workflow minor mode. Load `codemode-how-to-workflow` for launching, monitoring and recovery.
|
|
9
|
+
|
|
10
|
+
In Help mode, use `scaffold_workflow` to create a YAML skeleton. Choose an explicit `preset`; omitting it preserves the existing `dag` skeleton. Existing files require explicit `force: true` to overwrite. Scaffolding writes a definition, it does not launch agents or run commands. Review and customize the generated file before running it.
|
|
11
|
+
|
|
12
|
+
## Choose a workflow type
|
|
13
|
+
|
|
14
|
+
| Preset | Use when | Completion authority |
|
|
15
|
+
| ---------------- | ------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------- |
|
|
16
|
+
| `dag` | Jobs and their dependencies are known before launch. | Job/step outcomes and declared artifacts. |
|
|
17
|
+
| `child-review` | One producer owns the work and repairs, while independent child jobs attest acceptance criteria. | Current immutable artifact checks from the authorized child verifiers. |
|
|
18
|
+
| `dynamic-fanout` | A step discovers a bounded item list at runtime and needs tracked per-item work. | The enclosing step's outcome and persisted results, not independent acceptance. |
|
|
19
|
+
|
|
20
|
+
Call the Help-only `scaffold_workflow` tool with one of these inputs:
|
|
21
|
+
|
|
22
|
+
```json
|
|
23
|
+
{ "path": "automations/check.workflow.yml", "preset": "dag" }
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
```json
|
|
27
|
+
{ "path": "automations/produce.workflow.yml", "preset": "child-review" }
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
```json
|
|
31
|
+
{ "path": "automations/items.workflow.yml", "preset": "dynamic-fanout" }
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
Do not turn independent acceptance into ordinary Team fan-out: a producer's summary of another agent's opinion is not an authorized criterion report. Conversely, use the simpler `dag` or `dynamic-fanout` contract when independent attestation is not required. Managed agent presets require the Po server; they are not shell/CLI-only workflows. Replace the example brief and set `runConfig.majorMode` to an existing mode with the workflow layer. The fan-out mode also needs Team. Pin available models under the producer/reviewer job `runConfig` when the task requires distinct models, never invent model IDs.
|
|
35
|
+
|
|
36
|
+
# Author Po workflows
|
|
37
|
+
|
|
38
|
+
Create a `*.workflow.yml` file and keep its graph explicit:
|
|
39
|
+
|
|
40
|
+
```yaml
|
|
41
|
+
name: verify
|
|
42
|
+
|
|
43
|
+
jobs:
|
|
44
|
+
test:
|
|
45
|
+
steps:
|
|
46
|
+
- name: Run tests
|
|
47
|
+
run: pnpm test
|
|
48
|
+
|
|
49
|
+
summarize:
|
|
50
|
+
needs: test
|
|
51
|
+
steps:
|
|
52
|
+
- name: Record result
|
|
53
|
+
run: node scripts/write-verification-summary.mjs
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
`needs` expresses job ordering. Keep steps small enough that failure evidence identifies the command that needs attention. Use runner-specific `interactiveRun` configuration when a command genuinely requires a TTY.
|
|
57
|
+
|
|
58
|
+
For an agent step, declare the command once under `commands` (usually in an imported file) and let the step name it. A command is a Liquid template; `inProcess: true` lets the Po server run it as a child session instead of the shell, and the CLI and the TUI run the rendered command:
|
|
59
|
+
|
|
60
|
+
```yaml
|
|
61
|
+
imports: [commands.yml]
|
|
62
|
+
choices:
|
|
63
|
+
default: { model: openai-codex/gpt-6-sol, thinking: medium }
|
|
64
|
+
jobs:
|
|
65
|
+
develop:
|
|
66
|
+
steps:
|
|
67
|
+
- name: Develop
|
|
68
|
+
runConfig: { majorMode: dev, domains: [engineering] }
|
|
69
|
+
systemPrompt: ${{ env.JOB_SYSTEM_PROMPT }}
|
|
70
|
+
prompt: ${{ env.WORKFLOW_CONTEXT }}
|
|
71
|
+
interactiveRun: [{ command: po }, { command: terminal }]
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
`po` and `terminal` are the commands `commands.yml` declares; a step can only name a declared command. `runConfig` takes `majorMode`, `minorModes`, `profile`, `domains`, `model`, and `thinking`, plus any key the template reads; any other key fails the step, so a typo such as `majormode` never runs on workspace defaults. `choices` compose model and thinking, with per-command overrides such as `terminal: { model: openai-codex/gpt-6-luna }`; a step can pin `choice:`, and a launch picks `command=` and `choice=` for the rest. Templates must quote prompts with `{{ prompt | shell }}`.
|
|
75
|
+
|
|
76
|
+
A command that only the Po server should run, such as `po: { inProcess: true }`, leaves out `run`. Its steps then fail in the CLI and the TUI, which have no shell command to run, instead of starting an agent outside Po.
|
|
77
|
+
|
|
78
|
+
After scaffolding and before launch, use `workflow.validate({ workflowPath, inputs, env, command, choice, runner, profile, job })` in code mode with the intended launch settings. Omit optional settings you do not need. Read diagnostic codes, locations and corrective messages; fix errors, then revalidate after edits. This checks the imported/extended graph and actual command binding resolution, not just the YAML schema. It checks required/default inputs and declared options/types, missing injected references, command/choice settings, effective runConfig and interpolation phases. Workflow env and runConfig values are literal where execution leaves them literal; a prompt cannot read a step-only env override that is installed later.
|
|
79
|
+
|
|
80
|
+
Read the separate `deferred` entries too. Run identities, assembled job prompts, child invocation inputs and conditional context files are not fabricated during validation. Mode/model/profile admission, authentication, shell behavior and produced artifacts still need runtime verification. `valid: true` means no errors detected by the available checks, not guaranteed successful execution. Reports/cards omit binding values; validation does not load secret files or execute steps. Secret availability may remain deferred.
|
|
81
|
+
|
|
82
|
+
Without code mode, run `workflow-mcp doctor <file-or-directory> --run-config-keys majorMode,minorModes,profile,domains,model,thinking,subagentModel,subagentThinking --format json` for definition diagnostics. The CLI doctor does not preview supplied launch bindings. Fix every error; the Po server refuses to launch a definition with errors.
|
|
83
|
+
|
|
84
|
+
An agent step ends by recording its outcome: `workflow-mcp step complete`, `step fix --restart-from <job> --reason ...`, or `step fail --reason ...`. The engine puts the instructions in the step's system prompt, and an agent that stops without deciding is sent back until it does. Write repair contracts in those terms, not as `fix.md`.
|
|
85
|
+
|
|
86
|
+
What a step or job must leave is held the same way. A step's `artifacts` must be written during the step. A job must be the last to have written each run-directory entry it produces (`produced-by`): an entry an earlier job wrote must be written again, while a retry or a job that skips work it already did keeps its own output, and removing a file counts. `writes.ndjson` in the run directory records which job and step last wrote each entry. An agent step that ends its job is sent back until those entries are written, and the job fails when one was not. List a job under `produced-by` only when it writes the entry in every run. Write a `description` for every entry: the reminder tells the agent what the file holds from it.
|
|
87
|
+
|
|
88
|
+
Put independent checks in a `parallel` group. A `run:` check with `restart-from: <job>` turns a failure into a fix request, and every fix request of the job merges into one repair, so one loop back fixes all of them. Keep steps that edit files out of a group: its steps share the checkout.
|
|
89
|
+
|
|
90
|
+
Every `run` command executes on the workflow host with that process's environment and privileges. There is no VM, container, or sandbox. Review workflow changes as executable code, avoid embedding secrets, and make retry-sensitive external side effects explicit.
|
|
91
|
+
|
|
92
|
+
Before relying on the graph, discover it with `workflow.list`, validate the exact intended settings with `workflow.validate`, then launch an authorized disposable run with `workflow.launch` and inspect job/step status with `workflow.status`. Test a failure path when recovery behavior matters. Validation alone is not runtime acceptance.
|
|
93
|
+
|
|
94
|
+
## Author one producer with independent child reviews
|
|
95
|
+
|
|
96
|
+
Start with `preset: child-review`. Keep exactly one main job under `jobs` when one producer is required. Define reusable reviewers separately under top-level `child-jobs`, not as root jobs connected with `needs`.
|
|
97
|
+
|
|
98
|
+
1. Declare the deliverable as a file under `run-directory.entries`, with a description and `produced-by: [producer]`. The producer's managed step declares that file in `artifacts` and writes it in `WORKFLOW_RUN_DIR`.
|
|
99
|
+
2. The producer's `children` lists allowed child definition names. Its `acceptance-criteria` maps stable criterion keys to descriptions, `verified-by` child names and explicit `artifacts` paths. Do not let assignment text, launch inputs or a producer-generated PASS file define acceptance authority.
|
|
100
|
+
3. The producer explicitly calls `workflow.spawnChild({ job, prompt })` after preparing evidence. Children are not scheduled automatically, and `children` is not a fixed chain. If `inputs` are needed, declare their primitive types/requirements on the child before passing them in the spawn call. Jobs execute from the runtime root; definition-relative imports/tools and step `working-directory` have separate meanings.
|
|
101
|
+
4. Each reviewer calls `workflow.reviewArtifacts()` and assesses the immutable snapshot for only its authorized keys. It calls `workflow.reportCriteria({ results: { accurate: { status: 'checked', feedback: 'Evidence verified...' } } })` or reports `not-met` with concrete findings. It must not rewrite the producer's evidence or certify the producer's assertions. Reports commit only after successful child settlement.
|
|
102
|
+
5. The producer inspects `workflow.children()` and `workflow.childStatus({ invocationId })`, makes repairs itself, and requests fresh checks after changing reviewed artifacts. Do not edit shared evidence while children are reviewing it. All children must settle and all criteria must be checked against current bytes before completion.
|
|
103
|
+
|
|
104
|
+
Explicit criterion artifacts keep unrelated files from invalidating a review. For media, a text snapshot containing a filename does not attest the MP4, image or audio bytes: include immutable manifests/hashes, have reviewers verify the referenced files, and inspect the actual rendered/audio evidence. Distinguish source checks, deterministic measurements, rendered inspection and listening. Never claim a kind of review that was not performed.
|
|
105
|
+
|
|
106
|
+
`completion.max-continuations: 3` permits three additional settled attempts in the same lead session after its initial attempt, not three total attempts or a fresh root-job retry budget. Child waits consume the lead step's timeout, not continuation prompts. `not-met` is successful review feedback; execution/auth/environment failures are failures, not editorial verdicts. Exhaustion fails with outstanding criteria. A person's stop stays stopped. Load `codemode-how-to-workflow` for role-scoped methods, settlement and restart behavior.
|
|
107
|
+
|
|
108
|
+
## Job-specific tools
|
|
109
|
+
|
|
110
|
+
Use a workflow-owned tools folder when a managed Po agent step needs task-specific methods. Reuse
|
|
111
|
+
code mode, not a new direct tool or external CLI bridge:
|
|
112
|
+
|
|
113
|
+
```yaml
|
|
114
|
+
tools: ./tools/shared
|
|
115
|
+
runConfig: { majorMode: copilot }
|
|
116
|
+
jobs:
|
|
117
|
+
summarize:
|
|
118
|
+
tools: ./tools/report
|
|
119
|
+
steps:
|
|
120
|
+
- name: Summarize
|
|
121
|
+
customRun:
|
|
122
|
+
prompt: Read workflow-job-tools, discover jobTools, then summarize this job.
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
Workflow `tools` is the default. A job override applies to its main steps, `preJob` and `postJob`;
|
|
126
|
+
repair triage uses `repair.tools` or the default. Global phases use the default. Paths resolve against
|
|
127
|
+
the declaring YAML before imports and template inheritance, never step `cwd` or environment values.
|
|
128
|
+
Each session uses its captured config.
|
|
129
|
+
Parsing, listing and inspection do not execute the tools module.
|
|
130
|
+
|
|
131
|
+
The folder must contain `index.mjs` and non-empty `SKILL.md`. Default-export a factory receiving
|
|
132
|
+
`{ sessionId, cwd, workflow, fs, shell, signal, context }`, where `workflow` is the trusted workflow
|
|
133
|
+
context and `context` is the call context `fs` and `shell` methods take (aborted with `signal`).
|
|
134
|
+
Return a `PoCodemodeNamespace` named `jobTools`, with a one-line `summary`, TypeScript `declarations`
|
|
135
|
+
and `bind(run)` returning flat named async methods with JSON arguments and results. Keep per-session
|
|
136
|
+
state inside the factory, validate method inputs, honour `run.signal`, pass `run.context` to `fs` and
|
|
137
|
+
`shell` calls made from a method so they stop with the exec, and register exec-owned cleanup
|
|
138
|
+
with `run.onDispose`. Optional approval policies must name returned methods and use the existing
|
|
139
|
+
code-mode approval flow. Put judgement, ordering and effect rules in the skill, not signatures.
|
|
140
|
+
The package README's **Job-specific tools** section has a runnable module and skill example.
|
|
141
|
+
|
|
142
|
+
Only managed Po `customRun` and in-process `interactiveRun` sessions receive the namespace and pinned
|
|
143
|
+
`workflow-job-tools` skill. Ordinary sessions, shell steps and external Claude/Codex runners do not.
|
|
144
|
+
These modules are trusted host code, not sandboxed code or directly loaded TypeScript. Native import
|
|
145
|
+
caches by file URL: restart the host after same-path module edits; there is no hot reload.
|
|
146
|
+
|
|
147
|
+
Verify a disposable managed step can read the skill, `discover({ namespace: 'jobTools' })`, and call
|
|
148
|
+
its methods through `exec`. Check invalid input and cancellation before relying on effects. Missing
|
|
149
|
+
files or malformed selected tools fail the managed session before its first prompt. Namespace and
|
|
150
|
+
skill dispose together without stopping the owning workflow or changing recovery ownership. Load
|
|
151
|
+
`codemode-how-to-workflow` for agent-side usage and safety rules.
|
|
152
|
+
|
|
153
|
+
## Step instructions
|
|
154
|
+
|
|
155
|
+
Top-level `instructions: ./AGENTS.md` gives the workflow's managed Po agent steps their own instructions
|
|
156
|
+
file in place of the AGENTS.md files they would discover from their working directory. It resolves and
|
|
157
|
+
inherits through imports like `tools`; the importing workflow's own value wins. A missing or unreadable
|
|
158
|
+
file fails the step session before its first prompt. Shell steps and external CLI runners ignore it.
|
|
159
|
+
|
|
160
|
+
## Dynamic fan-out inside a step
|
|
161
|
+
|
|
162
|
+
Start with `preset: dynamic-fanout` when one step needs work whose shape is only known at runtime (one agent per file, finding or page). Keep the YAML graph fixed and let a `customRun` step's agent run a `dynamicWorkflow` script through `exec_background`. The generated prompt includes a runnable `createStep` / committed item workflow / `.foreach(item, { concurrency: 3 })` example. Replace its sample items and read-only task with the real discovered list before running. The step session has code mode in every major mode; child agents (`team.run`) need the Team layer in the step's `runConfig.majorMode`.
|
|
163
|
+
|
|
164
|
+
Keep concurrency bounded and inspect every child's terminal status. A failed child must not become a success just because its error was returned as data. The runs appear under that step in Activity, but the YAML step still settles on its agent and declared artifacts: persist actual outcomes to the generated `results.md`, not just an exec return value. Item findings do not attest managed acceptance criteria.
|
|
165
|
+
|
|
166
|
+
Create and commit nested workflows within the same exec binding. Use the supplied `z`, `createStep` and `createWorkflow`, not raw package imports. Successful step outputs must be JSON-serializable for replay; code outside steps runs again, and interrupted steps may repeat effects. Prefer read-only item tasks and make any required writes idempotent. Resume with the exact saved source and the runtime's `dynamicWorkflow.resume` instructions rather than launching a fresh copy. Load `codemode-how-to-workflow` for the full composition and replay limits.
|
|
167
|
+
|
|
168
|
+
## Native execution contract
|
|
169
|
+
|
|
170
|
+
Agent steps require an effective `runConfig.majorMode`; delegated workflows require top-level `runConfig.majorMode` before their owner child is created. Selection projects major mode, minor modes, profile and domains, without adding a workflow minor mode. `subagentModel` and `subagentThinking` set Team preferences independently of the step model.
|
|
171
|
+
|
|
172
|
+
The native host requires execution-state inspection before creating agent steps. After settlement it waits for idle, no pending messages and a known background snapshot without core holds or holding-provider errors before checking decisions. Unknown ownership waits closed without consuming reminders; stops interrupt reads and retry delays.
|
|
173
|
+
|
|
174
|
+
Delegated successes are informational. Errors wake the workflow owner through durable custom-message admission; the launcher gets an error notification, not an agent-waking failure completion. Diagnosis stays local. A Po restart or session release resumes interrupted runs automatically, re-running the interrupted job while keeping earlier jobs finished. A person's stop never resumes automatically, and a person-paused run stays interrupted. Other recovery, pause, resume and stop actions are request-driven. User-requested stops do not trigger diagnosis or automatic restart.
|
|
@@ -4,6 +4,27 @@
|
|
|
4
4
|
* the cockpit renders them as 'workflow_runs' channel payloads.
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
|
+
import type { PoHubSessionUsage } from '@agimon-ai/po-core/hubChannel';
|
|
8
|
+
import type { PoWorkflowChildrenStatus } from '@agimon-ai/po-core/workflow';
|
|
9
|
+
|
|
10
|
+
/** Usage coverage is explicit: an absent total is not a measured zero. */
|
|
11
|
+
export interface WorkflowChildUsageSummary {
|
|
12
|
+
/** False when a journal or any invocation metric is unavailable. */
|
|
13
|
+
complete: boolean;
|
|
14
|
+
invocationCount: number;
|
|
15
|
+
tokensKnown: number;
|
|
16
|
+
costKnown: number;
|
|
17
|
+
toolCountKnown: number;
|
|
18
|
+
tokens?: PoHubSessionUsage['tokens'];
|
|
19
|
+
costUsd?: number;
|
|
20
|
+
toolCount?: number;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export interface WorkflowChildStatusError {
|
|
24
|
+
lead?: string;
|
|
25
|
+
message: string;
|
|
26
|
+
}
|
|
27
|
+
|
|
7
28
|
/** workflow-mcp's own stage vocabulary; the registry bucket a run record sits in. */
|
|
8
29
|
export type WorkflowStage = 'running' | 'completed' | 'error';
|
|
9
30
|
|
|
@@ -25,6 +46,8 @@ export type WorkflowProgressState =
|
|
|
25
46
|
export const STEP_SESSION_REF_KIND = 'session';
|
|
26
47
|
/** A command step ran in this terminal pane. */
|
|
27
48
|
export const STEP_PANE_REF_KIND = 'pane';
|
|
49
|
+
/** The activity panel's scope line while a step tab is open. */
|
|
50
|
+
export const STEP_ACTIVITY_SCOPE = 'diagnose step';
|
|
28
51
|
|
|
29
52
|
/** Where a host executor ran a step: `session` for a customRun agent, `pane` for a command. */
|
|
30
53
|
export interface WorkflowStepRefView {
|
|
@@ -77,6 +100,8 @@ export interface WorkflowPosition {
|
|
|
77
100
|
* run.json record plus the folded progress.ndjson job tree.
|
|
78
101
|
*/
|
|
79
102
|
export interface WorkflowRunView {
|
|
103
|
+
/** Opaque owner-qualified API/cache key. The displayed engine runKey stays unchanged. */
|
|
104
|
+
routeKey?: string;
|
|
80
105
|
/** Engine generation identity, distinct from a reused run key. */
|
|
81
106
|
runId?: string;
|
|
82
107
|
/** Registry identity within its workspace; unique per workspace+stage. */
|
|
@@ -102,12 +127,17 @@ export interface WorkflowRunView {
|
|
|
102
127
|
stale?: boolean;
|
|
103
128
|
staleReason?: string;
|
|
104
129
|
worktreeBranch?: string;
|
|
105
|
-
/** The session that owns the run (its
|
|
130
|
+
/** The session that owns the run (its PO_SESSION_ID); absent on records that carry none. */
|
|
106
131
|
ownerSessionId?: string;
|
|
107
132
|
/** The session that launched the run into its own workflow session, when it was handed off. */
|
|
108
133
|
launcherSessionId?: string;
|
|
109
134
|
position?: WorkflowPosition;
|
|
110
135
|
jobs: WorkflowJobView[];
|
|
136
|
+
/** Latest durable child state, including readable agent-session references. */
|
|
137
|
+
children?: readonly PoWorkflowChildrenStatus[];
|
|
138
|
+
childUsage?: WorkflowChildUsageSummary;
|
|
139
|
+
/** Missing or corrupt child evidence is visible, never represented as successful empty work. */
|
|
140
|
+
childStatusErrors?: WorkflowChildStatusError[];
|
|
111
141
|
}
|
|
112
142
|
|
|
113
143
|
/** What the workflow runs channel publishes for one session. */
|