@osolmaz/pi-workflows 0.16.1 → 0.16.3
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/README.md +41 -41
- package/dist/builtins/monitor.workflow.d.ts +1 -1
- package/dist/builtins/monitor.workflow.js +8 -8
- package/dist/builtins/pi-agent-group.js +3 -3
- package/dist/builtins/pi-agent-group.js.map +1 -1
- package/dist/channels/adapter-entry.js +14 -14
- package/dist/channels/adapter-entry.js.map +1 -1
- package/dist/client/client.d.ts +6 -6
- package/dist/client/client.js +27 -27
- package/dist/client/client.js.map +1 -1
- package/dist/client/protocol.d.ts +4 -1
- package/dist/client/protocol.js +17 -11
- package/dist/client/protocol.js.map +1 -1
- package/dist/client/resolver.d.ts +4 -4
- package/dist/client/view.d.ts +7 -1
- package/dist/client/view.js +1 -0
- package/dist/client/view.js.map +1 -1
- package/dist/extension/index.d.ts +1 -1
- package/dist/extension/index.js +66 -47
- package/dist/extension/index.js.map +1 -1
- package/dist/extension/recorder.d.ts +1 -1
- package/dist/extension/recorder.js +1 -1
- package/dist/extension/recorder.js.map +1 -1
- package/dist/extension/remote-recorder-store.d.ts +1 -1
- package/dist/extension/remote-recorder-store.js +2 -2
- package/dist/extension/remote-recorder-store.js.map +1 -1
- package/dist/extension/{controller-command.d.ts → resource-manager-command.d.ts} +6 -6
- package/dist/extension/{controller-command.js → resource-manager-command.js} +7 -7
- package/dist/extension/resource-manager-command.js.map +1 -0
- package/dist/extension/session-delivery.d.ts +1 -1
- package/dist/extension/session-delivery.js +2 -2
- package/dist/extension/session-delivery.js.map +1 -1
- package/dist/extension/session-view.d.ts +1 -1
- package/dist/extension/session-view.js +1 -1
- package/dist/extension/session-view.js.map +1 -1
- package/dist/extension/workflow-message-coordinator.d.ts +4 -3
- package/dist/extension/workflow-message-coordinator.js +81 -29
- package/dist/extension/workflow-message-coordinator.js.map +1 -1
- package/dist/resource-managers/conditions.d.ts +6 -0
- package/dist/{controllers → resource-managers}/conditions.js +3 -3
- package/dist/resource-managers/conditions.js.map +1 -0
- package/dist/resource-managers/definition.d.ts +6 -0
- package/dist/resource-managers/definition.js +45 -0
- package/dist/resource-managers/definition.js.map +1 -0
- package/dist/resource-managers/effects.d.ts +15 -0
- package/dist/{controllers → resource-managers}/effects.js +2 -2
- package/dist/resource-managers/effects.js.map +1 -0
- package/dist/resource-managers/errors.d.ts +12 -0
- package/dist/resource-managers/errors.js +25 -0
- package/dist/resource-managers/errors.js.map +1 -0
- package/dist/resource-managers/index.d.ts +12 -0
- package/dist/resource-managers/index.js +12 -0
- package/dist/resource-managers/index.js.map +1 -0
- package/dist/resource-managers/json.js.map +1 -0
- package/dist/resource-managers/loader.d.ts +23 -0
- package/dist/resource-managers/loader.js +75 -0
- package/dist/resource-managers/loader.js.map +1 -0
- package/dist/resource-managers/results.d.ts +5 -0
- package/dist/resource-managers/results.js.map +1 -0
- package/dist/resource-managers/runtime.d.ts +59 -0
- package/dist/{controllers/manager.js → resource-managers/runtime.js} +57 -57
- package/dist/resource-managers/runtime.js.map +1 -0
- package/dist/{controllers → resource-managers}/sqlite.d.ts +51 -43
- package/dist/{controllers → resource-managers}/sqlite.js +187 -125
- package/dist/resource-managers/sqlite.js.map +1 -0
- package/dist/{controllers → resource-managers}/store.d.ts +33 -33
- package/dist/{controllers → resource-managers}/store.js.map +1 -1
- package/dist/{controllers → resource-managers}/types.d.ts +41 -41
- package/dist/{controllers → resource-managers}/types.js.map +1 -1
- package/dist/resource-managers/workflows.d.ts +34 -0
- package/dist/{controllers → resource-managers}/workflows.js +15 -15
- package/dist/resource-managers/workflows.js.map +1 -0
- package/dist/server/channel-effects.js.map +1 -0
- package/dist/{host → server}/channel-supervisor.d.ts +6 -6
- package/dist/{host → server}/channel-supervisor.js +3 -3
- package/dist/server/channel-supervisor.js.map +1 -0
- package/dist/{host/child-worker-supervisor.d.ts → server/child-runner-supervisor.d.ts} +15 -13
- package/dist/{host/child-worker-supervisor.js → server/child-runner-supervisor.js} +6 -5
- package/dist/server/child-runner-supervisor.js.map +1 -0
- package/dist/{host → server}/processes.d.ts +3 -3
- package/dist/{host → server}/processes.js +3 -3
- package/dist/server/processes.js.map +1 -0
- package/dist/{host → server}/resolver-entry.d.ts +6 -6
- package/dist/{host → server}/resolver-entry.js +14 -14
- package/dist/server/resolver-entry.js.map +1 -0
- package/dist/server/resource-runner-entry.d.ts +2 -0
- package/dist/{host/controller-worker-entry.js → server/resource-runner-entry.js} +33 -33
- package/dist/server/resource-runner-entry.js.map +1 -0
- package/dist/server/resource-runner-protocol.d.ts +36 -0
- package/dist/server/resource-runner-protocol.js +49 -0
- package/dist/server/resource-runner-protocol.js.map +1 -0
- package/dist/server/resource-runner-supervisor.d.ts +21 -0
- package/dist/{host/worker-supervisor.js → server/resource-runner-supervisor.js} +17 -17
- package/dist/server/resource-runner-supervisor.js.map +1 -0
- package/dist/{host → server}/rpc-bridge.d.ts +3 -3
- package/dist/{host → server}/rpc-bridge.js +3 -3
- package/dist/server/rpc-bridge.js.map +1 -0
- package/dist/{host → server}/rpc-executor.d.ts +1 -1
- package/dist/{host → server}/rpc-executor.js +3 -3
- package/dist/server/rpc-executor.js.map +1 -0
- package/dist/{host/host-entry.js → server/server-entry.js} +6 -6
- package/dist/server/server-entry.js.map +1 -0
- package/dist/{host/runner.d.ts → server/server.d.ts} +47 -39
- package/dist/{host/runner.js → server/server.js} +624 -535
- package/dist/server/server.js.map +1 -0
- package/dist/{host → server}/state.d.ts +25 -25
- package/dist/{host → server}/state.js +49 -49
- package/dist/server/state.js.map +1 -0
- package/dist/{host → server}/view.d.ts +7 -7
- package/dist/{host → server}/view.js +19 -15
- package/dist/server/view.js.map +1 -0
- package/dist/server/workflow-runner-content.d.ts +6 -0
- package/dist/server/workflow-runner-content.js +96 -0
- package/dist/server/workflow-runner-content.js.map +1 -0
- package/dist/server/workflow-runner-entry.d.ts +13 -0
- package/dist/{host/worker-entry.js → server/workflow-runner-entry.js} +89 -57
- package/dist/server/workflow-runner-entry.js.map +1 -0
- package/dist/server/workflow-runner-protocol.d.ts +69 -0
- package/dist/server/workflow-runner-protocol.js +176 -0
- package/dist/server/workflow-runner-protocol.js.map +1 -0
- package/dist/{host/worker-store.d.ts → server/workflow-runner-store.d.ts} +11 -11
- package/dist/{host/worker-store.js → server/workflow-runner-store.js} +8 -8
- package/dist/server/workflow-runner-store.js.map +1 -0
- package/dist/server/workflow-runner-supervisor.d.ts +22 -0
- package/dist/server/workflow-runner-supervisor.js +56 -0
- package/dist/server/workflow-runner-supervisor.js.map +1 -0
- package/dist/state/prune.d.ts +1 -1
- package/dist/state/prune.js +17 -10
- package/dist/state/prune.js.map +1 -1
- package/dist/state/schema.js +2 -2
- package/dist/state/workflow-messages.d.ts +3 -1
- package/dist/state/workflow-messages.js +32 -1
- package/dist/state/workflow-messages.js.map +1 -1
- package/dist/viewer/backup.js +1 -1
- package/dist/viewer/backup.js.map +1 -1
- package/dist/viewer/cli.d.ts +2 -2
- package/dist/viewer/cli.js +46 -32
- package/dist/viewer/cli.js.map +1 -1
- package/dist/viewer/tui.d.ts +1 -1
- package/dist/viewer/tui.js +1 -1
- package/dist/viewer/tui.js.map +1 -1
- package/dist/workflows/command-batch.js +2 -2
- package/dist/workflows/composition.js +0 -4
- package/dist/workflows/composition.js.map +1 -1
- package/dist/workflows/definition.js +0 -8
- package/dist/workflows/definition.js.map +1 -1
- package/dist/workflows/engine.js +18 -20
- package/dist/workflows/engine.js.map +1 -1
- package/dist/workflows/schema.js +0 -4
- package/dist/workflows/schema.js.map +1 -1
- package/dist/workflows/store.d.ts +27 -11
- package/dist/workflows/store.js +66 -18
- package/dist/workflows/store.js.map +1 -1
- package/dist/workflows/types.d.ts +3 -5
- package/docs/2026-08-20-durable-workflow-launch-plan.md +12 -12
- package/docs/2026-08-25-workflow-follow-ups.md +7 -7
- package/docs/2026-08-25-workflow-settings.md +3 -3
- package/docs/2026-08-30-out-of-process-workflow-host-plan.md +3 -3
- package/docs/2026-09-01-restore-session-delivery-controls-plan.md +5 -5
- package/docs/2026-09-01-unified-workflow-client-plan.md +6 -6
- package/docs/2026-09-02-installed-live-e2e-plan.md +3 -3
- package/docs/2026-09-02-unify-workflow-messages-plan.md +8 -8
- package/docs/2026-09-04-workflow-run-state-plan.md +363 -0
- package/docs/DEFERRED_TURNS.md +7 -7
- package/docs/DESIGN_PHILOSOPHY.md +1 -1
- package/docs/HUMAN_DECISIONS.md +11 -11
- package/docs/HUMAN_DECISION_PRESENTATIONS.md +4 -4
- package/docs/MONITOR.md +1 -1
- package/docs/RESOURCE_MANAGERS.md +221 -0
- package/docs/SQLITE_STATE.md +40 -34
- package/docs/WORKFLOW_COMPOSITION.md +1 -1
- package/docs/{WORKFLOW_HOST.md → WORKFLOW_SERVER.md} +131 -116
- package/docs/WORKFLOW_STEP_MESSAGES.md +18 -18
- package/docs/WORKFLOW_UPDATES.md +16 -16
- package/docs/development.md +15 -14
- package/docs/live-replay-protocol.md +20 -20
- package/docs/plans/2026-08-04-controller-runtime-plan.md +25 -25
- package/docs/plans/2026-08-05-always-on-workflows-plan.md +8 -8
- package/docs/plans/2026-08-10-agent-managed-monitor-workflows-plan.md +2 -2
- package/docs/plans/2026-08-13-session-addressed-workflow-notifications-plan.md +1 -1
- package/docs/plans/2026-08-16-workflow-updates-plan.md +5 -5
- package/docs/plans/2026-08-19-human-decision-gates-plan.md +1 -1
- package/docs/plans/2026-08-20-bounded-command-batches-plan.md +1 -1
- package/docs/plans/2026-08-21-deferred-turn-intents-plan.md +3 -3
- package/docs/plans/2026-08-21-sanity-check-plan.md +2 -2
- package/docs/plans/2026-08-23-assistant-agent-completion-plan.md +5 -5
- package/docs/plans/2026-08-23-sqlite-state-plan.md +25 -25
- package/docs/plans/2026-08-25-live-workflow-settings-plan.md +4 -4
- package/docs/plans/2026-08-27-workflow-terminal-restart-plan.md +3 -3
- package/docs/plans/2026-09-04-workflow-runner-resume-state-plan.md +318 -0
- package/docs/plans/piw-viewer-experience-implementation-plan.md +1 -1
- package/docs/tui-viewer.md +9 -9
- package/docs/workflows.md +78 -63
- package/examples/{controllers/pull-request.controller.ts → resource-managers/pull-request.resource-manager.ts} +12 -12
- package/herdr-plugin.toml +1 -1
- package/package.json +5 -5
- package/protocol/client.v1.schema.json +7 -7
- package/protocol/fixtures/client-v1.json +1 -1
- package/src/builtins/monitor.workflow.ts +9 -9
- package/src/builtins/pi-agent-group.ts +3 -3
- package/src/channels/adapter-entry.ts +14 -14
- package/src/client/client.ts +33 -32
- package/src/client/protocol.ts +16 -11
- package/src/client/resolver.ts +4 -4
- package/src/client/view.ts +9 -1
- package/src/extension/index.ts +81 -53
- package/src/extension/recorder.ts +1 -1
- package/src/extension/remote-recorder-store.ts +2 -2
- package/src/extension/resource-manager-command.ts +45 -0
- package/src/extension/session-delivery.ts +2 -2
- package/src/extension/session-view.ts +1 -1
- package/src/extension/workflow-message-coordinator.ts +94 -30
- package/src/{controllers → resource-managers}/conditions.ts +23 -23
- package/src/resource-managers/definition.ts +71 -0
- package/src/{controllers → resource-managers}/effects.ts +9 -9
- package/src/resource-managers/errors.ts +27 -0
- package/src/resource-managers/index.ts +88 -0
- package/src/resource-managers/loader.ts +111 -0
- package/src/{controllers → resource-managers}/results.ts +4 -4
- package/src/{controllers/manager.ts → resource-managers/runtime.ts} +95 -92
- package/src/{controllers → resource-managers}/sqlite.ts +275 -181
- package/src/{controllers → resource-managers}/store.ts +46 -38
- package/src/{controllers → resource-managers}/types.ts +50 -41
- package/src/{controllers → resource-managers}/workflows.ts +43 -41
- package/src/{host → server}/channel-supervisor.ts +8 -8
- package/src/{host/child-worker-supervisor.ts → server/child-runner-supervisor.ts} +22 -18
- package/src/{host → server}/processes.ts +3 -3
- package/src/{host → server}/resolver-entry.ts +28 -25
- package/src/{host/controller-worker-entry.ts → server/resource-runner-entry.ts} +67 -65
- package/src/server/resource-runner-protocol.ts +103 -0
- package/src/server/resource-runner-supervisor.ts +76 -0
- package/src/{host → server}/rpc-bridge.ts +3 -3
- package/src/{host → server}/rpc-executor.ts +4 -4
- package/src/{host/host-entry.ts → server/server-entry.ts} +5 -5
- package/src/{host/runner.ts → server/server.ts} +786 -672
- package/src/{host → server}/state.ts +78 -67
- package/src/{host → server}/view.ts +21 -17
- package/src/server/workflow-runner-content.ts +119 -0
- package/src/{host/worker-entry.ts → server/workflow-runner-entry.ts} +131 -82
- package/src/server/workflow-runner-protocol.ts +241 -0
- package/src/{host/worker-store.ts → server/workflow-runner-store.ts} +18 -20
- package/src/server/workflow-runner-supervisor.ts +79 -0
- package/src/state/prune.ts +27 -9
- package/src/state/schema.ts +2 -2
- package/src/state/workflow-messages.ts +52 -1
- package/src/viewer/backup.ts +1 -1
- package/src/viewer/cli.ts +50 -36
- package/src/viewer/tui.ts +1 -1
- package/src/workflows/command-batch.ts +2 -2
- package/src/workflows/composition.ts +0 -5
- package/src/workflows/definition.ts +0 -8
- package/src/workflows/engine.ts +18 -21
- package/src/workflows/schema.ts +0 -6
- package/src/workflows/store.ts +95 -28
- package/src/workflows/types.ts +3 -5
- package/dist/controllers/conditions.d.ts +0 -6
- package/dist/controllers/conditions.js.map +0 -1
- package/dist/controllers/definition.d.ts +0 -6
- package/dist/controllers/definition.js +0 -45
- package/dist/controllers/definition.js.map +0 -1
- package/dist/controllers/effects.d.ts +0 -15
- package/dist/controllers/effects.js.map +0 -1
- package/dist/controllers/errors.d.ts +0 -12
- package/dist/controllers/errors.js +0 -25
- package/dist/controllers/errors.js.map +0 -1
- package/dist/controllers/index.d.ts +0 -12
- package/dist/controllers/index.js +0 -12
- package/dist/controllers/index.js.map +0 -1
- package/dist/controllers/json.js.map +0 -1
- package/dist/controllers/loader.d.ts +0 -23
- package/dist/controllers/loader.js +0 -74
- package/dist/controllers/loader.js.map +0 -1
- package/dist/controllers/manager.d.ts +0 -59
- package/dist/controllers/manager.js.map +0 -1
- package/dist/controllers/results.d.ts +0 -5
- package/dist/controllers/results.js.map +0 -1
- package/dist/controllers/sqlite.js.map +0 -1
- package/dist/controllers/workflows.d.ts +0 -34
- package/dist/controllers/workflows.js.map +0 -1
- package/dist/extension/controller-command.js.map +0 -1
- package/dist/host/channel-effects.js.map +0 -1
- package/dist/host/channel-supervisor.js.map +0 -1
- package/dist/host/child-worker-supervisor.js.map +0 -1
- package/dist/host/controller-worker-entry.d.ts +0 -2
- package/dist/host/controller-worker-entry.js.map +0 -1
- package/dist/host/controller-worker-protocol.d.ts +0 -36
- package/dist/host/controller-worker-protocol.js +0 -49
- package/dist/host/controller-worker-protocol.js.map +0 -1
- package/dist/host/controller-worker-supervisor.d.ts +0 -21
- package/dist/host/controller-worker-supervisor.js +0 -54
- package/dist/host/controller-worker-supervisor.js.map +0 -1
- package/dist/host/host-entry.js.map +0 -1
- package/dist/host/processes.js.map +0 -1
- package/dist/host/resolver-entry.js.map +0 -1
- package/dist/host/rpc-bridge.js.map +0 -1
- package/dist/host/rpc-executor.js.map +0 -1
- package/dist/host/runner.js.map +0 -1
- package/dist/host/state.js.map +0 -1
- package/dist/host/view.js.map +0 -1
- package/dist/host/worker-entry.d.ts +0 -10
- package/dist/host/worker-entry.js.map +0 -1
- package/dist/host/worker-protocol.d.ts +0 -31
- package/dist/host/worker-protocol.js +0 -122
- package/dist/host/worker-protocol.js.map +0 -1
- package/dist/host/worker-store.js.map +0 -1
- package/dist/host/worker-supervisor.d.ts +0 -22
- package/dist/host/worker-supervisor.js.map +0 -1
- package/docs/CONTROLLERS.md +0 -217
- package/src/controllers/definition.ts +0 -65
- package/src/controllers/errors.ts +0 -27
- package/src/controllers/index.ts +0 -88
- package/src/controllers/loader.ts +0 -104
- package/src/extension/controller-command.ts +0 -45
- package/src/host/controller-worker-protocol.ts +0 -104
- package/src/host/controller-worker-supervisor.ts +0 -79
- package/src/host/worker-protocol.ts +0 -165
- package/src/host/worker-supervisor.ts +0 -74
- /package/dist/{controllers → resource-managers}/json.d.ts +0 -0
- /package/dist/{controllers → resource-managers}/json.js +0 -0
- /package/dist/{controllers → resource-managers}/results.js +0 -0
- /package/dist/{controllers → resource-managers}/store.js +0 -0
- /package/dist/{controllers → resource-managers}/types.js +0 -0
- /package/dist/{host → server}/channel-effects.d.ts +0 -0
- /package/dist/{host → server}/channel-effects.js +0 -0
- /package/dist/{host/host-entry.d.ts → server/server-entry.d.ts} +0 -0
- /package/src/{controllers → resource-managers}/json.ts +0 -0
- /package/src/{host → server}/channel-effects.ts +0 -0
package/docs/workflows.md
CHANGED
|
@@ -21,7 +21,7 @@ planning workflow that was first released as `autodevise`; the old command and
|
|
|
21
21
|
export are not retained. A project or global file named `monitor.workflow.ts`
|
|
22
22
|
replaces the built-in monitor. Each built-in has a stable reference such as
|
|
23
23
|
`builtin:monitor` and an explicit revision. A resolver child snapshots the
|
|
24
|
-
selected built-in before start, and each run
|
|
24
|
+
selected built-in before start, and each run runner verifies that identity
|
|
25
25
|
before execution. A revision mismatch refuses resume. Project and global
|
|
26
26
|
workflow files also use their absolute path and SHA-256 hash as source
|
|
27
27
|
identity.
|
|
@@ -108,54 +108,60 @@ Function actions receive `WorkflowActionContext`, which adds
|
|
|
108
108
|
|
|
109
109
|
## Durable runs, parking, and resume
|
|
110
110
|
|
|
111
|
-
Every run enters one global SQLite queue. One package-owned
|
|
111
|
+
Every run enters one global SQLite queue. One package-owned server claims runs,
|
|
112
112
|
renews live claims, commits state, and supervises one child process for each
|
|
113
|
-
active run generation. The extension is a local
|
|
113
|
+
active run generation. The extension is a local server client. It does not run
|
|
114
114
|
the workflow engine or workflow definitions.
|
|
115
115
|
|
|
116
|
-
The
|
|
117
|
-
control the same user-level
|
|
116
|
+
The server starts on demand when a Pi or CLI client needs it. These commands
|
|
117
|
+
control the same user-level server for all projects:
|
|
118
118
|
|
|
119
119
|
```bash
|
|
120
|
-
pi-workflows
|
|
121
|
-
pi-workflows
|
|
122
|
-
pi-workflows
|
|
123
|
-
pi-workflows
|
|
120
|
+
pi-workflows server start
|
|
121
|
+
pi-workflows server status
|
|
122
|
+
pi-workflows server stop
|
|
123
|
+
pi-workflows server run
|
|
124
124
|
```
|
|
125
125
|
|
|
126
|
-
`
|
|
126
|
+
`server run` stays attached. The other commands start, inspect, or stop the
|
|
127
127
|
on-demand process. No command installs an operating-system service.
|
|
128
128
|
|
|
129
|
-
The extension, CLI, and `piw` use the same version-1 client protocol over a Unix socket or Windows named pipe. The
|
|
129
|
+
The extension, CLI, and `piw` use the same version-1 client protocol over a Unix socket or Windows named pipe. The server sends byte-bounded run-list and run-view pages. Clients collect a complete run list for one revision and reject stale run pages whose cursor or revision no longer matches. The server reads only the selected history ranges and reuses an unchanged subscribed view after a lightweight revision check. It waits for a slow socket to drain and removes every subscription when its client unsubscribes. Large values stay available through verified content chunks. Server-generated aggregate values are saved and linked to the run before the server advertises them.
|
|
130
130
|
|
|
131
|
-
A
|
|
131
|
+
A runner verifies the root and all mounted source identities before it loads
|
|
132
132
|
workflow modules. It then checks the resolved mounted-source map and executes
|
|
133
|
-
from committed state through a
|
|
133
|
+
from committed state through a server-backed store. Resume and continuation
|
|
134
|
+
reads return only `WorkflowRunState`. Session messages, tool results, activity
|
|
135
|
+
events, viewer history, settings, follow-ups, and other inspection data stay in
|
|
136
|
+
server-owned SQLite. If one required result exceeds the runner protocol frame,
|
|
137
|
+
the server returns a digest-bound reference and the runner reads and verifies it
|
|
138
|
+
in bounded parts. A source mismatch parks the
|
|
134
139
|
run with `workflowSourceChanged`; normal scheduling does not retry it. Restore
|
|
135
140
|
the recorded source and explicitly resume, or cancel the run. A headless Pi
|
|
136
|
-
child uses its own registered process group. The
|
|
137
|
-
normal completion, and the
|
|
138
|
-
|
|
141
|
+
child uses its own registered process group. The runner stops that group on
|
|
142
|
+
normal completion, and the server reaps it if the runner exits first. If the
|
|
143
|
+
runner stops for another recoverable reason, pure work can run again. A
|
|
139
144
|
protected write checks and renews the exact live token and generation in one
|
|
140
145
|
transaction. An expired or replaced owner cannot revive itself.
|
|
141
146
|
|
|
142
147
|
Interactive agent and assistant-message steps do not run headlessly for a Pi
|
|
143
|
-
session. The
|
|
148
|
+
session. The runner commits a durable interaction request and parks. The origin
|
|
144
149
|
session presents the request through documented Pi APIs and submits the exact
|
|
145
|
-
request, node, attempt, and revision. The
|
|
146
|
-
provisional. A new supervised
|
|
147
|
-
function before the
|
|
150
|
+
request, node, attempt, and revision. The server records submitted output as
|
|
151
|
+
provisional. A new supervised runner loads the workflow and runs its `validate`
|
|
152
|
+
function before the server accepts the submission. A validation error leaves the
|
|
148
153
|
same request pending and returns the error to the model. Closing Pi leaves that
|
|
149
154
|
request pending; reopening the same session adopts the existing session entry
|
|
150
155
|
or presents it once. Step prompts, protected decisions, notifications, terminal
|
|
151
|
-
results, and follow-ups use the
|
|
156
|
+
results, and follow-ups use the server-owned `workflow_messages` table and one
|
|
152
157
|
extension sender. Initial, reminder, and resumed prompts are the same step-message
|
|
153
|
-
kind with different display reasons. A terminal workflow message becomes
|
|
154
|
-
the terminal outcome is committed. A
|
|
155
|
-
headless `pi --mode rpc` child
|
|
158
|
+
kind with different display reasons. A terminal workflow message becomes
|
|
159
|
+
eligible only after the terminal outcome is committed. A resource manager child
|
|
160
|
+
without an origin session can use a supervised headless `pi --mode rpc` child
|
|
161
|
+
for structured agent steps.
|
|
156
162
|
|
|
157
|
-
Pause stops the
|
|
158
|
-
new generation. Cancellation can stop a live
|
|
163
|
+
Pause stops the runner and parks at the last durable boundary. Resume takes a
|
|
164
|
+
new generation. Cancellation can stop a live runner or atomically claim and
|
|
159
165
|
cancel an expired running row. Resume refuses changed workflow source.
|
|
160
166
|
|
|
161
167
|
## Node types
|
|
@@ -194,15 +200,15 @@ agent({
|
|
|
194
200
|
because an invalid response is already visible and must not be retried.
|
|
195
201
|
|
|
196
202
|
For submitted output, the engine appends the existing workflow-tool contract.
|
|
197
|
-
The
|
|
198
|
-
submission, and starts a supervised
|
|
203
|
+
The server checks the durable transport identifiers, stores a `validating`
|
|
204
|
+
submission, and starts a supervised runner. In that runner, the output passes
|
|
199
205
|
through tolerant JSON normalization and then `validate`. The tool reports
|
|
200
206
|
success only after this check accepts the output. If the tool turn is aborted,
|
|
201
|
-
the client stops waiting but does not cancel the durable
|
|
207
|
+
the client stops waiting but does not cancel the durable server command. A retry
|
|
202
208
|
uses a new transport request ID with the same durable submission identity and
|
|
203
209
|
adopts the stored result. Rejected submissions return
|
|
204
210
|
the validation error and can retry in the same step. If the model settles
|
|
205
|
-
without submitting, the
|
|
211
|
+
without submitting, the server increments the request's unproductive-turn counter
|
|
206
212
|
and can create at most two step messages with reason `reminder`. The next
|
|
207
213
|
unproductive turn fails the step. The timeout remains active during each
|
|
208
214
|
reported model turn, and cancellation remains active throughout. For assistant-message output, the engine appends a normal-response contract,
|
|
@@ -214,7 +220,7 @@ form's active Pi turn.
|
|
|
214
220
|
node context that returns either value. Omit it to use the 15-minute engine
|
|
215
221
|
default. The limit counts active node execution. For an origin-session agent
|
|
216
222
|
node, it counts reported model-turn time from an active connected Pi session.
|
|
217
|
-
It excludes message delivery, waiting, paused time, disconnects, and
|
|
223
|
+
It excludes message delivery, waiting, paused time, disconnects, and server downtime. Set it to `null` to disable only this deadline; cancellation,
|
|
218
224
|
parking, claim loss, shutdown, and the node's abort signal still work. A timeout
|
|
219
225
|
function can use prepared outputs to select a policy for this run. It has 30
|
|
220
226
|
seconds to return. Computed timeout functions are runtime code, so definition
|
|
@@ -232,7 +238,7 @@ compute({ run: ({ outputs }) => ({ merged: { ...outputs } }) });
|
|
|
232
238
|
|
|
233
239
|
Queues a durable plain-text message for the Pi session that started the run.
|
|
234
240
|
The runner does not write the message into its own conversation. A standalone
|
|
235
|
-
|
|
241
|
+
server can execute this node, and the message still waits for the origin session.
|
|
236
242
|
|
|
237
243
|
```typescript
|
|
238
244
|
notify({
|
|
@@ -245,13 +251,13 @@ The runtime gives each logical execution of a notification node a stable index.
|
|
|
245
251
|
A retry after a crash reuses that index, so it cannot queue the same message
|
|
246
252
|
twice. Re-entering the node later in a loop gets the next index. A workflow
|
|
247
253
|
with a `notify` node must be an interactive queued run with an origin session.
|
|
248
|
-
|
|
249
|
-
|
|
254
|
+
ResourceManager child workflows are detached and must report through their
|
|
255
|
+
managed resource instead.
|
|
250
256
|
|
|
251
257
|
### action
|
|
252
258
|
|
|
253
259
|
Performs managed work. Every function action and shell action must declare how
|
|
254
|
-
the
|
|
260
|
+
the server recovers if the runner exits after the external operation but before
|
|
255
261
|
it saves a receipt.
|
|
256
262
|
|
|
257
263
|
Use `idempotentEffect(type)` only when the operation has a stable external
|
|
@@ -267,8 +273,8 @@ action({
|
|
|
267
273
|
```
|
|
268
274
|
|
|
269
275
|
Use `manualEffect(type)` when the external system cannot prove whether an
|
|
270
|
-
uncertain request applied. An uncertain
|
|
271
|
-
`ambiguous`, parks the run, and requires explicit operator recovery. The
|
|
276
|
+
uncertain request applied. An uncertain runner exit marks that effect
|
|
277
|
+
`ambiguous`, parks the run, and requires explicit operator recovery. The server
|
|
272
278
|
does not retry it automatically.
|
|
273
279
|
|
|
274
280
|
The shell form (`shell` is a synonym that requires `exec`) runs a command owned
|
|
@@ -323,7 +329,10 @@ keeps normal output capture. Lines and update data are each limited to 64 KiB.
|
|
|
323
329
|
See [WORKFLOW_UPDATES.md](WORKFLOW_UPDATES.md) for the envelope, progress
|
|
324
330
|
schema, limits, estimation, and error rules.
|
|
325
331
|
|
|
326
|
-
The
|
|
332
|
+
The server reserves the effect before it lets the action run. The engine creates
|
|
333
|
+
the internal key from the run ID, effect type, full compiled node path, and node
|
|
334
|
+
visit number. Workflow code does not supply that key. Two included workflows
|
|
335
|
+
can use the same local node name without sharing an effect. A repeated key with
|
|
327
336
|
the same request adopts the durable record; the same key with another request
|
|
328
337
|
is a conflict. A normal caught error settles the attempt as rejected. After an
|
|
329
338
|
uncertain process exit, an idempotent effect returns to pending for retry, while
|
|
@@ -379,9 +388,9 @@ humanDecision({
|
|
|
379
388
|
});
|
|
380
389
|
```
|
|
381
390
|
|
|
382
|
-
The waiting run stores a versioned request and asks every channel configured for the logical audience. The structured `subject` remains machine data. Channels receive only the normalized `presentation`, title, choices, input prompts, and any deadline policy. The first valid verified human answer wins. When `onTimeout` is present and no human answer wins before the saved deadline, the
|
|
391
|
+
The waiting run stores a versioned request and asks every channel configured for the logical audience. The structured `subject` remains machine data. Channels receive only the normalized `presentation`, title, choices, input prompts, and any deadline policy. The first valid verified human answer wins. When `onTimeout` is present and no human answer wins before the saved deadline, the server takes a control claim on the waiting parent and atomically applies the validated response with `timeout` provenance, closes the interaction, and reserves the continuation. This policy can continue without a configured channel. A continuation preserves the original workflow input and exposes the resolved response as the checkpoint output. `humanDecisionEdge()` provides exhaustive routing for the choices. The removed `body` request form is invalid under the alpha hard cut.
|
|
383
392
|
|
|
384
|
-
The model-facing workflow tool cannot answer a protected human decision. The origin Pi session displays the request without starting a model turn. A person uses `/workflow answer` to send the answer through the
|
|
393
|
+
The model-facing workflow tool cannot answer a protected human decision. The origin Pi session displays the request without starting a model turn. A person uses `/workflow answer` to send the answer through the server-owned path. Ordinary checkpoints can also use the model-facing `answer` action.
|
|
385
394
|
|
|
386
395
|
See [Human decisions](HUMAN_DECISIONS.md) for channels, recovery, persistence, and plan approval.
|
|
387
396
|
|
|
@@ -487,8 +496,8 @@ A direct user request to continue or resume the active workflow maps to
|
|
|
487
496
|
`resume` immediately. The model does not call `status` instead of `resume` or
|
|
488
497
|
use it as a prerequisite. An already active run adopts the resume request. A
|
|
489
498
|
pending interaction on a paused run remains the same durable request and resumes
|
|
490
|
-
without a
|
|
491
|
-
With no resumable run, the
|
|
499
|
+
without a runner. Other paused or parked work gets a new claim generation and runner.
|
|
500
|
+
With no resumable run, the server rejects the request.
|
|
492
501
|
|
|
493
502
|
The origin Pi session shows its active run in the workflow widget. `Shift+Up`
|
|
494
503
|
and `Shift+Down` scroll it. A sent step message is open only while its
|
|
@@ -500,16 +509,16 @@ pending step messages. A turn that starts while the run is paused does not bind
|
|
|
500
509
|
to the workflow. The paused run does not accept updates, submissions, or
|
|
501
510
|
decision answers until `resume`.
|
|
502
511
|
|
|
503
|
-
`status` reports the durable queue projection. A
|
|
512
|
+
`status` reports the durable queue projection. A server command succeeds only
|
|
504
513
|
after its transaction commits. The protocol stores request fingerprints and
|
|
505
514
|
receipts, so an exact duplicate adopts the committed result and conflicting
|
|
506
515
|
reuse is rejected.
|
|
507
516
|
|
|
508
517
|
The normal extension offers these actions through the origin Pi session. The
|
|
509
|
-
headless RPC bridge offers only `update` and `submit`, so a
|
|
510
|
-
cannot recursively control unrelated runs.
|
|
518
|
+
headless RPC bridge offers only `update` and `submit`, so a resource manager child
|
|
519
|
+
cannot recursively control unrelated runs. ResourceManager code can use its narrow
|
|
511
520
|
`ctx.workflows` methods for child runs, settings, and follow-up records. Those
|
|
512
|
-
methods also commit through the global
|
|
521
|
+
methods also commit through the global server.
|
|
513
522
|
|
|
514
523
|
### Built-in plain summary
|
|
515
524
|
|
|
@@ -663,7 +672,7 @@ The interval uses the existing shell action to launch the current Node
|
|
|
663
672
|
executable with a timer. This works on every platform supported by Pi. The node
|
|
664
673
|
and command timeouts are higher than the maximum interval. Cancelling the
|
|
665
674
|
workflow aborts the timer process immediately. If the owning Pi process or
|
|
666
|
-
standalone
|
|
675
|
+
standalone server stops during the wait, normal parking rules abort the shell node
|
|
667
676
|
and resume later by running that wait again from the beginning.
|
|
668
677
|
|
|
669
678
|
A monitor uses the session's single active workflow slot. It does not provide
|
|
@@ -706,7 +715,7 @@ notification does not start an assistant response. Step prompts, decisions, noti
|
|
|
706
715
|
|
|
707
716
|
Workflow nodes normally produce structured values for routing and persistence.
|
|
708
717
|
When a person must receive normal prose, use an agent node with
|
|
709
|
-
`expectedOutput: assistantMessage()`. The
|
|
718
|
+
`expectedOutput: assistantMessage()`. The runner parks and records the exact
|
|
710
719
|
step request. The origin Pi session starts the model turn, and the visible
|
|
711
720
|
assistant text becomes the node output after the turn settles.
|
|
712
721
|
|
|
@@ -715,7 +724,7 @@ looks for an existing session entry with the durable request ID. It inserts a
|
|
|
715
724
|
new visible message only when no adopted entry exists. A repeated submission
|
|
716
725
|
returns its stored receipt.
|
|
717
726
|
|
|
718
|
-
A headless
|
|
727
|
+
A headless resource manager child cannot produce a visible assistant message without
|
|
719
728
|
an approved origin-session binding. Use structured agent output for detached
|
|
720
729
|
work. A final continuation-chain outcome creates its own terminal workflow message through the shared coordinator only after the outcome is durable.
|
|
721
730
|
|
|
@@ -729,36 +738,42 @@ possible. Defaults worth knowing:
|
|
|
729
738
|
number or context callback. A timed-out node has outcome `timed_out` and can
|
|
730
739
|
be routed with `$result.outcome`. A timed-out agent node also aborts its Pi
|
|
731
740
|
turn, and late output for that attempt is rejected. Interactive runs save the
|
|
732
|
-
resolved deadline before they park. The
|
|
741
|
+
resolved deadline before they park. The server advances it only during a
|
|
733
742
|
reported model turn from an active connected origin session. Message delivery,
|
|
734
|
-
waiting, pauses, disconnects, and
|
|
735
|
-
active-time budget survives
|
|
743
|
+
waiting, pauses, disconnects, and server downtime do not consume the limit. This
|
|
744
|
+
active-time budget survives server restart.
|
|
736
745
|
- `maxSteps` (workflow-level, default 100) bounds loops built from cycles in
|
|
737
746
|
the graph.
|
|
738
747
|
- `/workflow pause` atomically parks the run with `paused: true`, stores the
|
|
739
|
-
receipt, and fences the
|
|
748
|
+
receipt, and fences the runner before process-group shutdown. `/workflow
|
|
740
749
|
resume` takes a new generation and reruns only work after the last durable
|
|
741
750
|
boundary.
|
|
751
|
+
- The server tells each runner to `start`, `resume`, `continue`, or `restart`.
|
|
752
|
+
A checkpoint continuation names its waiting parent. A restart begins at the
|
|
753
|
+
workflow start and does not reuse checkpoint continuation rules.
|
|
742
754
|
- Resuming an active run adopts the existing work. Duplicate start, control,
|
|
743
755
|
update, and submission messages return their stored receipts.
|
|
744
756
|
- A start is committed as `queued` with its final run ID before the command
|
|
745
|
-
reports success. Cancellation can use that run ID before its scheduled
|
|
757
|
+
reports success. Cancellation can use that run ID before its scheduled runner
|
|
746
758
|
starts. Active cancellation commits its terminal state and command receipt
|
|
747
|
-
together before
|
|
759
|
+
together before runner shutdown. It cancels effects that have not started and
|
|
748
760
|
marks applying effects ambiguous for explicit recovery. `workflow status` and
|
|
749
761
|
`workflow cancel` can use the run ID immediately.
|
|
750
762
|
- One interactive workflow request is presented per Pi session. Other requests
|
|
751
763
|
remain durable and ordered.
|
|
752
764
|
- Each protected write renews only its exact live token and generation in the
|
|
753
765
|
same transaction. Claim loss does not write a failed run event.
|
|
754
|
-
- An uncommitted pure or idempotent node can run again after a
|
|
766
|
+
- An uncommitted pure or idempotent node can run again after a runner crash. An
|
|
755
767
|
uncertain manual effect parks as ambiguous and never retries automatically.
|
|
756
|
-
|
|
768
|
+
If a ready runner exits before the saved run revision advances, the server parks
|
|
769
|
+
the run with `runnerNoProgress`. The scheduler does not claim it again until
|
|
770
|
+
an operator explicitly resumes or cancels it.
|
|
771
|
+
- Server status reports safe counts and timestamps. It does not report session
|
|
757
772
|
IDs, project paths, prompts, payloads, tokens, process IDs, or credentials.
|
|
758
773
|
|
|
759
|
-
## Workflows started by
|
|
774
|
+
## Workflows started by resource managers
|
|
760
775
|
|
|
761
|
-
A
|
|
776
|
+
A resource manager can start a workflow as a finite child job with `ctx.workflows.ensure()`. The request key is stable across reconciliation passes, and the input fingerprint prevents one key from being reused for different work.
|
|
762
777
|
|
|
763
778
|
```typescript
|
|
764
779
|
const run = await ctx.workflows.ensure({
|
|
@@ -779,16 +794,16 @@ if (run.state !== "succeeded") {
|
|
|
779
794
|
}
|
|
780
795
|
```
|
|
781
796
|
|
|
782
|
-
Child workflow completion queues the parent resource again. The global
|
|
797
|
+
Child workflow completion queues the parent resource again. The global server runs the child through the same queue and supervised runner model as any other run. A server or runner crash resumes the existing durable run when its committed effect state makes that safe. Consequential external mutations belong in the workflow or resource manager effect API; an uncertain result stops for explicit recovery.
|
|
783
798
|
|
|
784
|
-
See [
|
|
799
|
+
See [RESOURCE_MANAGERS.md](RESOURCE_MANAGERS.md) for resource manager definitions and the full recovery contract.
|
|
785
800
|
|
|
786
801
|
## Using the engine outside Pi
|
|
787
802
|
|
|
788
803
|
The engine remains Pi-agnostic. `WorkflowEngine` takes any `AgentStepExecutor`,
|
|
789
804
|
so tests and custom library integrations can script agent steps. The package's
|
|
790
805
|
production extension does not use this as a selectable embedded runtime; it
|
|
791
|
-
always sends runs to the global
|
|
806
|
+
always sends runs to the global server.
|
|
792
807
|
|
|
793
808
|
```typescript
|
|
794
809
|
import { WorkflowEngine, type AgentStepExecutor } from "@osolmaz/pi-workflows";
|
|
@@ -813,7 +828,7 @@ const { state } = await engine.run(workflow, { task: "..." });
|
|
|
813
828
|
The installed-package end-to-end test packs this repository and installs the
|
|
814
829
|
archive with production dependencies in a temporary consumer project. It then
|
|
815
830
|
starts the repository-pinned base Pi with only that Pi Workflows installation.
|
|
816
|
-
The test checks command isolation,
|
|
831
|
+
The test checks command isolation, server startup, widget and status changes,
|
|
817
832
|
pause, resume, completion, and `piw <runId> --once` output.
|
|
818
833
|
|
|
819
834
|
Run the deterministic phase without a model call:
|
|
@@ -2,9 +2,9 @@ import {
|
|
|
2
2
|
conditionFalse,
|
|
3
3
|
conditionTrue,
|
|
4
4
|
conditionUnknown,
|
|
5
|
-
|
|
5
|
+
defineResourceManager,
|
|
6
6
|
type ChildWorkflowRecord,
|
|
7
|
-
} from "@osolmaz/pi-workflows/
|
|
7
|
+
} from "@osolmaz/pi-workflows/resource-managers";
|
|
8
8
|
|
|
9
9
|
type PullRequestSpec = {
|
|
10
10
|
apiBaseUrl: string;
|
|
@@ -30,7 +30,7 @@ type CommitStatus = {
|
|
|
30
30
|
state: "error" | "failure" | "pending" | "success";
|
|
31
31
|
};
|
|
32
32
|
|
|
33
|
-
export default
|
|
33
|
+
export default defineResourceManager<PullRequestSpec, PullRequestStatus>({
|
|
34
34
|
name: "pull-request",
|
|
35
35
|
initialStatus: () => ({ phase: "observing" }),
|
|
36
36
|
|
|
@@ -41,14 +41,14 @@ export default defineController<PullRequestSpec, PullRequestStatus>({
|
|
|
41
41
|
|
|
42
42
|
if (pullRequest.merged) {
|
|
43
43
|
return ctx.settled({
|
|
44
|
-
|
|
44
|
+
resourceManagerStatus: { phase: "merged", ...observed },
|
|
45
45
|
conditions: [conditionTrue("Ready", "Merged")],
|
|
46
46
|
workflowRun: null,
|
|
47
47
|
});
|
|
48
48
|
}
|
|
49
49
|
if (pullRequest.head.sha !== resource.spec.expectedHeadSha) {
|
|
50
50
|
return ctx.settled({
|
|
51
|
-
|
|
51
|
+
resourceManagerStatus: { phase: "blocked", ...observed },
|
|
52
52
|
conditions: [conditionFalse("Ready", "HeadChanged")],
|
|
53
53
|
});
|
|
54
54
|
}
|
|
@@ -65,14 +65,14 @@ export default defineController<PullRequestSpec, PullRequestStatus>({
|
|
|
65
65
|
const workflowRun = workflowReference(child);
|
|
66
66
|
if (child.state === "failed") {
|
|
67
67
|
return ctx.settled({
|
|
68
|
-
|
|
68
|
+
resourceManagerStatus: { phase: "blocked", ...observed },
|
|
69
69
|
conditions: [conditionFalse("Ready", "RepairFailed", child.error)],
|
|
70
70
|
workflowRun,
|
|
71
71
|
});
|
|
72
72
|
}
|
|
73
73
|
if (child.state !== "succeeded") {
|
|
74
74
|
return ctx.requeueAfter(5_000, {
|
|
75
|
-
|
|
75
|
+
resourceManagerStatus: { phase: "repairing", ...observed },
|
|
76
76
|
conditions: [conditionUnknown("Ready", "RepairRunning")],
|
|
77
77
|
workflowRun,
|
|
78
78
|
});
|
|
@@ -81,14 +81,14 @@ export default defineController<PullRequestSpec, PullRequestStatus>({
|
|
|
81
81
|
const checks = await client.commitStatus(pullRequest.head.sha, ctx.signal);
|
|
82
82
|
if (checks.state !== "success") {
|
|
83
83
|
return ctx.requeueAfter(30_000, {
|
|
84
|
-
|
|
84
|
+
resourceManagerStatus: { phase: "waiting", ...observed },
|
|
85
85
|
conditions: [conditionUnknown("Ready", "ChecksPending", checks.state)],
|
|
86
86
|
workflowRun,
|
|
87
87
|
});
|
|
88
88
|
}
|
|
89
89
|
if (!resource.spec.mergeApproved) {
|
|
90
90
|
return ctx.settled({
|
|
91
|
-
|
|
91
|
+
resourceManagerStatus: { phase: "ready", ...observed },
|
|
92
92
|
conditions: [conditionFalse("Ready", "ApprovalRequired")],
|
|
93
93
|
workflowRun,
|
|
94
94
|
});
|
|
@@ -116,20 +116,20 @@ export default defineController<PullRequestSpec, PullRequestStatus>({
|
|
|
116
116
|
});
|
|
117
117
|
if (effect.state === "rejected") {
|
|
118
118
|
return ctx.settled({
|
|
119
|
-
|
|
119
|
+
resourceManagerStatus: { phase: "blocked", ...observed },
|
|
120
120
|
conditions: [conditionFalse("Ready", "MergeRejected", effect.error)],
|
|
121
121
|
workflowRun,
|
|
122
122
|
});
|
|
123
123
|
}
|
|
124
124
|
if (effect.state === "indeterminate") {
|
|
125
125
|
return ctx.requeueAfter(10_000, {
|
|
126
|
-
|
|
126
|
+
resourceManagerStatus: { phase: "waiting", ...observed },
|
|
127
127
|
conditions: [conditionUnknown("Ready", "MergeUncertain", effect.error)],
|
|
128
128
|
workflowRun,
|
|
129
129
|
});
|
|
130
130
|
}
|
|
131
131
|
return ctx.requeue({
|
|
132
|
-
|
|
132
|
+
resourceManagerStatus: { phase: "waiting", ...observed },
|
|
133
133
|
conditions: [conditionUnknown("Ready", "MergeSubmitted")],
|
|
134
134
|
workflowRun,
|
|
135
135
|
});
|
package/herdr-plugin.toml
CHANGED
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@osolmaz/pi-workflows",
|
|
3
|
-
"version": "0.16.
|
|
4
|
-
"description": "Workflow and
|
|
3
|
+
"version": "0.16.3",
|
|
4
|
+
"description": "Workflow and resource manager runtime with a live terminal viewer for the pi coding agent",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"pi-package"
|
|
7
7
|
],
|
|
@@ -44,9 +44,9 @@
|
|
|
44
44
|
"types": "./dist/client/index.d.ts",
|
|
45
45
|
"default": "./dist/client/index.js"
|
|
46
46
|
},
|
|
47
|
-
"./
|
|
48
|
-
"types": "./dist/
|
|
49
|
-
"default": "./dist/
|
|
47
|
+
"./resource-managers": {
|
|
48
|
+
"types": "./dist/resource-managers/index.d.ts",
|
|
49
|
+
"default": "./dist/resource-managers/index.js"
|
|
50
50
|
},
|
|
51
51
|
"./builtins": {
|
|
52
52
|
"types": "./dist/builtins/index.d.ts",
|
|
@@ -47,13 +47,13 @@
|
|
|
47
47
|
"notification.deliver",
|
|
48
48
|
"turn.claim",
|
|
49
49
|
"turn.resolve",
|
|
50
|
-
"
|
|
51
|
-
"
|
|
52
|
-
"
|
|
53
|
-
"
|
|
54
|
-
"
|
|
55
|
-
"
|
|
56
|
-
"
|
|
50
|
+
"resourceManager.list",
|
|
51
|
+
"resourceManager.get",
|
|
52
|
+
"resourceManager.apply",
|
|
53
|
+
"resourceManager.reconcile",
|
|
54
|
+
"resourceManager.delete",
|
|
55
|
+
"server.status",
|
|
56
|
+
"server.stop",
|
|
57
57
|
"view.runs.watch",
|
|
58
58
|
"view.runs.page",
|
|
59
59
|
"view.run.get",
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"valid": [
|
|
3
3
|
"{\"connectionId\":\"connection-1\",\"packageVersion\":\"0.15.3\",\"schema\":\"pi-workflows.client.v1\",\"type\":\"hello\"}",
|
|
4
|
-
"{\"clientId\":\"client-1\",\"idempotencyKey\":\"key-1\",\"operation\":\"
|
|
4
|
+
"{\"clientId\":\"client-1\",\"idempotencyKey\":\"key-1\",\"operation\":\"server.status\",\"payload\":{},\"requestId\":\"request-1\",\"schema\":\"pi-workflows.client.v1\",\"type\":\"request\"}",
|
|
5
5
|
"{\"clientId\":\"client-1\",\"idempotencyKey\":\"key-runs-page\",\"operation\":\"view.runs.page\",\"payload\":{\"cursor\":2,\"revision\":\"3:10:20\"},\"requestId\":\"request-runs-page\",\"schema\":\"pi-workflows.client.v1\",\"type\":\"request\"}",
|
|
6
6
|
"{\"clientId\":\"client-1\",\"idempotencyKey\":\"key-run-get\",\"operation\":\"view.run.get\",\"payload\":{},\"requestId\":\"request-run-get\",\"runId\":\"run-1\",\"schema\":\"pi-workflows.client.v1\",\"type\":\"request\"}",
|
|
7
7
|
"{\"clientId\":\"client-1\",\"expectedRevision\":7,\"idempotencyKey\":\"key-page\",\"operation\":\"view.page\",\"payload\":{\"cursor\":299,\"kind\":\"steps\"},\"requestId\":\"request-page\",\"runId\":\"run-1\",\"schema\":\"pi-workflows.client.v1\",\"type\":\"request\"}",
|
|
@@ -83,7 +83,7 @@ type MonitorCostSafety = {
|
|
|
83
83
|
};
|
|
84
84
|
type MonitorDefectSafety = {
|
|
85
85
|
sharedCodeOrDataDefect: boolean;
|
|
86
|
-
|
|
86
|
+
paidRunners: "not-applicable" | "stopped" | "running";
|
|
87
87
|
evidence: string;
|
|
88
88
|
};
|
|
89
89
|
type MonitorActionRequest = {
|
|
@@ -308,20 +308,20 @@ function parseCostSafety(input: unknown): MonitorCostSafety {
|
|
|
308
308
|
|
|
309
309
|
function parseDefectSafety(input: unknown): MonitorDefectSafety {
|
|
310
310
|
const value = requireRecord(input, "action defect");
|
|
311
|
-
requireExactKeys(value, ["sharedCodeOrDataDefect", "
|
|
311
|
+
requireExactKeys(value, ["sharedCodeOrDataDefect", "paidRunners", "evidence"], "action defect");
|
|
312
312
|
if (typeof value.sharedCodeOrDataDefect !== "boolean") {
|
|
313
313
|
throw new Error("action defect sharedCodeOrDataDefect must be boolean");
|
|
314
314
|
}
|
|
315
315
|
if (
|
|
316
|
-
value.
|
|
317
|
-
value.
|
|
318
|
-
value.
|
|
316
|
+
value.paidRunners !== "not-applicable" &&
|
|
317
|
+
value.paidRunners !== "stopped" &&
|
|
318
|
+
value.paidRunners !== "running"
|
|
319
319
|
) {
|
|
320
|
-
throw new Error("action defect
|
|
320
|
+
throw new Error("action defect paidRunners is invalid");
|
|
321
321
|
}
|
|
322
322
|
return {
|
|
323
323
|
sharedCodeOrDataDefect: value.sharedCodeOrDataDefect,
|
|
324
|
-
|
|
324
|
+
paidRunners: value.paidRunners,
|
|
325
325
|
evidence: requireBoundedString(value.evidence, "action defect evidence", MAX_ACTION_TEXT_CHARS),
|
|
326
326
|
};
|
|
327
327
|
}
|
|
@@ -396,7 +396,7 @@ function parseActionRequest(input: unknown): MonitorActionRequest {
|
|
|
396
396
|
if (
|
|
397
397
|
request.kind === "repair" &&
|
|
398
398
|
request.defect.sharedCodeOrDataDefect &&
|
|
399
|
-
request.defect.
|
|
399
|
+
request.defect.paidRunners === "running"
|
|
400
400
|
) {
|
|
401
401
|
throw new Error("paid workers must stop before a shared code or data repair");
|
|
402
402
|
}
|
|
@@ -850,7 +850,7 @@ const monitorWorkflow: WorkflowDefinition = defineWorkflow({
|
|
|
850
850
|
].join("\n\n");
|
|
851
851
|
},
|
|
852
852
|
expectedOutput:
|
|
853
|
-
'{ "route": "wait" | "act" | "stop", "goalState": "complete" | "incomplete" | "blocked", "workState": "running" | "waiting" | "idle" | "failed" | "stopped" | "unknown", "observation": "factual state", "report": "concise factual summary", "targetStateId": "stable observed target-state ID", "authorizedActions": ["safe action already authorized by the user"], "progress": { "tracks": [{ "key": "stable-key", "data": { "schema": "pi-workflows.progress.v1", "status": "running", "completed": 1, "total": 2, "unit": "items" } }] } (optional), "action": { "kind": "advance" | "recover" | "repair", "incomplete": "what remains", "evidence": {}, "nextAction": "one exact action", "authority": { "status": "authorized", "basis": "existing authority", "allowedMutations": ["allowed file, system, or resource"], "forbiddenMutations": [], "costLimit": "recorded limit or not applicable", "providerRuntime": "recorded contract or not applicable", "requiredChecks": [], "stopConditions": [], "allowedRecoveryActions": [], "repository": "optional absolute path", "baseBranch": "optional branch", "merge": false, "repairApproval": { "mode": "auto" | "required" | "skip" } }, "cost": { "paidAction": false, "status": "not-applicable" | "within-limit", "evidence": "cost evidence" }, "defect": { "sharedCodeOrDataDefect": false, "
|
|
853
|
+
'{ "route": "wait" | "act" | "stop", "goalState": "complete" | "incomplete" | "blocked", "workState": "running" | "waiting" | "idle" | "failed" | "stopped" | "unknown", "observation": "factual state", "report": "concise factual summary", "targetStateId": "stable observed target-state ID", "authorizedActions": ["safe action already authorized by the user"], "progress": { "tracks": [{ "key": "stable-key", "data": { "schema": "pi-workflows.progress.v1", "status": "running", "completed": 1, "total": 2, "unit": "items" } }] } (optional), "action": { "kind": "advance" | "recover" | "repair", "incomplete": "what remains", "evidence": {}, "nextAction": "one exact action", "authority": { "status": "authorized", "basis": "existing authority", "allowedMutations": ["allowed file, system, or resource"], "forbiddenMutations": [], "costLimit": "recorded limit or not applicable", "providerRuntime": "recorded contract or not applicable", "requiredChecks": [], "stopConditions": [], "allowedRecoveryActions": [], "repository": "optional absolute path", "baseBranch": "optional branch", "merge": false, "repairApproval": { "mode": "auto" | "required" | "skip" } }, "cost": { "paidAction": false, "status": "not-applicable" | "within-limit", "evidence": "cost evidence" }, "defect": { "sharedCodeOrDataDefect": false, "paidRunners": "not-applicable" | "stopped" | "running", "evidence": "worker evidence" }, "verification": "how to prove success", "failureId": "stable failure ID", "targetStateId": "stable target-state ID" } (required only for act), "reason": "short reason" }',
|
|
854
854
|
validate: validateMonitorObservation,
|
|
855
855
|
}),
|
|
856
856
|
guard: compute({ run: guardObservation }),
|
|
@@ -33,7 +33,7 @@ const BUILTIN_TOOLS = new Set(["read", "grep", "find", "ls"]);
|
|
|
33
33
|
const RESERVED_EXTENSION_NAMES = new Set([
|
|
34
34
|
"workflow",
|
|
35
35
|
"piw",
|
|
36
|
-
"
|
|
36
|
+
"resource-manager",
|
|
37
37
|
"workflow-update",
|
|
38
38
|
"workflow-answer",
|
|
39
39
|
"workflow-submit",
|
|
@@ -162,8 +162,8 @@ export async function runPiAgentGroup(
|
|
|
162
162
|
}
|
|
163
163
|
};
|
|
164
164
|
|
|
165
|
-
const
|
|
166
|
-
await Promise.all(Array.from({ length:
|
|
165
|
+
const runnerCount = Math.min(options.maxConcurrency, requests.length);
|
|
166
|
+
await Promise.all(Array.from({ length: runnerCount }, worker));
|
|
167
167
|
|
|
168
168
|
if (options.signal.aborted) throw cancellationError("group", options.signal.reason);
|
|
169
169
|
if (primary !== undefined) {
|