@mcoda/mswarm 0.1.133 → 0.1.135-codali.2

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 (250) hide show
  1. package/README.md +44 -0
  2. package/dist/codali-executor.d.ts +66 -1
  3. package/dist/codali-executor.d.ts.map +1 -1
  4. package/dist/codali-executor.js +83 -8
  5. package/dist/codali-executor.js.map +1 -1
  6. package/dist/invocation-token.d.ts.map +1 -1
  7. package/dist/invocation-token.js +1 -0
  8. package/dist/invocation-token.js.map +1 -1
  9. package/dist/native-reasoning.d.ts +8 -0
  10. package/dist/native-reasoning.d.ts.map +1 -0
  11. package/dist/native-reasoning.js +18 -0
  12. package/dist/native-reasoning.js.map +1 -0
  13. package/dist/runtime.d.ts +25 -1
  14. package/dist/runtime.d.ts.map +1 -1
  15. package/dist/runtime.js +220 -20
  16. package/dist/runtime.js.map +1 -1
  17. package/dist/server.d.ts +3 -1
  18. package/dist/server.d.ts.map +1 -1
  19. package/dist/server.js +58 -8
  20. package/dist/server.js.map +1 -1
  21. package/dist/vendor/codali/agents/RoleResolution.d.ts.map +1 -1
  22. package/dist/vendor/codali/agents/RoleResolution.js +4 -4
  23. package/dist/vendor/codali/api/CodaliApi.d.ts +16 -0
  24. package/dist/vendor/codali/api/CodaliApi.d.ts.map +1 -1
  25. package/dist/vendor/codali/api/CodaliApi.js +39 -10
  26. package/dist/vendor/codali/cli/AskCommand.d.ts +3 -0
  27. package/dist/vendor/codali/cli/AskCommand.d.ts.map +1 -1
  28. package/dist/vendor/codali/cli/AskCommand.js +76 -13
  29. package/dist/vendor/codali/cli/RunCommand.d.ts +4 -0
  30. package/dist/vendor/codali/cli/RunCommand.d.ts.map +1 -1
  31. package/dist/vendor/codali/cli/RunCommand.js +110 -24
  32. package/dist/vendor/codali/cli/TerminalCommand.d.ts +35 -0
  33. package/dist/vendor/codali/cli/TerminalCommand.d.ts.map +1 -0
  34. package/dist/vendor/codali/cli/TerminalCommand.js +616 -0
  35. package/dist/vendor/codali/cli/TerminalCredentials.d.ts +3 -0
  36. package/dist/vendor/codali/cli/TerminalCredentials.d.ts.map +1 -0
  37. package/dist/vendor/codali/cli/TerminalCredentials.js +89 -0
  38. package/dist/vendor/codali/cli/TerminalInput.d.ts +24 -0
  39. package/dist/vendor/codali/cli/TerminalInput.d.ts.map +1 -0
  40. package/dist/vendor/codali/cli/TerminalInput.js +98 -0
  41. package/dist/vendor/codali/cli/TerminalText.d.ts +10 -0
  42. package/dist/vendor/codali/cli/TerminalText.d.ts.map +1 -0
  43. package/dist/vendor/codali/cli/TerminalText.js +53 -0
  44. package/dist/vendor/codali/cli.d.ts.map +1 -1
  45. package/dist/vendor/codali/cli.js +33 -4
  46. package/dist/vendor/codali/cognitive/ConfiguredPipeline.d.ts +34 -0
  47. package/dist/vendor/codali/cognitive/ConfiguredPipeline.d.ts.map +1 -0
  48. package/dist/vendor/codali/cognitive/ConfiguredPipeline.js +50 -0
  49. package/dist/vendor/codali/cognitive/ValidationRunner.d.ts +4 -0
  50. package/dist/vendor/codali/cognitive/ValidationRunner.d.ts.map +1 -1
  51. package/dist/vendor/codali/cognitive/ValidationRunner.js +18 -41
  52. package/dist/vendor/codali/config/NodeOrchestration.d.ts +21 -0
  53. package/dist/vendor/codali/config/NodeOrchestration.d.ts.map +1 -0
  54. package/dist/vendor/codali/config/NodeOrchestration.js +54 -0
  55. package/dist/vendor/codali/config/OrchestrationConfig.d.ts +100 -0
  56. package/dist/vendor/codali/config/OrchestrationConfig.d.ts.map +1 -0
  57. package/dist/vendor/codali/config/OrchestrationConfig.js +245 -0
  58. package/dist/vendor/codali/connectors/mcp/McpClient.d.ts +3 -1
  59. package/dist/vendor/codali/connectors/mcp/McpClient.d.ts.map +1 -1
  60. package/dist/vendor/codali/connectors/mcp/McpClient.js +3 -2
  61. package/dist/vendor/codali/connectors/mcp/McpServerRegistry.d.ts +2 -2
  62. package/dist/vendor/codali/connectors/mcp/McpServerRegistry.d.ts.map +1 -1
  63. package/dist/vendor/codali/connectors/mcp/McpServerRegistry.js +39 -16
  64. package/dist/vendor/codali/connectors/mcp/McpToolAdapter.js +2 -2
  65. package/dist/vendor/codali/connectors/media/ConfiguredMediaTools.d.ts +6 -0
  66. package/dist/vendor/codali/connectors/media/ConfiguredMediaTools.d.ts.map +1 -0
  67. package/dist/vendor/codali/connectors/media/ConfiguredMediaTools.js +41 -0
  68. package/dist/vendor/codali/connectors/media/ImageGenerationTool.js +3 -3
  69. package/dist/vendor/codali/connectors/media/MediaArtifactReceipt.d.ts +5 -0
  70. package/dist/vendor/codali/connectors/media/MediaArtifactReceipt.d.ts.map +1 -0
  71. package/dist/vendor/codali/connectors/media/MediaArtifactReceipt.js +65 -0
  72. package/dist/vendor/codali/connectors/media/MediaJobStore.d.ts +68 -0
  73. package/dist/vendor/codali/connectors/media/MediaJobStore.d.ts.map +1 -0
  74. package/dist/vendor/codali/connectors/media/MediaJobStore.js +199 -0
  75. package/dist/vendor/codali/connectors/media/MediaJobWorker.d.ts +2 -0
  76. package/dist/vendor/codali/connectors/media/MediaJobWorker.d.ts.map +1 -0
  77. package/dist/vendor/codali/connectors/media/MediaJobWorker.js +65 -0
  78. package/dist/vendor/codali/connectors/media/RemoteMediaJob.d.ts +6 -0
  79. package/dist/vendor/codali/connectors/media/RemoteMediaJob.d.ts.map +1 -0
  80. package/dist/vendor/codali/connectors/media/RemoteMediaJob.js +80 -0
  81. package/dist/vendor/codali/docdex/DocdexClient.d.ts +18 -1
  82. package/dist/vendor/codali/docdex/DocdexClient.d.ts.map +1 -1
  83. package/dist/vendor/codali/docdex/DocdexClient.js +135 -19
  84. package/dist/vendor/codali/docdex/ManagedDocdex.d.ts +29 -0
  85. package/dist/vendor/codali/docdex/ManagedDocdex.d.ts.map +1 -0
  86. package/dist/vendor/codali/docdex/ManagedDocdex.js +215 -0
  87. package/dist/vendor/codali/docdex/ManagedRuntime.d.ts +28 -0
  88. package/dist/vendor/codali/docdex/ManagedRuntime.d.ts.map +1 -0
  89. package/dist/vendor/codali/docdex/ManagedRuntime.js +212 -0
  90. package/dist/vendor/codali/eval/EvaluationProcess.d.ts +13 -0
  91. package/dist/vendor/codali/eval/EvaluationProcess.d.ts.map +1 -0
  92. package/dist/vendor/codali/eval/EvaluationProcess.js +76 -0
  93. package/dist/vendor/codali/eval/LongWorkflowJourney.d.ts +34 -0
  94. package/dist/vendor/codali/eval/LongWorkflowJourney.d.ts.map +1 -0
  95. package/dist/vendor/codali/eval/LongWorkflowJourney.js +243 -0
  96. package/dist/vendor/codali/eval/PlanningCorpus.d.ts +45 -0
  97. package/dist/vendor/codali/eval/PlanningCorpus.d.ts.map +1 -0
  98. package/dist/vendor/codali/eval/PlanningCorpus.js +189 -0
  99. package/dist/vendor/codali/eval/PlanningCorpusRunner.d.ts +13 -0
  100. package/dist/vendor/codali/eval/PlanningCorpusRunner.d.ts.map +1 -0
  101. package/dist/vendor/codali/eval/PlanningCorpusRunner.js +89 -0
  102. package/dist/vendor/codali/eval/TerminalCorpusRunner.d.ts +36 -0
  103. package/dist/vendor/codali/eval/TerminalCorpusRunner.d.ts.map +1 -0
  104. package/dist/vendor/codali/eval/TerminalCorpusRunner.js +222 -0
  105. package/dist/vendor/codali/eval/TerminalTaskCorpus.d.ts +26 -0
  106. package/dist/vendor/codali/eval/TerminalTaskCorpus.d.ts.map +1 -0
  107. package/dist/vendor/codali/eval/TerminalTaskCorpus.js +105 -0
  108. package/dist/vendor/codali/eval/TerminalWorkflowCorpus.d.ts +11 -0
  109. package/dist/vendor/codali/eval/TerminalWorkflowCorpus.d.ts.map +1 -0
  110. package/dist/vendor/codali/eval/TerminalWorkflowCorpus.js +116 -0
  111. package/dist/vendor/codali/eval/fixtures/TerminalRecoveryJourney.d.ts +4 -0
  112. package/dist/vendor/codali/eval/fixtures/TerminalRecoveryJourney.d.ts.map +1 -0
  113. package/dist/vendor/codali/eval/fixtures/TerminalRecoveryJourney.js +132 -0
  114. package/dist/vendor/codali/gateway/CodaliGateway.d.ts +2 -0
  115. package/dist/vendor/codali/gateway/CodaliGateway.d.ts.map +1 -1
  116. package/dist/vendor/codali/gateway/CodaliGateway.js +16 -4
  117. package/dist/vendor/codali/gateway/ConfiguredGateway.d.ts +23 -0
  118. package/dist/vendor/codali/gateway/ConfiguredGateway.d.ts.map +1 -0
  119. package/dist/vendor/codali/gateway/ConfiguredGateway.js +44 -0
  120. package/dist/vendor/codali/gateway/GatewayTracer.d.ts +1 -1
  121. package/dist/vendor/codali/gateway/GatewayTracer.d.ts.map +1 -1
  122. package/dist/vendor/codali/gateway/GatewayTracer.js +2 -27
  123. package/dist/vendor/codali/gateway/LocalGatewayTaskRunner.d.ts.map +1 -1
  124. package/dist/vendor/codali/gateway/LocalGatewayTaskRunner.js +13 -1
  125. package/dist/vendor/codali/index.d.ts +23 -0
  126. package/dist/vendor/codali/index.d.ts.map +1 -1
  127. package/dist/vendor/codali/index.js +12 -0
  128. package/dist/vendor/codali/permissions/PermissionGate.d.ts +44 -0
  129. package/dist/vendor/codali/permissions/PermissionGate.d.ts.map +1 -0
  130. package/dist/vendor/codali/permissions/PermissionGate.js +97 -0
  131. package/dist/vendor/codali/providers/ConfiguredEmbeddings.d.ts +43 -0
  132. package/dist/vendor/codali/providers/ConfiguredEmbeddings.d.ts.map +1 -0
  133. package/dist/vendor/codali/providers/ConfiguredEmbeddings.js +87 -0
  134. package/dist/vendor/codali/providers/ConfiguredModelScope.d.ts +69 -0
  135. package/dist/vendor/codali/providers/ConfiguredModelScope.d.ts.map +1 -0
  136. package/dist/vendor/codali/providers/ConfiguredModelScope.js +113 -0
  137. package/dist/vendor/codali/providers/ConfiguredProvider.d.ts +79 -0
  138. package/dist/vendor/codali/providers/ConfiguredProvider.d.ts.map +1 -0
  139. package/dist/vendor/codali/providers/ConfiguredProvider.js +238 -0
  140. package/dist/vendor/codali/providers/ModelServiceError.d.ts +10 -0
  141. package/dist/vendor/codali/providers/ModelServiceError.d.ts.map +1 -0
  142. package/dist/vendor/codali/providers/ModelServiceError.js +45 -0
  143. package/dist/vendor/codali/providers/MswarmWorkerProvider.d.ts.map +1 -1
  144. package/dist/vendor/codali/providers/MswarmWorkerProvider.js +4 -0
  145. package/dist/vendor/codali/providers/OpenAiCompatibleProvider.d.ts.map +1 -1
  146. package/dist/vendor/codali/providers/OpenAiCompatibleProvider.js +134 -52
  147. package/dist/vendor/codali/providers/ProviderTypes.d.ts +14 -0
  148. package/dist/vendor/codali/providers/ProviderTypes.d.ts.map +1 -1
  149. package/dist/vendor/codali/runtime/CodaliJobRuntime.d.ts +6 -0
  150. package/dist/vendor/codali/runtime/CodaliJobRuntime.d.ts.map +1 -1
  151. package/dist/vendor/codali/runtime/CodaliJobRuntime.js +36 -1
  152. package/dist/vendor/codali/runtime/CodaliRuntime.d.ts +30 -0
  153. package/dist/vendor/codali/runtime/CodaliRuntime.d.ts.map +1 -1
  154. package/dist/vendor/codali/runtime/CodaliRuntime.js +71 -1
  155. package/dist/vendor/codali/runtime/CompletionReport.d.ts +5 -0
  156. package/dist/vendor/codali/runtime/CompletionReport.d.ts.map +1 -0
  157. package/dist/vendor/codali/runtime/CompletionReport.js +12 -0
  158. package/dist/vendor/codali/runtime/ProgressTracker.d.ts +17 -0
  159. package/dist/vendor/codali/runtime/ProgressTracker.d.ts.map +1 -0
  160. package/dist/vendor/codali/runtime/ProgressTracker.js +27 -0
  161. package/dist/vendor/codali/runtime/RequestedTestEvidence.d.ts +12 -0
  162. package/dist/vendor/codali/runtime/RequestedTestEvidence.d.ts.map +1 -0
  163. package/dist/vendor/codali/runtime/RequestedTestEvidence.js +16 -0
  164. package/dist/vendor/codali/runtime/RequiredRetrieval.d.ts +13 -0
  165. package/dist/vendor/codali/runtime/RequiredRetrieval.d.ts.map +1 -0
  166. package/dist/vendor/codali/runtime/RequiredRetrieval.js +25 -0
  167. package/dist/vendor/codali/runtime/ReviewSource.d.ts +6 -0
  168. package/dist/vendor/codali/runtime/ReviewSource.d.ts.map +1 -0
  169. package/dist/vendor/codali/runtime/ReviewSource.js +38 -0
  170. package/dist/vendor/codali/runtime/Runner.d.ts +13 -0
  171. package/dist/vendor/codali/runtime/Runner.d.ts.map +1 -1
  172. package/dist/vendor/codali/runtime/Runner.js +220 -158
  173. package/dist/vendor/codali/runtime/SecretRedaction.d.ts +11 -0
  174. package/dist/vendor/codali/runtime/SecretRedaction.d.ts.map +1 -0
  175. package/dist/vendor/codali/runtime/SecretRedaction.js +85 -0
  176. package/dist/vendor/codali/runtime/SessionController.d.ts +148 -0
  177. package/dist/vendor/codali/runtime/SessionController.d.ts.map +1 -0
  178. package/dist/vendor/codali/runtime/SessionController.js +1356 -0
  179. package/dist/vendor/codali/runtime/StructuralEvidence.d.ts +22 -0
  180. package/dist/vendor/codali/runtime/StructuralEvidence.d.ts.map +1 -0
  181. package/dist/vendor/codali/runtime/StructuralEvidence.js +87 -0
  182. package/dist/vendor/codali/runtime/TaskReviewContext.d.ts +34 -0
  183. package/dist/vendor/codali/runtime/TaskReviewContext.d.ts.map +1 -0
  184. package/dist/vendor/codali/runtime/TaskReviewContext.js +34 -0
  185. package/dist/vendor/codali/runtime/ValidationOutput.d.ts +5 -0
  186. package/dist/vendor/codali/runtime/ValidationOutput.d.ts.map +1 -0
  187. package/dist/vendor/codali/runtime/ValidationOutput.js +32 -0
  188. package/dist/vendor/codali/runtime/VerificationCommand.d.ts +3 -0
  189. package/dist/vendor/codali/runtime/VerificationCommand.d.ts.map +1 -0
  190. package/dist/vendor/codali/runtime/VerificationCommand.js +48 -0
  191. package/dist/vendor/codali/runtime/WorkStatusPage.d.ts +15 -0
  192. package/dist/vendor/codali/runtime/WorkStatusPage.d.ts.map +1 -0
  193. package/dist/vendor/codali/runtime/WorkStatusPage.js +58 -0
  194. package/dist/vendor/codali/runtime/WorkspaceLedger.d.ts +13 -0
  195. package/dist/vendor/codali/runtime/WorkspaceLedger.d.ts.map +1 -0
  196. package/dist/vendor/codali/runtime/WorkspaceLedger.js +145 -0
  197. package/dist/vendor/codali/runtime/WorkspaceLock.d.ts.map +1 -1
  198. package/dist/vendor/codali/runtime/WorkspaceLock.js +20 -17
  199. package/dist/vendor/codali/runtime/WorkspaceSnapshot.d.ts +13 -0
  200. package/dist/vendor/codali/runtime/WorkspaceSnapshot.d.ts.map +1 -0
  201. package/dist/vendor/codali/runtime/WorkspaceSnapshot.js +88 -0
  202. package/dist/vendor/codali/session/AtomicState.d.ts +13 -0
  203. package/dist/vendor/codali/session/AtomicState.d.ts.map +1 -0
  204. package/dist/vendor/codali/session/AtomicState.js +109 -0
  205. package/dist/vendor/codali/session/SessionStoragePath.d.ts +15 -0
  206. package/dist/vendor/codali/session/SessionStoragePath.d.ts.map +1 -0
  207. package/dist/vendor/codali/session/SessionStoragePath.js +89 -0
  208. package/dist/vendor/codali/session/SessionStore.d.ts +9 -0
  209. package/dist/vendor/codali/session/SessionStore.d.ts.map +1 -1
  210. package/dist/vendor/codali/session/SessionStore.js +181 -47
  211. package/dist/vendor/codali/session/WorkState.d.ts +23 -0
  212. package/dist/vendor/codali/session/WorkState.d.ts.map +1 -0
  213. package/dist/vendor/codali/session/WorkState.js +367 -0
  214. package/dist/vendor/codali/session/WorkTypes.d.ts +94 -0
  215. package/dist/vendor/codali/session/WorkTypes.d.ts.map +1 -0
  216. package/dist/vendor/codali/session/WorkTypes.js +1 -0
  217. package/dist/vendor/codali/tools/ToolRegistry.d.ts +2 -0
  218. package/dist/vendor/codali/tools/ToolRegistry.d.ts.map +1 -1
  219. package/dist/vendor/codali/tools/ToolRegistry.js +12 -2
  220. package/dist/vendor/codali/tools/ToolTypes.d.ts +16 -0
  221. package/dist/vendor/codali/tools/ToolTypes.d.ts.map +1 -1
  222. package/dist/vendor/codali/tools/docdex/DocdexTools.d.ts +2 -0
  223. package/dist/vendor/codali/tools/docdex/DocdexTools.d.ts.map +1 -1
  224. package/dist/vendor/codali/tools/docdex/DocdexTools.js +17 -2
  225. package/dist/vendor/codali/tools/filesystem/FileTools.d.ts.map +1 -1
  226. package/dist/vendor/codali/tools/filesystem/FileTools.js +30 -10
  227. package/dist/vendor/codali/tools/shell/AsyncProcess.d.ts +16 -0
  228. package/dist/vendor/codali/tools/shell/AsyncProcess.d.ts.map +1 -0
  229. package/dist/vendor/codali/tools/shell/AsyncProcess.js +94 -0
  230. package/dist/vendor/codali/tools/shell/DarwinRuntimeLibraries.d.ts +13 -0
  231. package/dist/vendor/codali/tools/shell/DarwinRuntimeLibraries.d.ts.map +1 -0
  232. package/dist/vendor/codali/tools/shell/DarwinRuntimeLibraries.js +130 -0
  233. package/dist/vendor/codali/tools/shell/HostToolchain.d.ts +19 -0
  234. package/dist/vendor/codali/tools/shell/HostToolchain.d.ts.map +1 -0
  235. package/dist/vendor/codali/tools/shell/HostToolchain.js +264 -0
  236. package/dist/vendor/codali/tools/shell/IsolatedExecutor.d.ts +15 -0
  237. package/dist/vendor/codali/tools/shell/IsolatedExecutor.d.ts.map +1 -0
  238. package/dist/vendor/codali/tools/shell/IsolatedExecutor.js +134 -0
  239. package/dist/vendor/codali/tools/shell/ShellTool.d.ts.map +1 -1
  240. package/dist/vendor/codali/tools/shell/ShellTool.js +9 -29
  241. package/dist/vendor/codali/tools/shell/ShellWorkingDirectory.d.ts +3 -0
  242. package/dist/vendor/codali/tools/shell/ShellWorkingDirectory.d.ts.map +1 -0
  243. package/dist/vendor/codali/tools/shell/ShellWorkingDirectory.js +30 -0
  244. package/package.json +31 -29
  245. package/scripts/backend-http-drain.mjs +152 -0
  246. package/scripts/media_gpu_lock.py +238 -0
  247. package/scripts/stable-audio-3-openai-server.py +45 -14
  248. package/scripts/stable-diffusion-cpp-openai-server.py +34 -4
  249. package/scripts/stable-diffusion-cpp-webm-duration.patch +22 -0
  250. package/scripts/wan22-openai-server.py +97 -18
