@marcoscale98/pi-extensible-workflows 5.17.0-fork.1 → 6.2.1-fork.1

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.
Files changed (128) hide show
  1. package/CHANGELOG.md +145 -0
  2. package/README.md +2 -2
  3. package/dist/src/agent-execution.d.ts +43 -10
  4. package/dist/src/agent-execution.js +442 -162
  5. package/dist/src/background-widget.d.ts +5 -1
  6. package/dist/src/background-widget.js +5 -10
  7. package/dist/src/decoders.d.ts +2 -3
  8. package/dist/src/decoders.js +59 -37
  9. package/dist/src/execution.d.ts +6 -2
  10. package/dist/src/execution.js +48 -7
  11. package/dist/src/host-delivery.js +5 -8
  12. package/dist/src/host-navigator.js +5 -2
  13. package/dist/src/host-phases.d.ts +1 -0
  14. package/dist/src/host-recovery.d.ts +11 -8
  15. package/dist/src/host-recovery.js +14 -22
  16. package/dist/src/host-runtime.js +56 -5
  17. package/dist/src/host-view.d.ts +6 -1
  18. package/dist/src/host-view.js +46 -20
  19. package/dist/src/host.d.ts +2 -2
  20. package/dist/src/host.js +246 -118
  21. package/dist/src/index.d.ts +1 -2
  22. package/dist/src/index.js +1985 -1690
  23. package/dist/src/index.js.map +3 -3
  24. package/dist/src/paths.d.ts +8 -5
  25. package/dist/src/paths.js +24 -13
  26. package/dist/src/persistence.d.ts +1 -0
  27. package/dist/src/persistence.js +1 -0
  28. package/dist/src/pi-runtime-runner.js +4 -1
  29. package/dist/src/registry.d.ts +9 -7
  30. package/dist/src/registry.js +29 -71
  31. package/dist/src/runtime/agent-runner.d.ts +2 -0
  32. package/dist/src/script-tools.d.ts +27 -0
  33. package/dist/src/script-tools.js +87 -0
  34. package/dist/src/session-lease.d.ts +1 -1
  35. package/dist/src/session-lease.js +45 -11
  36. package/dist/src/settings.d.ts +19 -3
  37. package/dist/src/settings.js +63 -50
  38. package/dist/src/store.d.ts +3 -1
  39. package/dist/src/store.js +17 -1
  40. package/dist/src/trajectory.d.ts +12 -3
  41. package/dist/src/trajectory.js +32 -11
  42. package/dist/src/types.d.ts +129 -45
  43. package/dist/src/types.js +5 -8
  44. package/dist/src/utils.d.ts +21 -1
  45. package/dist/src/utils.js +46 -6
  46. package/dist/src/validation.d.ts +14 -3
  47. package/dist/src/validation.js +143 -87
  48. package/dist/starter/index.js +8 -11
  49. package/dist/starter/index.js.map +1 -1
  50. package/dist/starter/review-loop.d.ts +0 -13
  51. package/dist/starter/review-loop.js +8 -9
  52. package/dist/subagents/index.js +904 -956
  53. package/dist/subagents/index.js.map +3 -3
  54. package/dist/subagents/src/contracts.d.ts +48 -31
  55. package/dist/subagents/src/contracts.js +20 -9
  56. package/dist/subagents/src/index.d.ts +1 -1
  57. package/dist/subagents/src/index.js +14 -8
  58. package/dist/subagents/src/manager.js +52 -73
  59. package/dist/subagents/src/navigator.js +3 -14
  60. package/dist/subagents/src/view.d.ts +1 -1
  61. package/dist/subagents/src/view.js +15 -68
  62. package/dist/subagents/src/worktree.js +1 -1
  63. package/dist/trajectory/assets/index.html +35 -13
  64. package/dist/trajectory/index.js +576 -932
  65. package/dist/trajectory/index.js.map +3 -3
  66. package/dist/trajectory/src/assets/index.html +35 -13
  67. package/dist/trajectory/src/index.js +134 -104
  68. package/dist/trajectory/src/server.js +268 -27
  69. package/dist/trajectory/src/server.js.map +3 -3
  70. package/dist/trajectory/src/startup-mutex.d.ts +17 -0
  71. package/dist/trajectory/src/startup-mutex.js +172 -0
  72. package/examples/workflow-extension-template/README.md +4 -7
  73. package/examples/workflow-extension-template/extension.test.mjs +4 -8
  74. package/examples/workflow-extension-template/index.js +0 -3
  75. package/package.json +10 -10
  76. package/skills/pi-extensible-workflows/SKILL.md +12 -8
  77. package/src/agent-execution.ts +412 -164
  78. package/src/background-widget.ts +5 -11
  79. package/src/decoders.ts +51 -37
  80. package/src/execution.ts +46 -9
  81. package/src/host-delivery.ts +5 -8
  82. package/src/host-navigator.ts +4 -2
  83. package/src/host-phases.ts +1 -1
  84. package/src/host-recovery.ts +23 -28
  85. package/src/host-runtime.ts +44 -6
  86. package/src/host-view.ts +41 -16
  87. package/src/host.ts +229 -142
  88. package/src/index.ts +1 -2
  89. package/src/paths.ts +18 -9
  90. package/src/persistence.ts +1 -0
  91. package/src/pi-runtime-runner.ts +3 -1
  92. package/src/registry.ts +28 -64
  93. package/src/runtime/agent-runner.ts +2 -0
  94. package/src/script-tools.ts +76 -0
  95. package/src/session-lease.ts +34 -6
  96. package/src/settings.ts +56 -50
  97. package/src/store.ts +18 -2
  98. package/src/trajectory.ts +32 -15
  99. package/src/types.ts +82 -34
  100. package/src/utils.ts +42 -5
  101. package/src/validation.ts +121 -80
  102. package/starter/index.ts +0 -1
  103. package/starter/review-loop.ts +8 -9
  104. package/starter/roles/developer.md +0 -1
  105. package/starter/roles/oracle.md +0 -1
  106. package/starter/roles/researcher.md +0 -1
  107. package/starter/roles/reviewer.md +0 -1
  108. package/starter/roles/scout.md +0 -1
  109. package/subagents/README.md +10 -16
  110. package/subagents/src/contracts.ts +21 -11
  111. package/subagents/src/index.ts +17 -8
  112. package/subagents/src/manager.ts +48 -128
  113. package/subagents/src/navigator.ts +4 -13
  114. package/subagents/src/view.ts +16 -63
  115. package/subagents/src/worktree.ts +1 -1
  116. package/trajectory/src/assets/index.html +35 -13
  117. package/trajectory/src/index.ts +112 -91
  118. package/trajectory/src/server.ts +46 -10
  119. package/trajectory/src/startup-mutex.ts +127 -0
  120. package/dist/src/roles.d.ts +0 -70
  121. package/dist/src/roles.js +0 -325
  122. package/dist/starter/roles/developer.md +0 -6
  123. package/dist/starter/roles/oracle.md +0 -18
  124. package/dist/starter/roles/researcher.md +0 -20
  125. package/dist/starter/roles/reviewer.md +0 -19
  126. package/dist/starter/roles/scout.md +0 -18
  127. package/examples/workflow-extension-template/roles/reviewer.md +0 -4
  128. package/src/roles.ts +0 -326
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@marcoscale98/pi-extensible-workflows",
3
- "version": "5.17.0-fork.1",
4
- "description": "Deterministic multi-agent workflow orchestration for Pi",
3
+ "version": "6.2.1-fork.1",
4
+ "description": "Deterministic multi-agent workflow orchestration and codemode scripts for Pi",
5
5
  "homepage": "https://vekexasia.github.io/pi-extensible-workflows/",
