indusagi-coding-agent 0.2.3 → 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 (260) hide show
  1. package/CHANGELOG.md +25 -0
  2. package/LICENSE +661 -0
  3. package/README.md +95 -1
  4. package/dist/entry.js +3205 -1585
  5. package/dist/guardrails.js +47 -515
  6. package/dist/index.js +3232 -1671
  7. package/package.json +8 -7
  8. package/dist/types/addons/addons.test.d.ts +0 -21
  9. package/dist/types/addons/contract.d.ts +0 -640
  10. package/dist/types/addons/dispatch/event-dispatcher.d.ts +0 -140
  11. package/dist/types/addons/dispatch/index.d.ts +0 -23
  12. package/dist/types/addons/dispatch/tool-interceptor.d.ts +0 -128
  13. package/dist/types/addons/host.d.ts +0 -246
  14. package/dist/types/addons/index.d.ts +0 -51
  15. package/dist/types/addons/manifest.d.ts +0 -56
  16. package/dist/types/addons/sandbox.d.ts +0 -103
  17. package/dist/types/addons/surface.d.ts +0 -42
  18. package/dist/types/boot/auth-vault.d.ts +0 -29
  19. package/dist/types/boot/boot.d.ts +0 -26
  20. package/dist/types/boot/boot.test.d.ts +0 -15
  21. package/dist/types/boot/contract.d.ts +0 -236
  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 -89
  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/session-persist.test.d.ts +0 -10
  41. package/dist/types/boot/runners/session.d.ts +0 -65
  42. package/dist/types/boot/runners/session.test.d.ts +0 -10
  43. package/dist/types/boot/stages.d.ts +0 -92
  44. package/dist/types/boot/upgrade/apply.d.ts +0 -45
  45. package/dist/types/boot/upgrade/index.d.ts +0 -13
  46. package/dist/types/boot/upgrade/upgrades.d.ts +0 -126
  47. package/dist/types/briefing/briefing.test.d.ts +0 -15
  48. package/dist/types/briefing/compose.d.ts +0 -37
  49. package/dist/types/briefing/context-docs.d.ts +0 -38
  50. package/dist/types/briefing/context-docs.test.d.ts +0 -18
  51. package/dist/types/briefing/contract.d.ts +0 -686
  52. package/dist/types/briefing/index.d.ts +0 -29
  53. package/dist/types/briefing/macros.d.ts +0 -206
  54. package/dist/types/briefing/skills.d.ts +0 -67
  55. package/dist/types/capability-deck/bridge-ledger/index.d.ts +0 -25
  56. package/dist/types/capability-deck/bridge-ledger/key.d.ts +0 -65
  57. package/dist/types/capability-deck/bridge-ledger/ledger.d.ts +0 -129
  58. package/dist/types/capability-deck/bridge-ledger/network.d.ts +0 -115
  59. package/dist/types/capability-deck/builtin-bridge.d.ts +0 -114
  60. package/dist/types/capability-deck/capability-deck.test.d.ts +0 -18
  61. package/dist/types/capability-deck/cards/bg-process-card.d.ts +0 -99
  62. package/dist/types/capability-deck/cards/index.d.ts +0 -37
  63. package/dist/types/capability-deck/cards/memory-card.d.ts +0 -68
  64. package/dist/types/capability-deck/cards/plan-file.d.ts +0 -56
  65. package/dist/types/capability-deck/cards/plan-tools.d.ts +0 -97
  66. package/dist/types/capability-deck/cards/plan-tools.test.d.ts +0 -9
  67. package/dist/types/capability-deck/cards/saas-card.d.ts +0 -78
  68. package/dist/types/capability-deck/cards/task-card.d.ts +0 -106
  69. package/dist/types/capability-deck/cards/todo-card.d.ts +0 -78
  70. package/dist/types/capability-deck/cards/workflow-card.d.ts +0 -55
  71. package/dist/types/capability-deck/cards/workflow-card.test.d.ts +0 -12
  72. package/dist/types/capability-deck/checkpoint.int.test.d.ts +0 -25
  73. package/dist/types/capability-deck/contract.d.ts +0 -317
  74. package/dist/types/capability-deck/index.d.ts +0 -46
  75. package/dist/types/capability-deck/manifest.d.ts +0 -60
  76. package/dist/types/capability-deck/provision.d.ts +0 -76
  77. package/dist/types/capability-deck/read-edit-gate.int.test.d.ts +0 -21
  78. package/dist/types/channels/channels.test.d.ts +0 -15
  79. package/dist/types/channels/contract.d.ts +0 -489
  80. package/dist/types/channels/framer.d.ts +0 -49
  81. package/dist/types/channels/index.d.ts +0 -24
  82. package/dist/types/channels/link/dialog.d.ts +0 -138
  83. package/dist/types/channels/link/driver.d.ts +0 -81
  84. package/dist/types/channels/link/index.d.ts +0 -13
  85. package/dist/types/channels/link/server.d.ts +0 -70
  86. package/dist/types/channels/oneshot.d.ts +0 -37
  87. package/dist/types/channels/ops.d.ts +0 -89
  88. package/dist/types/channels/session-ops.d.ts +0 -80
  89. package/dist/types/conductor/bash-guard.d.ts +0 -106
  90. package/dist/types/conductor/bash-guard.test.d.ts +0 -17
  91. package/dist/types/conductor/catalog/catalog.d.ts +0 -87
  92. package/dist/types/conductor/catalog/index.d.ts +0 -14
  93. package/dist/types/conductor/catalog/matcher.d.ts +0 -47
  94. package/dist/types/conductor/conductor.d.ts +0 -189
  95. package/dist/types/conductor/conductor.test.d.ts +0 -10
  96. package/dist/types/conductor/contract.d.ts +0 -774
  97. package/dist/types/conductor/diagnostics.d.ts +0 -183
  98. package/dist/types/conductor/diagnostics.test.d.ts +0 -10
  99. package/dist/types/conductor/index.d.ts +0 -26
  100. package/dist/types/conductor/permission-gate.integration.test.d.ts +0 -22
  101. package/dist/types/conductor/permission-wiring.test.d.ts +0 -14
  102. package/dist/types/conductor/permissions.d.ts +0 -217
  103. package/dist/types/conductor/permissions.test.d.ts +0 -12
  104. package/dist/types/conductor/plan-mode.integration.test.d.ts +0 -23
  105. package/dist/types/conductor/post-edit-diagnostics.test.d.ts +0 -13
  106. package/dist/types/conductor/signal-hub/hub.d.ts +0 -83
  107. package/dist/types/conductor/signal-hub/index.d.ts +0 -19
  108. package/dist/types/conductor/signal-hub/translate.d.ts +0 -77
  109. package/dist/types/conductor/skill-parse/index.d.ts +0 -10
  110. package/dist/types/conductor/skill-parse/parse.d.ts +0 -67
  111. package/dist/types/conductor/submit.test.d.ts +0 -28
  112. package/dist/types/conductor/transcript-store/index.d.ts +0 -16
  113. package/dist/types/conductor/transcript-store/serialize.d.ts +0 -106
  114. package/dist/types/conductor/transcript-store/serialize.test.d.ts +0 -10
  115. package/dist/types/conductor/transcript-store/store.d.ts +0 -188
  116. package/dist/types/console/components/AgentsView.d.ts +0 -41
  117. package/dist/types/console/components/BackgroundAgents.d.ts +0 -63
  118. package/dist/types/console/components/BackgroundAgents.test.d.ts +0 -8
  119. package/dist/types/console/components/Banner.d.ts +0 -110
  120. package/dist/types/console/components/Composer.d.ts +0 -37
  121. package/dist/types/console/components/StatusBar.d.ts +0 -42
  122. package/dist/types/console/components/TerminalConsole.d.ts +0 -32
  123. package/dist/types/console/components/WorkingIndicator.d.ts +0 -44
  124. package/dist/types/console/components/WorkingIndicator.test.d.ts +0 -9
  125. package/dist/types/console/components/banner-sweep.d.ts +0 -55
  126. package/dist/types/console/components/banner.test.d.ts +0 -9
  127. package/dist/types/console/components/welcome.d.ts +0 -115
  128. package/dist/types/console/components/welcome.test.d.ts +0 -9
  129. package/dist/types/console/console.test.d.ts +0 -19
  130. package/dist/types/console/contract.d.ts +0 -598
  131. package/dist/types/console/index.d.ts +0 -34
  132. package/dist/types/console/input/complete.d.ts +0 -120
  133. package/dist/types/console/input/dir-reader.d.ts +0 -28
  134. package/dist/types/console/input/index.d.ts +0 -24
  135. package/dist/types/console/input/input.test.d.ts +0 -14
  136. package/dist/types/console/input/keymap.d.ts +0 -193
  137. package/dist/types/console/input/paste.d.ts +0 -131
  138. package/dist/types/console/mount.d.ts +0 -53
  139. package/dist/types/console/overlays/approval-queue.d.ts +0 -71
  140. package/dist/types/console/overlays/approval.d.ts +0 -104
  141. package/dist/types/console/overlays/approval.test.d.ts +0 -17
  142. package/dist/types/console/overlays/auth.d.ts +0 -31
  143. package/dist/types/console/overlays/boards.d.ts +0 -55
  144. package/dist/types/console/overlays/host.d.ts +0 -45
  145. package/dist/types/console/overlays/index.d.ts +0 -15
  146. package/dist/types/console/overlays/pickers.d.ts +0 -37
  147. package/dist/types/console/overlays/sessions.d.ts +0 -29
  148. package/dist/types/console/reducer.d.ts +0 -51
  149. package/dist/types/console/slash/builtins.d.ts +0 -33
  150. package/dist/types/console/slash/commands/dynamic.d.ts +0 -57
  151. package/dist/types/console/slash/commands/dynamic.test.d.ts +0 -9
  152. package/dist/types/console/slash/commands/integrations.d.ts +0 -28
  153. package/dist/types/console/slash/commands/integrations.test.d.ts +0 -18
  154. package/dist/types/console/slash/commands/shared.d.ts +0 -72
  155. package/dist/types/console/slash/commands/transcript.d.ts +0 -24
  156. package/dist/types/console/slash/commands/transcript.test.d.ts +0 -10
  157. package/dist/types/console/slash/commands/workbench.d.ts +0 -21
  158. package/dist/types/console/slash/commands/workbench.test.d.ts +0 -10
  159. package/dist/types/console/slash/index.d.ts +0 -34
  160. package/dist/types/console/slash/registry.d.ts +0 -90
  161. package/dist/types/console/slash/resolve.d.ts +0 -109
  162. package/dist/types/console/slash/slash.test.d.ts +0 -18
  163. package/dist/types/console/startup.d.ts +0 -119
  164. package/dist/types/console/theme/adapter.d.ts +0 -79
  165. package/dist/types/console/theme/index.d.ts +0 -18
  166. package/dist/types/console/theme/palette.d.ts +0 -77
  167. package/dist/types/console/theme/resolve.d.ts +0 -45
  168. package/dist/types/console/theme/theme.test.d.ts +0 -16
  169. package/dist/types/console/theme/tokens.d.ts +0 -62
  170. package/dist/types/entry.d.ts +0 -17
  171. package/dist/types/guardrails.d.ts +0 -33
  172. package/dist/types/index.d.ts +0 -24
  173. package/dist/types/insight/channel.d.ts +0 -45
  174. package/dist/types/insight/contract.d.ts +0 -411
  175. package/dist/types/insight/index.d.ts +0 -26
  176. package/dist/types/insight/insight.test.d.ts +0 -17
  177. package/dist/types/insight/recorder.d.ts +0 -63
  178. package/dist/types/insight/redaction.d.ts +0 -44
  179. package/dist/types/insight/replay.d.ts +0 -77
  180. package/dist/types/insight/sampling.d.ts +0 -84
  181. package/dist/types/insight/serialize.d.ts +0 -54
  182. package/dist/types/insight/sinks/console.d.ts +0 -36
  183. package/dist/types/insight/sinks/file.d.ts +0 -37
  184. package/dist/types/insight/sinks/index.d.ts +0 -16
  185. package/dist/types/insight/sinks/stream.d.ts +0 -53
  186. package/dist/types/kit/clipboard-image.d.ts +0 -40
  187. package/dist/types/kit/external-editor.d.ts +0 -35
  188. package/dist/types/kit/image.d.ts +0 -102
  189. package/dist/types/kit/index.d.ts +0 -29
  190. package/dist/types/kit/kit.test.d.ts +0 -13
  191. package/dist/types/kit/shell.d.ts +0 -50
  192. package/dist/types/kit/tool-fetch.d.ts +0 -165
  193. package/dist/types/launch/catalog.d.ts +0 -51
  194. package/dist/types/launch/contract.d.ts +0 -387
  195. package/dist/types/launch/credentials.d.ts +0 -112
  196. package/dist/types/launch/index.d.ts +0 -28
  197. package/dist/types/launch/invocation/attachments.d.ts +0 -72
  198. package/dist/types/launch/invocation/flags.d.ts +0 -59
  199. package/dist/types/launch/invocation/index.d.ts +0 -23
  200. package/dist/types/launch/invocation/read.d.ts +0 -52
  201. package/dist/types/launch/invocation/usage.d.ts +0 -25
  202. package/dist/types/launch/launch.test.d.ts +0 -20
  203. package/dist/types/launch/oauth.d.ts +0 -101
  204. package/dist/types/launch/packages.d.ts +0 -75
  205. package/dist/types/launch/packages.test.d.ts +0 -15
  206. package/dist/types/launch/pickers.d.ts +0 -97
  207. package/dist/types/runtime-bridge/bridges/_drive.d.ts +0 -74
  208. package/dist/types/runtime-bridge/bridges/builtins.d.ts +0 -77
  209. package/dist/types/runtime-bridge/bridges/claude-cli.d.ts +0 -37
  210. package/dist/types/runtime-bridge/bridges/codex-cli.d.ts +0 -27
  211. package/dist/types/runtime-bridge/bridges/index.d.ts +0 -15
  212. package/dist/types/runtime-bridge/bridges/indusagi-cli.d.ts +0 -36
  213. package/dist/types/runtime-bridge/broker.d.ts +0 -182
  214. package/dist/types/runtime-bridge/contract.d.ts +0 -436
  215. package/dist/types/runtime-bridge/index.d.ts +0 -21
  216. package/dist/types/runtime-bridge/runtime-bridge.test.d.ts +0 -17
  217. package/dist/types/runtime-bridge/sink.d.ts +0 -59
  218. package/dist/types/sessions/contract.d.ts +0 -79
  219. package/dist/types/sessions/index.d.ts +0 -11
  220. package/dist/types/sessions/library.d.ts +0 -95
  221. package/dist/types/sessions/sessions.test.d.ts +0 -11
  222. package/dist/types/settings/contract.d.ts +0 -175
  223. package/dist/types/settings/index.d.ts +0 -13
  224. package/dist/types/settings/manager.d.ts +0 -109
  225. package/dist/types/settings/settings.test.d.ts +0 -16
  226. package/dist/types/transcript-export/index.d.ts +0 -20
  227. package/dist/types/transcript-export/publish.d.ts +0 -81
  228. package/dist/types/transcript-export/sgr.d.ts +0 -90
  229. package/dist/types/transcript-export/template.d.ts +0 -64
  230. package/dist/types/transcript-export/theme-bridge.d.ts +0 -99
  231. package/dist/types/transcript-export/transcript-export.test.d.ts +0 -16
  232. package/dist/types/window-budget/budget/estimate.d.ts +0 -47
  233. package/dist/types/window-budget/budget/gate.d.ts +0 -37
  234. package/dist/types/window-budget/budget/index.d.ts +0 -14
  235. package/dist/types/window-budget/budget/slice.d.ts +0 -38
  236. package/dist/types/window-budget/condenser.d.ts +0 -73
  237. package/dist/types/window-budget/contract.d.ts +0 -182
  238. package/dist/types/window-budget/index.d.ts +0 -17
  239. package/dist/types/window-budget/microcompact.d.ts +0 -68
  240. package/dist/types/window-budget/microcompact.test.d.ts +0 -16
  241. package/dist/types/window-budget/rehydrate.d.ts +0 -56
  242. package/dist/types/window-budget/summarize/condense.d.ts +0 -70
  243. package/dist/types/window-budget/summarize/index.d.ts +0 -12
  244. package/dist/types/window-budget/summarize/prompt.d.ts +0 -56
  245. package/dist/types/window-budget/window-budget.test.d.ts +0 -18
  246. package/dist/types/workflow-engine/agent-runner.d.ts +0 -105
  247. package/dist/types/workflow-engine/agent-runner.test.d.ts +0 -8
  248. package/dist/types/workflow-engine/display.d.ts +0 -148
  249. package/dist/types/workflow-engine/display.test.d.ts +0 -1
  250. package/dist/types/workflow-engine/engine.d.ts +0 -183
  251. package/dist/types/workflow-engine/engine.test.d.ts +0 -1
  252. package/dist/types/workflow-engine/index.d.ts +0 -21
  253. package/dist/types/workflow-engine/parse.d.ts +0 -64
  254. package/dist/types/workflow-engine/parse.test.d.ts +0 -1
  255. package/dist/types/workflow-engine/structured-output.d.ts +0 -51
  256. package/dist/types/workflow-engine/structured-output.test.d.ts +0 -1
  257. package/dist/types/workspace/brand.d.ts +0 -26
  258. package/dist/types/workspace/index.d.ts +0 -11
  259. package/dist/types/workspace/locator.d.ts +0 -50
  260. package/dist/types/workspace/runtime-detect.d.ts +0 -56