@@ -0,0 +1,89 @@
1
+ import { promises as fs } from "node:fs";
2
+ import path from "node:path";
3
+ import { randomUUID } from "node:crypto";
4
+ import { credentialFilePath, parseCredentialFile, resetCredentialCache } from "../runcontext/CredentialFile.js";
5
+ import { withStateLock } from "../session/AtomicState.js";
6
+ export const setTerminalCredential = async (key) => {
7
+ if (key !== undefined && (!key.trim() || /[\r\n\0]/.test(key) || key.length > 8192))
8
+ throw new Error("Invalid API key");
9
+ const file = credentialFilePath();
10
+ await fs.mkdir(path.dirname(file), { recursive: true, mode: 0o700 });
11
+ await withStateLock(file, async () => {
12
+ let existing = "";
13
+ try {
14
+ const stat = await fs.lstat(file);
15
+ if (stat.isSymbolicLink())
16
+ throw new Error("Credential file must not be a symlink");
17
+ existing = await fs.readFile(file, "utf8");
18
+ }
19
+ catch (error) {
20
+ if (error.code !== "ENOENT")
21
+ throw error;
22
+ }
23
+ const lines = existing.split(/\r?\n/).filter(line => !Object.keys(parseCredentialFile(line)).some(name => ["MCODA_MSWARM_API_KEY", "MSWARM_API_KEY", "CODALI_MSWARM_LOGGED_OUT"].includes(name)));
24
+ lines.push(key === undefined ? "CODALI_MSWARM_LOGGED_OUT=1" : `MCODA_MSWARM_API_KEY=${key.trim()}`);
25
+ const temporary = `${file}.${randomUUID()}.tmp`;
26
+ const handle = await fs.open(temporary, "wx", 0o600);
27
+ try {
28
+ await handle.writeFile(`${lines.filter(Boolean).join("\n")}\n`);
29
+ await handle.sync();
30
+ await handle.close();
31
+ await fs.rename(temporary, file);
32
+ }
33
+ finally {
34
+ await handle.close().catch(() => undefined);
35
+ await fs.unlink(temporary).catch(() => undefined);
36
+ }
37
+ });
38
+ resetCredentialCache();
39
+ };
40
+ export const readTerminalCredential = async (fromStdin) => {
41
+ if (fromStdin) {
42
+ if (process.stdin.isTTY)
43
+ throw new Error("--stdin requires piped input");
44
+ let value = "";
45
+ for await (const chunk of process.stdin) {
46
+ value += String(chunk);
47
+ if (value.length > 8192)
48
+ throw new Error("API key input is too large");
49
+ }
50
+ return value.trim();
51
+ }
52
+ if (!process.stdin.isTTY)
53
+ throw new Error("Use codali login --stdin with piped input");
54
+ return new Promise((resolve, reject) => {
55
+ let value = "";
56
+ const wasRaw = process.stdin.isRaw;
57
+ const finish = (error) => { process.stdin.off("data", onData); process.stdin.setRawMode(wasRaw); process.stdin.pause(); process.stderr.write("\n"); error ? reject(error) : resolve(value); };
58
+ const onData = (chunk) => {
59
+ for (const character of chunk.toString("utf8")) {
60
+ if (character === "\u0003") {
61
+ finish(new Error("Login cancelled"));
62
+ return;
63
+ }
64
+ if (character === "\r" || character === "\n") {
65
+ finish();
66
+ return;
67
+ }
68
+ if (character === "\u007f" || character === "\b") {
69
+ if (value) {
70
+ value = value.slice(0, -1);
71
+ process.stderr.write("\b \b");
72
+ }
73
+ }
74
+ else if (character >= " " && character <= "~") {
75
+ value += character;
76
+ process.stderr.write("*");
77
+ if (value.length > 8192) {
78
+ finish(new Error("API key is too large"));
79
+ return;
80
+ }
81
+ }
82
+ }
83
+ };
84
+ process.stderr.write("mSwarm API key: ");
85
+ process.stdin.setRawMode(true);
86
+ process.stdin.resume();
87
+ process.stdin.on("data", onData);
88
+ });
89
+ };
@@ -0,0 +1,24 @@
1
+ import { Transform, type TransformCallback } from "node:stream";
2
+ import type { Interface } from "node:readline";
3
+ /** Bracketed paste is one editable input, never a sequence of submitted commands. */
4
+ export declare class TerminalInput extends Transform {
5
+ private readonly options;
6
+ private readonly decoder;
7
+ private pending;
8
+ private pasting;
9
+ private pasted;
10
+ private bytes;
11
+ private overflow;
12
+ constructor(options: {
13
+ onPaste: (text: string) => void;
14
+ onRejected: (reason: string) => void;
15
+ maxPasteBytes?: number;
16
+ });
17
+ private append;
18
+ private consume;
19
+ _transform(chunk: Buffer, _encoding: BufferEncoding, callback: TransformCallback): void;
20
+ _flush(callback: TransformCallback): void;
21
+ }
22
+ /** readline exposes the current editable line and cursor; refresh preserves multiline content. */
23
+ export declare const insertTerminalPaste: (readline: Interface, text: string) => void;
24
+ //# sourceMappingURL=TerminalInput.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"TerminalInput.d.ts","sourceRoot":"","sources":["../../src/cli/TerminalInput.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,KAAK,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAEhE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAS/C,qFAAqF;AACrF,qBAAa,aAAc,SAAQ,SAAS;IAO9B,OAAO,CAAC,QAAQ,CAAC,OAAO;IANpC,OAAO,CAAC,QAAQ,CAAC,OAAO,CAA6B;IACrD,OAAO,CAAC,OAAO,CAAM;IACrB,OAAO,CAAC,OAAO,CAAS;IACxB,OAAO,CAAC,MAAM,CAAM;IACpB,OAAO,CAAC,KAAK,CAAK;IAClB,OAAO,CAAC,QAAQ,CAAS;gBACI,OAAO,EAAE;QAAE,OAAO,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;QAAC,UAAU,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,IAAI,CAAC;QAAC,aAAa,CAAC,EAAE,MAAM,CAAA;KAAE;IACvI,OAAO,CAAC,MAAM;IAKd,OAAO,CAAC,OAAO;IAmBN,UAAU,CAAC,KAAK,EAAE,MAAM,EAAE,SAAS,EAAE,cAAc,EAAE,QAAQ,EAAE,iBAAiB,GAAG,IAAI;IAGvF,MAAM,CAAC,QAAQ,EAAE,iBAAiB,GAAG,IAAI;CAOnD;AAED,kGAAkG;AAClG,eAAO,MAAM,mBAAmB,GAAI,UAAU,SAAS,EAAE,MAAM,MAAM,KAAG,IAOvE,CAAC"}
@@ -0,0 +1,98 @@
1
+ import { Transform } from "node:stream";
2
+ import { StringDecoder } from "node:string_decoder";
3
+ const START = "\u001b[200~";
4
+ const END = "\u001b[201~";
5
+ const suffixLength = (text, token) => {
6
+ for (let size = Math.min(text.length, token.length - 1); size > 0; size--)
7
+ if (text.endsWith(token.slice(0, size)))
8
+ return size;
9
+ return 0;
10
+ };
11
+ /** Bracketed paste is one editable input, never a sequence of submitted commands. */
12
+ export class TerminalInput extends Transform {
13
+ constructor(options) {
14
+ super();
15
+ this.options = options;
16
+ this.decoder = new StringDecoder("utf8");
17
+ this.pending = "";
18
+ this.pasting = false;
19
+ this.pasted = "";
20
+ this.bytes = 0;
21
+ this.overflow = false;
22
+ }
23
+ append(text) {
24
+ this.bytes += Buffer.byteLength(text);
25
+ if (this.bytes > (this.options.maxPasteBytes ?? 262144)) {
26
+ this.overflow = true;
27
+ this.pasted = "";
28
+ }
29
+ else if (!this.overflow)
30
+ this.pasted += text;
31
+ }
32
+ consume(text) {
33
+ this.pending += text;
34
+ while (this.pending) {
35
+ const token = this.pasting ? END : START;
36
+ const index = this.pending.indexOf(token);
37
+ if (index < 0) {
38
+ const keep = suffixLength(this.pending, token);
39
+ const ready = this.pending.slice(0, this.pending.length - keep);
40
+ if (this.pasting)
41
+ this.append(ready);
42
+ else if (ready)
43
+ this.push(ready);
44
+ this.pending = keep ? this.pending.slice(-keep) : "";
45
+ return;
46
+ }
47
+ const ready = this.pending.slice(0, index);
48
+ this.pending = this.pending.slice(index + token.length);
49
+ if (this.pasting) {
50
+ this.append(ready);
51
+ if (this.overflow)
52
+ this.options.onRejected("Paste exceeds the 256 KiB input limit");
53
+ else
54
+ this.options.onPaste(this.pasted.replace(/\r\n?/g, "\n").replace(/[\x00-\x08\x0b\x0c\x0e-\x1f\x7f-\x9f]/g, ""));
55
+ this.pasting = false;
56
+ this.pasted = "";
57
+ this.bytes = 0;
58
+ this.overflow = false;
59
+ }
60
+ else {
61
+ if (ready)
62
+ this.push(ready);
63
+ this.pasting = true;
64
+ }
65
+ }
66
+ }
67
+ _transform(chunk, _encoding, callback) {
68
+ try {
69
+ this.consume(this.decoder.write(chunk));
70
+ callback();
71
+ }
72
+ catch (error) {
73
+ callback(error);
74
+ }
75
+ }
76
+ _flush(callback) {
77
+ try {
78
+ this.consume(this.decoder.end());
79
+ if (this.pasting)
80
+ this.options.onRejected("Incomplete paste discarded");
81
+ else if (this.pending)
82
+ this.push(this.pending);
83
+ callback();
84
+ }
85
+ catch (error) {
86
+ callback(error);
87
+ }
88
+ }
89
+ }
90
+ /** readline exposes the current editable line and cursor; refresh preserves multiline content. */
91
+ export const insertTerminalPaste = (readline, text) => {
92
+ // Node documents coordinated line/cursor updates; @types/node marks both readonly.
93
+ // Keep this compatibility boundary together: https://nodejs.org/api/readline.html#rlline
94
+ const editable = readline;
95
+ editable.line = editable.line.slice(0, editable.cursor) + text + editable.line.slice(editable.cursor);
96
+ editable.cursor += text.length;
97
+ readline.prompt(true);
98
+ };
@@ -0,0 +1,10 @@
1
+ export declare const terminalText: (value: string) => string;
2
+ /** Buffers incomplete ANSI/OSC sequences split across streamed chunks. */
3
+ export declare class TerminalTextStream {
4
+ private pending;
5
+ private secrets;
6
+ write(chunk: string): string;
7
+ finish(): string;
8
+ reset(): void;
9
+ }
10
+ //# sourceMappingURL=TerminalText.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"TerminalText.d.ts","sourceRoot":"","sources":["../../src/cli/TerminalText.ts"],"names":[],"mappings":"AAQA,eAAO,MAAM,YAAY,GAAI,OAAO,MAAM,KAAG,MAA0D,CAAC;AAExG,0EAA0E;AAC1E,qBAAa,kBAAkB;IAC7B,OAAO,CAAC,OAAO,CAAM;IACrB,OAAO,CAAC,OAAO,CAAiC;IAChD,KAAK,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM;IAwB5B,MAAM,IAAI,MAAM;IAChB,KAAK,IAAI,IAAI;CACd"}
@@ -0,0 +1,53 @@
1
+ import { stripVTControlCharacters } from "node:util";
2
+ import { redactSecretValues } from "../gateway/GatewayTracer.js";
3
+ import { StreamingSecretRedactor } from "../runtime/SecretRedaction.js";
4
+ /** Model/tool text is data, never terminal control sequences or clipboard commands. */
5
+ const stripTerminalControls = (value) => stripVTControlCharacters(value)
6
+ .replace(/[\u0000-\u0008\u000b-\u001f\u007f-\u009f]/g, "")
7
+ .replace(/[\u202a-\u202e\u2066-\u2069]/g, "");
8
+ export const terminalText = (value) => redactSecretValues(stripTerminalControls(value));
9
+ /** Buffers incomplete ANSI/OSC sequences split across streamed chunks. */
10
+ export class TerminalTextStream {
11
+ constructor() {
12
+ this.pending = "";
13
+ this.secrets = new StreamingSecretRedactor();
14
+ }
15
+ write(chunk) {
16
+ this.pending += chunk;
17
+ let cutoff = this.pending.length;
18
+ for (let index = 0; index < this.pending.length; index++) {
19
+ if (this.pending[index] !== "\u001b")
20
+ continue;
21
+ const next = this.pending[index + 1];
22
+ if (next === undefined) {
23
+ cutoff = index;
24
+ break;
25
+ }
26
+ if (["]", "P", "_", "^", "X"].includes(next)) {
27
+ const rest = this.pending.slice(index + 2);
28
+ const end = rest.search(/\u0007|\u001b\\/);
29
+ if (end < 0) {
30
+ cutoff = index;
31
+ break;
32
+ }
33
+ index += end + 2;
34
+ }
35
+ else if (next === "[") {
36
+ const rest = this.pending.slice(index + 2);
37
+ const end = rest.search(/[\x40-\x7e]/);
38
+ if (end < 0) {
39
+ cutoff = index;
40
+ break;
41
+ }
42
+ index += end + 2;
43
+ }
44
+ }
45
+ const ready = this.pending.slice(0, cutoff);
46
+ this.pending = this.pending.slice(cutoff);
47
+ if (this.pending.length > 8192)
48
+ this.pending = "";
49
+ return this.secrets.write(stripTerminalControls(ready));
50
+ }
51
+ finish() { this.pending = ""; return this.secrets.finish(); }
52
+ reset() { this.pending = ""; this.secrets = new StreamingSecretRedactor(); }
53
+ }
@@ -1 +1 @@
1
- {"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";AAsFA,eAAO,MAAM,MAAM,GAAU,OAAM,MAAM,EAA0B,KAAG,OAAO,CAAC,IAAI,CAkEjF,CAAC"}
1
+ {"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";AA2FA,eAAO,MAAM,MAAM,GAAU,OAAM,MAAM,EAA0B,KAAG,OAAO,CAAC,IAAI,CAyEjF,CAAC"}
@@ -11,7 +11,12 @@ import { FeedbackCommand } from "./cli/FeedbackCommand.js";
11
11
  import { EvalCommand } from "./cli/EvalCommand.js";
12
12
  import { DatasetCommand } from "./cli/DatasetCommand.js";
13
13
  import { ImprovementCommand } from "./cli/ImprovementCommand.js";
14
- const HELP_TEXT = "Usage: codali ask \"<question>\" [--trace] [--json] [--workspace-root <path>]\n" +
14
+ import { TerminalCommand, terminalDoctor } from "./cli/TerminalCommand.js";
15
+ const HELP_TEXT = "Usage: codali [chat] [prompt] [--effort low|medium|high|max] [--permissions plan|ask|workspace]\n" +
16
+ " or: codali exec <prompt> [--json] [--config <path>]\n" +
17
+ " or: codali setup | login [--stdin] | logout | auth status\n" +
18
+ " or: codali sessions | resume <id> | inspect <id>\n" +
19
+ " or: codali ask \"<question>\" [--trace] [--json] [--workspace-root <path>]\n" +
15
20
  " or: codali tools <list|describe|call|health> [options]\n" +
16
21
  " or: codali auth <microsoft>\n" +
17
22
  " or: codali serve [--port <n>] [--api-key <key>]\n" +
@@ -79,6 +84,10 @@ const printDoctor = () => {
79
84
  console.log(lines.join("\n"));
80
85
  };
81
86
  export const runCli = async (argv = process.argv.slice(2)) => {
87
+ if (argv.length === 0 && process.stdin.isTTY) {
88
+ await TerminalCommand.run(["chat"]);
89
+ return;
90
+ }
82
91
  if (argv.includes("--help") || argv.includes("-h") || argv.length === 0) {
83
92
  // eslint-disable-next-line no-console
84
93
  console.log(HELP_TEXT);
@@ -86,13 +95,25 @@ export const runCli = async (argv = process.argv.slice(2)) => {
86
95
  }
87
96
  const [command, ...rest] = argv;
88
97
  if (command === "--version" || command === "-v" || command === "version") {
89
- // Keep this lightweight for scaffold phase.
90
- // eslint-disable-next-line no-console
91
- console.log("dev");
98
+ const pkg = JSON.parse(fs.readFileSync(new URL("../package.json", import.meta.url), "utf8"));
99
+ console.log(pkg.version);
92
100
  return;
93
101
  }
94
102
  if (command === "doctor" || command === "--doctor") {
103
+ if (rest.includes("--json")) {
104
+ await TerminalCommand.run(["doctor", ...rest]);
105
+ return;
106
+ }
95
107
  printDoctor();
108
+ console.log(JSON.stringify(await terminalDoctor(rest.includes("--config") ? rest[rest.indexOf("--config") + 1] : undefined), null, 2));
109
+ return;
110
+ }
111
+ if (["chat", "exec", "setup", "login", "logout", "sessions", "resume", "status", "inspect", "checkpoint", "amend"].includes(command)) {
112
+ await TerminalCommand.run(argv);
113
+ return;
114
+ }
115
+ if (["--effort", "--permissions", "--config", "--workspace-root", "--plain", "--json", "--stdin"].includes(command)) {
116
+ await TerminalCommand.run(["chat", ...argv]);
96
117
  return;
97
118
  }
98
119
  if (command === "ask") {
@@ -100,6 +121,10 @@ export const runCli = async (argv = process.argv.slice(2)) => {
100
121
  return;
101
122
  }
102
123
  if (command === "auth") {
124
+ if (rest[0] === "status") {
125
+ await TerminalCommand.run(["auth-status", ...rest.slice(1)]);
126
+ return;
127
+ }
103
128
  await AuthCommand.run(rest);
104
129
  return;
105
130
  }
@@ -131,6 +156,10 @@ export const runCli = async (argv = process.argv.slice(2)) => {
131
156
  await FeedbackCommand.run(rest);
132
157
  return;
133
158
  }
159
+ if (!command.startsWith("-")) {
160
+ await TerminalCommand.run(["chat", ...argv]);
161
+ return;
162
+ }
134
163
  throw new Error(HELP_TEXT);
135
164
  };
136
165
  const isMain = (() => {
@@ -0,0 +1,34 @@
1
+ import { ConfiguredModelScope, type ScopedModelEvent, type ScopedModelUsage } from "../providers/ConfiguredModelScope.js";
2
+ import type { EffortLevel, ResolvedOrchestrationConfig } from "../config/OrchestrationConfig.js";
3
+ import type { ModelCallerContext } from "../providers/ConfiguredProvider.js";
4
+ import type { DocdexClient } from "../docdex/DocdexClient.js";
5
+ import { type ArchitectPlannerOptions } from "./ArchitectPlanner.js";
6
+ import { type BuilderRunnerOptions } from "./BuilderRunner.js";
7
+ import { type ContextAssemblerOptions } from "./ContextAssembler.js";
8
+ import { type PatchInterpreterOptions } from "./PatchInterpreter.js";
9
+ import { type SmartPipelineOptions, type SmartPipelineResult } from "./SmartPipeline.js";
10
+ export interface ConfiguredPipelineHost {
11
+ /** Host supplies a managed/configured retrieval client and owns its tool permissions. */
12
+ docdex: DocdexClient;
13
+ context?: Omit<ContextAssemblerOptions, "queryProvider">;
14
+ architect?: ArchitectPlannerOptions;
15
+ builder: Omit<BuilderRunnerOptions, "provider" | "interpreter">;
16
+ interpreter?: Omit<PatchInterpreterOptions, "provider">;
17
+ /** ValidationRunner and other host operations must use scope.signal. */
18
+ pipeline: Omit<SmartPipelineOptions, "contextAssembler" | "architectPlanner" | "builderRunner" | "onPhaseProviderFailure">;
19
+ }
20
+ export interface ConfiguredPipelineOptions {
21
+ orchestration: ResolvedOrchestrationConfig;
22
+ effort?: EffortLevel;
23
+ signal?: AbortSignal;
24
+ caller?: ModelCallerContext;
25
+ onModelEvent?: (event: ScopedModelEvent) => Promise<void> | void;
26
+ configure: (scope: ConfiguredModelScope) => ConfiguredPipelineHost | Promise<ConfiguredPipelineHost>;
27
+ }
28
+ /** Adapter for the existing cognitive pipeline; no second execution loop or undeclared fallback. */
29
+ export declare const runConfiguredPipeline: (task: string, options: ConfiguredPipelineOptions) => Promise<{
30
+ result: SmartPipelineResult;
31
+ usage: ScopedModelUsage;
32
+ toolCalls: number;
33
+ }>;
34
+ //# sourceMappingURL=ConfiguredPipeline.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ConfiguredPipeline.d.ts","sourceRoot":"","sources":["../../src/cognitive/ConfiguredPipeline.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,KAAK,gBAAgB,EAAE,KAAK,gBAAgB,EAAE,MAAM,sCAAsC,CAAC;AAC1H,OAAO,KAAK,EAAE,WAAW,EAAE,2BAA2B,EAAE,MAAM,kCAAkC,CAAC;AACjG,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,oCAAoC,CAAC;AAC7E,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AAC9D,OAAO,EAAoB,KAAK,uBAAuB,EAAE,MAAM,uBAAuB,CAAC;AACvF,OAAO,EAAiB,KAAK,oBAAoB,EAAE,MAAM,oBAAoB,CAAC;AAC9E,OAAO,EAAoB,KAAK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
1
+ import { ConfiguredModelScope } from "../providers/ConfiguredModelScope.js";
2
+ import { ArchitectPlanner } from "./ArchitectPlanner.js";
3
+ import { BuilderRunner } from "./BuilderRunner.js";
4
+ import { ContextAssembler } from "./ContextAssembler.js";
5
+ import { PatchInterpreter } from "./PatchInterpreter.js";
6
+ import { SmartPipeline } from "./SmartPipeline.js";
7
+ /** Adapter for the existing cognitive pipeline; no second execution loop or undeclared fallback. */
8
+ export const runConfiguredPipeline = async (task, options) => {
9
+ const scope = new ConfiguredModelScope(options.orchestration, { effort: options.effort, signal: options.signal, caller: options.caller, onEvent: options.onModelEvent });
10
+ let toolCalls = 0;
11
+ try {
12
+ const host = await options.configure(scope);
13
+ const budget = scope.budget();
14
+ for (const [record, forbidden] of [[host.context, ["queryProvider"]], [host.builder, ["provider", "interpreter"]], [host.interpreter, ["provider"]],
15
+ [host.pipeline, ["contextAssembler", "architectPlanner", "builderRunner", "onPhaseProviderFailure"]]]) {
16
+ for (const key of forbidden)
17
+ if (record && key in record)
18
+ throw new Error(`Configured pipeline cannot accept a legacy ${key} override`);
19
+ }
20
+ scope.signal.throwIfAborted();
21
+ const beforeTool = host.builder.context.beforeTool;
22
+ const afterTool = host.builder.context.afterTool;
23
+ const context = { ...host.builder.context, signal: scope.signal,
24
+ beforeTool: async (...args) => {
25
+ scope.signal.throwIfAborted();
26
+ if (toolCalls >= budget.maxToolCalls)
27
+ throw new Error("Shared pipeline tool budget exhausted");
28
+ toolCalls++;
29
+ await beforeTool?.(...args);
30
+ scope.signal.throwIfAborted();
31
+ },
32
+ afterTool: async (...args) => { await afterTool?.(...args); scope.signal.throwIfAborted(); },
33
+ };
34
+ const pipeline = new SmartPipeline({ ...host.pipeline,
35
+ contextAssembler: new ContextAssembler(host.docdex, { ...host.context, queryProvider: scope.provider("router") }),
36
+ architectPlanner: new ArchitectPlanner(scope.provider("architect"), host.architect),
37
+ builderRunner: new BuilderRunner({ ...host.builder, context, provider: scope.provider("worker"),
38
+ maxTokens: Math.min(host.builder.maxTokens ?? budget.maxOutputTokens, budget.maxOutputTokens),
39
+ maxSteps: Math.min(host.builder.maxSteps, budget.maxSteps), maxToolCalls: Math.min(host.builder.maxToolCalls, budget.maxToolCalls),
40
+ timeoutMs: Math.min(host.builder.timeoutMs ?? budget.timeoutMs, budget.timeoutMs),
41
+ interpreter: host.interpreter ? new PatchInterpreter({ ...host.interpreter, provider: scope.provider("repair") }) : undefined }),
42
+ });
43
+ const result = await pipeline.run(task);
44
+ scope.signal.throwIfAborted();
45
+ return { result, usage: scope.snapshot(), toolCalls };
46
+ }
47
+ finally {
48
+ scope.close();
49
+ }
50
+ };
@@ -1,6 +1,10 @@
1
+ import { type ToolContext } from "../tools/ToolTypes.js";
1
2
  import type { DocdexClient } from "../docdex/DocdexClient.js";
2
3
  import type { VerificationCheckResult, VerificationCheckType, VerificationOutcome, VerificationPolicySummary, VerificationReasonCode, VerificationReport } from "./Types.js";
3
4
  export interface ValidationRunnerOptions {
5
+ signal?: AbortSignal;
6
+ shellExecutor?: ToolContext["shellExecutor"];
7
+ onOutput?: ToolContext["onOutput"];
4
8
  allowShell: boolean;
5
9
  shellAllowlist: string[];
6
10
  workspaceRoot: string;
@@ -1 +1 @@
1
- {"version":3,"file":"ValidationRunner.d.ts","sourceRoot":"","sources":["../../src/cognitive/ValidationRunner.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AAC9D,OAAO,KAAK,EACV,uBAAuB,EACvB,qBAAqB,EACrB,mBAAmB,EACnB,yBAAyB,EACzB,sBAAsB,EACtB,kBAAkB,EACnB,MAAM,YAAY,CAAC;AAEpB,MAAM,WAAW,uBAAuB;IACtC,UAAU,EAAE,OAAO,CAAC;IACpB,cAAc,EAAE,MAAM,EAAE,CAAC;IACzB,aAAa,EAAE,MAAM,CAAC;IACtB,YAAY,CAAC,EAAE,YAAY,CAAC;IAC5B,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,iBAAiB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EAAE,MAAM,EAAE,CAAC;IAC3B,MAAM,EAAE,gBAAgB,CAAC;IACzB,MAAM,EAAE,kBAAkB,CAAC;CAC5B;AAuQD,qBAAa,gBAAgB;IAC3B,OAAO,CAAC,OAAO,CAA0B;gBAE7B,OAAO,EAAE,uBAAuB;IAItC,GAAG,CAAC,KAAK,EAAE,MAAM,EAAE,EAAE,UAAU,GAAE,oBAAyB,GAAG,OAAO,CAAC,gBAAgB,CAAC;CA4O7F"}
@@ -1,4 +1,5 @@
1
- import { spawnSync } from "node:child_process";
1
+ import { runProcess } from "../tools/shell/AsyncProcess.js";
2
+ import { ToolExecutionError } from "../tools/ToolTypes.js";
2
3
  import { existsSync } from "node:fs";
3
4
  import path from "node:path";
4
5
  const DEFAULT_SHELL_TIMEOUT_MS = 120000;
@@ -266,6 +267,7 @@ export class ValidationRunner {
266
267
  this.options = options;
267
268
  }
268
269
  async run(steps, runOptions = {}) {
270
+ this.options.signal?.throwIfAborted();
269
271
  const errors = [];
270
272
  const touchedFiles = (runOptions.touchedFiles ?? []).map((entry) => entry.trim()).filter(Boolean);
271
273
  const languageSignals = detectLanguageSignals(touchedFiles);
@@ -330,6 +332,7 @@ export class ValidationRunner {
330
332
  }
331
333
  };
332
334
  for (const check of checks) {
335
+ this.options.signal?.throwIfAborted();
333
336
  const startedAt = Date.now();
334
337
  const step = check.step;
335
338
  if (!step) {
@@ -405,54 +408,28 @@ export class ValidationRunner {
405
408
  });
406
409
  continue;
407
410
  }
408
- const result = spawnSync(command, args, {
409
- cwd: this.options.workspaceRoot,
410
- encoding: "utf8",
411
- timeout: this.options.shellTimeoutMs ?? DEFAULT_SHELL_TIMEOUT_MS,
412
- });
413
- if (result.error) {
414
- const errorMessage = result.error.message;
415
- const timeoutHit = result.error.name === "TimeoutError"
416
- || result.error.code === "ETIMEDOUT"
417
- || result.error.message.toLowerCase().includes("timed out");
418
- pushResult({
419
- ...check,
420
- status: "failed",
421
- reason_code: timeoutHit
422
- ? "verification_command_timeout"
423
- : "verification_tool_unavailable",
424
- message: errorMessage,
425
- duration_ms: Date.now() - startedAt,
411
+ try {
412
+ const result = await (this.options.shellExecutor ?? runProcess)(command, args, {
413
+ workspaceRoot: this.options.workspaceRoot, signal: this.options.signal,
414
+ shellTimeoutMs: this.options.shellTimeoutMs ?? DEFAULT_SHELL_TIMEOUT_MS, onOutput: this.options.onOutput,
426
415
  });
427
- continue;
416
+ this.options.signal?.throwIfAborted();
417
+ const details = result.data;
418
+ pushResult({ ...check, status: "passed", evidence: compactText(details?.stdout ?? result.output) ?? `command succeeded: ${command}`, duration_ms: Date.now() - startedAt });
428
419
  }
429
- if (result.status === null && result.signal === "SIGTERM") {
420
+ catch (error) {
421
+ this.options.signal?.throwIfAborted();
422
+ const code = error instanceof ToolExecutionError ? error.code : undefined;
423
+ const details = error instanceof ToolExecutionError ? error.details : undefined;
430
424
  pushResult({
431
425
  ...check,
432
426
  status: "failed",
433
- reason_code: "verification_command_timeout",
434
- message: `command timed out: ${command}`,
427
+ reason_code: code === "tool_timeout" ? "verification_command_timeout" : code === "tool_execution_failed" ? "verification_command_failed" : "verification_tool_unavailable",
428
+ message: error instanceof Error ? error.message : String(error),
429
+ evidence: compactText(details?.stdout),
435
430
  duration_ms: Date.now() - startedAt,
436
431
  });
437
- continue;
438
- }
439
- if (result.status !== 0) {
440
- pushResult({
441
- ...check,
442
- status: "failed",
443
- reason_code: "verification_command_failed",
444
- message: result.stderr?.toString().trim() || `command failed: ${command}`,
445
- evidence: compactText(result.stdout?.toString()),
446
- duration_ms: Date.now() - startedAt,
447
- });
448
- continue;
449
432
  }
450
- pushResult({
451
- ...check,
452
- status: "passed",
453
- evidence: compactText(result.stdout?.toString()) ?? `command succeeded: ${command}`,
454
- duration_ms: Date.now() - startedAt,
455
- });
456
433
  }
457
434
  const totals = {
458
435
  configured: checks.length,
@@ -0,0 +1,21 @@
1
+ export interface ApprovedNodeModel {
2
+ model: string;
3
+ baseUrl?: string;
4
+ modelDigest?: string;
5
+ contextWindow?: number;
6
+ maxOutputTokens?: number;
7
+ modelsPath?: string;
8
+ supportsTools?: boolean;
9
+ supportsStreaming?: boolean;
10
+ }
11
+ /** The node may serve only the model already admitted by its registry/job boundary. */
12
+ export declare function loadNodeOrchestrationConfig(file: string, approved: ApprovedNodeModel, nativeReasoning?: {
13
+ reasoning_effort?: string;
14
+ reasoning_budget_tokens?: number;
15
+ }): Promise<{
16
+ sourceHash: string;
17
+ config: import("./OrchestrationConfig.js").OrchestrationConfig;
18
+ hash: string;
19
+ source: string;
20
+ }>;
21
+ //# sourceMappingURL=NodeOrchestration.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"NodeOrchestration.d.ts","sourceRoot":"","sources":["../../src/config/NodeOrchestration.ts"],"names":[],"mappings":"AAGA,MAAM,WAAW,iBAAiB;IAChC,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,iBAAiB,CAAC,EAAE,OAAO,CAAC;CAC7B;AAED,uFAAuF;AACvF,wBAAsB,2BAA2B,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,iBAAiB,EAAE,eAAe,GAAE;IAAE,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAAC,uBAAuB,CAAC,EAAE,MAAM,CAAA;CAAO;;;;;GAyCjL"}