@north-light/cli 0.3.561 → 0.3.563

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 (579) hide show
  1. package/dist/api/client.d.ts +27 -4
  2. package/dist/api/client.js +3 -3
  3. package/dist/api/contract.d.ts +1 -1
  4. package/dist/api/contract.js +1 -1
  5. package/dist/api/dto/bash-jobs.d.ts +5 -1
  6. package/dist/api/dto/broker-ops.d.ts +25 -1
  7. package/dist/api/dto/charges.d.ts +9 -2
  8. package/dist/api/dto/delivery.d.ts +26 -2
  9. package/dist/api/dto/execution-start.d.ts +57 -0
  10. package/dist/api/dto/execution-start.js +0 -0
  11. package/dist/api/dto/modelauth.d.ts +5 -0
  12. package/dist/api/dto/node-records.d.ts +16 -0
  13. package/dist/api/dto/objects.d.ts +1 -1
  14. package/dist/api/dto/reports.d.ts +0 -3
  15. package/dist/api/dto/run-events.d.ts +7 -1
  16. package/dist/api/dto/settings.d.ts +55 -0
  17. package/dist/api/dto/settings.js +0 -0
  18. package/dist/api/index.d.ts +2 -0
  19. package/dist/api/index.js +1 -1
  20. package/dist/api/routes.d.ts +11 -0
  21. package/dist/api/routes.js +1 -1
  22. package/dist/build-root.d.ts +1 -0
  23. package/dist/build-root.js +1 -1
  24. package/dist/builtin-memory/crouter-sdk/release-notes.md +4 -0
  25. package/dist/cli.js +7 -7
  26. package/dist/clients/attach/chrome/bash-jobs.d.ts +11 -1
  27. package/dist/clients/attach/chrome/bash-jobs.js +1 -1
  28. package/dist/clients/attach/chrome/canvas-panels.d.ts +1 -1
  29. package/dist/clients/attach/chrome/roster.js +6 -4
  30. package/dist/clients/attach/overlays/auth.js +2 -2
  31. package/dist/clients/attach/render/chat-view.js +1 -1
  32. package/dist/clients/attach/viewer.js +550 -567
  33. package/dist/commands/canvas-config.js +2 -2
  34. package/dist/commands/canvas-use.js +1 -1
  35. package/dist/commands/human.js +2 -2
  36. package/dist/commands/node/bash.js +3 -3
  37. package/dist/commands/node/create.js +2 -2
  38. package/dist/commands/person-settings.d.ts +1 -0
  39. package/dist/commands/person-settings.js +1 -0
  40. package/dist/commands/pkg/market-manage.d.ts +2 -2
  41. package/dist/commands/pkg/market-manage.js +1 -1
  42. package/dist/commands/pkg/plugin-manage.js +13 -13
  43. package/dist/commands/pkg/shared.js +1 -1
  44. package/dist/commands/profile/default.js +1 -1
  45. package/dist/commands/push.js +2 -3
  46. package/dist/commands/sys/config.js +1 -1
  47. package/dist/commands/sys/connect.js +1 -1
  48. package/dist/commands/sys/context/sysprompt.js +2 -2
  49. package/dist/commands/sys/doctor.js +1 -1
  50. package/dist/commands/sys/join.js +1 -1
  51. package/dist/commands/sys/panels/broker-limits-panel.js +1 -1
  52. package/dist/commands/sys/panels/keybindings-panel.js +1 -1
  53. package/dist/commands/sys/panels/models-panel.d.ts +8 -2
  54. package/dist/commands/sys/panels/models-panel.js +1 -1
  55. package/dist/commands/sys/panels/prefs-panel.d.ts +1 -0
  56. package/dist/commands/sys/panels/prefs-panel.js +1 -1
  57. package/dist/commands/sys/panels/profiles-panel.js +1 -1
  58. package/dist/commands/sys/panels/provider-panel.d.ts +4 -0
  59. package/dist/commands/sys/panels/provider-panel.js +1 -1
  60. package/dist/commands/sys/provider-login.js +5 -5
  61. package/dist/commands/sys/setup-core.js +3 -3
  62. package/dist/commands/sys/setup-settings-runner.js +1 -1
  63. package/dist/commands/sys/spend.js +3 -3
  64. package/dist/commands/sys/update.js +1 -1
  65. package/dist/core/auth-file.d.ts +11 -19
  66. package/dist/core/auth-file.js +1 -2
  67. package/dist/core/auto-update.d.ts +1 -1
  68. package/dist/core/auto-update.js +4 -4
  69. package/dist/core/bash-jobs.d.ts +29 -71
  70. package/dist/core/bash-jobs.js +9 -10
  71. package/dist/core/blobs/directory.d.ts +3 -0
  72. package/dist/core/blobs/directory.js +1 -0
  73. package/dist/core/blobs/fault.d.ts +3 -0
  74. package/dist/core/blobs/fault.js +1 -0
  75. package/dist/core/blobs/index.d.ts +21 -0
  76. package/dist/core/blobs/index.js +1 -0
  77. package/dist/core/blobs/r2.d.ts +9 -0
  78. package/dist/core/blobs/r2.js +4 -0
  79. package/dist/core/bootstrap.d.ts +1 -1
  80. package/dist/core/bootstrap.js +2 -2
  81. package/dist/core/canvas/canvas.d.ts +9 -7
  82. package/dist/core/canvas/canvas.js +8 -8
  83. package/dist/core/canvas/crons.d.ts +3 -2
  84. package/dist/core/canvas/crons.js +3 -3
  85. package/dist/core/canvas/daemon-owner.d.ts +5 -0
  86. package/dist/core/canvas/daemon-owner.js +1 -1
  87. package/dist/core/canvas/db.d.ts +10 -9
  88. package/dist/core/canvas/db.js +4 -4
  89. package/dist/core/canvas/executions.d.ts +100 -4
  90. package/dist/core/canvas/executions.js +1 -1
  91. package/dist/core/canvas/export-sqlite.js +1 -1
  92. package/dist/core/canvas/focuses.d.ts +4 -0
  93. package/dist/core/canvas/focuses.js +1 -1
  94. package/dist/core/canvas/history.js +9 -9
  95. package/dist/core/canvas/managed-worktree-sweep-candidates.d.ts +2 -1
  96. package/dist/core/canvas/managed-worktree-sweep-candidates.js +3 -2
  97. package/dist/core/canvas/node-tokens.d.ts +1 -4
  98. package/dist/core/canvas/node-tokens.js +3 -3
  99. package/dist/core/canvas/paths.d.ts +0 -1
  100. package/dist/core/canvas/paths.js +1 -1
  101. package/dist/core/canvas/person-state.d.ts +26 -0
  102. package/dist/core/canvas/person-state.js +1 -0
  103. package/dist/core/canvas/person.d.ts +3 -10
  104. package/dist/core/canvas/person.js +7 -7
  105. package/dist/core/canvas/reconciler-leases.d.ts +12 -0
  106. package/dist/core/canvas/reconciler-leases.js +8 -0
  107. package/dist/core/canvas/recovery.d.ts +4 -0
  108. package/dist/core/canvas/recovery.js +1 -1
  109. package/dist/core/canvas/schema-pg/003-fleet-removals.sql +1 -1
  110. package/dist/core/canvas/schema-pg/005-fleet-blobs.sql +13 -0
  111. package/dist/core/canvas/schema-pg/006-job-rows.sql +20 -0
  112. package/dist/core/canvas/schema-pg/007-ledger-check.sql +117 -0
  113. package/dist/core/canvas/schema-version.d.ts +1 -1
  114. package/dist/core/canvas/schema-version.js +1 -1
  115. package/dist/core/canvas/sessions.d.ts +8 -11
  116. package/dist/core/canvas/sessions.js +1 -4
  117. package/dist/core/canvas/tree.d.ts +4 -2
  118. package/dist/core/canvas/tree.js +6 -6
  119. package/dist/core/canvas/types.d.ts +7 -0
  120. package/dist/core/command-hooks/transport/exec-lifecycle.js +1 -1
  121. package/dist/core/command-plugins/bundle.d.ts +1 -1
  122. package/dist/core/command-plugins/bundle.js +1 -1
  123. package/dist/core/command-plugins/compose.d.ts +1 -1
  124. package/dist/core/command-plugins/discovery.d.ts +0 -1
  125. package/dist/core/command-plugins/discovery.js +1 -1
  126. package/dist/core/command-plugins/help-addenda.js +1 -1
  127. package/dist/core/command-plugins/presence.d.ts +2 -0
  128. package/dist/core/command-plugins/presence.js +1 -1
  129. package/dist/core/config.d.ts +16 -15
  130. package/dist/core/config.js +1 -1
  131. package/dist/core/conversation-store/client-worker.js +1 -1
  132. package/dist/core/conversation-store/client.js +2 -2
  133. package/dist/core/conversation-store/index.d.ts +9 -11
  134. package/dist/core/conversation-store/index.js +1 -1
  135. package/dist/core/conversation-store/patch.js +1 -1
  136. package/dist/core/conversation-store/row-store.d.ts +14 -0
  137. package/dist/core/conversation-store/row-store.js +13 -0
  138. package/dist/core/directory/join.d.ts +5 -3
  139. package/dist/core/directory/join.js +1 -1
  140. package/dist/core/env-name.d.ts +1 -0
  141. package/dist/core/env-name.js +1 -1
  142. package/dist/core/environment-recipe.d.ts +15 -0
  143. package/dist/core/environment-recipe.js +1 -0
  144. package/dist/core/environments.js +1 -1
  145. package/dist/core/events/emit.js +2 -2
  146. package/dist/core/events/run-event-chunks.d.ts +25 -0
  147. package/dist/core/events/run-event-chunks.js +5 -0
  148. package/dist/core/feed/messages.js +5 -5
  149. package/dist/core/grants/mirror.d.ts +15 -0
  150. package/dist/core/grants/mirror.js +15 -3
  151. package/dist/core/grants/on-sync.d.ts +9 -5
  152. package/dist/core/grants/on-sync.js +1 -1
  153. package/dist/core/grants/remove.d.ts +1 -6
  154. package/dist/core/grants/remove.js +1 -1
  155. package/dist/core/grants/sync.js +1 -1
  156. package/dist/core/grants/watch.d.ts +15 -9
  157. package/dist/core/grants/watch.js +1 -1
  158. package/dist/core/graph/custom.js +8 -8
  159. package/dist/core/graph/jobs.d.ts +83 -5
  160. package/dist/core/graph/jobs.js +11 -2
  161. package/dist/core/graph/kinds/job.js +2 -2
  162. package/dist/core/graph/names.js +7 -7
  163. package/dist/core/graph/objects.d.ts +5 -1
  164. package/dist/core/graph/objects.js +11 -11
  165. package/dist/core/graph/reader.d.ts +3 -0
  166. package/dist/core/graph/reader.js +3 -3
  167. package/dist/core/graph/repo-sync/identity.d.ts +3 -1
  168. package/dist/core/graph/repo-sync/identity.js +1 -1
  169. package/dist/core/graph/repo-sync/repos.d.ts +1 -1
  170. package/dist/core/graph/repo-sync/repos.js +2 -2
  171. package/dist/core/graph/repo-sync/sync.js +2 -2
  172. package/dist/core/installed-plugins.js +1 -1
  173. package/dist/core/keybindings/persistence.d.ts +1 -1
  174. package/dist/core/keybindings/persistence.js +1 -1
  175. package/dist/core/layout-migrate/loose-keys.d.ts +1 -1
  176. package/dist/core/layout-migrate/loose-keys.js +1 -1
  177. package/dist/core/ledger/account.d.ts +12 -0
  178. package/dist/core/ledger/account.js +2 -0
  179. package/dist/core/ledger/charges.d.ts +2 -2
  180. package/dist/core/ledger/charges.js +1 -1
  181. package/dist/core/ledger/check.d.ts +5 -1
  182. package/dist/core/ledger/check.js +1 -7
  183. package/dist/core/ledger/chunks.d.ts +8 -0
  184. package/dist/core/ledger/chunks.js +2 -0
  185. package/dist/core/ledger/index.d.ts +2 -1
  186. package/dist/core/ledger/index.js +1 -1
  187. package/dist/core/ledger/infra-allowance.d.ts +9 -0
  188. package/dist/core/ledger/infra-allowance.js +1 -0
  189. package/dist/core/ledger/limits.js +3 -3
  190. package/dist/core/ledger/payer.d.ts +1 -1
  191. package/dist/core/ledger/payer.js +1 -1
  192. package/dist/core/ledger/read.d.ts +14 -4
  193. package/dist/core/ledger/read.js +2 -3
  194. package/dist/core/ledger/totals.d.ts +5 -16
  195. package/dist/core/ledger/totals.js +4 -4
  196. package/dist/core/ledger/types.d.ts +12 -3
  197. package/dist/core/llm/run.js +2 -2
  198. package/dist/core/managed-providers.d.ts +72 -0
  199. package/dist/core/managed-providers.js +1 -0
  200. package/dist/core/model-auth/api-credential-store.d.ts +10 -0
  201. package/dist/core/model-auth/api-credential-store.js +1 -0
  202. package/dist/core/model-auth/daemon-login.d.ts +1 -1
  203. package/dist/core/model-auth/daemon-login.js +1 -1
  204. package/dist/core/model-auth/flows.d.ts +5 -4
  205. package/dist/core/model-auth/flows.js +1 -1
  206. package/dist/core/model-auth/handoff-jti.d.ts +3 -4
  207. package/dist/core/model-auth/handoff-jti.js +1 -1
  208. package/dist/core/model-auth/readiness.js +1 -1
  209. package/dist/core/model-config.d.ts +1 -1
  210. package/dist/core/model-config.js +1 -1
  211. package/dist/core/model-routes-pool.d.ts +14 -0
  212. package/dist/core/model-routes-pool.js +1 -0
  213. package/dist/core/model-routes.d.ts +11 -16
  214. package/dist/core/model-routes.js +1 -1
  215. package/dist/core/peer/ingest.d.ts +2 -0
  216. package/dist/core/peer/ingest.js +1 -1
  217. package/dist/core/peer/stubs.d.ts +8 -0
  218. package/dist/core/peer/stubs.js +1 -1
  219. package/dist/core/permissions/evaluator.d.ts +7 -2
  220. package/dist/core/permissions/evaluator.js +2 -2
  221. package/dist/core/plugin-env.js +1 -1
  222. package/dist/core/pool-credential-store.d.ts +2 -5
  223. package/dist/core/pool-credential-store.js +1 -1
  224. package/dist/core/profiles/app-env-store.d.ts +5 -5
  225. package/dist/core/profiles/app-env-store.js +1 -2
  226. package/dist/core/profiles/default-binding.d.ts +5 -5
  227. package/dist/core/profiles/default-binding.js +1 -1
  228. package/dist/core/profiles/env-store.d.ts +10 -21
  229. package/dist/core/profiles/env-store.js +1 -2
  230. package/dist/core/profiles/manifest.d.ts +14 -18
  231. package/dist/core/profiles/manifest.js +1 -1
  232. package/dist/core/profiles/relocate.js +1 -1
  233. package/dist/core/profiles/select.js +21 -21
  234. package/dist/core/provider-credential.d.ts +1 -1
  235. package/dist/core/provider-credential.js +1 -1
  236. package/dist/core/provider-management.d.ts +3 -4
  237. package/dist/core/provider-management.js +1 -1
  238. package/dist/core/providers/bundles.js +2 -2
  239. package/dist/core/providers/call.d.ts +3 -34
  240. package/dist/core/providers/description.d.ts +34 -0
  241. package/dist/core/providers/description.js +0 -0
  242. package/dist/core/providers/token-cache.d.ts +14 -14
  243. package/dist/core/providers/token-cache.js +1 -1
  244. package/dist/core/review/companion.js +1 -1
  245. package/dist/core/runs/activity.d.ts +1 -1
  246. package/dist/core/runs/activity.js +1 -1
  247. package/dist/core/runs/events.d.ts +7 -5
  248. package/dist/core/runs/events.js +2 -6
  249. package/dist/core/runs/operations.d.ts +1 -1
  250. package/dist/core/runs/operations.js +6 -6
  251. package/dist/core/runtime/bearings.js +1 -1
  252. package/dist/core/runtime/broker/attachments-fetch.d.ts +5 -0
  253. package/dist/core/runtime/broker/attachments-fetch.js +1 -0
  254. package/dist/core/runtime/broker/bash-job-launch.d.ts +4 -2
  255. package/dist/core/runtime/broker/bash-job-launch.js +1 -1
  256. package/dist/core/runtime/broker/boot-state.d.ts +9 -0
  257. package/dist/core/runtime/broker/boot-state.js +1 -0
  258. package/dist/core/runtime/broker/cli-relay.d.ts +2 -1
  259. package/dist/core/runtime/broker/cli-relay.js +1 -1
  260. package/dist/core/runtime/broker/client-registry.d.ts +3 -3
  261. package/dist/core/runtime/broker/daemon-ops.d.ts +10 -1
  262. package/dist/core/runtime/broker/daemon-ops.js +1 -1
  263. package/dist/core/runtime/broker/fault-retry.d.ts +2 -0
  264. package/dist/core/runtime/broker/fault-retry.js +1 -1
  265. package/dist/core/runtime/broker/frame-engine-control.js +1 -1
  266. package/dist/core/runtime/broker/held-deferred-inbox.d.ts +3 -0
  267. package/dist/core/runtime/broker/held-deferred-inbox.js +1 -1
  268. package/dist/core/runtime/broker/job-reporter.d.ts +18 -0
  269. package/dist/core/runtime/broker/job-reporter.js +2 -0
  270. package/dist/core/runtime/broker/model-adapter.d.ts +3 -0
  271. package/dist/core/runtime/broker/model-adapter.js +3 -2
  272. package/dist/core/runtime/broker/signal-stream.js +1 -1
  273. package/dist/core/runtime/broker/spilled-body.d.ts +5 -0
  274. package/dist/core/runtime/broker/spilled-body.js +1 -0
  275. package/dist/core/runtime/broker/summaries-post.d.ts +5 -0
  276. package/dist/core/runtime/broker/summaries-post.js +1 -0
  277. package/dist/core/runtime/broker/tool-groups.d.ts +3 -0
  278. package/dist/core/runtime/broker/tool-groups.js +1 -1
  279. package/dist/core/runtime/broker/turn-replies.d.ts +1 -0
  280. package/dist/core/runtime/broker/turn-replies.js +1 -1
  281. package/dist/core/runtime/broker-persona-guidance.js +2 -2
  282. package/dist/core/runtime/broker.js +1 -1
  283. package/dist/core/runtime/deliver-live.js +1 -1
  284. package/dist/core/runtime/first-boot-rows.d.ts +8 -0
  285. package/dist/core/runtime/first-boot-rows.js +2 -0
  286. package/dist/core/runtime/fleet.d.ts +13 -12
  287. package/dist/core/runtime/front-door-login.js +1 -1
  288. package/dist/core/runtime/front-door.js +6 -6
  289. package/dist/core/runtime/headless-pi.js +1 -1
  290. package/dist/core/runtime/host.d.ts +14 -3
  291. package/dist/core/runtime/host.js +3 -3
  292. package/dist/core/runtime/invocation.d.ts +6 -0
  293. package/dist/core/runtime/kickoff.d.ts +2 -14
  294. package/dist/core/runtime/kickoff.js +17 -19
  295. package/dist/core/runtime/launch-config-worker.js +1 -1
  296. package/dist/core/runtime/launch.js +2 -2
  297. package/dist/core/runtime/model-registry.js +1 -1
  298. package/dist/core/runtime/node-read.d.ts +4 -6
  299. package/dist/core/runtime/node-read.js +3 -3
  300. package/dist/core/runtime/nodes.js +1 -1
  301. package/dist/core/runtime/outcome-document.d.ts +0 -1
  302. package/dist/core/runtime/outcome-document.js +1 -1
  303. package/dist/core/runtime/output-result.d.ts +15 -0
  304. package/dist/core/runtime/output-result.js +5 -0
  305. package/dist/core/runtime/placement.d.ts +17 -1
  306. package/dist/core/runtime/placement.js +1 -1
  307. package/dist/core/runtime/provider-credential-gate.d.ts +6 -2
  308. package/dist/core/runtime/provider-credential-gate.js +2 -2
  309. package/dist/core/runtime/recovery-hold.d.ts +21 -2
  310. package/dist/core/runtime/recovery-hold.js +2 -1
  311. package/dist/core/runtime/recycle.js +1 -1
  312. package/dist/core/runtime/reset.js +1 -1
  313. package/dist/core/runtime/revive.d.ts +2 -2
  314. package/dist/core/runtime/revive.js +2 -2
  315. package/dist/core/runtime/runner/blaxel/client.d.ts +81 -0
  316. package/dist/core/runtime/runner/blaxel/client.js +1 -0
  317. package/dist/core/runtime/runner/blaxel/image-build.d.ts +74 -0
  318. package/dist/core/runtime/runner/blaxel/image-build.js +5 -0
  319. package/dist/core/runtime/runner/blaxel/runner.d.ts +41 -0
  320. package/dist/core/runtime/runner/blaxel/runner.js +3 -0
  321. package/dist/core/runtime/runner/index.d.ts +8 -0
  322. package/dist/core/runtime/runner/index.js +1 -0
  323. package/dist/core/runtime/runner/process.d.ts +11 -0
  324. package/dist/core/runtime/runner/process.js +1 -0
  325. package/dist/core/runtime/runner/types.d.ts +95 -0
  326. package/dist/core/runtime/runner/types.js +0 -0
  327. package/dist/core/runtime/situational-context.d.ts +3 -6
  328. package/dist/core/runtime/situational-context.js +2 -2
  329. package/dist/core/runtime/situational-live.js +1 -1
  330. package/dist/core/runtime/spawn-env-rows.d.ts +5 -0
  331. package/dist/core/runtime/spawn-env-rows.js +1 -0
  332. package/dist/core/runtime/spawn-env.d.ts +4 -18
  333. package/dist/core/runtime/spawn-env.js +1 -1
  334. package/dist/core/runtime/spawn.js +2 -2
  335. package/dist/core/runtime/stop-guard.d.ts +1 -1
  336. package/dist/core/runtime/stop-guard.js +2 -8
  337. package/dist/core/runtime/structured-output.d.ts +0 -67
  338. package/dist/core/runtime/structured-output.js +3 -8
  339. package/dist/core/runtime/tmux-driver.d.ts +8 -0
  340. package/dist/core/runtime/tmux-driver.js +6 -6
  341. package/dist/core/runtime/view-socket.d.ts +20 -0
  342. package/dist/core/runtime/view-socket.js +3 -1
  343. package/dist/core/runtime/warm-pool.d.ts +13 -1
  344. package/dist/core/runtime/warm-pool.js +1 -1
  345. package/dist/core/scoped-state/legacy-profiles.d.ts +11 -0
  346. package/dist/core/scoped-state/legacy-profiles.js +1 -0
  347. package/dist/core/scoped-state/materialized-plugins.d.ts +18 -0
  348. package/dist/core/scoped-state/materialized-plugins.js +1 -0
  349. package/dist/core/scoped-state/migrate.d.ts +8 -1
  350. package/dist/core/scoped-state/migrate.js +3 -3
  351. package/dist/core/scoped-state/person-rows.d.ts +10 -0
  352. package/dist/core/scoped-state/person-rows.js +6 -0
  353. package/dist/core/scoped-state/person-store.d.ts +72 -0
  354. package/dist/core/scoped-state/person-store.js +1 -0
  355. package/dist/core/secrets/blaxel-launch.d.ts +24 -0
  356. package/dist/core/secrets/blaxel-launch.js +4 -0
  357. package/dist/core/secrets/blaxel-register.d.ts +2 -0
  358. package/dist/core/secrets/blaxel-register.js +1 -0
  359. package/dist/core/secrets/env-rows.d.ts +17 -0
  360. package/dist/core/secrets/env-rows.js +4 -0
  361. package/dist/core/secrets/environment-owner.d.ts +8 -0
  362. package/dist/core/secrets/environment-owner.js +1 -0
  363. package/dist/core/secrets/environment-secrets.d.ts +14 -0
  364. package/dist/core/secrets/environment-secrets.js +1 -0
  365. package/dist/core/secrets/index.d.ts +2 -0
  366. package/dist/core/secrets/index.js +1 -0
  367. package/dist/core/secrets/key.d.ts +3 -0
  368. package/dist/core/secrets/key.js +2 -0
  369. package/dist/core/secrets/seal.d.ts +18 -0
  370. package/dist/core/secrets/seal.js +1 -0
  371. package/dist/core/spaces/mounts.d.ts +1 -1
  372. package/dist/core/spaces/mounts.js +1 -1
  373. package/dist/core/spaces/process.d.ts +1 -1
  374. package/dist/core/spaces/stop.d.ts +7 -5
  375. package/dist/core/spaces/stop.js +2 -2
  376. package/dist/core/spaces/users.d.ts +2 -1
  377. package/dist/core/spaces/users.js +1 -1
  378. package/dist/core/storage/attachments.d.ts +11 -8
  379. package/dist/core/storage/attachments.js +1 -1
  380. package/dist/core/storage/tables.d.ts +4 -0
  381. package/dist/core/storage/tables.js +3 -3
  382. package/dist/core/subscription-state.d.ts +34 -72
  383. package/dist/core/subscription-state.js +1 -4
  384. package/dist/core/substrate/delivery/plan.js +1 -1
  385. package/dist/core/user-settings.js +1 -1
  386. package/dist/daemon/api/app-listener.js +10 -10
  387. package/dist/daemon/api/auth/person-bearer.d.ts +14 -0
  388. package/dist/daemon/api/auth/person-bearer.js +1 -0
  389. package/dist/daemon/api/bridge.js +4 -4
  390. package/dist/daemon/api/document-listener.js +3 -3
  391. package/dist/daemon/api/environment-of.d.ts +18 -0
  392. package/dist/daemon/api/environment-of.js +5 -0
  393. package/dist/daemon/api/handlers/analytics.js +1 -1
  394. package/dist/daemon/api/handlers/app-profiles.d.ts +2 -2
  395. package/dist/daemon/api/handlers/app-profiles.js +1 -1
  396. package/dist/daemon/api/handlers/bash-jobs.js +1 -1
  397. package/dist/daemon/api/handlers/bash.js +1 -1
  398. package/dist/daemon/api/handlers/broker-ops.d.ts +3 -0
  399. package/dist/daemon/api/handlers/broker-ops.js +1 -1
  400. package/dist/daemon/api/handlers/broker-recovery.js +1 -1
  401. package/dist/daemon/api/handlers/broker-signals.d.ts +0 -3
  402. package/dist/daemon/api/handlers/broker-signals.js +2 -2
  403. package/dist/daemon/api/handlers/canvas.js +4 -4
  404. package/dist/daemon/api/handlers/charges.d.ts +1 -1
  405. package/dist/daemon/api/handlers/charges.js +1 -1
  406. package/dist/daemon/api/handlers/conversations.d.ts +2 -0
  407. package/dist/daemon/api/handlers/conversations.js +3 -0
  408. package/dist/daemon/api/handlers/crons.js +1 -1
  409. package/dist/daemon/api/handlers/daemon.js +1 -1
  410. package/dist/daemon/api/handlers/delivery.d.ts +1 -1
  411. package/dist/daemon/api/handlers/delivery.js +1 -1
  412. package/dist/daemon/api/handlers/docs.js +1 -1
  413. package/dist/daemon/api/handlers/exec.js +1 -1
  414. package/dist/daemon/api/handlers/execution-start.d.ts +2 -0
  415. package/dist/daemon/api/handlers/execution-start.js +2 -0
  416. package/dist/daemon/api/handlers/files.js +1 -1
  417. package/dist/daemon/api/handlers/git-credential.d.ts +11 -0
  418. package/dist/daemon/api/handlers/git-credential.js +1 -0
  419. package/dist/daemon/api/handlers/hook-exec.d.ts +1 -1
  420. package/dist/daemon/api/handlers/hook-exec.js +1 -1
  421. package/dist/daemon/api/handlers/human-requests.js +1 -1
  422. package/dist/daemon/api/handlers/inbox.js +1 -1
  423. package/dist/daemon/api/handlers/messages.js +1 -1
  424. package/dist/daemon/api/handlers/model-config.js +1 -1
  425. package/dist/daemon/api/handlers/modelauth.d.ts +1 -1
  426. package/dist/daemon/api/handlers/modelauth.js +1 -1
  427. package/dist/daemon/api/handlers/node-events.d.ts +6 -0
  428. package/dist/daemon/api/handlers/node-events.js +3 -3
  429. package/dist/daemon/api/handlers/node-outcomes.js +1 -1
  430. package/dist/daemon/api/handlers/node-records.js +3 -2
  431. package/dist/daemon/api/handlers/nodes.js +1 -1
  432. package/dist/daemon/api/handlers/objects.js +3 -3
  433. package/dist/daemon/api/handlers/profiles.js +1 -1
  434. package/dist/daemon/api/handlers/providers.js +1 -1
  435. package/dist/daemon/api/handlers/reports.js +9 -13
  436. package/dist/daemon/api/handlers/reviews.js +1 -1
  437. package/dist/daemon/api/handlers/runs.js +1 -1
  438. package/dist/daemon/api/handlers/settings.d.ts +2 -0
  439. package/dist/daemon/api/handlers/settings.js +1 -0
  440. package/dist/daemon/api/handlers/structured-requests.js +1 -1
  441. package/dist/daemon/api/handlers/vendor-status.d.ts +1 -1
  442. package/dist/daemon/api/handlers/vendor-status.js +1 -1
  443. package/dist/daemon/api/handlers/worktree.js +1 -1
  444. package/dist/daemon/api/map.d.ts +2 -2
  445. package/dist/daemon/api/map.js +2 -2
  446. package/dist/daemon/api/operations.js +1 -1
  447. package/dist/daemon/api/reader.d.ts +8 -1
  448. package/dist/daemon/api/reader.js +1 -1
  449. package/dist/daemon/api/router.d.ts +4 -2
  450. package/dist/daemon/api/router.js +1 -1
  451. package/dist/daemon/api/server.d.ts +15 -3
  452. package/dist/daemon/api/server.js +1 -1
  453. package/dist/daemon/api/vendor-signin.d.ts +2 -1
  454. package/dist/daemon/api/vendor-signin.js +19 -19
  455. package/dist/daemon/api/viewer-presence.d.ts +20 -6
  456. package/dist/daemon/api/viewer-presence.js +2 -1
  457. package/dist/daemon/boot-settings.d.ts +3 -0
  458. package/dist/daemon/boot-settings.js +1 -0
  459. package/dist/daemon/broker-signals/bus.d.ts +48 -11
  460. package/dist/daemon/broker-signals/bus.js +1 -1
  461. package/dist/daemon/cron/armed-context.js +1 -1
  462. package/dist/daemon/cron/lease-recovery.js +1 -1
  463. package/dist/daemon/cron/live-runs.d.ts +6 -0
  464. package/dist/daemon/cron/live-runs.js +1 -1
  465. package/dist/daemon/cron/run-socket.js +1 -1
  466. package/dist/daemon/cron-run.js +2 -2
  467. package/dist/daemon/crtrd-cli.js +1 -1
  468. package/dist/daemon/crtrd.d.ts +10 -0
  469. package/dist/daemon/crtrd.js +18 -17
  470. package/dist/daemon/delivery/run-delivery.d.ts +1 -1
  471. package/dist/daemon/delivery/run-delivery.js +1 -1
  472. package/dist/daemon/due-sources.d.ts +1 -1
  473. package/dist/daemon/due-sources.js +1 -1
  474. package/dist/daemon/due.js +7 -6
  475. package/dist/daemon/fleet.d.ts +6 -6
  476. package/dist/daemon/fleet.js +9 -9
  477. package/dist/daemon/park-activity.d.ts +2 -1
  478. package/dist/daemon/park-activity.js +1 -1
  479. package/dist/daemon/park-pending.d.ts +20 -13
  480. package/dist/daemon/park-pending.js +3 -1
  481. package/dist/daemon/profile-delete.js +1 -1
  482. package/dist/daemon/reconcilers/bash-deadline.d.ts +15 -10
  483. package/dist/daemon/reconcilers/bash-deadline.js +1 -3
  484. package/dist/daemon/reconcilers/broker-supervision.d.ts +13 -3
  485. package/dist/daemon/reconcilers/broker-supervision.js +4 -4
  486. package/dist/daemon/reconcilers/cron-lane.d.ts +0 -1
  487. package/dist/daemon/reconcilers/cron-lane.js +1 -1
  488. package/dist/daemon/reconcilers/fault-retry-backstop.d.ts +2 -9
  489. package/dist/daemon/reconcilers/fault-retry-backstop.js +1 -1
  490. package/dist/daemon/reconcilers/grant-effects.d.ts +8 -0
  491. package/dist/daemon/reconcilers/grant-effects.js +1 -0
  492. package/dist/daemon/reconcilers/grove-instance-sweep.d.ts +1 -3
  493. package/dist/daemon/reconcilers/grove-instance-sweep.js +1 -1
  494. package/dist/daemon/reconcilers/ledger-r2.d.ts +27 -0
  495. package/dist/daemon/reconcilers/ledger-r2.js +7 -0
  496. package/dist/daemon/reconcilers/ledger-sandbox.d.ts +55 -0
  497. package/dist/daemon/reconcilers/ledger-sandbox.js +9 -0
  498. package/dist/daemon/reconcilers/ledger-storage.d.ts +22 -0
  499. package/dist/daemon/reconcilers/ledger-storage.js +5 -0
  500. package/dist/daemon/reconcilers/live-obligation.d.ts +3 -2
  501. package/dist/daemon/reconcilers/live-obligation.js +1 -1
  502. package/dist/daemon/reconcilers/managed-worktree-sweep.d.ts +0 -5
  503. package/dist/daemon/reconcilers/managed-worktree-sweep.js +1 -1
  504. package/dist/daemon/reconcilers/node-deadline.d.ts +2 -1
  505. package/dist/daemon/reconcilers/node-deadline.js +1 -1
  506. package/dist/daemon/reconcilers/node-lifecycle/freeze-lane.d.ts +1 -2
  507. package/dist/daemon/reconcilers/node-lifecycle/freeze-lane.js +1 -1
  508. package/dist/daemon/reconcilers/node-lifecycle/remote-wake.d.ts +31 -0
  509. package/dist/daemon/reconcilers/node-lifecycle/remote-wake.js +1 -0
  510. package/dist/daemon/reconcilers/node-lifecycle/requested-stops.d.ts +5 -0
  511. package/dist/daemon/reconcilers/node-lifecycle/requested-stops.js +2 -0
  512. package/dist/daemon/reconcilers/node-lifecycle/tick.js +1 -1
  513. package/dist/daemon/reconcilers/pending-review-submit.js +1 -1
  514. package/dist/daemon/reconcilers/recipe-image.d.ts +49 -0
  515. package/dist/daemon/reconcilers/recipe-image.js +7 -0
  516. package/dist/daemon/reconcilers/row-claim.d.ts +19 -0
  517. package/dist/daemon/reconcilers/row-claim.js +2 -0
  518. package/dist/daemon/reconcilers/storage-due-work.d.ts +18 -3
  519. package/dist/daemon/reconcilers/storage-due-work.js +2 -1
  520. package/dist/daemon/reconcilers/storage-maintenance.d.ts +5 -13
  521. package/dist/daemon/reconcilers/storage-maintenance.js +1 -1
  522. package/dist/daemon/reconcilers/structured-request-lane.js +1 -1
  523. package/dist/daemon/reconcilers/throttled-lane.d.ts +11 -0
  524. package/dist/daemon/reconcilers/throttled-lane.js +1 -0
  525. package/dist/daemon/review/finish.js +1 -1
  526. package/dist/daemon/run-notices.d.ts +3 -0
  527. package/dist/daemon/run-notices.js +1 -1
  528. package/dist/daemon/runs/append-section.d.ts +4 -1
  529. package/dist/daemon/runs/append-section.js +2 -2
  530. package/dist/daemon/runs/observer.d.ts +3 -2
  531. package/dist/daemon/runs/observer.js +3 -2
  532. package/dist/daemon/runs/view-transport.d.ts +19 -0
  533. package/dist/daemon/runs/view-transport.js +1 -0
  534. package/dist/daemon/structured-requests/boot.d.ts +2 -1
  535. package/dist/daemon/structured-requests/boot.js +1 -1
  536. package/dist/daemon/structured-requests/effects.d.ts +4 -3
  537. package/dist/daemon/structured-requests/effects.js +1 -1
  538. package/dist/daemon/structured-requests/notifier.d.ts +2 -0
  539. package/dist/daemon/structured-requests/notifier.js +1 -1
  540. package/dist/daemon/structured-requests/sidecar.d.ts +4 -3
  541. package/dist/daemon/structured-requests/sidecar.js +1 -1
  542. package/dist/launcher/validate.js +1 -1
  543. package/dist/migrations/004-canvas-documents/index.js +2 -2
  544. package/dist/pi-extensions/broker-local.d.ts +3 -3
  545. package/dist/pi-extensions/broker-local.js +1 -2
  546. package/dist/pi-extensions/canvas-bash-valve.js +6 -6
  547. package/dist/pi-extensions/canvas-context-intro.js +2 -2
  548. package/dist/pi-extensions/canvas-elapsed.js +2 -2
  549. package/dist/pi-extensions/canvas-goal-capture.js +1 -1
  550. package/dist/pi-extensions/canvas-inbox-watcher.js +2 -2
  551. package/dist/pi-extensions/canvas-review-boundary.d.ts +11 -1
  552. package/dist/pi-extensions/canvas-review-boundary.js +3 -3
  553. package/dist/pi-extensions/canvas-stophook.js +1 -1
  554. package/dist/pi-extensions/canvas-structured-output.d.ts +5 -3
  555. package/dist/pi-extensions/canvas-structured-output.js +6 -11
  556. package/dist/pi-extensions/canvas-tool-guide.d.ts +9 -2
  557. package/dist/pi-extensions/canvas-tool-guide.js +6 -6
  558. package/dist/shared/inbox-entry-body.js +7 -7
  559. package/dist/types.d.ts +12 -0
  560. package/docs/sdk/release-notes.md +4 -0
  561. package/package.json +7 -4
  562. package/packages/crouter-identity/package.json +1 -1
  563. package/runtime.lock.json +13 -13
  564. package/scripts/git-credential-crtr +33 -0
  565. package/scripts/sandbox-bootstrap.sh +54 -0
  566. package/scripts/sandbox-start.mjs +320 -0
  567. package/dist/builtin-pi-packages/pi-crtr-extensions/extensions/provider-rotation.d.ts +0 -78
  568. package/dist/builtin-pi-packages/pi-crtr-extensions/extensions/provider-rotation.js +0 -1179
  569. package/dist/builtin-pi-packages/pi-crtr-extensions/extensions/provider-rotation.ts +0 -1406
  570. package/dist/core/conversation-store/file-store.d.ts +0 -37
  571. package/dist/core/conversation-store/file-store.js +0 -9
  572. package/dist/core/conversation-store/listener.d.ts +0 -4
  573. package/dist/core/conversation-store/listener.js +0 -8
  574. package/dist/core/scoped-state/profiles.d.ts +0 -27
  575. package/dist/core/scoped-state/profiles.js +0 -1
  576. package/dist/core/scoped-state/providers.d.ts +0 -24
  577. package/dist/core/scoped-state/providers.js +0 -1
  578. package/dist/core/scoped-state/settings.d.ts +0 -28
  579. package/dist/core/scoped-state/settings.js +0 -1
