indusagi-coding-agent 0.2.4 → 0.2.5

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 (266) hide show
  1. package/LICENSE +661 -0
  2. package/README.md +95 -1
  3. package/dist/entry.js +1559 -1100
  4. package/dist/guardrails.js +26 -509
  5. package/dist/index.js +1581 -1155
  6. package/package.json +8 -7
  7. package/dist/types/addons/addons.test.d.ts +0 -21
  8. package/dist/types/addons/contract.d.ts +0 -640
  9. package/dist/types/addons/dispatch/event-dispatcher.d.ts +0 -140
  10. package/dist/types/addons/dispatch/index.d.ts +0 -23
  11. package/dist/types/addons/dispatch/tool-interceptor.d.ts +0 -128
  12. package/dist/types/addons/host.d.ts +0 -246
  13. package/dist/types/addons/index.d.ts +0 -51
  14. package/dist/types/addons/manifest.d.ts +0 -56
  15. package/dist/types/addons/sandbox.d.ts +0 -103
  16. package/dist/types/addons/surface.d.ts +0 -42
  17. package/dist/types/boot/auth-vault.d.ts +0 -29
  18. package/dist/types/boot/boot.d.ts +0 -26
  19. package/dist/types/boot/boot.test.d.ts +0 -15
  20. package/dist/types/boot/contract.d.ts +0 -236
  21. package/dist/types/boot/heap.d.ts +0 -31
  22. package/dist/types/boot/index.d.ts +0 -20
  23. package/dist/types/boot/invocation.d.ts +0 -40
  24. package/dist/types/boot/invocation.test.d.ts +0 -8
  25. package/dist/types/boot/runners/addon-wiring.d.ts +0 -103
  26. package/dist/types/boot/runners/addon-wiring.test.d.ts +0 -19
  27. package/dist/types/boot/runners/checkpoint.d.ts +0 -133
  28. package/dist/types/boot/runners/checkpoint.test.d.ts +0 -12
  29. package/dist/types/boot/runners/delegate-runner.d.ts +0 -109
  30. package/dist/types/boot/runners/delegate-runner.test.d.ts +0 -13
  31. package/dist/types/boot/runners/index.d.ts +0 -13
  32. package/dist/types/boot/runners/link-runner.d.ts +0 -20
  33. package/dist/types/boot/runners/memdir.d.ts +0 -103
  34. package/dist/types/boot/runners/memdir.test.d.ts +0 -12
  35. package/dist/types/boot/runners/oneshot-runner.d.ts +0 -19
  36. package/dist/types/boot/runners/read-state.d.ts +0 -82
  37. package/dist/types/boot/runners/read-state.test.d.ts +0 -10
  38. package/dist/types/boot/runners/registry.d.ts +0 -30
  39. package/dist/types/boot/runners/repl-runner.d.ts +0 -19
  40. package/dist/types/boot/runners/server-mode.d.ts +0 -71
  41. package/dist/types/boot/runners/session-persist.test.d.ts +0 -10
  42. package/dist/types/boot/runners/session.d.ts +0 -88
  43. package/dist/types/boot/runners/session.test.d.ts +0 -15
  44. package/dist/types/boot/server-token.d.ts +0 -97
  45. package/dist/types/boot/stages.d.ts +0 -92
  46. package/dist/types/boot/upgrade/apply.d.ts +0 -45
  47. package/dist/types/boot/upgrade/index.d.ts +0 -13
  48. package/dist/types/boot/upgrade/upgrades.d.ts +0 -126
  49. package/dist/types/briefing/briefing.test.d.ts +0 -15
  50. package/dist/types/briefing/compose.d.ts +0 -37
  51. package/dist/types/briefing/context-docs.d.ts +0 -38
  52. package/dist/types/briefing/context-docs.test.d.ts +0 -18
  53. package/dist/types/briefing/contract.d.ts +0 -686
  54. package/dist/types/briefing/index.d.ts +0 -29
  55. package/dist/types/briefing/macros.d.ts +0 -206
  56. package/dist/types/briefing/skills.d.ts +0 -67
  57. package/dist/types/capability-deck/bridge-ledger/index.d.ts +0 -25
  58. package/dist/types/capability-deck/bridge-ledger/key.d.ts +0 -65
  59. package/dist/types/capability-deck/bridge-ledger/ledger.d.ts +0 -129
  60. package/dist/types/capability-deck/bridge-ledger/network.d.ts +0 -115
  61. package/dist/types/capability-deck/builtin-bridge.d.ts +0 -114
  62. package/dist/types/capability-deck/capability-deck.test.d.ts +0 -18
  63. package/dist/types/capability-deck/cards/bg-process-card.d.ts +0 -99
  64. package/dist/types/capability-deck/cards/index.d.ts +0 -37
  65. package/dist/types/capability-deck/cards/memory-card.d.ts +0 -68
  66. package/dist/types/capability-deck/cards/plan-file.d.ts +0 -56
  67. package/dist/types/capability-deck/cards/plan-tools.d.ts +0 -97
  68. package/dist/types/capability-deck/cards/plan-tools.test.d.ts +0 -9
  69. package/dist/types/capability-deck/cards/saas-card.d.ts +0 -78
  70. package/dist/types/capability-deck/cards/task-card.d.ts +0 -106
  71. package/dist/types/capability-deck/cards/todo-card.d.ts +0 -78
  72. package/dist/types/capability-deck/cards/workflow-card.d.ts +0 -55
  73. package/dist/types/capability-deck/cards/workflow-card.test.d.ts +0 -12
  74. package/dist/types/capability-deck/checkpoint.int.test.d.ts +0 -25
  75. package/dist/types/capability-deck/contract.d.ts +0 -318
  76. package/dist/types/capability-deck/index.d.ts +0 -46
  77. package/dist/types/capability-deck/manifest.d.ts +0 -60
  78. package/dist/types/capability-deck/provision.d.ts +0 -76
  79. package/dist/types/capability-deck/read-edit-gate.int.test.d.ts +0 -21
  80. package/dist/types/channels/channels.test.d.ts +0 -15
  81. package/dist/types/channels/contract.d.ts +0 -489
  82. package/dist/types/channels/framer.d.ts +0 -49
  83. package/dist/types/channels/index.d.ts +0 -24
  84. package/dist/types/channels/link/dialog.d.ts +0 -138
  85. package/dist/types/channels/link/driver.d.ts +0 -81
  86. package/dist/types/channels/link/index.d.ts +0 -13
  87. package/dist/types/channels/link/server.d.ts +0 -70
  88. package/dist/types/channels/oneshot.d.ts +0 -37
  89. package/dist/types/channels/ops.d.ts +0 -89
  90. package/dist/types/channels/session-ops.d.ts +0 -80
  91. package/dist/types/conductor/bash-guard.d.ts +0 -106
  92. package/dist/types/conductor/bash-guard.test.d.ts +0 -17
  93. package/dist/types/conductor/catalog/catalog.d.ts +0 -87
  94. package/dist/types/conductor/catalog/index.d.ts +0 -14
  95. package/dist/types/conductor/catalog/matcher.d.ts +0 -47
  96. package/dist/types/conductor/conductor.d.ts +0 -213
  97. package/dist/types/conductor/conductor.test.d.ts +0 -10
  98. package/dist/types/conductor/contract.d.ts +0 -838
  99. package/dist/types/conductor/diagnostics.d.ts +0 -183
  100. package/dist/types/conductor/diagnostics.test.d.ts +0 -10
  101. package/dist/types/conductor/index.d.ts +0 -26
  102. package/dist/types/conductor/permission-gate.integration.test.d.ts +0 -22
  103. package/dist/types/conductor/permission-wiring.test.d.ts +0 -14
  104. package/dist/types/conductor/permissions.d.ts +0 -287
  105. package/dist/types/conductor/permissions.test.d.ts +0 -12
  106. package/dist/types/conductor/plan-mode.integration.test.d.ts +0 -23
  107. package/dist/types/conductor/post-edit-diagnostics.test.d.ts +0 -18
  108. package/dist/types/conductor/quota-error.d.ts +0 -35
  109. package/dist/types/conductor/signal-hub/hub.d.ts +0 -83
  110. package/dist/types/conductor/signal-hub/index.d.ts +0 -19
  111. package/dist/types/conductor/signal-hub/translate.d.ts +0 -77
  112. package/dist/types/conductor/skill-parse/index.d.ts +0 -10
  113. package/dist/types/conductor/skill-parse/parse.d.ts +0 -67
  114. package/dist/types/conductor/submit.test.d.ts +0 -28
  115. package/dist/types/conductor/transcript-store/index.d.ts +0 -16
  116. package/dist/types/conductor/transcript-store/serialize.d.ts +0 -106
  117. package/dist/types/conductor/transcript-store/serialize.test.d.ts +0 -10
  118. package/dist/types/conductor/transcript-store/store.d.ts +0 -188
  119. package/dist/types/console/auth-status.d.ts +0 -28
  120. package/dist/types/console/components/AgentsView.d.ts +0 -41
  121. package/dist/types/console/components/BackgroundAgents.d.ts +0 -63
  122. package/dist/types/console/components/BackgroundAgents.test.d.ts +0 -8
  123. package/dist/types/console/components/Banner.d.ts +0 -110
  124. package/dist/types/console/components/Composer.d.ts +0 -37
  125. package/dist/types/console/components/StatusBar.d.ts +0 -42
  126. package/dist/types/console/components/TerminalConsole.d.ts +0 -27
  127. package/dist/types/console/components/WorkingIndicator.d.ts +0 -44
  128. package/dist/types/console/components/WorkingIndicator.test.d.ts +0 -9
  129. package/dist/types/console/components/banner-sweep.d.ts +0 -55
  130. package/dist/types/console/components/banner.test.d.ts +0 -9
  131. package/dist/types/console/components/welcome.d.ts +0 -115
  132. package/dist/types/console/components/welcome.test.d.ts +0 -9
  133. package/dist/types/console/console.test.d.ts +0 -19
  134. package/dist/types/console/contract.d.ts +0 -611
  135. package/dist/types/console/index.d.ts +0 -34
  136. package/dist/types/console/input/complete.d.ts +0 -120
  137. package/dist/types/console/input/dir-reader.d.ts +0 -28
  138. package/dist/types/console/input/index.d.ts +0 -24
  139. package/dist/types/console/input/input.test.d.ts +0 -14
  140. package/dist/types/console/input/keymap.d.ts +0 -193
  141. package/dist/types/console/input/paste.d.ts +0 -183
  142. package/dist/types/console/mount.d.ts +0 -53
  143. package/dist/types/console/overlays/approval-queue.d.ts +0 -88
  144. package/dist/types/console/overlays/approval.d.ts +0 -104
  145. package/dist/types/console/overlays/approval.test.d.ts +0 -17
  146. package/dist/types/console/overlays/auth.d.ts +0 -31
  147. package/dist/types/console/overlays/boards.d.ts +0 -55
  148. package/dist/types/console/overlays/host.d.ts +0 -45
  149. package/dist/types/console/overlays/index.d.ts +0 -15
  150. package/dist/types/console/overlays/pickers.d.ts +0 -37
  151. package/dist/types/console/overlays/sessions.d.ts +0 -29
  152. package/dist/types/console/reducer.d.ts +0 -51
  153. package/dist/types/console/slash/builtins.d.ts +0 -33
  154. package/dist/types/console/slash/commands/dynamic.d.ts +0 -57
  155. package/dist/types/console/slash/commands/dynamic.test.d.ts +0 -9
  156. package/dist/types/console/slash/commands/integrations.d.ts +0 -28
  157. package/dist/types/console/slash/commands/integrations.test.d.ts +0 -18
  158. package/dist/types/console/slash/commands/shared.d.ts +0 -72
  159. package/dist/types/console/slash/commands/transcript.d.ts +0 -24
  160. package/dist/types/console/slash/commands/transcript.test.d.ts +0 -10
  161. package/dist/types/console/slash/commands/workbench.d.ts +0 -21
  162. package/dist/types/console/slash/commands/workbench.test.d.ts +0 -10
  163. package/dist/types/console/slash/index.d.ts +0 -34
  164. package/dist/types/console/slash/registry.d.ts +0 -90
  165. package/dist/types/console/slash/resolve.d.ts +0 -109
  166. package/dist/types/console/slash/slash.test.d.ts +0 -18
  167. package/dist/types/console/startup.d.ts +0 -119
  168. package/dist/types/console/theme/adapter.d.ts +0 -79
  169. package/dist/types/console/theme/index.d.ts +0 -18
  170. package/dist/types/console/theme/palette.d.ts +0 -77
  171. package/dist/types/console/theme/resolve.d.ts +0 -45
  172. package/dist/types/console/theme/theme.test.d.ts +0 -16
  173. package/dist/types/console/theme/tokens.d.ts +0 -62
  174. package/dist/types/entry.d.ts +0 -17
  175. package/dist/types/guardrails.d.ts +0 -33
  176. package/dist/types/index.d.ts +0 -24
  177. package/dist/types/insight/channel.d.ts +0 -45
  178. package/dist/types/insight/contract.d.ts +0 -411
  179. package/dist/types/insight/index.d.ts +0 -26
  180. package/dist/types/insight/insight.test.d.ts +0 -17
  181. package/dist/types/insight/recorder.d.ts +0 -63
  182. package/dist/types/insight/redaction.d.ts +0 -44
  183. package/dist/types/insight/replay.d.ts +0 -77
  184. package/dist/types/insight/sampling.d.ts +0 -84
  185. package/dist/types/insight/serialize.d.ts +0 -54
  186. package/dist/types/insight/sinks/console.d.ts +0 -36
  187. package/dist/types/insight/sinks/file.d.ts +0 -37
  188. package/dist/types/insight/sinks/index.d.ts +0 -16
  189. package/dist/types/insight/sinks/stream.d.ts +0 -53
  190. package/dist/types/kit/clipboard-image.d.ts +0 -40
  191. package/dist/types/kit/external-editor.d.ts +0 -35
  192. package/dist/types/kit/image.d.ts +0 -102
  193. package/dist/types/kit/index.d.ts +0 -29
  194. package/dist/types/kit/kit.test.d.ts +0 -13
  195. package/dist/types/kit/shell.d.ts +0 -50
  196. package/dist/types/kit/tool-fetch.d.ts +0 -165
  197. package/dist/types/launch/catalog.d.ts +0 -51
  198. package/dist/types/launch/contract.d.ts +0 -387
  199. package/dist/types/launch/credentials.d.ts +0 -112
  200. package/dist/types/launch/index.d.ts +0 -28
  201. package/dist/types/launch/invocation/attachments.d.ts +0 -72
  202. package/dist/types/launch/invocation/flags.d.ts +0 -59
  203. package/dist/types/launch/invocation/index.d.ts +0 -23
  204. package/dist/types/launch/invocation/read.d.ts +0 -52
  205. package/dist/types/launch/invocation/usage.d.ts +0 -25
  206. package/dist/types/launch/launch.test.d.ts +0 -20
  207. package/dist/types/launch/login.d.ts +0 -68
  208. package/dist/types/launch/oauth.d.ts +0 -101
  209. package/dist/types/launch/oauth.test.d.ts +0 -20
  210. package/dist/types/launch/packages.d.ts +0 -75
  211. package/dist/types/launch/packages.test.d.ts +0 -15
  212. package/dist/types/launch/pickers.d.ts +0 -97
  213. package/dist/types/runtime-bridge/bridges/_drive.d.ts +0 -74
  214. package/dist/types/runtime-bridge/bridges/builtins.d.ts +0 -77
  215. package/dist/types/runtime-bridge/bridges/claude-cli.d.ts +0 -37
  216. package/dist/types/runtime-bridge/bridges/codex-cli.d.ts +0 -27
  217. package/dist/types/runtime-bridge/bridges/index.d.ts +0 -15
  218. package/dist/types/runtime-bridge/bridges/indusagi-cli.d.ts +0 -36
  219. package/dist/types/runtime-bridge/broker.d.ts +0 -182
  220. package/dist/types/runtime-bridge/contract.d.ts +0 -436
  221. package/dist/types/runtime-bridge/index.d.ts +0 -21
  222. package/dist/types/runtime-bridge/runtime-bridge.test.d.ts +0 -17
  223. package/dist/types/runtime-bridge/sink.d.ts +0 -59
  224. package/dist/types/sessions/contract.d.ts +0 -79
  225. package/dist/types/sessions/index.d.ts +0 -11
  226. package/dist/types/sessions/library.d.ts +0 -95
  227. package/dist/types/sessions/sessions.test.d.ts +0 -11
  228. package/dist/types/settings/contract.d.ts +0 -175
  229. package/dist/types/settings/index.d.ts +0 -13
  230. package/dist/types/settings/manager.d.ts +0 -109
  231. package/dist/types/settings/settings.test.d.ts +0 -16
  232. package/dist/types/transcript-export/index.d.ts +0 -20
  233. package/dist/types/transcript-export/publish.d.ts +0 -81
  234. package/dist/types/transcript-export/sgr.d.ts +0 -90
  235. package/dist/types/transcript-export/template.d.ts +0 -64
  236. package/dist/types/transcript-export/theme-bridge.d.ts +0 -99
  237. package/dist/types/transcript-export/transcript-export.test.d.ts +0 -16
  238. package/dist/types/window-budget/budget/estimate.d.ts +0 -47
  239. package/dist/types/window-budget/budget/gate.d.ts +0 -37
  240. package/dist/types/window-budget/budget/index.d.ts +0 -14
  241. package/dist/types/window-budget/budget/slice.d.ts +0 -38
  242. package/dist/types/window-budget/condenser.d.ts +0 -73
  243. package/dist/types/window-budget/contract.d.ts +0 -182
  244. package/dist/types/window-budget/index.d.ts +0 -17
  245. package/dist/types/window-budget/microcompact.d.ts +0 -68
  246. package/dist/types/window-budget/microcompact.test.d.ts +0 -16
  247. package/dist/types/window-budget/rehydrate.d.ts +0 -56
  248. package/dist/types/window-budget/summarize/condense.d.ts +0 -76
  249. package/dist/types/window-budget/summarize/index.d.ts +0 -12
  250. package/dist/types/window-budget/summarize/prompt.d.ts +0 -56
  251. package/dist/types/window-budget/window-budget.test.d.ts +0 -18
  252. package/dist/types/workflow-engine/agent-runner.d.ts +0 -124
  253. package/dist/types/workflow-engine/agent-runner.test.d.ts +0 -8
  254. package/dist/types/workflow-engine/display.d.ts +0 -148
  255. package/dist/types/workflow-engine/display.test.d.ts +0 -1
  256. package/dist/types/workflow-engine/engine.d.ts +0 -183
  257. package/dist/types/workflow-engine/engine.test.d.ts +0 -1
  258. package/dist/types/workflow-engine/index.d.ts +0 -21
  259. package/dist/types/workflow-engine/parse.d.ts +0 -64
  260. package/dist/types/workflow-engine/parse.test.d.ts +0 -1
  261. package/dist/types/workflow-engine/structured-output.d.ts +0 -51
  262. package/dist/types/workflow-engine/structured-output.test.d.ts +0 -1
  263. package/dist/types/workspace/brand.d.ts +0 -26
  264. package/dist/types/workspace/index.d.ts +0 -11
  265. package/dist/types/workspace/locator.d.ts +0 -50
  266. package/dist/types/workspace/runtime-detect.d.ts +0 -56
