@maiaos/cli 0.1.0-canary.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 (413) hide show
  1. package/README.md +287 -0
  2. package/dist/bin/maia.NOTICES.txt +59 -0
  3. package/dist/bin/maia.cdx.json +145 -0
  4. package/dist/bin/maia.mjs +2 -0
  5. package/dist/bootstrap/index.d.ts +3 -0
  6. package/dist/bootstrap/index.js +3 -0
  7. package/dist/bootstrap/process.d.ts +5 -0
  8. package/dist/bootstrap/process.js +45 -0
  9. package/dist/bootstrap/run.d.ts +25 -0
  10. package/dist/bootstrap/run.js +95 -0
  11. package/dist/bootstrap/stdio.d.ts +4 -0
  12. package/dist/bootstrap/stdio.js +9 -0
  13. package/dist/cli/cli.d.ts +17 -0
  14. package/dist/cli/cli.js +481 -0
  15. package/dist/cli/environment.d.ts +8 -0
  16. package/dist/cli/environment.js +12 -0
  17. package/dist/cli/index.d.ts +2 -0
  18. package/dist/cli/index.js +2 -0
  19. package/dist/cli/services.d.ts +4 -0
  20. package/dist/cli/services.js +4 -0
  21. package/dist/command-line/context.d.ts +178 -0
  22. package/dist/command-line/context.js +2 -0
  23. package/dist/command-line/index.d.ts +7 -0
  24. package/dist/command-line/index.js +6 -0
  25. package/dist/command-line/input/arguments.d.ts +55 -0
  26. package/dist/command-line/input/arguments.js +220 -0
  27. package/dist/command-line/input/index.d.ts +4 -0
  28. package/dist/command-line/input/index.js +4 -0
  29. package/dist/command-line/input/prompt.d.ts +8 -0
  30. package/dist/command-line/input/prompt.js +44 -0
  31. package/dist/command-line/input/stdin-stream.d.ts +4 -0
  32. package/dist/command-line/input/stdin-stream.js +3 -0
  33. package/dist/command-line/input/stdin.d.ts +11 -0
  34. package/dist/command-line/input/stdin.js +23 -0
  35. package/dist/command-line/json-decoder.d.ts +3 -0
  36. package/dist/command-line/json-decoder.js +3 -0
  37. package/dist/command-line/json.d.ts +3 -0
  38. package/dist/command-line/json.js +4 -0
  39. package/dist/command-line/output.d.ts +57 -0
  40. package/dist/command-line/output.js +94 -0
  41. package/dist/command-line/rows.d.ts +10 -0
  42. package/dist/command-line/rows.js +32 -0
  43. package/dist/command-line/two-phase.d.ts +57 -0
  44. package/dist/command-line/two-phase.js +148 -0
  45. package/dist/command-receipt/command.d.ts +4 -0
  46. package/dist/command-receipt/command.js +59 -0
  47. package/dist/command-receipt/compact-list.d.ts +20 -0
  48. package/dist/command-receipt/compact-list.js +29 -0
  49. package/dist/command-receipt/index.d.ts +3 -0
  50. package/dist/command-receipt/index.js +3 -0
  51. package/dist/command-tree/commands.d.ts +17 -0
  52. package/dist/command-tree/commands.js +41 -0
  53. package/dist/command-tree/completion.d.ts +6 -0
  54. package/dist/command-tree/completion.js +36 -0
  55. package/dist/command-tree/grammar.d.ts +18 -0
  56. package/dist/command-tree/grammar.js +160 -0
  57. package/dist/command-tree/help.d.ts +62 -0
  58. package/dist/command-tree/help.js +219 -0
  59. package/dist/command-tree/index.d.ts +8 -0
  60. package/dist/command-tree/index.js +6 -0
  61. package/dist/command-tree/local.d.ts +3 -0
  62. package/dist/command-tree/local.js +126 -0
  63. package/dist/command-tree/placeholder.d.ts +3 -0
  64. package/dist/command-tree/placeholder.js +4 -0
  65. package/dist/command-tree/row.d.ts +29 -0
  66. package/dist/command-tree/row.js +2 -0
  67. package/dist/command-tree/suggest.d.ts +3 -0
  68. package/dist/command-tree/suggest.js +81 -0
  69. package/dist/command-tree/tree.d.ts +34 -0
  70. package/dist/command-tree/tree.js +124 -0
  71. package/dist/connection/client.d.ts +692 -0
  72. package/dist/connection/client.js +28 -0
  73. package/dist/connection/commands.d.ts +15 -0
  74. package/dist/connection/commands.js +118 -0
  75. package/dist/connection/index.d.ts +7 -0
  76. package/dist/connection/index.js +7 -0
  77. package/dist/connection/input.d.ts +50 -0
  78. package/dist/connection/input.js +90 -0
  79. package/dist/connection/login.d.ts +13 -0
  80. package/dist/connection/login.js +69 -0
  81. package/dist/connection/output/format.d.ts +32 -0
  82. package/dist/connection/output/format.js +94 -0
  83. package/dist/connection/output/index.d.ts +2 -0
  84. package/dist/connection/output/index.js +2 -0
  85. package/dist/connection/resolve.d.ts +60 -0
  86. package/dist/connection/resolve.js +30 -0
  87. package/dist/connection/signin.d.ts +4 -0
  88. package/dist/connection/signin.js +32 -0
  89. package/dist/connection/system.d.ts +4 -0
  90. package/dist/connection/system.js +190 -0
  91. package/dist/connection/tree/index.d.ts +2 -0
  92. package/dist/connection/tree/index.js +2 -0
  93. package/dist/connection/tree/tree.d.ts +3 -0
  94. package/dist/connection/tree/tree.js +209 -0
  95. package/dist/container/client.d.ts +142 -0
  96. package/dist/container/client.js +11 -0
  97. package/dist/container/commands.d.ts +7 -0
  98. package/dist/container/commands.js +100 -0
  99. package/dist/container/index.d.ts +3 -0
  100. package/dist/container/index.js +3 -0
  101. package/dist/container/output/format.d.ts +11 -0
  102. package/dist/container/output/format.js +28 -0
  103. package/dist/container/output/index.d.ts +2 -0
  104. package/dist/container/output/index.js +2 -0
  105. package/dist/context/client.d.ts +7 -0
  106. package/dist/context/client.js +21 -0
  107. package/dist/context/commands.d.ts +3 -0
  108. package/dist/context/commands.js +27 -0
  109. package/dist/context/index.d.ts +3 -0
  110. package/dist/context/index.js +3 -0
  111. package/dist/development/cli.d.ts +3 -0
  112. package/dist/development/cli.js +44 -0
  113. package/dist/execution/client.d.ts +25 -0
  114. package/dist/execution/client.js +24 -0
  115. package/dist/execution/index.d.ts +3 -0
  116. package/dist/execution/index.js +3 -0
  117. package/dist/execution/relocation.d.ts +6 -0
  118. package/dist/execution/relocation.js +123 -0
  119. package/dist/execution/tree/index.d.ts +2 -0
  120. package/dist/execution/tree/index.js +2 -0
  121. package/dist/execution/tree/tree.d.ts +3 -0
  122. package/dist/execution/tree/tree.js +137 -0
  123. package/dist/hold/client.d.ts +137 -0
  124. package/dist/hold/client.js +12 -0
  125. package/dist/hold/commands.d.ts +5 -0
  126. package/dist/hold/commands.js +91 -0
  127. package/dist/hold/index.d.ts +3 -0
  128. package/dist/hold/index.js +3 -0
  129. package/dist/hold/output/format.d.ts +11 -0
  130. package/dist/hold/output/format.js +29 -0
  131. package/dist/hold/output/index.d.ts +2 -0
  132. package/dist/hold/output/index.js +2 -0
  133. package/dist/hold/tree/index.d.ts +2 -0
  134. package/dist/hold/tree/index.js +2 -0
  135. package/dist/hold/tree/tree.d.ts +3 -0
  136. package/dist/hold/tree/tree.js +96 -0
  137. package/dist/import/client.d.ts +14 -0
  138. package/dist/import/client.js +16 -0
  139. package/dist/import/commands.d.ts +5 -0
  140. package/dist/import/commands.js +76 -0
  141. package/dist/import/index.d.ts +3 -0
  142. package/dist/import/index.js +3 -0
  143. package/dist/import/input.d.ts +16 -0
  144. package/dist/import/input.js +92 -0
  145. package/dist/import/output.d.ts +6 -0
  146. package/dist/import/output.js +40 -0
  147. package/dist/index.d.ts +2 -0
  148. package/dist/index.js +2 -0
  149. package/dist/integration/client.d.ts +1284 -0
  150. package/dist/integration/client.js +24 -0
  151. package/dist/integration/commands.d.ts +10 -0
  152. package/dist/integration/commands.js +104 -0
  153. package/dist/integration/index.d.ts +3 -0
  154. package/dist/integration/index.js +3 -0
  155. package/dist/integration/output.d.ts +22 -0
  156. package/dist/integration/output.js +20 -0
  157. package/dist/local-node/call.d.ts +7 -0
  158. package/dist/local-node/call.js +13 -0
  159. package/dist/local-node/client.d.ts +67 -0
  160. package/dist/local-node/client.js +241 -0
  161. package/dist/local-node/index.d.ts +3 -0
  162. package/dist/local-node/index.js +3 -0
  163. package/dist/login/agent-provider.d.ts +20 -0
  164. package/dist/login/agent-provider.js +109 -0
  165. package/dist/login/commands.d.ts +4 -0
  166. package/dist/login/commands.js +93 -0
  167. package/dist/login/failure.d.ts +3 -0
  168. package/dist/login/failure.js +14 -0
  169. package/dist/login/gateway.d.ts +12 -0
  170. package/dist/login/gateway.js +71 -0
  171. package/dist/login/index.d.ts +3 -0
  172. package/dist/login/index.js +2 -0
  173. package/dist/login/menu.d.ts +4 -0
  174. package/dist/login/menu.js +105 -0
  175. package/dist/login/output/format.d.ts +16 -0
  176. package/dist/login/output/format.js +31 -0
  177. package/dist/login/output/index.d.ts +2 -0
  178. package/dist/login/output/index.js +2 -0
  179. package/dist/login/vendor-account.d.ts +95 -0
  180. package/dist/login/vendor-account.js +75 -0
  181. package/dist/login/vendor-input.d.ts +14 -0
  182. package/dist/login/vendor-input.js +36 -0
  183. package/dist/mcp/calls.d.ts +7 -0
  184. package/dist/mcp/calls.js +202 -0
  185. package/dist/mcp/commands.d.ts +9 -0
  186. package/dist/mcp/commands.js +21 -0
  187. package/dist/mcp/index.d.ts +2 -0
  188. package/dist/mcp/index.js +2 -0
  189. package/dist/mcp/server.d.ts +11 -0
  190. package/dist/mcp/server.js +57 -0
  191. package/dist/orchestration/client.d.ts +78 -0
  192. package/dist/orchestration/client.js +89 -0
  193. package/dist/orchestration/commands.d.ts +14 -0
  194. package/dist/orchestration/commands.js +312 -0
  195. package/dist/orchestration/index.d.ts +3 -0
  196. package/dist/orchestration/index.js +3 -0
  197. package/dist/orchestration/output/compact-aggregate.d.ts +121 -0
  198. package/dist/orchestration/output/compact-aggregate.js +110 -0
  199. package/dist/orchestration/output/compact-run-list.d.ts +20 -0
  200. package/dist/orchestration/output/compact-run-list.js +16 -0
  201. package/dist/orchestration/output/human.d.ts +80 -0
  202. package/dist/orchestration/output/human.js +252 -0
  203. package/dist/orchestration/output/index.d.ts +4 -0
  204. package/dist/orchestration/output/index.js +4 -0
  205. package/dist/orchestration/tree/index.d.ts +2 -0
  206. package/dist/orchestration/tree/index.js +2 -0
  207. package/dist/orchestration/tree/tree.d.ts +3 -0
  208. package/dist/orchestration/tree/tree.js +142 -0
  209. package/dist/port-lease/client.d.ts +160 -0
  210. package/dist/port-lease/client.js +11 -0
  211. package/dist/port-lease/commands.d.ts +6 -0
  212. package/dist/port-lease/commands.js +17 -0
  213. package/dist/port-lease/index.d.ts +3 -0
  214. package/dist/port-lease/index.js +3 -0
  215. package/dist/port-lease/input.d.ts +65 -0
  216. package/dist/port-lease/input.js +67 -0
  217. package/dist/port-lease/output/format.d.ts +11 -0
  218. package/dist/port-lease/output/format.js +24 -0
  219. package/dist/port-lease/output/index.d.ts +2 -0
  220. package/dist/port-lease/output/index.js +2 -0
  221. package/dist/presentation/client.d.ts +10 -0
  222. package/dist/presentation/client.js +9 -0
  223. package/dist/presentation/commands.d.ts +6 -0
  224. package/dist/presentation/commands.js +78 -0
  225. package/dist/presentation/index.d.ts +4 -0
  226. package/dist/presentation/index.js +3 -0
  227. package/dist/presentation/output/format.d.ts +11 -0
  228. package/dist/presentation/output/format.js +32 -0
  229. package/dist/presentation/output/index.d.ts +3 -0
  230. package/dist/presentation/output/index.js +2 -0
  231. package/dist/project-guard/client.d.ts +88 -0
  232. package/dist/project-guard/client.js +7 -0
  233. package/dist/project-guard/commands.d.ts +4 -0
  234. package/dist/project-guard/commands.js +39 -0
  235. package/dist/project-guard/index.d.ts +3 -0
  236. package/dist/project-guard/index.js +3 -0
  237. package/dist/project-guard/input.d.ts +18 -0
  238. package/dist/project-guard/input.js +47 -0
  239. package/dist/project-guard/output/format.d.ts +11 -0
  240. package/dist/project-guard/output/format.js +35 -0
  241. package/dist/project-guard/output/index.d.ts +2 -0
  242. package/dist/project-guard/output/index.js +2 -0
  243. package/dist/project-workspace/client.d.ts +86 -0
  244. package/dist/project-workspace/client.js +159 -0
  245. package/dist/project-workspace/commands.d.ts +30 -0
  246. package/dist/project-workspace/commands.js +700 -0
  247. package/dist/project-workspace/index.d.ts +5 -0
  248. package/dist/project-workspace/index.js +5 -0
  249. package/dist/project-workspace/metadata-client.d.ts +99 -0
  250. package/dist/project-workspace/metadata-client.js +8 -0
  251. package/dist/project-workspace/metadata-commands.d.ts +4 -0
  252. package/dist/project-workspace/metadata-commands.js +56 -0
  253. package/dist/project-workspace/output/human.d.ts +126 -0
  254. package/dist/project-workspace/output/human.js +103 -0
  255. package/dist/project-workspace/output/index.d.ts +3 -0
  256. package/dist/project-workspace/output/index.js +3 -0
  257. package/dist/project-workspace/output/metadata.d.ts +11 -0
  258. package/dist/project-workspace/output/metadata.js +17 -0
  259. package/dist/project-workspace/tree/index.d.ts +2 -0
  260. package/dist/project-workspace/tree/index.js +2 -0
  261. package/dist/project-workspace/tree/tree.d.ts +3 -0
  262. package/dist/project-workspace/tree/tree.js +197 -0
  263. package/dist/provider/client.d.ts +6 -0
  264. package/dist/provider/client.js +5 -0
  265. package/dist/provider/commands.d.ts +3 -0
  266. package/dist/provider/commands.js +38 -0
  267. package/dist/provider/index.d.ts +3 -0
  268. package/dist/provider/index.js +3 -0
  269. package/dist/reference/commands.d.ts +3 -0
  270. package/dist/reference/commands.js +39 -0
  271. package/dist/reference/index.d.ts +3 -0
  272. package/dist/reference/index.js +3 -0
  273. package/dist/reference/resolve.d.ts +29 -0
  274. package/dist/reference/resolve.js +294 -0
  275. package/dist/reference/tree/index.d.ts +2 -0
  276. package/dist/reference/tree/index.js +2 -0
  277. package/dist/reference/tree/tree.d.ts +3 -0
  278. package/dist/reference/tree/tree.js +17 -0
  279. package/dist/remote-node/client.d.ts +258 -0
  280. package/dist/remote-node/client.js +12 -0
  281. package/dist/remote-node/commands.d.ts +6 -0
  282. package/dist/remote-node/commands.js +264 -0
  283. package/dist/remote-node/connector.d.ts +59 -0
  284. package/dist/remote-node/connector.js +122 -0
  285. package/dist/remote-node/index.d.ts +4 -0
  286. package/dist/remote-node/index.js +4 -0
  287. package/dist/remote-node/reachability.d.ts +22 -0
  288. package/dist/remote-node/reachability.js +34 -0
  289. package/dist/remote-node/text.d.ts +9 -0
  290. package/dist/remote-node/text.js +64 -0
  291. package/dist/remote-node/tree/index.d.ts +2 -0
  292. package/dist/remote-node/tree/index.js +2 -0
  293. package/dist/remote-node/tree/tree.d.ts +3 -0
  294. package/dist/remote-node/tree/tree.js +51 -0
  295. package/dist/run-ledger/client.d.ts +358 -0
  296. package/dist/run-ledger/client.js +13 -0
  297. package/dist/run-ledger/commands.d.ts +8 -0
  298. package/dist/run-ledger/commands.js +19 -0
  299. package/dist/run-ledger/index.d.ts +3 -0
  300. package/dist/run-ledger/index.js +3 -0
  301. package/dist/run-ledger/input.d.ts +42 -0
  302. package/dist/run-ledger/input.js +107 -0
  303. package/dist/run-ledger/output/format.d.ts +11 -0
  304. package/dist/run-ledger/output/format.js +49 -0
  305. package/dist/run-ledger/output/index.d.ts +2 -0
  306. package/dist/run-ledger/output/index.js +2 -0
  307. package/dist/session/agent-permission.d.ts +63 -0
  308. package/dist/session/agent-permission.js +20 -0
  309. package/dist/session/approval/client.d.ts +117 -0
  310. package/dist/session/approval/client.js +7 -0
  311. package/dist/session/approval/commands.d.ts +7 -0
  312. package/dist/session/approval/commands.js +123 -0
  313. package/dist/session/approval/index.d.ts +3 -0
  314. package/dist/session/approval/index.js +3 -0
  315. package/dist/session/approval/output/format.d.ts +12 -0
  316. package/dist/session/approval/output/format.js +25 -0
  317. package/dist/session/approval/output/index.d.ts +2 -0
  318. package/dist/session/approval/output/index.js +2 -0
  319. package/dist/session/attach-client.d.ts +16 -0
  320. package/dist/session/attach-client.js +8 -0
  321. package/dist/session/attach-render.d.ts +16 -0
  322. package/dist/session/attach-render.js +154 -0
  323. package/dist/session/attach.d.ts +5 -0
  324. package/dist/session/attach.js +106 -0
  325. package/dist/session/client.d.ts +132 -0
  326. package/dist/session/client.js +128 -0
  327. package/dist/session/coding-client.d.ts +16 -0
  328. package/dist/session/coding-client.js +15 -0
  329. package/dist/session/coding-commands.d.ts +4 -0
  330. package/dist/session/coding-commands.js +50 -0
  331. package/dist/session/commands.d.ts +13 -0
  332. package/dist/session/commands.js +488 -0
  333. package/dist/session/create-tasks.d.ts +20 -0
  334. package/dist/session/create-tasks.js +110 -0
  335. package/dist/session/index.d.ts +9 -0
  336. package/dist/session/index.js +7 -0
  337. package/dist/session/interaction/client.d.ts +347 -0
  338. package/dist/session/interaction/client.js +15 -0
  339. package/dist/session/interaction/commands.d.ts +7 -0
  340. package/dist/session/interaction/commands.js +101 -0
  341. package/dist/session/interaction/index.d.ts +3 -0
  342. package/dist/session/interaction/index.js +3 -0
  343. package/dist/session/interaction/input.d.ts +15 -0
  344. package/dist/session/interaction/input.js +46 -0
  345. package/dist/session/interaction/output/format.d.ts +11 -0
  346. package/dist/session/interaction/output/format.js +3 -0
  347. package/dist/session/interaction/output/index.d.ts +2 -0
  348. package/dist/session/interaction/output/index.js +2 -0
  349. package/dist/session/output/diff.d.ts +3 -0
  350. package/dist/session/output/diff.js +30 -0
  351. package/dist/session/output/failure.d.ts +11 -0
  352. package/dist/session/output/failure.js +24 -0
  353. package/dist/session/output/human.d.ts +112 -0
  354. package/dist/session/output/human.js +71 -0
  355. package/dist/session/output/index.d.ts +6 -0
  356. package/dist/session/output/index.js +6 -0
  357. package/dist/session/output/observe.d.ts +4 -0
  358. package/dist/session/output/observe.js +46 -0
  359. package/dist/session/output/tasks.d.ts +19 -0
  360. package/dist/session/output/tasks.js +34 -0
  361. package/dist/session/rename.d.ts +3 -0
  362. package/dist/session/rename.js +37 -0
  363. package/dist/session/task-file.d.ts +5 -0
  364. package/dist/session/task-file.js +23 -0
  365. package/dist/session/tree/index.d.ts +2 -0
  366. package/dist/session/tree/index.js +2 -0
  367. package/dist/session/tree/tree.d.ts +3 -0
  368. package/dist/session/tree/tree.js +309 -0
  369. package/dist/session/turn/client.d.ts +25 -0
  370. package/dist/session/turn/client.js +40 -0
  371. package/dist/session/turn/commands.d.ts +6 -0
  372. package/dist/session/turn/commands.js +157 -0
  373. package/dist/session/turn/index.d.ts +4 -0
  374. package/dist/session/turn/index.js +3 -0
  375. package/dist/session/turn/output.d.ts +42 -0
  376. package/dist/session/turn/output.js +38 -0
  377. package/dist/status/client.d.ts +119 -0
  378. package/dist/status/client.js +5 -0
  379. package/dist/status/command.d.ts +4 -0
  380. package/dist/status/command.js +40 -0
  381. package/dist/status/doctor.d.ts +15 -0
  382. package/dist/status/doctor.js +111 -0
  383. package/dist/status/index.d.ts +5 -0
  384. package/dist/status/index.js +4 -0
  385. package/dist/status/output/compact.d.ts +31 -0
  386. package/dist/status/output/compact.js +46 -0
  387. package/dist/status/output/human.d.ts +7 -0
  388. package/dist/status/output/human.js +30 -0
  389. package/dist/status/output/index.d.ts +3 -0
  390. package/dist/status/output/index.js +3 -0
  391. package/dist/terminal/arguments.d.ts +13 -0
  392. package/dist/terminal/arguments.js +79 -0
  393. package/dist/terminal/client.d.ts +79 -0
  394. package/dist/terminal/client.js +68 -0
  395. package/dist/terminal/commands.d.ts +7 -0
  396. package/dist/terminal/commands.js +131 -0
  397. package/dist/terminal/control-commands.d.ts +10 -0
  398. package/dist/terminal/control-commands.js +212 -0
  399. package/dist/terminal/index.d.ts +4 -0
  400. package/dist/terminal/index.js +4 -0
  401. package/dist/terminal/output/compact-list.d.ts +147 -0
  402. package/dist/terminal/output/compact-list.js +152 -0
  403. package/dist/terminal/output/human.d.ts +59 -0
  404. package/dist/terminal/output/human.js +55 -0
  405. package/dist/terminal/output/index.d.ts +3 -0
  406. package/dist/terminal/output/index.js +3 -0
  407. package/dist/terminal/tree/index.d.ts +2 -0
  408. package/dist/terminal/tree/index.js +2 -0
  409. package/dist/terminal/tree/tree.d.ts +3 -0
  410. package/dist/terminal/tree/tree.js +104 -0
  411. package/guidance/maia-cli/SKILL.md +58 -0
  412. package/guidance/maia-orchestration/SKILL.md +54 -0
  413. package/package.json +76 -0
