@miosa/cli 1.3.4 → 2.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (489) hide show
  1. package/README.md +20 -835
  2. package/bin/miosa.js +75 -0
  3. package/lib/archive.js +88 -0
  4. package/lib/checksums.js +29 -0
  5. package/lib/platforms.js +31 -0
  6. package/lib/resolve.js +47 -0
  7. package/package.json +26 -41
  8. package/scripts/postinstall.js +68 -0
  9. package/CHANGELOG.md +0 -110
  10. package/dist/action-authority.d.ts +0 -106
  11. package/dist/action-authority.d.ts.map +0 -1
  12. package/dist/action-authority.js +0 -116
  13. package/dist/action-authority.js.map +0 -1
  14. package/dist/app-advisor.d.ts +0 -80
  15. package/dist/app-advisor.d.ts.map +0 -1
  16. package/dist/app-advisor.js +0 -486
  17. package/dist/app-advisor.js.map +0 -1
  18. package/dist/app-contract.d.ts +0 -92
  19. package/dist/app-contract.d.ts.map +0 -1
  20. package/dist/app-contract.js +0 -218
  21. package/dist/app-contract.js.map +0 -1
  22. package/dist/app-document.d.ts +0 -23
  23. package/dist/app-document.d.ts.map +0 -1
  24. package/dist/app-document.js +0 -180
  25. package/dist/app-document.js.map +0 -1
  26. package/dist/app-manifest.d.ts +0 -140
  27. package/dist/app-manifest.d.ts.map +0 -1
  28. package/dist/app-manifest.js +0 -377
  29. package/dist/app-manifest.js.map +0 -1
  30. package/dist/app-operation.d.ts +0 -23
  31. package/dist/app-operation.d.ts.map +0 -1
  32. package/dist/app-operation.js +0 -49
  33. package/dist/app-operation.js.map +0 -1
  34. package/dist/app-release.d.ts +0 -132
  35. package/dist/app-release.d.ts.map +0 -1
  36. package/dist/app-release.js +0 -294
  37. package/dist/app-release.js.map +0 -1
  38. package/dist/bin/miosa.d.ts +0 -3
  39. package/dist/bin/miosa.d.ts.map +0 -1
  40. package/dist/bin/miosa.js +0 -288
  41. package/dist/bin/miosa.js.map +0 -1
  42. package/dist/cli-env.d.ts +0 -12
  43. package/dist/cli-env.d.ts.map +0 -1
  44. package/dist/cli-env.js +0 -34
  45. package/dist/cli-env.js.map +0 -1
  46. package/dist/client.d.ts +0 -155
  47. package/dist/client.d.ts.map +0 -1
  48. package/dist/client.js +0 -865
  49. package/dist/client.js.map +0 -1
  50. package/dist/commands/actions.d.ts +0 -3
  51. package/dist/commands/actions.d.ts.map +0 -1
  52. package/dist/commands/actions.js +0 -222
  53. package/dist/commands/actions.js.map +0 -1
  54. package/dist/commands/agent-runtime-profiles.d.ts +0 -3
  55. package/dist/commands/agent-runtime-profiles.d.ts.map +0 -1
  56. package/dist/commands/agent-runtime-profiles.js +0 -198
  57. package/dist/commands/agent-runtime-profiles.js.map +0 -1
  58. package/dist/commands/agent.d.ts +0 -18
  59. package/dist/commands/agent.d.ts.map +0 -1
  60. package/dist/commands/agent.js +0 -737
  61. package/dist/commands/agent.js.map +0 -1
  62. package/dist/commands/alerts.d.ts +0 -3
  63. package/dist/commands/alerts.d.ts.map +0 -1
  64. package/dist/commands/alerts.js +0 -41
  65. package/dist/commands/alerts.js.map +0 -1
  66. package/dist/commands/api-keys.d.ts +0 -3
  67. package/dist/commands/api-keys.d.ts.map +0 -1
  68. package/dist/commands/api-keys.js +0 -160
  69. package/dist/commands/api-keys.js.map +0 -1
  70. package/dist/commands/api-resource.d.ts +0 -20
  71. package/dist/commands/api-resource.d.ts.map +0 -1
  72. package/dist/commands/api-resource.js +0 -120
  73. package/dist/commands/api-resource.js.map +0 -1
  74. package/dist/commands/app.d.ts +0 -38
  75. package/dist/commands/app.d.ts.map +0 -1
  76. package/dist/commands/app.js +0 -1182
  77. package/dist/commands/app.js.map +0 -1
  78. package/dist/commands/apps.d.ts +0 -3
  79. package/dist/commands/apps.d.ts.map +0 -1
  80. package/dist/commands/apps.js +0 -218
  81. package/dist/commands/apps.js.map +0 -1
  82. package/dist/commands/audit.d.ts +0 -3
  83. package/dist/commands/audit.d.ts.map +0 -1
  84. package/dist/commands/audit.js +0 -25
  85. package/dist/commands/audit.js.map +0 -1
  86. package/dist/commands/auth.d.ts +0 -3
  87. package/dist/commands/auth.d.ts.map +0 -1
  88. package/dist/commands/auth.js +0 -282
  89. package/dist/commands/auth.js.map +0 -1
  90. package/dist/commands/backups.d.ts +0 -3
  91. package/dist/commands/backups.d.ts.map +0 -1
  92. package/dist/commands/backups.js +0 -23
  93. package/dist/commands/backups.js.map +0 -1
  94. package/dist/commands/billing.d.ts +0 -3
  95. package/dist/commands/billing.d.ts.map +0 -1
  96. package/dist/commands/billing.js +0 -208
  97. package/dist/commands/billing.js.map +0 -1
  98. package/dist/commands/builds.d.ts +0 -3
  99. package/dist/commands/builds.d.ts.map +0 -1
  100. package/dist/commands/builds.js +0 -198
  101. package/dist/commands/builds.js.map +0 -1
  102. package/dist/commands/capabilities.d.ts +0 -3
  103. package/dist/commands/capabilities.d.ts.map +0 -1
  104. package/dist/commands/capabilities.js +0 -1002
  105. package/dist/commands/capabilities.js.map +0 -1
  106. package/dist/commands/checkpoints.d.ts +0 -3
  107. package/dist/commands/checkpoints.d.ts.map +0 -1
  108. package/dist/commands/checkpoints.js +0 -193
  109. package/dist/commands/checkpoints.js.map +0 -1
  110. package/dist/commands/cleanup.d.ts +0 -3
  111. package/dist/commands/cleanup.d.ts.map +0 -1
  112. package/dist/commands/cleanup.js +0 -65
  113. package/dist/commands/cleanup.js.map +0 -1
  114. package/dist/commands/cloud.d.ts +0 -3
  115. package/dist/commands/cloud.d.ts.map +0 -1
  116. package/dist/commands/cloud.js +0 -192
  117. package/dist/commands/cloud.js.map +0 -1
  118. package/dist/commands/command-overview.d.ts +0 -13
  119. package/dist/commands/command-overview.d.ts.map +0 -1
  120. package/dist/commands/command-overview.js +0 -50
  121. package/dist/commands/command-overview.js.map +0 -1
  122. package/dist/commands/completion.d.ts +0 -3
  123. package/dist/commands/completion.d.ts.map +0 -1
  124. package/dist/commands/completion.js +0 -183
  125. package/dist/commands/completion.js.map +0 -1
  126. package/dist/commands/computers.d.ts +0 -3
  127. package/dist/commands/computers.d.ts.map +0 -1
  128. package/dist/commands/computers.js +0 -706
  129. package/dist/commands/computers.js.map +0 -1
  130. package/dist/commands/config.d.ts +0 -3
  131. package/dist/commands/config.d.ts.map +0 -1
  132. package/dist/commands/config.js +0 -114
  133. package/dist/commands/config.js.map +0 -1
  134. package/dist/commands/connect.d.ts +0 -6
  135. package/dist/commands/connect.d.ts.map +0 -1
  136. package/dist/commands/connect.js +0 -127
  137. package/dist/commands/connect.js.map +0 -1
  138. package/dist/commands/connectors.d.ts +0 -3
  139. package/dist/commands/connectors.d.ts.map +0 -1
  140. package/dist/commands/connectors.js +0 -172
  141. package/dist/commands/connectors.js.map +0 -1
  142. package/dist/commands/containers.d.ts +0 -3
  143. package/dist/commands/containers.d.ts.map +0 -1
  144. package/dist/commands/containers.js +0 -20
  145. package/dist/commands/containers.js.map +0 -1
  146. package/dist/commands/context.d.ts +0 -3
  147. package/dist/commands/context.d.ts.map +0 -1
  148. package/dist/commands/context.js +0 -233
  149. package/dist/commands/context.js.map +0 -1
  150. package/dist/commands/cp.d.ts +0 -3
  151. package/dist/commands/cp.d.ts.map +0 -1
  152. package/dist/commands/cp.js +0 -319
  153. package/dist/commands/cp.js.map +0 -1
  154. package/dist/commands/cron.d.ts +0 -3
  155. package/dist/commands/cron.d.ts.map +0 -1
  156. package/dist/commands/cron.js +0 -65
  157. package/dist/commands/cron.js.map +0 -1
  158. package/dist/commands/dashboard.d.ts +0 -13
  159. package/dist/commands/dashboard.d.ts.map +0 -1
  160. package/dist/commands/dashboard.js +0 -54
  161. package/dist/commands/dashboard.js.map +0 -1
  162. package/dist/commands/databases.d.ts +0 -3
  163. package/dist/commands/databases.d.ts.map +0 -1
  164. package/dist/commands/databases.js +0 -714
  165. package/dist/commands/databases.js.map +0 -1
  166. package/dist/commands/db.d.ts +0 -3
  167. package/dist/commands/db.d.ts.map +0 -1
  168. package/dist/commands/db.js +0 -385
  169. package/dist/commands/db.js.map +0 -1
  170. package/dist/commands/deploy.d.ts +0 -3
  171. package/dist/commands/deploy.d.ts.map +0 -1
  172. package/dist/commands/deploy.js +0 -1234
  173. package/dist/commands/deploy.js.map +0 -1
  174. package/dist/commands/desktop.d.ts +0 -3
  175. package/dist/commands/desktop.d.ts.map +0 -1
  176. package/dist/commands/desktop.js +0 -277
  177. package/dist/commands/desktop.js.map +0 -1
  178. package/dist/commands/dev.d.ts +0 -3
  179. package/dist/commands/dev.d.ts.map +0 -1
  180. package/dist/commands/dev.js +0 -245
  181. package/dist/commands/dev.js.map +0 -1
  182. package/dist/commands/devices.d.ts +0 -3
  183. package/dist/commands/devices.d.ts.map +0 -1
  184. package/dist/commands/devices.js +0 -279
  185. package/dist/commands/devices.js.map +0 -1
  186. package/dist/commands/docker-deploy.d.ts +0 -3
  187. package/dist/commands/docker-deploy.d.ts.map +0 -1
  188. package/dist/commands/docker-deploy.js +0 -659
  189. package/dist/commands/docker-deploy.js.map +0 -1
  190. package/dist/commands/doctor.d.ts +0 -69
  191. package/dist/commands/doctor.d.ts.map +0 -1
  192. package/dist/commands/doctor.js +0 -596
  193. package/dist/commands/doctor.js.map +0 -1
  194. package/dist/commands/domains.d.ts +0 -3
  195. package/dist/commands/domains.d.ts.map +0 -1
  196. package/dist/commands/domains.js +0 -307
  197. package/dist/commands/domains.js.map +0 -1
  198. package/dist/commands/enterprise-util.d.ts +0 -39
  199. package/dist/commands/enterprise-util.d.ts.map +0 -1
  200. package/dist/commands/enterprise-util.js +0 -217
  201. package/dist/commands/enterprise-util.js.map +0 -1
  202. package/dist/commands/env-input.d.ts +0 -26
  203. package/dist/commands/env-input.d.ts.map +0 -1
  204. package/dist/commands/env-input.js +0 -68
  205. package/dist/commands/env-input.js.map +0 -1
  206. package/dist/commands/env.d.ts +0 -3
  207. package/dist/commands/env.d.ts.map +0 -1
  208. package/dist/commands/env.js +0 -189
  209. package/dist/commands/env.js.map +0 -1
  210. package/dist/commands/exec.d.ts +0 -3
  211. package/dist/commands/exec.d.ts.map +0 -1
  212. package/dist/commands/exec.js +0 -110
  213. package/dist/commands/exec.js.map +0 -1
  214. package/dist/commands/forge.d.ts +0 -3
  215. package/dist/commands/forge.d.ts.map +0 -1
  216. package/dist/commands/forge.js +0 -254
  217. package/dist/commands/forge.js.map +0 -1
  218. package/dist/commands/functions.d.ts +0 -3
  219. package/dist/commands/functions.d.ts.map +0 -1
  220. package/dist/commands/functions.js +0 -47
  221. package/dist/commands/functions.js.map +0 -1
  222. package/dist/commands/gha-runners.d.ts +0 -3
  223. package/dist/commands/gha-runners.d.ts.map +0 -1
  224. package/dist/commands/gha-runners.js +0 -33
  225. package/dist/commands/gha-runners.js.map +0 -1
  226. package/dist/commands/groups.d.ts +0 -3
  227. package/dist/commands/groups.d.ts.map +0 -1
  228. package/dist/commands/groups.js +0 -38
  229. package/dist/commands/groups.js.map +0 -1
  230. package/dist/commands/host.d.ts +0 -3
  231. package/dist/commands/host.d.ts.map +0 -1
  232. package/dist/commands/host.js +0 -74
  233. package/dist/commands/host.js.map +0 -1
  234. package/dist/commands/hosts.d.ts +0 -7
  235. package/dist/commands/hosts.d.ts.map +0 -1
  236. package/dist/commands/hosts.js +0 -91
  237. package/dist/commands/hosts.js.map +0 -1
  238. package/dist/commands/link.d.ts +0 -8
  239. package/dist/commands/link.d.ts.map +0 -1
  240. package/dist/commands/link.js +0 -124
  241. package/dist/commands/link.js.map +0 -1
  242. package/dist/commands/login.d.ts +0 -10
  243. package/dist/commands/login.d.ts.map +0 -1
  244. package/dist/commands/login.js +0 -263
  245. package/dist/commands/login.js.map +0 -1
  246. package/dist/commands/logout.d.ts +0 -3
  247. package/dist/commands/logout.d.ts.map +0 -1
  248. package/dist/commands/logout.js +0 -43
  249. package/dist/commands/logout.js.map +0 -1
  250. package/dist/commands/logs.d.ts +0 -3
  251. package/dist/commands/logs.d.ts.map +0 -1
  252. package/dist/commands/logs.js +0 -401
  253. package/dist/commands/logs.js.map +0 -1
  254. package/dist/commands/ls.d.ts +0 -3
  255. package/dist/commands/ls.d.ts.map +0 -1
  256. package/dist/commands/ls.js +0 -121
  257. package/dist/commands/ls.js.map +0 -1
  258. package/dist/commands/mcp.d.ts +0 -46
  259. package/dist/commands/mcp.d.ts.map +0 -1
  260. package/dist/commands/mcp.js +0 -3413
  261. package/dist/commands/mcp.js.map +0 -1
  262. package/dist/commands/menu.d.ts +0 -29
  263. package/dist/commands/menu.d.ts.map +0 -1
  264. package/dist/commands/menu.js +0 -147
  265. package/dist/commands/menu.js.map +0 -1
  266. package/dist/commands/meshes.d.ts +0 -3
  267. package/dist/commands/meshes.d.ts.map +0 -1
  268. package/dist/commands/meshes.js +0 -27
  269. package/dist/commands/meshes.js.map +0 -1
  270. package/dist/commands/network-policy.d.ts +0 -3
  271. package/dist/commands/network-policy.d.ts.map +0 -1
  272. package/dist/commands/network-policy.js +0 -155
  273. package/dist/commands/network-policy.js.map +0 -1
  274. package/dist/commands/new.d.ts +0 -3
  275. package/dist/commands/new.d.ts.map +0 -1
  276. package/dist/commands/new.js +0 -296
  277. package/dist/commands/new.js.map +0 -1
  278. package/dist/commands/opencomputers.d.ts +0 -10
  279. package/dist/commands/opencomputers.d.ts.map +0 -1
  280. package/dist/commands/opencomputers.js +0 -25
  281. package/dist/commands/opencomputers.js.map +0 -1
  282. package/dist/commands/operating-contract.d.ts +0 -3
  283. package/dist/commands/operating-contract.d.ts.map +0 -1
  284. package/dist/commands/operating-contract.js +0 -651
  285. package/dist/commands/operating-contract.js.map +0 -1
  286. package/dist/commands/project.d.ts +0 -4
  287. package/dist/commands/project.d.ts.map +0 -1
  288. package/dist/commands/project.js +0 -25
  289. package/dist/commands/project.js.map +0 -1
  290. package/dist/commands/pull.d.ts +0 -14
  291. package/dist/commands/pull.d.ts.map +0 -1
  292. package/dist/commands/pull.js +0 -156
  293. package/dist/commands/pull.js.map +0 -1
  294. package/dist/commands/regions.d.ts +0 -3
  295. package/dist/commands/regions.d.ts.map +0 -1
  296. package/dist/commands/regions.js +0 -103
  297. package/dist/commands/regions.js.map +0 -1
  298. package/dist/commands/releases.d.ts +0 -3
  299. package/dist/commands/releases.d.ts.map +0 -1
  300. package/dist/commands/releases.js +0 -365
  301. package/dist/commands/releases.js.map +0 -1
  302. package/dist/commands/rm.d.ts +0 -3
  303. package/dist/commands/rm.d.ts.map +0 -1
  304. package/dist/commands/rm.js +0 -42
  305. package/dist/commands/rm.js.map +0 -1
  306. package/dist/commands/rollback.d.ts +0 -3
  307. package/dist/commands/rollback.d.ts.map +0 -1
  308. package/dist/commands/rollback.js +0 -62
  309. package/dist/commands/rollback.js.map +0 -1
  310. package/dist/commands/run-groups.d.ts +0 -3
  311. package/dist/commands/run-groups.d.ts.map +0 -1
  312. package/dist/commands/run-groups.js +0 -364
  313. package/dist/commands/run-groups.js.map +0 -1
  314. package/dist/commands/run.d.ts +0 -3
  315. package/dist/commands/run.d.ts.map +0 -1
  316. package/dist/commands/run.js +0 -130
  317. package/dist/commands/run.js.map +0 -1
  318. package/dist/commands/runs.d.ts +0 -3
  319. package/dist/commands/runs.d.ts.map +0 -1
  320. package/dist/commands/runs.js +0 -365
  321. package/dist/commands/runs.js.map +0 -1
  322. package/dist/commands/runtime-env.d.ts +0 -3
  323. package/dist/commands/runtime-env.d.ts.map +0 -1
  324. package/dist/commands/runtime-env.js +0 -114
  325. package/dist/commands/runtime-env.js.map +0 -1
  326. package/dist/commands/sandbox-delete-guard.d.ts +0 -4
  327. package/dist/commands/sandbox-delete-guard.d.ts.map +0 -1
  328. package/dist/commands/sandbox-delete-guard.js +0 -32
  329. package/dist/commands/sandbox-delete-guard.js.map +0 -1
  330. package/dist/commands/sandbox-dev.d.ts +0 -20
  331. package/dist/commands/sandbox-dev.d.ts.map +0 -1
  332. package/dist/commands/sandbox-dev.js +0 -583
  333. package/dist/commands/sandbox-dev.js.map +0 -1
  334. package/dist/commands/sandbox.d.ts +0 -36
  335. package/dist/commands/sandbox.d.ts.map +0 -1
  336. package/dist/commands/sandbox.js +0 -3796
  337. package/dist/commands/sandbox.js.map +0 -1
  338. package/dist/commands/scale.d.ts +0 -3
  339. package/dist/commands/scale.d.ts.map +0 -1
  340. package/dist/commands/scale.js +0 -61
  341. package/dist/commands/scale.js.map +0 -1
  342. package/dist/commands/schedules.d.ts +0 -3
  343. package/dist/commands/schedules.d.ts.map +0 -1
  344. package/dist/commands/schedules.js +0 -37
  345. package/dist/commands/schedules.js.map +0 -1
  346. package/dist/commands/secrets.d.ts +0 -3
  347. package/dist/commands/secrets.d.ts.map +0 -1
  348. package/dist/commands/secrets.js +0 -200
  349. package/dist/commands/secrets.js.map +0 -1
  350. package/dist/commands/services.d.ts +0 -3
  351. package/dist/commands/services.d.ts.map +0 -1
  352. package/dist/commands/services.js +0 -70
  353. package/dist/commands/services.js.map +0 -1
  354. package/dist/commands/shell.d.ts +0 -16
  355. package/dist/commands/shell.d.ts.map +0 -1
  356. package/dist/commands/shell.js +0 -555
  357. package/dist/commands/shell.js.map +0 -1
  358. package/dist/commands/snapshot.d.ts +0 -10
  359. package/dist/commands/snapshot.d.ts.map +0 -1
  360. package/dist/commands/snapshot.js +0 -181
  361. package/dist/commands/snapshot.js.map +0 -1
  362. package/dist/commands/ssh.d.ts +0 -3
  363. package/dist/commands/ssh.d.ts.map +0 -1
  364. package/dist/commands/ssh.js +0 -93
  365. package/dist/commands/ssh.js.map +0 -1
  366. package/dist/commands/status.d.ts +0 -3
  367. package/dist/commands/status.d.ts.map +0 -1
  368. package/dist/commands/status.js +0 -302
  369. package/dist/commands/status.js.map +0 -1
  370. package/dist/commands/storage.d.ts +0 -3
  371. package/dist/commands/storage.d.ts.map +0 -1
  372. package/dist/commands/storage.js +0 -456
  373. package/dist/commands/storage.js.map +0 -1
  374. package/dist/commands/teams.d.ts +0 -3
  375. package/dist/commands/teams.d.ts.map +0 -1
  376. package/dist/commands/teams.js +0 -169
  377. package/dist/commands/teams.js.map +0 -1
  378. package/dist/commands/templates.d.ts +0 -3
  379. package/dist/commands/templates.d.ts.map +0 -1
  380. package/dist/commands/templates.js +0 -690
  381. package/dist/commands/templates.js.map +0 -1
  382. package/dist/commands/tenant.d.ts +0 -3
  383. package/dist/commands/tenant.d.ts.map +0 -1
  384. package/dist/commands/tenant.js +0 -95
  385. package/dist/commands/tenant.js.map +0 -1
  386. package/dist/commands/tunnel.d.ts +0 -3
  387. package/dist/commands/tunnel.d.ts.map +0 -1
  388. package/dist/commands/tunnel.js +0 -418
  389. package/dist/commands/tunnel.js.map +0 -1
  390. package/dist/commands/up.d.ts +0 -14
  391. package/dist/commands/up.d.ts.map +0 -1
  392. package/dist/commands/up.js +0 -720
  393. package/dist/commands/up.js.map +0 -1
  394. package/dist/commands/update.d.ts +0 -3
  395. package/dist/commands/update.d.ts.map +0 -1
  396. package/dist/commands/update.js +0 -166
  397. package/dist/commands/update.js.map +0 -1
  398. package/dist/commands/util.d.ts +0 -25
  399. package/dist/commands/util.d.ts.map +0 -1
  400. package/dist/commands/util.js +0 -199
  401. package/dist/commands/util.js.map +0 -1
  402. package/dist/commands/volumes.d.ts +0 -3
  403. package/dist/commands/volumes.d.ts.map +0 -1
  404. package/dist/commands/volumes.js +0 -196
  405. package/dist/commands/volumes.js.map +0 -1
  406. package/dist/commands/watch.d.ts +0 -6
  407. package/dist/commands/watch.d.ts.map +0 -1
  408. package/dist/commands/watch.js +0 -414
  409. package/dist/commands/watch.js.map +0 -1
  410. package/dist/commands/webhooks.d.ts +0 -3
  411. package/dist/commands/webhooks.d.ts.map +0 -1
  412. package/dist/commands/webhooks.js +0 -23
  413. package/dist/commands/webhooks.js.map +0 -1
  414. package/dist/commands/whoami.d.ts +0 -3
  415. package/dist/commands/whoami.d.ts.map +0 -1
  416. package/dist/commands/whoami.js +0 -156
  417. package/dist/commands/whoami.js.map +0 -1
  418. package/dist/commands/workspaces.d.ts +0 -3
  419. package/dist/commands/workspaces.d.ts.map +0 -1
  420. package/dist/commands/workspaces.js +0 -147
  421. package/dist/commands/workspaces.js.map +0 -1
  422. package/dist/config.d.ts +0 -54
  423. package/dist/config.d.ts.map +0 -1
  424. package/dist/config.js +0 -275
  425. package/dist/config.js.map +0 -1
  426. package/dist/errors.d.ts +0 -30
  427. package/dist/errors.d.ts.map +0 -1
  428. package/dist/errors.js +0 -92
  429. package/dist/errors.js.map +0 -1
  430. package/dist/framework-detector.d.ts +0 -22
  431. package/dist/framework-detector.d.ts.map +0 -1
  432. package/dist/framework-detector.js +0 -373
  433. package/dist/framework-detector.js.map +0 -1
  434. package/dist/generated/action-capabilities.d.ts +0 -826
  435. package/dist/generated/action-capabilities.d.ts.map +0 -1
  436. package/dist/generated/action-capabilities.js +0 -1035
  437. package/dist/generated/action-capabilities.js.map +0 -1
  438. package/dist/net-diagnosis.d.ts +0 -87
  439. package/dist/net-diagnosis.d.ts.map +0 -1
  440. package/dist/net-diagnosis.js +0 -408
  441. package/dist/net-diagnosis.js.map +0 -1
  442. package/dist/pty/raw-mode.d.ts +0 -7
  443. package/dist/pty/raw-mode.d.ts.map +0 -1
  444. package/dist/pty/raw-mode.js +0 -22
  445. package/dist/pty/raw-mode.js.map +0 -1
  446. package/dist/pty/ws-pty-client.d.ts +0 -13
  447. package/dist/pty/ws-pty-client.d.ts.map +0 -1
  448. package/dist/pty/ws-pty-client.js +0 -73
  449. package/dist/pty/ws-pty-client.js.map +0 -1
  450. package/dist/tui/dashboard.d.ts +0 -35
  451. package/dist/tui/dashboard.d.ts.map +0 -1
  452. package/dist/tui/dashboard.js +0 -191
  453. package/dist/tui/dashboard.js.map +0 -1
  454. package/dist/tui/logs.d.ts +0 -26
  455. package/dist/tui/logs.d.ts.map +0 -1
  456. package/dist/tui/logs.js +0 -276
  457. package/dist/tui/logs.js.map +0 -1
  458. package/dist/types.d.ts +0 -362
  459. package/dist/types.d.ts.map +0 -1
  460. package/dist/types.js +0 -16
  461. package/dist/types.js.map +0 -1
  462. package/dist/ui/picker.d.ts +0 -41
  463. package/dist/ui/picker.d.ts.map +0 -1
  464. package/dist/ui/picker.js +0 -77
  465. package/dist/ui/picker.js.map +0 -1
  466. package/dist/ui/progress.d.ts +0 -10
  467. package/dist/ui/progress.d.ts.map +0 -1
  468. package/dist/ui/progress.js +0 -36
  469. package/dist/ui/progress.js.map +0 -1
  470. package/dist/ui/render.d.ts +0 -91
  471. package/dist/ui/render.d.ts.map +0 -1
  472. package/dist/ui/render.js +0 -138
  473. package/dist/ui/render.js.map +0 -1
  474. package/dist/ui/spinner.d.ts +0 -4
  475. package/dist/ui/spinner.d.ts.map +0 -1
  476. package/dist/ui/spinner.js +0 -7
  477. package/dist/ui/spinner.js.map +0 -1
  478. package/dist/ui/table.d.ts +0 -8
  479. package/dist/ui/table.d.ts.map +0 -1
  480. package/dist/ui/table.js +0 -46
  481. package/dist/ui/table.js.map +0 -1
  482. package/dist/update-check.d.ts +0 -13
  483. package/dist/update-check.d.ts.map +0 -1
  484. package/dist/update-check.js +0 -94
  485. package/dist/update-check.js.map +0 -1
  486. package/dist/version.d.ts +0 -3
  487. package/dist/version.d.ts.map +0 -1
  488. package/dist/version.js +0 -5
  489. package/dist/version.js.map +0 -1