@@ -1,183 +0,0 @@
1
- /**
2
- * runWorkflow — the deterministic workflow orchestration engine.
3
- *
4
- * A workflow script is plain JavaScript (parsed by {@link parseWorkflowScript})
5
- * that orchestrates a fan-out of subagents. The engine evaluates the script's
6
- * body inside a Node `vm` sandbox seeded with a small, frozen global surface:
7
- *
8
- * - `agent(prompt, opts?)` — spawn one subagent, awaitable, returns its
9
- * result (string, or the validated `opts.schema`
10
- * object). Runs under a FIFO concurrency limiter.
11
- * - `parallel(thunks)` — run an array of `() => Promise` thunks and wait
12
- * for ALL of them (a barrier); results in input
13
- * order; a failed branch logs and yields `null`.
14
- * - `pipeline(items, …st)` — run each item through the stages sequentially,
15
- * while different items proceed independently
16
- * (NO cross-item barrier); a failed stage logs and
17
- * yields `null` for that item.
18
- * - `phase(title)` — open/activate a named progress group.
19
- * - `log(message)` — append a log line.
20
- * - `args` — the caller-supplied JSON value.
21
- * - `budget` — `{ total, spent(), remaining() }` token budget.
22
- * - `cwd` — the working directory string.
23
- * - frozen `console` — routed into `log`.
24
- *
25
- * The actual subagent spawn is NOT owned here: the engine delegates each
26
- * `agent()` call to an injected {@link WorkflowAgentRunner} (stage 2 supplies a
27
- * real one backed by a fresh framework `Agent`; tests pass an in-memory fake).
28
- * This is the spawn seam that keeps the engine pure and network-free.
29
- *
30
- * Behavioral port of pi-dynamic-workflows' `runWorkflow`
31
- * (pi-dynamic-workflows/src/workflow.ts): same concurrency cap formula, same
32
- * FIFO limiter, same pending-run tracking + final `Promise.allSettled`, same
33
- * per-branch failure-to-null semantics, same budget loop, same abort handling,
34
- * same structured-clone guard on the result, same default agent labels.
35
- */
36
- import { type WorkflowMeta } from "./parse";
37
- /**
38
- * Live activity metrics for one running subagent.
39
- *
40
- * Folded by the {@link WorkflowAgentRunner} from the framework `Agent`'s event
41
- * stream and forwarded — via {@link WorkflowAgentRunOptions.onActivity} → the
42
- * engine's {@link WorkflowRunOptions.onAgentActivity} — into that agent's row in
43
- * the live `◆ Workflow:` progress tree.
44
- */
45
- export interface WorkflowAgentActivity {
46
- /** Cumulative input tokens spent so far. */
47
- tokensIn: number;
48
- /** Cumulative output tokens spent so far. */
49
- tokensOut: number;
50
- /** How many tool calls the subagent has started. */
51
- toolCount: number;
52
- /** The tool the subagent is running right now, if any. */
53
- currentTool?: string;
54
- /** The last tool the subagent finished (when nothing is running). */
55
- lastTool?: string;
56
- }
57
- /** Options the engine hands a {@link WorkflowAgentRunner} for one subagent. */
58
- export interface WorkflowAgentRunOptions {
59
- /** The resolved, human-readable label for this subagent run. */
60
- label: string;
61
- /** The phase this subagent belongs to, if any. */
62
- phase?: string;
63
- /**
64
- * Optional JSON-Schema / TypeBox schema the subagent's result must satisfy.
65
- * When present the runner returns the validated object; when absent it returns
66
- * the subagent's final assistant text as a string. Left as `unknown` so the
67
- * engine stays decoupled from any particular schema library.
68
- */
69
- schema?: unknown;
70
- /** Extra system guidance the engine derived (phase/model/type/isolation). */
71
- instructions?: string;
72
- /** Requested model id, if the script passed `opts.model`. */
73
- model?: string;
74
- /** Requested subagent profile/type, if the script passed `opts.agentType`. */
75
- agentType?: string;
76
- /** Requested isolation mode, if the script passed `opts.isolation`. */
77
- isolation?: "worktree";
78
- /** Abort signal forwarded from the workflow run. */
79
- signal?: AbortSignal;
80
- /**
81
- * Called whenever the subagent's live activity changes (a tool starts/ends or
82
- * a turn settles with token spend). The runner folds this from the framework
83
- * `Agent` event stream; the engine forwards it to
84
- * {@link WorkflowRunOptions.onAgentActivity}. Optional — a test fake may omit it.
85
- */
86
- onActivity?: (metrics: WorkflowAgentActivity) => void;
87
- }
88
- /**
89
- * The minimal contract the engine needs to spawn a subagent.
90
- *
91
- * Stage 2 implements this against a fresh, isolated framework `Agent` (the
92
- * delegate-runner spawn pattern): resolve the model, build the authoring deck,
93
- * prompt to completion, then read either the structured-output capture or the
94
- * final assistant text. Tests implement it with an in-memory fake so the engine
95
- * can be exercised with no network.
96
- */
97
- export interface WorkflowAgentRunner {
98
- /**
99
- * Run one subagent task and resolve with its result.
100
- *
101
- * @param prompt the task prompt
102
- * @param options the resolved run options (label, schema, signal, …)
103
- * @returns the subagent's result — a string, or the validated schema object
104
- */
105
- run(prompt: string, options: WorkflowAgentRunOptions): Promise<unknown>;
106
- }
107
- /** Per-subagent option bag accepted by the in-sandbox `agent()` global. */
108
- export interface AgentOptions {
109
- /** Short unique label for the run (2-5 words); defaulted when absent. */
110
- label?: string;
111
- /** Override the phase this agent is attributed to. */
112
- phase?: string;
113
- /** Result schema; when present the agent returns the validated object. */
114
- schema?: unknown;
115
- /** Requested model id. */
116
- model?: string;
117
- /** Requested isolation mode. */
118
- isolation?: "worktree";
119
- /** Requested subagent profile/type. */
120
- agentType?: string;
121
- }
122
- /** Options for {@link runWorkflow}. */
123
- export interface WorkflowRunOptions {
124
- /** The injected subagent runner (required to actually spawn). */
125
- agentRunner: WorkflowAgentRunner;
126
- /** The JSON value exposed to the script as global `args`. */
127
- args?: unknown;
128
- /** The working directory exposed to the script as `cwd`/`process.cwd()`. */
129
- cwd?: string;
130
- /** Max concurrent subagents; clamped to `[1, 16]`. */
131
- concurrency?: number;
132
- /** Optional token budget; `null`/absent means unbounded. */
133
- tokenBudget?: number | null;
134
- /** Abort signal — aborts pending and future subagent spawns. */
135
- signal?: AbortSignal;
136
- /** Called for each `log()` / console line. */
137
- onLog?: (message: string) => void;
138
- /** Called when a new phase is activated. */
139
- onPhase?: (title: string) => void;
140
- /** Called just before a subagent starts. */
141
- onAgentStart?: (event: {
142
- id: number;
143
- label: string;
144
- phase?: string;
145
- prompt: string;
146
- }) => void;
147
- /** Called when a subagent ends (`result === null` means it failed). */
148
- onAgentEnd?: (event: {
149
- id: number;
150
- label: string;
151
- phase?: string;
152
- result: unknown;
153
- }) => void;
154
- /**
155
- * Called whenever a running subagent's live activity changes (tool start/end,
156
- * settled turn token spend). `id` is the 1-based start-order id that matches
157
- * the `id` on the corresponding {@link onAgentStart} / {@link onAgentEnd} event.
158
- */
159
- onAgentActivity?: (id: number, metrics: WorkflowAgentActivity) => void;
160
- }
161
- /** The structured result of a completed workflow run. */
162
- export interface WorkflowRunResult<T = unknown> {
163
- /** The validated workflow header. */
164
- meta: WorkflowMeta;
165
- /** The script's returned value (structured-clone checked). */
166
- result: T;
167
- /** All log lines emitted during the run, in order. */
168
- logs: string[];
169
- /** All phases observed during the run, in order. */
170
- phases: string[];
171
- /** Total subagents spawned. */
172
- agentCount: number;
173
- /** Wall-clock duration of the run. */
174
- durationMs: number;
175
- }
176
- /**
177
- * Parse and run a deterministic workflow script to completion.
178
- *
179
- * @param script the raw workflow JavaScript (first statement: `export const meta`)
180
- * @param options the injected runner plus run configuration / callbacks
181
- * @returns the meta, the script's returned value, and run telemetry
182
- */
183
- export declare function runWorkflow<T = unknown>(script: string, options: WorkflowRunOptions): Promise<WorkflowRunResult<T>>;
@@ -1 +0,0 @@
1
- export {};
@@ -1,21 +0,0 @@
1
- /**
2
- * workflow-engine — the pure, network-free orchestration core for the `workflow`
3
- * dynamic-workflow tool.
4
- *
5
- * This barrel exposes the engine subsystem only: the deterministic script
6
- * parser, the `structured_output` capture tool, the progress snapshot model +
7
- * text renderer, and the `runWorkflow` engine with its injectable
8
- * {@link WorkflowAgentRunner} spawn seam. The card and console wiring (the real
9
- * runner backed by a fresh framework `Agent`, the `tool_update` product signal,
10
- * and `APP_NOVEL_CARDS` registration) live in stage 2 and consume these exports.
11
- */
12
- export type { ParsedWorkflow, WorkflowMeta, WorkflowMetaPhase, } from "./parse";
13
- export { NONDETERMINISM_ERROR, parseWorkflowScript } from "./parse";
14
- export type { StructuredOutputCapture, StructuredOutputToolOptions, } from "./structured-output";
15
- export { createStructuredOutputTool } from "./structured-output";
16
- export type { WorkflowAgentSnapshot, WorkflowAgentStatus, WorkflowDisplayOptions, WorkflowSnapshot, } from "./display";
17
- export { createWorkflowSnapshot, preview, recomputeWorkflowSnapshot, renderWorkflowLines, renderWorkflowText, } from "./display";
18
- export type { AgentOptions, WorkflowAgentActivity, WorkflowAgentRunner, WorkflowAgentRunOptions, WorkflowRunOptions, WorkflowRunResult, } from "./engine";
19
- export { runWorkflow } from "./engine";
20
- export type { WorkflowAgentRunnerOptions, WorkflowSubAgent, WorkflowSpawnContext, } from "./agent-runner";
21
- export { createWorkflowAgentRunner } from "./agent-runner";
@@ -1,64 +0,0 @@
1
- /**
2
- * Workflow script parser — extract and validate the leading `meta` export,
3
- * enforce determinism, and hand back the runnable sandbox body.
4
- *
5
- * A workflow script is plain JavaScript whose FIRST statement must be
6
- * `export const meta = { ... }` (an object literal). This module:
7
- *
8
- * 1. locates that leading export with a lexer-free, dependency-free scan,
9
- * 2. evaluates ONLY the `{ ... }` literal in a frozen, empty Node `vm`
10
- * sandbox (no globals reachable, so the literal cannot call into
11
- * anything), capturing the resulting plain object as {@link WorkflowMeta},
12
- * 3. validates the meta shape (name/description required, optional
13
- * whenToUse/phases),
14
- * 4. enforces the determinism guard over the WHOLE script source —
15
- * `Date.now()`, `Math.random()`, and `new Date()` are rejected so a
16
- * workflow always produces the same orchestration plan, and
17
- * 5. strips the `export const meta = …;` statement so the remaining `body`
18
- * runs as an ordinary async function body inside the engine sandbox.
19
- *
20
- * This is a dependency-free port of pi's acorn-based `parseWorkflowScript`
21
- * (pi-dynamic-workflows/src/workflow.ts). It deliberately does NOT pull in
22
- * `acorn`: the only thing the engine needs to read out of the source is the
23
- * leading literal, which a sandboxed `Function`/`vm` evaluation of that one
24
- * expression handles safely, and the determinism guard is a source string-scan
25
- * over the call/`new` forms pi's AST walk rejected.
26
- */
27
- /** One declared phase in the upfront `meta.phases` outline. */
28
- export interface WorkflowMetaPhase {
29
- /** Human title for the phase row. */
30
- title: string;
31
- /** Optional one-line elaboration of what the phase does. */
32
- detail?: string;
33
- /** Optional model hint the phase prefers (documentation only). */
34
- model?: string;
35
- }
36
- /** The validated `export const meta = { … }` header of a workflow script. */
37
- export interface WorkflowMeta {
38
- /** Short snake_case identifier for the workflow. */
39
- name: string;
40
- /** Non-empty human description of what the workflow accomplishes. */
41
- description: string;
42
- /** Optional guidance on when a model should reach for this workflow. */
43
- whenToUse?: string;
44
- /** Optional upfront outline; live progress is still driven by `phase()`. */
45
- phases?: WorkflowMetaPhase[];
46
- }
47
- /** The result of {@link parseWorkflowScript}: validated meta + runnable body. */
48
- export interface ParsedWorkflow {
49
- /** The validated workflow header. */
50
- meta: WorkflowMeta;
51
- /** The script with the leading `export const meta = …` statement removed. */
52
- body: string;
53
- }
54
- /** Message raised when a script reaches for a non-deterministic primitive. */
55
- export declare const NONDETERMINISM_ERROR = "Workflow scripts must be deterministic: Date.now()/Math.random()/new Date() are unavailable";
56
- /**
57
- * Parse a workflow script into its validated {@link WorkflowMeta} and the
58
- * runnable `body` (the script with the meta export removed).
59
- *
60
- * @param script the raw workflow JavaScript source
61
- * @throws if the first statement is not `export const meta = {literal}`, if the
62
- * meta fails validation, or if the source uses a non-deterministic primitive
63
- */
64
- export declare function parseWorkflowScript(script: string): ParsedWorkflow;
@@ -1 +0,0 @@
1
- export {};
@@ -1,51 +0,0 @@
1
- /**
2
- * structured_output — the per-subagent "final answer channel" tool.
3
- *
4
- * A workflow subagent that needs to return a machine-readable result is given a
5
- * tool named `structured_output` whose `parameters` ARE the caller-supplied
6
- * TypeBox schema. When the subagent calls it, the framework has already
7
- * validated the arguments against that schema, so `execute` simply records the
8
- * validated value into a shared {@link StructuredOutputCapture} and returns a
9
- * normal {@link AgentToolResult}.
10
- *
11
- * Difference from pi's version (pi-dynamic-workflows/src/structured-output.ts):
12
- * the indus-code-rebuild framework `AgentToolResult` has NO `terminate` flag
13
- * (see {@link "indusagi/agent"} `AgentToolResult`), so this tool does NOT end
14
- * the subagent's loop early. The stage-2 runner instead runs the subagent to
15
- * completion and reads `capture.value` afterward. This file is therefore a
16
- * plain {@link AgentTool} object literal (no `defineTool`, no `terminate`).
17
- */
18
- import type { Static, TSchema } from "@sinclair/typebox";
19
- import type { AgentTool } from "../capability-deck";
20
- /**
21
- * Mutable sink the {@link createStructuredOutputTool} tool writes into. The
22
- * runner constructs one per subagent run, passes it in, and reads `value` after
23
- * the subagent finishes.
24
- */
25
- export interface StructuredOutputCapture<T = unknown> {
26
- /** The last validated payload the subagent submitted, if any. */
27
- value: T | undefined;
28
- /** Whether `structured_output` was ever called during the run. */
29
- called: boolean;
30
- }
31
- /** Options for {@link createStructuredOutputTool}. */
32
- export interface StructuredOutputToolOptions<TSchemaDef extends TSchema> {
33
- /** The TypeBox schema the subagent's result must satisfy. */
34
- schema: TSchemaDef;
35
- /** The capture sink the validated result is recorded into. */
36
- capture: StructuredOutputCapture<Static<TSchemaDef>>;
37
- /** Override the tool name (defaults to `structured_output`). */
38
- name?: string;
39
- }
40
- /**
41
- * Build the `structured_output` capture tool for one subagent run.
42
- *
43
- * The returned tool's `parameters` are exactly `schema`, so the framework
44
- * validates the subagent's arguments before `execute` runs; `execute` then
45
- * records them into `capture` and acknowledges. Idempotent in the sense that a
46
- * second call simply overwrites `capture.value` with the newer payload.
47
- *
48
- * @param options the result schema, the capture sink, and an optional name
49
- * @returns an {@link AgentTool} whose parameters mirror the caller schema
50
- */
51
- export declare function createStructuredOutputTool<TSchemaDef extends TSchema>({ schema, capture, name, }: StructuredOutputToolOptions<TSchemaDef>): AgentTool<TSchemaDef, Static<TSchemaDef>>;
@@ -1,26 +0,0 @@
1
- /**
2
- * Brand record — the single source of truth for every identity literal.
3
- *
4
- * One frozen {@link Brand} value. Nothing else in the app hard-codes the
5
- * product name, the profile-directory leaf, the bin names, the env-var
6
- * namespace, or the share-viewer origin. A rebrand edits this record and
7
- * nothing else.
8
- *
9
- * Shape is dictated by the boot contract ({@link Brand}); the *values* are the
10
- * indusagi identity.
11
- */
12
- import type { Brand } from "../boot/contract";
13
- /**
14
- * The concrete indusagi identity.
15
- *
16
- * Frozen at module scope so the record cannot be mutated by any consumer, and
17
- * typed `satisfies Brand` so a drift from the contract is a compile error here
18
- * rather than a runtime surprise downstream.
19
- */
20
- export declare const BRAND: Brand;
21
- /**
22
- * The product version — printed by `--version` and shown on the startup banner.
23
- * Single source of truth: bump this one line per release. Co-located with the
24
- * brand so `boot` reads it without importing the index barrel.
25
- */
26
- export declare const VERSION = "0.2.4";
@@ -1,11 +0,0 @@
1
- /**
2
- * Workspace subsystem — public barrel.
3
- *
4
- * One import site for the keyed Workspace Locator, the concrete {@link BRAND}
5
- * record, and the runtime/packaging detection. Boot stages depend on this
6
- * module rather than reaching into the individual files.
7
- */
8
- export { BRAND, VERSION } from "./brand";
9
- export { createWorkspace, ensureDirs, type WorkspaceOverrides, } from "./locator";
10
- export { isPackagedBinary, resolvePackageRoot, detectPackagingFromModuleUrl, type Packaging, } from "./runtime-detect";
11
- export type { Brand, Workspace } from "../boot/contract";
@@ -1,50 +0,0 @@
1
- /**
2
- * Workspace Locator — turns the active {@link Brand} plus the environment into a
3
- * single, fully-resolved {@link Workspace} record of absolute paths.
4
- *
5
- * Replaces a family of free `get<Thing>Path()` getters with one keyed map: every
6
- * member of {@link Workspace} is described once as a relative location inside the
7
- * profile directory, and the record is built by folding that map against a
8
- * resolved profile root. There is no per-path function and no string literal
9
- * duplicated across the codebase — the layout is data.
10
- *
11
- * Resolution is pure: it reads `os.homedir()` and the process env (both
12
- * overridable for tests), joins against {@link Brand.profileDirName} /
13
- * {@link Brand.stateDirName}, and never touches the filesystem. The optional
14
- * {@link ensureDirs} helper is the only function that writes, and it only ever
15
- * `mkdir`s directories that belong to the resolved workspace.
16
- */
17
- import type { Brand, Workspace } from "../boot/contract";
18
- /**
19
- * Inputs that normally come from the OS but may be pinned for testing or
20
- * embedding. All optional; each defaults to its live process value.
21
- */
22
- export interface WorkspaceOverrides {
23
- /** User home directory; defaults to {@link homedir}. */
24
- readonly home?: string;
25
- /** Working directory the resolution is anchored to; defaults to `process.cwd()`. */
26
- readonly cwd?: string;
27
- /** Environment to read the profile-dir override from; defaults to {@link process.env}. */
28
- readonly env?: NodeJS.ProcessEnv;
29
- /** Brand whose directory names drive the layout; defaults to {@link BRAND}. */
30
- readonly brand?: Brand;
31
- }
32
- /**
33
- * Build the fully-resolved {@link Workspace} for the active brand and
34
- * environment.
35
- *
36
- * Pure path computation: resolves the profile root, then folds the
37
- * {@link LAYOUT} map into a frozen record by joining each member's segments onto
38
- * that root. No filesystem access — call {@link ensureDirs} separately if the
39
- * directories need to exist.
40
- */
41
- export declare function createWorkspace(overrides?: WorkspaceOverrides): Workspace;
42
- /**
43
- * Create every directory the workspace expects, idempotently.
44
- *
45
- * Walks the {@link DIRECTORY_KEYS} subset of the resolved {@link Workspace} and
46
- * `mkdir -p`s each one. Files are never created here — only their containing
47
- * directories — so callers can write `settings.json` et al. afterwards without
48
- * a missing-parent error. Returns the same workspace for chaining.
49
- */
50
- export declare function ensureDirs(workspace: Workspace): Workspace;
@@ -1,56 +0,0 @@
1
- /**
2
- * Runtime / package-root detection.
3
- *
4
- * Two facts the rest of boot needs to know about *how* the process was started:
5
- *
6
- * 1. Is this a single-file compiled binary (a Bun standalone executable) or
7
- * an ordinary interpreted launch (Node, or `bun run` over source)?
8
- * 2. Where on disk is the package root — the directory that anchors bundled
9
- * assets (themes, export templates) and the `package.json` manifest?
10
- *
11
- * The compiled-binary case is *dictated by the Bun toolchain*: a standalone
12
- * executable resolves its own module URLs through a synthetic virtual
13
- * filesystem whose path component Bun spells `$bunfs` (and, depending on the
14
- * platform/escaping, the home-marker variants `~BUN` / `%7EBUN`). Those exact
15
- * markers are not a stylistic choice — they are the only signal Bun emits — so
16
- * we keep the literals but quarantine them inside a *single* renamed probe
17
- * ({@link detectPackagingFromModuleUrl}) instead of scattering the check.
18
- *
19
- * Root resolution is expressed as an ordered {@link resolveRoot} strategy table:
20
- * the first strategy that matches the detected packaging produces the root, so
21
- * adding a future strategy (e.g. an explicit override) is a row, not a branch.
22
- */
23
- /**
24
- * The two shapes a launch can take, from the boot layer's point of view.
25
- *
26
- * - `compiled-binary` — a Bun standalone executable; assets live next to
27
- * {@link process.execPath}, and module URLs point at Bun's virtual FS.
28
- * - `interpreted` — Node, or `bun run` over a real source/`dist` tree; assets
29
- * live in the directory tree containing this module.
30
- */
31
- export type Packaging = "compiled-binary" | "interpreted";
32
- /**
33
- * The lone probe over an `import.meta.url`-shaped string.
34
- *
35
- * Renamed wrapper around the (Bun-dictated) virtual-FS markers: if the module
36
- * URL carries any marker the launch is a compiled binary, otherwise it is an
37
- * interpreted run. Pure and string-only so it is trivially unit-testable
38
- * without spawning a real binary.
39
- *
40
- * @param moduleUrl the `import.meta.url` of the calling module.
41
- */
42
- export declare function detectPackagingFromModuleUrl(moduleUrl: string): Packaging;
43
- /**
44
- * Whether the current process is a Bun-compiled standalone binary.
45
- *
46
- * Convenience over {@link detectPackagingFromModuleUrl} bound to this module's
47
- * own URL — the single public predicate the rest of boot calls.
48
- */
49
- export declare function isPackagedBinary(): boolean;
50
- /**
51
- * Resolve the absolute package-root directory for the active launch.
52
- *
53
- * Detects packaging once, then folds the {@link ROOT_STRATEGIES} table to the
54
- * first claimant. The final row claims unconditionally, so this always returns.
55
- */
56
- export declare function resolvePackageRoot(): string;