@@ -1,6 +1,6 @@
1
- var L=Object.defineProperty;var a=(e,t)=>L(e,"name",{value:t,configurable:!0});import{personIdAsync as l}from"../canvas/person.js";import{OBJECT_TYPE as O,GROUP_TYPE as w}from"./builtin.js";import{ceilingFrag as b,resolveCeiling as C}from"./ceiling.js";import{compilePermission as f}from"./compile.js";import{PermissionError as I}from"./errors.js";import{loadDefinitions as g}from"./schemas.js";import{TRUE as $,and as H,f as E,or as x,raw as p}from"./sql.js";const D=["read","edit","message","use","share"],U={read:"read",use:"read",edit:"write",share:"write",message:"message"},m=a(e=>e.replace(/^user:/,""),"bareUser");async function W(e,t){if(t.class==="person"){const c=await e.prepare("SELECT external_id FROM identities WHERE object = ? AND scheme = 'user'").get(t.person.id);return m(c?.external_id??await l())}if(t.class==="app")return m(t.sub??await l());const s=t.class==="node"?t.node.id:t.object.id,r=await e.prepare("SELECT sub FROM nodes WHERE node_id = ?").get(s);return m(r?.sub??await l())}a(W,"userOf");async function y(e,t){const s=[t,"*"],r=await e.prepareUncached(`WITH RECURSIVE g(id) AS (
1
+ var j=Object.defineProperty;var o=(e,t)=>j(e,"name",{value:t,configurable:!0});import{isCloudRole as C,personIdAsync as m}from"../canvas/person.js";import{OBJECT_TYPE as I,GROUP_TYPE as w}from"./builtin.js";import{ceilingFrag as L,resolveCeiling as O}from"./ceiling.js";import{compilePermission as f}from"./compile.js";import{PermissionError as $}from"./errors.js";import{loadDefinitions as A}from"./schemas.js";import{TRUE as x,and as H,f as E,or as U,raw as p}from"./sql.js";const D=["read","edit","message","use","share"],W={read:"read",use:"read",edit:"write",share:"write",message:"message"},l=o(e=>e.replace(/^user:/,""),"bareUser");async function F(e,t){if(t.class==="person"){const c=await e.prepare("SELECT external_id FROM identities WHERE object = ? AND scheme = 'user'").get(t.person.id);return l(c?.external_id??await m())}if(t.class==="app")return l(t.sub??await m());const s=t.class==="node"?t.node.id:t.object.id,r=await e.prepare("SELECT sub FROM nodes WHERE node_id = ?").get(s);return l(r?.sub??await m())}o(F,"userOf");async function M(e,t){return t.class==="app"&&t.sub===void 0&&C()?null:await F(e,t)}o(M,"readerUser");async function _(e,t){const s=[t,"*"],r=await e.prepareUncached(`WITH RECURSIVE g(id) AS (
2
2
  SELECT resource_id FROM relations WHERE resource_type = ? AND relation = 'member' AND subject_type = 'user' AND subject_id = ANY(?::text[])
3
3
  UNION
4
4
  SELECT r.resource_id FROM relations r JOIN g ON r.subject_type = ? AND r.subject_id = g.id AND r.subject_relation = 'member'
5
5
  WHERE r.resource_type = ? AND r.relation = 'member')
6
- SELECT id FROM g`).all(w,s,w,w);return{userIds:s,groupIds:r.map(c=>c.id)}}a(y,"subjectSet");async function F(e,t){const s=await W(e,t);return{reader:t,userId:s,subjects:await y(e,s)}}a(F,"resolveReader");const M=a(e=>"subjects"in e,"isEval");async function k(e,t,s,r="o",c={}){if(!D.includes(s))throw new I(400,"unknown_permission",`unknown permission ${s}`);const n=M(t)?t:await F(e,t),i=await g(e),d=p(`${r}.id`),N=f(i,n.subjects,O,s,d),S=s==="read"?x([N,p(`${r}.type = 'app'`)]):N,h=n.reader.class==="person"?null:n.reader.app.id,T=n.reader.class==="app"&&n.reader.place===void 0&&h!==null?await P(e,h):new Set,u=[];for(const[o,_]of i){if(o.startsWith("crtr/")||o==="user"||o==="app"||!(s in _.permissions)&&!(s in _.relations))continue;const j=o.split("/")[0];u.push(E`WHEN ${p(r)}.schema_type = ${o} THEN ${T.has(j)?$:f(i,n.subjects,o,s,d)}`)}const A=u.length===0?E`(CASE WHEN ${p(r)}.schema_type IS NULL THEN ${S} ELSE FALSE END)`:E`(CASE WHEN ${p(r)}.schema_type IS NULL THEN ${S} ${{sql:u.map(o=>o.sql).join(" "),params:u.flatMap(o=>o.params)}} ELSE FALSE END)`,R=await C(e,n.reader,U[s],c);return R===null?A:H([b(R,r),A])}a(k,"permits");async function P(e,t){const s=await e.prepare("SELECT s.namespace FROM schemas s JOIN identities i ON i.external_id = s.app AND i.scheme = 'app' WHERE i.object = ?").all(t);return new Set(s.map(r=>r.namespace))}a(P,"ownNamespaceTypes");async function Q(e,t,s,r,c={}){const n=await k(e,t,s,"o",c);return(await e.prepareUncached(`SELECT ${n.sql} AS ok FROM objects o WHERE o.id = ?`).get(...n.params,r))?.ok===!0}a(Q,"check");async function X(e,t,s,r){const c=await y(e,m(t)),n=await g(e),i=f(n,c,r.type,s,E`${r.id}::text`);return(await e.prepareUncached(`SELECT ${i.sql} AS ok`).get(...i.params))?.ok===!0}a(X,"checkUser");export{D as PERMISSIONS,Q as check,X as checkUser,k as permits,F as resolveReader,y as subjectSet,W as userOf};
6
+ SELECT id FROM g`).all(w,s,w,w);return{userIds:s,groupIds:r.map(c=>c.id)}}o(_,"subjectSet");async function k(e,t){const s=await M(e,t);return{reader:t,userId:s,subjects:s===null?{userIds:["*"],groupIds:[]}:await _(e,s)}}o(k,"resolveReader");const P=o(e=>"subjects"in e,"isEval");async function v(e,t,s,r="o",c={}){if(!D.includes(s))throw new $(400,"unknown_permission",`unknown permission ${s}`);const n=P(t)?t:await k(e,t),i=await A(e),d=p(`${r}.id`),N=f(i,n.subjects,I,s,d),S=s==="read"?U([N,p(`${r}.type = 'app'`)]):N,R=n.reader.class==="person"?null:n.reader.app.id,T=n.reader.class==="app"&&n.reader.place===void 0&&R!==null?await q(e,R):new Set,u=[];for(const[a,y]of i){if(a.startsWith("crtr/")||a==="user"||a==="app"||!(s in y.permissions)&&!(s in y.relations))continue;const b=a.split("/")[0];u.push(E`WHEN ${p(r)}.schema_type = ${a} THEN ${T.has(b)?x:f(i,n.subjects,a,s,d)}`)}const g=u.length===0?E`(CASE WHEN ${p(r)}.schema_type IS NULL THEN ${S} ELSE FALSE END)`:E`(CASE WHEN ${p(r)}.schema_type IS NULL THEN ${S} ${{sql:u.map(a=>a.sql).join(" "),params:u.flatMap(a=>a.params)}} ELSE FALSE END)`,h=await O(e,n.reader,W[s],c);return h===null?g:H([L(h,r),g])}o(v,"permits");async function q(e,t){const s=await e.prepare("SELECT s.namespace FROM schemas s JOIN identities i ON i.external_id = s.app AND i.scheme = 'app' WHERE i.object = ?").all(t);return new Set(s.map(r=>r.namespace))}o(q,"ownNamespaceTypes");async function Z(e,t,s,r,c={}){const n=await v(e,t,s,"o",c);return(await e.prepareUncached(`SELECT ${n.sql} AS ok FROM objects o WHERE o.id = ?`).get(...n.params,r))?.ok===!0}o(Z,"check");async function ee(e,t,s,r){const c=await _(e,l(t)),n=await A(e),i=f(n,c,r.type,s,E`${r.id}::text`);return(await e.prepareUncached(`SELECT ${i.sql} AS ok`).get(...i.params))?.ok===!0}o(ee,"checkUser");export{D as PERMISSIONS,Z as check,ee as checkUser,v as permits,M as readerUser,k as resolveReader,_ as subjectSet,F as userOf};
@@ -1 +1 @@
1
- var u=Object.defineProperty;var s=(t,e)=>u(t,"name",{value:e,configurable:!0});import{validateEnvVarName as a}from"./env-name.js";import{isReservedEnvName as f}from"./profiles/env-store.js";function l(t){if(!t||typeof t!="object"||Array.isArray(t))return["env must be an object mapping variable names to declarations"];const e=[];for(const[r,i]of Object.entries(t)){if((!a(r).isValid||f(r))&&e.push(`env.${r} has an invalid or reserved name`),!i||typeof i!="object"||Array.isArray(i)){e.push(`env.${r} must be an object`);continue}const n=i;(typeof n.description!="string"||!n.description.trim())&&e.push(`env.${r}.description must be a non-empty string`),n.required!==void 0&&typeof n.required!="boolean"&&e.push(`env.${r}.required must be boolean`),n.secret!==void 0&&typeof n.secret!="boolean"&&e.push(`env.${r}.secret must be boolean`),n.url!==void 0&&(typeof n.url!="string"||!/^https:\/\/[^\s]+$/.test(n.url))&&e.push(`env.${r}.url must be an https URL`);for(const o of Object.keys(n))["description","required","secret","url"].includes(o)||e.push(`env.${r}.${o} is unknown`)}return e}s(l,"invalidPluginEnvReasons");function m(t){return Object.entries(t??{}).filter(([,e])=>e.required!==!1).map(([e])=>e)}s(m,"requiredPluginEnv");export{l as invalidPluginEnvReasons,m as requiredPluginEnv};
1
+ var u=Object.defineProperty;var s=(t,e)=>u(t,"name",{value:e,configurable:!0});import{isReservedEnvName as a,validateEnvVarName as f}from"./env-name.js";function d(t){if(!t||typeof t!="object"||Array.isArray(t))return["env must be an object mapping variable names to declarations"];const e=[];for(const[r,i]of Object.entries(t)){if((!f(r).isValid||a(r))&&e.push(`env.${r} has an invalid or reserved name`),!i||typeof i!="object"||Array.isArray(i)){e.push(`env.${r} must be an object`);continue}const n=i;(typeof n.description!="string"||!n.description.trim())&&e.push(`env.${r}.description must be a non-empty string`),n.required!==void 0&&typeof n.required!="boolean"&&e.push(`env.${r}.required must be boolean`),n.secret!==void 0&&typeof n.secret!="boolean"&&e.push(`env.${r}.secret must be boolean`),n.url!==void 0&&(typeof n.url!="string"||!/^https:\/\/[^\s]+$/.test(n.url))&&e.push(`env.${r}.url must be an https URL`);for(const o of Object.keys(n))["description","required","secret","url"].includes(o)||e.push(`env.${r}.${o} is unknown`)}return e}s(d,"invalidPluginEnvReasons");function l(t){return Object.entries(t??{}).filter(([,e])=>e.required!==!1).map(([e])=>e)}s(l,"requiredPluginEnv");export{d as invalidPluginEnvReasons,l as requiredPluginEnv};
@@ -11,17 +11,14 @@ import { type ManagedProviderId, type SubscriptionCredential } from './subscript
11
11
  * nothing: deciding a turn is unservable belongs to the rotation loop, and an `undefined` here