package/dist/client.js DELETED
@@ -1,865 +0,0 @@
1
- import { request } from "undici";
2
- import { AuthError, mapHttpError, NetworkError, UserError } from "./errors.js";
3
- import { isDebugMode } from "./cli-env.js";
4
- import { CLI_USER_AGENT } from "./version.js";
5
- // Retry policy for idempotent POSTs — mirrors the TS/Python SDK transports.
6
- const RETRY_STATUS = new Set([429, 500, 502, 503, 504]);
7
- const DEFAULT_CREATE_MAX_RETRIES = 3;
8
- const RETRY_BASE_DELAY_MS = 500;
9
- function sleep(ms) {
10
- return new Promise((resolve) => setTimeout(resolve, ms));
11
- }
12
- function retryDelay(attempt, retryAfter) {
13
- if (retryAfter !== null) {
14
- const seconds = parseInt(retryAfter, 10);
15
- if (!Number.isNaN(seconds))
16
- return seconds * 1000;
17
- }
18
- return RETRY_BASE_DELAY_MS * 2 ** attempt + Math.random() * 100;
19
- }
20
- export class MiosaClient {
21
- endpoint;
22
- apiKey;
23
- tenant;
24
- workspace;
25
- constructor(config) {
26
- if (!config.api_key) {
27
- throw new AuthError("You are not logged in. Run: miosa login", "Run `miosa login` to authenticate.");
28
- }
29
- this.endpoint = config.endpoint.replace(/\/$/, "");
30
- this.apiKey = config.api_key;
31
- this.tenant = config.tenant ?? null;
32
- this.workspace = config.workspace ?? null;
33
- }
34
- headers() {
35
- const headers = {
36
- Authorization: `Bearer ${this.apiKey}`,
37
- "Content-Type": "application/json",
38
- Accept: "application/json",
39
- "User-Agent": CLI_USER_AGENT,
40
- };
41
- if (this.tenant)
42
- headers["X-MIOSA-Tenant"] = this.tenant;
43
- if (this.workspace)
44
- headers["X-MIOSA-Workspace"] = this.workspace;
45
- return headers;
46
- }
47
- url(path) {
48
- return `${this.endpoint}${path}`;
49
- }
50
- async parseError(res, method, path) {
51
- const rawBody = await res.body.text();
52
- const requestId = responseHeader(res, "x-request-id");
53
- let body = {};
54
- try {
55
- body = JSON.parse(rawBody);
56
- }
57
- catch {
58
- body = { message: rawBody || `HTTP ${res.statusCode}` };
59
- }
60
- debugHttpError(method, path, res.statusCode, requestId, rawBody);
61
- throw mapHttpError(res.statusCode, body, rawBody, requestId);
62
- }
63
- async get(path) {
64
- let res;
65
- try {
66
- res = await request(this.url(path), {
67
- method: "GET",
68
- headers: this.headers(),
69
- });
70
- }
71
- catch (err) {
72
- throw new NetworkError(`Network error: ${err instanceof Error ? err.message : String(err)}`, "Check your connection and endpoint: miosa status");
73
- }
74
- if (res.statusCode >= 400)
75
- return this.parseError(res, "GET", path);
76
- return res.body.json();
77
- }
78
- async post(path, body, extraHeaders) {
79
- let res;
80
- try {
81
- res = await request(this.url(path), {
82
- method: "POST",
83
- headers: { ...this.headers(), ...extraHeaders },
84
- body: body !== undefined ? JSON.stringify(body) : undefined,
85
- });
86
- }
87
- catch (err) {
88
- throw new NetworkError(`Network error: ${err instanceof Error ? err.message : String(err)}`, "Check your connection and endpoint: miosa status");
89
- }
90
- if (res.statusCode >= 400)
91
- return this.parseError(res, "POST", path);
92
- return res.body.json();
93
- }
94
- async delete(path) {
95
- let res;
96
- try {
97
- res = await request(this.url(path), {
98
- method: "DELETE",
99
- headers: this.headers(),
100
- });
101
- }
102
- catch (err) {
103
- throw new NetworkError(`Network error: ${err instanceof Error ? err.message : String(err)}`);
104
- }
105
- if (res.statusCode >= 400)
106
- return this.parseError(res, "DELETE", path);
107
- if (res.statusCode === 204)
108
- return undefined;
109
- return res.body.json();
110
- }
111
- /** Generic GET for command groups that map directly to stable API routes. */
112
- async apiGet(path) {
113
- return this.get(path);
114
- }
115
- /** Generic binary GET for file/artifact download routes. */
116
- async apiGetBinary(path) {
117
- let res;
118
- try {
119
- res = await request(this.url(path), {
120
- method: "GET",
121
- headers: this.headers(),
122
- });
123
- }
124
- catch (err) {
125
- throw new NetworkError(`Network error: ${err instanceof Error ? err.message : String(err)}`, "Check your connection and endpoint: miosa status");
126
- }
127
- if (res.statusCode >= 400)
128
- return this.parseError(res, "GET", path);
129
- const chunks = [];
130
- for await (const chunk of res.body) {
131
- chunks.push(Buffer.isBuffer(chunk) ? chunk : Buffer.from(chunk));
132
- }
133
- return Buffer.concat(chunks);
134
- }
135
- /** Generic SSE GET for command groups that stream API events. */
136
- async apiStream(path) {
137
- let res;
138
- try {
139
- res = await request(this.url(path), {
140
- method: "GET",
141
- headers: {
142
- ...this.headers(),
143
- Accept: "text/event-stream, application/json, */*",
144
- },
145
- });
146
- }
147
- catch (err) {
148
- throw new NetworkError(`Network error: ${err instanceof Error ? err.message : String(err)}`, "Check your connection and endpoint: miosa status");
149
- }
150
- if (res.statusCode >= 400)
151
- return this.parseError(res, "GET", path);
152
- return res;
153
- }
154
- /** Generic POST for command groups that map directly to stable API routes. */
155
- async apiPost(path, body, headers) {
156
- return this.post(path, body, headers);
157
- }
158
- /**
159
- * POST with bounded exponential-backoff retry on 429/500/502/503/504 and
160
- * transient network errors — matching the TS/Python SDK retry policy.
161
- *
162
- * The request headers (including any ``Idempotency-Key``) are built ONCE and
163
- * re-sent unchanged on every retry, so this is only safe for idempotent
164
- * calls. Callers that need dedup MUST pass an ``Idempotency-Key`` header; a
165
- * retried create without one could spawn a duplicate, billable sandbox.
166
- */
167
- async apiPostWithRetry(path, body, extraHeaders, opts = {}) {
168
- const maxRetries = opts.maxRetries ?? DEFAULT_CREATE_MAX_RETRIES;
169
- // Built once — the same headers (and Idempotency-Key) are reused on every
170
- // retry so the server dedups instead of creating duplicates.
171
- const headers = { ...this.headers(), ...extraHeaders };
172
- for (let attempt = 0; attempt <= maxRetries; attempt++) {
173
- let res;
174
- try {
175
- res = await request(this.url(path), {
176
- method: "POST",
177
- headers,
178
- body: body !== undefined ? JSON.stringify(body) : undefined,
179
- });
180
- }
181
- catch (err) {
182
- if (attempt < maxRetries) {
183
- await sleep(retryDelay(attempt, null));
184
- continue;
185
- }
186
- throw new NetworkError(`Network error: ${err instanceof Error ? err.message : String(err)}`, "Check your connection and endpoint: miosa status");
187
- }
188
- if (RETRY_STATUS.has(res.statusCode) && attempt < maxRetries) {
189
- const retryAfter = responseHeader(res, "retry-after");
190
- // Drain the body so the socket can be reused for the retry.
191
- await res.body.dump();
192
- await sleep(retryDelay(attempt, retryAfter));
193
- continue;
194
- }
195
- if (res.statusCode >= 400)
196
- return this.parseError(res, "POST", path);
197
- return res.body.json();
198
- }
199
- // Unreachable: the loop either returns or throws on the final attempt.
200
- throw new NetworkError("Max retries exceeded", "Check your connection and endpoint: miosa status");
201
- }
202
- /** Generic PUT for command groups that map directly to stable API routes. */
203
- async apiPut(path, body) {
204
- let res;
205
- try {
206
- res = await request(this.url(path), {
207
- method: "PUT",
208
- headers: this.headers(),
209
- body: body !== undefined ? JSON.stringify(body) : undefined,
210
- });
211
- }
212
- catch (err) {
213
- throw new NetworkError(`Network error: ${err instanceof Error ? err.message : String(err)}`, "Check your connection and endpoint: miosa status");
214
- }
215
- if (res.statusCode >= 400)
216
- return this.parseError(res, "PUT", path);
217
- return res.body.json();
218
- }
219
- /** Generic PATCH for command groups that map directly to stable API routes. */
220
- async apiPatch(path, body) {
221
- let res;
222
- try {
223
- res = await request(this.url(path), {
224
- method: "PATCH",
225
- headers: this.headers(),
226
- body: body !== undefined ? JSON.stringify(body) : undefined,
227
- });
228
- }
229
- catch (err) {
230
- throw new NetworkError(`Network error: ${err instanceof Error ? err.message : String(err)}`, "Check your connection and endpoint: miosa status");
231
- }
232
- if (res.statusCode >= 400)
233
- return this.parseError(res, "PATCH", path);
234
- return res.body.json();
235
- }
236
- /** Generic DELETE for command groups that map directly to stable API routes. */
237
- async apiDelete(path) {
238
- return this.delete(path);
239
- }
240
- /** DELETE with the attributable operation metadata returned in response headers. */
241
- async apiDeleteWithReceipt(path) {
242
- let res;
243
- try {
244
- res = await request(this.url(path), {
245
- method: "DELETE",
246
- headers: this.headers(),
247
- });
248
- }
249
- catch (err) {
250
- throw new NetworkError(`Network error: ${err instanceof Error ? err.message : String(err)}`, "Check your connection and endpoint: miosa status");
251
- }
252
- if (res.statusCode >= 400)
253
- return this.parseError(res, "DELETE", path);
254
- await res.body.dump();
255
- const operationId = responseHeader(res, "x-forge-operation-id");
256
- if (!operationId) {
257
- throw new UserError("Forge delete did not return an operation receipt.", "Retry with --debug and contact MIOSA support if the response remains incomplete.");
258
- }
259
- return {
260
- operationId,
261
- replayed: responseHeader(res, "idempotency-replayed") === "true",
262
- };
263
- }
264
- // --- ClinicIQ / workspace admin SDK helpers ---
265
- async listWorkspaces() {
266
- return unwrapData(await this.get("/api/v1/workspaces"), []);
267
- }
268
- async createWorkspace(attrs) {
269
- return unwrapData(await this.post("/api/v1/workspaces", attrs));
270
- }
271
- async getWorkspaceInventory(workspaceId) {
272
- return unwrapData(await this.get(`/api/v1/workspaces/${encodeURIComponent(workspaceId)}/inventory`));
273
- }
274
- async cleanupWorkspaceResources(workspaceId, opts) {
275
- return unwrapData(await this.post(`/api/v1/workspaces/${encodeURIComponent(workspaceId)}/cleanup`, opts));
276
- }
277
- async deleteWorkspace(workspaceId, opts) {
278
- const qs = queryString({
279
- force: opts?.force,
280
- dry_run: opts?.dryRun,
281
- });
282
- return unwrapData(await this.delete(`/api/v1/workspaces/${encodeURIComponent(workspaceId)}${qs}`));
283
- }
284
- async listComputers(params) {
285
- return unwrapList(await this.get(`/api/v1/computers${queryString(paramsToApi(params))}`), ["computers", "data"]);
286
- }
287
- async deleteComputer(computerId) {
288
- return unwrapData(await this.delete(`/api/v1/computers/${encodeURIComponent(computerId)}`));
289
- }
290
- async listSandboxes(params) {
291
- return unwrapList(await this.get(`/api/v1/sandboxes${queryString(paramsToApi(params))}`));
292
- }
293
- async deleteSandbox(sandboxId) {
294
- return unwrapData(await this.delete(`/api/v1/sandboxes/${encodeURIComponent(sandboxId)}`));
295
- }
296
- async listDomains(params) {
297
- return unwrapList(await this.get(`/api/v1/custom-domains${queryString(paramsToApi(params))}`));
298
- }
299
- async deleteDomain(hostnameOrId) {
300
- return unwrapData(await this.delete(`/api/v1/domains/${encodeURIComponent(hostnameOrId)}`));
301
- }
302
- async listDatabases(params) {
303
- return unwrapList(await this.get(`/api/v1/databases${queryString(paramsToApi(params))}`));
304
- }
305
- async deleteDatabase(databaseId) {
306
- return unwrapData(await this.delete(`/api/v1/databases/${encodeURIComponent(databaseId)}`));
307
- }
308
- async listSecretsMetadata(params) {
309
- return unwrapList(await this.get(`/api/v1/egress/secrets${queryString(paramsToApi(params))}`));
310
- }
311
- async unsetSecret(secretId) {
312
- return unwrapData(await this.delete(`/api/v1/egress/secrets/${encodeURIComponent(secretId)}`));
313
- }
314
- async listStorageBuckets(params) {
315
- return unwrapList(await this.get(`/api/v1/storage/buckets${queryString(paramsToApi(params))}`));
316
- }
317
- async deleteStorageBucket(bucketId) {
318
- return unwrapData(await this.delete(`/api/v1/storage/buckets/${encodeURIComponent(bucketId)}`));
319
- }
320
- async getAuditEvents(params) {
321
- return unwrapList(await this.get(`/api/v1/audit-log${queryString(paramsToApi(params))}`));
322
- }
323
- // --- Tenant ---
324
- async getTenant() {
325
- const response = await this.get("/api/v1/platform/tenants/current");
326
- const tenant = normalizeTenantResponse(response);
327
- const billingOverview = await this.getBillingOverview().catch(() => null);
328
- const billingCreditBalance = billingOverview?.available_balance_cents ??
329
- (billingOverview
330
- ? Math.max(0, (billingOverview.usage_budget_cents ?? 0) +
331
- (billingOverview.topup_balance_cents ?? 0) -
332
- (billingOverview.billing_period_usage_cents ?? 0))
333
- : null);
334
- return {
335
- ...tenant,
336
- plan: tenant.plan ?? tenant.plan_name ?? null,
337
- credit_balance: billingCreditBalance ?? tenant.credit_balance ?? 0,
338
- };
339
- }
340
- async getBillingOverview() {
341
- const response = await this.get("/api/v1/billing/overview");
342
- return response.data ?? response;
343
- }
344
- // --- Hosts ---
345
- async listHosts() {
346
- return this.get("/api/v1/opencomputers/hosts").then((r) => r.data ?? []);
347
- }
348
- async getHost(idOrName) {
349
- // Try by ID first; if 404 fallback to name search
350
- try {
351
- return await this.get(`/api/v1/opencomputers/hosts/${encodeURIComponent(idOrName)}`).then((r) => r.data);
352
- }
353
- catch {
354
- // Fallback: search by name
355
- const hosts = await this.listHosts();
356
- const match = hosts.find((h) => h.name === idOrName || h.id === idOrName);
357
- if (!match) {
358
- const { UserError } = await import("./errors.js");
359
- const hint = /^(sbx_|sb_)/.test(idOrName)
360
- ? "This looks like a sandbox id. Use `miosa sandbox ls` / `miosa sandbox cp` for sandboxes."
361
- : "Run `miosa hosts` to list available fleet hosts.";
362
- throw new UserError(`Host not found: ${idOrName}`, hint);
363
- }
364
- return match;
365
- }
366
- }
367
- async createHost(params) {
368
- return this.post("/api/v1/opencomputers/hosts", params).then((r) => r.data);
369
- }
370
- // --- Terminal ---
371
- async getTerminalTicket(hostId) {
372
- return this.post(`/api/v1/opencomputers/hosts/${hostId}/terminal/ticket`).then((r) => r.data);
373
- }
374
- // --- Jobs ---
375
- async createJob(hostId, params) {
376
- return this.post(`/api/v1/opencomputers/hosts/${hostId}/jobs`, params).then((r) => r.data);
377
- }
378
- /** Returns a raw Response for SSE streaming */
379
- async streamJob(hostId, params) {
380
- let res;
381
- try {
382
- res = await request(this.url(`/api/v1/opencomputers/hosts/${hostId}/jobs`), {
383
- method: "POST",
384
- headers: {
385
- ...this.headers(),
386
- Accept: "text/event-stream, application/json, */*",
387
- },
388
- body: JSON.stringify({ ...params, stream: true }),
389
- });
390
- }
391
- catch (err) {
392
- throw new NetworkError(`Network error: ${err instanceof Error ? err.message : String(err)}`);
393
- }
394
- if (res.statusCode >= 400) {
395
- return this.parseError(res, "POST", `/api/v1/opencomputers/hosts/${hostId}/jobs`);
396
- }
397
- return res;
398
- }
399
- // --- Filesystem ---
400
- async listFs(hostId, path) {
401
- return this.get(`/api/v1/opencomputers/hosts/${hostId}/fs?path=${encodeURIComponent(path)}`).then((r) => r.data);
402
- }
403
- async downloadFile(hostId, remotePath) {
404
- let res;
405
- try {
406
- res = await request(this.url(`/api/v1/opencomputers/hosts/${hostId}/fs/content?path=${encodeURIComponent(remotePath)}`), { method: "GET", headers: this.headers() });
407
- }
408
- catch (err) {
409
- throw new NetworkError(`Network error: ${err instanceof Error ? err.message : String(err)}`);
410
- }
411
- if (res.statusCode >= 400) {
412
- return this.parseError(res, "GET", `/api/v1/opencomputers/hosts/${hostId}/fs/content`);
413
- }
414
- return res;
415
- }
416
- async uploadFile(hostId, remotePath, data, filename) {
417
- const boundary = `----MiosaUpload${Date.now()}`;
418
- const header = `--${boundary}\r\n` +
419
- `Content-Disposition: form-data; name="file"; filename="${filename}"\r\n` +
420
- `Content-Type: application/octet-stream\r\n\r\n`;
421
- const footer = `\r\n--${boundary}--\r\n`;
422
- const body = Buffer.concat([
423
- Buffer.from(header),
424
- data,
425
- Buffer.from(footer),
426
- ]);
427
- let res;
428
- try {
429
- res = await request(this.url(`/api/v1/opencomputers/hosts/${hostId}/fs/content`), {
430
- method: "POST",
431
- headers: {
432
- ...this.headers(),
433
- "Content-Type": `multipart/form-data; boundary=${boundary}`,
434
- "X-Remote-Path": remotePath,
435
- },
436
- body,
437
- });
438
- }
439
- catch (err) {
440
- throw new NetworkError(`Network error: ${err instanceof Error ? err.message : String(err)}`);
441
- }
442
- if (res.statusCode >= 400) {
443
- await this.parseError(res, "POST", `/api/v1/opencomputers/hosts/${hostId}/fs/content`);
444
- }
445
- await res.body.dump();
446
- }
447
- async deleteFs(hostId, path, recursive) {
448
- await this.delete(`/api/v1/opencomputers/hosts/${hostId}/fs?path=${encodeURIComponent(path)}&recursive=${recursive}`);
449
- }
450
- // --- Computers (Firecracker microVMs) filesystem ---
451
- async computerListFiles(computerId, remotePath) {
452
- return this.get(`/api/v1/computers/${computerId}/files?path=${encodeURIComponent(remotePath)}`).then((r) => r.data);
453
- }
454
- async computerWriteFile(computerId, remotePath, content) {
455
- const body = content instanceof Buffer ? content.toString("base64") : content;
456
- await this.post(`/api/v1/computers/${computerId}/files/write`, {
457
- path: remotePath,
458
- content: body,
459
- encoding: content instanceof Buffer ? "base64" : "utf8",
460
- });
461
- }
462
- async computerDownloadFile(computerId, remotePath) {
463
- let res;
464
- try {
465
- res = await request(this.url(`/api/v1/computers/${computerId}/files/download?path=${encodeURIComponent(remotePath)}`), { method: "GET", headers: this.headers() });
466
- }
467
- catch (err) {
468
- throw new NetworkError(`Network error: ${err instanceof Error ? err.message : String(err)}`);
469
- }
470
- if (res.statusCode >= 400) {
471
- return this.parseError(res, "GET", `/api/v1/computers/${computerId}/files/download`);
472
- }
473
- return res;
474
- }
475
- async computerUploadFile(computerId, remotePath, data, filename) {
476
- const boundary = `----MiosaComputerUpload${Date.now()}`;
477
- const header = `--${boundary}\r\n` +
478
- `Content-Disposition: form-data; name="file"; filename="${filename}"\r\n` +
479
- `Content-Type: application/octet-stream\r\n\r\n`;
480
- const footer = `\r\n--${boundary}--\r\n`;
481
- const body = Buffer.concat([
482
- Buffer.from(header),
483
- data,
484
- Buffer.from(footer),
485
- ]);
486
- let res;
487
- try {
488
- res = await request(this.url(`/api/v1/computers/${computerId}/files/upload`), {
489
- method: "POST",
490
- headers: {
491
- ...this.headers(),
492
- "Content-Type": `multipart/form-data; boundary=${boundary}`,
493
- "X-Remote-Path": remotePath,
494
- },
495
- body,
496
- });
497
- }
498
- catch (err) {
499
- throw new NetworkError(`Network error: ${err instanceof Error ? err.message : String(err)}`);
500
- }
501
- if (res.statusCode >= 400) {
502
- await this.parseError(res, "POST", `/api/v1/computers/${computerId}/files/upload`);
503
- }
504
- await res.body.dump();
505
- }
506
- async computerMkdir(computerId, remotePath) {
507
- await this.post(`/api/v1/computers/${computerId}/files/mkdir`, {
508
- path: remotePath,
509
- });
510
- }
511
- async computerDeleteFile(computerId, remotePath) {
512
- await this.delete(`/api/v1/computers/${computerId}/files?path=${encodeURIComponent(remotePath)}`);
513
- }
514
- async computerStat(computerId, remotePath) {
515
- return this.post(`/api/v1/computers/${computerId}/files/stat`, { path: remotePath }).then((r) => r.data);
516
- }
517
- // --- Computers exec ---
518
- async computerExec(computerId, command, opts) {
519
- const path = opts?.language === "python"
520
- ? `/api/v1/computers/${computerId}/exec/python`
521
- : `/api/v1/computers/${computerId}/exec`;
522
- let res;
523
- try {
524
- res = await request(this.url(path), {
525
- method: "POST",
526
- headers: {
527
- ...this.headers(),
528
- Accept: "text/event-stream, application/json, */*",
529
- },
530
- body: JSON.stringify({ command }),
531
- });
532
- }
533
- catch (err) {
534
- throw new NetworkError(`Network error: ${err instanceof Error ? err.message : String(err)}`);
535
- }
536
- if (res.statusCode >= 400)
537
- return this.parseError(res, "POST", path);
538
- return res;
539
- }
540
- // --- Tunnels ---
541
- async listTunnels(hostId) {
542
- return this.get(`/api/v1/opencomputers/hosts/${hostId}/tunnels`).then((r) => r.data);
543
- }
544
- async createTunnel(hostId, params) {
545
- return this.post(`/api/v1/opencomputers/hosts/${hostId}/tunnels`, params).then((r) => r.data);
546
- }
547
- async closeTunnel(hostId, slug) {
548
- await this.delete(`/api/v1/opencomputers/hosts/${hostId}/tunnels/${slug}`);
549
- }
550
- // --- Agent ---
551
- async dispatchAgent(hostId, params) {
552
- let res;
553
- try {
554
- res = await request(this.url(`/api/v1/opencomputers/hosts/${hostId}/agent/dispatch`), {
555
- method: "POST",
556
- headers: {
557
- ...this.headers(),
558
- Accept: "text/event-stream, application/json, */*",
559
- },
560
- body: JSON.stringify(params),
561
- });
562
- }
563
- catch (err) {
564
- throw new NetworkError(`Network error: ${err instanceof Error ? err.message : String(err)}`);
565
- }
566
- if (res.statusCode >= 400) {
567
- return this.parseError(res, "POST", `/api/v1/opencomputers/hosts/${hostId}/agent/dispatch`);
568
- }
569
- return res;
570
- }
571
- // --- Deployments ---
572
- async listDeployments(params) {
573
- const qs = new URLSearchParams();
574
- if (params?.state)
575
- qs.set("state", params.state);
576
- const workspaceId = params?.workspace_id ?? params?.workspace;
577
- if (workspaceId)
578
- qs.set("workspace_id", workspaceId);
579
- if (params?.limit != null)
580
- qs.set("limit", String(params.limit));
581
- const suffix = qs.toString() ? `?${qs.toString()}` : "";
582
- return this.get(`/api/v1/deployments${suffix}`).then((r) => r.data);
583
- }
584
- async getDeployment(id) {
585
- return this.get(`/api/v1/deployments/${encodeURIComponent(id)}`).then((r) => r.data);
586
- }
587
- async createDeployment(params) {
588
- return this.post("/api/v1/deployments", params);
589
- }
590
- async deleteDeployment(id) {
591
- return this.delete(`/api/v1/deployments/${encodeURIComponent(id)}`);
592
- }
593
- async redeployDeployment(id) {
594
- return this.post(`/api/v1/deployments/${encodeURIComponent(id)}/redeploy`).then((r) => r.data);
595
- }
596
- async listBuilds(id) {
597
- return this.get(`/api/v1/deployments/${encodeURIComponent(id)}/builds`).then((r) => r.data);
598
- }
599
- async getBuild(id, bid) {
600
- return this.get(`/api/v1/deployments/${encodeURIComponent(id)}/builds/${encodeURIComponent(bid)}`).then((r) => r.data);
601
- }
602
- /** Returns a raw SSE Response for deployment log streaming */
603
- async streamDeploymentLogs(id) {
604
- let res;
605
- try {
606
- res = await request(this.url(`/api/v1/deployments/${encodeURIComponent(id)}/logs`), {
607
- method: "GET",
608
- headers: {
609
- ...this.headers(),
610
- Accept: "text/event-stream, application/json, */*",
611
- },
612
- });
613
- }
614
- catch (err) {
615
- throw new NetworkError(`Network error: ${err instanceof Error ? err.message : String(err)}`);
616
- }
617
- if (res.statusCode >= 400) {
618
- return this.parseError(res, "GET", `/api/v1/deployments/${encodeURIComponent(id)}/logs`);
619
- }
620
- return res;
621
- }
622
- /** Returns a raw SSE Response for build log streaming */
623
- async streamBuildLogs(id, buildId) {
624
- let res;
625
- try {
626
- res = await request(this.url(`/api/v1/deployments/${encodeURIComponent(id)}/builds/${encodeURIComponent(buildId)}/logs`), {
627
- method: "GET",
628
- headers: {
629
- ...this.headers(),
630
- Accept: "text/event-stream, application/json, */*",
631
- },
632
- });
633
- }
634
- catch (err) {
635
- throw new NetworkError(`Network error: ${err instanceof Error ? err.message : String(err)}`);
636
- }
637
- if (res.statusCode >= 400) {
638
- return this.parseError(res, "GET", `/api/v1/deployments/${encodeURIComponent(id)}/builds/${encodeURIComponent(buildId)}/logs`);
639
- }
640
- return res;
641
- }
642
- async getDeploymentEnv(id) {
643
- return this.get(`/api/v1/deployments/${encodeURIComponent(id)}/env`).then((r) => r.data);
644
- }
645
- async setDeploymentEnv(id, env) {
646
- return this.post(`/api/v1/deployments/${encodeURIComponent(id)}/env`, { env }).then((r) => r.data);
647
- }
648
- // --- Watch ---
649
- async watchEvents(hostId) {
650
- let res;
651
- try {
652
- res = await request(this.url(`/api/v1/opencomputers/hosts/${hostId}/events`), {
653
- method: "GET",
654
- headers: {
655
- ...this.headers(),
656
- Accept: "text/event-stream, application/json, */*",
657
- },
658
- });
659
- }
660
- catch (err) {
661
- throw new NetworkError(`Network error: ${err instanceof Error ? err.message : String(err)}`);
662
- }
663
- if (res.statusCode >= 400) {
664
- return this.parseError(res, "GET", `/api/v1/opencomputers/hosts/${hostId}/events`);
665
- }
666
- return res;
667
- }
668
- /** Open an SSE event stream for a Computer (Firecracker microVM). */
669
- async watchComputerEvents(computerId) {
670
- let res;
671
- try {
672
- res = await request(this.url(`/api/v1/computers/${computerId}/events`), {
673
- method: "GET",
674
- headers: {
675
- ...this.headers(),
676
- Accept: "text/event-stream, application/json, */*",
677
- },
678
- });
679
- }
680
- catch (err) {
681
- throw new NetworkError(`Network error: ${err instanceof Error ? err.message : String(err)}`);
682
- }
683
- if (res.statusCode >= 400) {
684
- return this.parseError(res, "GET", `/api/v1/computers/${computerId}/events`);
685
- }
686
- return res;
687
- }
688
- }
689
- function normalizeTenantResponse(response) {
690
- const candidate = response.data ?? response.tenant ?? response;
691
- if (!isRecord(candidate)) {
692
- throw malformedTenantError();
693
- }
694
- const name = stringField(candidate, "name");
695
- const slug = stringField(candidate, "slug");
696
- if (!name || !slug) {
697
- throw malformedTenantError();
698
- }
699
- return candidate;
700
- }
701
- function malformedTenantError() {
702
- return new UserError("MIOSA returned an invalid account response.", "Run `miosa status --json` and try `miosa login` again. If this persists, contact MIOSA support with --debug output.");
703
- }
704
- function stringField(record, key) {
705
- const value = record[key];
706
- return typeof value === "string" && value.trim() !== "" ? value : null;
707
- }
708
- function responseHeader(res, name) {
709
- const headers = res.headers;
710
- if (Array.isArray(headers)) {
711
- for (let i = 0; i < headers.length; i += 2) {
712
- const key = String(headers[i] ?? "").toLowerCase();
713
- if (key === name.toLowerCase())
714
- return String(headers[i + 1] ?? "");
715
- }
716
- return null;
717
- }
718
- const value = headers?.[name] ?? headers?.[name.toLowerCase()];
719
- if (Array.isArray(value))
720
- return value[0] ?? null;
721
- return value ?? null;
722
- }
723
- function unwrapData(payload, fallback) {
724
- if (isRecord(payload) && "data" in payload)
725
- return payload["data"];
726
- if (payload === undefined && fallback !== undefined)
727
- return fallback;
728
- return payload;
729
- }
730
- function unwrapList(payload, keys = ["data"]) {
731
- if (Array.isArray(payload))
732
- return payload;
733
- if (isRecord(payload)) {
734
- for (const key of keys) {
735
- const value = payload[key];
736
- if (Array.isArray(value))
737
- return value;
738
- }
739
- }
740
- return [];
741
- }
742
- function queryString(values) {
743
- if (!values)
744
- return "";
745
- const params = new URLSearchParams();
746
- for (const [key, value] of Object.entries(values)) {
747
- if (value === undefined ||
748
- value === null ||
749
- value === false ||
750
- value === "")
751
- continue;
752
- params.set(key, String(value));
753
- }
754
- const encoded = params.toString();
755
- return encoded ? `?${encoded}` : "";
756
- }
757
- function paramsToApi(params) {
758
- if (!params)
759
- return undefined;
760
- const result = { ...params };
761
- if (params.workspace && !params.workspace_id)
762
- result["workspace_id"] = params.workspace;
763
- delete result["workspace"];
764
- return result;
765
- }
766
- function isRecord(value) {
767
- return typeof value === "object" && value !== null && !Array.isArray(value);
768
- }
769
- function debugHttpError(method, path, status, requestId, rawBody) {
770
- if (!isDebugMode())
771
- return;
772
- const requestIdText = requestId ? ` request_id=${requestId}` : "";
773
- process.stderr.write(`[debug] ${method} ${path} -> HTTP ${status}${requestIdText}\n`);
774
- if (rawBody) {
775
- process.stderr.write(`[debug] response_body=${rawBody}\n`);
776
- }
777
- }
778
- // SSE parser — consumes undici body stream, yields parsed events
779
- export async function* parseSse(body) {
780
- let buffer = "";
781
- for await (const chunk of body) {
782
- buffer += chunk.toString();
783
- const lines = buffer.split("\n");
784
- // Keep last potentially incomplete line
785
- buffer = lines.pop() ?? "";
786
- let eventType = "";
787
- let dataLines = [];
788
- for (const line of lines) {
789
- if (line.startsWith("event:")) {
790
- eventType = line.slice(6).trim();
791
- }
792
- else if (line.startsWith("data:")) {
793
- dataLines.push(line.slice(5).trim());
794
- }
795
- else if (line === "") {
796
- // Dispatch event
797
- if (dataLines.length > 0) {
798
- const raw = dataLines.join("\n");
799
- yield parseSseEvent(eventType, raw);
800
- }
801
- eventType = "";
802
- dataLines = [];
803
- }
804
- }
805
- }
806
- }
807
- function parseSseEvent(eventType, raw) {
808
- let parsed;
809
- try {
810
- parsed = JSON.parse(raw);
811
- }
812
- catch {
813
- return { type: "unknown", raw };
814
- }
815
- const data = parsed;
816
- // Normalize event type from field or explicit event: line
817
- const type = eventType || (typeof data["type"] === "string" ? data["type"] : "unknown");
818
- switch (type) {
819
- case "stdout":
820
- // Sandbox exec/stream frames are `data: {"line": "..."}` (see
821
- // apps/web/lib/web/controllers/sandboxes/execution_controller.ex);
822
- // `data`/`output` are kept as fallbacks for other stream producers.
823
- return {
824
- type: "stdout",
825
- data: String(data["line"] ?? data["data"] ?? data["output"] ?? ""),
826
- };
827
- case "stderr":
828
- return {
829
- type: "stderr",
830
- data: String(data["line"] ?? data["data"] ?? data["output"] ?? ""),
831
- };
832
- case "exit":
833
- return {
834
- type: "exit",
835
- exit_code: Number(data["exit_code"] ?? data["code"] ?? 0),
836
- };
837
- case "error":
838
- return { type: "error", message: String(data["message"] ?? raw) };
839
- case "thought":
840
- return {
841
- type: "thought",
842
- content: String(data["content"] ?? data["thought"] ?? ""),
843
- };
844
- case "tool_call":
845
- return {
846
- type: "tool_call",
847
- tool: String(data["tool"] ?? ""),
848
- input: data["input"],
849
- };
850
- case "tool_result":
851
- return {
852
- type: "tool_result",
853
- tool: String(data["tool"] ?? ""),
854
- output: data["output"],
855
- };
856
- case "done":
857
- return { type: "done", result: data["result"] };
858
- case "heartbeat":
859
- case "ping":
860
- return { type: "heartbeat" };
861
- default:
862
- return { type: "unknown", raw };
863
- }
864
- }
865
- //# sourceMappingURL=client.js.map