@dreamlake/dreamlake-cli 0.88.0 → 0.89.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 (535) hide show
  1. package/dist/api/access.d.ts +83 -0
  2. package/dist/api/access.js +77 -0
  3. package/dist/api/agent.d.ts +156 -0
  4. package/dist/api/agent.js +111 -0
  5. package/dist/api/browser.d.ts +90 -0
  6. package/dist/api/browser.js +102 -0
  7. package/dist/api/client.d.ts +53 -0
  8. package/dist/api/client.js +102 -0
  9. package/dist/api/common.d.ts +28 -0
  10. package/dist/api/common.js +16 -0
  11. package/dist/api/content.d.ts +195 -0
  12. package/dist/api/content.js +147 -0
  13. package/dist/api/execution.d.ts +84 -0
  14. package/dist/api/execution.js +73 -0
  15. package/dist/api/http.d.ts +19 -0
  16. package/dist/api/http.js +66 -0
  17. package/dist/api/index.d.ts +2330 -0
  18. package/dist/api/index.js +114 -0
  19. package/dist/api/infra.d.ts +2 -0
  20. package/dist/api/infra.js +2 -0
  21. package/dist/api/jobs.d.ts +2 -0
  22. package/dist/api/jobs.js +2 -0
  23. package/dist/api/layout.d.ts +2 -0
  24. package/dist/api/layout.js +2 -0
  25. package/dist/api/library-edit.d.ts +3 -0
  26. package/dist/api/library-edit.js +3 -0
  27. package/dist/api/library-manifest.d.ts +2 -0
  28. package/dist/api/library-manifest.js +2 -0
  29. package/dist/api/note-character-plan.d.ts +2 -0
  30. package/dist/api/note-character-plan.js +2 -0
  31. package/dist/api/note-editing.d.ts +2 -0
  32. package/dist/api/note-editing.js +2 -0
  33. package/dist/api/note-edits.d.ts +21 -0
  34. package/dist/api/note-edits.js +10 -0
  35. package/dist/api/note-events.d.ts +5 -0
  36. package/dist/api/note-events.js +11 -0
  37. package/dist/api/note-files.d.ts +75 -0
  38. package/dist/api/note-files.js +65 -0
  39. package/dist/api/note-html-read.d.ts +2 -0
  40. package/dist/api/note-html-read.js +2 -0
  41. package/dist/api/note-html.d.ts +2 -0
  42. package/dist/api/note-html.js +2 -0
  43. package/dist/api/note-toc.d.ts +2 -0
  44. package/dist/api/note-toc.js +2 -0
  45. package/dist/api/notes.d.ts +304 -0
  46. package/dist/api/notes.js +181 -0
  47. package/dist/api/open-resources.d.ts +27 -0
  48. package/dist/api/open-resources.js +102 -0
  49. package/dist/api/ownership.d.ts +12 -0
  50. package/dist/api/ownership.js +24 -0
  51. package/dist/api/platform.d.ts +83 -0
  52. package/dist/api/platform.js +56 -0
  53. package/dist/api/presigned-transfer.d.ts +2 -0
  54. package/dist/api/presigned-transfer.js +2 -0
  55. package/dist/api/registered-runs.d.ts +48 -0
  56. package/dist/api/registered-runs.js +33 -0
  57. package/dist/api/sessions.d.ts +299 -0
  58. package/dist/api/sessions.js +105 -0
  59. package/dist/api/storage.d.ts +46 -0
  60. package/dist/api/storage.js +34 -0
  61. package/dist/api/streams.d.ts +18 -0
  62. package/dist/api/streams.js +70 -0
  63. package/dist/api/vault.d.ts +93 -0
  64. package/dist/api/vault.js +79 -0
  65. package/dist/api/workspace.d.ts +180 -0
  66. package/dist/api/workspace.js +146 -0
  67. package/dist/cli/agent-identity.d.ts +4 -0
  68. package/dist/cli/agent-identity.js +21 -0
  69. package/dist/cli/agents/identity.d.ts +50 -0
  70. package/dist/cli/agents/identity.js +105 -0
  71. package/dist/cli/agents/index.d.ts +31 -0
  72. package/dist/cli/agents/index.js +580 -0
  73. package/dist/cli/agents/manage.d.ts +43 -0
  74. package/dist/cli/agents/manage.js +376 -0
  75. package/dist/cli/agents/spec.d.ts +104 -0
  76. package/dist/cli/agents/spec.js +280 -0
  77. package/dist/cli/agents/web.d.ts +7 -0
  78. package/dist/cli/agents/web.js +109 -0
  79. package/dist/cli/artifact/incremental.d.ts +21 -0
  80. package/dist/cli/artifact/incremental.js +80 -0
  81. package/dist/cli/artifact/index.d.ts +52 -0
  82. package/dist/cli/artifact/index.js +405 -0
  83. package/dist/cli/artifact/meta.d.ts +69 -0
  84. package/dist/cli/artifact/meta.js +189 -0
  85. package/dist/cli/auth/commands.d.ts +29 -0
  86. package/dist/cli/auth/commands.js +327 -0
  87. package/dist/cli/auth/constants.d.ts +13 -0
  88. package/dist/cli/auth/constants.js +18 -0
  89. package/dist/cli/auth/credentials.d.ts +37 -0
  90. package/dist/cli/auth/credentials.js +155 -0
  91. package/dist/cli/auth/device-flow.d.ts +32 -0
  92. package/dist/cli/auth/device-flow.js +154 -0
  93. package/dist/cli/auth/device-secret.d.ts +6 -0
  94. package/dist/cli/auth/device-secret.js +26 -0
  95. package/dist/cli/auth/machine.d.ts +15 -0
  96. package/dist/cli/auth/machine.js +126 -0
  97. package/dist/cli/auth/materialized.d.ts +32 -0
  98. package/dist/cli/auth/materialized.js +102 -0
  99. package/dist/cli/auth/migrate.d.ts +10 -0
  100. package/dist/cli/auth/migrate.js +75 -0
  101. package/dist/cli/client.d.ts +102 -0
  102. package/dist/cli/client.js +206 -0
  103. package/dist/cli/collection-list.d.ts +3 -0
  104. package/dist/cli/collection-list.js +25 -0
  105. package/dist/cli/compat/ctx.d.ts +26 -0
  106. package/dist/cli/compat/ctx.js +76 -0
  107. package/dist/cli/compat/dreamdb-wasm-embedded.d.ts +2 -0
  108. package/dist/cli/compat/dreamdb-wasm-embedded.js +8 -0
  109. package/dist/cli/compat/dreamdb-wasm.d.ts +1 -0
  110. package/dist/cli/compat/dreamdb-wasm.js +26 -0
  111. package/dist/cli/compat/dreamdb.d.ts +112 -0
  112. package/dist/cli/compat/dreamdb.js +219 -0
  113. package/dist/cli/compat/flags.d.ts +2 -0
  114. package/dist/cli/compat/flags.js +13 -0
  115. package/dist/cli/compat/http.d.ts +23 -0
  116. package/dist/cli/compat/http.js +137 -0
  117. package/dist/cli/compat/presignedTransfer.d.ts +139 -0
  118. package/dist/cli/compat/presignedTransfer.js +580 -0
  119. package/dist/cli/compat/s3-backend.d.ts +73 -0
  120. package/dist/cli/compat/s3-backend.js +132 -0
  121. package/dist/cli/config.d.ts +22 -0
  122. package/dist/cli/config.js +96 -0
  123. package/dist/cli/connection/dto.d.ts +159 -0
  124. package/dist/cli/connection/dto.js +497 -0
  125. package/dist/cli/connection/index.d.ts +50 -0
  126. package/dist/cli/connection/index.js +413 -0
  127. package/dist/cli/connection/oauth.d.ts +23 -0
  128. package/dist/cli/connection/oauth.js +290 -0
  129. package/dist/cli/connection/write.d.ts +47 -0
  130. package/dist/cli/connection/write.js +573 -0
  131. package/dist/cli/create/index.d.ts +19 -0
  132. package/dist/cli/create/index.js +209 -0
  133. package/dist/cli/declare/index.d.ts +29 -0
  134. package/dist/cli/declare/index.js +304 -0
  135. package/dist/cli/delete/index.d.ts +18 -0
  136. package/dist/cli/delete/index.js +232 -0
  137. package/dist/cli/download/index.d.ts +9 -0
  138. package/dist/cli/download/index.js +128 -0
  139. package/dist/cli/env/compose.d.ts +88 -0
  140. package/dist/cli/env/compose.js +402 -0
  141. package/dist/cli/env/index.d.ts +176 -0
  142. package/dist/cli/env/index.js +1011 -0
  143. package/dist/cli/experiments/index.d.ts +11 -0
  144. package/dist/cli/experiments/index.js +168 -0
  145. package/dist/cli/glob.d.ts +1 -0
  146. package/dist/cli/glob.js +45 -0
  147. package/dist/cli/graphql-helpers.d.ts +23 -0
  148. package/dist/cli/graphql-helpers.js +42 -0
  149. package/dist/cli/graphql.d.ts +10 -0
  150. package/dist/cli/graphql.js +47 -0
  151. package/dist/cli/help-examples.generated.d.ts +1 -0
  152. package/dist/cli/help-examples.generated.js +192 -0
  153. package/dist/cli/helpers.d.ts +8 -0
  154. package/dist/cli/helpers.js +106 -0
  155. package/dist/cli/hosts/api.d.ts +29 -0
  156. package/dist/cli/hosts/api.js +54 -0
  157. package/dist/cli/hosts/bootstrap-source.d.ts +1 -0
  158. package/dist/cli/hosts/bootstrap-source.js +2 -0
  159. package/dist/cli/hosts/catalog.d.ts +26 -0
  160. package/dist/cli/hosts/catalog.js +55 -0
  161. package/dist/cli/hosts/config.d.ts +45 -0
  162. package/dist/cli/hosts/config.js +179 -0
  163. package/dist/cli/hosts/credentials.d.ts +19 -0
  164. package/dist/cli/hosts/credentials.js +173 -0
  165. package/dist/cli/hosts/enroll.d.ts +17 -0
  166. package/dist/cli/hosts/enroll.js +109 -0
  167. package/dist/cli/hosts/enrollments.d.ts +25 -0
  168. package/dist/cli/hosts/enrollments.js +54 -0
  169. package/dist/cli/hosts/index.d.ts +6 -0
  170. package/dist/cli/hosts/index.js +279 -0
  171. package/dist/cli/hosts/inventory.d.ts +40 -0
  172. package/dist/cli/hosts/inventory.js +91 -0
  173. package/dist/cli/hosts/lifecycle.d.ts +15 -0
  174. package/dist/cli/hosts/lifecycle.js +108 -0
  175. package/dist/cli/hosts/metrics-source.d.ts +12 -0
  176. package/dist/cli/hosts/metrics-source.js +89 -0
  177. package/dist/cli/hosts/observations.d.ts +39 -0
  178. package/dist/cli/hosts/observations.js +102 -0
  179. package/dist/cli/hosts/remote.d.ts +5 -0
  180. package/dist/cli/hosts/remote.js +66 -0
  181. package/dist/cli/hosts/ssh.d.ts +63 -0
  182. package/dist/cli/hosts/ssh.js +276 -0
  183. package/dist/cli/index.d.ts +1 -0
  184. package/dist/cli/index.js +288 -0
  185. package/dist/cli/infra/api.d.ts +95 -0
  186. package/dist/cli/infra/api.js +291 -0
  187. package/dist/cli/infra/index.d.ts +5 -0
  188. package/dist/cli/infra/index.js +102 -0
  189. package/dist/cli/infra/move.d.ts +15 -0
  190. package/dist/cli/infra/move.js +123 -0
  191. package/dist/cli/infra/transfer.d.ts +15 -0
  192. package/dist/cli/infra/transfer.js +280 -0
  193. package/dist/cli/jobs/api.d.ts +69 -0
  194. package/dist/cli/jobs/api.js +121 -0
  195. package/dist/cli/jobs/index.d.ts +5 -0
  196. package/dist/cli/jobs/index.js +140 -0
  197. package/dist/cli/lakeshore/index.d.ts +98 -0
  198. package/dist/cli/lakeshore/index.js +502 -0
  199. package/dist/cli/launch/index.d.ts +43 -0
  200. package/dist/cli/launch/index.js +270 -0
  201. package/dist/cli/layout/index.d.ts +2 -0
  202. package/dist/cli/layout/index.js +44 -0
  203. package/dist/cli/layout/transport.d.ts +12 -0
  204. package/dist/cli/layout/transport.js +70 -0
  205. package/dist/cli/library/add.d.ts +60 -0
  206. package/dist/cli/library/add.js +348 -0
  207. package/dist/cli/library/cache.d.ts +26 -0
  208. package/dist/cli/library/cache.js +88 -0
  209. package/dist/cli/library/config.d.ts +75 -0
  210. package/dist/cli/library/config.js +198 -0
  211. package/dist/cli/library/digest.d.ts +5 -0
  212. package/dist/cli/library/digest.js +19 -0
  213. package/dist/cli/library/discover.d.ts +87 -0
  214. package/dist/cli/library/discover.js +534 -0
  215. package/dist/cli/library/freshness.d.ts +35 -0
  216. package/dist/cli/library/freshness.js +109 -0
  217. package/dist/cli/library/generation.d.ts +35 -0
  218. package/dist/cli/library/generation.js +211 -0
  219. package/dist/cli/library/index.d.ts +2 -0
  220. package/dist/cli/library/index.js +36 -0
  221. package/dist/cli/library/info.d.ts +69 -0
  222. package/dist/cli/library/info.js +311 -0
  223. package/dist/cli/library/list.d.ts +33 -0
  224. package/dist/cli/library/list.js +86 -0
  225. package/dist/cli/library/manifest.d.ts +81 -0
  226. package/dist/cli/library/manifest.js +200 -0
  227. package/dist/cli/library/manifestCache.d.ts +45 -0
  228. package/dist/cli/library/manifestCache.js +169 -0
  229. package/dist/cli/library/pull.d.ts +30 -0
  230. package/dist/cli/library/pull.js +438 -0
  231. package/dist/cli/library/push.d.ts +72 -0
  232. package/dist/cli/library/push.js +642 -0
  233. package/dist/cli/library/rm.d.ts +31 -0
  234. package/dist/cli/library/rm.js +200 -0
  235. package/dist/cli/library/search.d.ts +18 -0
  236. package/dist/cli/library/search.js +181 -0
  237. package/dist/cli/library/stat.d.ts +15 -0
  238. package/dist/cli/library/stat.js +127 -0
  239. package/dist/cli/library/tools.d.ts +104 -0
  240. package/dist/cli/library/tools.js +163 -0
  241. package/dist/cli/library/wire.d.ts +47 -0
  242. package/dist/cli/library/wire.js +120 -0
  243. package/dist/cli/list/index.d.ts +26 -0
  244. package/dist/cli/list/index.js +256 -0
  245. package/dist/cli/notes/character-plan.d.ts +22 -0
  246. package/dist/cli/notes/character-plan.js +232 -0
  247. package/dist/cli/notes/document.d.ts +73 -0
  248. package/dist/cli/notes/document.js +306 -0
  249. package/dist/cli/notes/edit-commands.d.ts +106 -0
  250. package/dist/cli/notes/edit-commands.js +623 -0
  251. package/dist/cli/notes/editing.d.ts +81 -0
  252. package/dist/cli/notes/editing.js +305 -0
  253. package/dist/cli/notes/events.d.ts +36 -0
  254. package/dist/cli/notes/events.js +54 -0
  255. package/dist/cli/notes/files-commands.d.ts +120 -0
  256. package/dist/cli/notes/files-commands.js +554 -0
  257. package/dist/cli/notes/html-read.d.ts +9 -0
  258. package/dist/cli/notes/html-read.js +90 -0
  259. package/dist/cli/notes/html.d.ts +73 -0
  260. package/dist/cli/notes/html.js +381 -0
  261. package/dist/cli/notes/index.d.ts +123 -0
  262. package/dist/cli/notes/index.js +1303 -0
  263. package/dist/cli/notes/linger.d.ts +59 -0
  264. package/dist/cli/notes/linger.js +339 -0
  265. package/dist/cli/notes/media-commands.d.ts +5 -0
  266. package/dist/cli/notes/media-commands.js +51 -0
  267. package/dist/cli/notes/move-command.d.ts +83 -0
  268. package/dist/cli/notes/move-command.js +259 -0
  269. package/dist/cli/notes/rm-command.d.ts +22 -0
  270. package/dist/cli/notes/rm-command.js +110 -0
  271. package/dist/cli/notes/select-command.d.ts +12 -0
  272. package/dist/cli/notes/select-command.js +84 -0
  273. package/dist/cli/notes/suggest-diff.d.ts +56 -0
  274. package/dist/cli/notes/suggest-diff.js +311 -0
  275. package/dist/cli/notes/toc.d.ts +38 -0
  276. package/dist/cli/notes/toc.js +144 -0
  277. package/dist/cli/notes/transfer-command.d.ts +6 -0
  278. package/dist/cli/notes/transfer-command.js +9 -0
  279. package/dist/cli/notes/version-commands.d.ts +19 -0
  280. package/dist/cli/notes/version-commands.js +178 -0
  281. package/dist/cli/nymph/index.d.ts +74 -0
  282. package/dist/cli/nymph/index.js +349 -0
  283. package/dist/cli/org/index.d.ts +34 -0
  284. package/dist/cli/org/index.js +341 -0
  285. package/dist/cli/ownership/index.d.ts +12 -0
  286. package/dist/cli/ownership/index.js +122 -0
  287. package/dist/cli/ownership/metadata-transfer.d.ts +20 -0
  288. package/dist/cli/ownership/metadata-transfer.js +159 -0
  289. package/dist/cli/page/index.d.ts +58 -0
  290. package/dist/cli/page/index.js +387 -0
  291. package/dist/cli/pipeline/index.d.ts +69 -0
  292. package/dist/cli/pipeline/index.js +604 -0
  293. package/dist/cli/progress.d.ts +60 -0
  294. package/dist/cli/progress.js +276 -0
  295. package/dist/cli/project/attachments.d.ts +10 -0
  296. package/dist/cli/project/attachments.js +39 -0
  297. package/dist/cli/project/grants.d.ts +10 -0
  298. package/dist/cli/project/grants.js +39 -0
  299. package/dist/cli/project/index.d.ts +8 -0
  300. package/dist/cli/project/index.js +92 -0
  301. package/dist/cli/project/move.d.ts +57 -0
  302. package/dist/cli/project/move.js +242 -0
  303. package/dist/cli/project/output.d.ts +2 -0
  304. package/dist/cli/project/output.js +29 -0
  305. package/dist/cli/project/stream.d.ts +55 -0
  306. package/dist/cli/project/stream.js +207 -0
  307. package/dist/cli/project/transfer-preview.d.ts +8 -0
  308. package/dist/cli/project/transfer-preview.js +10 -0
  309. package/dist/cli/prompt.d.ts +1 -0
  310. package/dist/cli/prompt.js +17 -0
  311. package/dist/cli/provider/dreamdir.d.ts +52 -0
  312. package/dist/cli/provider/dreamdir.js +138 -0
  313. package/dist/cli/provider/index.d.ts +4 -0
  314. package/dist/cli/provider/index.js +419 -0
  315. package/dist/cli/provider/jump-worker.d.ts +9 -0
  316. package/dist/cli/provider/jump-worker.js +141 -0
  317. package/dist/cli/provider/lifecycle.d.ts +149 -0
  318. package/dist/cli/provider/lifecycle.js +1390 -0
  319. package/dist/cli/provider/machine.d.ts +17 -0
  320. package/dist/cli/provider/machine.js +116 -0
  321. package/dist/cli/provider/ssh.d.ts +105 -0
  322. package/dist/cli/provider/ssh.js +305 -0
  323. package/dist/cli/provider/terraform.d.ts +140 -0
  324. package/dist/cli/provider/terraform.js +288 -0
  325. package/dist/cli/providers/index.d.ts +18 -0
  326. package/dist/cli/providers/index.js +422 -0
  327. package/dist/cli/python.d.ts +61 -0
  328. package/dist/cli/python.js +255 -0
  329. package/dist/cli/queues/index.d.ts +33 -0
  330. package/dist/cli/queues/index.js +248 -0
  331. package/dist/cli/queues/slurm.d.ts +10 -0
  332. package/dist/cli/queues/slurm.js +134 -0
  333. package/dist/cli/resources.d.ts +72 -0
  334. package/dist/cli/resources.js +137 -0
  335. package/dist/cli/run/index.d.ts +15 -0
  336. package/dist/cli/run/index.js +163 -0
  337. package/dist/cli/run/input.d.ts +34 -0
  338. package/dist/cli/run/input.js +135 -0
  339. package/dist/cli/run/recovery.d.ts +2 -0
  340. package/dist/cli/run/recovery.js +18 -0
  341. package/dist/cli/run/setup.d.ts +3 -0
  342. package/dist/cli/run/setup.js +62 -0
  343. package/dist/cli/runconfig/index.d.ts +12 -0
  344. package/dist/cli/runconfig/index.js +130 -0
  345. package/dist/cli/runnable/index.d.ts +35 -0
  346. package/dist/cli/runnable/index.js +575 -0
  347. package/dist/cli/runnable/path.d.ts +115 -0
  348. package/dist/cli/runnable/path.js +288 -0
  349. package/dist/cli/runnable/run.d.ts +91 -0
  350. package/dist/cli/runnable/run.js +239 -0
  351. package/dist/cli/runnable/upload.d.ts +43 -0
  352. package/dist/cli/runnable/upload.js +342 -0
  353. package/dist/cli/runnable/worker.d.ts +1 -0
  354. package/dist/cli/runnable/worker.js +44 -0
  355. package/dist/cli/schemas/workflow-spec.schema.json +335 -0
  356. package/dist/cli/self-update/index.d.ts +5 -0
  357. package/dist/cli/self-update/index.js +107 -0
  358. package/dist/cli/self-update/install.d.ts +60 -0
  359. package/dist/cli/self-update/install.js +428 -0
  360. package/dist/cli/self-update/paths.d.ts +40 -0
  361. package/dist/cli/self-update/paths.js +87 -0
  362. package/dist/cli/self-update/releases.d.ts +41 -0
  363. package/dist/cli/self-update/releases.js +153 -0
  364. package/dist/cli/self-update/settings.d.ts +16 -0
  365. package/dist/cli/self-update/settings.js +68 -0
  366. package/dist/cli/self-update/update.d.ts +18 -0
  367. package/dist/cli/self-update/update.js +241 -0
  368. package/dist/cli/service-accounts/index.d.ts +3 -0
  369. package/dist/cli/service-accounts/index.js +149 -0
  370. package/dist/cli/session-affiliation.d.ts +26 -0
  371. package/dist/cli/session-affiliation.js +135 -0
  372. package/dist/cli/sessions/affiliation.d.ts +8 -0
  373. package/dist/cli/sessions/affiliation.js +66 -0
  374. package/dist/cli/sessions/api.d.ts +55 -0
  375. package/dist/cli/sessions/api.js +88 -0
  376. package/dist/cli/sessions/control.d.ts +6 -0
  377. package/dist/cli/sessions/control.js +159 -0
  378. package/dist/cli/sessions/conversation.d.ts +15 -0
  379. package/dist/cli/sessions/conversation.js +118 -0
  380. package/dist/cli/sessions/index.d.ts +2 -0
  381. package/dist/cli/sessions/index.js +209 -0
  382. package/dist/cli/sessions/managed.d.ts +39 -0
  383. package/dist/cli/sessions/managed.js +63 -0
  384. package/dist/cli/sessions/redaction.d.ts +2 -0
  385. package/dist/cli/sessions/redaction.js +11 -0
  386. package/dist/cli/sessions/runner/exec.d.ts +108 -0
  387. package/dist/cli/sessions/runner/exec.js +335 -0
  388. package/dist/cli/sessions/runner/journal.d.ts +26 -0
  389. package/dist/cli/sessions/runner/journal.js +49 -0
  390. package/dist/cli/sessions/runner/native.d.ts +48 -0
  391. package/dist/cli/sessions/runner/native.js +170 -0
  392. package/dist/cli/sessions/runner/pod.d.ts +30 -0
  393. package/dist/cli/sessions/runner/pod.js +129 -0
  394. package/dist/cli/sessions/runner/serve.d.ts +85 -0
  395. package/dist/cli/sessions/runner/serve.js +558 -0
  396. package/dist/cli/sessions/sync.d.ts +47 -0
  397. package/dist/cli/sessions/sync.js +80 -0
  398. package/dist/cli/sessions/transport.d.ts +14 -0
  399. package/dist/cli/sessions/transport.js +116 -0
  400. package/dist/cli/share.d.ts +15 -0
  401. package/dist/cli/share.js +139 -0
  402. package/dist/cli/skill/catalog.d.ts +141 -0
  403. package/dist/cli/skill/catalog.js +442 -0
  404. package/dist/cli/skill/files.d.ts +89 -0
  405. package/dist/cli/skill/files.js +264 -0
  406. package/dist/cli/skill/index.d.ts +268 -0
  407. package/dist/cli/skill/index.js +1216 -0
  408. package/dist/cli/skill/manifest.d.ts +30 -0
  409. package/dist/cli/skill/manifest.js +101 -0
  410. package/dist/cli/skill/prefs.d.ts +9 -0
  411. package/dist/cli/skill/prefs.js +32 -0
  412. package/dist/cli/skill/reminders.d.ts +15 -0
  413. package/dist/cli/skill/reminders.js +105 -0
  414. package/dist/cli/skill/tar.d.ts +17 -0
  415. package/dist/cli/skill/tar.js +195 -0
  416. package/dist/cli/snapshot/index.d.ts +24 -0
  417. package/dist/cli/snapshot/index.js +146 -0
  418. package/dist/cli/source/access.d.ts +45 -0
  419. package/dist/cli/source/access.js +563 -0
  420. package/dist/cli/source/control.d.ts +103 -0
  421. package/dist/cli/source/control.js +546 -0
  422. package/dist/cli/source/delete.d.ts +89 -0
  423. package/dist/cli/source/delete.js +463 -0
  424. package/dist/cli/source/index.d.ts +288 -0
  425. package/dist/cli/source/index.js +1348 -0
  426. package/dist/cli/source/share.d.ts +65 -0
  427. package/dist/cli/source/share.js +530 -0
  428. package/dist/cli/source/upload.d.ts +62 -0
  429. package/dist/cli/source/upload.js +258 -0
  430. package/dist/cli/source/write.d.ts +77 -0
  431. package/dist/cli/source/write.js +335 -0
  432. package/dist/cli/spawn.d.ts +28 -0
  433. package/dist/cli/spawn.js +81 -0
  434. package/dist/cli/target.d.ts +22 -0
  435. package/dist/cli/target.js +85 -0
  436. package/dist/cli/tasks/index.d.ts +38 -0
  437. package/dist/cli/tasks/index.js +365 -0
  438. package/dist/cli/team/index.d.ts +37 -0
  439. package/dist/cli/team/index.js +407 -0
  440. package/dist/cli/telemetry.d.ts +23 -0
  441. package/dist/cli/telemetry.js +262 -0
  442. package/dist/cli/telemetryJournal.d.ts +26 -0
  443. package/dist/cli/telemetryJournal.js +104 -0
  444. package/dist/cli/update/index.d.ts +21 -0
  445. package/dist/cli/update/index.js +284 -0
  446. package/dist/cli/upload/index.d.ts +11 -0
  447. package/dist/cli/upload/index.js +261 -0
  448. package/dist/cli/upload/kinds.d.ts +10 -0
  449. package/dist/cli/upload/kinds.js +85 -0
  450. package/dist/cli/upload/multipart.d.ts +21 -0
  451. package/dist/cli/upload/multipart.js +248 -0
  452. package/dist/cli/vault/affected-preview.d.ts +15 -0
  453. package/dist/cli/vault/affected-preview.js +38 -0
  454. package/dist/cli/vault/cloud.d.ts +55 -0
  455. package/dist/cli/vault/cloud.js +287 -0
  456. package/dist/cli/vault/format.d.ts +18 -0
  457. package/dist/cli/vault/format.js +104 -0
  458. package/dist/cli/vault/hostCredentials.d.ts +21 -0
  459. package/dist/cli/vault/hostCredentials.js +71 -0
  460. package/dist/cli/vault/hostSupersessions.d.ts +18 -0
  461. package/dist/cli/vault/hostSupersessions.js +68 -0
  462. package/dist/cli/vault/import.d.ts +3 -0
  463. package/dist/cli/vault/import.js +79 -0
  464. package/dist/cli/vault/index.d.ts +14 -0
  465. package/dist/cli/vault/index.js +225 -0
  466. package/dist/cli/vault/keys.d.ts +5 -0
  467. package/dist/cli/vault/keys.js +165 -0
  468. package/dist/cli/vault/kms.d.ts +6 -0
  469. package/dist/cli/vault/kms.js +169 -0
  470. package/dist/cli/vault/list.d.ts +13 -0
  471. package/dist/cli/vault/list.js +60 -0
  472. package/dist/cli/vault/listView.d.ts +21 -0
  473. package/dist/cli/vault/listView.js +123 -0
  474. package/dist/cli/vault/managementMetadata.d.ts +2 -0
  475. package/dist/cli/vault/managementMetadata.js +23 -0
  476. package/dist/cli/vault/mutations.d.ts +8 -0
  477. package/dist/cli/vault/mutations.js +151 -0
  478. package/dist/cli/vault/otp.d.ts +6 -0
  479. package/dist/cli/vault/otp.js +62 -0
  480. package/dist/cli/vault/otpIntent.d.ts +23 -0
  481. package/dist/cli/vault/otpIntent.js +76 -0
  482. package/dist/cli/vault/passImport.d.ts +25 -0
  483. package/dist/cli/vault/passImport.js +129 -0
  484. package/dist/cli/vault/passOtp.d.ts +51 -0
  485. package/dist/cli/vault/passOtp.js +101 -0
  486. package/dist/cli/vault/passStore.d.ts +26 -0
  487. package/dist/cli/vault/passStore.js +134 -0
  488. package/dist/cli/vault/passwordCommand.d.ts +39 -0
  489. package/dist/cli/vault/passwordCommand.js +101 -0
  490. package/dist/cli/vault/passwordProbe.d.ts +27 -0
  491. package/dist/cli/vault/passwordProbe.js +282 -0
  492. package/dist/cli/vault/passwordRotation.d.ts +9 -0
  493. package/dist/cli/vault/passwordRotation.js +273 -0
  494. package/dist/cli/vault/rotationApi.d.ts +13 -0
  495. package/dist/cli/vault/rotationApi.js +58 -0
  496. package/dist/cli/vault/rotationCommand.d.ts +2 -0
  497. package/dist/cli/vault/rotationCommand.js +75 -0
  498. package/dist/cli/vault/rotationEngine.d.ts +19 -0
  499. package/dist/cli/vault/rotationEngine.js +65 -0
  500. package/dist/cli/vault/rotationHelperSource.d.ts +2 -0
  501. package/dist/cli/vault/rotationHelperSource.js +3 -0
  502. package/dist/cli/vault/rotationInput.d.ts +11 -0
  503. package/dist/cli/vault/rotationInput.js +48 -0
  504. package/dist/cli/vault/rotationJournal.d.ts +16 -0
  505. package/dist/cli/vault/rotationJournal.js +183 -0
  506. package/dist/cli/vault/rotationKeys.d.ts +4 -0
  507. package/dist/cli/vault/rotationKeys.js +48 -0
  508. package/dist/cli/vault/rotationPrepare.d.ts +17 -0
  509. package/dist/cli/vault/rotationPrepare.js +108 -0
  510. package/dist/cli/vault/rotationRemote.d.ts +33 -0
  511. package/dist/cli/vault/rotationRemote.js +156 -0
  512. package/dist/cli/vault/rotationState.d.ts +42 -0
  513. package/dist/cli/vault/rotationState.js +115 -0
  514. package/dist/cli/vault/rotationTransport.d.ts +18 -0
  515. package/dist/cli/vault/rotationTransport.js +71 -0
  516. package/dist/cli/vault/sshSource.d.ts +18 -0
  517. package/dist/cli/vault/sshSource.js +196 -0
  518. package/dist/cli/vault/sshSync.d.ts +17 -0
  519. package/dist/cli/vault/sshSync.js +224 -0
  520. package/dist/cli/vault/sshTransfer.d.ts +22 -0
  521. package/dist/cli/vault/sshTransfer.js +140 -0
  522. package/dist/cli/vault/terraformState.d.ts +66 -0
  523. package/dist/cli/vault/terraformState.js +252 -0
  524. package/dist/cli/vault/terraformStateCommand.d.ts +2 -0
  525. package/dist/cli/vault/terraformStateCommand.js +61 -0
  526. package/dist/cli/vault/tree.d.ts +43 -0
  527. package/dist/cli/vault/tree.js +292 -0
  528. package/dist/cli/version.d.ts +1 -0
  529. package/dist/cli/version.js +9 -0
  530. package/dist/cli/workflow/index.d.ts +76 -0
  531. package/dist/cli/workflow/index.js +826 -0
  532. package/dist/cli/workflow/validate.d.ts +19 -0
  533. package/dist/cli/workflow/validate.js +353 -0
  534. package/dist/package.json +1 -0
  535. package/package.json +28 -10