6
6
  "repository": {
7
7
  "type": "git",
@@ -15,7 +15,8 @@
15
15
  "workflow",
16
16
  "multi-agent",
17
17
  "orchestration",
18
- "automation"
18
+ "automation",
19
+ "codemode"
19
20
  ],
20
21
  "exports": {
21
22
  ".": "./dist/src/index.js",
@@ -24,7 +25,6 @@
24
25
  "./utils": "./dist/src/utils.js",
25
26
  "./budget": "./dist/src/budget.js",
26
27
  "./validation": "./dist/src/validation.js",
27
- "./roles": "./dist/src/roles.js",
28
28
  "./registry": "./dist/src/registry.js",
29
29
  "./runtime": "./dist/src/runtime/index.js",
30
30
  "./trajectory": "./dist/trajectory/index.js"
@@ -48,7 +48,7 @@
48
48
  "CHANGELOG.md"
49
49
  ],
50
50
  "scripts": {
51
- "build": "rm -rf dist && tsc -p tsconfig.json && cp -R starter/roles dist/starter/roles && cp -R trajectory/src/assets dist/trajectory/src/assets && cp -R trajectory/src/assets dist/trajectory/assets && esbuild src/index.ts starter/index.ts subagents/index.ts trajectory/index.ts --bundle --format=esm --platform=node --packages=external --sourcemap --sources-content=false --outbase=. --outdir=dist && esbuild trajectory/src/server.ts --bundle --format=esm --platform=node --sourcemap --sources-content=false --outfile=dist/trajectory/src/server.js",
51
+ "build": "rm -rf dist && tsc -p tsconfig.json && cp -R trajectory/src/assets dist/trajectory/src/assets && cp -R trajectory/src/assets dist/trajectory/assets && esbuild src/index.ts starter/index.ts subagents/index.ts trajectory/index.ts --bundle --format=esm --platform=node --packages=external --sourcemap --sources-content=false --outbase=. --outdir=dist && esbuild trajectory/src/server.ts --bundle --format=esm --platform=node --sourcemap --sources-content=false --outfile=dist/trajectory/src/server.js",
52
52
  "lint": "eslint .",
53
53
  "test": "npm run test:layout && npm run build && npm run test:widget && npm run test:run && npm run test:herdr && npm run test:subagents",
54
54
  "test:layout": "node --test --test-timeout=10000 --test-force-exit test/workspace-layout.test.mjs",
@@ -76,15 +76,15 @@
76
76
  },
