@cuna_labs/cli 0.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 (624) hide show
  1. package/LICENSE +201 -0
  2. package/NOTICE +9 -0
  3. package/README.md +169 -0
  4. package/THIRD_PARTY_NOTICES.md +29 -0
  5. package/dist/api/capability-evidence.d.ts +19 -0
  6. package/dist/api/capability-evidence.d.ts.map +1 -0
  7. package/dist/api/capability-evidence.js +38 -0
  8. package/dist/api/capability-evidence.js.map +1 -0
  9. package/dist/api/client.d.ts +167 -0
  10. package/dist/api/client.d.ts.map +1 -0
  11. package/dist/api/client.js +937 -0
  12. package/dist/api/client.js.map +1 -0
  13. package/dist/api/contracts.d.ts +345 -0
  14. package/dist/api/contracts.d.ts.map +1 -0
  15. package/dist/api/contracts.js +976 -0
  16. package/dist/api/contracts.js.map +1 -0
  17. package/dist/api/execution-workspaces.d.ts +17 -0
  18. package/dist/api/execution-workspaces.d.ts.map +1 -0
  19. package/dist/api/execution-workspaces.js +46 -0
  20. package/dist/api/execution-workspaces.js.map +1 -0
  21. package/dist/api/http.d.ts +76 -0
  22. package/dist/api/http.d.ts.map +1 -0
  23. package/dist/api/http.js +838 -0
  24. package/dist/api/http.js.map +1 -0
  25. package/dist/api/managed-executions.d.ts +37 -0
  26. package/dist/api/managed-executions.d.ts.map +1 -0
  27. package/dist/api/managed-executions.js +80 -0
  28. package/dist/api/managed-executions.js.map +1 -0
  29. package/dist/api/observer-v2-schema.d.ts +206 -0
  30. package/dist/api/observer-v2-schema.d.ts.map +1 -0
  31. package/dist/api/observer-v2-schema.js +264 -0
  32. package/dist/api/observer-v2-schema.js.map +1 -0
  33. package/dist/api/observer-v2.d.ts +33 -0
  34. package/dist/api/observer-v2.d.ts.map +1 -0
  35. package/dist/api/observer-v2.js +60 -0
  36. package/dist/api/observer-v2.js.map +1 -0
  37. package/dist/api/owner-observe-grants-v2-schema.d.ts +678 -0
  38. package/dist/api/owner-observe-grants-v2-schema.d.ts.map +1 -0
  39. package/dist/api/owner-observe-grants-v2-schema.js +887 -0
  40. package/dist/api/owner-observe-grants-v2-schema.js.map +1 -0
  41. package/dist/api/owner-observe-grants-v2.d.ts +268 -0
  42. package/dist/api/owner-observe-grants-v2.d.ts.map +1 -0
  43. package/dist/api/owner-observe-grants-v2.js +604 -0
  44. package/dist/api/owner-observe-grants-v2.js.map +1 -0
  45. package/dist/api/provider-v2-schema.d.ts +293 -0
  46. package/dist/api/provider-v2-schema.d.ts.map +1 -0
  47. package/dist/api/provider-v2-schema.js +381 -0
  48. package/dist/api/provider-v2-schema.js.map +1 -0
  49. package/dist/api/provider-v2.d.ts +55 -0
  50. package/dist/api/provider-v2.d.ts.map +1 -0
  51. package/dist/api/provider-v2.js +54 -0
  52. package/dist/api/provider-v2.js.map +1 -0
  53. package/dist/api/remote-workspace.d.ts +29 -0
  54. package/dist/api/remote-workspace.d.ts.map +1 -0
  55. package/dist/api/remote-workspace.js +62 -0
  56. package/dist/api/remote-workspace.js.map +1 -0
  57. package/dist/api/supervisor-live-update.d.ts +248 -0
  58. package/dist/api/supervisor-live-update.d.ts.map +1 -0
  59. package/dist/api/supervisor-live-update.js +434 -0
  60. package/dist/api/supervisor-live-update.js.map +1 -0
  61. package/dist/api/terminal-reason.d.ts +5 -0
  62. package/dist/api/terminal-reason.d.ts.map +1 -0
  63. package/dist/api/terminal-reason.js +12 -0
  64. package/dist/api/terminal-reason.js.map +1 -0
  65. package/dist/auth/browser-handoff.d.ts +59 -0
  66. package/dist/auth/browser-handoff.d.ts.map +1 -0
  67. package/dist/auth/browser-handoff.js +33 -0
  68. package/dist/auth/browser-handoff.js.map +1 -0
  69. package/dist/auth/browser.d.ts +11 -0
  70. package/dist/auth/browser.d.ts.map +1 -0
  71. package/dist/auth/browser.js +47 -0
  72. package/dist/auth/browser.js.map +1 -0
  73. package/dist/auth/human-client.d.ts +39 -0
  74. package/dist/auth/human-client.d.ts.map +1 -0
  75. package/dist/auth/human-client.js +66 -0
  76. package/dist/auth/human-client.js.map +1 -0
  77. package/dist/auth/human-contracts.d.ts +52 -0
  78. package/dist/auth/human-contracts.d.ts.map +1 -0
  79. package/dist/auth/human-contracts.js +229 -0
  80. package/dist/auth/human-contracts.js.map +1 -0
  81. package/dist/auth/human-session.d.ts +48 -0
  82. package/dist/auth/human-session.d.ts.map +1 -0
  83. package/dist/auth/human-session.js +902 -0
  84. package/dist/auth/human-session.js.map +1 -0
  85. package/dist/auth/onboarding-state.d.ts +31 -0
  86. package/dist/auth/onboarding-state.d.ts.map +1 -0
  87. package/dist/auth/onboarding-state.js +52 -0
  88. package/dist/auth/onboarding-state.js.map +1 -0
  89. package/dist/auth/pkce.d.ts +15 -0
  90. package/dist/auth/pkce.d.ts.map +1 -0
  91. package/dist/auth/pkce.js +19 -0
  92. package/dist/auth/pkce.js.map +1 -0
  93. package/dist/bin/cuna.d.ts +3 -0
  94. package/dist/bin/cuna.d.ts.map +1 -0
  95. package/dist/bin/cuna.js +4 -0
  96. package/dist/bin/cuna.js.map +1 -0
  97. package/dist/build-identity.d.ts +20 -0
  98. package/dist/build-identity.d.ts.map +1 -0
  99. package/dist/build-identity.js +77 -0
  100. package/dist/build-identity.js.map +1 -0
  101. package/dist/cli/command-help.d.ts +9 -0
  102. package/dist/cli/command-help.d.ts.map +1 -0
  103. package/dist/cli/command-help.js +324 -0
  104. package/dist/cli/command-help.js.map +1 -0
  105. package/dist/cli/help.d.ts +40 -0
  106. package/dist/cli/help.d.ts.map +1 -0
  107. package/dist/cli/help.js +256 -0
  108. package/dist/cli/help.js.map +1 -0
  109. package/dist/cli/output.d.ts +28 -0
  110. package/dist/cli/output.d.ts.map +1 -0
  111. package/dist/cli/output.js +95 -0
  112. package/dist/cli/output.js.map +1 -0
  113. package/dist/cli/parser.d.ts +65 -0
  114. package/dist/cli/parser.d.ts.map +1 -0
  115. package/dist/cli/parser.js +294 -0
  116. package/dist/cli/parser.js.map +1 -0
  117. package/dist/cli/process-entrypoint.d.ts +18 -0
  118. package/dist/cli/process-entrypoint.d.ts.map +1 -0
  119. package/dist/cli/process-entrypoint.js +26 -0
  120. package/dist/cli/process-entrypoint.js.map +1 -0
  121. package/dist/cli/run.d.ts +114 -0
  122. package/dist/cli/run.d.ts.map +1 -0
  123. package/dist/cli/run.js +1969 -0
  124. package/dist/cli/run.js.map +1 -0
  125. package/dist/commands/commands.d.ts +74 -0
  126. package/dist/commands/commands.d.ts.map +1 -0
  127. package/dist/commands/commands.js +2814 -0
  128. package/dist/commands/commands.js.map +1 -0
  129. package/dist/config/config.d.ts +86 -0
  130. package/dist/config/config.d.ts.map +1 -0
  131. package/dist/config/config.js +323 -0
  132. package/dist/config/config.js.map +1 -0
  133. package/dist/config/infra-contract-witness.d.ts +29 -0
  134. package/dist/config/infra-contract-witness.d.ts.map +1 -0
  135. package/dist/config/infra-contract-witness.js +30 -0
  136. package/dist/config/infra-contract-witness.js.map +1 -0
  137. package/dist/core/browser-url.d.ts +2 -0
  138. package/dist/core/browser-url.d.ts.map +1 -0
  139. package/dist/core/browser-url.js +20 -0
  140. package/dist/core/browser-url.js.map +1 -0
  141. package/dist/core/deployed-wire-compatibility.d.ts +15 -0
  142. package/dist/core/deployed-wire-compatibility.d.ts.map +1 -0
  143. package/dist/core/deployed-wire-compatibility.js +15 -0
  144. package/dist/core/deployed-wire-compatibility.js.map +1 -0
  145. package/dist/core/errors.d.ts +59 -0
  146. package/dist/core/errors.d.ts.map +1 -0
  147. package/dist/core/errors.js +82 -0
  148. package/dist/core/errors.js.map +1 -0
  149. package/dist/core/exit-codes.d.ts +68 -0
  150. package/dist/core/exit-codes.d.ts.map +1 -0
  151. package/dist/core/exit-codes.js +84 -0
  152. package/dist/core/exit-codes.js.map +1 -0
  153. package/dist/core/instant.d.ts +60 -0
  154. package/dist/core/instant.d.ts.map +1 -0
  155. package/dist/core/instant.js +90 -0
  156. package/dist/core/instant.js.map +1 -0
  157. package/dist/core/namespace.d.ts +171 -0
  158. package/dist/core/namespace.d.ts.map +1 -0
  159. package/dist/core/namespace.js +227 -0
  160. package/dist/core/namespace.js.map +1 -0
  161. package/dist/core/observation-budget.d.ts +185 -0
  162. package/dist/core/observation-budget.d.ts.map +1 -0
  163. package/dist/core/observation-budget.js +209 -0
  164. package/dist/core/observation-budget.js.map +1 -0
  165. package/dist/core/product-web.d.ts +81 -0
  166. package/dist/core/product-web.d.ts.map +1 -0
  167. package/dist/core/product-web.js +87 -0
  168. package/dist/core/product-web.js.map +1 -0
  169. package/dist/core/validation.d.ts +90 -0
  170. package/dist/core/validation.d.ts.map +1 -0
  171. package/dist/core/validation.js +199 -0
  172. package/dist/core/validation.js.map +1 -0
  173. package/dist/credentials/contracts.d.ts +82 -0
  174. package/dist/credentials/contracts.d.ts.map +1 -0
  175. package/dist/credentials/contracts.js +2 -0
  176. package/dist/credentials/contracts.js.map +1 -0
  177. package/dist/credentials/errors.d.ts +19 -0
  178. package/dist/credentials/errors.d.ts.map +1 -0
  179. package/dist/credentials/errors.js +16 -0
  180. package/dist/credentials/errors.js.map +1 -0
  181. package/dist/credentials/index.d.ts +6 -0
  182. package/dist/credentials/index.d.ts.map +1 -0
  183. package/dist/credentials/index.js +6 -0
  184. package/dist/credentials/index.js.map +1 -0
  185. package/dist/credentials/local-session.d.ts +101 -0
  186. package/dist/credentials/local-session.d.ts.map +1 -0
  187. package/dist/credentials/local-session.js +839 -0
  188. package/dist/credentials/local-session.js.map +1 -0
  189. package/dist/credentials/secret-material.d.ts +17 -0
  190. package/dist/credentials/secret-material.d.ts.map +1 -0
  191. package/dist/credentials/secret-material.js +49 -0
  192. package/dist/credentials/secret-material.js.map +1 -0
  193. package/dist/credentials/vault.d.ts +41 -0
  194. package/dist/credentials/vault.d.ts.map +1 -0
  195. package/dist/credentials/vault.js +719 -0
  196. package/dist/credentials/vault.js.map +1 -0
  197. package/dist/daemon/endpoint.d.ts +29 -0
  198. package/dist/daemon/endpoint.d.ts.map +1 -0
  199. package/dist/daemon/endpoint.js +66 -0
  200. package/dist/daemon/endpoint.js.map +1 -0
  201. package/dist/daemon/journal.d.ts +62 -0
  202. package/dist/daemon/journal.d.ts.map +1 -0
  203. package/dist/daemon/journal.js +299 -0
  204. package/dist/daemon/journal.js.map +1 -0
  205. package/dist/daemon/lease.d.ts +25 -0
  206. package/dist/daemon/lease.d.ts.map +1 -0
  207. package/dist/daemon/lease.js +94 -0
  208. package/dist/daemon/lease.js.map +1 -0
  209. package/dist/daemon/lifecycle.d.ts +14 -0
  210. package/dist/daemon/lifecycle.d.ts.map +1 -0
  211. package/dist/daemon/lifecycle.js +29 -0
  212. package/dist/daemon/lifecycle.js.map +1 -0
  213. package/dist/daemon/protocol.d.ts +65 -0
  214. package/dist/daemon/protocol.d.ts.map +1 -0
  215. package/dist/daemon/protocol.js +194 -0
  216. package/dist/daemon/protocol.js.map +1 -0
  217. package/dist/daemon/supervisor.d.ts +29 -0
  218. package/dist/daemon/supervisor.d.ts.map +1 -0
  219. package/dist/daemon/supervisor.js +87 -0
  220. package/dist/daemon/supervisor.js.map +1 -0
  221. package/dist/daemon/views.d.ts +31 -0
  222. package/dist/daemon/views.d.ts.map +1 -0
  223. package/dist/daemon/views.js +86 -0
  224. package/dist/daemon/views.js.map +1 -0
  225. package/dist/index.d.ts +38 -0
  226. package/dist/index.d.ts.map +1 -0
  227. package/dist/index.js +38 -0
  228. package/dist/index.js.map +1 -0
  229. package/dist/journey/api-effects.d.ts +59 -0
  230. package/dist/journey/api-effects.d.ts.map +1 -0
  231. package/dist/journey/api-effects.js +386 -0
  232. package/dist/journey/api-effects.js.map +1 -0
  233. package/dist/journey/derived-identity.d.ts +91 -0
  234. package/dist/journey/derived-identity.d.ts.map +1 -0
  235. package/dist/journey/derived-identity.js +123 -0
  236. package/dist/journey/derived-identity.js.map +1 -0
  237. package/dist/journey/index.d.ts +6 -0
  238. package/dist/journey/index.d.ts.map +1 -0
  239. package/dist/journey/index.js +6 -0
  240. package/dist/journey/index.js.map +1 -0
  241. package/dist/journey/intent.d.ts +36 -0
  242. package/dist/journey/intent.d.ts.map +1 -0
  243. package/dist/journey/intent.js +191 -0
  244. package/dist/journey/intent.js.map +1 -0
  245. package/dist/journey/orchestrator.d.ts +140 -0
  246. package/dist/journey/orchestrator.d.ts.map +1 -0
  247. package/dist/journey/orchestrator.js +415 -0
  248. package/dist/journey/orchestrator.js.map +1 -0
  249. package/dist/journey/provider-launch-intent.d.ts +12 -0
  250. package/dist/journey/provider-launch-intent.d.ts.map +1 -0
  251. package/dist/journey/provider-launch-intent.js +40 -0
  252. package/dist/journey/provider-launch-intent.js.map +1 -0
  253. package/dist/journey/remote-workspace.d.ts +34 -0
  254. package/dist/journey/remote-workspace.d.ts.map +1 -0
  255. package/dist/journey/remote-workspace.js +91 -0
  256. package/dist/journey/remote-workspace.js.map +1 -0
  257. package/dist/journey/root-entry.d.ts +56 -0
  258. package/dist/journey/root-entry.d.ts.map +1 -0
  259. package/dist/journey/root-entry.js +19 -0
  260. package/dist/journey/root-entry.js.map +1 -0
  261. package/dist/journey/selection.d.ts +165 -0
  262. package/dist/journey/selection.d.ts.map +1 -0
  263. package/dist/journey/selection.js +565 -0
  264. package/dist/journey/selection.js.map +1 -0
  265. package/dist/journey/session-failure.d.ts +4 -0
  266. package/dist/journey/session-failure.d.ts.map +1 -0
  267. package/dist/journey/session-failure.js +28 -0
  268. package/dist/journey/session-failure.js.map +1 -0
  269. package/dist/journey/workspace-effects.d.ts +30 -0
  270. package/dist/journey/workspace-effects.d.ts.map +1 -0
  271. package/dist/journey/workspace-effects.js +348 -0
  272. package/dist/journey/workspace-effects.js.map +1 -0
  273. package/dist/local-actions/broker.d.ts +32 -0
  274. package/dist/local-actions/broker.d.ts.map +1 -0
  275. package/dist/local-actions/broker.js +400 -0
  276. package/dist/local-actions/broker.js.map +1 -0
  277. package/dist/local-actions/browser-action.d.ts +78 -0
  278. package/dist/local-actions/browser-action.d.ts.map +1 -0
  279. package/dist/local-actions/browser-action.js +307 -0
  280. package/dist/local-actions/browser-action.js.map +1 -0
  281. package/dist/local-actions/callback-relay.d.ts +45 -0
  282. package/dist/local-actions/callback-relay.d.ts.map +1 -0
  283. package/dist/local-actions/callback-relay.js +265 -0
  284. package/dist/local-actions/callback-relay.js.map +1 -0
  285. package/dist/local-actions/clipboard.d.ts +3 -0
  286. package/dist/local-actions/clipboard.d.ts.map +1 -0
  287. package/dist/local-actions/clipboard.js +18 -0
  288. package/dist/local-actions/clipboard.js.map +1 -0
  289. package/dist/local-actions/contracts.d.ts +63 -0
  290. package/dist/local-actions/contracts.d.ts.map +1 -0
  291. package/dist/local-actions/contracts.js +18 -0
  292. package/dist/local-actions/contracts.js.map +1 -0
  293. package/dist/local-actions/desktop-presentation.d.ts +141 -0
  294. package/dist/local-actions/desktop-presentation.d.ts.map +1 -0
  295. package/dist/local-actions/desktop-presentation.js +253 -0
  296. package/dist/local-actions/desktop-presentation.js.map +1 -0
  297. package/dist/local-actions/device-selection.d.ts +43 -0
  298. package/dist/local-actions/device-selection.d.ts.map +1 -0
  299. package/dist/local-actions/device-selection.js +154 -0
  300. package/dist/local-actions/device-selection.js.map +1 -0
  301. package/dist/local-actions/executor.d.ts +49 -0
  302. package/dist/local-actions/executor.d.ts.map +1 -0
  303. package/dist/local-actions/executor.js +329 -0
  304. package/dist/local-actions/executor.js.map +1 -0
  305. package/dist/local-actions/file-transfers.d.ts +141 -0
  306. package/dist/local-actions/file-transfers.d.ts.map +1 -0
  307. package/dist/local-actions/file-transfers.js +446 -0
  308. package/dist/local-actions/file-transfers.js.map +1 -0
  309. package/dist/local-actions/foreground-notifications.d.ts +45 -0
  310. package/dist/local-actions/foreground-notifications.d.ts.map +1 -0
  311. package/dist/local-actions/foreground-notifications.js +163 -0
  312. package/dist/local-actions/foreground-notifications.js.map +1 -0
  313. package/dist/local-actions/git-signing.d.ts +39 -0
  314. package/dist/local-actions/git-signing.d.ts.map +1 -0
  315. package/dist/local-actions/git-signing.js +135 -0
  316. package/dist/local-actions/git-signing.js.map +1 -0
  317. package/dist/local-actions/index.d.ts +19 -0
  318. package/dist/local-actions/index.d.ts.map +1 -0
  319. package/dist/local-actions/index.js +19 -0
  320. package/dist/local-actions/index.js.map +1 -0
  321. package/dist/local-actions/local-service-actions.d.ts +87 -0
  322. package/dist/local-actions/local-service-actions.d.ts.map +1 -0
  323. package/dist/local-actions/local-service-actions.js +347 -0
  324. package/dist/local-actions/local-service-actions.js.map +1 -0
  325. package/dist/local-actions/loopback.d.ts +5 -0
  326. package/dist/local-actions/loopback.d.ts.map +1 -0
  327. package/dist/local-actions/loopback.js +15 -0
  328. package/dist/local-actions/loopback.js.map +1 -0
  329. package/dist/local-actions/policy-store.d.ts +7 -0
  330. package/dist/local-actions/policy-store.d.ts.map +1 -0
  331. package/dist/local-actions/policy-store.js +70 -0
  332. package/dist/local-actions/policy-store.js.map +1 -0
  333. package/dist/local-actions/policy.d.ts +21 -0
  334. package/dist/local-actions/policy.d.ts.map +1 -0
  335. package/dist/local-actions/policy.js +43 -0
  336. package/dist/local-actions/policy.js.map +1 -0
  337. package/dist/local-actions/private-port-forward.d.ts +36 -0
  338. package/dist/local-actions/private-port-forward.d.ts.map +1 -0
  339. package/dist/local-actions/private-port-forward.js +154 -0
  340. package/dist/local-actions/private-port-forward.js.map +1 -0
  341. package/dist/local-actions/provider-mcp-config.d.ts +101 -0
  342. package/dist/local-actions/provider-mcp-config.d.ts.map +1 -0
  343. package/dist/local-actions/provider-mcp-config.js +166 -0
  344. package/dist/local-actions/provider-mcp-config.js.map +1 -0
  345. package/dist/local-actions/providers.d.ts +12 -0
  346. package/dist/local-actions/providers.d.ts.map +1 -0
  347. package/dist/local-actions/providers.js +42 -0
  348. package/dist/local-actions/providers.js.map +1 -0
  349. package/dist/local-actions/schemas.d.ts +4 -0
  350. package/dist/local-actions/schemas.d.ts.map +1 -0
  351. package/dist/local-actions/schemas.js +314 -0
  352. package/dist/local-actions/schemas.js.map +1 -0
  353. package/dist/local-actions/sensitive-consent.d.ts +32 -0
  354. package/dist/local-actions/sensitive-consent.d.ts.map +1 -0
  355. package/dist/local-actions/sensitive-consent.js +47 -0
  356. package/dist/local-actions/sensitive-consent.js.map +1 -0
  357. package/dist/machines/command-launch.d.ts +17 -0
  358. package/dist/machines/command-launch.d.ts.map +1 -0
  359. package/dist/machines/command-launch.js +52 -0
  360. package/dist/machines/command-launch.js.map +1 -0
  361. package/dist/machines/execution-receipt.d.ts +18 -0
  362. package/dist/machines/execution-receipt.d.ts.map +1 -0
  363. package/dist/machines/execution-receipt.js +87 -0
  364. package/dist/machines/execution-receipt.js.map +1 -0
  365. package/dist/machines/executions-screen.d.ts +6 -0
  366. package/dist/machines/executions-screen.d.ts.map +1 -0
  367. package/dist/machines/executions-screen.js +410 -0
  368. package/dist/machines/executions-screen.js.map +1 -0
  369. package/dist/machines/explorer.d.ts +75 -0
  370. package/dist/machines/explorer.d.ts.map +1 -0
  371. package/dist/machines/explorer.js +1726 -0
  372. package/dist/machines/explorer.js.map +1 -0
  373. package/dist/machines/live-supervisor-update.d.ts +325 -0
  374. package/dist/machines/live-supervisor-update.d.ts.map +1 -0
  375. package/dist/machines/live-supervisor-update.js +513 -0
  376. package/dist/machines/live-supervisor-update.js.map +1 -0
  377. package/dist/machines/machine-first.d.ts +123 -0
  378. package/dist/machines/machine-first.d.ts.map +1 -0
  379. package/dist/machines/machine-first.js +119 -0
  380. package/dist/machines/machine-first.js.map +1 -0
  381. package/dist/machines/opencode-supervisor.d.ts +51 -0
  382. package/dist/machines/opencode-supervisor.d.ts.map +1 -0
  383. package/dist/machines/opencode-supervisor.js +124 -0
  384. package/dist/machines/opencode-supervisor.js.map +1 -0
  385. package/dist/machines/pagination.d.ts +4 -0
  386. package/dist/machines/pagination.d.ts.map +1 -0
  387. package/dist/machines/pagination.js +7 -0
  388. package/dist/machines/pagination.js.map +1 -0
  389. package/dist/machines/provider-availability.d.ts +42 -0
  390. package/dist/machines/provider-availability.d.ts.map +1 -0
  391. package/dist/machines/provider-availability.js +82 -0
  392. package/dist/machines/provider-availability.js.map +1 -0
  393. package/dist/machines/provider-screen.d.ts +12 -0
  394. package/dist/machines/provider-screen.d.ts.map +1 -0
  395. package/dist/machines/provider-screen.js +129 -0
  396. package/dist/machines/provider-screen.js.map +1 -0
  397. package/dist/machines/session-actionability.d.ts +86 -0
  398. package/dist/machines/session-actionability.d.ts.map +1 -0
  399. package/dist/machines/session-actionability.js +125 -0
  400. package/dist/machines/session-actionability.js.map +1 -0
  401. package/dist/machines/session-visibility.d.ts +139 -0
  402. package/dist/machines/session-visibility.d.ts.map +1 -0
  403. package/dist/machines/session-visibility.js +109 -0
  404. package/dist/machines/session-visibility.js.map +1 -0
  405. package/dist/platform/adapter.d.ts +62 -0
  406. package/dist/platform/adapter.d.ts.map +1 -0
  407. package/dist/platform/adapter.js +240 -0
  408. package/dist/platform/adapter.js.map +1 -0
  409. package/dist/platform/support.d.ts +12 -0
  410. package/dist/platform/support.d.ts.map +1 -0
  411. package/dist/platform/support.js +25 -0
  412. package/dist/platform/support.js.map +1 -0
  413. package/dist/pty/contracts.d.ts +45 -0
  414. package/dist/pty/contracts.d.ts.map +1 -0
  415. package/dist/pty/contracts.js +2 -0
  416. package/dist/pty/contracts.js.map +1 -0
  417. package/dist/pty/evidence-gate.d.ts +14 -0
  418. package/dist/pty/evidence-gate.d.ts.map +1 -0
  419. package/dist/pty/evidence-gate.js +35 -0
  420. package/dist/pty/evidence-gate.js.map +1 -0
  421. package/dist/pty/index.d.ts +5 -0
  422. package/dist/pty/index.d.ts.map +1 -0
  423. package/dist/pty/index.js +5 -0
  424. package/dist/pty/index.js.map +1 -0
  425. package/dist/pty/node-host-terminal.d.ts +14 -0
  426. package/dist/pty/node-host-terminal.d.ts.map +1 -0
  427. package/dist/pty/node-host-terminal.js +173 -0
  428. package/dist/pty/node-host-terminal.js.map +1 -0
  429. package/dist/pty/node-process.d.ts +26 -0
  430. package/dist/pty/node-process.d.ts.map +1 -0
  431. package/dist/pty/node-process.js +102 -0
  432. package/dist/pty/node-process.js.map +1 -0
  433. package/dist/runtime/api-terminal-control-plane.d.ts +7 -0
  434. package/dist/runtime/api-terminal-control-plane.d.ts.map +1 -0
  435. package/dist/runtime/api-terminal-control-plane.js +95 -0
  436. package/dist/runtime/api-terminal-control-plane.js.map +1 -0
  437. package/dist/runtime/backoff.d.ts +17 -0
  438. package/dist/runtime/backoff.d.ts.map +1 -0
  439. package/dist/runtime/backoff.js +61 -0
  440. package/dist/runtime/backoff.js.map +1 -0
  441. package/dist/runtime/boundary.d.ts +171 -0
  442. package/dist/runtime/boundary.d.ts.map +1 -0
  443. package/dist/runtime/boundary.js +1858 -0
  444. package/dist/runtime/boundary.js.map +1 -0
  445. package/dist/runtime/capability-gate.d.ts +25 -0
  446. package/dist/runtime/capability-gate.d.ts.map +1 -0
  447. package/dist/runtime/capability-gate.js +77 -0
  448. package/dist/runtime/capability-gate.js.map +1 -0
  449. package/dist/runtime/contracts.d.ts +25 -0
  450. package/dist/runtime/contracts.d.ts.map +1 -0
  451. package/dist/runtime/contracts.js +66 -0
  452. package/dist/runtime/contracts.js.map +1 -0
  453. package/dist/runtime/errors.d.ts +20 -0
  454. package/dist/runtime/errors.d.ts.map +1 -0
  455. package/dist/runtime/errors.js +22 -0
  456. package/dist/runtime/errors.js.map +1 -0
  457. package/dist/runtime/index.d.ts +9 -0
  458. package/dist/runtime/index.d.ts.map +1 -0
  459. package/dist/runtime/index.js +9 -0
  460. package/dist/runtime/index.js.map +1 -0
  461. package/dist/runtime/node-foreground-session.d.ts +50 -0
  462. package/dist/runtime/node-foreground-session.d.ts.map +1 -0
  463. package/dist/runtime/node-foreground-session.js +431 -0
  464. package/dist/runtime/node-foreground-session.js.map +1 -0
  465. package/dist/runtime/node-websocket-connector.d.ts +6 -0
  466. package/dist/runtime/node-websocket-connector.d.ts.map +1 -0
  467. package/dist/runtime/node-websocket-connector.js +344 -0
  468. package/dist/runtime/node-websocket-connector.js.map +1 -0
  469. package/dist/runtime/observer-screen.d.ts +6 -0
  470. package/dist/runtime/observer-screen.d.ts.map +1 -0
  471. package/dist/runtime/observer-screen.js +144 -0
  472. package/dist/runtime/observer-screen.js.map +1 -0
  473. package/dist/runtime/owner-grant-operations.d.ts +136 -0
  474. package/dist/runtime/owner-grant-operations.d.ts.map +1 -0
  475. package/dist/runtime/owner-grant-operations.js +216 -0
  476. package/dist/runtime/owner-grant-operations.js.map +1 -0
  477. package/dist/runtime/owner-grants-screen.d.ts +40 -0
  478. package/dist/runtime/owner-grants-screen.d.ts.map +1 -0
  479. package/dist/runtime/owner-grants-screen.js +987 -0
  480. package/dist/runtime/owner-grants-screen.js.map +1 -0
  481. package/dist/runtime/terminal-transport.d.ts +85 -0
  482. package/dist/runtime/terminal-transport.d.ts.map +1 -0
  483. package/dist/runtime/terminal-transport.js +152 -0
  484. package/dist/runtime/terminal-transport.js.map +1 -0
  485. package/dist/sync/continuous-sync-supervisor.d.ts +107 -0
  486. package/dist/sync/continuous-sync-supervisor.d.ts.map +1 -0
  487. package/dist/sync/continuous-sync-supervisor.js +1117 -0
  488. package/dist/sync/continuous-sync-supervisor.js.map +1 -0
  489. package/dist/sync/index.d.ts +9 -0
  490. package/dist/sync/index.d.ts.map +1 -0
  491. package/dist/sync/index.js +9 -0
  492. package/dist/sync/index.js.map +1 -0
  493. package/dist/sync/journal.d.ts +57 -0
  494. package/dist/sync/journal.d.ts.map +1 -0
  495. package/dist/sync/journal.js +685 -0
  496. package/dist/sync/journal.js.map +1 -0
  497. package/dist/sync/revisions.d.ts +118 -0
  498. package/dist/sync/revisions.d.ts.map +1 -0
  499. package/dist/sync/revisions.js +364 -0
  500. package/dist/sync/revisions.js.map +1 -0
  501. package/dist/sync/supervisor.d.ts +107 -0
  502. package/dist/sync/supervisor.d.ts.map +1 -0
  503. package/dist/sync/supervisor.js +246 -0
  504. package/dist/sync/supervisor.js.map +1 -0
  505. package/dist/sync/workspace-sync-client.d.ts +18 -0
  506. package/dist/sync/workspace-sync-client.d.ts.map +1 -0
  507. package/dist/sync/workspace-sync-client.js +150 -0
  508. package/dist/sync/workspace-sync-client.js.map +1 -0
  509. package/dist/sync/workspace-sync-coordinator.d.ts +76 -0
  510. package/dist/sync/workspace-sync-coordinator.d.ts.map +1 -0
  511. package/dist/sync/workspace-sync-coordinator.js +621 -0
  512. package/dist/sync/workspace-sync-coordinator.js.map +1 -0
  513. package/dist/sync/workspace-sync-product-service.d.ts +79 -0
  514. package/dist/sync/workspace-sync-product-service.d.ts.map +1 -0
  515. package/dist/sync/workspace-sync-product-service.js +398 -0
  516. package/dist/sync/workspace-sync-product-service.js.map +1 -0
  517. package/dist/sync/workspace-sync-protocol.d.ts +145 -0
  518. package/dist/sync/workspace-sync-protocol.d.ts.map +1 -0
  519. package/dist/sync/workspace-sync-protocol.js +347 -0
  520. package/dist/sync/workspace-sync-protocol.js.map +1 -0
  521. package/dist/terminal/appbar.d.ts +40 -0
  522. package/dist/terminal/appbar.d.ts.map +1 -0
  523. package/dist/terminal/appbar.js +55 -0
  524. package/dist/terminal/appbar.js.map +1 -0
  525. package/dist/terminal/cell-width.d.ts +3 -0
  526. package/dist/terminal/cell-width.d.ts.map +1 -0
  527. package/dist/terminal/cell-width.js +53 -0
  528. package/dist/terminal/cell-width.js.map +1 -0
  529. package/dist/terminal/codec.d.ts +107 -0
  530. package/dist/terminal/codec.d.ts.map +1 -0
  531. package/dist/terminal/codec.js +538 -0
  532. package/dist/terminal/codec.js.map +1 -0
  533. package/dist/terminal/foreground.d.ts +135 -0
  534. package/dist/terminal/foreground.d.ts.map +1 -0
  535. package/dist/terminal/foreground.js +2097 -0
  536. package/dist/terminal/foreground.js.map +1 -0
  537. package/dist/terminal/generated/terminal-wire-v1.d.ts +26 -0
  538. package/dist/terminal/generated/terminal-wire-v1.d.ts.map +1 -0
  539. package/dist/terminal/generated/terminal-wire-v1.js +27 -0
  540. package/dist/terminal/generated/terminal-wire-v1.js.map +1 -0
  541. package/dist/terminal/mode.d.ts +33 -0
  542. package/dist/terminal/mode.d.ts.map +1 -0
  543. package/dist/terminal/mode.js +99 -0
  544. package/dist/terminal/mode.js.map +1 -0
  545. package/dist/terminal/passthrough.d.ts +47 -0
  546. package/dist/terminal/passthrough.d.ts.map +1 -0
  547. package/dist/terminal/passthrough.js +666 -0
  548. package/dist/terminal/passthrough.js.map +1 -0
  549. package/dist/terminal/resume.d.ts +58 -0
  550. package/dist/terminal/resume.d.ts.map +1 -0
  551. package/dist/terminal/resume.js +185 -0
  552. package/dist/terminal/resume.js.map +1 -0
  553. package/dist/terminal/viewport.d.ts +93 -0
  554. package/dist/terminal/viewport.d.ts.map +1 -0
  555. package/dist/terminal/viewport.js +266 -0
  556. package/dist/terminal/viewport.js.map +1 -0
  557. package/dist/terminal/workbench.d.ts +32 -0
  558. package/dist/terminal/workbench.d.ts.map +1 -0
  559. package/dist/terminal/workbench.js +316 -0
  560. package/dist/terminal/workbench.js.map +1 -0
  561. package/dist/terminal/xterm-vte.d.ts +49 -0
  562. package/dist/terminal/xterm-vte.d.ts.map +1 -0
  563. package/dist/terminal/xterm-vte.js +602 -0
  564. package/dist/terminal/xterm-vte.js.map +1 -0
  565. package/dist/version.d.ts +3 -0
  566. package/dist/version.d.ts.map +1 -0
  567. package/dist/version.js +3 -0
  568. package/dist/version.js.map +1 -0
  569. package/dist/workspace/binding-path.d.ts +17 -0
  570. package/dist/workspace/binding-path.d.ts.map +1 -0
  571. package/dist/workspace/binding-path.js +91 -0
  572. package/dist/workspace/binding-path.js.map +1 -0
  573. package/dist/workspace/binding-store.d.ts +107 -0
  574. package/dist/workspace/binding-store.d.ts.map +1 -0
  575. package/dist/workspace/binding-store.js +783 -0
  576. package/dist/workspace/binding-store.js.map +1 -0
  577. package/dist/workspace/binding.d.ts +35 -0
  578. package/dist/workspace/binding.d.ts.map +1 -0
  579. package/dist/workspace/binding.js +70 -0
  580. package/dist/workspace/binding.js.map +1 -0
  581. package/dist/workspace/errors.d.ts +4 -0
  582. package/dist/workspace/errors.d.ts.map +1 -0
  583. package/dist/workspace/errors.js +19 -0
  584. package/dist/workspace/errors.js.map +1 -0
  585. package/dist/workspace/exclusion.d.ts +21 -0
  586. package/dist/workspace/exclusion.d.ts.map +1 -0
  587. package/dist/workspace/exclusion.js +243 -0
  588. package/dist/workspace/exclusion.js.map +1 -0
  589. package/dist/workspace/index.d.ts +8 -0
  590. package/dist/workspace/index.d.ts.map +1 -0
  591. package/dist/workspace/index.js +8 -0
  592. package/dist/workspace/index.js.map +1 -0
  593. package/dist/workspace/lifecycle.d.ts +56 -0
  594. package/dist/workspace/lifecycle.d.ts.map +1 -0
  595. package/dist/workspace/lifecycle.js +94 -0
  596. package/dist/workspace/lifecycle.js.map +1 -0
  597. package/dist/workspace/manifest.d.ts +47 -0
  598. package/dist/workspace/manifest.d.ts.map +1 -0
  599. package/dist/workspace/manifest.js +243 -0
  600. package/dist/workspace/manifest.js.map +1 -0
  601. package/dist/workspace/paths.d.ts +14 -0
  602. package/dist/workspace/paths.d.ts.map +1 -0
  603. package/dist/workspace/paths.js +67 -0
  604. package/dist/workspace/paths.js.map +1 -0
  605. package/dist/workspace/schema.d.ts +15 -0
  606. package/dist/workspace/schema.d.ts.map +1 -0
  607. package/dist/workspace/schema.js +33 -0
  608. package/dist/workspace/schema.js.map +1 -0
  609. package/dist/workspace/selection-screen.d.ts +4 -0
  610. package/dist/workspace/selection-screen.d.ts.map +1 -0
  611. package/dist/workspace/selection-screen.js +216 -0
  612. package/dist/workspace/selection-screen.js.map +1 -0
  613. package/dist/workspace/selection-service.d.ts +16 -0
  614. package/dist/workspace/selection-service.d.ts.map +1 -0
  615. package/dist/workspace/selection-service.js +65 -0
  616. package/dist/workspace/selection-service.js.map +1 -0
  617. package/node_modules/@xterm/headless/README.md +31 -0
  618. package/node_modules/@xterm/headless/lib-headless/xterm-headless.js +2 -0
  619. package/node_modules/@xterm/headless/lib-headless/xterm-headless.js.map +1 -0
  620. package/node_modules/@xterm/headless/lib-headless/xterm-headless.mjs +46 -0
  621. package/node_modules/@xterm/headless/lib-headless/xterm-headless.mjs.map +7 -0
  622. package/node_modules/@xterm/headless/package.json +29 -0
  623. package/node_modules/@xterm/headless/typings/xterm-headless.d.ts +1385 -0
  624. package/package.json +75 -0
