voratiq 0.1.0-beta.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (302) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +59 -0
  3. package/dist/auth/providers/claude/constants.d.ts +7 -0
  4. package/dist/auth/providers/claude/constants.js +9 -0
  5. package/dist/auth/providers/claude/credentials.d.ts +5 -0
  6. package/dist/auth/providers/claude/credentials.js +112 -0
  7. package/dist/auth/providers/claude/error.d.ts +5 -0
  8. package/dist/auth/providers/claude/error.js +6 -0
  9. package/dist/auth/providers/claude/keychain.d.ts +4 -0
  10. package/dist/auth/providers/claude/keychain.js +158 -0
  11. package/dist/auth/providers/claude.d.ts +2 -0
  12. package/dist/auth/providers/claude.js +124 -0
  13. package/dist/auth/providers/codex.d.ts +2 -0
  14. package/dist/auth/providers/codex.js +93 -0
  15. package/dist/auth/providers/gemini.d.ts +2 -0
  16. package/dist/auth/providers/gemini.js +159 -0
  17. package/dist/auth/providers/index.d.ts +2 -0
  18. package/dist/auth/providers/index.js +16 -0
  19. package/dist/auth/providers/messages.d.ts +1 -0
  20. package/dist/auth/providers/messages.js +3 -0
  21. package/dist/auth/providers/secret-staging.d.ts +14 -0
  22. package/dist/auth/providers/secret-staging.js +72 -0
  23. package/dist/auth/providers/teardown.d.ts +2 -0
  24. package/dist/auth/providers/teardown.js +6 -0
  25. package/dist/auth/providers/types.d.ts +31 -0
  26. package/dist/auth/providers/types.js +1 -0
  27. package/dist/auth/providers/utils.d.ts +20 -0
  28. package/dist/auth/providers/utils.js +148 -0
  29. package/dist/auth/runtime.d.ts +2 -0
  30. package/dist/auth/runtime.js +17 -0
  31. package/dist/auth/staging.d.ts +8 -0
  32. package/dist/auth/staging.js +7 -0
  33. package/dist/bin.d.ts +2 -0
  34. package/dist/bin.js +142 -0
  35. package/dist/cli/apply.d.ts +14 -0
  36. package/dist/cli/apply.js +38 -0
  37. package/dist/cli/commander-utils.d.ts +3 -0
  38. package/dist/cli/commander-utils.js +27 -0
  39. package/dist/cli/confirmation.d.ts +14 -0
  40. package/dist/cli/confirmation.js +16 -0
  41. package/dist/cli/errors.d.ts +5 -0
  42. package/dist/cli/errors.js +16 -0
  43. package/dist/cli/init.d.ts +10 -0
  44. package/dist/cli/init.js +41 -0
  45. package/dist/cli/list.d.ts +14 -0
  46. package/dist/cli/list.js +48 -0
  47. package/dist/cli/output.d.ts +14 -0
  48. package/dist/cli/output.js +62 -0
  49. package/dist/cli/prune.d.ts +14 -0
  50. package/dist/cli/prune.js +54 -0
  51. package/dist/cli/review.d.ts +12 -0
  52. package/dist/cli/review.js +33 -0
  53. package/dist/cli/run.d.ts +13 -0
  54. package/dist/cli/run.js +51 -0
  55. package/dist/commands/apply/command.d.ts +9 -0
  56. package/dist/commands/apply/command.js +135 -0
  57. package/dist/commands/apply/errors.d.ts +35 -0
  58. package/dist/commands/apply/errors.js +73 -0
  59. package/dist/commands/apply/types.d.ts +13 -0
  60. package/dist/commands/apply/types.js +1 -0
  61. package/dist/commands/errors.d.ts +4 -0
  62. package/dist/commands/errors.js +7 -0
  63. package/dist/commands/fetch.d.ts +8 -0
  64. package/dist/commands/fetch.js +25 -0
  65. package/dist/commands/init/agents.d.ts +3 -0
  66. package/dist/commands/init/agents.js +159 -0
  67. package/dist/commands/init/command.d.ts +2 -0
  68. package/dist/commands/init/command.js +40 -0
  69. package/dist/commands/init/environment.d.ts +2 -0
  70. package/dist/commands/init/environment.js +76 -0
  71. package/dist/commands/init/evals.d.ts +4 -0
  72. package/dist/commands/init/evals.js +219 -0
  73. package/dist/commands/init/types.d.ts +48 -0
  74. package/dist/commands/init/types.js +1 -0
  75. package/dist/commands/list/command.d.ts +13 -0
  76. package/dist/commands/list/command.js +60 -0
  77. package/dist/commands/prune/command.d.ts +2 -0
  78. package/dist/commands/prune/command.js +336 -0
  79. package/dist/commands/prune/errors.d.ts +20 -0
  80. package/dist/commands/prune/errors.js +39 -0
  81. package/dist/commands/prune/types.d.ts +42 -0
  82. package/dist/commands/prune/types.js +1 -0
  83. package/dist/commands/review/command.d.ts +10 -0
  84. package/dist/commands/review/command.js +26 -0
  85. package/dist/commands/run/agent-execution.d.ts +19 -0
  86. package/dist/commands/run/agent-execution.js +63 -0
  87. package/dist/commands/run/agents/auth-stage.d.ts +23 -0
  88. package/dist/commands/run/agents/auth-stage.js +108 -0
  89. package/dist/commands/run/agents/chat-preserver.d.ts +9 -0
  90. package/dist/commands/run/agents/chat-preserver.js +35 -0
  91. package/dist/commands/run/agents/eval-runner.d.ts +19 -0
  92. package/dist/commands/run/agents/eval-runner.js +27 -0
  93. package/dist/commands/run/agents/failures.d.ts +7 -0
  94. package/dist/commands/run/agents/failures.js +32 -0
  95. package/dist/commands/run/agents/lifecycle.d.ts +9 -0
  96. package/dist/commands/run/agents/lifecycle.js +157 -0
  97. package/dist/commands/run/agents/preparation.d.ts +2 -0
  98. package/dist/commands/run/agents/preparation.js +123 -0
  99. package/dist/commands/run/agents/run-context.d.ts +46 -0
  100. package/dist/commands/run/agents/run-context.js +193 -0
  101. package/dist/commands/run/agents/sandbox-launcher.d.ts +44 -0
  102. package/dist/commands/run/agents/sandbox-launcher.js +211 -0
  103. package/dist/commands/run/agents/types.d.ts +47 -0
  104. package/dist/commands/run/agents/types.js +1 -0
  105. package/dist/commands/run/agents/watchdog.d.ts +39 -0
  106. package/dist/commands/run/agents/watchdog.js +172 -0
  107. package/dist/commands/run/agents/workspace-prep.d.ts +17 -0
  108. package/dist/commands/run/agents/workspace-prep.js +78 -0
  109. package/dist/commands/run/agents.d.ts +14 -0
  110. package/dist/commands/run/agents.js +47 -0
  111. package/dist/commands/run/argv.d.ts +1 -0
  112. package/dist/commands/run/argv.js +19 -0
  113. package/dist/commands/run/command.d.ts +14 -0
  114. package/dist/commands/run/command.js +170 -0
  115. package/dist/commands/run/errors.d.ts +61 -0
  116. package/dist/commands/run/errors.js +86 -0
  117. package/dist/commands/run/id.d.ts +1 -0
  118. package/dist/commands/run/id.js +22 -0
  119. package/dist/commands/run/lifecycle.d.ts +19 -0
  120. package/dist/commands/run/lifecycle.js +186 -0
  121. package/dist/commands/run/phases.d.ts +11 -0
  122. package/dist/commands/run/phases.js +1 -0
  123. package/dist/commands/run/prompts.d.ts +4 -0
  124. package/dist/commands/run/prompts.js +16 -0
  125. package/dist/commands/run/record-init.d.ts +15 -0
  126. package/dist/commands/run/record-init.js +29 -0
  127. package/dist/commands/run/reports.d.ts +14 -0
  128. package/dist/commands/run/reports.js +63 -0
  129. package/dist/commands/run/sandbox-registry.d.ts +4 -0
  130. package/dist/commands/run/sandbox-registry.js +54 -0
  131. package/dist/commands/run/sandbox.d.ts +16 -0
  132. package/dist/commands/run/sandbox.js +96 -0
  133. package/dist/commands/run/shim/agent-manifest.d.ts +7 -0
  134. package/dist/commands/run/shim/agent-manifest.js +1 -0
  135. package/dist/commands/run/shim/run-agent-shim.d.ts +1 -0
  136. package/dist/commands/run/shim/run-agent-shim.js +232 -0
  137. package/dist/commands/run/shim/run-agent-shim.mjs +10 -0
  138. package/dist/commands/run/validation.d.ts +20 -0
  139. package/dist/commands/run/validation.js +60 -0
  140. package/dist/configs/agents/defaults.d.ts +9 -0
  141. package/dist/configs/agents/defaults.js +55 -0
  142. package/dist/configs/agents/errors.d.ts +40 -0
  143. package/dist/configs/agents/errors.js +78 -0
  144. package/dist/configs/agents/loader.d.ts +8 -0
  145. package/dist/configs/agents/loader.js +137 -0
  146. package/dist/configs/agents/types.d.ts +39 -0
  147. package/dist/configs/agents/types.js +31 -0
  148. package/dist/configs/environment/detect.d.ts +17 -0
  149. package/dist/configs/environment/detect.js +79 -0
  150. package/dist/configs/environment/errors.d.ts +12 -0
  151. package/dist/configs/environment/errors.js +26 -0
  152. package/dist/configs/environment/loader.d.ts +10 -0
  153. package/dist/configs/environment/loader.js +80 -0
  154. package/dist/configs/environment/types.d.ts +21 -0
  155. package/dist/configs/environment/types.js +98 -0
  156. package/dist/configs/evals/defaults.d.ts +8 -0
  157. package/dist/configs/evals/defaults.js +28 -0
  158. package/dist/configs/evals/detect.d.ts +10 -0
  159. package/dist/configs/evals/detect.js +224 -0
  160. package/dist/configs/evals/errors.d.ts +16 -0
  161. package/dist/configs/evals/errors.js +29 -0
  162. package/dist/configs/evals/loader.d.ts +9 -0
  163. package/dist/configs/evals/loader.js +46 -0
  164. package/dist/configs/evals/types.d.ts +42 -0
  165. package/dist/configs/evals/types.js +74 -0
  166. package/dist/configs/sandbox/defaults.d.ts +14 -0
  167. package/dist/configs/sandbox/defaults.js +54 -0
  168. package/dist/configs/sandbox/errors.d.ts +5 -0
  169. package/dist/configs/sandbox/errors.js +8 -0
  170. package/dist/configs/sandbox/loader.d.ts +6 -0
  171. package/dist/configs/sandbox/loader.js +192 -0
  172. package/dist/configs/sandbox/merge.d.ts +9 -0
  173. package/dist/configs/sandbox/merge.js +94 -0
  174. package/dist/configs/sandbox/schemas.d.ts +58 -0
  175. package/dist/configs/sandbox/schemas.js +72 -0
  176. package/dist/configs/sandbox/types.d.ts +34 -0
  177. package/dist/configs/sandbox/types.js +1 -0
  178. package/dist/configs/shared/loader-factory.d.ts +19 -0
  179. package/dist/configs/shared/loader-factory.js +33 -0
  180. package/dist/configs/shared/yaml-error-formatter.d.ts +40 -0
  181. package/dist/configs/shared/yaml-error-formatter.js +41 -0
  182. package/dist/evals/runner.d.ts +16 -0
  183. package/dist/evals/runner.js +132 -0
  184. package/dist/preflight/errors.d.ts +10 -0
  185. package/dist/preflight/errors.js +21 -0
  186. package/dist/preflight/index.d.ts +30 -0
  187. package/dist/preflight/index.js +157 -0
  188. package/dist/records/enhanced.d.ts +38 -0
  189. package/dist/records/enhanced.js +139 -0
  190. package/dist/records/errors.d.ts +23 -0
  191. package/dist/records/errors.js +43 -0
  192. package/dist/records/history-lock.d.ts +27 -0
  193. package/dist/records/history-lock.js +184 -0
  194. package/dist/records/mutators.d.ts +17 -0
  195. package/dist/records/mutators.js +144 -0
  196. package/dist/records/persistence.d.ts +95 -0
  197. package/dist/records/persistence.js +459 -0
  198. package/dist/records/types.d.ts +238 -0
  199. package/dist/records/types.js +131 -0
  200. package/dist/render/interactions/confirmation.d.ts +19 -0
  201. package/dist/render/interactions/confirmation.js +63 -0
  202. package/dist/render/transcripts/apply.d.ts +2 -0
  203. package/dist/render/transcripts/apply.js +52 -0
  204. package/dist/render/transcripts/init.d.ts +18 -0
  205. package/dist/render/transcripts/init.js +84 -0
  206. package/dist/render/transcripts/list.d.ts +3 -0
  207. package/dist/render/transcripts/list.js +44 -0
  208. package/dist/render/transcripts/prune.d.ts +16 -0
  209. package/dist/render/transcripts/prune.js +50 -0
  210. package/dist/render/transcripts/review.d.ts +2 -0
  211. package/dist/render/transcripts/review.js +36 -0
  212. package/dist/render/transcripts/run.d.ts +25 -0
  213. package/dist/render/transcripts/run.js +295 -0
  214. package/dist/render/transcripts/shared.d.ts +12 -0
  215. package/dist/render/transcripts/shared.js +41 -0
  216. package/dist/render/utils/agents.d.ts +28 -0
  217. package/dist/render/utils/agents.js +261 -0
  218. package/dist/render/utils/badges.d.ts +20 -0
  219. package/dist/render/utils/badges.js +37 -0
  220. package/dist/render/utils/errors.d.ts +2 -0
  221. package/dist/render/utils/errors.js +14 -0
  222. package/dist/render/utils/records.d.ts +1 -0
  223. package/dist/render/utils/records.js +32 -0
  224. package/dist/render/utils/runs.d.ts +16 -0
  225. package/dist/render/utils/runs.js +50 -0
  226. package/dist/render/utils/table.d.ts +12 -0
  227. package/dist/render/utils/table.js +32 -0
  228. package/dist/render/utils/transcript.d.ts +14 -0
  229. package/dist/render/utils/transcript.js +44 -0
  230. package/dist/status/colors.d.ts +10 -0
  231. package/dist/status/colors.js +33 -0
  232. package/dist/status/index.d.ts +37 -0
  233. package/dist/status/index.js +30 -0
  234. package/dist/testing/test-hooks.d.ts +7 -0
  235. package/dist/testing/test-hooks.js +16 -0
  236. package/dist/utils/binaries.d.ts +1 -0
  237. package/dist/utils/binaries.js +13 -0
  238. package/dist/utils/cli-root.d.ts +2 -0
  239. package/dist/utils/cli-root.js +42 -0
  240. package/dist/utils/colors.d.ts +2 -0
  241. package/dist/utils/colors.js +23 -0
  242. package/dist/utils/diff.d.ts +9 -0
  243. package/dist/utils/diff.js +61 -0
  244. package/dist/utils/env.d.ts +10 -0
  245. package/dist/utils/env.js +56 -0
  246. package/dist/utils/errors.d.ts +31 -0
  247. package/dist/utils/errors.js +53 -0
  248. package/dist/utils/fs.d.ts +13 -0
  249. package/dist/utils/fs.js +70 -0
  250. package/dist/utils/git.d.ts +40 -0
  251. package/dist/utils/git.js +126 -0
  252. package/dist/utils/output.d.ts +4 -0
  253. package/dist/utils/output.js +12 -0
  254. package/dist/utils/path.d.ts +11 -0
  255. package/dist/utils/path.js +84 -0
  256. package/dist/utils/process.d.ts +37 -0
  257. package/dist/utils/process.js +152 -0
  258. package/dist/utils/terminal.d.ts +5 -0
  259. package/dist/utils/terminal.js +5 -0
  260. package/dist/utils/validators.d.ts +1 -0
  261. package/dist/utils/validators.js +15 -0
  262. package/dist/utils/version.d.ts +1 -0
  263. package/dist/utils/version.js +25 -0
  264. package/dist/utils/yaml-reader.d.ts +14 -0
  265. package/dist/utils/yaml-reader.js +41 -0
  266. package/dist/utils/yaml.d.ts +33 -0
  267. package/dist/utils/yaml.js +75 -0
  268. package/dist/workspace/agents.d.ts +33 -0
  269. package/dist/workspace/agents.js +189 -0
  270. package/dist/workspace/chat/artifacts.d.ts +14 -0
  271. package/dist/workspace/chat/artifacts.js +157 -0
  272. package/dist/workspace/chat/sources.d.ts +5 -0
  273. package/dist/workspace/chat/sources.js +80 -0
  274. package/dist/workspace/chat/types.d.ts +1 -0
  275. package/dist/workspace/chat/types.js +1 -0
  276. package/dist/workspace/cleanup.d.ts +4 -0
  277. package/dist/workspace/cleanup.js +12 -0
  278. package/dist/workspace/credential-guard.d.ts +4 -0
  279. package/dist/workspace/credential-guard.js +71 -0
  280. package/dist/workspace/dependencies.d.ts +23 -0
  281. package/dist/workspace/dependencies.js +190 -0
  282. package/dist/workspace/errors.d.ts +16 -0
  283. package/dist/workspace/errors.js +43 -0
  284. package/dist/workspace/layout.d.ts +30 -0
  285. package/dist/workspace/layout.js +124 -0
  286. package/dist/workspace/prune.d.ts +8 -0
  287. package/dist/workspace/prune.js +29 -0
  288. package/dist/workspace/run.d.ts +14 -0
  289. package/dist/workspace/run.js +28 -0
  290. package/dist/workspace/sandbox-requirements.d.ts +17 -0
  291. package/dist/workspace/sandbox-requirements.js +69 -0
  292. package/dist/workspace/setup.d.ts +3 -0
  293. package/dist/workspace/setup.js +81 -0
  294. package/dist/workspace/shim.d.ts +4 -0
  295. package/dist/workspace/shim.js +65 -0
  296. package/dist/workspace/structure.d.ts +77 -0
  297. package/dist/workspace/structure.js +134 -0
  298. package/dist/workspace/templates.d.ts +9 -0
  299. package/dist/workspace/templates.js +66 -0
  300. package/dist/workspace/types.d.ts +4 -0
  301. package/dist/workspace/types.js +1 -0
  302. package/package.json +82 -0