12
12
  * would make pi's eager launch gate FATAL a node that rotation could still have serviced.
13
13
  */
14
- export declare function electPoolCredential(providerId: ManagedProviderId, now?: number): SubscriptionCredential | undefined;
14
+ export declare function electPoolCredential(providerId: ManagedProviderId, now?: number): Promise<SubscriptionCredential | undefined>;
15
15
  export declare class PoolCredentialStore implements CredentialStore {
16
- private readonly authPath;
17
16
  private readonly auth;
18
- constructor(authPath?: string);
19
17
  read(providerId: string): Promise<Credential | undefined>;
20
18
  list(): Promise<readonly CredentialInfo[]>;
21
19
  /**
22
20
  * pi's locked read-modify-write, chiefly its OAuth refresh. The whole transaction — electing
23
- * the account, running pi's `fn`, committing the result — happens under the pool file's
24
- * cross-process lock, because a refresh token is single-use: two brokers electing the same
21
+ * the account, running pi's `fn`, committing the result — happens under the account row locks, because a refresh token is single-use: two brokers electing the same
25
22
  * expired account outside a lock would both spend it and the loser would get a genuine
26
23
  * `invalid_grant`. Electing under the lock is also what guarantees the refreshed token lands
27
24
  * back on exactly the account whose token was spent.
@@ -1 +1 @@
1
- var l=Object.defineProperty;var s=(n,t)=>l(n,"name",{value:t,configurable:!0});import{CrouterCredentialStore as m,defaultAuthPath as w}from"./auth-file.js";import{MANAGED_PROVIDER_IDS as x,getProviderLabel as g,isManagedProvider as c,modifyElectedSubscription as y,readSubscriptionPool as h,removeManagedAccount as P}from"./subscription-state.js";function r(n,t=Date.now()){return f(h(n),t)}s(r,"electPoolCredential");function f(n,t=Date.now()){return n.find(e=>!e.authFailure&&(!e.rateLimitedUntil||e.rateLimitedUntil<=t))??n[0]}s(f,"electFrom");function d(n){return{type:"oauth",refresh:n.refresh,access:n.access,expires:n.expires,...n.accountId?{accountId:n.accountId}:{},...n.clientId?{clientId:n.clientId}:{}}}s(d,"toCredential");class D{static{s(this,"PoolCredentialStore")}authPath;auth;constructor(t=w()){this.authPath=t,this.auth=new m(t)}async read(t){if(!c(t))return this.auth.read(t);const e=r(t);if(e!==void 0)return d(e);const i=await this.auth.read(t);return i?.type==="oauth"?void 0:i}async list(){const t=(await this.auth.list()).filter(e=>!(c(e.providerId)&&e.type==="oauth"));for(const e of x)t.some(i=>i.providerId===e)||h(e).length>0&&t.push({providerId:e,type:"oauth"});return t}async modify(t,e){if(!c(t))return this.auth.modify(t,e);if(r(t)===void 0){if(await this.read(t)!==void 0)return this.auth.modify(t,e);throw new Error(`${g(t)} has no account to update \u2014 add one with \`crtr sys settings\` or \`/provider-sub ${t} add\`.`)}const i=await y(t,u=>f(u),async u=>{const a=await e(d(u));if(a===void 0||a.type!=="oauth")return;const o=a.clientId;return{refresh:a.refresh,access:a.access,expires:a.expires,...typeof o=="string"&&o?{clientId:o}:{}}});return i===void 0?void 0:d(i)}async delete(t){if(!c(t))return this.auth.delete(t);const e=r(t);e!==void 0&&await P(t,e.label),await this.auth.read(t)!==void 0&&await this.auth.delete(t)}}export{D as PoolCredentialStore,r as electPoolCredential};
1
+ var l=Object.defineProperty;var s=(i,t)=>l(i,"name",{value:t,configurable:!0});import{CrouterCredentialStore as w}from"./auth-file.js";import{MANAGED_PROVIDER_IDS as m,getProviderLabel as g,isManagedProvider as u,modifyElectedSubscription as x,readSubscriptionPool as f,removeManagedAccount as y}from"./subscription-state.js";import{registerGateCredentialStore as p}from"./runtime/provider-credential-gate.js";async function c(i,t=Date.now()){return h(await f(i),t)}s(c,"electPoolCredential");function h(i,t=Date.now()){return i.find(e=>!e.authFailure&&(!e.rateLimitedUntil||e.rateLimitedUntil<=t))??i[0]}s(h,"electFrom");function d(i){return{type:"oauth",refresh:i.refresh,access:i.access,expires:i.expires,...i.accountId?{accountId:i.accountId}:{},...i.clientId?{clientId:i.clientId}:{}}}s(d,"toCredential");class C{static{s(this,"PoolCredentialStore")}auth=new w;async read(t){if(!u(t))return this.auth.read(t);const e=await c(t);if(e!==void 0)return d(e);const a=await this.auth.read(t);return a?.type==="oauth"?void 0:a}async list(){const t=(await this.auth.list()).filter(e=>!(u(e.providerId)&&e.type==="oauth"));for(const e of m)t.some(a=>a.providerId===e)||(await f(e)).length>0&&t.push({providerId:e,type:"oauth"});return t}async modify(t,e){if(!u(t))return this.auth.modify(t,e);if(await c(t)===void 0){if(await this.read(t)!==void 0)return this.auth.modify(t,e);throw new Error(`${g(t)} has no account to update \u2014 add one with \`crtr sys settings\` or \`/provider-sub ${t} add\`.`)}const a=await x(t,r=>h(r),async r=>{const n=await e(d(r));if(n===void 0||n.type!=="oauth")return;const o=n.clientId;return{refresh:n.refresh,access:n.access,expires:n.expires,...typeof o=="string"&&o?{clientId:o}:{}}});return a===void 0?void 0:d(a)}async delete(t){if(!u(t))return this.auth.delete(t);const e=await c(t);e!==void 0&&await y(t,e.label),await this.auth.read(t)!==void 0&&await this.auth.delete(t)}}p(new C);export{C as PoolCredentialStore,c as electPoolCredential};
@@ -1,6 +1,6 @@
1
1
  export declare const isDeploymentName: (name: string) => boolean;
2
- /** Every var an app's processes receive: its own store plus the deployment-wide one. */
3
- export declare function readAppEnvVars(app: string): Record<string, string>;
4
- export declare function listAppEnvNames(app: string): string[];
5
- export declare function setAppEnvVar(app: string, name: string, value: string): boolean;
6
- export declare function removeAppEnvVar(app: string, name: string): boolean;
2
+ /** Every var an app's processes receive: its own rows plus the deployment-wide ones. */
3
+ export declare function readAppEnvVars(app: string, person?: string): Promise<Record<string, string>>;
4
+ export declare function listAppEnvNames(app: string, person?: string): Promise<string[]>;
5
+ export declare function setAppEnvVar(app: string, name: string, value: string, person?: string): Promise<boolean>;
6
+ export declare function removeAppEnvVar(app: string, name: string, person?: string): Promise<boolean>;
@@ -1,2 +1 @@
1
- var N=Object.defineProperty;var o=(t,r)=>N(t,"name",{value:r,configurable:!0});import{existsSync as O,readFileSync as S,writeFileSync as w,chmodSync as A,renameSync as b}from"node:fs";import{basename as D,dirname as p,join as u}from"node:path";import{appSpace as _,secretsDir as f}from"../layout.js";import{ensureDir as m}from"../fs-utils.js";import{withExclusiveDirectoryLock as j}from"../exclusive-lock.js";import{isReservedEnvName as x}from"./env-store.js";import{validateEnvVarName as d}from"../env-name.js";import{usage as l}from"../errors.js";const T=new Set(["CRTR_FEEDBACK_ENDPOINT","CRTR_FEEDBACK_TOKEN"]),s=o(t=>T.has(t),"isDeploymentName"),v=o(t=>!x(t),"isAppName"),E={path:o(()=>u(f(),"env","_deployment"),"path"),admits:s},h=o(t=>({path:o(()=>u(f(),"env",D(_(t).root),"_app"),"path"),admits:v}),"appStore"),V=o((t,r)=>s(r)?E:h(t),"storeFor");function a(t){const r=Object.create(null);try{if(!O(t.path()))return r;const e=JSON.parse(S(t.path(),"utf8"));if(!e||typeof e!="object"||!("vars"in e)||!e.vars||typeof e.vars!="object"||Array.isArray(e.vars))return r;for(const[n,i]of Object.entries(e.vars))d(n).isValid&&t.admits(n)&&typeof i=="string"&&!i.includes("\0")&&(r[n]=i)}catch{}return r}o(a,"read");function R(t,r){const e=t.path();m(p(e));const n=`${e}.tmp.${process.pid}.${Math.random().toString(36).slice(2)}`;w(n,JSON.stringify({vars:r})+`
2
- `,{mode:384}),A(n,384),b(n,e)}o(R,"write");function F(t){if(!d(t).isValid||!(v(t)||s(t)))throw l(`invalid or reserved env var name: ${t}`,{field:"name"})}o(F,"validate");function y(t,r,e){F(r);const n=V(t,r);return m(p(n.path())),j(`${n.path()}.lock`,()=>{const i=a(n),c=e(i);return c!==null&&R(n,i),c})}o(y,"update");function $(t){return{...a(h(t)),...a(E)}}o($,"readAppEnvVars");function Y(t){return Object.keys($(t)).sort()}o(Y,"listAppEnvNames");function q(t,r,e){if(!e||e.includes("\0"))throw l("a non-empty env value without NUL bytes is required",{field:"value"});return y(t,r,n=>{const i=!Object.hasOwn(n,r);return n[r]=e,i})}o(q,"setAppEnvVar");function I(t,r){return y(t,r,e=>Object.hasOwn(e,r)?(delete e[r],!0):null)??!1}o(I,"removeAppEnvVar");export{s as isDeploymentName,Y as listAppEnvNames,$ as readAppEnvVars,I as removeAppEnvVar,q as setAppEnvVar};
1
+ var u=Object.defineProperty;var a=(t,e)=>u(t,"name",{value:e,configurable:!0});import{isReservedEnvName as N,validateEnvVarName as c}from"../env-name.js";import{usage as E}from"../errors.js";import{personIdAsync as y}from"../canvas/person.js";import{listEnvRowNames as w,putEnvRow as R,readEnvRows as d,removeEnvRow as A}from"../secrets/env-rows.js";import{DEPLOYMENT_ID as O}from"../secrets/environment-secrets.js";const D=new Set(["CRTR_FEEDBACK_ENDPOINT","CRTR_FEEDBACK_TOKEN"]),i=a(t=>D.has(t),"isDeploymentName"),o=a(t=>!N(t),"isAppName"),s={person:null,kind:"deployment",id:O},p=a(async(t,e)=>({person:e??await y(),kind:"app",id:t}),"appOwner"),v=a(async(t,e,n)=>i(e)?s:await p(t,n),"ownerFor");function m(t){if(!c(t).isValid||!(o(t)||i(t)))throw E(`invalid or reserved env var name: ${t}`,{field:"name"})}a(m,"validate");const f=a((t,e)=>{const n=Object.create(null);for(const[r,l]of Object.entries(t))c(r).isValid&&e(r)&&(n[r]=l);return n},"admitted");async function L(t,e){return{...f(await d(await p(t,e)),o),...f(await d(s),i)}}a(L,"readAppEnvVars");async function M(t,e){return[...(await w(await p(t,e))).filter(o),...(await w(s)).filter(i)].sort()}a(M,"listAppEnvNames");async function P(t,e,n,r){if(!n||n.includes("\0"))throw E("a non-empty env value without NUL bytes is required",{field:"value"});return m(e),await R(await v(t,e,r),e,n)}a(P,"setAppEnvVar");async function b(t,e,n){return m(e),await A(await v(t,e,n),e)}a(b,"removeAppEnvVar");export{i as isDeploymentName,M as listAppEnvNames,L as readAppEnvVars,b as removeAppEnvVar,P as setAppEnvVar};
@@ -1,15 +1,15 @@
1
1
  export declare function resolveBindingCwd(cwd: string): string;
2
2
  export declare function getDefaultProfileId(cwd: string): string | null;
3
- export declare function setDefaultProfileId(cwd: string, profileId: string): void;
4
- export declare function clearDefaultProfile(cwd: string): void;
3
+ export declare function setDefaultProfileId(cwd: string, profileId: string): Promise<void>;
4
+ export declare function clearDefaultProfile(cwd: string): Promise<void>;
5
5
  export declare function defaultProfileDirs(profileId: string): string[];
6
- export declare function clearDefaultProfileId(profileId: string): string[];
6
+ export declare function clearDefaultProfileId(profileId: string): Promise<string[]>;
7
7
  export declare function listDefaultPins(): Array<{
8
8
  dir: string;
9
9
  profileId: string;
10
10
  }>;
11
11
  /** Drop every pin whose directory no longer exists; returns what was removed. */
12
- export declare function clearMissingDefaultDirs(): Array<{
12
+ export declare function clearMissingDefaultDirs(): Promise<Array<{
13
13
  dir: string;
14
14
  profile_id: string;
15
- }>;
15
+ }>>;
@@ -1 +1 @@
1
- var u=Object.defineProperty;var o=(t,e)=>u(t,"name",{value:e,configurable:!0});import{existsSync as a,realpathSync as d}from"node:fs";import{resolve as p}from"node:path";import{userScopeRoot as l}from"../scope.js";import{mutateStoredDefaults as s,readStoredDefaults as m}from"../scoped-state/profiles.js";function f(t){const e=p(t);if(!a(e))return e;try{return d(e)}catch{return e}}o(f,"resolveBindingCwd");function c(){return m(l())}o(c,"bindings");function y(t){return c()[f(t)]??null}o(y,"getDefaultProfileId");function O(t,e){const i=f(t);s(l(),r=>({...r,[i]:e}))}o(O,"setDefaultProfileId");function S(t){const e=f(t);s(l(),i=>{const r={...i};return delete r[e],r})}o(S,"clearDefaultProfile");function g(t){return Object.entries(c()).filter(([,e])=>e===t).map(([e])=>e).sort()}o(g,"defaultProfileDirs");function h(t){let e=[];return s(l(),i=>{e=Object.entries(i).filter(([,n])=>n===t).map(([n])=>n).sort();const r={...i};for(const n of e)delete r[n];return r}),e}o(h,"clearDefaultProfileId");function v(){return Object.entries(c()).map(([t,e])=>({dir:t,profileId:e})).sort((t,e)=>t.dir.localeCompare(e.dir))}o(v,"listDefaultPins");function C(){let t=[];return s(l(),e=>{t=Object.entries(e).filter(([r])=>!a(r)).map(([r,n])=>({dir:r,profile_id:n})).sort((r,n)=>r.dir.localeCompare(n.dir));const i=new Set(t.map(r=>r.dir));return Object.fromEntries(Object.entries(e).filter(([r])=>!i.has(r)))}),t}o(C,"clearMissingDefaultDirs");export{S as clearDefaultProfile,h as clearDefaultProfileId,C as clearMissingDefaultDirs,g as defaultProfileDirs,y as getDefaultProfileId,v as listDefaultPins,f as resolveBindingCwd,O as setDefaultProfileId};
1
+ var f=Object.defineProperty;var n=(t,e)=>f(t,"name",{value:e,configurable:!0});import{existsSync as l,realpathSync as u}from"node:fs";import{resolve as d}from"node:path";import{cachedDefaults as p,writeSettings as m}from"../scoped-state/person-store.js";function s(t){const e=d(t);if(!l(e))return e;try{return u(e)}catch{return e}}n(s,"resolveBindingCwd");function c(){return p()}n(c,"bindings");function w(t){return c()[s(t)]??null}n(w,"getDefaultProfileId");async function a(t){await m(e=>[{op:"defaults.replace",defaults:t({...e.defaults})}])}n(a,"replaceDefaults");async function P(t,e){const i=s(t);await a(r=>({...r,[i]:e}))}n(P,"setDefaultProfileId");async function g(t){const e=s(t);await a(i=>{const r={...i};return delete r[e],r})}n(g,"clearDefaultProfile");function j(t){return Object.entries(c()).filter(([,e])=>e===t).map(([e])=>e).sort()}n(j,"defaultProfileDirs");async function O(t){let e=[];return await a(i=>{e=Object.entries(i).filter(([,o])=>o===t).map(([o])=>o).sort();const r={...i};for(const o of e)delete r[o];return r}),e}n(O,"clearDefaultProfileId");function h(){return Object.entries(c()).map(([t,e])=>({dir:t,profileId:e})).sort((t,e)=>t.dir.localeCompare(e.dir))}n(h,"listDefaultPins");async function v(){let t=[];return await a(e=>{t=Object.entries(e).filter(([r])=>!l(r)).map(([r,o])=>({dir:r,profile_id:o})).sort((r,o)=>r.dir.localeCompare(o.dir));const i=new Set(t.map(r=>r.dir));return Object.fromEntries(Object.entries(e).filter(([r])=>!i.has(r)))}),t}n(v,"clearMissingDefaultDirs");export{g as clearDefaultProfile,O as clearDefaultProfileId,v as clearMissingDefaultDirs,j as defaultProfileDirs,w as getDefaultProfileId,h as listDefaultPins,s as resolveBindingCwd,P as setDefaultProfileId};
@@ -1,22 +1,11 @@
1
- export declare function isReservedEnvName(name: string): boolean;
2
- /** Every stored variable NAME for a profile, sorted. Never returns values. */
3
- export declare function listProfileEnvNames(profileId: string): string[];
4
- /** Set one variable, replacing any prior value under the same name. Holds the
5
- * same per-profile lock manifest mutations use (`withProfileManifestLock`),
6
- * so a concurrent `profile delete` can never race a write into an
7
- * about-to-vanish profile dir — whichever runs first wins the lock, and the
8
- * loser either sees `not_found` (delete-then-set) or removes the file right
9
- * back out from under a just-written value (set-then-delete, via
10
- * `deleteProfile`'s recursive rm of the whole profile root). Returns whether
11
- * the name was newly added (`true`) or replaced an existing value (`false`). */
12
- export declare function setProfileEnvVar(profileId: string, name: string, value: string): boolean;
1
+ /** Every stored variable NAME for a profile, sorted. Never opens or returns values. */
2
+ export declare function listProfileEnvNames(profileId: string, person?: string): Promise<string[]>;
3
+ /** Set one variable, replacing any prior value under the same name. Returns whether the name was newly added (`true`) or replaced an
4
+ * existing value (`false`). One upsert on the sealed row; the profile must exist. */
5
+ export declare function setProfileEnvVar(profileId: string, name: string, value: string, person?: string): Promise<boolean>;
13
6
  /** Remove one variable. Returns whether it was present. */
14
- export declare function removeProfileEnvVar(profileId: string, name: string): boolean;
15
- /** Every stored `{name: value}` for a profile — the ONLY function that
16
- * returns raw values, called exclusively by `buildBrokerEnv`
17
- * (`core/runtime/spawn-env.ts`) to inject them directly into a launched
18
- * broker's env. Never throws: a stale/invalid/deleted profile id is a
19
- * hot-path no-op (mirrors `readRawProfileConfig` in `core/config.ts`),
20
- * because broker-env resolution must never fail a launch over a bad profile
21
- * id. */
22
- export declare function readProfileEnvVars(profileId: string | null): Record<string, string>;
7
+ export declare function removeProfileEnvVar(profileId: string, name: string, person?: string): Promise<boolean>;
8
+ /** Every stored `{name: value}` for a profile — the ONLY function that returns raw values, called by `buildBrokerEnv`
9
+ * (`core/runtime/spawn-env.ts`), the bash handler and cron. A null or empty profile id is `{}`. A row that fails to open
10
+ * (another key, altered bytes) throws: a launch never proceeds with a silently empty environment. */
11
+ export declare function readProfileEnvVars(profileId: string | null, person?: string): Promise<Record<string, string>>;
@@ -1,2 +1 @@
1
- var E=Object.defineProperty;var n=(e,t)=>E(e,"name",{value:t,configurable:!0});import{existsSync as p,readFileSync as y,renameSync as S,writeFileSync as O,chmodSync as b}from"node:fs";import{dirname as w}from"node:path";import{profileSpace as R}from"../layout.js";import{loadExactProfileManifest as c,withProfileManifestLock as u}from"./manifest.js";import{ensureDir as x}from"../fs-utils.js";import{notFound as N,usage as f}from"../errors.js";const P="CRTR_",g=new Set(["HOME"]);function v(e){return e.startsWith(P)||g.has(e)}n(v,"isReservedEnvName");function m(e){return e.includes("\0")}n(m,"hasNulByte");function l(e){const t=c(e);return R(t.manifest.grantee??"app:terminal",e).env}n(l,"envPath");function s(e){const t=l(e),r=Object.create(null);if(!p(t))return{vars:r};try{const o=JSON.parse(y(t,"utf8"));for(const[i,a]of Object.entries(o.vars??{}))typeof a=="string"&&(m(a)||v(i)||(r[i]=a))}catch{}return{vars:r}}n(s,"readStoreUnlocked");function d(e,t){const r=l(e);x(w(r));const o=`${r}.tmp.${process.pid}.${Math.random().toString(36).slice(2)}`;O(o,JSON.stringify(t,null,2)+`
2
- `,{mode:384}),b(o,384),S(o,r)}n(d,"writeStoreAtomic");function h(e){try{c(e)}catch(t){throw t instanceof Error&&t.message.startsWith("profile not found:")?N(`profile not found: ${e}`,{received:e}):t}}n(h,"requireProfileExists");function F(e){return Object.keys(s(e).vars).sort()}n(F,"listProfileEnvNames");function A(e,t,r){if(v(t))throw f(`env var name is reserved by crtr: ${t}`,{received:t,field:"name",next:"crtr identity/routing names (CRTR_* and HOME) cannot be stored in a profile env store \u2014 a stored value under one of these names could redirect a broker to a different canvas home. Choose a different name."});if(m(r))throw f("env var value contains a NUL byte, which no OS accepts in an environment variable",{field:"value",next:"Remove NUL bytes from the piped value and retry."});return u(e,()=>{h(e);const o=s(e),i=!Object.hasOwn(o.vars,t);return o.vars[t]=r,d(e,o),i})}n(A,"setProfileEnvVar");function D(e,t){return u(e,()=>{h(e);const r=s(e);return Object.hasOwn(r.vars,t)?(delete r.vars[t],d(e,r),!0):!1})}n(D,"removeProfileEnvVar");function L(e){if(e===null||e==="")return{};try{return{...s(e).vars}}catch{return{}}}n(L,"readProfileEnvVars");export{v as isReservedEnvName,F as listProfileEnvNames,L as readProfileEnvVars,D as removeProfileEnvVar,A as setProfileEnvVar};
1
+ var c=Object.defineProperty;var n=(e,r)=>c(e,"name",{value:r,configurable:!0});import{loadExactProfileManifest as v}from"./manifest.js";import{notFound as u,usage as s}from"../errors.js";import{isReservedEnvName as i}from"../env-name.js";import{personIdAsync as m}from"../canvas/person.js";import{listEnvRowNames as d,putEnvRow as l,readEnvRows as w,removeEnvRow as y}from"../secrets/env-rows.js";function h(e){return e.includes("\0")}n(h,"hasNulByte");const a=n(async(e,r)=>({person:r??await m(),kind:"profile",id:e}),"ownerOf");function f(e){try{v(e)}catch(r){throw r instanceof Error&&r.message.startsWith("profile not found:")?u(`profile not found: ${e}`,{received:e}):r}}n(f,"requireProfileExists");async function P(e,r){return(await d(await a(e,r))).filter(t=>!i(t))}n(P,"listProfileEnvNames");async function O(e,r,t,o){if(i(r))throw s(`env var name is reserved by crtr: ${r}`,{received:r,field:"name",next:"crtr identity/routing names (CRTR_* and HOME) cannot be stored in a profile env store \u2014 a stored value under one of these names could redirect a broker to a different canvas home. Choose a different name."});if(h(t))throw s("env var value contains a NUL byte, which no OS accepts in an environment variable",{field:"value",next:"Remove NUL bytes from the piped value and retry."});return f(e),await l(await a(e,o),r,t)}n(O,"setProfileEnvVar");async function g(e,r,t){return f(e),await y(await a(e,t),r)}n(g,"removeProfileEnvVar");async function k(e,r){if(e===null||e==="")return{};const t=await w(await a(e,r));for(const o of Object.keys(t))i(o)&&delete t[o];return t}n(k,"readProfileEnvVars");export{P as listProfileEnvNames,k as readProfileEnvVars,g as removeProfileEnvVar,O as setProfileEnvVar};
@@ -55,11 +55,7 @@ export declare function resolveProfileOperand(operand: string): ProfileEntry;
55
55
  /** `resolveProfileOperand` over any candidate list — the CLI passes the
56
56
  * profiles the daemon lists for its caller. */
57
57
  export declare function matchProfileOperand<T>(all: readonly T[], operand: string, key: CandidateOf<T>): T;
58
- /** Hold the per-profile manifest lock for the duration of `fn`. ALL manifest
59
- * mutations (create/rename/add-project/remove-project/delete/last-used)
60
- * below run inside this. */
61
- export declare function withProfileManifestLock<T>(profileId: string, fn: () => T): T;
62
- export declare function ensureRootProfile(): ProfileEntry;
58
+ export declare function ensureRootProfile(): Promise<ProfileEntry>;
63
59
  /** The env name a metadata entry surfaces as (spawn-env source F). Also the
64
60
  * uniqueness domain for keys: the fold is lossy (`a-b`, `a_b`, `A_B` →
65
61
  * `CRTR_PROFILE_META_A_B`), so two stored keys may not share a fold. */
@@ -77,9 +73,9 @@ export declare function createProfile(name: string, projects?: ProfileProject[],
77
73
  defaultKind?: string;
78
74
  metadata?: Record<string, string>;
79
75
  grantee?: string;
80
- }): ProfileEntry;
81
- export declare function ensureAppProfile(grantee: string): ProfileEntry;
82
- export declare function updateProfileLastUsed(profileId: string): ProfileEntry;
76
+ }): Promise<ProfileEntry>;
77
+ export declare function ensureAppProfile(grantee: string): Promise<ProfileEntry>;
78
+ export declare function updateProfileLastUsed(profileId: string): Promise<ProfileEntry>;
83
79
  /** Paused check for an ALREADY-RESOLVED durable id (a canvas row's `profile_id`,
84
80
  * `CRTR_PROFILE_ID`) — exact-id only, no name matching, so it costs one small
85
81
  * read on the hot delivery paths that call it every poll. Fails OPEN: an id
@@ -92,14 +88,14 @@ export declare function pausedCanvasProfiles(): Set<string>;
92
88
  * every gate that already holds a loaded manifest. */
