@wichayutdew/pi-workflows 0.3.0 → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +53 -39
- package/dist/index.js +5754 -4794
- package/package.json +1 -1
- package/src/command-names.ts +7 -1
- package/src/commands.ts +126 -52
- package/src/config/catalog.ts +162 -0
- package/src/config/ceiling.ts +116 -116
- package/src/config/command-conflicts.ts +4 -4
- package/src/config/diagnostics.ts +28 -0
- package/src/config/load-settings.ts +37 -0
- package/src/config/load-types.ts +53 -0
- package/src/config/load-workflows.ts +135 -0
- package/src/config/load.ts +43 -311
- package/src/config/types.ts +137 -135
- package/src/config/validate.ts +12 -1261
- package/src/config/validation/permissions.ts +291 -0
- package/src/config/validation/prompt.ts +19 -0
- package/src/config/validation/settings.ts +122 -0
- package/src/config/validation/shared.ts +129 -0
- package/src/config/validation/shortcut.ts +118 -0
- package/src/config/validation/step.ts +228 -0
- package/src/config/validation/subagent.ts +288 -0
- package/src/config/validation/workflow.ts +156 -0
- package/src/config/yaml.ts +29 -0
- package/src/digest.ts +38 -6
- package/src/engine/checkpoint.ts +13 -9
- package/src/engine/create-run.ts +42 -0
- package/src/engine/gate-transitions.ts +184 -0
- package/src/engine/reconciliation-history.ts +88 -0
- package/src/engine/resume.ts +19 -7
- package/src/engine/run-advance.ts +122 -0
- package/src/engine/run-lifecycle.ts +124 -0
- package/src/engine/run-reconciliation.ts +116 -0
- package/src/engine/run-validation.ts +128 -0
- package/src/engine/state-types.ts +64 -0
- package/src/engine/state.ts +10 -193
- package/src/engine/transition-helpers.ts +28 -0
- package/src/engine/transition-types.ts +8 -0
- package/src/engine/transitions.ts +17 -471
- package/src/harness/action-context.ts +181 -0
- package/src/harness/catalog.ts +45 -0
- package/src/harness/context-idle.ts +21 -0
- package/src/harness/core-actions.ts +299 -0
- package/src/harness/delegation-control-actions.ts +250 -0
- package/src/harness/delegation-failure.ts +215 -0
- package/src/harness/delegation-plan.ts +219 -0
- package/src/harness/delegation-recovery-validation.ts +159 -0
- package/src/harness/delegation-response-actions.ts +295 -0
- package/src/harness/delegation-retry-policy.ts +118 -0
- package/src/harness/dependencies.ts +165 -0
- package/src/harness/gate-submission-action.ts +154 -0
- package/src/harness/lifecycle-actions.ts +154 -0
- package/src/harness/pause-actions.ts +120 -0
- package/src/harness/plannotator-result-actions.ts +123 -0
- package/src/harness/prompt-gate-actions.ts +270 -0
- package/src/harness/resume-action.ts +261 -0
- package/src/harness/start-actions.ts +183 -0
- package/src/harness/status-actions.ts +191 -0
- package/src/harness/step-execution-actions.ts +283 -0
- package/src/harness/types.ts +76 -0
- package/src/harness.ts +236 -2303
- package/src/index.ts +73 -11
- package/src/integrations/plannotator-requests.ts +127 -0
- package/src/integrations/plannotator-responses.ts +141 -0
- package/src/integrations/plannotator-types.ts +44 -0
- package/src/integrations/plannotator.ts +16 -235
- package/src/integrations/prompt-gate.ts +17 -10
- package/src/integrations/subagents/child-policy-envelope.ts +119 -0
- package/src/integrations/subagents/child-policy-paths.ts +66 -0
- package/src/integrations/subagents/child-policy-sections.ts +174 -0
- package/src/integrations/subagents/child-policy-types.ts +32 -0
- package/src/integrations/subagents/child-policy-validation.ts +163 -0
- package/src/integrations/subagents/child-runtime-completion.ts +56 -0
- package/src/integrations/subagents/child-runtime-dependencies.ts +47 -0
- package/src/integrations/subagents/child-runtime-files.ts +156 -0
- package/src/integrations/subagents/child-runtime-policy.ts +83 -0
- package/src/integrations/subagents/child-runtime-types.ts +30 -0
- package/src/integrations/subagents/child-runtime.ts +140 -301
- package/src/integrations/subagents/client-delegation.ts +181 -0
- package/src/integrations/subagents/client-messages.ts +66 -0
- package/src/integrations/subagents/client-types.ts +36 -0
- package/src/integrations/subagents/client.ts +127 -219
- package/src/integrations/subagents/delegated-result.ts +31 -0
- package/src/integrations/subagents/diagnostic-format.ts +40 -0
- package/src/integrations/subagents/diagnostic-text.ts +114 -0
- package/src/integrations/subagents/diagnostic-types.ts +77 -0
- package/src/integrations/subagents/diagnostics.ts +24 -977
- package/src/integrations/subagents/failure-correlation.ts +235 -0
- package/src/integrations/subagents/failure-transcript.ts +192 -0
- package/src/integrations/subagents/hidden-bash-failure.ts +98 -0
- package/src/integrations/subagents/protocol-events.ts +27 -0
- package/src/integrations/subagents/protocol.ts +30 -375
- package/src/integrations/subagents/replay-audit.ts +147 -0
- package/src/integrations/subagents/replay-safety.ts +82 -0
- package/src/integrations/subagents/session-diagnostics.ts +258 -0
- package/src/policy/approved-command-extraction.ts +71 -0
- package/src/policy/approved-commands.ts +15 -432
- package/src/policy/bash-authorization.ts +86 -0
- package/src/policy/bash-read-only.ts +161 -0
- package/src/policy/bash-types.ts +20 -0
- package/src/policy/bash.ts +4 -346
- package/src/policy/completion-batch.ts +21 -16
- package/src/policy/immutable-input.ts +5 -2
- package/src/policy/mcp-authorization.ts +71 -0
- package/src/policy/restricted-command.ts +141 -0
- package/src/policy/restricted-git.ts +30 -0
- package/src/policy/reviewed-artifact.ts +97 -0
- package/src/policy/reviewed-command-safety.ts +150 -0
- package/src/policy/reviewed-command-shape.ts +49 -0
- package/src/policy/reviewed-repository-contract.ts +138 -0
- package/src/policy/reviewed-repository-cwd.ts +102 -0
- package/src/policy/tool-call-authorization.ts +58 -0
- package/src/policy/tool-selection.ts +72 -0
- package/src/policy/tool-types.ts +14 -0
- package/src/policy/tools.ts +11 -150
- package/src/preflight.ts +96 -61
- package/src/prompt/main-workflow-notice.ts +41 -0
- package/src/prompt/retry-task.ts +83 -0
- package/src/prompt/step-contract.ts +101 -0
- package/src/prompt/step-sections.ts +75 -0
- package/src/prompt/step-task.ts +156 -0
- package/src/prompt/template.ts +81 -0
- package/src/prompt.ts +10 -254
- package/src/runtime/completion-tool.ts +3 -0
- package/src/runtime/main-step-completion.ts +78 -0
- package/src/runtime/main-step-lifecycle.ts +37 -0
- package/src/runtime/main-step-policy.ts +84 -0
- package/src/runtime/main-step-runtime-types.ts +64 -0
- package/src/runtime/main-step-runtime.ts +129 -200
- package/src/runtime/main-step-state.ts +85 -0
- package/src/runtime/serial-task-queue.ts +48 -13
- package/src/runtime/step-result.ts +48 -27
- package/src/workflow-list.ts +15 -6
- package/src/workflow-status/format-status.ts +52 -0
- package/src/workflow-status/formatting.ts +178 -0
- package/src/workflow-status/layout.ts +109 -0
- package/src/workflow-status/render-board.ts +101 -0
- package/src/workflow-status/render-path.ts +123 -0
- package/src/workflow-status/render-summary.ts +144 -0
- package/src/workflow-status/types.ts +40 -0
- package/src/workflow-status/view.ts +273 -0
- package/src/workflow-status.ts +20 -820
package/README.md
CHANGED
|
@@ -248,16 +248,16 @@ configured in `~/.pi/agent/workflows/settings.yaml`.
|
|
|
248
248
|
|
|
249
249
|
Supported fields:
|
|
250
250
|
|
|
251
|
-
| Field | Default | Description
|
|
252
|
-
| ------------------- | --------------------- |
|
|
253
|
-
| `agent` | `pi-workflows.step` | Actual Pi Subagents profile, such as `scout`, `planner`, `worker`, or `reviewer`.
|
|
254
|
-
| `context` | `fresh` | Always isolated; parent and sibling transcripts are never inherited.
|
|
255
|
-
| `model` | Profile/default model | Optional pi-subagents model override for the selected profile.
|
|
256
|
-
| `timeoutMs` | `900000` | Child deadline, from 1 second through 24 hours.
|
|
257
|
-
| `turnBudget` | pi-subagents default | `{ "maxTurns": n, "graceTurns": n }`.
|
|
258
|
-
| `toolBudget` | pi-subagents default | `{ "soft": n, "hard": n, "block": "*" }`; `block` may instead be a tool-name array.
|
|
259
|
-
| `artifacts` | `false` | Ask pi-subagents to retain its normal run artifacts.
|
|
260
|
-
| `retryToolFailures` | `false` | Authorize
|
|
251
|
+
| Field | Default | Description |
|
|
252
|
+
| ------------------- | --------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
253
|
+
| `agent` | `pi-workflows.step` | Actual Pi Subagents profile, such as `scout`, `planner`, `worker`, or `reviewer`. |
|
|
254
|
+
| `context` | `fresh` | Always isolated; parent and sibling transcripts are never inherited. |
|
|
255
|
+
| `model` | Profile/default model | Optional pi-subagents model override for the selected profile. |
|
|
256
|
+
| `timeoutMs` | `900000` | Child deadline, from 1 second through 24 hours. |
|
|
257
|
+
| `turnBudget` | pi-subagents default | `{ "maxTurns": n, "graceTurns": n }`. |
|
|
258
|
+
| `toolBudget` | pi-subagents default | `{ "soft": n, "hard": n, "block": "*" }`; `block` may instead be a tool-name array. |
|
|
259
|
+
| `artifacts` | `false` | Ask pi-subagents to retain its normal run artifacts. |
|
|
260
|
+
| `retryToolFailures` | `false` | Authorize the bounded automatic recovery sequence in allow-list or unrestricted Bash mode; every failed attempt still needs a complete audit proving that its actual calls were mutation-safe. |
|
|
261
261
|
|
|
262
262
|
Pi Workflows installs an inert listener in every Pi Subagents child and
|
|
263
263
|
activates policy only after a valid, single-use workflow capability arrives, so
|
|
@@ -590,16 +590,17 @@ blocked. Wait for the terminal event; if the delegation channel has already
|
|
|
590
590
|
failed, restart Pi before resuming. This prevents an old writer and a resumed
|
|
591
591
|
writer from overlapping.
|
|
592
592
|
|
|
593
|
-
When a delegated child returns `failed
|
|
594
|
-
|
|
595
|
-
session before deciding whether to launch
|
|
596
|
-
audit accepts only regular, non-symlink session
|
|
597
|
-
parent session's child-run root, requires the
|
|
598
|
-
its per-request binding to match the active
|
|
599
|
-
tail, and proves that every recorded call
|
|
600
|
-
step's actual Bash policy before execution.
|
|
601
|
-
evaluated with the same authorization inputs
|
|
602
|
-
attempt is also replay-safe when the complete
|
|
593
|
+
When a delegated child returns `failed`, `structured_output_failed`,
|
|
594
|
+
`timed_out`, `turn_budget_exhausted`, or `tool_budget_exhausted`, the harness
|
|
595
|
+
audits the retained Pi child session before deciding whether to launch a fresh
|
|
596
|
+
automatic recovery child. The audit accepts only regular, non-symlink session
|
|
597
|
+
files contained by the current parent session's child-run root, requires the
|
|
598
|
+
persisted policy-stripped task and its per-request binding to match the active
|
|
599
|
+
delegation, reads a bounded complete tail, and proves that every recorded call
|
|
600
|
+
was read-only or rejected by that step's actual Bash policy before execution.
|
|
601
|
+
Approved exact Bash commands are evaluated with the same authorization inputs
|
|
602
|
+
used by the child. A zero-tool attempt is also replay-safe when the complete
|
|
603
|
+
bound transcript proves it.
|
|
603
604
|
|
|
604
605
|
When the terminal error identifies a failed tool, the harness also records the
|
|
605
606
|
exact correlated call, tool error, subagent exit code, terminal error, and
|
|
@@ -611,14 +612,26 @@ correlated result validates. This accepts the same finalized child result; it
|
|
|
611
612
|
never replays mutation-capable work.
|
|
612
613
|
|
|
613
614
|
Without a valid finalized result, the next fresh child receives the bounded
|
|
614
|
-
terminal evidence in an escaped JSON data boundary and is
|
|
615
|
-
current state, change its approach, resolve the cause, and
|
|
616
|
-
step.
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
615
|
+
history of distinct terminal evidence in an escaped JSON data boundary and is
|
|
616
|
+
told to inspect current state, change its approach, resolve the cause, and
|
|
617
|
+
finish the original step. The harness launches at most two automatic recovery
|
|
618
|
+
children and stops early when the semantic failure fingerprint repeats.
|
|
619
|
+
Availability of `edit` or `write` is not itself a veto: the complete audit must
|
|
620
|
+
prove that the failed attempt did not actually make or attempt a mutation.
|
|
621
|
+
Mutation-capable or unknown-effect calls, reported file mutation, a truncated or
|
|
622
|
+
malformed transcript, a missing active-request binding, cancellation,
|
|
623
|
+
interruption, detached or stopped execution, and protocol/configuration errors
|
|
624
|
+
remain hard stops. Local channel failures also wait for confirmed child
|
|
620
625
|
termination instead of risking two live children.
|
|
621
626
|
|
|
627
|
+
Temporary delegation-workspace removal is best-effort housekeeping. A cleanup
|
|
628
|
+
error produces a warning but cannot pause an otherwise healthy next step or
|
|
629
|
+
recovery child. Synchronous startup exceptions are contained by the serialized
|
|
630
|
+
failure path. Each recovery uses a new request identity, private result
|
|
631
|
+
capability, and fresh context. The fixed two-attempt bound means a failing step
|
|
632
|
+
can consume at most three times its per-child timeout, turn budget, and tool
|
|
633
|
+
budget.
|
|
634
|
+
|
|
622
635
|
Inside a live child, recovery is not tied to a list of known error strings. The
|
|
623
636
|
completion contract requires the agent to inspect the exact error and current
|
|
624
637
|
state, try a permitted semantically equivalent alternative, and continue the
|
|
@@ -806,8 +819,9 @@ ceilings, deterministic transitions, configuration reconciliation, pause/resume
|
|
|
806
819
|
state, gate handling, MCP isolation, Bash policy, extension tool selection,
|
|
807
820
|
main-agent completion, built-in feedback/approval, subagent request correlation
|
|
808
821
|
and cancellation, child policy enforcement, and dependency preflight,
|
|
809
|
-
including
|
|
810
|
-
|
|
822
|
+
including bounded automatic recovery after replay-safe terminal errors,
|
|
823
|
+
timeouts, budget exhaustion, and nonzero exits; duplicate-failure stopping;
|
|
824
|
+
reviewed exact-command propagation; and fail-closed legacy checkpoints.
|
|
811
825
|
`bun run check` also launches real Pi RPC subprocesses, invokes
|
|
812
826
|
`/work`, and verifies fresh `scout`, `worker`, and `reviewer` children receive
|
|
813
827
|
only the explicit compact handoff from the immediately preceding step.
|
|
@@ -827,17 +841,17 @@ The `pi-package` keyword makes the package discoverable by the Pi package galler
|
|
|
827
841
|
The current schema covers the execution harness requested here. Useful future
|
|
828
842
|
extensions, without hard-coding them into the orchestrator, are:
|
|
829
843
|
|
|
830
|
-
| Parameter | Why it belongs in configuration
|
|
831
|
-
| --------------------------------- |
|
|
832
|
-
| Configurable
|
|
833
|
-
| Acceptance criteria | Give each step machine-checkable completion evidence and verification commands.
|
|
834
|
-
| Working directory or worktree | Isolate mutating steps, monorepo packages, and concurrent branches.
|
|
835
|
-
| Parallel groups and join policy | Run independent steps together and declare fail-fast, quorum, or all-success behavior.
|
|
836
|
-
| Generic gates | Add ticket, CI, chat, or custom approval providers behind the same versioned gate contract.
|
|
837
|
-
| Output schema and named artifacts | Pass structured data between steps instead of relying only on a summary.
|
|
838
|
-
| Cost and token ceilings | Bound model spend independently from turn and tool-call budgets.
|
|
839
|
-
| Environment and secret references | Select named credentials without embedding secret values in workflow files.
|
|
840
|
-
| Logging and retention | Configure progress events, redaction, child artifact retention, and checkpoint history.
|
|
844
|
+
| Parameter | Why it belongs in configuration |
|
|
845
|
+
| --------------------------------- | -------------------------------------------------------------------------------------------------- |
|
|
846
|
+
| Configurable recovery and backoff | Replace the fixed two-attempt recovery cap with a ceiling-aware per-step transient-failure policy. |
|
|
847
|
+
| Acceptance criteria | Give each step machine-checkable completion evidence and verification commands. |
|
|
848
|
+
| Working directory or worktree | Isolate mutating steps, monorepo packages, and concurrent branches. |
|
|
849
|
+
| Parallel groups and join policy | Run independent steps together and declare fail-fast, quorum, or all-success behavior. |
|
|
850
|
+
| Generic gates | Add ticket, CI, chat, or custom approval providers behind the same versioned gate contract. |
|
|
851
|
+
| Output schema and named artifacts | Pass structured data between steps instead of relying only on a summary. |
|
|
852
|
+
| Cost and token ceilings | Bound model spend independently from turn and tool-call budgets. |
|
|
853
|
+
| Environment and secret references | Select named credentials without embedding secret values in workflow files. |
|
|
854
|
+
| Logging and retention | Configure progress events, redaction, child artifact retention, and checkpoint history. |
|
|
841
855
|
|
|
842
856
|
## Current limits
|
|
843
857
|
|