@@ -1,148 +0,0 @@
1
- /**
2
- * Workflow progress snapshot model + text renderer.
3
- *
4
- * The engine emits lifecycle callbacks (phase started, agent started/ended,
5
- * log) which a host folds into a {@link WorkflowSnapshot}. This module owns the
6
- * snapshot's pure data shape, the two pure recompute helpers, and the
7
- * `renderWorkflowText` / `renderWorkflowLines` renderers that turn a snapshot
8
- * into the `◆ Workflow:` progress tree shown live in the tool result.
9
- *
10
- * The renderer is a verbatim behavioral port of pi-dynamic-workflows'
11
- * `src/display.ts` — same `◆ Workflow: name (x/y done)` header, same per-phase
12
- * `▶/✓` markers with `done/total · running · errors · skipped` counts, same
13
- * ` #id <glyph> label` subagent rows, same status glyphs
14
- * (`○ queued`, `● running`, `✓ done`, `✗ error`, `- skipped`), same "Unphased"
15
- * group, same trailing `log:` lines.
16
- *
17
- * Unlike pi, this file carries NO framework-UI bindings (no `ExtensionContext`,
18
- * no widget display). The card/console wiring that consumes these renderers
19
- * lands in stage 2; here we expose only the pure snapshot + string surface.
20
- */
21
- import type { WorkflowMeta } from "./parse";
22
- /** Lifecycle status of a single workflow subagent row. */
23
- export type WorkflowAgentStatus = "queued" | "running" | "done" | "error" | "skipped";
24
- /** One subagent's row in the live progress tree. */
25
- export interface WorkflowAgentSnapshot {
26
- /** 1-based id, the order the agent started in. */
27
- id: number;
28
- /** Short human label for the agent (defaulted from phase + index if absent). */
29
- label: string;
30
- /** The phase the agent belongs to, if any. */
31
- phase?: string;
32
- /** The task prompt the agent was given. */
33
- prompt: string;
34
- /** Current lifecycle status. */
35
- status: WorkflowAgentStatus;
36
- /** Optional short preview of the agent's result. */
37
- resultPreview?: string;
38
- /** Optional error summary when the agent failed or was skipped. */
39
- error?: string;
40
- /** Wall-clock ms when the subagent started (for the live elapsed counter). */
41
- startedAt?: number;
42
- /** Wall-clock ms when the subagent settled (caps the elapsed counter). */
43
- endedAt?: number;
44
- /** Cumulative input tokens the subagent has spent. */
45
- tokensIn?: number;
46
- /** Cumulative output tokens the subagent has spent. */
47
- tokensOut?: number;
48
- /** How many tool calls the subagent has started. */
49
- toolCount?: number;
50
- /** The tool the subagent is running right now, if any. */
51
- currentTool?: string;
52
- /** The last tool the subagent finished (when nothing is running). */
53
- lastTool?: string;
54
- }
55
- /** The full live progress model for one workflow run. */
56
- export interface WorkflowSnapshot {
57
- /** Workflow name (from `meta.name`). */
58
- name: string;
59
- /** Workflow description (from `meta.description`). */
60
- description?: string;
61
- /** Declared/observed phase titles, in order. */
62
- phases: string[];
63
- /** The phase currently active (last `phase()` call). */
64
- currentPhase?: string;
65
- /** Log lines emitted via `log()`. */
66
- logs: string[];
67
- /** Every subagent row, in start order. */
68
- agents: WorkflowAgentSnapshot[];
69
- /** Total agents seen. */
70
- agentCount: number;
71
- /** Agents currently running. */
72
- runningCount: number;
73
- /** Agents finished successfully. */
74
- doneCount: number;
75
- /** Agents that errored. */
76
- errorCount: number;
77
- /** Total run duration once complete. */
78
- durationMs?: number;
79
- /** The workflow's final returned value once complete. */
80
- result?: unknown;
81
- }
82
- /** Tunables for the text renderer (how much of the tree to show). */
83
- export interface WorkflowDisplayOptions {
84
- /** Max subagent rows shown per phase (most recent kept). Default 8. */
85
- maxAgents?: number;
86
- /** Max trailing log lines shown. Default 2. */
87
- maxLogs?: number;
88
- /** Append a short result preview to each agent row. Default false. */
89
- showResultPreviews?: boolean;
90
- /**
91
- * Soft cap on total tree lines for the LIVE render. Default 9 — headroom under
92
- * the framework `TaskPanel` 10-line clamp so a running agent is never cut off
93
- * by a trailing `…`. Completed phases collapse to one line each, and if the
94
- * tree is still over budget the OLDEST completed phases collapse into a single
95
- * `… N earlier phases done` line (running/current phases are never collapsed).
96
- * Pass a large value (e.g. the settled/final render, or Ctrl+O expand) to show
97
- * everything in full.
98
- */
99
- maxLines?: number;
100
- }
101
- /**
102
- * Build an empty snapshot for a freshly parsed workflow `meta`.
103
- *
104
- * @param meta the workflow header
105
- */
106
- export declare function createWorkflowSnapshot(meta: WorkflowMeta): WorkflowSnapshot;
107
- /**
108
- * Recompute the derived counts (`agentCount`/`runningCount`/`doneCount`/
109
- * `errorCount`) from the `agents` array. Pure — returns a new snapshot.
110
- *
111
- * @param snapshot the snapshot whose counts to refresh
112
- */
113
- export declare function recomputeWorkflowSnapshot(snapshot: WorkflowSnapshot): WorkflowSnapshot;
114
- /**
115
- * Render the snapshot as the `◆ Workflow:` progress tree (array of lines).
116
- *
117
- * The per-agent metrics segment (elapsed seconds, token spend, tool activity) is
118
- * computed at render time from `now` so the seconds tick on every render even
119
- * during a long silent tool call. Keep `now` an explicit param so the renderer
120
- * stays pure and testable.
121
- *
122
- * @param snapshot the progress model
123
- * @param options render tunables
124
- * @param now the current wall-clock ms used to compute live elapsed seconds
125
- */
126
- export declare function renderWorkflowLines(snapshot: WorkflowSnapshot, options?: WorkflowDisplayOptions, now?: number): string[];
127
- /**
128
- * Render the snapshot as a single string for the tool result.
129
- *
130
- * For the LIVE (not-completed) render the `◆ Workflow:` header already says the
131
- * run is in progress, so no extra header line is added — this saves a line under
132
- * the framework `TaskPanel` 10-line clamp. The final (completed) render keeps the
133
- * explicit `Workflow completed` header.
134
- *
135
- * @param snapshot the progress model
136
- * @param completed whether the run has finished
137
- * @param options render tunables
138
- * @param now the current wall-clock ms used to compute live elapsed seconds
139
- */
140
- export declare function renderWorkflowText(snapshot: WorkflowSnapshot, completed?: boolean, options?: WorkflowDisplayOptions, now?: number): string;
141
- /**
142
- * One-line preview of an arbitrary result value (string passthrough, else
143
- * JSON), truncated to `max` chars. Used to fill `resultPreview`.
144
- *
145
- * @param value the result to preview
146
- * @param max max preview length
147
- */
148
- export declare function preview(value: unknown, max?: number): string;
@@ -1 +0,0 @@
1
- export {};
@@ -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.3";
@@ -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;