77
77
  "peerDependencies": {
78
78
  "@earendil-works/pi-ai": "*",
79
- "@earendil-works/pi-coding-agent": "*",
79
+ "@earendil-works/pi-coding-agent": ">=0.99.0",
80
80
  "@earendil-works/pi-tui": "*",
81
81
  "typebox": "*"
82
82
  },
83
83
  "devDependencies": {
84
- "@earendil-works/pi-ai": "0.85.0",
85
- "@earendil-works/pi-coding-agent": "0.85.0",
86
- "@earendil-works/pi-server": "0.85.0",
87
- "@earendil-works/pi-tui": "0.85.0",
84
+ "@earendil-works/pi-ai": "1.0.0",
85
+ "@earendil-works/pi-coding-agent": "1.0.0",
86
+ "@earendil-works/pi-server": "1.0.0",
87
+ "@earendil-works/pi-tui": "1.0.0",
88
88
  "@eslint/js": "10.0.1",
89
89
  "@types/node": "24.12.4",
90
90
  "esbuild": "^0.28.2",
@@ -38,6 +38,8 @@ Call `workflow_catalog` once to list functions and model aliases before the firs
38
38
 
39
39
  Workflow JavaScript has no imports, filesystem, network, process, or timers. Delegate that work to agents. `shell(command, options)` is the trusted host RPC for deterministic gates: it inherits the workflow or active-worktree cwd, merges string `env` overrides, and returns `{ exitCode, stdout, stderr }`; nonzero exits are results, but launch failures and timeouts fail with `SHELL_FAILED`.
40
40
 
41
+ `await tools.<name>(args)` calls a tool of the launching Pi session directly, without an agent, with the same names and results as Pi `codemode`: an object when the tool declares an output schema, otherwise its text; other failures reject with `TOOL_FAILED`. Do not probe with `"name" in tools`; the launch checks the names a script calls. Prefer it over an agent for mechanical reads and tool calls. Workflow and subagent tools are not callable, and calls inside `withWorktree` fail.
42
+
41
43
  Example use of `shell`:
42
44
 
43
45
  ```js
@@ -72,11 +74,11 @@ For a failed run, call `workflow_status({ runId })` first: a compact authoritati
72
74
  export interface AgentOptions {
73
75
  label?: string; // display name
74
76
  model?: string; // provider/model:thinking, or alias[:thinking]
75
- role?: string; // role file name
76
77
  contextFiles?: Array<"global" | "project" | "cwd">; // which Pi context files to load
77
- skills?: string[]; // minimatch overlay after the role list
78
- extensions?: string[]; // minimatch overlay after the role list
79
- tools?: string[]; // minimatch overlay after the role list
78
+ skills?: string[]; // minimatch selector, ordered defaults then call options
79
+ extensions?: string[]; // minimatch selector, ordered defaults then call options
80
+ tools?: string[]; // minimatch selector, ordered defaults then call options
81
+ excludeTools?: string[]; // exact tool names removed after preparation; no patterns or workflow_result; never widens the parent ceiling
80
82
  outputSchema?: JsonSchema; // structured result for a later phase
81
83
  retries?: number; // extra same-run retries for this agent
82
84
  timeoutMs?: number | null; // attempt timeout; null = none
@@ -84,9 +86,9 @@ export interface AgentOptions {
84
86
  }
85
87
  ```
86
88
 
87
- A `role` already sets model, tools, skills, extensions, and context files; call-level options silently override them. Pass `{ role }` alone unless an override is indispensable for that call. When overriding, selectors overlay the role list: restrict with `["!*", "read", "grep"]`; `["*"]` turns everything back on.
89
+ Restrict resource selectors with `["!*", "read", "grep"]`; `["*"]` selects every resource allowed by the parent ceiling.
88
90
 
89
- Extensions may add JSON-compatible agent options such as `advisor: true`; core keys retain validation and role constraints. Extension options go to setup hooks/native setup and are not inherited by child agents.
91
+ Extensions may add JSON-compatible agent options such as `advisor: true`; core keys retain validation and parent ceilings. Extension options go to setup hooks/native setup and are not inherited by child agents.
90
92
 
91
93
  Agent calls are unnamed. Direct calls receive hidden source call-site identity; aliases are unsupported, and calls from one source site must not race outside `parallel` or `pipeline`, whose structural keys make replay deterministic.
92
94
 
@@ -95,7 +97,7 @@ Agent calls are unnamed. Direct calls receive hidden source call-site identity;
95
97
  Use `agent.create(...)` when one agent must keep its transcript across several turns; use plain `agent(...)` calls for independent work.
96
98
 
97
99
  ```js
98
- const author = agent.create({ name: "author", role: "developer" });
100
+ const author = agent.create({ name: "author" });
99
101
  const draft = await author.send("Create the first draft");
100
102
  const revised = await author.send(
101
103
  prompt("Apply these findings:\n\n{findings}", { findings }),
@@ -143,12 +145,14 @@ const results = await parallel("implementation", {
143
145
  });
144
146
  ```
145
147
 
148
+ Registered extension functions also get `context.agent.create({ name, ... })` with the same handle rules as scripts. Handle journal identity is scoped by function invocation, branch, worktree, and name, so repeated or nested invocations and script handles never share a transcript; the prefix `function-handle/` is reserved in script names. Each turn is a separate agent node, with no automatic grouping.
149
+
146
150
  Registered extension functions receive `withWorktree` in context and can compose other registered functions with `context.invoke("reviewRepository", { focus: "security" }, "security-review")`. The optional label is presentation-only; journal identity remains the function name and occurrence. Their public inputs and outputs remain JSON; callbacks cannot cross the extension boundary.
147
151
 
148
152
  ## Rules
149
153
 
150
154
  - Workflow run does not inherit any of the main agent context. Keep that in mind when creating agent's prompts.
151
- - `model` must be a configured alias or the canonical `provider/model:thinking` form. Aliases are listed by `workflow_catalog`; prefer a suitable alias over a hardcoded model. Never guess a model identifier: verify unknown names with `pi --list-models "search term"` first, then use the fully qualified identifier it returns.
155
+ - If `model` is specified, it must be a configured alias or the canonical `provider/model:thinking` form. Aliases are listed by `workflow_catalog`; prefer a suitable alias over a hardcoded model. Never guess a model identifier: verify unknown names with `pi --list-models "search term"` first, then use the fully qualified identifier it returns.
152
156
  - Use `log(messageString)` for brief operator status and `phase(phaseName)` to signal the start of another phase.
153
157
  - Use `parallel()` for independent tasks with different flows and `pipeline()` when every keyed item follows the same ordered stages; do not duplicate identical chains in `parallel()`. Signatures are `parallel(operationName, tasksRecord)` and `pipeline(operationName, itemsRecord, stagesRecord)`; keys are stable task, item, and stage names.
154
158
  - Use a JavaScript loop for repeated work; each direct `agent(...)` call gets deterministic call-site and occurrence identity.