@@ -0,0 +1,513 @@
1
+ import { createHash } from "node:crypto";
2
+ import { lstat, unlink } from "node:fs/promises";
3
+ import { join } from "node:path";
4
+ import { CunaError } from "../core/errors.js";
5
+ import { isObservationBudgetCode } from "../core/observation-budget.js";
6
+ import { assertCanonicalUuid, assertMachineId } from "../core/validation.js";
7
+ /* -------------------------------------------------------------------------- */
8
+ /* What the producer's refusals mean for the Machine */
9
+ /* -------------------------------------------------------------------------- */
10
+ /**
11
+ * Refusals ordered strictly BEFORE the producer admits a durable operation.
12
+ *
13
+ * The grouping is the producer's ordering, read at
14
+ * `7cb7e37ec8f0821fc6b402be5fcc9bc8e9439d55`, not a guess: `updateLiveSupervisor`
15
+ * parses, reads the owned Machine, checks `status === "running"`, checks the
16
+ * runtime and resolves the tenant, and only THEN calls `claimOperation` — under
17
+ * the comment "the durable identity, before any observation of the Machine …
18
+ * an ABSENT record is itself evidence". Every code below can only be reached
19
+ * above that line, so no operation exists under the identity this CLI sent and
20
+ * the local record that holds it has nothing left to protect.
21
+ *
22
+ * `supervisor_live_update_unverifiable`, `..._control_unavailable`,
23
+ * `..._preconditions_unmet` and `..._not_required` are deliberately NOT here.
24
+ * The producer raises each of them from BOTH sides of the claim, and the wire
25
+ * carries no field that says which. Whether they settled the record is then the
26
+ * record's own question, and `machines live-update-status` is what asks it.
27
+ */
28
+ const NOT_ADMITTED_REASONS = new Set([
29
+ // 422: the request never named a Machine, or never named an operation.
30
+ "invalid_supervisor_upgrade_request",
31
+ // 409, both raised above the claim.
32
+ "supervisor_live_update_machine_not_running",
33
+ "supervisor_live_update_runtime_unavailable",
34
+ ]);
35
+ /**
36
+ * 404, and the one reason whose meaning depends on WHOSE identity was sent.
37
+ *
38
+ * The producer answers `resource_not_found` for an absent Machine, a Machine
39
+ * this principal does not own, AND an operation row that its owner-scoped query
40
+ * cannot see. Those are one answer by design — it refuses to tell a caller which
41
+ * of them is true — so the client cannot read it without saying what it asked
42
+ * with.
43
+ *
44
+ * With an identity this process MINTED microseconds ago, no operation can exist
45
+ * under it, so the answer is about the Machine and nothing was admitted.
46
+ *
47
+ * With an identity read from this computer's record, it is not. The signed-in
48
+ * principal may simply have changed since the record was written: the record is
49
+ * keyed by API origin and Machine, deliberately, so that switching profiles
50
+ * cannot clear it — and the same property means the account asking may not be
51
+ * the account that filed it. Treating that 404 as "this operation never
52
+ * existed" would discard the one handle that could still resolve it, on the say
53
+ * so of an answer that means "you cannot see it".
54
+ */
55
+ const NOT_FOUND_REASON = "resource_not_found";
56
+ /** The update landed, was acknowledged, and named AgentSessions that did not survive. */
57
+ const SESSIONS_ENDED_REASON = "supervisor_live_update_sessions_ended";
58
+ /**
59
+ * The producer's single word for "this operation has not resolved".
60
+ *
61
+ * Its meaning INVERTED at the producer commit this CLI is pinned to, and the
62
+ * inversion is the whole point of the durable identity. Every detail carrying
63
+ * this code used to end "do not repeat the update"; every one of them now ends
64
+ * "Repeat this same update request; do not start a new one." Repetition is safe
65
+ * because the identity is the producer's journal key — the same value resumes an
66
+ * attempt that spent nothing and reconciles one that may have spent something.
67
+ *
68
+ * It is still not a TRANSPORT retry. `api/client.ts` keeps `automaticRedispatch`
69
+ * off for this mutation so the only repetition is one a person chose.
70
+ */
71
+ const PENDING_REASON = "supervisor_live_update_pending";
72
+ /**
73
+ * Another operation holds this Machine, or this identity meant something else.
74
+ *
75
+ * One code covers five producer conditions, two of which ("this update has
76
+ * already changed this Machine's control", "this Machine is no longer the one
77
+ * this update measured") mean the identity we sent DID rotate control. The wire
78
+ * does not separate them, so this build does not either: it keeps the record and
79
+ * reads the operation.
80
+ */
81
+ const OPERATION_CONFLICT_REASON = "supervisor_live_update_operation_conflict";
82
+ /** Terminal, control rotated, nothing installed: the Machine was busy launching. */
83
+ const IN_PROGRESS_REASON = "supervisor_live_update_in_progress";
84
+ /**
85
+ * Dispositions for which the local record must survive.
86
+ *
87
+ * With a durable server-side operation the record stopped being a local
88
+ * suppression and became the only place the identity of a possibly-open
89
+ * operation lives. Dropping it strands the Machine twice over: the owner cannot
90
+ * resume the identity, and the producer refuses every DIFFERENT identity until
91
+ * that operation settles. So the record is kept unless an authoritative read
92
+ * says the operation settled, or the refusal proves it was never admitted.
93
+ */
94
+ /**
95
+ * Answers the producer only reaches through `settled(...)`, which writes the
96
+ * terminal record before it throws. Reaching one is itself proof that the
97
+ * operation is closed, whichever identity asked.
98
+ */
99
+ const SETTLED_DISPOSITIONS = new Set([
100
+ "applied_with_ended_sessions",
101
+ "settled_control_rotated",
102
+ ]);
103
+ /**
104
+ * Whether the local record must survive this refusal.
105
+ *
106
+ * Two ways out, and the asymmetry between them is what a reviewer drove out. A
107
+ * refusal that proves nothing was ADMITTED only proves it for an identity this
108
+ * process MINTED: the same refusal reached with a RECORDED identity may be
109
+ * about an operation that exists and is merely out of this account's view — the
110
+ * record is keyed by API origin and Machine so that switching profiles cannot
111
+ * clear it, and the price of that is that the account asking need not be the
112
+ * account that filed it. A record dropped there leaves a Machine nobody can
113
+ * resume and nobody can start afresh.
114
+ */
115
+ export function liveSupervisorUpdateRecordSurvives(disposition, origin = "recorded_identity") {
116
+ if (SETTLED_DISPOSITIONS.has(disposition))
117
+ return false;
118
+ // `not_admitted_machine_busy` is only ever produced for a minted identity, so
119
+ // the origin conjunct is stated once and both of them share it.
120
+ return !(origin === "new_identity" &&
121
+ (disposition === "not_admitted" || disposition === "not_admitted_machine_busy"));
122
+ }
123
+ /** Whether re-sending the SAME operation identity is the producer's own next step. */
124
+ export function liveSupervisorUpdateMayResume(disposition) {
125
+ return disposition === "resumable" || disposition === "unknown";
126
+ }
127
+ function reasonOf(error) {
128
+ if (!(error instanceof CunaError))
129
+ return undefined;
130
+ const reason = error.details?.["reason"];
131
+ return typeof reason === "string" ? reason : undefined;
132
+ }
133
+ /**
134
+ * Classify a failed dispatch of the in-place update.
135
+ *
136
+ * Fails CLOSED on purpose: an error this build cannot name is `unknown`, because
137
+ * the alternative is telling a caller nothing happened to a Machine whose
138
+ * supervisor may already have been replaced — and, now, discarding the one
139
+ * identity that could still resolve it.
140
+ */
141
+ export function classifyLiveSupervisorUpdateFailure(error,
142
+ /**
143
+ * What was sent. Defaulted to the conservative reading, so a caller that
144
+ * forgets to say cannot accidentally get the one answer that discards a
145
+ * record.
146
+ */
147
+ origin = "recorded_identity") {
148
+ const reason = reasonOf(error);
149
+ if (reason === NOT_FOUND_REASON) {
150
+ return origin === "new_identity" ? "not_admitted" : "operation_inaccessible";
151
+ }
152
+ if (reason !== undefined && NOT_ADMITTED_REASONS.has(reason))
153
+ return "not_admitted";
154
+ if (reason === SESSIONS_ENDED_REASON)
155
+ return "applied_with_ended_sessions";
156
+ if (reason === IN_PROGRESS_REASON)
157
+ return "settled_control_rotated";
158
+ if (reason === PENDING_REASON)
159
+ return "resumable";
160
+ if (reason === OPERATION_CONFLICT_REASON) {
161
+ /* One code, five producer conditions, and which are reachable depends on
162
+ what was sent. With an identity this process minted moments ago, only
163
+ `machine_busy` is: `claim_supervisor_live_update_operation` at 7cb
164
+ (migration 0193) looks the offered id up first, and when it is absent and
165
+ another unsettled operation holds the Machine it returns `machine_busy`
166
+ BEFORE its insert. No row exists for the id that was sent, so nothing was
167
+ admitted under it. The other four all require that id to exist already.
168
+ Treating this as `operation_conflict` for a fresh identity kept a record
169
+ naming an operation the producer had never heard of: no repeat, no new
170
+ update, and a read that could only ever answer not-found. The dispatch
171
+ path still confirms non-admission with that read before it acts. */
172
+ return origin === "new_identity" ? "not_admitted_machine_busy" : "operation_conflict";
173
+ }
174
+ if (error instanceof CunaError) {
175
+ // The CLI stopped waiting for its own response. The request is still in
176
+ // flight as far as this process knows.
177
+ if (isObservationBudgetCode(error.code))
178
+ return "unknown";
179
+ // Refusals this CLI raised itself, before anything left the process.
180
+ if (error.code === "cuna.usage.invalid" ||
181
+ error.code === "cuna.confirmation.required" ||
182
+ error.code.startsWith("cuna.capability."))
183
+ return "not_admitted";
184
+ // A credential the server refused outright never reached the operation.
185
+ if (error.code === "cuna.auth.rejected" || error.code === "cuna.policy.denied")
186
+ return "not_admitted";
187
+ }
188
+ return "unknown";
189
+ }
190
+ export function summarizeLiveSupervisorUpdate(result) {
191
+ const count = (outcome) => result.sessions.filter((session) => session.outcome === outcome).length;
192
+ const preserved = count("preserved");
193
+ const unknown = count("unknown");
194
+ return Object.freeze({
195
+ total: result.sessions.length,
196
+ preserved,
197
+ exited: count("exited"),
198
+ ended: count("ended"),
199
+ unknown,
200
+ // An empty Machine has nothing to preserve, and saying "all preserved" of
201
+ // zero sessions would read as a custody claim nobody made.
202
+ allPreserved: result.sessions.length > 0 && preserved === result.sessions.length,
203
+ anyUnknown: unknown > 0,
204
+ });
205
+ }
206
+ /**
207
+ * The human sentence for one session outcome.
208
+ *
209
+ * `ended` and `unknown` are deliberately not softened. A 200 that carries either
210
+ * is a producer this build does not expect — its operation raises instead — and
211
+ * the honest reading of that response is still the outcome it states.
212
+ */
213
+ export function liveSupervisorSessionOutcomeLabel(outcome) {
214
+ switch (outcome) {
215
+ case "preserved": return "preserved (same process, PTY and stored master)";
216
+ case "exited": return "exited on its own during the update";
217
+ case "ended": return "did not survive the update";
218
+ case "unknown": return "unknown: Cuna could not re-read it";
219
+ }
220
+ }
221
+ /* -------------------------------------------------------------------------- */
222
+ /* Reading one operation */
223
+ /* -------------------------------------------------------------------------- */
224
+ /**
225
+ * The producer's four phases in the one sentence each owner needs.
226
+ *
227
+ * None of them says "running", and that is deliberate. The producer's own note
228
+ * on this route is that a running Machine is not evidence that an update did or
229
+ * did not apply, and that this read is the only thing that is.
230
+ */
231
+ export function liveSupervisorUpdatePhaseLabel(phase) {
232
+ switch (phase) {
233
+ case "claimed":
234
+ return "claimed: recorded, and no enrollment, installer or control change has left Cuna";
235
+ case "control_rotated":
236
+ return "control rotated: this Machine's supervisor control HAS changed for this update, and what the installer did is unknown";
237
+ case "installed":
238
+ return "installed: the selected artifact is on the Machine; its acknowledgement and the fate of the AgentSessions may still be unestablished";
239
+ case "settled":
240
+ return "settled: terminal, and this recorded answer is what every repeat of this identity receives";
241
+ }
242
+ }
243
+ /**
244
+ * What Cuna OBSERVED of the installer, qualified by whether that installer can
245
+ * still act.
246
+ *
247
+ * `unknown` is the reason this takes a second argument. On its own the word
248
+ * covers two states a person has to tell apart: a request was sent and nobody
249
+ * found out, and an authorized installer may still wake up and write; or the
250
+ * same, plus a fence the Machine has since raised so that it never can. The
251
+ * producer publishes the difference and this sentence carries it.
252
+ *
253
+ * The fence never changes the outcome itself. `unknown` retired is still
254
+ * `unknown` — Cuna did not observe an installation and does not claim one — and
255
+ * `installed` is Cuna's own observation, which no retirement record replaces.
256
+ */
257
+ export function liveSupervisorInstallerOutcomeLabel(outcome, reach = "may_still_arrive") {
258
+ switch (outcome) {
259
+ case "not_sent":
260
+ return "not sent: no installer request left Cuna";
261
+ case "unknown":
262
+ return reach === "may_still_arrive"
263
+ ? "unknown: a request was sent, nothing observed what it did, and an installer it authorized may still arrive"
264
+ : "unknown: a request was sent and nothing observed what it did. Cuna has since retired that installer on the Machine, so it can no longer act";
265
+ case "refused":
266
+ return "refused: the installer answered and refused, which it does before it writes";
267
+ case "installed":
268
+ return "installed: the selected artifact is on the Machine";
269
+ }
270
+ }
271
+ /**
272
+ * What `installed_at` is a timestamp OF, which is not the same question twice.
273
+ *
274
+ * `installer_exit` is the installer's own zero exit inside this operation's
275
+ * request, so the time is the installation's. `reconciled` is a later read-only
276
+ * observation that found the artifact there: it establishes THAT it is
277
+ * installed and never WHEN, so the timestamp is when Cuna looked.
278
+ */
279
+ export function liveSupervisorInstallationEvidenceLabel(evidence) {
280
+ return evidence === "installer_exit"
281
+ ? "installer_exit: the installer's own zero exit, observed in this operation's own request"
282
+ : "reconciled: a later read-only observation found the artifact on the Machine, which establishes that it is installed and never when";
283
+ }
284
+ /** The fence reading, from the two fields the producer keeps paired. */
285
+ function installerReachOf(operation) {
286
+ if (operation.retiredAt === undefined)
287
+ return "may_still_arrive";
288
+ if (operation.retirementOutcome === "retired")
289
+ return "retired_without_admission";
290
+ if (operation.retirementOutcome === "installed")
291
+ return "retired_after_completion";
292
+ // `partial`, and the shape the decoder already refuses -- a retirement time
293
+ // with no outcome beside it. Falling through to `partial` is the safe
294
+ // direction for both: it is the only reading that asserts nothing about what
295
+ // the installer did or did not write, and it names an action. Falling through
296
+ // to `retired` would be the dangerous one, because that reading TELLS a person
297
+ // nothing on the Machine was changed.
298
+ return "retired_after_partial_write";
299
+ }
300
+ export function readLiveSupervisorUpdateOperation(operation) {
301
+ const declared = operation.declaredSessions.length;
302
+ const accounted = operation.sessions.length;
303
+ const installerReach = installerReachOf(operation);
304
+ return Object.freeze({
305
+ settled: operation.phase === "settled",
306
+ mayRepeatSameOperation: operation.nextAction === "repeat_same_operation",
307
+ controlRotated: operation.controlRotated,
308
+ declared,
309
+ accounted,
310
+ accountWithheld: declared > 0 && accounted === 0,
311
+ installerReach,
312
+ installerCanStillAct: installerReach === "may_still_arrive",
313
+ installerWroteNothing: installerReach === "retired_without_admission",
314
+ });
315
+ }
316
+ /**
317
+ * What the fence says, and what a person may do next because of it.
318
+ *
319
+ * Two sentences, and the second is an ACTION only where the producer supports
320
+ * one. The producer names it in its own refusals, which reach only a client
321
+ * that was live at the moment they were recorded; a client recovering later
322
+ * sees these fields and nothing else, so the sentence is derived from them here
323
+ * rather than left to a reader to reconstruct.
324
+ *
325
+ * What none of these may do: turn `unknown` into a success, or read a fence
326
+ * record of a completed installer as Cuna having observed an installation.
327
+ */
328
+ export function liveSupervisorInstallerReachLines(reading, machineId) {
329
+ const startNew = `Start a new in-place supervisor update: \`cuna machines live-update-supervisor ${machineId} --yes\`.`;
330
+ switch (reading.installerReach) {
331
+ case "may_still_arrive":
332
+ return [
333
+ "This update's installer has not been retired on the Machine, so one it authorized could still arrive and change this Machine, however long it has been.",
334
+ ];
335
+ case "retired_without_admission":
336
+ return [
337
+ "Cuna has retired this update's installer on the Machine itself: it reports that the installer never reached it, and it can no longer arrive. Nothing this installer would have written was written.",
338
+ `${startNew} This Machine's control generation has already moved, which is irreversible and is not undone by the retirement.`,
339
+ ];
340
+ case "retired_after_partial_write":
341
+ return [
342
+ "Cuna has retired this update's installer on the Machine, and the Machine reports that it had been admitted and did not finish: it began replacing the supervisor and stopped. Cuna cannot say which files it had already written, and cannot say what became of the AgentSessions.",
343
+ `${startNew} It re-measures this Machine and installs the whole release over what is there. Inspect the AgentSessions first if they matter.`,
344
+ ];
345
+ case "retired_after_completion":
346
+ return [
347
+ "Cuna has retired this update's installer on the Machine, and the Machine's own fence records that it had been admitted and finished. That is the FENCE's record, not an observation by Cuna: the installer outcome above is the only thing that says what Cuna saw.",
348
+ "Inspect this Machine's supervisor and its AgentSessions before starting anything else.",
349
+ ];
350
+ }
351
+ }
352
+ const CANONICAL_UUID = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/u;
353
+ const MAXIMUM_BYTES = 2048;
354
+ const NOTE_KEYS = "dispatchedAt,machineId,operationId,scope,version";
355
+ const NOTE_KEYS_WITH_ACCOUNT = "account,dispatchedAt,machineId,operationId,scope,version";
356
+ const DIRECTORY = "supervisor-live-updates";
357
+ /**
358
+ * One short, printable sentence about why a record could not be read.
359
+ *
360
+ * It reaches a terminal and a `--json` record, so it is bounded and carries no
361
+ * bytes from the record itself — only the reason the reader gave.
362
+ */
363
+ function boundedReason(error) {
364
+ const message = error instanceof Error && typeof error.message === "string"
365
+ ? error.message
366
+ : "the record could not be read";
367
+ const flattened = message.replaceAll(/\s+/gu, " ").trim();
368
+ return flattened.length <= 160 ? flattened : `${flattened.slice(0, 159)}…`;
369
+ }
370
+ function scopeDigest(scope) {
371
+ const url = new URL(scope.baseUrl);
372
+ if (url.username || url.password || !["https:", "http:"].includes(url.protocol)) {
373
+ throw new Error("Invalid live supervisor update scope.");
374
+ }
375
+ // `url.origin`, not `url.href`: the path, query and fragment of whichever
376
+ // base URL a profile happens to carry must not fork the exclusion.
377
+ return createHash("sha256")
378
+ .update(JSON.stringify(["supervisor-live-update", url.origin]))
379
+ .digest("hex");
380
+ }
381
+ export function liveSupervisorUpdateNotes(platform, scope) {
382
+ const digest = scopeDigest(scope);
383
+ const file = (machineId) => join(platform.paths.stateDirectory, DIRECTORY, digest, `${assertMachineId(machineId)}.json`);
384
+ // An adapter without the exclusive primitive cannot fence this mutation, and
385
+ // silently falling back to read-then-write is exactly the defect. Refuse to
386
+ // build the store at all rather than build one that cannot keep its promise.
387
+ if (typeof platform.createExclusiveConfig !== "function") {
388
+ throw new Error("This host cannot reserve a supervisor update exclusively. Nothing was sent.");
389
+ }
390
+ const notes = {
391
+ async reserve(machineId, operationId, dispatchedAt, account) {
392
+ if (!Number.isFinite(Date.parse(dispatchedAt)))
393
+ throw new Error("Invalid dispatch timestamp.");
394
+ const value = Object.freeze({
395
+ version: 2, scope: digest, machineId: assertMachineId(machineId),
396
+ operationId: assertCanonicalUuid(operationId, "supervisor update operation ID"),
397
+ dispatchedAt,
398
+ // Recorded only when the caller already held it. Nothing is fetched to
399
+ // populate a label, and nothing reads it back to decide.
400
+ ...(account === undefined ? {} : { account: assertCanonicalUuid(account, "account ID") }),
401
+ });
402
+ const path = file(machineId);
403
+ const text = `${JSON.stringify(value)}\n`;
404
+ // THE fence. One `open(O_CREAT|O_EXCL)` on the target, resolved by the
405
+ // kernel, so two processes interleaved in any order produce one winner.
406
+ // There is no read before it: a read that finds the slot free proves
407
+ // nothing about the instant of the write.
408
+ const created = await platform.createExclusiveConfig(path, text, MAXIMUM_BYTES);
409
+ if (!created)
410
+ return undefined;
411
+ // Kept from the original: the slot is ours, and these are the bytes that
412
+ // have to be in it. A file we created but cannot read back is a record
413
+ // this computer does not really hold.
414
+ const saved = await platform.readSafeConfig(path, MAXIMUM_BYTES);
415
+ if (!saved.exists || saved.text !== text) {
416
+ /* The message said "Nothing was sent" and left the file behind, so the
417
+ next invocation found a readable record naming an operation that had
418
+ never reached the producer — unresumable, and unclearable for as long
419
+ as the read of it answered not-found.
420
+ Withdrawn through `settle`, which is bound to THIS identity: if the
421
+ bytes now belong to another writer, `settle` answers `superseded` and
422
+ leaves them alone. A blind `discard` here would delete a concurrent
423
+ process's live reservation, which is the same class of defect one
424
+ layer down. Either way the refusal below is still raised. */
425
+ try {
426
+ await notes.settle(machineId, value.operationId);
427
+ }
428
+ catch { /* the throw below is the answer */ }
429
+ throw new Error("The supervisor update record could not be verified. Nothing was sent.");
430
+ }
431
+ return value;
432
+ },
433
+ async settle(machineId, operationId) {
434
+ const current = await notes.read(machineId);
435
+ if (current.state === "none")
436
+ return "absent";
437
+ // Unreadable bytes are not this dispatch's record. Removing them here
438
+ // would let a completion silently clear a state only an authoritative
439
+ // read may resolve.
440
+ if (current.state === "unreadable")
441
+ return "superseded";
442
+ if (current.note.operationId !== operationId)
443
+ return "superseded";
444
+ return (await notes.discard(machineId)) ? "settled" : "absent";
445
+ },
446
+ async discard(machineId) {
447
+ const path = file(machineId);
448
+ try {
449
+ const metadata = await lstat(path);
450
+ if (metadata.isSymbolicLink() || !metadata.isFile()) {
451
+ throw new Error("Unsafe supervisor update record.");
452
+ }
453
+ await unlink(path);
454
+ return true;
455
+ }
456
+ catch (error) {
457
+ if (error.code === "ENOENT")
458
+ return false;
459
+ throw error;
460
+ }
461
+ },
462
+ async read(machineId) {
463
+ const path = file(machineId);
464
+ // Every failure below answers `unreadable` instead of throwing, including
465
+ // a refusal from `readSafeConfig` itself: the acknowledgement path must
466
+ // stay reachable for a record whose bytes or permissions are wrong, and
467
+ // `discard` unlinks without needing to read.
468
+ const unreadable = (reason) => Object.freeze({ state: "unreadable", path, reason });
469
+ let snapshot;
470
+ try {
471
+ snapshot = await platform.readSafeConfig(path, MAXIMUM_BYTES);
472
+ }
473
+ catch (error) {
474
+ return unreadable(boundedReason(error));
475
+ }
476
+ if (!snapshot.exists)
477
+ return Object.freeze({ state: "none" });
478
+ let value;
479
+ try {
480
+ value = JSON.parse(snapshot.text ?? "");
481
+ }
482
+ catch {
483
+ return unreadable("the record is not JSON");
484
+ }
485
+ if (typeof value !== "object" || value === null || Array.isArray(value)) {
486
+ return unreadable("the record is not an object");
487
+ }
488
+ const row = value;
489
+ const dispatchedAt = row.dispatchedAt;
490
+ const operationId = row.operationId;
491
+ const account = row.account;
492
+ const keys = Object.keys(row).sort().join(",");
493
+ if ((keys !== NOTE_KEYS && keys !== NOTE_KEYS_WITH_ACCOUNT) || row.version !== 2 ||
494
+ row.scope !== digest || row.machineId !== machineId ||
495
+ typeof operationId !== "string" || !CANONICAL_UUID.test(operationId) ||
496
+ typeof dispatchedAt !== "string" || !Number.isFinite(Date.parse(dispatchedAt)) ||
497
+ (keys === NOTE_KEYS_WITH_ACCOUNT && typeof account !== "string")) {
498
+ return unreadable("the record does not match the shape this build writes");
499
+ }
500
+ // The account is returned for display and nothing else. It is NOT compared
501
+ // against the caller: a note that named a different account and let the
502
+ // mutation through would be metadata granting access, and the whole point
503
+ // of this record is that it can only ever refuse.
504
+ const note = Object.freeze({
505
+ version: 2, scope: digest, machineId, operationId, dispatchedAt,
506
+ ...(typeof account === "string" ? { account } : {}),
507
+ });
508
+ return Object.freeze({ state: "outstanding", note });
509
+ },
510
+ };
511
+ return Object.freeze(notes);
512
+ }
513
+ //# sourceMappingURL=live-supervisor-update.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"live-supervisor-update.js","sourceRoot":"","sources":["../../src/machines/live-supervisor-update.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AACjD,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAUjC,OAAO,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAC9C,OAAO,EAAE,uBAAuB,EAAE,MAAM,+BAA+B,CAAC;AACxE,OAAO,EAAE,m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E,SAAS,EAAE,WAAW,EAAE,YAAY;gBAC/D,GAAG,CAAC,OAAO,OAAO,KAAK,QAAQ,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;aACpD,CAAC,CAAC;YACH,OAAO,MAAM,CAAC,MAAM,CAAC,EAAE,KAAK,EAAE,aAAsB,EAAE,IAAI,EAAE,CAAC,CAAC;QAChE,CAAC;KACF,CAAC;IACF,OAAO,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;AAC9B,CAAC"}
@@ -0,0 +1,123 @@
1
+ import type { AgentSession, Machine } from "../api/contracts.js";
2
+ import { type ActionableProvider } from "./provider-availability.js";
3
+ export type MachineFirstScreen = Readonly<{
4
+ readonly kind: "machines";
5
+ }> | Readonly<{
6
+ readonly kind: "machine";
7
+ readonly machineId: string;
8
+ }> | Readonly<{
9
+ readonly kind: "provider";
10
+ readonly machineId: string;
11
+ readonly provider: ActionableProvider;
12
+ }>
13
+ /** PRD-PM-008 E13-R1: provider step of `n New machine`, reachable from any overview. */
14
+ | Readonly<{
15
+ readonly kind: "new-machine";
16
+ }>
17
+ /** Name step; the default is computed by the caller from the current inventory. */
18
+ | Readonly<{
19
+ readonly kind: "new-machine-name";
20
+ readonly provider: ActionableProvider;
21
+ }>;
22
+ export interface MachineFirstNavigationState {
23
+ readonly screen: MachineFirstScreen;
24
+ readonly selectedIndex: number;
25
+ readonly quit: boolean;
26
+ }
27
+ export type MachineFirstNavigationEvent = Readonly<{
28
+ readonly type: "move";
29
+ readonly delta: -1 | 1;
30
+ readonly itemCount: number;
31
+ }> | Readonly<{
32
+ readonly type: "open-machine";
33
+ readonly machineId: string;
34
+ }> | Readonly<{
35
+ readonly type: "open-provider";
36
+ readonly machineId: string;
37
+ readonly provider: ActionableProvider;
38
+ }> | Readonly<{
39
+ readonly type: "open-new-machine";
40
+ }> | Readonly<{
41
+ readonly type: "choose-new-machine-provider";
42
+ readonly provider: ActionableProvider;
43
+ }> | Readonly<{
44
+ readonly type: "back";
45
+ }> | Readonly<{
46
+ readonly type: "quit";
47
+ }>;
48
+ export type MachineContextAction = Readonly<{
49
+ readonly kind: "recover";
50
+ readonly label: "Recover creation";
51
+ readonly machineId: string;
52
+ }> | Readonly<{
53
+ readonly kind: "start";
54
+ readonly label: "Start";
55
+ readonly machineId: string;
56
+ }> | Readonly<{
57
+ readonly kind: "stop";
58
+ readonly label: "Stop";
59
+ readonly machineId: string;
60
+ }>
61
+ /**
62
+ * PRD-PM-008 E13-R2: offered in every state, including `error`, because a
63
+ * Machine the console can delete must be deletable here. The screen owns
64
+ * the double confirmation; this list only says the action exists.
65
+ */
66
+ | Readonly<{
67
+ readonly kind: "delete";
68
+ readonly label: "Delete";
69
+ readonly machineId: string;
70
+ }>
71
+ /**
72
+ * An informational, non-mutating first action. It exists so a running
73
+ * OpenCode Machine with a supervisor prerequisite does not make `Stop` the
74
+ * default Enter target in the machine menu.
75
+ */
76
+ | Readonly<{
77
+ readonly kind: "supervisor-blocked";
78
+ readonly label: "OpenCode needs a terminal update";
79
+ readonly machineId: string;
80
+ }>
81
+ /** Available only after the current Machine observation is stopped. */
82
+ | Readonly<{
83
+ readonly kind: "update-supervisor";
84
+ readonly label: "Update terminal supervisor";
85
+ readonly machineId: string;
86
+ }> | Readonly<{
87
+ readonly kind: "provider";
88
+ readonly label: string;
89
+ readonly machineId: string;
90
+ readonly provider: ActionableProvider;
91
+ }> | Readonly<{
92
+ readonly kind: "new-session";
93
+ readonly label: string;
94
+ readonly machineId: string;
95
+ readonly provider: ActionableProvider;
96
+ }>;
97
+ export type ProviderContextAction = Readonly<{
98
+ readonly kind: "session";
99
+ readonly label: string;
100
+ readonly session: AgentSession;
101
+ }>;
102
+ export declare const INITIAL_MACHINE_FIRST_STATE: MachineFirstNavigationState;
103
+ export declare function reduceMachineFirstNavigation(state: MachineFirstNavigationState, event: MachineFirstNavigationEvent): MachineFirstNavigationState;
104
+ export declare function resolveMachineContextActions(machine: Machine, options?: Readonly<{
105
+ readonly hasSessions?: boolean;
106
+ readonly canCreateSession?: boolean;
107
+ /** Exact, current server evidence—not a local provider guess. */
108
+ readonly opencodeSupervisorRepairRequired?: boolean;
109
+ }>): readonly MachineContextAction[];
110
+ export declare function resolveProviderContextActions(input: Readonly<{
111
+ readonly machine: Machine;
112
+ readonly provider: ActionableProvider;
113
+ readonly sessions: readonly AgentSession[];
114
+ readonly now: number;
115
+ }>): readonly ProviderContextAction[];
116
+ export declare function shouldShowRemoteWaitProgress(elapsedMs: number): boolean;
117
+ export declare function canAutoContinueMachineFirst(input: Readonly<{
118
+ readonly safeContinuationCount: number;
119
+ readonly screenShownAt: number;
120
+ readonly now: number;
121
+ readonly cancelled: boolean;
122
+ }>): boolean;
123
+ //# sourceMappingURL=machine-first.d.ts.map