93
89
  export declare function assertProfileEntryActive(entry: ProfileEntry): void;
94
90
  export declare function assertProfileActive(profileId: string | null | undefined): ProfileEntry | null;
95
- export declare function pauseProfile(profileId: string): ProfileEntry;
96
- export declare function resumeProfile(profileId: string): ProfileEntry & {
91
+ export declare function pauseProfile(profileId: string): Promise<ProfileEntry>;
92
+ export declare function resumeProfile(profileId: string): Promise<ProfileEntry & {
97
93
  pausedAt: string | null;
98
- };
99
- export declare function setProfileDefaultKind(profileId: string, defaultKind: string): ProfileEntry;
94
+ }>;
95
+ export declare function setProfileDefaultKind(profileId: string, defaultKind: string): Promise<ProfileEntry>;
100
96
  /** Merge `set` entries over the stored map and drop `unset` keys; the
101
97
  * `metadata` field is omitted entirely when the result is empty. */
102
- export declare function updateProfileMetadata(profileId: string, set: Record<string, string>, unset?: string[]): ProfileEntry;
98
+ export declare function updateProfileMetadata(profileId: string, set: Record<string, string>, unset?: string[]): Promise<ProfileEntry>;
103
99
  /** A profile's stored metadata for broker-env injection — sanitized entry by
104
100
  * entry (a manifest is hand-editable, so a bad key/value is dropped rather
105
101
  * than trusted) and never throwing: a stale/invalid/absent profile id is a
@@ -109,12 +105,12 @@ export declare function readProfileMetadata(profileId: string | null): Record<st
109
105
  /** Change the manifest `name` only. Callers that own the canvas (the daemon's
110
106
  * `PATCH /v1/profiles/:name`) must also rename the profile's canvas handle —
111
107
  * use `renameProfileAndHandle` there; the CLI and panels go through that route. */