@@ -0,0 +1,153 @@
1
+ // Client for the release bucket (the shared `dreamlake-downloads` R2
2
+ // bucket, fronted by dl.dreamlake.ai). Layout — deliberately dumb,
3
+ // just static objects, so no server code sits between a user and an
4
+ // install:
5
+ //
6
+ // /install.sh the bootstrap script, at the root for
7
+ // a short headline command
8
+ // /dreamlake-cli/releases/latest text: "0.4.0"
9
+ // /dreamlake-cli/releases/stable text: "0.3.9"
10
+ // /dreamlake-cli/releases/<v>/manifest.json
11
+ // /dreamlake-cli/releases/<v>/<platform>/dreamlake
12
+ //
13
+ // The bucket is shared with other DreamLake downloads, so the prefix names
14
+ // this CLI specifically — a future tool shipping the same way gets its own.
15
+ //
16
+ // The manifest carries a SHA-256 per platform, so every download is
17
+ // verified against a value fetched separately from the binary itself.
18
+ import { createHash } from "node:crypto";
19
+ import { existsSync } from "node:fs";
20
+ export const DEFAULT_BASE_URL = "https://dl.dreamlake.ai/dreamlake-cli/releases";
21
+ /** Release bucket base. `DREAMLAKE_DOWNLOAD_BASE_URL` overrides it for testing. */
22
+ export function baseUrl() {
23
+ const v = process.env.DREAMLAKE_DOWNLOAD_BASE_URL || DEFAULT_BASE_URL;
24
+ return v.replace(/\/+$/, "");
25
+ }
26
+ export const CHANNELS = ["latest", "stable"];
27
+ export function isChannel(v) {
28
+ return CHANNELS.includes(v);
29
+ }
30
+ export const VERSION_RE = /^\d+\.\d+\.\d+(-[^\s]+)?$/;
31
+ /**
32
+ * Platform key for the running machine, matching the keys install.sh
33
+ * derives from `uname`. musl distros get their own build because a
34
+ * glibc-linked binary will not start on Alpine.
35
+ */
36
+ export function detectPlatform() {
37
+ const arch = process.arch === "arm64" ? "arm64" : process.arch === "x64" ? "x64" : null;
38
+ if (!arch)
39
+ throw new Error(`unsupported architecture: ${process.arch}`);
40
+ if (process.platform === "darwin")
41
+ return `darwin-${arch}`;
42
+ if (process.platform === "win32")
43
+ return `win32-${arch}`;
44
+ if (process.platform === "linux")
45
+ return isMusl() ? `linux-${arch}-musl` : `linux-${arch}`;
46
+ throw new Error(`unsupported platform: ${process.platform} — no native build for it`);
47
+ }
48
+ function isMusl() {
49
+ if (existsSync("/lib/libc.musl-x86_64.so.1") || existsSync("/lib/libc.musl-aarch64.so.1")) {
50
+ return true;
51
+ }
52
+ try {
53
+ // glibcVersionRuntime is absent on musl builds.
54
+ const report = process.report?.getReport();
55
+ if (report?.header && !report.header.glibcVersionRuntime)
56
+ return true;
57
+ }
58
+ catch {
59
+ // Fall through — assume glibc, the far more common case.
60
+ }
61
+ return false;
62
+ }
63
+ async function get(url, init) {
64
+ const res = await fetch(url, {
65
+ ...init,
66
+ signal: init?.signal ?? AbortSignal.timeout(60_000),
67
+ });
68
+ if (!res.ok)
69
+ throw new Error(`GET ${url} → ${res.status} ${res.statusText}`);
70
+ return res;
71
+ }
72
+ /**
73
+ * Newest version on a channel. The pointer is a bare version string; we
74
+ * validate its shape before it can reach a URL, so an HTML error page (a
75
+ * captive portal, say) fails here rather than being pasted into a path.
76
+ */
77
+ export async function resolveChannel(channel, signal) {
78
+ const text = (await (await get(`${baseUrl()}/${channel}`, { signal })).text()).trim();
79
+ if (!VERSION_RE.test(text)) {
80
+ throw new Error(`channel "${channel}" returned unexpected content, not a version`);
81
+ }
82
+ return text;
83
+ }
84
+ export async function fetchManifest(version, signal) {
85
+ const manifest = (await (await get(`${baseUrl()}/${version}/manifest.json`, { signal })).json());
86
+ if (!manifest?.platforms)
87
+ throw new Error(`malformed manifest for ${version}`);
88
+ return manifest;
89
+ }
90
+ /**
91
+ * Download a platform binary and verify it against the manifest checksum.
92
+ * Throws on mismatch — the caller must never write an unverified binary to
93
+ * a path that later gets executed.
94
+ *
95
+ * `onProgress` receives each body chunk's size plus the best-known total
96
+ * (manifest size, else Content-Length, else 0 for "unknown").
97
+ */
98
+ export async function downloadBinary(version, platform, manifest, signal, onProgress) {
99
+ const entry = manifest.platforms[platform];
100
+ if (!entry) {
101
+ const known = Object.keys(manifest.platforms).join(", ");
102
+ throw new Error(`no ${platform} build in release ${version} (have: ${known})`);
103
+ }
104
+ // get()'s one-minute budget suits pointers and manifests, not a binary of
105
+ // tens of MB on a slow link — the body gets a far higher ceiling.
106
+ const res = await get(`${baseUrl()}/${version}/${platform}/${entry.binary}`, {
107
+ signal: signal ?? AbortSignal.timeout(15 * 60_000),
108
+ });
109
+ const total = entry.size || Number(res.headers.get("content-length") ?? 0) || 0;
110
+ let buf;
111
+ if (res.body) {
112
+ const chunks = [];
113
+ const reader = res.body.getReader();
114
+ for (;;) {
115
+ const { done, value } = await reader.read();
116
+ if (done)
117
+ break;
118
+ chunks.push(value);
119
+ onProgress?.(value.length, total);
120
+ }
121
+ buf = Buffer.concat(chunks);
122
+ }
123
+ else {
124
+ buf = Buffer.from(await res.arrayBuffer());
125
+ }
126
+ const actual = createHash("sha256").update(buf).digest("hex");
127
+ if (actual !== entry.checksum) {
128
+ throw new Error(`checksum mismatch for ${platform} ${version}: expected ${entry.checksum}, got ${actual}`);
129
+ }
130
+ return buf;
131
+ }
132
+ /** Numeric-ish semver compare. Returns >0 when `a` is newer than `b`. */
133
+ export function compareVersions(a, b) {
134
+ const parse = (v) => {
135
+ const [core = "", pre] = v.split("-", 2);
136
+ return { nums: core.split(".").map((n) => Number(n) || 0), pre };
137
+ };
138
+ const pa = parse(a);
139
+ const pb = parse(b);
140
+ for (let i = 0; i < 3; i++) {
141
+ const d = (pa.nums[i] ?? 0) - (pb.nums[i] ?? 0);
142
+ if (d !== 0)
143
+ return d;
144
+ }
145
+ // A release outranks its own prereleases (1.0.0 > 1.0.0-rc.1).
146
+ if (pa.pre && !pb.pre)
147
+ return -1;
148
+ if (!pa.pre && pb.pre)
149
+ return 1;
150
+ if (pa.pre && pb.pre)
151
+ return pa.pre < pb.pre ? -1 : pa.pre > pb.pre ? 1 : 0;
152
+ return 0;
153
+ }
@@ -0,0 +1,16 @@
1
+ import { type Channel } from "./releases.js";
2
+ export interface Settings {
3
+ channel: Channel;
4
+ /** Frozen version, or null when following a channel. */
5
+ pinned: string | null;
6
+ }
7
+ export declare function readSettings(): Settings;
8
+ export declare function writeSettings(next: Partial<Settings>): Settings;
9
+ /** Version this install is frozen on, or null when following a channel. */
10
+ export declare function pinnedVersion(): string | null;
11
+ /** Channel to update along: env override → saved setting → "latest". */
12
+ export declare function activeChannel(): Channel;
13
+ /** True when the user has switched off updates entirely. */
14
+ export declare function updatesDisabled(): boolean;
15
+ /** True when only the unattended background check is switched off. */
16
+ export declare function autoUpdaterDisabled(): boolean;
@@ -0,0 +1,68 @@
1
+ // Update settings, stored next to auth.yml as YAML at
2
+ // ~/.dreamlake/settings.yml.
3
+ //
4
+ // channel: latest # or "stable"
5
+ // pinned: 0.3.0 # optional — freeze on this version
6
+ //
7
+ // A pin is what installing an exact version means. Without it the
8
+ // background updater would quietly move you off the version you asked for,
9
+ // which makes "install 0.3.0" a lie the moment the next release ships.
10
+ // Choosing a channel clears the pin.
11
+ //
12
+ // Environment overrides, checked before the file:
13
+ // DREAMLAKE_AUTOUPDATE_CHANNEL force a channel for one run
14
+ // DREAMLAKE_DISABLE_AUTOUPDATER skip the background check only
15
+ // DREAMLAKE_DISABLE_UPDATES block every update path, background or not
16
+ import { mkdirSync, readFileSync, writeFileSync } from "node:fs";
17
+ import YAML from "yaml";
18
+ import { configDir, settingsPath } from "./paths.js";
19
+ import { isChannel, VERSION_RE } from "./releases.js";
20
+ const DEFAULTS = { channel: "latest", pinned: null };
21
+ export function readSettings() {
22
+ try {
23
+ const raw = readFileSync(settingsPath(), "utf8");
24
+ const parsed = YAML.parse(raw);
25
+ const channel = parsed?.channel;
26
+ const pinned = parsed?.pinned;
27
+ return {
28
+ channel: channel && isChannel(channel) ? channel : DEFAULTS.channel,
29
+ pinned: typeof pinned === "string" && VERSION_RE.test(pinned) ? pinned : null,
30
+ };
31
+ }
32
+ catch {
33
+ return { ...DEFAULTS };
34
+ }
35
+ }
36
+ export function writeSettings(next) {
37
+ const merged = { ...readSettings(), ...next };
38
+ mkdirSync(configDir(), { recursive: true });
39
+ // Omit a null pin rather than writing `pinned: null`, so the file reads
40
+ // as the short thing it usually is.
41
+ const doc = { channel: merged.channel };
42
+ if (merged.pinned)
43
+ doc.pinned = merged.pinned;
44
+ writeFileSync(settingsPath(), YAML.stringify(doc), { mode: 0o600 });
45
+ return merged;
46
+ }
47
+ /** Version this install is frozen on, or null when following a channel. */
48
+ export function pinnedVersion() {
49
+ return readSettings().pinned;
50
+ }
51
+ /** Channel to update along: env override → saved setting → "latest". */
52
+ export function activeChannel() {
53
+ const env = process.env.DREAMLAKE_AUTOUPDATE_CHANNEL;
54
+ if (env && isChannel(env))
55
+ return env;
56
+ return readSettings().channel;
57
+ }
58
+ /** True when the user has switched off updates entirely. */
59
+ export function updatesDisabled() {
60
+ return isTruthy(process.env.DREAMLAKE_DISABLE_UPDATES);
61
+ }
62
+ /** True when only the unattended background check is switched off. */
63
+ export function autoUpdaterDisabled() {
64
+ return updatesDisabled() || isTruthy(process.env.DREAMLAKE_DISABLE_AUTOUPDATER);
65
+ }
66
+ function isTruthy(v) {
67
+ return v === "1" || v === "true" || v === "yes";
68
+ }
@@ -0,0 +1,18 @@
1
+ export interface UpdateOptions {
2
+ /** Install this channel or version instead of the saved channel. */
3
+ target?: string;
4
+ /** Detached background run: no stdout, no progress — the only output is
5
+ * the one-line "found a new version" announcement on stderr. */
6
+ background?: boolean;
7
+ }
8
+ export declare function runUpdate(opts?: UpdateOptions): Promise<number>;
9
+ /**
10
+ * Fire-and-forget update check, called once at startup. Returns without
11
+ * doing anything unless this is a native install, the throttle window has
12
+ * elapsed, and auto-update is enabled. The child is detached and unref'd,
13
+ * so it never holds the CLI open; it inherits stderr (when that is a
14
+ * terminal) solely to say that a background update has started.
15
+ */
16
+ export declare function maybeCheckForUpdates(argv: string[]): void;
17
+ /** Human-readable last-check line for `dreamlake self-update --status`. */
18
+ export declare function updateStatus(): string;
@@ -0,0 +1,241 @@
1
+ // `dreamlake update` — apply an update now, and the throttled background
2
+ // check that keeps native installs current without anyone thinking about it.
3
+ //
4
+ // The background path mirrors what the native Claude Code installer does:
5
+ // a detached child downloads and installs while you work, and the new
6
+ // version takes effect the next time you start the CLI. Nothing is swapped
7
+ // underneath a running process beyond re-pointing a symlink.
8
+ import { spawn } from "node:child_process";
9
+ import { existsSync, mkdirSync, readFileSync, writeFileSync } from "node:fs";
10
+ import path from "node:path";
11
+ import { isNativeInstall, isWindows, updateStatePath } from "./paths.js";
12
+ import { compareVersions, resolveChannel } from "./releases.js";
13
+ import { activeChannel, autoUpdaterDisabled, pinnedVersion, updatesDisabled } from "./settings.js";
14
+ import { installWarnings, performInstall } from "./install.js";
15
+ import { remindAfterInstall } from "../skill/reminders.js";
16
+ import { VERSION } from "../version.js";
17
+ /** How long to wait between unattended checks. */
18
+ const CHECK_INTERVAL_MS = 4 * 60 * 60 * 1000;
19
+ function readState() {
20
+ try {
21
+ return JSON.parse(readFileSync(updateStatePath(), "utf8"));
22
+ }
23
+ catch {
24
+ return {};
25
+ }
26
+ }
27
+ function writeState(next) {
28
+ try {
29
+ mkdirSync(path.dirname(updateStatePath()), { recursive: true });
30
+ writeFileSync(updateStatePath(), JSON.stringify({ ...readState(), ...next }, null, 2));
31
+ }
32
+ catch {
33
+ // A read-only HOME must not break the command the user actually ran.
34
+ }
35
+ }
36
+ /**
37
+ * The background updater's single line to the terminal. Its stderr is the
38
+ * parent CLI's terminal when there was one (see maybeCheckForUpdates), and
39
+ * that terminal may have closed by the time this fires — a dead fd must
40
+ * not crash an updater that is otherwise doing its job.
41
+ */
42
+ function announce(msg) {
43
+ try {
44
+ process.stderr.write(msg);
45
+ }
46
+ catch {
47
+ /* terminal gone */
48
+ }
49
+ }
50
+ export async function runUpdate(opts = {}) {
51
+ const quiet = opts.background === true;
52
+ const say = (msg) => {
53
+ if (!quiet)
54
+ process.stdout.write(`${msg}\n`);
55
+ };
56
+ if (updatesDisabled()) {
57
+ say("Updates are disabled (DREAMLAKE_DISABLE_UPDATES).");
58
+ return 0;
59
+ }
60
+ try {
61
+ const channel = activeChannel();
62
+ const pin = pinnedVersion();
63
+ // A pin outranks the channel. Saying nothing here would let the
64
+ // updater quietly undo an explicit `self-update <version>`.
65
+ if (!opts.target && pin) {
66
+ say(`dreamlake is pinned to ${pin}. Run \`dreamlake self-update channel ${channel}\` to resume updates.`);
67
+ writeState({ lastCheck: Date.now(), lastResult: `pinned ${pin}` });
68
+ return 0;
69
+ }
70
+ let available;
71
+ if (opts.target) {
72
+ available = opts.target;
73
+ }
74
+ else {
75
+ try {
76
+ available = await resolveChannel(channel);
77
+ }
78
+ catch (err) {
79
+ // Distinguish "your channel does not exist" from "the network is
80
+ // down" — a 404 on the pointer is a permanent, actionable problem
81
+ // and reporting it as unreachable sends people to debug DNS.
82
+ const msg = err.message;
83
+ const detail = /→ 404/.test(msg)
84
+ ? `Release channel "${channel}" is not published. Switch back with: dreamlake self-update channel latest`
85
+ : `Could not reach the release server: ${msg}`;
86
+ if (!quiet)
87
+ process.stderr.write(`${detail}\n`);
88
+ writeState({ lastCheck: Date.now(), lastResult: `channel ${channel} failed` });
89
+ return 1;
90
+ }
91
+ }
92
+ // An explicit target is deliberate — honour a downgrade. Channel
93
+ // updates only ever move forward.
94
+ if (!opts.target && compareVersions(available, VERSION) <= 0) {
95
+ say(`dreamlake is up to date (${VERSION}).`);
96
+ writeState({ lastCheck: Date.now(), lastResult: "up-to-date" });
97
+ return 0;
98
+ }
99
+ // Unobtrusive is the point of the background updater; invisible is not.
100
+ // Say once, at detection time, that the binary is about to change under
101
+ // them — the leading newline breaks away from whatever the foreground
102
+ // command is printing right now.
103
+ if (quiet) {
104
+ announce(`\ndreamlake ${available} is available — updating in the background (applies on your next run).\n`);
105
+ }
106
+ const result = await performInstall(opts.target ?? channel, { background: quiet });
107
+ writeState({
108
+ lastCheck: Date.now(),
109
+ lastResult: `installed ${result.version}`,
110
+ // The next foreground run confirms the swap actually happened — the
111
+ // announcement above is lost when there was no terminal to write to.
112
+ ...(quiet && result.version !== VERSION
113
+ ? { pendingNotice: { from: VERSION, to: result.version, at: Date.now() } }
114
+ : {}),
115
+ });
116
+ if (result.previous && result.previous !== result.version) {
117
+ say(`Successfully updated from ${result.previous} to version ${result.version}.`);
118
+ }
119
+ else {
120
+ say(`Installed dreamlake ${result.version}.`);
121
+ }
122
+ if (result.pinned)
123
+ say(`Pinned to ${result.pinned} — auto-update is paused until you pick a channel.`);
124
+ for (const line of installWarnings(result)) {
125
+ if (!quiet)
126
+ process.stderr.write(`${line}\n`);
127
+ }
128
+ if (result.pathAdvice)
129
+ say(result.pathAdvice);
130
+ if (!quiet && !result.launcherConflict)
131
+ remindAfterInstall(result.version);
132
+ return 0;
133
+ }
134
+ catch (err) {
135
+ writeState({ lastCheck: Date.now(), lastResult: `error: ${err.message}` });
136
+ if (!quiet)
137
+ process.stderr.write(`Update failed: ${err.message}\n`);
138
+ return quiet ? 0 : 1;
139
+ }
140
+ }
141
+ // ─── background check ────────────────────────────────────────────────
142
+ /** Subcommands that must never trigger a background check (recursion, or
143
+ * a check racing the install the user explicitly asked for). `update` is
144
+ * absent on purpose — that one edits bindrs and datasets, not the CLI. */
145
+ const SKIP_COMMANDS = new Set(["install", "self-update", "doctor", "help"]);
146
+ /**
147
+ * One line confirming a background update that landed since the last run.
148
+ * By now the launcher symlink already points at the new version, so the
149
+ * process printing this normally *is* the `to` version — the message is
150
+ * how the user learns why.
151
+ */
152
+ function announcePendingUpdate() {
153
+ const { pendingNotice } = readState();
154
+ if (!pendingNotice)
155
+ return;
156
+ writeState({ pendingNotice: null });
157
+ process.stderr.write(`dreamlake was auto-updated from ${pendingNotice.from} to ${pendingNotice.to} in the background.\n`);
158
+ }
159
+ /**
160
+ * Fire-and-forget update check, called once at startup. Returns without
161
+ * doing anything unless this is a native install, the throttle window has
162
+ * elapsed, and auto-update is enabled. The child is detached and unref'd,
163
+ * so it never holds the CLI open; it inherits stderr (when that is a
164
+ * terminal) solely to say that a background update has started.
165
+ */
166
+ export function maybeCheckForUpdates(argv) {
167
+ try {
168
+ // The detached child boots through here too. It must neither consume
169
+ // the pending notice its own install is about to set, nor spawn a
170
+ // further check of its own.
171
+ if (process.env.DREAMLAKE_UPDATE_BACKGROUND === "1")
172
+ return;
173
+ // Before every early return below: a background update that already
174
+ // landed should be announced even if auto-updating has since been
175
+ // switched off or the window has not elapsed.
176
+ announcePendingUpdate();
177
+ if (autoUpdaterDisabled())
178
+ return;
179
+ if (!isNativeInstall())
180
+ return;
181
+ // No unattended updates on Windows. The launcher is a copy rather than
182
+ // a symlink, and Windows locks a running .exe, so swapping it out from
183
+ // under a live process is not something to do behind the user's back.
184
+ // `dreamlake self-update` still works, on purpose and in the
185
+ // foreground, where a failure is visible.
186
+ if (isWindows)
187
+ return;
188
+ // A pinned install is frozen on purpose — never move it.
189
+ if (pinnedVersion())
190
+ return;
191
+ const sub = argv[2];
192
+ if (sub && SKIP_COMMANDS.has(sub))
193
+ return;
194
+ const { lastCheck = 0 } = readState();
195
+ if (Date.now() - lastCheck < CHECK_INTERVAL_MS)
196
+ return;
197
+ // Stamp before spawning: a child that dies early must not cause a new
198
+ // check on every subsequent invocation.
199
+ writeState({ lastCheck: Date.now() });
200
+ if (!existsSync(process.execPath))
201
+ return;
202
+ const child = spawn(process.execPath, ["self-update", "--background"], {
203
+ detached: true,
204
+ // Hand the child the terminal's stderr so it can announce, once, that
205
+ // it found and is installing a new version — everything else it does
206
+ // stays silent. Without a terminal there is nobody to tell (and no
207
+ // TTY to garble), so everything is dropped as before.
208
+ stdio: process.stderr.isTTY ? ["ignore", "ignore", "inherit"] : "ignore",
209
+ env: { ...process.env, DREAMLAKE_UPDATE_BACKGROUND: "1" },
210
+ });
211
+ child.unref();
212
+ }
213
+ catch {
214
+ // Never let the updater interfere with the command being run.
215
+ }
216
+ }
217
+ /** Human-readable last-check line for `dreamlake self-update --status`. */
218
+ export function updateStatus() {
219
+ const { lastCheck, lastResult } = readState();
220
+ const channel = activeChannel();
221
+ const pin = pinnedVersion();
222
+ const lines = [
223
+ `version: ${VERSION}`,
224
+ `channel: ${channel}${pin ? " (overridden by pin)" : ""}`,
225
+ `pinned: ${pin ?? "no"}`,
226
+ `install: ${isNativeInstall() ? "native" : "not a native install (auto-update off)"}`,
227
+ `auto: ${!isNativeInstall()
228
+ ? "off (not a native install)"
229
+ : isWindows
230
+ ? "off on Windows — run `dreamlake self-update` to update"
231
+ : autoUpdaterDisabled()
232
+ ? "off (disabled by environment)"
233
+ : pin
234
+ ? "off (pinned)"
235
+ : "on"}`,
236
+ `last check: ${lastCheck ? new Date(lastCheck).toISOString() : "never"}`,
237
+ ];
238
+ if (lastResult)
239
+ lines.push(`last result: ${lastResult}`);
240
+ return lines.join("\n");
241
+ }
@@ -0,0 +1,3 @@
1
+ import type { Command } from "commander";
2
+ export declare function serviceAccountRequest(path: string, method?: string, body?: unknown): Promise<Record<string, unknown>>;
3
+ export declare function registerServiceAccountsCommand(program: Command): void;
@@ -0,0 +1,149 @@
1
+ import { collectionList } from "../collection-list.js";
2
+ import { resolveRemote, resolveToken } from "../config.js";
3
+ const ID = /^[a-f0-9]{24}$/;
4
+ const NS = /^[A-Za-z0-9][A-Za-z0-9_.-]{0,127}$/;
5
+ const NAME = /^[a-z][a-z0-9_-]{0,62}$/;
6
+ function namespace(value) {
7
+ if (!NS.test(value))
8
+ throw new Error("Use a single namespace name");
9
+ return `/namespaces/${encodeURIComponent(value)}/service-accounts`;
10
+ }
11
+ function account(value) {
12
+ const parts = value.split("/");
13
+ if (parts.length !== 2 || !ID.test(parts[1]))
14
+ throw new Error("Use namespace/service-account-id");
15
+ return `${namespace(parts[0])}/${parts[1]}`;
16
+ }
17
+ function resource(value) {
18
+ if (!ID.test(value))
19
+ throw new Error("Use a 24-character resource ID");
20
+ return value;
21
+ }
22
+ function page(value, fallback, max) {
23
+ const n = Number(value ?? fallback);
24
+ if (!Number.isSafeInteger(n) || n < 1 || n > max)
25
+ throw new Error("Invalid pagination");
26
+ return n;
27
+ }
28
+ // This API manages identities and grants only. Never forward unexpected credential
29
+ // fields from an API response to a terminal or JSON consumer.
30
+ function pick(value, fields) {
31
+ if (!value || typeof value !== "object" || Array.isArray(value))
32
+ throw new Error("Service account API returned an invalid response");
33
+ const selected = fields.filter(key => Object.hasOwn(value, key));
34
+ if (selected.some(key => value[key] !== null && !["string", "number", "boolean"].includes(typeof value[key])))
35
+ throw new Error("Service account API returned an invalid response");
36
+ return Object.fromEntries(selected.map(key => [key, value[key]]));
37
+ }
38
+ function safeResponse(value) {
39
+ const out = {};
40
+ const accountFields = ["id", "namespaceId", "name", "description", "createdByUserId", "createdAt", "updatedAt", "revokedAt"];
41
+ if (value?.serviceAccount)
42
+ out.serviceAccount = pick(value.serviceAccount, accountFields);
43
+ if (Array.isArray(value?.serviceAccounts))
44
+ out.serviceAccounts = value.serviceAccounts.map((entry) => pick(entry, accountFields));
45
+ if (Array.isArray(value?.projectGrants))
46
+ out.projectGrants = value.projectGrants.map((entry) => pick(entry, ["projectId", "role"]));
47
+ if (Array.isArray(value?.hostGrants))
48
+ out.hostGrants = value.hostGrants.map((entry) => pick(entry, ["hostId", "read", "use"]));
49
+ if (Object.hasOwn(value ?? {}, "binding"))
50
+ out.binding = value.binding === null ? null : pick(value.binding, ["enrollmentId"]);
51
+ if (value?.revocationState === "pending" || value?.revocationState === "revoked")
52
+ out.revocationState = value.revocationState;
53
+ if (Array.isArray(value?.revocations))
54
+ out.revocations = value.revocations.map((entry) => pick(entry, ["enrollmentId", "state"]));
55
+ if (value?.grant)
56
+ out.grant = pick(value.grant, ["projectId", "hostId", "role", "read", "use"]);
57
+ for (const key of ["page", "pageSize", "total"])
58
+ if (Number.isSafeInteger(value?.[key]))
59
+ out[key] = value[key];
60
+ if (value?.revoked === true)
61
+ out.revoked = true;
62
+ if (!Object.keys(out).length)
63
+ throw new Error("Service account API returned an invalid response");
64
+ return out;
65
+ }
66
+ export async function serviceAccountRequest(path, method = "GET", body) {
67
+ const token = resolveToken();
68
+ if (!token)
69
+ throw new Error("DreamLake authentication is required");
70
+ let response;
71
+ try {
72
+ response = await fetch(`${resolveRemote()}${path}`, { method,
73
+ headers: { Authorization: `Bearer ${token}`, ...(body === undefined ? {} : { "Content-Type": "application/json" }) },
74
+ body: body === undefined ? undefined : JSON.stringify(body), redirect: "error", signal: AbortSignal.timeout(30_000) });
75
+ }
76
+ catch {
77
+ throw new Error("Service account response unavailable; inspect account state before retrying a write");
78
+ }
79
+ // Errors can contain secrets or reflected input; report only the status.
80
+ if (!response.ok)
81
+ throw new Error(`Service account request failed (HTTP ${response.status})`);
82
+ let data;
83
+ try {
84
+ data = await response.json();
85
+ }
86
+ catch {
87
+ throw new Error("Service account API returned invalid JSON");
88
+ }
89
+ const result = safeResponse(data);
90
+ if (path.endsWith("/revoke") && (result.revocationState !== "pending" && result.revocationState !== "revoked"))
91
+ throw new Error("Service account revocation confirmation is missing; inspect account state and retry revocation");
92
+ return result;
93
+ }
94
+ async function execute(opts, work) {
95
+ try {
96
+ const result = await work();
97
+ console.log(JSON.stringify(result, null, opts.json ? undefined : 2));
98
+ if (result?.revocationState === "pending")
99
+ process.exitCode = 1;
100
+ }
101
+ catch (error) {
102
+ const result = { error: error instanceof Error ? error.message : "Service account request failed" };
103
+ if (opts.json)
104
+ console.log(JSON.stringify(result));
105
+ else
106
+ console.error(result.error);
107
+ process.exitCode = 1;
108
+ }
109
+ }
110
+ export function registerServiceAccountsCommand(program) {
111
+ const group = program.command("service-accounts").description("manage namespace-owned machine identities and explicit resource grants");
112
+ group.command("create <namespace>").requiredOption("--name <name>").option("--description <text>").option("--json")
113
+ .description("create one account per Nymph; identical name and description recover the same account")
114
+ .action((ns, opts) => execute(opts, () => {
115
+ if (!NAME.test(opts.name))
116
+ throw new Error("Account name must start with a lowercase letter and contain at most 63 lowercase letters, digits, underscores or hyphens");
117
+ if (opts.description !== undefined && (opts.description.length > 1000 || /[\x00-\x08\x0b\x0c\x0e-\x1f\x7f]/.test(opts.description)))
118
+ throw new Error("Description must be at most 1000 characters without control characters");
119
+ return serviceAccountRequest(namespace(ns), "POST", { name: opts.name, ...(opts.description !== undefined ? { description: opts.description } : {}) });
120
+ }));
121
+ collectionList(group, "list <namespace>").option("--page <n>").option("--page-size <n>").option("--json")
122
+ .action((ns, opts) => execute(opts, () => serviceAccountRequest(`${namespace(ns)}?page=${page(opts.page, 1, 100000)}&pageSize=${page(opts.pageSize, 50, 100)}`)));
123
+ group.command("show <account>").option("--json")
124
+ .action((value, opts) => execute(opts, () => serviceAccountRequest(account(value))));
125
+ group.command("bind <account>").description("bind an existing Nymph enrollment to its dedicated service account")
126
+ .requiredOption("--enrollment <id>", "existing enrollment in the same namespace").option("--json")
127
+ .action((value, opts) => execute(opts, () => serviceAccountRequest(`${account(value)}/enrollment`, "POST", { enrollmentId: resource(opts.enrollment) })));
128
+ group.command("revoke <account>").description("permanently revoke the account and its machine access").option("--json")
129
+ .action((value, opts) => execute(opts, () => serviceAccountRequest(`${account(value)}/revoke`, "POST", {})));
130
+ const projects = group.command("project-grants").description("set or remove an explicit project role; inspect with show");
131
+ projects.command("set <account>").requiredOption("--project <id>").requiredOption("--role <role>", "READ, WRITE or ADMIN").option("--json")
132
+ .action((value, opts) => execute(opts, () => {
133
+ if (!["READ", "WRITE", "ADMIN"].includes(opts.role))
134
+ throw new Error("Project role must be READ, WRITE or ADMIN");
135
+ return serviceAccountRequest(`${account(value)}/project-grants/${resource(opts.project)}`, "PUT", { role: opts.role });
136
+ }));
137
+ projects.command("remove <account>").requiredOption("--project <id>").option("--json")
138
+ .action((value, opts) => execute(opts, () => serviceAccountRequest(`${account(value)}/project-grants/${resource(opts.project)}`, "DELETE")));
139
+ const hosts = group.command("host-grants").description("set or remove explicit host permissions; inspect with show");
140
+ hosts.command("set <account>").requiredOption("--host <id>").option("--read", "allow inspecting the host").option("--use", "allow using the host").option("--json")
141
+ .description("replace host permissions; omitted flags become false")
142
+ .action((value, opts) => execute(opts, () => {
143
+ if (!opts.read && !opts.use)
144
+ throw new Error("Pass --read and/or --use, or remove the host grant");
145
+ return serviceAccountRequest(`${account(value)}/host-grants/${resource(opts.host)}`, "PUT", { read: opts.read === true, use: opts.use === true });
146
+ }));
147
+ hosts.command("remove <account>").requiredOption("--host <id>").option("--json")
148
+ .action((value, opts) => execute(opts, () => serviceAccountRequest(`${account(value)}/host-grants/${resource(opts.host)}`, "DELETE")));
149
+ }