@@ -0,0 +1,75 @@
1
+ import { Effect } from "effect";
2
+ import { CliArgumentError, writeSuccess, } from "../command-line/index.js";
3
+ import { callNode, ConnectionNodeError, findConnectionByName, formatConnectionResult, redactConnection, redactConnectionResult, runVendorLogin, } from "../connection/index.js";
4
+ import { newCliIdentifier } from "../local-node/index.js";
5
+ import { safeLoginError } from "./failure.js";
6
+ import { nextFreeName } from "./vendor-input.js";
7
+ const allAccounts = (context) => callNode(context.dependencies.listConnections, (list) => list({ limit: 100 }));
8
+ const accountName = (context, input) => input.name === undefined
9
+ ? allAccounts(context).pipe(Effect.map((result) => nextFreeName(input.vendor, new Set(result.items.map((item) => item.name)))))
10
+ : Effect.succeed(input.name);
11
+ const createAccount = (context, input, name) => callNode(context.dependencies.createConnection, (create) => Effect.flatMap(newCliIdentifier("command"), (commandId) => create({
12
+ commandId,
13
+ configRootKind: "maia-managed",
14
+ executor: input.executor,
15
+ name,
16
+ ...(input.maxConcurrentSessions === undefined
17
+ ? {}
18
+ : { maxConcurrentSessions: input.maxConcurrentSessions }),
19
+ }))).pipe(Effect.map((result) => result.connection));
20
+ const requireSignable = (connection, input) => {
21
+ if (connection.executor !== input.executor)
22
+ return Effect.fail(new CliArgumentError(`'${connection.name}' is a ${connection.executor} account.`));
23
+ if (connection.state !== "enabled")
24
+ return Effect.fail(new CliArgumentError(`Enable '${connection.name}' first: maia connection enable ${connection.name}.`));
25
+ return connection.configRoot.kind === "maia-managed"
26
+ ? Effect.succeed(connection)
27
+ : Effect.fail(new CliArgumentError(`'${connection.name}' uses your normal ${input.vendor} login; it is already signed in through the ${input.vendor} CLI.`));
28
+ };
29
+ const signableAccount = (context, input) => Effect.gen(function* () {
30
+ const name = yield* accountName(context, input);
31
+ const existing = yield* findConnectionByName(context, name);
32
+ return yield* requireSignable(existing ?? (yield* createAccount(context, input, name)), input);
33
+ });
34
+ const vendorSignIn = (context, connection, input) => Effect.suspend(() => (context.dependencies.runVendorLogin ?? runVendorLogin)(connection, {
35
+ deviceCode: input.deviceCode,
36
+ })).pipe(Effect.catchDefect(Effect.fail), Effect.mapError(() => safeLoginError("The vendor sign-in could not start.")), Effect.flatMap((status) => status === 0
37
+ ? Effect.void
38
+ : Effect.fail(new ConnectionNodeError({
39
+ code: "login_failed",
40
+ message: `The ${connection.executor} sign-in exited with status ${String(status)}.`,
41
+ retryable: true,
42
+ }))));
43
+ const freshUsage = (context, connection) => connection.executor === "codex-cli"
44
+ ? callNode(context.dependencies.showConnectionUsage, (show) => show({ connectionId: connection.connectionId, refresh: true })).pipe(Effect.map((result) => result.connection), Effect.orElseSucceed(() => connection))
45
+ : Effect.succeed(connection);
46
+ export const signInHere = (context, input) => Effect.gen(function* () {
47
+ const connection = yield* signableAccount(context, input);
48
+ yield* vendorSignIn(context, connection, input);
49
+ return yield* freshUsage(context, connection);
50
+ });
51
+ export const writeSignedIn = (context, connection) => {
52
+ writeSuccess({
53
+ command: "connection.login",
54
+ result: {
55
+ connection: redactConnection(connection),
56
+ method: "connection.login",
57
+ },
58
+ }, context, formatConnectionResult);
59
+ return 0;
60
+ };
61
+ const startDeviceCodeLogin = (context, connection) => callNode(context.dependencies.startConnectionLogin, (start) => Effect.flatMap(newCliIdentifier("command"), (commandId) => start({
62
+ commandId,
63
+ connectionId: connection.connectionId,
64
+ expectedRevision: connection.revision,
65
+ flow: "device-code",
66
+ })));
67
+ export const signInThroughNode = (context, input) => Effect.gen(function* () {
68
+ if (input.executor !== "codex-cli")
69
+ return yield* Effect.fail(new CliArgumentError("Claude Code signs in from a terminal: run 'maia login claude' in one."));
70
+ const connection = yield* signableAccount(context, input);
71
+ const started = yield* startDeviceCodeLogin(context, connection);
72
+ writeSuccess({ command: started.method, result: redactConnectionResult(started) }, context, formatConnectionResult);
73
+ return 0;
74
+ });
75
+ //# sourceMappingURL=vendor-account.js.map
@@ -0,0 +1,14 @@
1
+ export type Vendor = "claude" | "codex";
2
+ type VendorExecutor = "claude-code" | "codex-cli";
3
+ export declare const vendorExecutor: (vendor: string) => undefined | VendorExecutor;
4
+ export type VendorLoginInput = {
5
+ readonly deviceCode: boolean;
6
+ readonly executor: VendorExecutor;
7
+ readonly maxConcurrentSessions?: number;
8
+ readonly name?: string;
9
+ readonly vendor: Vendor;
10
+ };
11
+ export declare const readVendorLogin: (tokens: readonly string[]) => VendorLoginInput;
12
+ export declare const nextFreeName: (vendor: Vendor, taken: ReadonlySet<string>) => string;
13
+ export {};
14
+ //# sourceMappingURL=vendor-input.d.ts.map
@@ -0,0 +1,36 @@
1
+ import { CliArgumentError, parseOptions, requirePositionals, } from "../command-line/index.js";
2
+ const EXECUTORS = new Map([
3
+ ["claude", "claude-code"],
4
+ ["codex", "codex-cli"],
5
+ ]);
6
+ export const vendorExecutor = (vendor) => EXECUTORS.get(vendor);
7
+ const readSessionLimit = (value) => {
8
+ if (value === undefined)
9
+ return {};
10
+ if (!/^(?:[1-9]|1[0-6])$/u.test(value))
11
+ throw new CliArgumentError("Option '--max-sessions' must be an integer from 1 to 16.");
12
+ return { maxConcurrentSessions: Number(value) };
13
+ };
14
+ export const readVendorLogin = (tokens) => {
15
+ const parsed = parseOptions(tokens, new Set(["--max-sessions", "--name"]), new Set(["--device-code"]));
16
+ requirePositionals(parsed.positionals, 1);
17
+ const vendor = parsed.positionals[0] ?? "";
18
+ const executor = vendorExecutor(vendor);
19
+ if (executor === undefined || (vendor !== "claude" && vendor !== "codex"))
20
+ throw new CliArgumentError("The vendor must be claude or codex.");
21
+ const name = parsed.options.get("--name");
22
+ return {
23
+ deviceCode: parsed.flags.has("--device-code"),
24
+ executor,
25
+ vendor,
26
+ ...(name === undefined ? {} : { name }),
27
+ ...readSessionLimit(parsed.options.get("--max-sessions")),
28
+ };
29
+ };
30
+ export const nextFreeName = (vendor, taken) => {
31
+ const candidate = (index) => taken.has(`${vendor}-${String(index)}`)
32
+ ? candidate(index + 1)
33
+ : `${vendor}-${String(index)}`;
34
+ return candidate(1);
35
+ };
36
+ //# sourceMappingURL=vendor-input.js.map
@@ -0,0 +1,7 @@
1
+ import type { CoordinatorToolOperation } from "@maiaos/sdk";
2
+ import { type LocalNodeRequestMethod } from "@maiaos/sdk";
3
+ import { type CliNodeEffect, type CliNodeOperations } from "../local-node/index.js";
4
+ export type CoordinatorCall = (node: CliNodeOperations, input: unknown) => CliNodeEffect<unknown>;
5
+ export declare const COORDINATOR_CALLS: ReadonlyMap<CoordinatorToolOperation, CoordinatorCall>;
6
+ export declare const WORKER_CALLS: ReadonlyMap<LocalNodeRequestMethod, CoordinatorCall>;
7
+ //# sourceMappingURL=calls.d.ts.map
@@ -0,0 +1,202 @@
1
+ import { approvalListParametersSchema, approvalShowParametersSchema, connectionDetectParametersSchema, connectionListParametersSchema, connectionModelsListParametersSchema, connectionShowParametersSchema, connectionUsageShowParametersSchema, containerIndexListParametersSchema, COORDINATOR_TOOL_OPERATIONS, discoverySessionsListParametersSchema, invocationContextShowParametersSchema, LOCAL_NODE_CALL_METHODS, localNodeRequestPayloadSchema, portLeaseAcquireParametersSchema, portLeaseListParametersSchema, portLeaseReleaseParametersSchema, portLeaseRenewParametersSchema, projectGuardShowParametersSchema, projectListParametersSchema, projectShowParametersSchema, receiptGetParametersSchema, runLedgerCreateParametersSchema, runLedgerListParametersSchema, runLedgerTaskDispatchParametersSchema, runLedgerTaskListParametersSchema, runLedgerTaskSettleParametersSchema, runLedgerTaskShowParametersSchema, sessionArchiveParametersSchema, sessionCreateParametersSchema, sessionDiffParametersSchema, sessionEventsListParametersSchema, sessionHistoryReadParametersSchema, sessionListParametersSchema, sessionObserveParametersSchema, sessionResumeParametersSchema, sessionShowParametersSchema, sessionStartParametersSchema, sessionStopParametersSchema, turnInterruptParametersSchema, turnSendParametersSchema, turnShowParametersSchema, turnWaitParametersSchema, workerToolDefinitions, workspaceListParametersSchema, workspaceShowParametersSchema, } from "@maiaos/sdk";
2
+ import { Predicate } from "effect";
3
+ import { invalidNodeInput, } from "../local-node/index.js";
4
+ const recoveryOf = (input) => Predicate.hasProperty(input, "commandId") &&
5
+ Predicate.isString(input.commandId)
6
+ ? { commandId: input.commandId }
7
+ : undefined;
8
+ const validated = (schema, run) => (node, input) => node.runValidatedNodeOperation(input, schema, run, recoveryOf(input));
9
+ const status = (node, input) => input === undefined ||
10
+ (Predicate.isObject(input) && Object.keys(input).length === 0)
11
+ ? node.runNodeClientOperation((client, options) => client.status(options))
12
+ : invalidNodeInput();
13
+ const callBound = new Set(LOCAL_NODE_CALL_METHODS);
14
+ const isCallPayload = (payload) => callBound.has(payload.method);
15
+ const isCallBound = (operation) => callBound.has(operation);
16
+ const typedCall = (method) => (node, input) => {
17
+ const payload = localNodeRequestPayloadSchema.safeParse({
18
+ method,
19
+ parameters: input,
20
+ });
21
+ if (!payload.success)
22
+ return invalidNodeInput(payload.error);
23
+ const { data } = payload;
24
+ return isCallPayload(data)
25
+ ? node.runNodeClientOperation((client, options) => client.call(data.method, data.parameters, options), recoveryOf(input))
26
+ : invalidNodeInput();
27
+ };
28
+ export const COORDINATOR_CALLS = new Map([
29
+ ...COORDINATOR_TOOL_OPERATIONS.filter(isCallBound).map((operation) => [operation, typedCall(operation)]),
30
+ [
31
+ "approval.list",
32
+ validated(approvalListParametersSchema, (client, parameters, options) => client.listApprovals(parameters, options)),
33
+ ],
34
+ [
35
+ "approval.show",
36
+ validated(approvalShowParametersSchema, (client, parameters, options) => client.showApproval(parameters, options)),
37
+ ],
38
+ [
39
+ "connection.detect",
40
+ validated(connectionDetectParametersSchema, (client, parameters, options) => client.detectConnections(parameters, options)),
41
+ ],
42
+ [
43
+ "connection.list",
44
+ validated(connectionListParametersSchema, (client, parameters, options) => client.listConnections(parameters, options)),
45
+ ],
46
+ [
47
+ "connection.models.list",
48
+ validated(connectionModelsListParametersSchema, (client, parameters, options) => client.listConnectionModels(parameters, options)),
49
+ ],
50
+ [
51
+ "connection.show",
52
+ validated(connectionShowParametersSchema, (client, parameters, options) => client.showConnection(parameters, options)),
53
+ ],
54
+ [
55
+ "connection.usage.show",
56
+ validated(connectionUsageShowParametersSchema, (client, parameters, options) => client.showConnectionUsage(parameters, options)),
57
+ ],
58
+ [
59
+ "container.index.list",
60
+ validated(containerIndexListParametersSchema, (client, parameters, options) => client.listContainerIndex(parameters, options)),
61
+ ],
62
+ [
63
+ "discovery.sessions.list",
64
+ validated(discoverySessionsListParametersSchema, (client, parameters, options) => client.listDiscoveredSessions(parameters, options)),
65
+ ],
66
+ ["node.status", status],
67
+ [
68
+ "port.lease.acquire",
69
+ validated(portLeaseAcquireParametersSchema, (client, parameters, options) => client.acquirePortLease(parameters, options)),
70
+ ],
71
+ [
72
+ "port.lease.list",
73
+ validated(portLeaseListParametersSchema, (client, parameters, options) => client.listPortLeases(parameters, options)),
74
+ ],
75
+ [
76
+ "port.lease.release",
77
+ validated(portLeaseReleaseParametersSchema, (client, parameters, options) => client.releasePortLease(parameters, options)),
78
+ ],
79
+ [
80
+ "port.lease.renew",
81
+ validated(portLeaseRenewParametersSchema, (client, parameters, options) => client.renewPortLease(parameters, options)),
82
+ ],
83
+ [
84
+ "project.guard.show",
85
+ validated(projectGuardShowParametersSchema, (client, parameters, options) => client.showProjectGuard(parameters, options)),
86
+ ],
87
+ [
88
+ "project.list",
89
+ validated(projectListParametersSchema, (client, parameters, options) => client.listProjects(parameters, options)),
90
+ ],
91
+ [
92
+ "project.show",
93
+ validated(projectShowParametersSchema, (client, parameters, options) => client.showProject(parameters, options)),
94
+ ],
95
+ [
96
+ "receipt.get",
97
+ validated(receiptGetParametersSchema, (client, parameters, options) => client.getReceipt(parameters, options)),
98
+ ],
99
+ [
100
+ "run.ledger.create",
101
+ validated(runLedgerCreateParametersSchema, (client, parameters, options) => client.createRunLedger(parameters, options)),
102
+ ],
103
+ [
104
+ "run.ledger.list",
105
+ validated(runLedgerListParametersSchema, (client, parameters, options) => client.listRunLedgers(parameters, options)),
106
+ ],
107
+ [
108
+ "run.ledger.task.dispatch",
109
+ validated(runLedgerTaskDispatchParametersSchema, (client, parameters, options) => client.dispatchRunLedgerTask(parameters, options)),
110
+ ],
111
+ [
112
+ "run.ledger.task.list",
113
+ validated(runLedgerTaskListParametersSchema, (client, parameters, options) => client.listRunLedgerTasks(parameters, options)),
114
+ ],
115
+ [
116
+ "run.ledger.task.settle",
117
+ validated(runLedgerTaskSettleParametersSchema, (client, parameters, options) => client.settleRunLedgerTask(parameters, options)),
118
+ ],
119
+ [
120
+ "run.ledger.task.show",
121
+ validated(runLedgerTaskShowParametersSchema, (client, parameters, options) => client.showRunLedgerTask(parameters, options)),
122
+ ],
123
+ [
124
+ "session.archive",
125
+ validated(sessionArchiveParametersSchema, (client, parameters, options) => client.archiveSession(parameters, options)),
126
+ ],
127
+ [
128
+ "session.create",
129
+ validated(sessionCreateParametersSchema, (client, parameters, options) => client.createSession(parameters, options)),
130
+ ],
131
+ [
132
+ "session.diff",
133
+ validated(sessionDiffParametersSchema, (client, parameters, options) => client.diffSession(parameters, options)),
134
+ ],
135
+ [
136
+ "session.events.list",
137
+ validated(sessionEventsListParametersSchema, (client, parameters, options) => client.listSessionEvents(parameters, options)),
138
+ ],
139
+ [
140
+ "session.history.read",
141
+ validated(sessionHistoryReadParametersSchema, (client, parameters, options) => client.readSessionHistory(parameters, options)),
142
+ ],
143
+ [
144
+ "session.list",
145
+ validated(sessionListParametersSchema, (client, parameters, options) => client.listSessions(parameters, options)),
146
+ ],
147
+ [
148
+ "session.observe",
149
+ validated(sessionObserveParametersSchema, (client, parameters, options) => client.observeSessions(parameters, options)),
150
+ ],
151
+ [
152
+ "session.resume",
153
+ validated(sessionResumeParametersSchema, (client, parameters, options) => client.resumeSession(parameters, options)),
154
+ ],
155
+ [
156
+ "session.show",
157
+ validated(sessionShowParametersSchema, (client, parameters, options) => client.showSession(parameters, options)),
158
+ ],
159
+ [
160
+ "session.start",
161
+ validated(sessionStartParametersSchema, (client, parameters, options) => client.startSession(parameters, options)),
162
+ ],
163
+ [
164
+ "session.stop",
165
+ validated(sessionStopParametersSchema, (client, parameters, options) => client.stopSession(parameters, options)),
166
+ ],
167
+ [
168
+ "turn.interrupt",
169
+ validated(turnInterruptParametersSchema, (client, parameters, options) => client.interruptTurn(parameters, options)),
170
+ ],
171
+ [
172
+ "turn.send",
173
+ validated(turnSendParametersSchema, (client, parameters, options) => client.sendTurn(parameters, options)),
174
+ ],
175
+ [
176
+ "turn.show",
177
+ validated(turnShowParametersSchema, (client, parameters, options) => client.showTurn(parameters, options)),
178
+ ],
179
+ [
180
+ "turn.wait",
181
+ validated(turnWaitParametersSchema, (client, parameters, options) => client.waitTurns(parameters, options)),
182
+ ],
183
+ [
184
+ "workspace.list",
185
+ validated(workspaceListParametersSchema, (client, parameters, options) => client.listWorkspaces(parameters, options)),
186
+ ],
187
+ [
188
+ "workspace.show",
189
+ validated(workspaceShowParametersSchema, (client, parameters, options) => client.showWorkspace(parameters, options)),
190
+ ],
191
+ ]);
192
+ export const WORKER_CALLS = (() => {
193
+ const available = new Map(COORDINATOR_CALLS);
194
+ available.set("context.show", validated(invocationContextShowParametersSchema, (client, parameters, options) => client.showCurrentContext(parameters, options)));
195
+ return new Map(workerToolDefinitions().map(({ operation }) => {
196
+ const call = available.get(operation);
197
+ if (call === undefined)
198
+ throw new Error(`No worker SDK call for ${operation}.`);
199
+ return [operation, call];
200
+ }));
201
+ })();
202
+ //# sourceMappingURL=calls.js.map
@@ -0,0 +1,9 @@
1
+ import * as Effect from "effect/Effect";
2
+ import { type CliServices, type CommandContext, type CommandEffect } from "../command-line/index.js";
3
+ import type { CliNodeOperations } from "../local-node/index.js";
4
+ export type McpCliDependencies = {
5
+ readonly serveMcp: (version: string, worker?: boolean) => Effect.Effect<number, unknown, CliServices>;
6
+ };
7
+ export declare const makeMcpClient: (node: CliNodeOperations) => McpCliDependencies;
8
+ export declare const runMcpCommand: (tokens: readonly string[], context: CommandContext) => CommandEffect;
9
+ //# sourceMappingURL=commands.d.ts.map
@@ -0,0 +1,21 @@
1
+ import * as Config from "effect/Config";
2
+ import * as Effect from "effect/Effect";
3
+ import * as Option from "effect/Option";
4
+ import { requireNoArguments, } from "../command-line/index.js";
5
+ export const makeMcpClient = (node) => ({
6
+ serveMcp: (version, worker = false) => Effect.promise(() => import("./server.js")).pipe(Effect.flatMap((module) => Effect.gen(function* () {
7
+ const credential = yield* Config.option(Config.String("MAIA_SESSION_CREDENTIAL"));
8
+ const origin = yield* Config.option(Config.String("MAIA_NODE_ORIGIN"));
9
+ const session = worker || Option.isSome(credential) || Option.isSome(origin);
10
+ return yield* module.serveCoordinatorMcp(session ? node.asSession() : node.asCoordinator(), version, { worker: session });
11
+ }))),
12
+ });
13
+ export const runMcpCommand = (tokens, context) => {
14
+ const worker = tokens[0] === "--worker";
15
+ requireNoArguments(worker ? tokens.slice(1) : tokens, "MCP");
16
+ const { serveMcp } = context.dependencies;
17
+ if (serveMcp === undefined)
18
+ return Effect.die(new Error("The MCP server is unavailable."));
19
+ return Effect.orDie(serveMcp(context.version, worker));
20
+ };
21
+ //# sourceMappingURL=commands.js.map
@@ -0,0 +1,2 @@
1
+ export { makeMcpClient, type McpCliDependencies, runMcpCommand, } from "./commands.js";
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1,2 @@
1
+ export { makeMcpClient, runMcpCommand, } from "./commands.js";
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1,11 @@
1
+ import { Cause, Crypto, Effect, Layer } from "effect";
2
+ import { McpSchema } from "effect/ai";
3
+ import type { Stdio } from "effect/Stdio";
4
+ import type { CliNodeOperations, CliNodeResult } from "../local-node/index.js";
5
+ export declare const toolResult: (result: CliNodeResult<unknown>) => McpSchema.CallToolResult;
6
+ export declare const coordinatorMcpLayer: (node: CliNodeOperations, version: string, worker?: boolean) => Layer.Layer<never, Cause.IllegalArgumentError, Crypto.Crypto | Stdio>;
7
+ export declare const serveCoordinatorMcp: (node: CliNodeOperations, version: string, options?: {
8
+ readonly stdio?: Layer.Layer<Stdio>;
9
+ readonly worker?: boolean;
10
+ }) => Effect.Effect<number, never, Crypto.Crypto>;
11
+ //# sourceMappingURL=server.d.ts.map
@@ -0,0 +1,57 @@
1
+ import * as NodeStdio from "@effect/platform-node-shared/NodeStdio";
2
+ import { coordinatorToolDefinitions, workerToolDefinitions, } from "@maiaos/sdk";
3
+ import { Cause, Context, Crypto, Effect, Exit, Fiber, Layer, Logger, } from "effect";
4
+ import { McpProtocol, McpSchema, McpServer } from "effect/ai";
5
+ import { COORDINATOR_CALLS, WORKER_CALLS, } from "./calls.js";
6
+ export const toolResult = (result) => result.ok
7
+ ? new McpSchema.CallToolResult({
8
+ content: [{ text: JSON.stringify(result.value), type: "text" }],
9
+ })
10
+ : new McpSchema.CallToolResult({
11
+ content: [
12
+ {
13
+ text: JSON.stringify({
14
+ error: result.error,
15
+ ...(result.recovery === undefined
16
+ ? {}
17
+ : { recovery: result.recovery }),
18
+ }),
19
+ type: "text",
20
+ },
21
+ ],
22
+ isError: true,
23
+ });
24
+ const toolFor = (definition) => new McpSchema.Tool({
25
+ annotations: {
26
+ destructiveHint: definition.destructive,
27
+ idempotentHint: true,
28
+ openWorldHint: false,
29
+ readOnlyHint: definition.readOnly,
30
+ },
31
+ description: definition.description,
32
+ inputSchema: definition.inputSchema,
33
+ name: definition.name,
34
+ });
35
+ const callFor = (definition) => {
36
+ const call = WORKER_CALLS.get(definition.operation) ??
37
+ [...COORDINATOR_CALLS].find(([operation]) => operation === definition.operation)?.[1];
38
+ return call === undefined
39
+ ? Effect.die(new Error(`No SDK call for ${definition.operation}.`))
40
+ : Effect.succeed(call);
41
+ };
42
+ const registerTools = (node, worker) => Effect.gen(function* () {
43
+ const server = yield* McpServer.McpServer;
44
+ const crypto = yield* Crypto.Crypto;
45
+ yield* Effect.forEach(worker ? workerToolDefinitions() : coordinatorToolDefinitions(), (definition) => Effect.flatMap(callFor(definition), (call) => server.addTool({
46
+ annotations: Context.empty(),
47
+ handle: (payload) => call(node, payload).pipe(Effect.provideService(Crypto.Crypto, crypto), Effect.map(toolResult)),
48
+ tool: toolFor(definition),
49
+ })), { discard: true });
50
+ });
51
+ export const coordinatorMcpLayer = (node, version, worker = false) => Layer.effectDiscard(registerTools(node, worker)).pipe(Layer.provide(McpServer.layerStdio({
52
+ name: "maia",
53
+ protocols: [McpProtocol.v2025_06_18],
54
+ version,
55
+ })));
56
+ export const serveCoordinatorMcp = (node, version, options = {}) => Layer.launch(coordinatorMcpLayer(node, version, options.worker)).pipe(Effect.provide(options.stdio ?? NodeStdio.layer), Effect.provideService(Logger.LogToStderr, true), Effect.forkChild, Effect.flatMap(Fiber.await), Effect.map((exit) => Exit.isSuccess(exit) || Cause.hasInterruptsOnly(exit.cause) ? 0 : 1));
57
+ //# sourceMappingURL=server.js.map
@@ -0,0 +1,78 @@
1
+ import type { OrchestrationDispatchSettleTerminalResult, OrchestrationDispatchShowResult, OrchestrationInboxAckResult, OrchestrationInboxCheckParameters, OrchestrationInboxCheckResult, OrchestrationQuestionCancelResult, OrchestrationQuestionOpenResult, OrchestrationQuestionReplyResult, OrchestrationRunCreateResult, OrchestrationRunListResult, OrchestrationRunShowResult, OrchestrationTaskGraph, OrchestrationTaskListResult, OrchestrationTaskShowResult } from "@maiaos/sdk";
2
+ import { type CliNodeEffect, type CliNodeOperations } from "../local-node/index.js";
3
+ type MutationInput = {
4
+ readonly commandId?: string;
5
+ };
6
+ type CreateRunInput = {
7
+ readonly commandId?: string;
8
+ readonly graph: OrchestrationTaskGraph;
9
+ readonly terminalId: string;
10
+ readonly workspaceId: string;
11
+ };
12
+ export declare const makeOrchestrationClient: (node: CliNodeOperations) => {
13
+ acknowledgeRunDelivery: (input: MutationInput & {
14
+ readonly coordinatorEpoch: 1;
15
+ readonly deliveryId: string;
16
+ readonly expectedMailboxRevision: string;
17
+ readonly owner: OrchestrationInboxCheckParameters["owner"];
18
+ readonly runId: string;
19
+ }) => CliNodeEffect<OrchestrationInboxAckResult>;
20
+ cancelRunQuestion: (input: (MutationInput & {
21
+ readonly coordinatorEpoch: 1;
22
+ readonly dispatchId: string;
23
+ readonly expectedDispatchRevision: string;
24
+ readonly expectedRunRevision: string;
25
+ readonly runId: string;
26
+ }) & {
27
+ readonly expectedQuestionRevision: string;
28
+ readonly questionId: string;
29
+ }) => CliNodeEffect<OrchestrationQuestionCancelResult>;
30
+ checkRunInbox: (input: OrchestrationInboxCheckParameters) => CliNodeEffect<OrchestrationInboxCheckResult>;
31
+ createRun: (input: CreateRunInput) => CliNodeEffect<OrchestrationRunCreateResult>;
32
+ listRuns: (input: {
33
+ readonly afterCursor: string;
34
+ readonly limit: number;
35
+ readonly workspaceId: string;
36
+ }) => CliNodeEffect<OrchestrationRunListResult>;
37
+ listTasks: (input: {
38
+ readonly afterCursor: string;
39
+ readonly limit: number;
40
+ readonly runId: string;
41
+ }) => CliNodeEffect<OrchestrationTaskListResult>;
42
+ openRunQuestion: (input: (MutationInput & {
43
+ readonly coordinatorEpoch: 1;
44
+ readonly dispatchId: string;
45
+ readonly expectedDispatchRevision: string;
46
+ readonly expectedRunRevision: string;
47
+ readonly runId: string;
48
+ }) & {
49
+ readonly body: string;
50
+ readonly subject: string;
51
+ }) => CliNodeEffect<OrchestrationQuestionOpenResult>;
52
+ replyRunQuestion: (input: (MutationInput & {
53
+ readonly coordinatorEpoch: 1;
54
+ readonly dispatchId: string;
55
+ readonly expectedDispatchRevision: string;
56
+ readonly expectedRunRevision: string;
57
+ readonly runId: string;
58
+ }) & {
59
+ readonly answer: string;
60
+ readonly expectedQuestionRevision: string;
61
+ readonly questionId: string;
62
+ }) => CliNodeEffect<OrchestrationQuestionReplyResult>;
63
+ settleRunDispatchTerminal: (input: MutationInput & {
64
+ readonly coordinatorEpoch: 1;
65
+ readonly dispatchId: string;
66
+ readonly expectedDispatchRevision: string;
67
+ readonly expectedRunRevision: string;
68
+ readonly runId: string;
69
+ }) => CliNodeEffect<OrchestrationDispatchSettleTerminalResult>;
70
+ showDispatch: (runId: string) => CliNodeEffect<OrchestrationDispatchShowResult>;
71
+ showRun: (runId: string) => CliNodeEffect<OrchestrationRunShowResult>;
72
+ showTask: (input: {
73
+ readonly runId: string;
74
+ readonly taskId: string;
75
+ }) => CliNodeEffect<OrchestrationTaskShowResult>;
76
+ };
77
+ export {};
78
+ //# sourceMappingURL=client.d.ts.map
@@ -0,0 +1,89 @@
1
+ import { inspectOrchestrationRunCreateAdmission, orchestrationDispatchSettleTerminalParametersSchema, orchestrationDispatchShowParametersSchema, orchestrationInboxAckParametersSchema, orchestrationInboxCheckParametersSchema, orchestrationQuestionCancelParametersSchema, orchestrationQuestionOpenParametersSchema, orchestrationQuestionReplyParametersSchema, orchestrationRunCreateParametersSchema, orchestrationRunListParametersSchema, orchestrationRunShowParametersSchema, orchestrationTaskListParametersSchema, orchestrationTaskShowParametersSchema, } from "@maiaos/sdk";
2
+ import * as Effect from "effect/Effect";
3
+ import { commandIdentifier, invalidNodeInput, } from "../local-node/index.js";
4
+ const admittedRunCreateParameters = (input, commandId) => {
5
+ const parameters = orchestrationRunCreateParametersSchema.safeParse({
6
+ commandId,
7
+ expectedRevision: "0",
8
+ graph: input.graph,
9
+ terminalId: input.terminalId,
10
+ workspaceId: input.workspaceId,
11
+ });
12
+ if (!parameters.success)
13
+ return;
14
+ try {
15
+ inspectOrchestrationRunCreateAdmission(parameters.data);
16
+ }
17
+ catch {
18
+ return;
19
+ }
20
+ return parameters.data;
21
+ };
22
+ export const makeOrchestrationClient = (node) => {
23
+ const createRun = (input) => {
24
+ return Effect.flatMap(commandIdentifier(input.commandId), (commandId) => {
25
+ const parameters = admittedRunCreateParameters(input, commandId);
26
+ if (parameters === undefined)
27
+ return invalidNodeInput();
28
+ return node.runNodeClientOperation((client, options) => client.createOrchestrationRun(parameters, options), { commandId });
29
+ });
30
+ };
31
+ const listRuns = (input) => {
32
+ return node.runValidatedNodeOperation(input, orchestrationRunListParametersSchema, (client, parameters, options) => client.listOrchestrationRuns(parameters, options));
33
+ };
34
+ const showRun = (runId) => {
35
+ return node.runValidatedNodeOperation({ runId }, orchestrationRunShowParametersSchema, (client, parameters, options) => client.showOrchestrationRun(parameters, options));
36
+ };
37
+ const listTasks = (input) => {
38
+ return node.runValidatedNodeOperation(input, orchestrationTaskListParametersSchema, (client, parameters, options) => client.listOrchestrationTasks(parameters, options));
39
+ };
40
+ const showDispatch = (runId) => {
41
+ return node.runValidatedNodeOperation({ runId }, orchestrationDispatchShowParametersSchema, (client, parameters, options) => client.showOrchestrationDispatch(parameters, options));
42
+ };
43
+ const showTask = (input) => {
44
+ return node.runValidatedNodeOperation(input, orchestrationTaskShowParametersSchema, (client, parameters, options) => client.showOrchestrationTask(parameters, options));
45
+ };
46
+ const checkRunInbox = (input) => {
47
+ return node.runValidatedNodeOperation(input, orchestrationInboxCheckParametersSchema, (client, parameters, options) => client.checkOrchestrationInbox(parameters, options));
48
+ };
49
+ const acknowledgeRunDelivery = (input) => {
50
+ return Effect.flatMap(commandIdentifier(input.commandId), (commandId) => {
51
+ return node.runValidatedNodeOperation({ ...input, commandId }, orchestrationInboxAckParametersSchema, (client, parameters, options) => client.acknowledgeOrchestrationDelivery(parameters, options), { commandId });
52
+ });
53
+ };
54
+ const openRunQuestion = (input) => {
55
+ return Effect.flatMap(commandIdentifier(input.commandId), (commandId) => {
56
+ return node.runValidatedNodeOperation({ ...input, commandId }, orchestrationQuestionOpenParametersSchema, (client, parameters, options) => client.openOrchestrationQuestion(parameters, options), { commandId });
57
+ });
58
+ };
59
+ const replyRunQuestion = (input) => {
60
+ return Effect.flatMap(commandIdentifier(input.commandId), (commandId) => {
61
+ return node.runValidatedNodeOperation({ ...input, commandId }, orchestrationQuestionReplyParametersSchema, (client, parameters, options) => client.replyOrchestrationQuestion(parameters, options), { commandId });
62
+ });
63
+ };
64
+ const cancelRunQuestion = (input) => {
65
+ return Effect.flatMap(commandIdentifier(input.commandId), (commandId) => {
66
+ return node.runValidatedNodeOperation({ ...input, commandId }, orchestrationQuestionCancelParametersSchema, (client, parameters, options) => client.cancelOrchestrationQuestion(parameters, options), { commandId });
67
+ });
68
+ };
69
+ const settleRunDispatchTerminal = (input) => {
70
+ return Effect.flatMap(commandIdentifier(input.commandId), (commandId) => {
71
+ return node.runValidatedNodeOperation({ ...input, commandId }, orchestrationDispatchSettleTerminalParametersSchema, (client, parameters, options) => client.settleOrchestrationDispatchTerminal(parameters, options), { commandId });
72
+ });
73
+ };
74
+ return {
75
+ acknowledgeRunDelivery,
76
+ cancelRunQuestion,
77
+ checkRunInbox,
78
+ createRun,
79
+ listRuns,
80
+ listTasks,
81
+ openRunQuestion,
82
+ replyRunQuestion,
83
+ settleRunDispatchTerminal,
84
+ showDispatch,
85
+ showRun,
86
+ showTask,
87
+ };
88
+ };
89
+ //# sourceMappingURL=client.js.map
@@ -0,0 +1,14 @@
1
+ import { type CommandContext, type CommandEffect } from "../command-line/index.js";
2
+ export declare const runCreate: (tokens: readonly string[], context: CommandContext) => CommandEffect;
3
+ export declare const runShow: (tokens: readonly string[], context: CommandContext) => CommandEffect;
4
+ export declare const runList: (tokens: readonly string[], context: CommandContext) => CommandEffect;
5
+ export declare const runTaskList: (tokens: readonly string[], context: CommandContext) => CommandEffect;
6
+ export declare const runTaskShow: (tokens: readonly string[], context: CommandContext) => CommandEffect;
7
+ export declare const runInboxCheck: (tokens: readonly string[], context: CommandContext) => CommandEffect;
8
+ export declare const runInboxAck: (tokens: readonly string[], context: CommandContext) => CommandEffect;
9
+ export declare const runQuestionOpen: (tokens: readonly string[], context: CommandContext) => CommandEffect;
10
+ export declare const runQuestionReply: (tokens: readonly string[], context: CommandContext) => CommandEffect;
11
+ export declare const runQuestionCancel: (tokens: readonly string[], context: CommandContext) => CommandEffect;
12
+ export declare const runDispatchShow: (tokens: readonly string[], context: CommandContext) => CommandEffect;
13
+ export declare const runDispatchSettleTerminal: (tokens: readonly string[], context: CommandContext) => CommandEffect;
14
+ //# sourceMappingURL=commands.d.ts.map