112
- export declare function renameProfile(profileId: string, name: string): ProfileEntry;
108
+ export declare function renameProfile(profileId: string, name: string): Promise<ProfileEntry>;
113
109
  /** A new path appends; a path already listed keeps its position. */
114
- export declare function addProfileProject(profileId: string, dir: string): ProfileEntry;
110
+ export declare function addProfileProject(profileId: string, dir: string): Promise<ProfileEntry>;
115
111
  /** Set one owner's automatic delivery limit. `content` is the uncapped level,
116
112
  * so it removes the owner's entry instead of storing it. */
117
- export declare function setProfileDeliveryLimit(profileId: string, owner: string, level: ProfileProjectMemory): ProfileEntry;
118
- export declare function removeProfileProject(profileId: string, dir: string): ProfileEntry;
119
- export declare function deleteProfile(profileId: string): void;
113
+ export declare function setProfileDeliveryLimit(profileId: string, owner: string, level: ProfileProjectMemory): Promise<ProfileEntry>;
114
+ export declare function removeProfileProject(profileId: string, dir: string): Promise<ProfileEntry>;
115
+ export declare function deleteProfile(profileId: string): Promise<void>;
120
116
  export {};
@@ -1 +1 @@
1
- var Y=Object.defineProperty;var o=(e,t)=>Y(e,"name",{value:t,configurable:!0});import{randomUUID as G}from"node:crypto";import{existsSync as W,realpathSync as b,rmSync as S,statSync as B}from"node:fs";import{join as A,resolve as E}from"node:path";import{SCHEMA_VERSION as R}from"../../types.js";import{profileSpace as g}from"../layout.js";import{PROFILE_PROJECT_MEMORY_VALUES as O}from"../../api/dto/profiles.js";import{userScopeRoot as c}from"../scope.js";import{ensureDir as k,nowIso as m}from"../fs-utils.js";import{deleteStoredProfile as Q,getStoredProfile as h,insertStoredProfile as M,listStoredProfiles as X,pausedProfileIds as I,profilePaused as ee,updateStoredProfile as te}from"../scoped-state/profiles.js";import{usage as f,notFound as d,ambiguous as D,general as L}from"../errors.js";import{withExclusiveDirectoryLock as re}from"../exclusive-lock.js";import{fuzzyMatchProfile as ne}from"./fuzzy-match.js";const N=/^[a-z0-9]+(?:-[a-z0-9]+)*-[0-9a-f]{8}$/,p="root-00000000",oe="root";function P(e){return e.grantee??"app:terminal"}o(P,"profileApp");function w(e,t){k(g(P(t),e).dir)}o(w,"scaffoldProfile");function y(e){if(!N.test(e))throw f(`invalid profile id: ${e}`,{received:e,next:"Profile ids look like <slug>-<8-hex-chars> (as printed by `crtr profile new`). Pass an exact id or a profile name, not a raw path."})}o(y,"assertSafeProfileId");function Ee(e){y(e);const t=h(c(),e);if(t===null)throw d(`profile not found: ${e}`,{received:e});return g(P(t.manifest),e).dir}o(Ee,"profileDir");function z(e){if(!Array.isArray(e))throw f("projects must be an array of {path} objects",{received:typeof e,field:"projects",next:'Pass entries like {"path": "/abs/dir"}.'});for(const t of e){if(typeof t!="object"||t===null||Array.isArray(t))throw f(`invalid project entry: ${JSON.stringify(t)}`,{field:"projects",next:'Every project is an object like {"path": "/abs/dir"}.'});const{path:r}=t;if(typeof r!="string"||r.trim()==="")throw f(`project entry has no path: ${JSON.stringify(t)}`,{field:"projects",next:"Give every project entry a non-empty directory path."})}}o(z,"assertProfileProjects");function ie(e){const t=O.join(", ");if(typeof e!="object"||e===null||Array.isArray(e))throw f("delivery_limits must be an object mapping owner handles to a level",{received:typeof e,field:"delivery_limits",next:`Pass e.g. {"crouter": "preview"} \u2014 each level is one of: ${t}.`});for(const[r,n]of Object.entries(e)){if(r.trim()==="")throw f("delivery_limits has an empty owner handle",{field:"delivery_limits",next:"Key each limit by an owner handle such as a repo handle or `user`, or exactly by `<type>:<handle>` such as `repo:crouter`."});if(typeof n!="string"||!O.includes(n))throw f(`invalid delivery limit for ${r}: ${JSON.stringify(n)}`,{received:String(n),field:"delivery_limits",next:`Set ${r} to one of: ${t}.`})}}o(ie,"assertDeliveryLimits");function ae(){return{entries:X(c()),unreadableIds:[]}}o(ae,"enumerateProfiles");function x(){return ae().entries}o(x,"listProfiles");function se(e){const t=x(),r=J(t,e,$);return r?{kind:"resolved",entry:r}:{kind:"absent"}}o(se,"lookupProfile");function C(e){y(e);const t=h(c(),e);if(t!==null)return t;throw d(`profile not found: ${e}`,{received:e,next:"Run `crtr profile list` to see available profiles."})}o(C,"loadExactProfileManifest");const $=o(e=>({profileId:e.profileId,name:e.manifest.name}),"entryCandidate");function J(e,t,r){if(N.test(t)){const i=e.find(a=>r(a).profileId===t);if(i!==void 0)return i}const n=e.filter(i=>r(i).name===t);if(n.length===1)return n[0];if(n.length>1){const i=n.map(a=>r(a).profileId);throw D(`profile name "${t}" matches ${i.length} profiles: ${i.join(", ")}`,{received:t,candidates:i,next:`Re-run with one exact profile id: ${i.join(", ")}.`})}return null}o(J,"findExactProfile");function T(e,t,r){const n=e.map(i=>`${r(i).profileId} (${r(i).name})`);return d(`profile not found: ${t}`,{received:t,available:n,next:n.length>0?`Re-run with one of the profiles on this host: ${n.join(", ")} \u2014 or create one with \`crtr profile new --name <name>\`.`:"No profiles exist on this host yet \u2014 create one with `crtr profile new --name <name>`."})}o(T,"profileNotFound");function fe(e){const t=se(e);if(t.kind==="resolved")return t.entry;throw T(x(),e,$)}o(fe,"loadProfileManifest");function Re(e){return le(x(),e,$)}o(Re,"resolveProfileOperand");function le(e,t,r){const n=J(e,t,r);if(n!==null)return n;const{match:i,tied:a}=ne(t,e.map(r));if(i!==null){const s=e.find(l=>r(l).profileId===i.profileId);return console.error(`crtr: no profile named "${t}" \u2014 using the closest match: ${r(s).name} (${r(s).profileId})`),s}if(a.length>1){const s=a.map(l=>`${l.profileId} (${l.name})`);throw D(`"${t}" is equally close to ${a.length} profiles: ${s.join(", ")}`,{received:t,candidates:a.map(l=>l.profileId),next:`Re-run with one exact profile id or name: ${s.join(", ")}.`})}throw T(e,t,r)}o(le,"matchProfileOperand");function U(){return A(c(),"profile-locks")}o(U,"locksDir");function v(e,t){return y(e),k(U()),re(A(U(),`${e}.lock`),t,{timeoutError:o(()=>L(`timed out waiting for the profile lock: ${e}`,{next:"Retry \u2014 another `crtr profile` command may be running concurrently on this profile."}),"timeoutError")})}o(v,"withProfileManifestLock");function F(e){const t=E(e);if(!W(t)||!B(t).isDirectory())throw f(`project directory does not exist or is not a directory: ${e}`,{received:e,next:"Pass an existing directory path."});try{return b(t)}catch{return t}}o(F,"resolveExistingProjectDir");function K(e){const t=new Set,r=[];for(const n of e)t.has(n.path)||(t.add(n.path),r.push(n));return r}o(K,"dedupeProjects");function ce(e){let t=e.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"");return t.length>40&&(t=t.slice(0,40).replace(/-+$/g,"")),t.length>0?t:"profile"}o(ce,"slugify");function ue(e){const t=ce(e);for(let r=0;r<20;r++){const n=G().replace(/-/g,"").slice(0,8),i=`${t}-${n}`;if(h(c(),i)===null)return i}throw L(`failed to generate a unique profile id for "${e}" after 20 attempts`)}o(ue,"generateProfileId");function Oe(){return v(p,()=>{const e=h(c(),p);if(e!==null)return w(p,e.manifest),e;const t={schema_version:R,name:oe,projects:[],grantee:"app:terminal",paused_at:null,created_at:m(),last_used_at:m()};return w(p,t),M(c(),{profileId:p,manifest:t}),{profileId:p,manifest:t}})}o(Oe,"ensureRootProfile");const q=/^[A-Za-z0-9][A-Za-z0-9_-]*$/;function H(e){return`CRTR_PROFILE_META_${e.toUpperCase().replace(/[^A-Z0-9]+/g,"_")}`}o(H,"metadataEnvName");function _(e){if(typeof e!="object"||e===null||Array.isArray(e))throw f("metadata must be a map of string keys to string values",{field:"metadata",next:'Pass an object, e.g. {"role": "support"}.'});const t=new Map;for(const[r,n]of Object.entries(e)){if(!q.test(r))throw f(`invalid metadata key: ${JSON.stringify(r)}`,{received:r,field:"metadata",next:"Keys start with a letter or digit, followed by letters, digits, `_`, or `-`."});if(typeof n!="string")throw f(`metadata value for ${r} must be a string`,{received:typeof n,field:"metadata",next:"Every metadata value is an env-var value \u2014 pass strings only."});if(n.includes("\0"))throw f(`metadata value for ${r} contains a NUL byte, which no OS accepts in an environment variable`,{field:"metadata",next:"Remove NUL bytes from the value and retry."});const i=H(r),a=t.get(i);if(a!==void 0)throw f(`metadata keys ${JSON.stringify(a)} and ${JSON.stringify(r)} both surface as ${i}`,{field:"metadata",next:"Rename or drop one \u2014 keys must stay distinct after uppercasing and `_`-folding."});t.set(i,r)}}o(_,"assertProfileMetadata");function Z(e){if(typeof e!="object"||e===null||Array.isArray(e))return{};const t={},r=new Set;for(const[n,i]of Object.entries(e)){if(typeof i!="string"||!q.test(n)||i.includes("\0"))continue;const a=H(n);r.has(a)||(r.add(a),t[n]=i)}return t}o(Z,"sanitizeProfileMetadata");function de(e,t=[],r={}){const n=e.trim();if(n==="")throw f("profile name must not be empty");r.metadata!==void 0&&_(r.metadata),z(t);const i=K(t.map(s=>({path:F(s.path)}))),a=ue(n);return v(a,()=>{const s={schema_version:R,name:n,projects:i,paused_at:null,...r.grantee===void 0?{}:{grantee:r.grantee},...r.defaultKind!==void 0?{default_kind:r.defaultKind}:{},...r.metadata!==void 0&&Object.keys(r.metadata).length>0?{metadata:{...r.metadata}}:{},created_at:m(),last_used_at:null};return w(a,s),M(c(),{profileId:a,manifest:s}),{profileId:a,manifest:s}})}o(de,"createProfile");function ke(e){if(!e.startsWith("app:")||e.length<=4)throw f("an app grantee is required");const t=`app-${e.slice(4)}`,r=x().filter(n=>n.manifest.name===t&&n.manifest.grantee===e);if(r.length>1)throw new Error(`duplicate default profile for ${e}`);return r[0]?r[0]:de(t,[],{grantee:e})}o(ke,"ensureAppProfile");function V(e){if(y(e),h(c(),e)===null)throw d(`profile not found: ${e}`,{received:e,next:"Run `crtr profile list` to see available profiles."})}o(V,"requireExistingProfile");function u(e,t){return V(e),v(e,()=>{const r=te(c(),e,t);if(r===null)throw d(`profile not found: ${e}`,{received:e});return r})}o(u,"mutateManifest");function Me(e){return u(e,t=>({...t,last_used_at:m()}))}o(Me,"updateProfileLastUsed");function pe(e){if(e==null||e==="")return null;try{return fe(e)}catch{return null}}o(pe,"loadProfileManifestOrNull");function De(e){if(e==null||e==="")return!1;try{return y(e),ee(c(),e)}catch{return!1}}o(De,"isProfilePaused");function Le(){return I(c())}o(Le,"pausedCanvasProfiles");function me(e){if(e.manifest.paused_at!==null)throw f(`profile "${e.manifest.name}" is paused and cannot start nodes`,{received:e.profileId,next:`Resume it with \`crtr profile resume ${e.profileId}\`.`})}o(me,"assertProfileEntryActive");function Ne(e){const t=pe(e);return t===null?null:(me(t),t)}o(Ne,"assertProfileActive");function ze(e){return u(e,t=>({...t,paused_at:t.paused_at??m()}))}o(ze,"pauseProfile");function Ce(e){let t=null;return{...u(e,n=>(t=n.paused_at,{...n,paused_at:null})),pausedAt:t}}o(Ce,"resumeProfile");function Je(e,t){return u(e,r=>({...r,default_kind:t}))}o(Je,"setProfileDefaultKind");function Te(e,t,r=[]){return _(t),u(e,n=>{const i={...Z(n.metadata),...t};for(const l of r)delete i[l];_(i);const{metadata:a,...s}=n;return{...s,...Object.keys(i).length>0?{metadata:i}:{}}})}o(Te,"updateProfileMetadata");function Ue(e){if(e===null||e==="")return{};try{return Z(C(e).manifest.metadata)}catch{return{}}}o(Ue,"readProfileMetadata");function Fe(e,t){const r=t.trim();if(r==="")throw f("profile name must not be empty");return u(e,i=>({...i,name:r}))}o(Fe,"renameProfile");function Ke(e,t){z([{path:t}]);const r=F(t);return u(e,i=>({...i,projects:K([...i.projects,{path:r}])}))}o(Ke,"addProfileProject");function qe(e,t,r){return ie({[t]:r}),u(e,n=>{const{[t]:i,...a}=n.delivery_limits??{},s=r==="content"?a:{...a,[t]:r},{delivery_limits:l,...j}=n;return Object.keys(s).length===0?j:{...j,delivery_limits:s}})}o(qe,"setProfileDeliveryLimit");function He(e,t){const r=E(t);let n=r;try{n=b(r)}catch{}return u(e,a=>{const s=a.projects.filter(l=>l.path!==n&&l.path!==r);if(s.length===a.projects.length)throw d(`project not found on profile: ${t}`,{received:t,next:`Current projects: ${a.projects.length>0?a.projects.map(l=>l.path).join(", "):"(none)"}.`});return{...a,projects:s}})}o(He,"removeProfileProject");function Ze(e){V(e),v(e,()=>{const t=g(P(C(e).manifest),e);if(!Q(c(),e))throw d(`profile not found: ${e}`,{received:e});S(t.dir,{recursive:!0,force:!0}),S(t.env,{force:!0})})}o(Ze,"deleteProfile");export{p as ROOT_PROFILE_ID,Ke as addProfileProject,ie as assertDeliveryLimits,Ne as assertProfileActive,me as assertProfileEntryActive,_ as assertProfileMetadata,z as assertProfileProjects,de as createProfile,Ze as deleteProfile,ke as ensureAppProfile,Oe as ensureRootProfile,De as isProfilePaused,x as listProfiles,C as loadExactProfileManifest,fe as loadProfileManifest,se as lookupProfile,le as matchProfileOperand,H as metadataEnvName,ze as pauseProfile,Le as pausedCanvasProfiles,Ee as profileDir,Ue as readProfileMetadata,He as removeProfileProject,Fe as renameProfile,Re as resolveProfileOperand,Ce as resumeProfile,Z as sanitizeProfileMetadata,Je as setProfileDefaultKind,qe as setProfileDeliveryLimit,Me as updateProfileLastUsed,Te as updateProfileMetadata,v as withProfileManifestLock};
1
+ var F=Object.defineProperty;var o=(e,t)=>F(e,"name",{value:t,configurable:!0});import{randomUUID as K}from"node:crypto";import{existsSync as q,realpathSync as b,rmSync as A,statSync as H}from"node:fs";import{resolve as E}from"node:path";import{SCHEMA_VERSION as S}from"../../types.js";import{profileSpace as v}from"../layout.js";import{PROFILE_PROJECT_MEMORY_VALUES as O}from"../../api/dto/profiles.js";import{ensureDir as Z,nowIso as m}from"../fs-utils.js";import{cachedPausedProfileIds as V,cachedProfilePaused as Y,getCachedProfile as d,listCachedProfiles as G,writeSettings as h}from"../scoped-state/person-store.js";import{usage as f,notFound as u,ambiguous as R,general as W}from"../errors.js";import{fuzzyMatchProfile as B}from"./fuzzy-match.js";const x=/^[a-z0-9]+(?:-[a-z0-9]+)*-[0-9a-f]{8}$/,p="root-00000000",Q="root";function w(e){return e.grantee??"app:terminal"}o(w,"profileApp");function g(e,t){Z(v(w(t),e).dir)}o(g,"scaffoldProfile");function P(e){if(!x.test(e))throw f(`invalid profile id: ${e}`,{received:e,next:"Profile ids look like <slug>-<8-hex-chars> (as printed by `crtr profile new`). Pass an exact id or a profile name, not a raw path."})}o(P,"assertSafeProfileId");function we(e){P(e);const t=d(e);if(t===null)throw u(`profile not found: ${e}`,{received:e});return v(w(t.manifest),e).dir}o(we,"profileDir");function M(e){if(!Array.isArray(e))throw f("projects must be an array of {path} objects",{received:typeof e,field:"projects",next:'Pass entries like {"path": "/abs/dir"}.'});for(const t of e){if(typeof t!="object"||t===null||Array.isArray(t))throw f(`invalid project entry: ${JSON.stringify(t)}`,{field:"projects",next:'Every project is an object like {"path": "/abs/dir"}.'});const{path:r}=t;if(typeof r!="string"||r.trim()==="")throw f(`project entry has no path: ${JSON.stringify(t)}`,{field:"projects",next:"Give every project entry a non-empty directory path."})}}o(M,"assertProfileProjects");function X(e){const t=O.join(", ");if(typeof e!="object"||e===null||Array.isArray(e))throw f("delivery_limits must be an object mapping owner handles to a level",{received:typeof e,field:"delivery_limits",next:`Pass e.g. {"crouter": "preview"} \u2014 each level is one of: ${t}.`});for(const[r,n]of Object.entries(e)){if(r.trim()==="")throw f("delivery_limits has an empty owner handle",{field:"delivery_limits",next:"Key each limit by an owner handle such as a repo handle or `user`, or exactly by `<type>:<handle>` such as `repo:crouter`."});if(typeof n!="string"||!O.includes(n))throw f(`invalid delivery limit for ${r}: ${JSON.stringify(n)}`,{received:String(n),field:"delivery_limits",next:`Set ${r} to one of: ${t}.`})}}o(X,"assertDeliveryLimits");function I(){return{entries:G(),unreadableIds:[]}}o(I,"enumerateProfiles");function y(){return I().entries}o(y,"listProfiles");function ee(e){const t=y(),r=C(t,e,$);return r?{kind:"resolved",entry:r}:{kind:"absent"}}o(ee,"lookupProfile");function k(e){P(e);const t=d(e);if(t!==null)return t;throw u(`profile not found: ${e}`,{received:e,next:"Run `crtr profile list` to see available profiles."})}o(k,"loadExactProfileManifest");const $=o(e=>({profileId:e.profileId,name:e.manifest.name}),"entryCandidate");function C(e,t,r){if(x.test(t)){const i=e.find(a=>r(a).profileId===t);if(i!==void 0)return i}const n=e.filter(i=>r(i).name===t);if(n.length===1)return n[0];if(n.length>1){const i=n.map(a=>r(a).profileId);throw R(`profile name "${t}" matches ${i.length} profiles: ${i.join(", ")}`,{received:t,candidates:i,next:`Re-run with one exact profile id: ${i.join(", ")}.`})}return null}o(C,"findExactProfile");function D(e,t,r){const n=e.map(i=>`${r(i).profileId} (${r(i).name})`);return u(`profile not found: ${t}`,{received:t,available:n,next:n.length>0?`Re-run with one of the profiles on this host: ${n.join(", ")} \u2014 or create one with \`crtr profile new --name <name>\`.`:"No profiles exist on this host yet \u2014 create one with `crtr profile new --name <name>`."})}o(D,"profileNotFound");function te(e){const t=ee(e);if(t.kind==="resolved")return t.entry;throw D(y(),e,$)}o(te,"loadProfileManifest");function ge(e){return re(y(),e,$)}o(ge,"resolveProfileOperand");function re(e,t,r){const n=C(e,t,r);if(n!==null)return n;const{match:i,tied:a}=B(t,e.map(r));if(i!==null){const s=e.find(c=>r(c).profileId===i.profileId);return console.error(`crtr: no profile named "${t}" \u2014 using the closest match: ${r(s).name} (${r(s).profileId})`),s}if(a.length>1){const s=a.map(c=>`${c.profileId} (${c.name})`);throw R(`"${t}" is equally close to ${a.length} profiles: ${s.join(", ")}`,{received:t,candidates:a.map(c=>c.profileId),next:`Re-run with one exact profile id or name: ${s.join(", ")}.`})}throw D(e,t,r)}o(re,"matchProfileOperand");function L(e){const t=E(e);if(!q(t)||!H(t).isDirectory())throw f(`project directory does not exist or is not a directory: ${e}`,{received:e,next:"Pass an existing directory path."});try{return b(t)}catch{return t}}o(L,"resolveExistingProjectDir");function N(e){const t=new Set,r=[];for(const n of e)t.has(n.path)||(t.add(n.path),r.push(n));return r}o(N,"dedupeProjects");function ne(e){let t=e.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"");return t.length>40&&(t=t.slice(0,40).replace(/-+$/g,"")),t.length>0?t:"profile"}o(ne,"slugify");function oe(e){const t=ne(e);for(let r=0;r<20;r++){const n=K().replace(/-/g,"").slice(0,8),i=`${t}-${n}`;if(d(i)===null)return i}throw W(`failed to generate a unique profile id for "${e}" after 20 attempts`)}o(oe,"generateProfileId");async function Pe(){const e=d(p);if(e!==null)return g(p,e.manifest),e;const t={schema_version:S,name:Q,projects:[],grantee:"app:terminal",paused_at:null,created_at:m(),last_used_at:m()};return g(p,t),await h(r=>r.profiles.some(n=>n.profileId===p)?[]:[{op:"profile.insert",profile:{profileId:p,manifest:t}}]),d(p)}o(Pe,"ensureRootProfile");const z=/^[A-Za-z0-9][A-Za-z0-9_-]*$/;function J(e){return`CRTR_PROFILE_META_${e.toUpperCase().replace(/[^A-Z0-9]+/g,"_")}`}o(J,"metadataEnvName");function _(e){if(typeof e!="object"||e===null||Array.isArray(e))throw f("metadata must be a map of string keys to string values",{field:"metadata",next:'Pass an object, e.g. {"role": "support"}.'});const t=new Map;for(const[r,n]of Object.entries(e)){if(!z.test(r))throw f(`invalid metadata key: ${JSON.stringify(r)}`,{received:r,field:"metadata",next:"Keys start with a letter or digit, followed by letters, digits, `_`, or `-`."});if(typeof n!="string")throw f(`metadata value for ${r} must be a string`,{received:typeof n,field:"metadata",next:"Every metadata value is an env-var value \u2014 pass strings only."});if(n.includes("\0"))throw f(`metadata value for ${r} contains a NUL byte, which no OS accepts in an environment variable`,{field:"metadata",next:"Remove NUL bytes from the value and retry."});const i=J(r),a=t.get(i);if(a!==void 0)throw f(`metadata keys ${JSON.stringify(a)} and ${JSON.stringify(r)} both surface as ${i}`,{field:"metadata",next:"Rename or drop one \u2014 keys must stay distinct after uppercasing and `_`-folding."});t.set(i,r)}}o(_,"assertProfileMetadata");function T(e){if(typeof e!="object"||e===null||Array.isArray(e))return{};const t={},r=new Set;for(const[n,i]of Object.entries(e)){if(typeof i!="string"||!z.test(n)||i.includes("\0"))continue;const a=J(n);r.has(a)||(r.add(a),t[n]=i)}return t}o(T,"sanitizeProfileMetadata");async function ie(e,t=[],r={}){const n=e.trim();if(n==="")throw f("profile name must not be empty");r.metadata!==void 0&&_(r.metadata),M(t);const i=N(t.map(c=>({path:L(c.path)}))),a=oe(n),s={schema_version:S,name:n,projects:i,paused_at:null,...r.grantee===void 0?{}:{grantee:r.grantee},...r.defaultKind!==void 0?{default_kind:r.defaultKind}:{},...r.metadata!==void 0&&Object.keys(r.metadata).length>0?{metadata:{...r.metadata}}:{},created_at:m(),last_used_at:null};return g(a,s),await h(()=>[{op:"profile.insert",profile:{profileId:a,manifest:s}}]),{profileId:a,manifest:s}}o(ie,"createProfile");async function $e(e){if(!e.startsWith("app:")||e.length<=4)throw f("an app grantee is required");const t=`app-${e.slice(4)}`,r=y().filter(n=>n.manifest.name===t&&n.manifest.grantee===e);if(r.length>1)throw new Error(`duplicate default profile for ${e}`);return r[0]?r[0]:await ie(t,[],{grantee:e})}o($e,"ensureAppProfile");function U(e){if(P(e),d(e)===null)throw u(`profile not found: ${e}`,{received:e,next:"Run `crtr profile list` to see available profiles."})}o(U,"requireExistingProfile");async function l(e,t){U(e);let r;return await h(n=>{const i=n.profiles.find(a=>a.profileId===e);if(i===void 0)throw u(`profile not found: ${e}`,{received:e});return r={profileId:e,manifest:t(structuredClone(i.manifest))},[{op:"profile.update",profile:r}]}),r}o(l,"mutateManifest");async function _e(e){return await l(e,t=>({...t,last_used_at:m()}))}o(_e,"updateProfileLastUsed");function ae(e){if(e==null||e==="")return null;try{return te(e)}catch{return null}}o(ae,"loadProfileManifestOrNull");function je(e){return e==null||e===""||!x.test(e)?!1:Y(e)}o(je,"isProfilePaused");function be(){return V()}o(be,"pausedCanvasProfiles");function se(e){if(e.manifest.paused_at!==null)throw f(`profile "${e.manifest.name}" is paused and cannot start nodes`,{received:e.profileId,next:`Resume it with \`crtr profile resume ${e.profileId}\`.`})}o(se,"assertProfileEntryActive");function Ae(e){const t=ae(e);return t===null?null:(se(t),t)}o(Ae,"assertProfileActive");async function Ee(e){return await l(e,t=>({...t,paused_at:t.paused_at??m()}))}o(Ee,"pauseProfile");async function Se(e){let t=null;return{...await l(e,n=>(t=n.paused_at,{...n,paused_at:null})),pausedAt:t}}o(Se,"resumeProfile");async function Oe(e,t){return await l(e,r=>({...r,default_kind:t}))}o(Oe,"setProfileDefaultKind");async function Re(e,t,r=[]){return _(t),await l(e,n=>{const i={...T(n.metadata),...t};for(const c of r)delete i[c];_(i);const{metadata:a,...s}=n;return{...s,...Object.keys(i).length>0?{metadata:i}:{}}})}o(Re,"updateProfileMetadata");function Me(e){if(e===null||e==="")return{};try{return T(k(e).manifest.metadata)}catch{return{}}}o(Me,"readProfileMetadata");async function ke(e,t){const r=t.trim();if(r==="")throw f("profile name must not be empty");return await l(e,i=>({...i,name:r}))}o(ke,"renameProfile");async function Ce(e,t){M([{path:t}]);const r=L(t);return await l(e,i=>({...i,projects:N([...i.projects,{path:r}])}))}o(Ce,"addProfileProject");async function De(e,t,r){return X({[t]:r}),await l(e,n=>{const{[t]:i,...a}=n.delivery_limits??{},s=r==="content"?a:{...a,[t]:r},{delivery_limits:c,...j}=n;return Object.keys(s).length===0?j:{...j,delivery_limits:s}})}o(De,"setProfileDeliveryLimit");async function Le(e,t){const r=E(t);let n=r;try{n=b(r)}catch{}return await l(e,a=>{const s=a.projects.filter(c=>c.path!==n&&c.path!==r);if(s.length===a.projects.length)throw u(`project not found on profile: ${t}`,{received:t,next:`Current projects: ${a.projects.length>0?a.projects.map(c=>c.path).join(", "):"(none)"}.`});return{...a,projects:s}})}o(Le,"removeProfileProject");async function Ne(e){U(e);const t=v(w(k(e).manifest),e);await h(r=>{if(!r.profiles.some(n=>n.profileId===e))throw u(`profile not found: ${e}`,{received:e});return[{op:"profile.delete",profileId:e}]}),A(t.dir,{recursive:!0,force:!0}),A(t.env,{force:!0})}o(Ne,"deleteProfile");export{p as ROOT_PROFILE_ID,Ce as addProfileProject,X as assertDeliveryLimits,Ae as assertProfileActive,se as assertProfileEntryActive,_ as assertProfileMetadata,M as assertProfileProjects,ie as createProfile,Ne as deleteProfile,$e as ensureAppProfile,Pe as ensureRootProfile,je as isProfilePaused,y as listProfiles,k as loadExactProfileManifest,te as loadProfileManifest,ee as lookupProfile,re as matchProfileOperand,J as metadataEnvName,Ee as pauseProfile,be as pausedCanvasProfiles,we as profileDir,Me as readProfileMetadata,Le as removeProfileProject,ke as renameProfile,ge as resolveProfileOperand,Se as resumeProfile,T as sanitizeProfileMetadata,Oe as setProfileDefaultKind,De as setProfileDeliveryLimit,_e as updateProfileLastUsed,Re as updateProfileMetadata};
@@ -1 +1 @@
1
- var g=Object.defineProperty;var p=(e,s)=>g(e,"name",{value:s,configurable:!0});import{existsSync as f,mkdirSync as w,readdirSync as m,renameSync as d,rmdirSync as l,statSync as u}from"node:fs";import{join as c}from"node:path";import{appSpace as y,appsRoot as h}from"../layout.js";import{userScopeRoot as S}from"../scope.js";import{prepared as $}from"../sqlite-statements.js";import{withScopedWrite as R}from"../scoped-state/db.js";import{canonicalRoot as D,userStore as _}from"../scoped-state/paths.js";import{listStoredProfiles as T}from"../scoped-state/profiles.js";function E(e,s,t){for(const o of m(e)){const r=c(e,o),i=c(s,o);if(!f(i)){d(r,i);continue}if(u(r).isDirectory()&&u(i).isDirectory()){E(r,i,t);try{l(r)}catch{t.push(r)}}else t.push(r)}}p(E,"mergeInto");function I(){const e=[];if(f(h()))for(const t of m(h(),{withFileTypes:!0})){if(!t.isDirectory()||!/^[a-zA-Z0-9][a-zA-Z0-9._-]*$/.test(t.name))continue;const o=y(t.name),r=c(o.root,"memory","profiles");if(f(r)){if(!f(o.profiles))d(r,o.profiles),e.push(`profile folders: moved ${r} to ${o.profiles}`);else{const i=[];E(r,o.profiles,i);try{l(r)}catch{}e.push(`profile folders: merged ${r} into ${o.profiles}`);for(const n of i)e.push(`profile folders: left ${n} in place; ${o.profiles} already holds that name`)}try{l(c(o.root,"memory"))}catch{}}}const s=T(S());return s.length>0&&R(_(S()),t=>{for(const{profileId:o,manifest:r}of s){const i=c(y(r.grantee??"app:terminal").profiles,o);w(i,{recursive:!0});const n=D(i),a=$(t,"SELECT root FROM scope_owners WHERE owner_key=?").get(`profile:${o}`);a!==void 0&&a.root!==n&&($(t,"UPDATE scope_owners SET root=? WHERE owner_key=?").run(n,`profile:${o}`),e.push(`profile folders: settings root of ${o} is now ${n}`))}}),e}p(I,"relocateProfileFolders");export{I as relocateProfileFolders};
1
+ var d=Object.defineProperty;var f=(e,i)=>d(e,"name",{value:i,configurable:!0});import{existsSync as n,readdirSync as l,renameSync as a,rmdirSync as p,statSync as m}from"node:fs";import{join as c}from"node:path";import{appSpace as h,appsRoot as y}from"../layout.js";function u(e,i,o){for(const r of l(e)){const t=c(e,r),s=c(i,r);if(!n(s)){a(t,s);continue}if(m(t).isDirectory()&&m(s).isDirectory()){u(t,s,o);try{p(t)}catch{o.push(t)}}else o.push(t)}}f(u,"mergeInto");function x(){const e=[];if(n(y()))for(const i of l(y(),{withFileTypes:!0})){if(!i.isDirectory()||!/^[a-zA-Z0-9][a-zA-Z0-9._-]*$/.test(i.name))continue;const o=h(i.name),r=c(o.root,"memory","profiles");if(n(r)){if(!n(o.profiles))a(r,o.profiles),e.push(`profile folders: moved ${r} to ${o.profiles}`);else{const t=[];u(r,o.profiles,t);try{p(r)}catch{}e.push(`profile folders: merged ${r} into ${o.profiles}`);for(const s of t)e.push(`profile folders: left ${s} in place; ${o.profiles} already holds that name`)}try{p(c(o.root,"memory"))}catch{}}}return e}f(x,"relocateProfileFolders");export{x as relocateProfileFolders};
@@ -1,35 +1,35 @@
1
- var oe=Object.defineProperty;var l=(t,e)=>oe(t,"name",{value:e,configurable:!0});import{spawnSync as ie}from"node:child_process";import{existsSync as se,realpathSync as le}from"node:fs";import{basename as ce,resolve as ae,sep as S}from"node:path";import{createInterface as v}from"node:readline/promises";import{emitKeypressEvents as E}from"node:readline";import{initializeFreshScopedStore as fe}from"../scoped-state/migrate.js";import{userScopeRoot as ue}from"../scope.js";import{listProfiles as A,loadProfileManifest as pe,resolveProfileOperand as de,updateProfileLastUsed as P,createProfile as me,addProfileProject as j,ensureRootProfile as k,ROOT_PROFILE_ID as D}from"./manifest.js";import{getDefaultProfileId as he,setDefaultProfileId as $e,clearDefaultProfile as O}from"./default-binding.js";import{tildify as b}from"../fs-utils.js";import{stdoutColor as M}from"../output.js";import{inTmux as ge}from"../runtime/placement-tmux.js";import{surfaceTmuxStyleArgs as Ie}from"../runtime/surface-bg.js";import{formatBinding as g,matchesTerminalInput as we,resolveUserKeybindings as ye}from"../keybindings/index.js";const xe=["crtr.profile.menu.abort","crtr.profile.menu.up","crtr.profile.menu.down","crtr.profile.menu.select","crtr.profile.menu.accept-default","crtr.profile.menu.slot.1","crtr.profile.menu.slot.2","crtr.profile.menu.slot.3","crtr.profile.menu.slot.4","crtr.profile.menu.slot.5","crtr.profile.menu.slot.6","crtr.profile.menu.slot.7","crtr.profile.menu.slot.8","crtr.profile.menu.slot.9","crtr.profile.menu.create","crtr.profile.menu.search-existing","crtr.profile.menu.use-root","crtr.profile.menu.set-default","crtr.profile.menu.add-directory","crtr.profile.menu.unpin","crtr.profile.menu.manage"],Pe=["crtr.profile.search.abort","crtr.profile.search.back","crtr.profile.search.pick","crtr.profile.search.up","crtr.profile.search.down","crtr.profile.search.delete"];function L(t,e){return{input:e.ctrl===!0||e.meta===!0?e.name??t:t,upArrow:e.name==="up",downArrow:e.name==="down",return:e.name==="return"||e.name==="enter",escape:e.name==="escape",backspace:e.name==="backspace",ctrl:e.ctrl,meta:e.meta,shift:e.shift}}l(L,"profileRawInput");function N(t,e,r){return e.find(n=>we(t,n,r))??null}l(N,"firstProfileMatch");function be(t,e){return N(t,xe,e)}l(be,"resolveProfileMenuAction");function ve(t,e){return N(t,Pe,e)}l(ve,"resolveProfileSearchAction");function Y(t){const e=ae(t);if(!se(e))return e;try{return le(e)}catch{return e}}l(Y,"resolveCwd");function B(t,e){return!!(t===e||t.startsWith(e+S)||e.startsWith(t+S))}l(B,"projectCovers");function F(t,e){return t.manifest.projects.some(r=>B(e,r.path))}l(F,"profileCoversCwd");function T(t,e){return t===null?!1:e===null?!0:t>e}l(T,"isMoreRecent");function W(t){return t.reduce((e,r)=>T(r.manifest.last_used_at,e.manifest.last_used_at)?r:e)}l(W,"pickMostRecent");function U(t){const e=Y(t),r=A().filter(o=>F(o,e)),n=r.filter(o=>o.manifest.projects.some(u=>u.path===e)),s=he(e),i=s===null?null:r.find(o=>o.profileId===s)??null;return{covering:r,exact:n,pinnedId:s,pinned:i}}l(U,"profileSelectionState");function Je(t){const{covering:e,exact:r,pinned:n}=U(t);if(n!==null)return n.profileId;if(r.length===1)return r[0].profileId;const s=r.length>0?r:e;return s.length>0?W(s).profileId:D}l(Je,"selectProfileForCwdReadOnly");function H(){return!!process.stdin.isTTY&&!!process.stdout.isTTY}l(H,"isInteractive");const $=M.dim,x=M.bold,w=M.cyan;function Me(t){return w(x(t))}l(Me,"key");function K(t){if(t===null)return"never used";const e=Date.parse(t);if(Number.isNaN(e))return"used recently";const r=Math.max(0,Math.floor((Date.now()-e)/1e3));if(r<60)return"used just now";const n=Math.floor(r/60);if(n<60)return`used ${n}m ago`;const s=Math.floor(n/60);if(s<24)return`used ${s}h ago`;const i=Math.floor(s/24);if(i<30)return`used ${i}d ago`;const o=Math.floor(i/30);return o<12?`used ${o}mo ago`:`used ${Math.floor(o/12)}y ago`}l(K,"relativeUsed");function Te(t,e){const r=e!==void 0?` ${$(e)}
1
+ var oe=Object.defineProperty;var l=(t,e)=>oe(t,"name",{value:e,configurable:!0});import{spawnSync as ie}from"node:child_process";import{existsSync as se,realpathSync as le}from"node:fs";import{basename as ae,resolve as ce,sep as S}from"node:path";import{createInterface as v}from"node:readline/promises";import{emitKeypressEvents as E}from"node:readline";import{listProfiles as A,loadProfileManifest as fe,resolveProfileOperand as ue,updateProfileLastUsed as P,createProfile as pe,addProfileProject as j,ensureRootProfile as D,ROOT_PROFILE_ID as O}from"./manifest.js";import{getDefaultProfileId as de,setDefaultProfileId as me,clearDefaultProfile as k}from"./default-binding.js";import{tildify as b}from"../fs-utils.js";import{stdoutColor as M}from"../output.js";import{inTmux as he}from"../runtime/placement-tmux.js";import{surfaceTmuxStyleArgs as $e}from"../runtime/surface-bg.js";import{formatBinding as w,matchesTerminalInput as we,resolveUserKeybindings as ge}from"../keybindings/index.js";const Ie=["crtr.profile.menu.abort","crtr.profile.menu.up","crtr.profile.menu.down","crtr.profile.menu.select","crtr.profile.menu.accept-default","crtr.profile.menu.slot.1","crtr.profile.menu.slot.2","crtr.profile.menu.slot.3","crtr.profile.menu.slot.4","crtr.profile.menu.slot.5","crtr.profile.menu.slot.6","crtr.profile.menu.slot.7","crtr.profile.menu.slot.8","crtr.profile.menu.slot.9","crtr.profile.menu.create","crtr.profile.menu.search-existing","crtr.profile.menu.use-root","crtr.profile.menu.set-default","crtr.profile.menu.add-directory","crtr.profile.menu.unpin","crtr.profile.menu.manage"],ye=["crtr.profile.search.abort","crtr.profile.search.back","crtr.profile.search.pick","crtr.profile.search.up","crtr.profile.search.down","crtr.profile.search.delete"];function L(t,e){return{input:e.ctrl===!0||e.meta===!0?e.name??t:t,upArrow:e.name==="up",downArrow:e.name==="down",return:e.name==="return"||e.name==="enter",escape:e.name==="escape",backspace:e.name==="backspace",ctrl:e.ctrl,meta:e.meta,shift:e.shift}}l(L,"profileRawInput");function N(t,e,r){return e.find(n=>we(t,n,r))??null}l(N,"firstProfileMatch");function xe(t,e){return N(t,Ie,e)}l(xe,"resolveProfileMenuAction");function Pe(t,e){return N(t,ye,e)}l(Pe,"resolveProfileSearchAction");function Y(t){const e=ce(t);if(!se(e))return e;try{return le(e)}catch{return e}}l(Y,"resolveCwd");function B(t,e){return!!(t===e||t.startsWith(e+S)||e.startsWith(t+S))}l(B,"projectCovers");function W(t,e){return t.manifest.projects.some(r=>B(e,r.path))}l(W,"profileCoversCwd");function T(t,e){return t===null?!1:e===null?!0:t>e}l(T,"isMoreRecent");function F(t){return t.reduce((e,r)=>T(r.manifest.last_used_at,e.manifest.last_used_at)?r:e)}l(F,"pickMostRecent");function U(t){const e=Y(t),r=A().filter(o=>W(o,e)),n=r.filter(o=>o.manifest.projects.some(u=>u.path===e)),s=de(e),i=s===null?null:r.find(o=>o.profileId===s)??null;return{covering:r,exact:n,pinnedId:s,pinned:i}}l(U,"profileSelectionState");function Ke(t){const{covering:e,exact:r,pinned:n}=U(t);if(n!==null)return n.profileId;if(r.length===1)return r[0].profileId;const s=r.length>0?r:e;return s.length>0?F(s).profileId:O}l(Ke,"selectProfileForCwdReadOnly");function H(){return!!process.stdin.isTTY&&!!process.stdout.isTTY}l(H,"isInteractive");const $=M.dim,x=M.bold,I=M.cyan;function be(t){return I(x(t))}l(be,"key");function K(t){if(t===null)return"never used";const e=Date.parse(t);if(Number.isNaN(e))return"used recently";const r=Math.max(0,Math.floor((Date.now()-e)/1e3));if(r<60)return"used just now";const n=Math.floor(r/60);if(n<60)return`used ${n}m ago`;const s=Math.floor(n/60);if(s<24)return`used ${s}h ago`;const i=Math.floor(s/24);if(i<30)return`used ${i}d ago`;const o=Math.floor(i/30);return o<12?`used ${o}mo ago`:`used ${Math.floor(o/12)}y ago`}l(K,"relativeUsed");function ve(t,e){const r=e!==void 0?` ${$(e)}
2
2
  `:"";process.stdout.write(`
3
3
  ${x(t)}
4
4
  ${r}
5
- `)}l(Te,"writeHeader");function _e(t){const e=t.manifest.projects.length,r=t.manifest.projects[0];return r===void 0?K(t.manifest.last_used_at):e>1?`${b(r.path)} \xB7 ${e} dirs total`:b(r.path)}l(_e,"purviewSummary");const q=w("\u25B8"),z=l(t=>t>0?`\x1B[${t}A\r`:"","cursorUp"),G="\x1B[0J",Ce=/\u001b\[[0-9;]*m/g;function J(t){const e=process.stdout.columns??80,r=t.split(`
6
- `),n=r.length-1;let s=0;for(let i=0;i<n;i++){const o=r[i].replace(Ce,"").length;e>0&&o>e&&(s+=Math.ceil(o/e)-1)}return n+s}l(J,"blockRows");function Re(t,e,r,n,s,i){let o=`
5
+ `)}l(ve,"writeHeader");function Me(t){const e=t.manifest.projects.length,r=t.manifest.projects[0];return r===void 0?K(t.manifest.last_used_at):e>1?`${b(r.path)} \xB7 ${e} dirs total`:b(r.path)}l(Me,"purviewSummary");const q=I("\u25B8"),G=l(t=>t>0?`\x1B[${t}A\r`:"","cursorUp"),J="\x1B[0J",Te=/\u001b\[[0-9;]*m/g;function z(t){const e=process.stdout.columns??80,r=t.split(`
6
+ `),n=r.length-1;let s=0;for(let i=0;i<n;i++){const o=r[i].replace(Te,"").length;e>0&&o>e&&(s+=Math.ceil(o/e)-1)}return n+s}l(z,"blockRows");function _e(t,e,r,n,s,i){let o=`
7
7
  ${x(e)}
8
8
  `;r!==void 0&&(o+=` ${$(r)}
9
9
  `),o+=`
10
- `;let u=0;for(const[h,m]of n.entries()){const a=m.bindingId===void 0?++u:0,d=m.bindingId!==void 0?g(t,m.bindingId):a<=9?g(t,`crtr.profile.menu.slot.${a}`):"",p=h===s?q:" ",f=m.detail!==""?" "+$(m.detail):"",c=m.isDefault?" "+w("\xB7 "+(m.defaultText??"default")):"";o+=` ${p} ${Me(d)} ${m.label}${f}${c}
10
+ `;let u=0;for(const[h,m]of n.entries()){const c=m.bindingId===void 0?++u:0,d=m.bindingId!==void 0?w(t,m.bindingId):c<=9?w(t,`crtr.profile.menu.slot.${c}`):"",p=h===s?q:" ",f=m.detail!==""?" "+$(m.detail):"",a=m.isDefault?" "+I("\xB7 "+(m.defaultText??"default")):"";o+=` ${p} ${be(d)} ${m.label}${f}${a}
11
11
  `}return i!==void 0&&(o+=`
12
12
  ${$(i)}
13
13
  `),o+=`
14
- ${$(`${g(t,"crtr.profile.menu.up")}/${g(t,"crtr.profile.menu.down")} move ${g(t,"crtr.profile.menu.select")} select ${g(t,"crtr.profile.menu.accept-default")} default ${g(t,"crtr.profile.menu.abort")} quit`)}
15
- `,o}l(Re,"renderMenu");function Q(t,e,r,n,s={}){const i=[];n.forEach((u,h)=>{u.bindingId===void 0&&i.push(h)});let o=s.initialIndex??0;return new Promise(u=>{let h=0;const m=l(()=>{const p=Re(t,e,r,n,o,s.hint);process.stdout.write((h>0?z(h)+G:"")+p),h=J(p)},"draw"),a=l(()=>{process.stdin.off("keypress",d),process.stdin.isTTY&&process.stdin.setRawMode(!1),process.stdin.pause()},"cleanup"),d=l((p,f)=>{const c=be(t,L(p,f));if(c==="crtr.profile.menu.abort"&&(a(),process.stdout.write(`
16
- `),process.exit(130)),c==="crtr.profile.menu.up"){o=(o-1+n.length)%n.length,m();return}if(c==="crtr.profile.menu.down"){o=(o+1)%n.length,m();return}if(c==="crtr.profile.menu.select"){a(),u({index:o});return}if(c==="crtr.profile.menu.accept-default"){a(),u({index:s.initialIndex??0});return}if(c?.startsWith("crtr.profile.menu.slot.")){const I=Number.parseInt(c.slice(-1),10);I>=1&&I<=i.length&&(o=i[I-1],m());return}const y=n.findIndex(I=>I.bindingId!==void 0&&I.bindingId===c);if(y>=0){a(),u({index:y});return}c!==null&&s.actionBindingIds?.includes(c)===!0&&(a(),u({index:o,action:c}))},"onKey");E(process.stdin),process.stdin.isTTY&&process.stdin.setRawMode(!0),process.stdin.resume(),process.stdin.on("keypress",d),m()})}l(Q,"runMenu");function V(t){return ge()?(ie("tmux",["display-popup","-E","-T"," profiles ","-w","90%","-h","85%","-d",t,...Ie(),"crtr sys settings --page profiles"],{stdio:"inherit"}),!0):(process.stdout.write(` ${$("the profile manager needs tmux \u2014 run `crtr sys settings` instead")}
17
- `),!1)}l(V,"openProfileManager");const _=Symbol("profile-manager-ran");function X(t){return` ${w("\u203A")} ${$(t)} `}l(X,"caret");function Se(t){return`crtr: no profile covers ${t}, and this session is non-interactive \u2014 using the root profile.
14
+ ${$(`${w(t,"crtr.profile.menu.up")}/${w(t,"crtr.profile.menu.down")} move ${w(t,"crtr.profile.menu.select")} select ${w(t,"crtr.profile.menu.accept-default")} default ${w(t,"crtr.profile.menu.abort")} quit`)}
15
+ `,o}l(_e,"renderMenu");function Q(t,e,r,n,s={}){const i=[];n.forEach((u,h)=>{u.bindingId===void 0&&i.push(h)});let o=s.initialIndex??0;return new Promise(u=>{let h=0;const m=l(()=>{const p=_e(t,e,r,n,o,s.hint);process.stdout.write((h>0?G(h)+J:"")+p),h=z(p)},"draw"),c=l(()=>{process.stdin.off("keypress",d),process.stdin.isTTY&&process.stdin.setRawMode(!1),process.stdin.pause()},"cleanup"),d=l((p,f)=>{const a=xe(t,L(p,f));if(a==="crtr.profile.menu.abort"&&(c(),process.stdout.write(`
16
+ `),process.exit(130)),a==="crtr.profile.menu.up"){o=(o-1+n.length)%n.length,m();return}if(a==="crtr.profile.menu.down"){o=(o+1)%n.length,m();return}if(a==="crtr.profile.menu.select"){c(),u({index:o});return}if(a==="crtr.profile.menu.accept-default"){c(),u({index:s.initialIndex??0});return}if(a?.startsWith("crtr.profile.menu.slot.")){const g=Number.parseInt(a.slice(-1),10);g>=1&&g<=i.length&&(o=i[g-1],m());return}const y=n.findIndex(g=>g.bindingId!==void 0&&g.bindingId===a);if(y>=0){c(),u({index:y});return}a!==null&&s.actionBindingIds?.includes(a)===!0&&(c(),u({index:o,action:a}))},"onKey");E(process.stdin),process.stdin.isTTY&&process.stdin.setRawMode(!0),process.stdin.resume(),process.stdin.on("keypress",d),m()})}l(Q,"runMenu");function V(t){return he()?(ie("tmux",["display-popup","-E","-T"," profiles ","-w","90%","-h","85%","-d",t,...$e(),"crtr sys settings --page profiles"],{stdio:"inherit"}),!0):(process.stdout.write(` ${$("the profile manager needs tmux \u2014 run `crtr sys settings` instead")}
17
+ `),!1)}l(V,"openProfileManager");const _=Symbol("profile-manager-ran");function X(t){return` ${I("\u203A")} ${$(t)} `}l(X,"caret");function Ce(t){return`crtr: no profile covers ${t}, and this session is non-interactive \u2014 using the root profile.
18
18
  Run \`crtr profile new --name <name> --project ${t}\` to create a dedicated profile, or pass --profile <id-or-name> next time.
19
- `}l(Se,"rootProfileMessage");async function Ee(t,e){const r=v({input:process.stdin,output:process.stdout});try{Te(`Profile "${t.manifest.name}" doesn't cover this directory`),await Z(r,t,e)}finally{r.close()}}l(Ee,"promptAddDirToProfile");async function Z(t,e,r){const n=(await t.question(X(`add this directory to "${e.manifest.name}"? [Y/n]`))).trim().toLowerCase();n==="n"||n==="no"||(j(e.profileId,r),process.stdout.write(` ${w("\u2713")} ${$(`added this directory to "${e.manifest.name}"`)}
20
- `))}l(Z,"offerAddDirToProfile");async function Ae(t){const e=[...A()].filter(i=>i.profileId!==D).sort((i,o)=>T(i.manifest.last_used_at,o.manifest.last_used_at)?-1:1);if(e.length===0)return process.stdout.write(` ${$("no existing profiles to select")}
21
- `),null;let r="",n=0;const s=l(()=>r===""?e:e.filter(i=>i.manifest.name.toLowerCase().includes(r)||i.manifest.projects.some(o=>b(o.path).toLowerCase().includes(r))),"matchesOf");return new Promise(i=>{let o=0;const u=l(()=>{const a=s();n>=a.length&&(n=Math.max(0,a.length-1));let d=`
19
+ `}l(Ce,"rootProfileMessage");async function Re(t,e){const r=v({input:process.stdin,output:process.stdout});try{ve(`Profile "${t.manifest.name}" doesn't cover this directory`),await Z(r,t,e)}finally{r.close()}}l(Re,"promptAddDirToProfile");async function Z(t,e,r){const n=(await t.question(X(`add this directory to "${e.manifest.name}"? [Y/n]`))).trim().toLowerCase();n==="n"||n==="no"||(await j(e.profileId,r),process.stdout.write(` ${I("\u2713")} ${$(`added this directory to "${e.manifest.name}"`)}
20
+ `))}l(Z,"offerAddDirToProfile");async function Se(t){const e=[...A()].filter(i=>i.profileId!==O).sort((i,o)=>T(i.manifest.last_used_at,o.manifest.last_used_at)?-1:1);if(e.length===0)return process.stdout.write(` ${$("no existing profiles to select")}
21
+ `),null;let r="",n=0;const s=l(()=>r===""?e:e.filter(i=>i.manifest.name.toLowerCase().includes(r)||i.manifest.projects.some(o=>b(o.path).toLowerCase().includes(r))),"matchesOf");return new Promise(i=>{let o=0;const u=l(()=>{const c=s();n>=c.length&&(n=Math.max(0,c.length-1));let d=`
22
22
  ${x("Select an existing profile")}
23
23
  `;if(d+=` ${$("across every profile, not just this directory")}
24
24
 
25
- `,a.length===0)d+=` ${$(`no match for "${r}"`)}
26
- `;else{const p=Math.max(...a.map(f=>f.manifest.name.length));a.forEach((f,c)=>{d+=` ${c===n?q:" "} ${x(f.manifest.name.padEnd(p))} ${$(_e(f))}
25
+ `,c.length===0)d+=` ${$(`no match for "${r}"`)}
26
+ `;else{const p=Math.max(...c.map(f=>f.manifest.name.length));c.forEach((f,a)=>{d+=` ${a===n?q:" "} ${x(f.manifest.name.padEnd(p))} ${$(Me(f))}
27
27
  `})}d+=`
28
- ${w("\u203A")} ${r}${$("\u2588")}
29
- `,d+=` ${$(`type to filter ${g(t,"crtr.profile.search.up")}/${g(t,"crtr.profile.search.down")} move ${g(t,"crtr.profile.search.pick")} pick ${g(t,"crtr.profile.search.back")} back`)}
30
- `,process.stdout.write((o>0?z(o)+G:"")+d),o=J(d)},"draw"),h=l(()=>{process.stdin.off("keypress",m),process.stdin.isTTY&&process.stdin.setRawMode(!1),process.stdin.pause()},"cleanup"),m=l((a,d)=>{const p=ve(t,L(a,d));if(p==="crtr.profile.search.abort"&&(h(),process.stdout.write(`
31
- `),process.exit(130)),p==="crtr.profile.search.back"){h(),i(null);return}const f=s();if(p==="crtr.profile.search.pick"){f.length>0&&(h(),i(f[n].profileId));return}if(p==="crtr.profile.search.up"){f.length>0&&(n=(n-1+f.length)%f.length,u());return}if(p==="crtr.profile.search.down"){f.length>0&&(n=(n+1)%f.length,u());return}if(p==="crtr.profile.search.delete"){r=r.slice(0,-1),n=0,u();return}a!==void 0&&a.length===1&&a>=" "&&d.ctrl!==!0&&(r+=a.toLowerCase(),n=0,u())},"onKey");E(process.stdin),process.stdin.isTTY&&process.stdin.setRawMode(!0),process.stdin.resume(),process.stdin.on("keypress",m),u()})}l(Ae,"promptSelectExistingProfile");async function ee(t,e){const r=ce(e)||"profile",n=(await t.question(X(`name the new profile [${r}]`))).trim(),s=n!==""?n:r,i=me(s,[{path:e}]).profileId;return process.stdout.write(` ${w("\u2713")} ${$(`created profile "${s}"`)}
32
- `),i}l(ee,"createProfileHere");async function je(t,e){const r=[{label:"create a profile here",detail:"",bindingId:"crtr.profile.menu.create"},{label:"select an existing profile",detail:"",bindingId:"crtr.profile.menu.search-existing"},{label:$("use the root profile"),detail:"",bindingId:"crtr.profile.menu.use-root",isDefault:!0}];for(;;){const n=await Q(e,"No profile covers this directory",void 0,r,{initialIndex:2,actionBindingIds:["crtr.profile.menu.manage"],hint:`${g(e,"crtr.profile.menu.manage")}=manage profiles`});if(n.action==="crtr.profile.menu.manage"){if(V(t))return _;continue}if(n.index===0){const s=v({input:process.stdin,output:process.stdout});try{return await ee(s,t)}finally{s.close()}}if(n.index===1){const s=await Ae(e);if(s===null)continue;const i=pe(s),o=v({input:process.stdin,output:process.stdout});try{await Z(o,i,t)}finally{o.close()}return i.profileId}return k().profileId}}l(je,"promptCreateOrRoot");async function C(t,e,r,n,s){const i=[...t].sort((c,y)=>T(c.manifest.last_used_at,y.manifest.last_used_at)?-1:1),o=n!==null?i.find(c=>c.profileId===n)??null:null,u=o!==null?[o,...i.filter(c=>c!==o)]:i,h=Math.max(...u.map(c=>c.manifest.name.length)),m=u.map((c,y)=>{const I=c.manifest.projects.length,te=r?`${K(c.manifest.last_used_at)}${I>1?` \xB7 ${I} dirs total`:""}`:(()=>{const R=c.manifest.projects.find(ne=>B(e,ne.path))??c.manifest.projects[0];return I>1?`matches ${b(R.path)} \xB7 ${I} dirs total`:`matches ${b(R.path)}`})(),re=o!==null&&u[0]===o?"default (pinned)":"default";return{label:x(c.manifest.name.padEnd(h)),detail:te,isDefault:y===0,defaultText:re}});m.push({label:$("create a new profile here"),detail:"",bindingId:"crtr.profile.menu.create"});const a=["crtr.profile.menu.set-default","crtr.profile.menu.manage"];r||a.push("crtr.profile.menu.add-directory"),o!==null&&a.push("crtr.profile.menu.unpin");const d=[`${g(s,"crtr.profile.menu.set-default")}=set default`];r||d.push(`${g(s,"crtr.profile.menu.add-directory")}=add dir here`),o!==null&&d.push(`${g(s,"crtr.profile.menu.unpin")}=unpin`),d.push(`${g(s,"crtr.profile.menu.manage")}=manage profiles`);const p=await Q(s,r?"Choose a profile":"Select a profile",r?"Several profiles claim this directory as their project":"This directory falls under existing profile(s)",m,{actionBindingIds:a,hint:d.join(" ")});if(p.action==="crtr.profile.menu.manage")return V(e)?_:await C(t,e,r,n,s);if(p.index>=u.length){const c=v({input:process.stdin,output:process.stdout});try{return await ee(c,e)}finally{c.close()}}const f=u[p.index];return p.action==="crtr.profile.menu.unpin"?(O(e),process.stdout.write(` ${w("\u2713")} ${$("cleared the default for this directory")}
33
- `),f.profileId):(p.action==="crtr.profile.menu.set-default"?($e(e,f.profileId),process.stdout.write(` ${w("\u2713")} ${$(`"${f.manifest.name}" is now the default here`)}
34
- `)):p.action==="crtr.profile.menu.add-directory"&&(j(f.profileId,e),process.stdout.write(` ${w("\u2713")} ${$(`added this directory to "${f.manifest.name}"`)}
35
- `)),f.profileId)}l(C,"promptPickProfileOrCreate");async function Qe(t,e,r=!1){fe({kind:"user",root:ue()});const n=Y(t),s=ye();if(e!=null&&e!==""){const i=de(e);return!F(i,n)&&H()&&await Ee(i,n),P(i.profileId),i.profileId}for(;;){const{covering:i,exact:o,pinnedId:u,pinned:h}=U(n);if(u!==null&&h===null&&O(n),h!==null&&!r)return P(h.profileId),h.profileId;if(!r&&h===null&&o.length===1)return P(o[0].profileId),o[0].profileId;if(!H()){const d=o.length>0?o:i;if(d.length>0){const f=W(d);return P(f.profileId),f.profileId}const p=k();return process.stderr.write(Se(n)),p.profileId}const m=h!==null?h.profileId:null,a=o.length>1?await C(o,n,!0,m,s):i.length>0?await C(i,n,!1,m,s):await je(n,s);if(a!==_)return P(a),a}}l(Qe,"selectProfileForCwd");export{F as profileCoversCwd,be as resolveProfileMenuAction,ve as resolveProfileSearchAction,Qe as selectProfileForCwd,Je as selectProfileForCwdReadOnly};
28
+ ${I("\u203A")} ${r}${$("\u2588")}
29
+ `,d+=` ${$(`type to filter ${w(t,"crtr.profile.search.up")}/${w(t,"crtr.profile.search.down")} move ${w(t,"crtr.profile.search.pick")} pick ${w(t,"crtr.profile.search.back")} back`)}
30
+ `,process.stdout.write((o>0?G(o)+J:"")+d),o=z(d)},"draw"),h=l(()=>{process.stdin.off("keypress",m),process.stdin.isTTY&&process.stdin.setRawMode(!1),process.stdin.pause()},"cleanup"),m=l((c,d)=>{const p=Pe(t,L(c,d));if(p==="crtr.profile.search.abort"&&(h(),process.stdout.write(`
31
+ `),process.exit(130)),p==="crtr.profile.search.back"){h(),i(null);return}const f=s();if(p==="crtr.profile.search.pick"){f.length>0&&(h(),i(f[n].profileId));return}if(p==="crtr.profile.search.up"){f.length>0&&(n=(n-1+f.length)%f.length,u());return}if(p==="crtr.profile.search.down"){f.length>0&&(n=(n+1)%f.length,u());return}if(p==="crtr.profile.search.delete"){r=r.slice(0,-1),n=0,u();return}c!==void 0&&c.length===1&&c>=" "&&d.ctrl!==!0&&(r+=c.toLowerCase(),n=0,u())},"onKey");E(process.stdin),process.stdin.isTTY&&process.stdin.setRawMode(!0),process.stdin.resume(),process.stdin.on("keypress",m),u()})}l(Se,"promptSelectExistingProfile");async function ee(t,e){const r=ae(e)||"profile",n=(await t.question(X(`name the new profile [${r}]`))).trim(),s=n!==""?n:r,i=(await pe(s,[{path:e}])).profileId;return process.stdout.write(` ${I("\u2713")} ${$(`created profile "${s}"`)}
32
+ `),i}l(ee,"createProfileHere");async function Ee(t,e){const r=[{label:"create a profile here",detail:"",bindingId:"crtr.profile.menu.create"},{label:"select an existing profile",detail:"",bindingId:"crtr.profile.menu.search-existing"},{label:$("use the root profile"),detail:"",bindingId:"crtr.profile.menu.use-root",isDefault:!0}];for(;;){const n=await Q(e,"No profile covers this directory",void 0,r,{initialIndex:2,actionBindingIds:["crtr.profile.menu.manage"],hint:`${w(e,"crtr.profile.menu.manage")}=manage profiles`});if(n.action==="crtr.profile.menu.manage"){if(V(t))return _;continue}if(n.index===0){const s=v({input:process.stdin,output:process.stdout});try{return await ee(s,t)}finally{s.close()}}if(n.index===1){const s=await Se(e);if(s===null)continue;const i=fe(s),o=v({input:process.stdin,output:process.stdout});try{await Z(o,i,t)}finally{o.close()}return i.profileId}return(await D()).profileId}}l(Ee,"promptCreateOrRoot");async function C(t,e,r,n,s){const i=[...t].sort((a,y)=>T(a.manifest.last_used_at,y.manifest.last_used_at)?-1:1),o=n!==null?i.find(a=>a.profileId===n)??null:null,u=o!==null?[o,...i.filter(a=>a!==o)]:i,h=Math.max(...u.map(a=>a.manifest.name.length)),m=u.map((a,y)=>{const g=a.manifest.projects.length,te=r?`${K(a.manifest.last_used_at)}${g>1?` \xB7 ${g} dirs total`:""}`:(()=>{const R=a.manifest.projects.find(ne=>B(e,ne.path))??a.manifest.projects[0];return g>1?`matches ${b(R.path)} \xB7 ${g} dirs total`:`matches ${b(R.path)}`})(),re=o!==null&&u[0]===o?"default (pinned)":"default";return{label:x(a.manifest.name.padEnd(h)),detail:te,isDefault:y===0,defaultText:re}});m.push({label:$("create a new profile here"),detail:"",bindingId:"crtr.profile.menu.create"});const c=["crtr.profile.menu.set-default","crtr.profile.menu.manage"];r||c.push("crtr.profile.menu.add-directory"),o!==null&&c.push("crtr.profile.menu.unpin");const d=[`${w(s,"crtr.profile.menu.set-default")}=set default`];r||d.push(`${w(s,"crtr.profile.menu.add-directory")}=add dir here`),o!==null&&d.push(`${w(s,"crtr.profile.menu.unpin")}=unpin`),d.push(`${w(s,"crtr.profile.menu.manage")}=manage profiles`);const p=await Q(s,r?"Choose a profile":"Select a profile",r?"Several profiles claim this directory as their project":"This directory falls under existing profile(s)",m,{actionBindingIds:c,hint:d.join(" ")});if(p.action==="crtr.profile.menu.manage")return V(e)?_:await C(t,e,r,n,s);if(p.index>=u.length){const a=v({input:process.stdin,output:process.stdout});try{return await ee(a,e)}finally{a.close()}}const f=u[p.index];return p.action==="crtr.profile.menu.unpin"?(await k(e),process.stdout.write(` ${I("\u2713")} ${$("cleared the default for this directory")}
33
+ `),f.profileId):(p.action==="crtr.profile.menu.set-default"?(await me(e,f.profileId),process.stdout.write(` ${I("\u2713")} ${$(`"${f.manifest.name}" is now the default here`)}
34
+ `)):p.action==="crtr.profile.menu.add-directory"&&(await j(f.profileId,e),process.stdout.write(` ${I("\u2713")} ${$(`added this directory to "${f.manifest.name}"`)}
35
+ `)),f.profileId)}l(C,"promptPickProfileOrCreate");async function qe(t,e,r=!1){const n=Y(t),s=ge();if(e!=null&&e!==""){const i=ue(e);return!W(i,n)&&H()&&await Re(i,n),await P(i.profileId),i.profileId}for(;;){const{covering:i,exact:o,pinnedId:u,pinned:h}=U(n);if(u!==null&&h===null&&await k(n),h!==null&&!r)return await P(h.profileId),h.profileId;if(!r&&h===null&&o.length===1)return await P(o[0].profileId),o[0].profileId;if(!H()){const d=o.length>0?o:i;if(d.length>0){const f=F(d);return await P(f.profileId),f.profileId}const p=await D();return process.stderr.write(Ce(n)),p.profileId}const m=h!==null?h.profileId:null,c=o.length>1?await C(o,n,!0,m,s):i.length>0?await C(i,n,!1,m,s):await Ee(n,s);if(c!==_)return await P(c),c}}l(qe,"selectProfileForCwd");export{W as profileCoversCwd,xe as resolveProfileMenuAction,Pe as resolveProfileSearchAction,qe as selectProfileForCwd,Ke as selectProfileForCwdReadOnly};
@@ -3,4 +3,4 @@ import type { ModelRegistry, ModelRuntime } from '@earendil-works/pi-coding-agen
3
3
  * configured predicate shown by the setup Providers panel. */
4
4
  export declare function isProviderCredentialConfigured(providerId: string, registry: ModelRegistry): boolean;
5
5
  /** Whether any provider in the setup catalog has a usable configured credential. */
6
- export declare function hasProviderCredential(runtime: ModelRuntime, registry: ModelRegistry): boolean;
6
+ export declare function hasProviderCredential(runtime: ModelRuntime, registry: ModelRegistry): Promise<boolean>;
@@ -1 +1 @@
1
- var i=Object.defineProperty;var t=(e,r)=>i(e,"name",{value:r,configurable:!0});import{isManagedProvider as n,readSubscriptionPool as d}from"./subscription-state.js";function a(e,r){return r.getProviderAuthStatus(e).configured||n(e)&&d(e).length>0}t(a,"isProviderCredentialConfigured");function g(e,r){return[...new Set([...e.getProviders().map(o=>o.id),...r.getAll().map(o=>o.provider)])].some(o=>a(o,r))}t(g,"hasProviderCredential");export{g as hasProviderCredential,a as isProviderCredentialConfigured};
1
+ var n=Object.defineProperty;var o=(e,r)=>n(e,"name",{value:r,configurable:!0});function d(e,r){return r.getProviderAuthStatus(e).configured}o(d,"isProviderCredentialConfigured");async function a(e,r){const i=new Set([...e.getProviders().map(t=>t.id),...r.getAll().map(t=>t.provider)]);for(const t of i)if(d(t,r))return!0;return!1}o(a,"hasProviderCredential");export{a as hasProviderCredential,d as isProviderCredentialConfigured};
@@ -1,3 +1,4 @@
1
+ import type { CrtrClient } from '../api/client.js';
1
2
  /** The minimal shape of a Providers-panel row the removal router needs. */
2
3
  export interface RemovableProviderRow {
3
4
  providerId: string;
@@ -6,7 +7,5 @@ export interface RemovableProviderRow {
6
7
  configured?: boolean;
7
8
  label?: string;
8
9
  }
9
- /** Route a row's removal to the coordinated service (managed) or auth.json (non-managed) and
10
- * return the truthful panel notice. May throw (e.g. an unknown-subscription error) — callers
11
- * surface that as the notice. */
12
- export declare function removeProviderRow(agentDir: string, row: RemovableProviderRow): Promise<string>;
10
+ /** Route a row's removal through the daemon and return the truthful panel notice. A managed account row removes that account only; a managed header row or a non-managed provider removes every credential for the provider. May throw (e.g. an unknown account) — callers surface that as the notice. */
11
+ export declare function removeProviderRow(client: CrtrClient, row: RemovableProviderRow): Promise<string>;
@@ -1 +1 @@
1
- var i=Object.defineProperty;var a=(r,e)=>i(r,"name",{value:e,configurable:!0});import{join as m}from"node:path";import{deleteAuthCredential as n}from"./auth-file.js";import{secretsDir as t}from"./layout.js";import{removeManagedProvider as o}from"./subscription-state.js";async function l(r,e){return e.managed?(await o(e.providerId,e.label),e.label===void 0?`Removed ${e.name}`:`Removed ${e.name} account`):(await n(e.providerId,m(t(),"auth.json")),`Removed ${e.name}`)}a(l,"removeProviderRow");export{l as removeProviderRow};
1
+ var n=Object.defineProperty;var d=(a,e)=>n(a,"name",{value:e,configurable:!0});async function t(a,e){return e.managed&&e.label!==void 0?(await a.removeModelAuthAccount(e.providerId,e.label),`Removed ${e.name} account`):(await a.removeCredential(e.providerId),`Removed ${e.name}`)}d(t,"removeProviderRow");export{t as removeProviderRow};