@@ -0,0 +1,295 @@
1
+ import { getEvalStatusStyle } from "../../status/colors.js";
2
+ import { colorize } from "../../utils/colors.js";
3
+ import { formatCompactDiffStatistics } from "../../utils/diff.js";
4
+ import { formatAgentDuration, formatAgentStatusLabel, formatDurationLabel, } from "../utils/agents.js";
5
+ import { formatAgentBadge } from "../utils/badges.js";
6
+ import { formatRunTimestamp } from "../utils/records.js";
7
+ import { buildRunMetadataSection } from "../utils/runs.js";
8
+ import { renderTable } from "../utils/table.js";
9
+ import { renderTranscript } from "../utils/transcript.js";
10
+ const SUPPRESS_RUN_STATUS_TABLE_ENV = "VORATIQ_SUPPRESS_RUN_STATUS_TABLE";
11
+ function shouldSuppressRunStatusTable() {
12
+ const flag = process.env[SUPPRESS_RUN_STATUS_TABLE_ENV];
13
+ return flag === "1" || flag?.toLowerCase() === "true";
14
+ }
15
+ const ERASE_LINE = "\u001b[2K";
16
+ const CURSOR_COLUMN_START = "\u001b[0G";
17
+ function cursorUp(lines) {
18
+ return `\u001b[${lines}F`;
19
+ }
20
+ const DASH = "—";
21
+ function formatErrorDetail(error) {
22
+ if (error instanceof Error) {
23
+ return error.message;
24
+ }
25
+ if (typeof error === "string") {
26
+ return error;
27
+ }
28
+ if (error === null || error === undefined) {
29
+ return "unknown error";
30
+ }
31
+ if (typeof error === "number" ||
32
+ typeof error === "boolean" ||
33
+ typeof error === "bigint") {
34
+ return `${error}`;
35
+ }
36
+ if (typeof error === "symbol") {
37
+ return error.description ?? error.toString();
38
+ }
39
+ if (typeof error === "object") {
40
+ try {
41
+ const serialized = JSON.stringify(error);
42
+ if (serialized) {
43
+ return serialized;
44
+ }
45
+ }
46
+ catch {
47
+ // ignore JSON serialization failures; fall through to default message.
48
+ }
49
+ }
50
+ return "unknown error";
51
+ }
52
+ export function createRunRenderer(options = {}) {
53
+ const stdout = options.stdout ?? process.stdout;
54
+ const stderr = options.stderr ?? process.stderr;
55
+ const now = options.now ?? Date.now.bind(Date);
56
+ let context;
57
+ let disabled = shouldSuppressRunStatusTable();
58
+ let warningLogged = false;
59
+ let lastRenderedLines = 0;
60
+ let blockInitialized = false;
61
+ let metadataPrinted = false;
62
+ const agentOrder = [];
63
+ const agentRecords = new Map();
64
+ function guard(action) {
65
+ if (disabled) {
66
+ return;
67
+ }
68
+ try {
69
+ action();
70
+ }
71
+ catch (error) {
72
+ disabled = true;
73
+ if (!warningLogged) {
74
+ warningLogged = true;
75
+ const detail = formatErrorDetail(error);
76
+ stderr.write(`[voratiq] Progressive run output disabled: ${detail}\n`);
77
+ }
78
+ }
79
+ }
80
+ function buildInteractiveLines(metadataLines, tableLines) {
81
+ if (metadataLines.length === 0) {
82
+ return [];
83
+ }
84
+ const lines = [""];
85
+ lines.push(...metadataLines);
86
+ if (tableLines.length > 0) {
87
+ lines.push("");
88
+ lines.push(...tableLines);
89
+ }
90
+ lines.push("");
91
+ return lines;
92
+ }
93
+ function buildTableRefreshLines(tableLines) {
94
+ if (tableLines.length === 0) {
95
+ return [];
96
+ }
97
+ return ["", ...tableLines, ""];
98
+ }
99
+ function render() {
100
+ if (!context || disabled) {
101
+ return;
102
+ }
103
+ const metadataLines = buildRunMetadataSection({
104
+ runId: context.runId,
105
+ status: context.status,
106
+ specPath: context.specPath,
107
+ workspacePath: context.workspacePath,
108
+ createdAt: formatRunTimestamp(context.createdAt),
109
+ baseRevisionSha: context.baseRevisionSha,
110
+ });
111
+ const tableLines = buildAgentTable();
112
+ const shouldIncludeTable = tableLines.length > 0;
113
+ const interactiveLines = buildInteractiveLines(metadataLines, tableLines);
114
+ if (stdout.isTTY) {
115
+ if (interactiveLines.length === 0) {
116
+ return;
117
+ }
118
+ if (!blockInitialized) {
119
+ stdout.write(interactiveLines.join("\n"));
120
+ lastRenderedLines = interactiveLines.length;
121
+ blockInitialized = true;
122
+ return;
123
+ }
124
+ const linesToRewind = Math.max(0, lastRenderedLines - 1);
125
+ if (linesToRewind > 0) {
126
+ stdout.write(cursorUp(linesToRewind));
127
+ }
128
+ stdout.write(CURSOR_COLUMN_START);
129
+ const totalLines = Math.max(lastRenderedLines, interactiveLines.length);
130
+ const rewrittenLines = [];
131
+ for (let index = 0; index < totalLines; index += 1) {
132
+ const line = interactiveLines[index] ?? "";
133
+ rewrittenLines.push(CURSOR_COLUMN_START, ERASE_LINE, line);
134
+ if (index < totalLines - 1) {
135
+ rewrittenLines.push("\n");
136
+ }
137
+ }
138
+ stdout.write(rewrittenLines.join(""));
139
+ lastRenderedLines = totalLines;
140
+ return;
141
+ }
142
+ if (!metadataPrinted) {
143
+ if (interactiveLines.length > 0) {
144
+ stdout.write(interactiveLines.join("\n"));
145
+ }
146
+ metadataPrinted = true;
147
+ return;
148
+ }
149
+ if (!shouldIncludeTable) {
150
+ return;
151
+ }
152
+ const refreshLines = buildTableRefreshLines(tableLines);
153
+ if (refreshLines.length > 0) {
154
+ stdout.write(refreshLines.join("\n"));
155
+ }
156
+ }
157
+ function buildAgentTable() {
158
+ if (agentRecords.size === 0) {
159
+ return [];
160
+ }
161
+ const rows = agentOrder
162
+ .filter((agentId) => agentRecords.has(agentId))
163
+ .map((agentId) => {
164
+ const record = agentRecords.get(agentId);
165
+ return {
166
+ agentId: formatAgentBadge(agentId),
167
+ status: formatAgentStatusLabel(record.status),
168
+ elapsed: formatElapsed(record),
169
+ diff: formatDiffCell(record.diffStatistics),
170
+ evals: formatEvals(record),
171
+ };
172
+ });
173
+ return renderTable({
174
+ columns: [
175
+ { header: "AGENT", accessor: (row) => row.agentId },
176
+ { header: "STATUS", accessor: (row) => row.status },
177
+ { header: "ELAPSED", accessor: (row) => row.elapsed },
178
+ { header: "CHANGES", accessor: (row) => row.diff },
179
+ { header: "EVALS", accessor: (row) => row.evals },
180
+ ],
181
+ rows,
182
+ });
183
+ }
184
+ function formatDiffCell(value) {
185
+ const compact = formatCompactDiffStatistics(value);
186
+ if (compact) {
187
+ return compact;
188
+ }
189
+ return value ?? DASH;
190
+ }
191
+ function formatElapsed(record) {
192
+ if (!record.startedAt) {
193
+ return DASH;
194
+ }
195
+ const started = Date.parse(record.startedAt);
196
+ if (Number.isNaN(started)) {
197
+ return DASH;
198
+ }
199
+ if (!record.completedAt && record.status === "running") {
200
+ const elapsedMs = Math.max(0, now() - started);
201
+ const formattedElapsed = formatDurationLabel(elapsedMs);
202
+ return formattedElapsed ?? DASH;
203
+ }
204
+ if (!record.completedAt) {
205
+ return DASH;
206
+ }
207
+ const formatted = formatAgentDuration({
208
+ agentId: record.agentId,
209
+ status: record.status,
210
+ startedAt: record.startedAt,
211
+ completedAt: record.completedAt,
212
+ });
213
+ if (formatted) {
214
+ return formatted;
215
+ }
216
+ const completed = Date.parse(record.completedAt);
217
+ if (Number.isNaN(completed)) {
218
+ return DASH;
219
+ }
220
+ const elapsed = formatDurationLabel(Math.max(0, completed - started));
221
+ return elapsed ?? DASH;
222
+ }
223
+ function formatEvals(record) {
224
+ if (!record.evals || record.evals.length === 0) {
225
+ return DASH;
226
+ }
227
+ return record.evals
228
+ .map((evaluation) => colorize(evaluation.slug, getEvalStatusStyle(evaluation.status).cli))
229
+ .join(" ");
230
+ }
231
+ function upsertRecord(record) {
232
+ if (!agentOrder.includes(record.agentId)) {
233
+ agentOrder.push(record.agentId);
234
+ }
235
+ agentRecords.set(record.agentId, record);
236
+ }
237
+ function ensureFinalRender(report) {
238
+ if (!context) {
239
+ return;
240
+ }
241
+ context = {
242
+ ...context,
243
+ status: report.status,
244
+ };
245
+ render();
246
+ }
247
+ return {
248
+ begin(beginContext) {
249
+ guard(() => {
250
+ if (!beginContext) {
251
+ render();
252
+ return;
253
+ }
254
+ context = { ...beginContext };
255
+ render();
256
+ });
257
+ },
258
+ update(record) {
259
+ guard(() => {
260
+ upsertRecord(record);
261
+ render();
262
+ });
263
+ },
264
+ complete(report) {
265
+ let transcript = "";
266
+ guard(() => {
267
+ ensureFinalRender(report);
268
+ disabled = true;
269
+ });
270
+ const hint = {
271
+ message: `To review results:\n voratiq review --run ${report.runId}`,
272
+ };
273
+ const sections = stdout.isTTY
274
+ ? undefined
275
+ : buildRunTranscriptSections(report);
276
+ transcript = renderTranscript({ sections, hint });
277
+ return transcript;
278
+ },
279
+ };
280
+ }
281
+ export function buildRunTranscriptSections(report) {
282
+ const sections = [];
283
+ const headerLines = [];
284
+ headerLines.push(`${report.runId} ${report.status.toUpperCase()}`);
285
+ sections.push(headerLines);
286
+ const agentLines = [];
287
+ const sortedAgents = [...report.agents].sort((a, b) => a.agentId.localeCompare(b.agentId));
288
+ for (const agent of sortedAgents) {
289
+ agentLines.push(` ${agent.agentId} ${agent.status.toUpperCase()}`);
290
+ }
291
+ if (agentLines.length > 0) {
292
+ sections.push(agentLines);
293
+ }
294
+ return sections;
295
+ }
@@ -0,0 +1,12 @@
1
+ import type { AgentSectionInput } from "../utils/agents.js";
2
+ import type { RunDisplayInfo } from "../utils/runs.js";
3
+ import type { TranscriptHintOptions } from "../utils/transcript.js";
4
+ export interface TranscriptScaffoldOptions {
5
+ metadata: RunDisplayInfo;
6
+ agents: readonly AgentSectionInput[];
7
+ beforeAgents?: readonly string[][];
8
+ afterAgents?: readonly string[][];
9
+ warnings?: readonly string[];
10
+ hint?: TranscriptHintOptions;
11
+ }
12
+ export declare function renderTranscriptWithMetadata(options: TranscriptScaffoldOptions): string;
@@ -0,0 +1,41 @@
1
+ import { buildAgentSection } from "../utils/agents.js";
2
+ import { buildRunMetadataSection } from "../utils/runs.js";
3
+ import { renderTranscript } from "../utils/transcript.js";
4
+ export function renderTranscriptWithMetadata(options) {
5
+ const sections = buildTranscriptSections(options);
6
+ return renderTranscript({ sections, hint: options.hint });
7
+ }
8
+ function buildTranscriptSections(options) {
9
+ const sections = [];
10
+ const metadataSection = buildRunMetadataSection(options.metadata);
11
+ if (metadataSection.length > 0) {
12
+ sections.push(metadataSection);
13
+ }
14
+ appendSections(sections, options.beforeAgents);
15
+ options.agents.forEach((agent) => {
16
+ const agentSection = buildAgentSection(agent);
17
+ if (agentSection.length > 0) {
18
+ sections.push(agentSection);
19
+ }
20
+ });
21
+ appendSections(sections, buildWarningSections(options.warnings));
22
+ appendSections(sections, options.afterAgents);
23
+ return sections;
24
+ }
25
+ function buildWarningSections(warnings) {
26
+ if (!warnings || warnings.length === 0) {
27
+ return undefined;
28
+ }
29
+ return warnings.map((warning) => [warning]);
30
+ }
31
+ function appendSections(sections, blocks) {
32
+ if (!blocks) {
33
+ return;
34
+ }
35
+ blocks.forEach((block) => {
36
+ if (block.length === 0) {
37
+ return;
38
+ }
39
+ sections.push(block);
40
+ });
41
+ }
@@ -0,0 +1,28 @@
1
+ import type { AgentEvalEnhanced, AgentInvocationEnhanced } from "../../records/enhanced.js";
2
+ import type { AgentEvalView, AgentReport, AgentStatus } from "../../records/types.js";
3
+ type AgentHeaderSource = Pick<AgentInvocationEnhanced, "agentId" | "status" | "startedAt" | "completedAt"> | Pick<AgentReport, "agentId" | "status" | "startedAt" | "completedAt">;
4
+ type AgentSectionSource = AgentHeaderSource & {
5
+ diffStatistics?: string;
6
+ error?: string;
7
+ warnings?: string[];
8
+ baseDirectory?: string;
9
+ runtimeManifestPath?: string;
10
+ assets?: AgentInvocationEnhanced["assets"];
11
+ evals?: (AgentEvalEnhanced | AgentEvalView)[];
12
+ };
13
+ export type AgentSectionInput = AgentSectionSource;
14
+ type AgentMetadataRow = {
15
+ label: string;
16
+ value: string;
17
+ };
18
+ export declare function formatAgentStatusLabel(status: AgentStatus): string;
19
+ export declare function buildAgentSectionHeader(agent: AgentHeaderSource): string;
20
+ export declare function getAgentMetadata(agent: AgentSectionSource): AgentMetadataRow[];
21
+ export declare function buildAgentMetadataSection(agent: AgentSectionSource): string[];
22
+ export declare function buildAgentSection(agent: AgentSectionSource): string[];
23
+ export declare function buildAgentSectionArtifacts(agent: AgentSectionSource, agentRoot?: string): string[];
24
+ export declare function buildAgentSectionEvals(agent: AgentSectionSource, agentRoot?: string): string[];
25
+ export declare function buildAgentSectionRuntime(agent: AgentSectionSource, agentRoot?: string): string[];
26
+ export declare function formatAgentDuration(agent: AgentHeaderSource): string | undefined;
27
+ export declare function formatDurationLabel(durationMs: number): string | undefined;
28
+ export {};
@@ -0,0 +1,261 @@
1
+ import { getAgentStatusStyle, getEvalStatusStyle, } from "../../status/colors.js";
2
+ import { colorize } from "../../utils/colors.js";
3
+ import { formatAgentBadge } from "./badges.js";
4
+ import { renderTable } from "./table.js";
5
+ export function formatAgentStatusLabel(status) {
6
+ const statusColor = getAgentStatusStyle(status).cli;
7
+ return colorize(status.toUpperCase(), statusColor);
8
+ }
9
+ export function buildAgentSectionHeader(agent) {
10
+ const agentLabel = formatAgentBadge(agent.agentId);
11
+ const status = agent.status;
12
+ const statusLabel = formatAgentStatusLabel(status);
13
+ return ` ${agentLabel} ${statusLabel}`;
14
+ }
15
+ export function getAgentMetadata(agent) {
16
+ const baseDir = agent.baseDirectory;
17
+ const candidates = [
18
+ { label: "Duration", value: formatAgentDuration(agent) },
19
+ { label: "Changes", value: agent.diffStatistics },
20
+ { label: "Root", value: baseDir },
21
+ ];
22
+ return candidates.filter((row) => typeof row.value === "string" && row.value.length > 0);
23
+ }
24
+ export function buildAgentMetadataSection(agent) {
25
+ const metadata = getAgentMetadata(agent);
26
+ if (metadata.length === 0) {
27
+ return [];
28
+ }
29
+ const tableLines = renderTable({
30
+ columns: [
31
+ {
32
+ header: "FIELD",
33
+ accessor: (row) => row.label,
34
+ },
35
+ {
36
+ header: "VALUE",
37
+ accessor: (row) => row.value,
38
+ },
39
+ ],
40
+ rows: metadata,
41
+ });
42
+ const [, ...bodyLines] = tableLines;
43
+ return bodyLines;
44
+ }
45
+ export function buildAgentSection(agent) {
46
+ const lines = [buildAgentSectionHeader(agent)];
47
+ const agentRoot = getAgentRootPath(agent);
48
+ const metadataLines = buildAgentMetadataSection(agent);
49
+ if (metadataLines.length > 0) {
50
+ lines.push("", ...indentLines(metadataLines));
51
+ }
52
+ const runtimeLines = buildAgentSectionRuntime(agent, agentRoot);
53
+ if (runtimeLines.length > 0) {
54
+ lines.push("", ...indentLines(runtimeLines));
55
+ }
56
+ if (agent.warnings && agent.warnings.length > 0) {
57
+ const warningLines = agent.warnings.map((warning) => colorize(`Warning: ${warning}`, "yellow"));
58
+ lines.push("", ...indentLines(warningLines));
59
+ }
60
+ if (agent.error) {
61
+ lines.push("", ...indentLines([colorize(`Error: ${agent.error}`, "red")]));
62
+ }
63
+ const evalLines = buildAgentSectionEvals(agent, agentRoot);
64
+ if (evalLines.length > 0) {
65
+ lines.push("", ...indentLines(evalLines));
66
+ }
67
+ const artifactLines = buildAgentSectionArtifacts(agent, agentRoot);
68
+ if (artifactLines.length > 0) {
69
+ lines.push("", ...indentLines(artifactLines));
70
+ }
71
+ return lines;
72
+ }
73
+ export function buildAgentSectionArtifacts(agent, agentRoot) {
74
+ const labelValuePairs = [
75
+ ["summary", agent.assets?.summaryPath],
76
+ ["diff", agent.assets?.diffPath],
77
+ ["chat", agent.assets?.chatPath],
78
+ ["stdout", agent.assets?.stdoutPath],
79
+ ["stderr", agent.assets?.stderrPath],
80
+ ];
81
+ const availablePairs = labelValuePairs.filter((pair) => typeof pair[1] === "string");
82
+ if (availablePairs.length === 0) {
83
+ return [];
84
+ }
85
+ const rows = availablePairs.map(([label, value]) => [
86
+ label,
87
+ relativizePath(value, agentRoot),
88
+ ]);
89
+ const tableLines = renderTable({
90
+ columns: [
91
+ {
92
+ header: "ARTIFACT",
93
+ accessor: (row) => row[0],
94
+ },
95
+ {
96
+ header: "PATH",
97
+ accessor: (row) => row[1],
98
+ },
99
+ ],
100
+ rows,
101
+ });
102
+ return tableLines;
103
+ }
104
+ export function buildAgentSectionEvals(agent, agentRoot) {
105
+ const evalResults = agent.evals ?? [];
106
+ const rows = evalResults.length === 0
107
+ ? [
108
+ {
109
+ slug: "none",
110
+ status: colorize("SKIPPED", getEvalStatusStyle("skipped").cli),
111
+ log: "—",
112
+ },
113
+ ]
114
+ : evalResults.map((evaluation) => ({
115
+ slug: evaluation.slug,
116
+ status: colorize(evaluation.status.toUpperCase(), getEvalStatusStyle(evaluation.status).cli),
117
+ log: evaluation.logPath !== undefined
118
+ ? relativizePath(evaluation.logPath, agentRoot)
119
+ : "—",
120
+ }));
121
+ const tableLines = renderTable({
122
+ columns: [
123
+ { header: "EVAL", accessor: (row) => row.slug },
124
+ { header: "STATUS", accessor: (row) => row.status },
125
+ { header: "LOG", accessor: (row) => row.log },
126
+ ],
127
+ rows,
128
+ });
129
+ return tableLines;
130
+ }
131
+ export function buildAgentSectionRuntime(agent, agentRoot) {
132
+ const rows = [];
133
+ if (typeof agent.runtimeManifestPath === "string" &&
134
+ agent.runtimeManifestPath.length > 0) {
135
+ rows.push([
136
+ "manifest",
137
+ relativizePath(agent.runtimeManifestPath, agentRoot),
138
+ ]);
139
+ }
140
+ const sandboxPath = deriveSandboxSettingsPath(agent);
141
+ if (sandboxPath) {
142
+ rows.push(["sandbox", relativizePath(sandboxPath, agentRoot)]);
143
+ }
144
+ if (rows.length === 0) {
145
+ return [];
146
+ }
147
+ const tableLines = renderTable({
148
+ columns: [
149
+ {
150
+ header: "RUNTIME",
151
+ accessor: (row) => row[0],
152
+ },
153
+ {
154
+ header: "PATH",
155
+ accessor: (row) => row[1],
156
+ },
157
+ ],
158
+ rows,
159
+ });
160
+ return tableLines;
161
+ }
162
+ export function formatAgentDuration(agent) {
163
+ const startedAt = safeParse(agent.startedAt);
164
+ const completedAt = safeParse(agent.completedAt);
165
+ if (startedAt === undefined ||
166
+ completedAt === undefined ||
167
+ completedAt < startedAt) {
168
+ return undefined;
169
+ }
170
+ const durationMs = completedAt - startedAt;
171
+ return formatDurationLabel(durationMs);
172
+ }
173
+ function safeParse(timestamp) {
174
+ if (!timestamp) {
175
+ return undefined;
176
+ }
177
+ const parsed = Date.parse(timestamp);
178
+ if (Number.isNaN(parsed)) {
179
+ return undefined;
180
+ }
181
+ return parsed;
182
+ }
183
+ export function formatDurationLabel(durationMs) {
184
+ if (!Number.isFinite(durationMs) || durationMs < 0) {
185
+ return undefined;
186
+ }
187
+ const totalSeconds = Math.round(durationMs / 1000);
188
+ const hours = Math.floor(totalSeconds / 3600);
189
+ const minutes = Math.floor((totalSeconds % 3600) / 60);
190
+ const seconds = totalSeconds % 60;
191
+ const parts = [];
192
+ if (hours > 0) {
193
+ parts.push(`${hours}h`);
194
+ }
195
+ if (minutes > 0) {
196
+ parts.push(`${minutes}m`);
197
+ }
198
+ if (seconds > 0 || parts.length === 0) {
199
+ parts.push(`${seconds}s`);
200
+ }
201
+ return parts.join(" ");
202
+ }
203
+ function getAgentRootPath(agent) {
204
+ if (typeof agent.baseDirectory === "string") {
205
+ return agent.baseDirectory;
206
+ }
207
+ const assets = agent.assets;
208
+ const candidates = [
209
+ assets?.summaryPath,
210
+ assets?.diffPath,
211
+ assets?.stdoutPath,
212
+ assets?.stderrPath,
213
+ ].filter((value) => typeof value === "string");
214
+ for (const candidate of candidates) {
215
+ const parent = parentDirectory(candidate);
216
+ if (parent) {
217
+ return stripWorkspaceSuffix(parent);
218
+ }
219
+ }
220
+ return undefined;
221
+ }
222
+ function parentDirectory(path) {
223
+ const segments = path.split("/").filter((segment) => segment.length > 0);
224
+ if (segments.length <= 1) {
225
+ return undefined;
226
+ }
227
+ return segments.slice(0, -1).join("/");
228
+ }
229
+ function stripWorkspaceSuffix(path) {
230
+ return path.endsWith("/workspace") ? path.slice(0, -10) : path;
231
+ }
232
+ function deriveSandboxSettingsPath(agent) {
233
+ if (typeof agent.baseDirectory === "string" &&
234
+ agent.baseDirectory.length > 0) {
235
+ return `${stripTrailingSlash(agent.baseDirectory)}/runtime/sandbox.json`;
236
+ }
237
+ if (typeof agent.runtimeManifestPath === "string" &&
238
+ agent.runtimeManifestPath.length > 0) {
239
+ const runtimeDir = parentDirectory(agent.runtimeManifestPath);
240
+ if (runtimeDir) {
241
+ return `${runtimeDir}/sandbox.json`;
242
+ }
243
+ }
244
+ return undefined;
245
+ }
246
+ function stripTrailingSlash(path) {
247
+ return path.endsWith("/") ? path.slice(0, -1) : path;
248
+ }
249
+ function relativizePath(path, root) {
250
+ if (!root) {
251
+ return path;
252
+ }
253
+ const normalizedRoot = root.endsWith("/") ? root : `${root}/`;
254
+ if (path.startsWith(normalizedRoot)) {
255
+ return path.slice(normalizedRoot.length);
256
+ }
257
+ return path;
258
+ }
259
+ function indentLines(lines) {
260
+ return lines.map((line) => (line.length > 0 ? ` ${line}` : line));
261
+ }
@@ -0,0 +1,20 @@
1
+ type AnsiCode = string;
2
+ export interface BadgeStyle {
3
+ foreground?: AnsiCode;
4
+ background?: AnsiCode;
5
+ bold?: boolean;
6
+ padding?: number;
7
+ }
8
+ export declare const BADGE_STYLES: {
9
+ readonly run: {
10
+ readonly foreground: "\u001B[38;2;0;0;0m";
11
+ readonly background: "\u001B[48;2;164;203;153m";
12
+ readonly bold: true;
13
+ };
14
+ readonly agent: {
15
+ readonly bold: true;
16
+ };
17
+ };
18
+ export declare function formatRunBadge(text: string): string;
19
+ export declare function formatAgentBadge(text: string): string;
20
+ export {};
@@ -0,0 +1,37 @@
1
+ const ANSI_RESET = "\u001B[0m";
2
+ const ANSI_BOLD = "\u001B[1m";
3
+ const ESC = "\u001B[";
4
+ const BRAND_COLOR = "164;203;153";
5
+ export const BADGE_STYLES = {
6
+ run: {
7
+ foreground: `${ESC}38;2;0;0;0m`,
8
+ background: `${ESC}48;2;${BRAND_COLOR}m`,
9
+ bold: true,
10
+ },
11
+ agent: {
12
+ bold: true,
13
+ },
14
+ };
15
+ function applyBadgeStyle(text, style) {
16
+ const padding = Math.max(0, style.padding ?? 0);
17
+ const pad = padding === 0 ? "" : " ".repeat(padding);
18
+ const padded = `${pad}${text}${pad}`;
19
+ const parts = [];
20
+ if (typeof style.background === "string" && style.background.length > 0) {
21
+ parts.push(style.background);
22
+ }
23
+ if (typeof style.foreground === "string" && style.foreground.length > 0) {
24
+ parts.push(style.foreground);
25
+ }
26
+ if (style.bold === true) {
27
+ parts.push(ANSI_BOLD);
28
+ }
29
+ parts.push(padded, ANSI_RESET);
30
+ return parts.join("");
31
+ }
32
+ export function formatRunBadge(text) {
33
+ return applyBadgeStyle(text, BADGE_STYLES.run);
34
+ }
35
+ export function formatAgentBadge(text) {
36
+ return applyBadgeStyle(text, BADGE_STYLES.agent);
37
+ }
@@ -0,0 +1,2 @@
1
+ import { CliError } from "../../cli/errors.js";
2
+ export declare function renderCliError(error: CliError): string;