@clagentic/console 1.12.0-beta.3 → 1.13.0-beta.1

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 (243) hide show
  1. package/README.md +7 -1
  2. package/bin/cli.js +18 -15
  3. package/lib/agent-roster-ws.js +38 -13
  4. package/lib/agent-roster.js +111 -12
  5. package/lib/agents.js +68 -33
  6. package/lib/atomic-install.js +334 -0
  7. package/lib/build-changes.js +33 -4
  8. package/lib/build-sha.json +2 -2
  9. package/lib/build-update-offer.js +12 -0
  10. package/lib/chat-width.js +31 -0
  11. package/lib/cli/agent-usage.js +126 -0
  12. package/lib/cli/arg-validation.js +1 -1
  13. package/lib/cli/compact-output.js +69 -0
  14. package/lib/cli/ipc-subcommands.js +92 -67
  15. package/lib/cli/output.js +28 -0
  16. package/lib/cli/restart-verb.js +132 -0
  17. package/lib/cli/schedule-input-subcommands.js +45 -8
  18. package/lib/cli/session-subcommands.js +37 -11
  19. package/lib/cli/settings-subcommands.js +74 -0
  20. package/lib/cli-transcript-title.js +56 -3
  21. package/lib/client-files.js +79 -0
  22. package/lib/daemon.js +100 -28
  23. package/lib/default-avatar-color.js +4 -0
  24. package/lib/drain.js +58 -10
  25. package/lib/mcp-tool-input.js +2 -2
  26. package/lib/model-families.js +49 -1
  27. package/lib/notify/type-registry.js +4 -0
  28. package/lib/notify/types.js +7 -4
  29. package/lib/pages.js +13 -63
  30. package/lib/permission-summary.js +12 -16
  31. package/lib/plan-usage-reader.js +70 -0
  32. package/lib/project-connection.js +4 -2
  33. package/lib/project-filesystem.js +6 -7
  34. package/lib/project-notifications.js +55 -8
  35. package/lib/project-prompt-expiry-settings.js +42 -0
  36. package/lib/project-sessions.js +52 -0
  37. package/lib/project-settings-gate.js +98 -0
  38. package/lib/project-user-mention.js +3 -2
  39. package/lib/project.js +1 -1
  40. package/lib/prompt-expiry-settings.js +49 -0
  41. package/lib/prompt-expiry.js +24 -3
  42. package/lib/prompt-kinds/codecs.js +6 -2
  43. package/lib/public/app.js +36 -36
  44. package/lib/public/css/admin.css +156 -170
  45. package/lib/public/css/agent-messages.css +24 -24
  46. package/lib/public/css/agent-picker.css +90 -38
  47. package/lib/public/css/agent-roster.css +61 -27
  48. package/lib/public/css/at-agents.css +10 -10
  49. package/lib/public/css/base.css +207 -184
  50. package/lib/public/css/chat-layout.css +228 -0
  51. package/lib/public/css/command-palette.css +86 -88
  52. package/lib/public/css/diagnostics.css +78 -204
  53. package/lib/public/css/diff.css +10 -10
  54. package/lib/public/css/filebrowser.css +32 -60
  55. package/lib/public/css/home-hub.css +100 -100
  56. package/lib/public/css/icon-strip.css +195 -238
  57. package/lib/public/css/input.css +191 -212
  58. package/lib/public/css/login-panel.css +16 -16
  59. package/lib/public/css/loop.css +96 -187
  60. package/lib/public/css/mention.css +49 -110
  61. package/lib/public/css/menus.css +162 -169
  62. package/lib/public/css/messages.css +49 -123
  63. package/lib/public/css/mobile-nav.css +207 -264
  64. package/lib/public/css/notifications-center.css +45 -124
  65. package/lib/public/css/overlay.css +269 -0
  66. package/lib/public/css/overlays.css +134 -156
  67. package/lib/public/css/playbook.css +41 -41
  68. package/lib/public/css/profile.css +43 -112
  69. package/lib/public/css/rewind.css +112 -112
  70. package/lib/public/css/scheduler-modal.css +27 -135
  71. package/lib/public/css/scheduler.css +204 -210
  72. package/lib/public/css/server-settings.css +173 -239
  73. package/lib/public/css/session-search.css +20 -20
  74. package/lib/public/css/settings-nav.css +197 -0
  75. package/lib/public/css/sidebar.css +213 -304
  76. package/lib/public/css/skills.css +121 -135
  77. package/lib/public/css/sticky-notes.css +114 -200
  78. package/lib/public/css/stt.css +17 -26
  79. package/lib/public/css/team-panel.css +36 -36
  80. package/lib/public/css/team-view.css +9 -9
  81. package/lib/public/css/title-bar.css +83 -100
  82. package/lib/public/css/tooltip.css +10 -10
  83. package/lib/public/css/user-settings.css +78 -131
  84. package/lib/public/css/user-shell.css +125 -29
  85. package/lib/public/index.html +178 -177
  86. package/lib/public/manifest.json +0 -2
  87. package/lib/public/modules/admin.js +54 -92
  88. package/lib/public/modules/agent-avatar.js +134 -3
  89. package/lib/public/modules/agent-messages.js +2 -1
  90. package/lib/public/modules/agent-picker.js +23 -21
  91. package/lib/public/modules/agent-roster-groups.js +128 -0
  92. package/lib/public/modules/agent-roster.js +40 -11
  93. package/lib/public/modules/app-connection.js +13 -1
  94. package/lib/public/modules/app-cursors.js +9 -9
  95. package/lib/public/modules/app-favicon.js +8 -16
  96. package/lib/public/modules/app-header.js +28 -19
  97. package/lib/public/modules/app-history-replay.js +67 -4
  98. package/lib/public/modules/app-home-hub.js +15 -0
  99. package/lib/public/modules/app-loop-ui.js +41 -47
  100. package/lib/public/modules/app-loop-wizard.js +9 -10
  101. package/lib/public/modules/app-messages.js +32 -36
  102. package/lib/public/modules/app-misc.js +22 -92
  103. package/lib/public/modules/app-modals.js +98 -0
  104. package/lib/public/modules/app-notifications.js +124 -135
  105. package/lib/public/modules/app-panels.js +28 -32
  106. package/lib/public/modules/app-projects.js +30 -40
  107. package/lib/public/modules/app-rate-limit.js +26 -9
  108. package/lib/public/modules/app-rendering.js +128 -110
  109. package/lib/public/modules/app-skills-install.js +6 -4
  110. package/lib/public/modules/assistant-identity.js +55 -0
  111. package/lib/public/modules/at-agents.js +3 -0
  112. package/lib/public/modules/build-guard.js +25 -11
  113. package/lib/public/modules/chat-width-choice.js +75 -0
  114. package/lib/public/modules/chat-width-prefs.js +52 -0
  115. package/lib/public/modules/chat-width.js +102 -0
  116. package/lib/public/modules/collapsible-text.js +36 -4
  117. package/lib/public/modules/command-palette.js +28 -34
  118. package/lib/public/modules/context-sources.js +3 -5
  119. package/lib/public/modules/diagnostics.js +130 -129
  120. package/lib/public/modules/info-panel.js +31 -0
  121. package/lib/public/modules/injected-identity.js +8 -8
  122. package/lib/public/modules/input-list-menu.js +39 -0
  123. package/lib/public/modules/input.js +22 -21
  124. package/lib/public/modules/markdown.js +10 -11
  125. package/lib/public/modules/mcp-ui.js +4 -14
  126. package/lib/public/modules/mention.js +100 -229
  127. package/lib/public/modules/message-header.js +80 -0
  128. package/lib/public/modules/message-participants.js +39 -0
  129. package/lib/public/modules/mobile-action-sheet.js +46 -0
  130. package/lib/public/modules/mobile-nav-sheet.js +104 -0
  131. package/lib/public/modules/model-families.js +41 -4
  132. package/lib/public/modules/note-order.js +39 -0
  133. package/lib/public/modules/notifications.js +35 -52
  134. package/lib/public/modules/overlay-history.js +73 -19
  135. package/lib/public/modules/overlay-menu.js +123 -0
  136. package/lib/public/modules/overlay-modal.js +186 -0
  137. package/lib/public/modules/overlay-registry.js +392 -0
  138. package/lib/public/modules/overlay-stack.js +110 -0
  139. package/lib/public/modules/overlay.js +117 -0
  140. package/lib/public/modules/popover-position.js +18 -2
  141. package/lib/public/modules/preference-sync.js +28 -0
  142. package/lib/public/modules/profile.js +24 -49
  143. package/lib/public/modules/project-settings.js +27 -172
  144. package/lib/public/modules/prompt-expiry-controls.js +46 -0
  145. package/lib/public/modules/prompt-kinds/command-summary.js +149 -0
  146. package/lib/public/modules/prompt-kinds/permission.js +70 -92
  147. package/lib/public/modules/prompts.js +1 -2
  148. package/lib/public/modules/qrcode.js +6 -21
  149. package/lib/public/modules/queued-button.js +15 -2
  150. package/lib/public/modules/rewind.js +9 -3
  151. package/lib/public/modules/schedule-time.js +32 -7
  152. package/lib/public/modules/scheduled-outbox.js +51 -18
  153. package/lib/public/modules/scheduler-config.js +87 -127
  154. package/lib/public/modules/scheduler.js +29 -26
  155. package/lib/public/modules/serialized-save.js +79 -0
  156. package/lib/public/modules/server-settings.js +75 -65
  157. package/lib/public/modules/session-grants.js +16 -19
  158. package/lib/public/modules/session-list-avatars.js +98 -0
  159. package/lib/public/modules/session-vendor-state.js +86 -0
  160. package/lib/public/modules/settings-access.js +35 -0
  161. package/lib/public/modules/settings-hub.js +125 -0
  162. package/lib/public/modules/settings-nav.js +182 -0
  163. package/lib/public/modules/shell-line.js +24 -0
  164. package/lib/public/modules/sidebar-mobile.js +151 -195
  165. package/lib/public/modules/sidebar-projects.js +88 -129
  166. package/lib/public/modules/sidebar-sessions.js +66 -34
  167. package/lib/public/modules/sidebar.js +2 -2
  168. package/lib/public/modules/skills.js +11 -26
  169. package/lib/public/modules/sticky-notes.js +19 -16
  170. package/lib/public/modules/stt.js +9 -23
  171. package/lib/public/modules/terminal.js +86 -90
  172. package/lib/public/modules/theme-choice.js +126 -0
  173. package/lib/public/modules/theme-colors.js +19 -0
  174. package/lib/public/modules/theme-prefs.js +121 -0
  175. package/lib/public/modules/theme.js +227 -605
  176. package/lib/public/modules/tool-palette.js +7 -17
  177. package/lib/public/modules/tools.js +8 -10
  178. package/lib/public/modules/user-settings.js +59 -115
  179. package/lib/public/modules/user-shell.js +9 -2
  180. package/lib/public/modules/utils.js +10 -12
  181. package/lib/public/modules/vendor-picker.js +4 -2
  182. package/lib/public/modules/vendor-registry.js +1 -2
  183. package/lib/public/style.css +3 -1
  184. package/lib/public/sw.js +9 -2
  185. package/lib/public/theme-core.js +411 -0
  186. package/lib/request-body.js +70 -0
  187. package/lib/sdk-bridge.js +227 -88
  188. package/lib/sdk-message-processor.js +44 -16
  189. package/lib/server-admin.js +198 -200
  190. package/lib/server-auth.js +16 -13
  191. package/lib/server-dm.js +4 -3
  192. package/lib/server-settings.js +177 -130
  193. package/lib/server.js +87 -36
  194. package/lib/session-background-tasks.js +79 -0
  195. package/lib/session-directory.js +138 -13
  196. package/lib/session-input-ipc.js +2 -0
  197. package/lib/session-input.js +39 -5
  198. package/lib/session-list-avatars.js +16 -0
  199. package/lib/session-reclaim.js +37 -25
  200. package/lib/session-vendor.js +37 -0
  201. package/lib/sessions.js +99 -34
  202. package/lib/settings-ipc.js +60 -0
  203. package/lib/settings-registry.js +86 -0
  204. package/lib/terminal-manager.js +17 -5
  205. package/lib/theme-files.js +132 -0
  206. package/lib/theme-seed.js +136 -0
  207. package/lib/themes/clagentic-dark.json +13 -6
  208. package/lib/themes/clagentic-light.json +12 -5
  209. package/lib/updater.js +6 -4
  210. package/lib/usage-store.js +97 -10
  211. package/lib/users-preferences.js +118 -19
  212. package/lib/users.js +19 -10
  213. package/lib/vendor-catalog.js +130 -0
  214. package/lib/ws-schema.js +4 -2
  215. package/lib/yoke/adapters/claude.js +81 -1
  216. package/lib/yoke/adapters/codex-user-shell.js +87 -23
  217. package/lib/yoke/adapters/codex.js +89 -5
  218. package/lib/yoke/codex-binary.js +59 -0
  219. package/package.json +1 -1
  220. package/scripts/check-test-count.js +5 -0
  221. package/scripts/install-local-test.js +50 -9
  222. package/scripts/write-build-sha.js +18 -2
  223. package/lib/public/css/channel-layout.css +0 -329
  224. package/lib/themes/ayu-light.json +0 -9
  225. package/lib/themes/catppuccin-latte.json +0 -9
  226. package/lib/themes/catppuccin-mocha.json +0 -9
  227. package/lib/themes/dracula.json +0 -9
  228. package/lib/themes/everforest-light.json +0 -9
  229. package/lib/themes/everforest.json +0 -9
  230. package/lib/themes/github-light.json +0 -9
  231. package/lib/themes/gruvbox-dark.json +0 -9
  232. package/lib/themes/gruvbox-light.json +0 -9
  233. package/lib/themes/monokai.json +0 -9
  234. package/lib/themes/nord-light.json +0 -9
  235. package/lib/themes/nord.json +0 -9
  236. package/lib/themes/one-dark.json +0 -9
  237. package/lib/themes/one-light.json +0 -9
  238. package/lib/themes/rose-pine-dawn.json +0 -9
  239. package/lib/themes/rose-pine.json +0 -9
  240. package/lib/themes/solarized-dark.json +0 -9
  241. package/lib/themes/solarized-light.json +0 -9
  242. package/lib/themes/tokyo-night-light.json +0 -9
  243. package/lib/themes/tokyo-night.json +0 -9
package/lib/ws-schema.js CHANGED
@@ -39,7 +39,7 @@ var schema = {
39
39
  // derives every render surface's dot from. No new wire message type was
40
40
  // added for "activity"; it is data already on this existing message.
41
41
  "session_list": { direction: "s2c", handler: "lib/public/modules/app-messages.js", description: "Full list of sessions for the sidebar" },
42
- "session_switched": { direction: "s2c", handler: "lib/public/modules/app-messages.js", description: "Confirmation that active session changed" },
42
+ "session_switched": { direction: "s2c", handler: "lib/public/modules/app-messages.js", description: "Confirmation that active session changed; carries vendor and vendorSource (present, default-bound, error or absent)" },
43
43
  "session_id": { direction: "s2c", handler: "lib/public/modules/app-messages.js", description: "CLI session ID assigned to the current session" },
44
44
  "session_presence": { direction: "s2c", handler: "lib/public/modules/app-messages.js", description: "Which users are present in which sessions" },
45
45
  "session_io": { direction: "s2c", handler: "lib/public/modules/app-messages.js", description: "Notify that a session has new output activity" },
@@ -128,7 +128,7 @@ var schema = {
128
128
  "team_traffic": { direction: "s2c", handler: "lib/public/modules/app-messages.js", description: "Agent messages (drawn by agent-messages.js): pairs (count, last seen), messages, pending scheduled inputs, withheld count and reasons" },
129
129
  "team_traffic_changed": { direction: "s2c", handler: "lib/public/modules/app-messages.js", description: "An open or send landed; ask again (carries no content)" },
130
130
  "agent_roster_request": { direction: "c2s", handler: "lib/agent-roster-ws.js", description: "Ask for the agent roster" },
131
- "agent_roster": { direction: "s2c", handler: "lib/public/modules/app-messages.js", description: "The agent roster (drawn by agent-roster.js): every agent identity the console has seen, each {key, firstSeen, lastSeen, places [{source, project, session, lastSeen}], avatar}; avatar is {style, seed}, {custom} (a custom-icon slug) or null. Sent to a connection on connect and on request, limited to the projects that connection may read (an agent with no readable place is omitted); the avatar map every agent label resolves from" },
131
+ "agent_roster": { direction: "s2c", handler: "lib/public/modules/app-messages.js", description: "The agent roster (drawn by agent-roster.js): every agent identity the console has seen, each {key, lastSeen, places [{source, project, session, lastSeen}], avatar, group, vendor}; avatar is {style, seed}, {custom} (a custom-icon slug) or null; group is agent, helper or model and vendor the vendor whose list held a helper or model. Sent to a connection on connect and on request, limited to the projects that connection may read (an agent with no readable place is omitted; lastSeen is the latest among the readable places; no firstSeen is sent); the avatar map every agent label resolves from" },
132
132
  "agent_roster_changed": { direction: "s2c", handler: "lib/public/modules/app-messages.js", description: "The agent roster changed; send agent_roster_request (carries no content)" },
133
133
  "agent_avatar_set": { direction: "c2s", handler: "lib/agent-roster-ws.js", description: "Choose the avatar of a seen agent: {key, avatar}; avatar is {style, seed}, {custom} or null to clear" },
134
134
  "agent_avatar_set_result": { direction: "s2c", handler: "lib/public/modules/app-messages.js", description: "The outcome of agent_avatar_set for the client that asked: {key, ok, error?}" },
@@ -234,6 +234,8 @@ var schema = {
234
234
  "recheck_vendors": { direction: "c2s", handler: "lib/project-sessions.js", description: "Look again for installed agents and broadcast the vendor registry" },
235
235
  "config_state": { direction: "s2c", handler: "lib/public/modules/app-messages.js", description: "Config state: model, effort, betas, thinking, and the viewed session's mode (absent when the push is not about a mode)" },
236
236
  "permission_settings": { direction: "s2c", handler: "lib/public/modules/app-messages.js", description: "The server-wide permission settings: autoApproveReadOnly, openedSessionMode" },
237
+ "set_prompt_expiry_settings": { direction: "c2s", handler: "lib/project-prompt-expiry-settings.js", description: "Change how long an unanswered prompt waits before it expires (admin only): {promptExpiryMinutes}, a whole number of minutes, 0 for no expiry. Anything else is refused with an error and nothing is saved; the default (30) removes the key from daemon.json. Applies to the next prompt" },
238
+ "prompt_expiry_settings": { direction: "s2c", handler: "lib/public/modules/app-messages.js", description: "The prompt expiry setting, sent on connect and to every client after a change: {promptExpiryMinutes} (default 30, 0 means no expiry)" },
237
239
  "permission_mode_applied": { direction: "s2c", handler: "lib/public/modules/app-messages.js", description: "Result of applying a new default mode to the running sessions: applied count and skipped sessions with reasons" },
238
240
  "slash_commands": { direction: "s2c", handler: "lib/public/modules/app-messages.js", description: "Available slash commands list" },
239
241
  "fast_mode_state": { direction: "s2c", handler: "lib/public/modules/app-messages.js", description: "Fast mode toggle state" },
@@ -13,6 +13,7 @@ var { spawn } = require("child_process");
13
13
  var { resolveOsUserInfo } = require("../../os-users");
14
14
  var modelFamilies = require("../../model-families");
15
15
  var modelCatalog = require("../../model-catalog");
16
+ var vendorCatalog = require("../../vendor-catalog").defaultCatalog;
16
17
  var permissionRelay = require("./permission-relay");
17
18
  var effortControl = require("./effort-control");
18
19
  var runtimeEnv = require("../../runtime-env");
@@ -207,7 +208,7 @@ function flattenEvent(raw) {
207
208
  // lr-1317b8: parity fields (sdk.d.ts:4060-4082), not yet rendered
208
209
  // anywhere (frontend derivation lands in a later task) — carried
209
210
  // through now as substrate for CLI-parity labels (e.g. subagent_type
210
- // is the data behind "PRAX researching...").
211
+ // is the data behind "<agent> researching...").
211
212
  base.subagentType = raw.subagent_type || null;
212
213
  base.taskType = raw.task_type || null;
213
214
  base.workflowName = raw.workflow_name || null;
@@ -257,6 +258,20 @@ function flattenEvent(raw) {
257
258
  base.patch = raw.patch || {};
258
259
  return base;
259
260
  }
261
+ // The full set of live background tasks of any type (sdk.d.ts
262
+ // SDKBackgroundTasksChangedMessage): the host replaces its set with it.
263
+ if (raw.subtype === "background_tasks_changed") {
264
+ base.yokeType = "background_tasks_changed";
265
+ base.tasks = (Array.isArray(raw.tasks) ? raw.tasks : []).map(function (t) {
266
+ return {
267
+ id: t.task_id,
268
+ type: t.task_type || null,
269
+ description: t.description || "",
270
+ ambient: !!t.ambient,
271
+ };
272
+ });
273
+ return base;
274
+ }
260
275
  // Catch-all system event
261
276
  base.yokeType = "system";
262
277
  base.subtype = raw.subtype;
@@ -300,6 +315,12 @@ function flattenEvent(raw) {
300
315
  if (launch && typeof launch === "object" && launch.status === "async_launched") {
301
316
  base.asyncLaunch = { agentId: typeof launch.agentId === "string" ? launch.agentId : null };
302
317
  }
318
+ // A run_in_background Bash command returns its task id the same way
319
+ // (sdk-tools.d.ts BashOutput backgroundTaskId); the task_notification that
320
+ // ends it names that id.
321
+ if (launch && typeof launch === "object" && typeof launch.backgroundTaskId === "string" && launch.backgroundTaskId) {
322
+ base.backgroundTaskId = launch.backgroundTaskId;
323
+ }
303
324
  return base;
304
325
  }
305
326
 
@@ -420,6 +441,46 @@ function receiptOf(receipt) {
420
441
  return { stillQueued: receipt.still_queued.filter(function (id) { return typeof id === "string"; }) };
421
442
  }
422
443
 
444
+ // --- Plan usage (SDK get_usage control request) ---
445
+ // The one capability check for reading plan rate-limit utilization from a live
446
+ // query. The SDK marks the method experimental and says its name will change,
447
+ // so the name lives here alone: a missing, renamed or throwing method, a reply
448
+ // that says plan limits do not apply, or a malformed reply all read as "no
449
+ // reading" (null), never as an error and never as zero.
450
+ var PLAN_USAGE_METHOD = "usage_EXPERIMENTAL_MAY_CHANGE_DO_NOT_RELY_ON_THIS_API_YET";
451
+ var PLAN_USAGE_BUCKETS = ["five_hour", "seven_day"];
452
+
453
+ // The readings as rate-limit info objects (utilization as a 0-1 fraction,
454
+ // resetsAt in epoch seconds, the shape usage-store.record takes), or null.
455
+ function parsePlanUsage(reply) {
456
+ if (!reply || typeof reply !== "object" || reply.rate_limits_available !== true) return null;
457
+ var limits = reply.rate_limits;
458
+ if (!limits || typeof limits !== "object") return null;
459
+ var readings = [];
460
+ PLAN_USAGE_BUCKETS.forEach(function (bucket) {
461
+ var w = limits[bucket];
462
+ if (!w || typeof w !== "object") return;
463
+ if (typeof w.utilization !== "number" || !isFinite(w.utilization) || w.utilization < 0) return;
464
+ var resetsMs = typeof w.resets_at === "string" ? Date.parse(w.resets_at) : NaN;
465
+ readings.push({
466
+ rateLimitType: bucket,
467
+ utilization: w.utilization / 100,
468
+ resetsAt: isFinite(resetsMs) ? resetsMs / 1000 : null,
469
+ });
470
+ });
471
+ return readings.length > 0 ? readings : null;
472
+ }
473
+
474
+ // Never rejects. skipBehaviors keeps the request to the usage numbers.
475
+ function readPlanUsage(rawQuery) {
476
+ try {
477
+ if (!rawQuery || typeof rawQuery[PLAN_USAGE_METHOD] !== "function") return Promise.resolve(null);
478
+ return Promise.resolve(rawQuery[PLAN_USAGE_METHOD]({ skipBehaviors: true })).then(parsePlanUsage, function () { return null; });
479
+ } catch (e) {
480
+ return Promise.resolve(null);
481
+ }
482
+ }
483
+
423
484
  // --- QueryHandle ---
424
485
  // Wraps a raw SDK query object with the YOKE QueryHandle interface.
425
486
  // Events are flattened via flattenEvent before yielding.
@@ -523,6 +584,12 @@ function createQueryHandle(rawQuery, messageQueue, abortController, userShellEnv
523
584
  return Promise.resolve(null);
524
585
  },
525
586
 
587
+ // Optional (off the interface list; the OS-user worker handle has none):
588
+ // plan usage readings or null. Resolves, never rejects.
589
+ readPlanUsage: function() {
590
+ return readPlanUsage(rawQuery);
591
+ },
592
+
526
593
  // lr-d91ecf: a per-query supportedModels() used to live here, but it was
527
594
  // not part of the documented QueryHandle contract (see
528
595
  // yoke/interface.js's QUERY_HANDLE_METHODS) and had no caller anywhere
@@ -1717,6 +1784,16 @@ function enrichClaudeModelsWithCatalog(models) {
1717
1784
  }
1718
1785
 
1719
1786
 
1787
+ // What supportedModels() returned, as the vendor reported it, goes to the vendor
1788
+ // catalog and fixes the family list. The release-time catalog entries that
1789
+ // enrichClaudeModelsWithCatalog merges in are not a vendor report and stay out.
1790
+ // An empty or failed listing reports nothing, so the family fallback stays.
1791
+ function reportLiveModels(models) {
1792
+ if (!Array.isArray(models) || models.length === 0) return;
1793
+ vendorCatalog.report("claude", { models: models });
1794
+ modelFamilies.setClaudeModelFamilies(models);
1795
+ }
1796
+
1720
1797
  // --- Adapter factory ---
1721
1798
 
1722
1799
  function resolveClaudeBinaryPath() {
@@ -2070,6 +2147,7 @@ function createClaudeAdapter(opts) {
2070
2147
 
2071
2148
  try {
2072
2149
  var models = await stream.supportedModels();
2150
+ reportLiveModels(models);
2073
2151
  result.models = enrichClaudeModelsWithCatalog(models || []);
2074
2152
  _cachedModels = result.models;
2075
2153
  } catch (e) {
@@ -2124,6 +2202,7 @@ function createClaudeAdapter(opts) {
2124
2202
  if (msg.type === "warmup_done" && !warmupDone) {
2125
2203
  warmupDone = true;
2126
2204
  var r = msg.result || {};
2205
+ reportLiveModels(r.models);
2127
2206
  var enrichedModels = enrichClaudeModelsWithCatalog(r.models || []);
2128
2207
  _cachedModels = enrichedModels;
2129
2208
  resolve({
@@ -2174,5 +2253,6 @@ module.exports = {
2174
2253
  _test_createQueryHandle: createQueryHandle,
2175
2254
  _test_createWorkerQueryHandle: createWorkerQueryHandle,
2176
2255
  _test_buildShellTranscriptMessage: buildShellTranscriptMessage,
2256
+ _test_parsePlanUsage: parsePlanUsage,
2177
2257
  };
2178
2258
 
@@ -11,6 +11,16 @@
11
11
  // id. A model turn's start, items and end carry another id and always go on to
12
12
  // the stream; the end of an earlier command's turn that arrives late is matched
13
13
  // by its id too, never by how many are expected.
14
+ //
15
+ // The request answers {} and names no turn, so the command's turn id is learned
16
+ // from the turn that follows it: the first turn/started after the request. That
17
+ // is sound because nothing else can start a turn in the window: a command is
18
+ // refused while a model turn runs, and chat is held (whenIdle) until the runner
19
+ // is idle. A run the watchdog gives up on before its turn started stays pending
20
+ // (not idle) until that turn starts and ends, so the hold covers it too: the
21
+ // turn that starts next is the run's, bound and suppressed by its id. No timer
22
+ // and no command text takes part in telling a turn; the only other ways out are
23
+ // the session's Stop and the query ending.
14
24
 
15
25
  var userShell = require("../user-shell");
16
26
 
@@ -19,10 +29,10 @@ var userShell = require("../user-shell");
19
29
  var TURN_GRACE_MS = 3000;
20
30
  // How far past its timeout a command whose turn never started is given up on.
21
31
  var WATCHDOG_GRACE_MS = 20000;
22
- // How long a settled command's late turn ending is still taken as its own.
23
- var LATE_END_WINDOW_MS = 30000;
24
32
 
25
33
  var MODEL_TURN_RUNNING = "Not run: the agent is working. Try again when its turn has ended.";
34
+ var COMMAND_TURN_PENDING = "Not run: the previous command's turn has not ended. Try again when it has, or press Stop.";
35
+ var CHAT_WAITS = "The command's turn has not started. Chat waits until that turn ends or you press Stop.";
26
36
 
27
37
  function refusedResult(message) {
28
38
  return { exitCode: null, durationMs: 0, output: message, truncated: false, timedOut: false, interrupted: false };
@@ -53,15 +63,23 @@ function itemOutput(item) {
53
63
  */
54
64
  function createUserShellRunner(deps) {
55
65
  var current = null;
56
- // Turn id of a settled command's turn whose ending is still to arrive -> the
57
- // time after which it is no longer waited for.
66
+ // Turn ids of settled commands' turns whose ending is still to arrive.
58
67
  var lateEnds = {};
68
+ // The run the watchdog gave up on before its turn started: { turnId } with
69
+ // turnId null until that turn's turn/started arrives. The runner is not idle
70
+ // while it is set; it ends with the turn's own end, Stop, or the query ending.
71
+ var pendingLate = null;
72
+ // Stop or the query ending was seen: nothing is waited for any more.
73
+ var stopped = false;
74
+ var idleWaiters = [];
59
75
 
60
- function sweepLateEnds() {
61
- var now = Date.now();
62
- Object.keys(lateEnds).forEach(function (id) {
63
- if (lateEnds[id] < now) delete lateEnds[id];
64
- });
76
+ function isIdle() { return !current && !pendingLate; }
77
+
78
+ function wakeIdle() {
79
+ if (!isIdle()) return;
80
+ var waiters = idleWaiters;
81
+ idleWaiters = [];
82
+ waiters.forEach(function (resolve) { resolve(); });
65
83
  }
66
84
 
67
85
  function clearTimers(run) {
@@ -85,11 +103,16 @@ function createUserShellRunner(deps) {
85
103
  clearTimers(run);
86
104
  // A standalone turn that started and has not ended will still end, and that
87
105
  // ending is this command's.
88
- if (run.turnId && !run.turnEnded) lateEnds[run.turnId] = Date.now() + LATE_END_WINDOW_MS;
89
- sweepLateEnds();
106
+ if (run.turnId && !run.turnEnded) lateEnds[run.turnId] = true;
107
+ // The watchdog gave up before any turn started: the command may still start
108
+ // one, and it is this run's. The runner stays busy until that turn ends.
109
+ var waitsForTurn = !run.turnId && !!how.timedOut && !stopped;
110
+ if (waitsForTurn) pendingLate = { turnId: null };
111
+ wakeIdle();
90
112
  var elapsed = Date.now() - run.startedAt;
91
113
  var text = run.output;
92
- if (how.failure) text = (text ? text + "\n" : "") + how.failure;
114
+ var failure = how.failure || (waitsForTurn ? CHAT_WAITS : null);
115
+ if (failure) text = (text ? text + "\n" : "") + failure;
93
116
  var capped = userShell.capText(text, run.maxBytes);
94
117
  var timedOut = !!how.timedOut ||
95
118
  (run.itemStatus === "failed" && run.exitCode === null && !run.interruptSent && elapsed >= run.timeoutMs - 2000);
@@ -123,12 +146,38 @@ function createUserShellRunner(deps) {
123
146
  }
124
147
 
125
148
  function consumeLateEnd(params) {
126
- sweepLateEnds();
127
149
  var id = turnIdOf(params);
128
- if (!id || lateEnds[id] === undefined) return false;
129
- var until = lateEnds[id];
150
+ if (!id || !lateEnds[id]) return false;
130
151
  delete lateEnds[id];
131
- return Date.now() <= until;
152
+ return true;
153
+ }
154
+
155
+ // The run the watchdog gave up on. Its turn is the first turn/started after
156
+ // its request (the runner is busy, so no other turn can start); from then it is
157
+ // held out of the stream by its id until its own end, which frees the runner.
158
+ function consumePendingLate(method, params) {
159
+ var id = turnIdOf(params);
160
+ if (!id) return false;
161
+ if (!pendingLate.turnId) {
162
+ if (method !== "turn/started") return false;
163
+ pendingLate.turnId = id;
164
+ return true;
165
+ }
166
+ if (id !== pendingLate.turnId) return false;
167
+ if (method === "turn/completed" || method === "turn/failed") {
168
+ pendingLate = null;
169
+ wakeIdle();
170
+ }
171
+ return true;
172
+ }
173
+
174
+ // Stop or the query ending: nothing is waited for. A late turn already bound
175
+ // keeps its ending out of the stream by id.
176
+ function clearPendingLate() {
177
+ if (!pendingLate) return;
178
+ if (pendingLate.turnId) lateEnds[pendingLate.turnId] = true;
179
+ pendingLate = null;
180
+ wakeIdle();
132
181
  }
133
182
 
134
183
  function consumeItem(run, method, params) {
@@ -164,17 +213,17 @@ function createUserShellRunner(deps) {
164
213
  var isEnd = method === "turn/completed" || method === "turn/failed";
165
214
  if (isEnd && consumeLateEnd(params)) return true;
166
215
  var run = current;
216
+ if (pendingLate && consumePendingLate(method, params)) return true;
167
217
 
168
218
  if (method === "turn/started") {
169
219
  var startedId = turnIdOf(params);
170
220
  if (!run) return false;
171
221
  // Another turn starting once the command's is known is not the command's.
172
222
  if (run.turnId || !startedId) return false;
173
- // The first turn to start after the request is bound as the command's.
174
- // That holds because the console starts a model turn only from its own
175
- // sends, and the busy state that gates this method (refuses a command while
176
- // a turn runs, holds chat while one runs) leaves no other turn able to start
177
- // in this window.
223
+ // The request names no turn, so the first turn to start after it is the
224
+ // command's. Nothing else can start one in that window: a command is refused
225
+ // while a model turn runs, chat is held until the runner is idle (whenIdle),
226
+ // and a new command is refused while an earlier run is still pending.
178
227
  run.turnId = startedId;
179
228
  if (run.abortRequested) interruptNow(run);
180
229
  return true;
@@ -210,6 +259,9 @@ function createUserShellRunner(deps) {
210
259
  // cannot be told from the model's own commands or stopped without stopping
211
260
  // the turn, so it is refused while a model turn runs.
212
261
  if (deps.activeTurnId()) return Promise.resolve(refusedResult(MODEL_TURN_RUNNING));
262
+ // An earlier command the watchdog gave up on still has its turn to come; a
263
+ // second request now would leave two turns to tell apart.
264
+ if (pendingLate) return Promise.resolve(refusedResult(COMMAND_TURN_PENDING));
213
265
  return new Promise(function (resolve, reject) {
214
266
  var r = {
215
267
  resolve: resolve,
@@ -248,6 +300,7 @@ function createUserShellRunner(deps) {
248
300
  r.settled = true;
249
301
  current = null;
250
302
  clearTimers(r);
303
+ wakeIdle();
251
304
  reject(err);
252
305
  });
253
306
  });
@@ -257,8 +310,19 @@ function createUserShellRunner(deps) {
257
310
  run: run,
258
311
  consume: consume,
259
312
  isRunning: function () { return !!current; },
260
- // The query is being aborted or closed: stop the running command.
261
- interruptRunning: function () { if (current) requestInterrupt(current); },
313
+ // Resolves when no command is running or waiting for its turn: chat waits
314
+ // here so its turn cannot start while a command's turn is the one expected.
315
+ whenIdle: function () {
316
+ if (isIdle()) return Promise.resolve();
317
+ return new Promise(function (resolve) { idleWaiters.push(resolve); });
318
+ },
319
+ // The query is being aborted or closed: stop the running command and stop
320
+ // waiting for a late turn.
321
+ interruptRunning: function () {
322
+ stopped = true;
323
+ clearPendingLate();
324
+ if (current) requestInterrupt(current);
325
+ },
262
326
  };
263
327
  }
264
328
 
@@ -14,7 +14,9 @@ var runtimeEnv = require("../../runtime-env");
14
14
  var codexCapabilities = require("./codex-capabilities").codexCapabilities;
15
15
  var codexProtocol = require("../codex-protocol");
16
16
  var codexVersion = require("../codex-version");
17
+ var codexBinary = require("../codex-binary");
17
18
  var userShellModule = require("./codex-user-shell");
19
+ var vendorCatalog = require("../../vendor-catalog").defaultCatalog;
18
20
  var createUserShellRunner = userShellModule.createUserShellRunner;
19
21
  var refusedResult = userShellModule.refusedResult;
20
22
  var OTHER_DIRECTORY = "Not run: this Codex session runs commands only in its own working directory.";
@@ -1083,6 +1085,12 @@ function createCodexQueryHandle(appServer, queryOpts) {
1083
1085
  }
1084
1086
 
1085
1087
  while (!isCancelled()) {
1088
+ // Chat waits for a running ! command, and for the turn of one the
1089
+ // watchdog gave up on, to end, as it queues behind one natively: a turn
1090
+ // started now would be the first to start after the command's request and
1091
+ // could be taken for the command's own.
1092
+ await userShellRunner.whenIdle();
1093
+ if (isCancelled()) break;
1086
1094
  // Reset per-turn state
1087
1095
  state.turnStarted = false;
1088
1096
  // Named on the turn_start event so the console can publish which turn
@@ -1470,8 +1478,11 @@ function createCodexQueryHandle(appServer, queryOpts) {
1470
1478
  var CODEX_EFFORT_LEVELS = ["minimal", "low", "medium", "high", "xhigh"];
1471
1479
  var CODEX_EFFORT_LEVELS_STANDARD = ["low", "medium", "high"]; // models without xhigh/minimal
1472
1480
 
1473
- // Fallback table used only when the live "model/list" RPC fails or returns
1474
- // nothing (see catch block below). This static list carries no "upgrade"
1481
+ // Documented last-resort fallback, used only when the live "model/list" RPC
1482
+ // fails or returns nothing (see catch block below): it feeds the model picker so
1483
+ // a session can still start, is never merged into a live list, and is never
1484
+ // reported to the vendor catalog, so the Team view does not group by it. This
1485
+ // static list carries no "upgrade"
1475
1486
  // signal from the app-server, so isLatest defaults true for every entry —
1476
1487
  // nothing is hidden behind the older-models disclosure when we have no basis
1477
1488
  // to tier it (lr-e03635: absence of signal must never manifest as a hidden
@@ -1598,10 +1609,16 @@ function createCodexAdapter(opts) {
1598
1609
  var _instances = new Map();
1599
1610
  var _shutdownPromise = null;
1600
1611
  var _shuttingDown = false; // shutdown() of the whole adapter is running
1612
+ // Servers started from a Codex binary that has since changed: no longer
1613
+ // handed out, kept until the turns still on them finish.
1614
+ var _stale = new Set();
1615
+ var _binaryProbe = (opts && opts.binaryProbe) || codexBinary.probe;
1601
1616
 
1602
1617
  function createInstance(fingerprint) {
1603
1618
  return {
1604
1619
  fingerprint: fingerprint,
1620
+ // The binary this server was started from: { path, version, fileId }.
1621
+ binary: null,
1605
1622
  appServer: null,
1606
1623
  initPromise: null,
1607
1624
  retirePromise: null,
@@ -1673,6 +1690,59 @@ function createCodexAdapter(opts) {
1673
1690
  inst.refCount = 0;
1674
1691
  }
1675
1692
  updateLastActiveAt(inst);
1693
+ if (inst.refCount === 0 && _stale.has(inst)) retireStale(inst);
1694
+ }
1695
+
1696
+ function describeBinary(binary) {
1697
+ return binary.path + " (version " + (binary.version || "unknown") + ", file " + binary.fileId + ")";
1698
+ }
1699
+
1700
+ // The binary the lookup finds now, or null when it cannot be told. Looks at
1701
+ // files only; Codex is run (for its version) just when the file at the path
1702
+ // is not the one the server started from.
1703
+ function changedBinary(inst) {
1704
+ var was = inst.binary;
1705
+ if (!was || !was.path) return null;
1706
+ var nowPath = _binaryProbe.locate();
1707
+ if (!nowPath) return null;
1708
+ var nowFileId = _binaryProbe.fileId(nowPath);
1709
+ if (nowPath === was.path && nowFileId === was.fileId) return null;
1710
+
1711
+ var resolved;
1712
+ try {
1713
+ resolved = _binaryProbe.resolve();
1714
+ } catch (e) {
1715
+ // Mid-upgrade the binary may not answer; keep serving and look again next time.
1716
+ console.warn("[codex] the codex binary changed but could not be read yet:", e && e.message || e);
1717
+ return null;
1718
+ }
1719
+ if (!resolved) return null;
1720
+ if (nowPath === was.path && resolved.version === was.version) {
1721
+ // Same version at the same path (a touched file): remember the new file identity.
1722
+ was.fileId = nowFileId;
1723
+ return null;
1724
+ }
1725
+ return { path: nowPath, version: resolved.version, fileId: nowFileId };
1726
+ }
1727
+
1728
+ function retireStale(inst) {
1729
+ // After the current tick, so a caller that was just handed this server has
1730
+ // taken its count first.
1731
+ setImmediate(function() {
1732
+ if (inst.refCount > 0 || inst.retirePromise) return;
1733
+ retireInstance(inst, false).then(null, function(err) {
1734
+ console.error("[yoke/codex] Retiring a stale app-server failed:", err && err.message || err);
1735
+ }).then(function() { _stale.delete(inst); });
1736
+ });
1737
+ }
1738
+
1739
+ // Takes a server started from a binary that has changed out of use. Its
1740
+ // running turns finish on it; it is retired, never forced, once none is left.
1741
+ function markStale(inst, now) {
1742
+ console.log("[yoke/codex] retiring app-server: codex binary changed from " + describeBinary(inst.binary) + " to " + describeBinary(now));
1743
+ if (_instances.get(inst.fingerprint) === inst) _instances.delete(inst.fingerprint);
1744
+ _stale.add(inst);
1745
+ if (inst.refCount === 0) retireStale(inst);
1676
1746
  }
1677
1747
 
1678
1748
  function isStarted(inst) {
@@ -1849,7 +1919,7 @@ function createCodexAdapter(opts) {
1849
1919
 
1850
1920
  _shutdownPromise = (async function() {
1851
1921
  try {
1852
- var results = await Promise.allSettled(Array.from(_instances.values()).map(function(inst) {
1922
+ var results = await Promise.allSettled(Array.from(_instances.values()).concat(Array.from(_stale)).map(function(inst) {
1853
1923
  return retireInstance(inst, force);
1854
1924
  }));
1855
1925
  var failed = results.filter(function(r) { return r.status === "rejected"; })[0];
@@ -1866,7 +1936,8 @@ function createCodexAdapter(opts) {
1866
1936
 
1867
1937
  // The started, initialized instance for a fingerprint, starting (or waiting
1868
1938
  // out the retirement of) one when there is none. Never hands back a server
1869
- // that was started with a different environment.
1939
+ // that was started with a different environment, nor one started from a
1940
+ // Codex binary that has since changed.
1870
1941
  async function acquireInstance(queryOpts, fingerprint) {
1871
1942
  for (var attempt = 0; attempt < 3; attempt++) {
1872
1943
  if (_shuttingDown) throw createShutdownError();
@@ -1875,7 +1946,12 @@ function createCodexAdapter(opts) {
1875
1946
  await afterRetire(inst);
1876
1947
  continue;
1877
1948
  }
1878
- if (isStarted(inst) && !inst.initPromise) return inst;
1949
+ if (isStarted(inst) && !inst.initPromise) {
1950
+ var now = changedBinary(inst);
1951
+ if (!now) return inst;
1952
+ markStale(inst, now);
1953
+ continue;
1954
+ }
1879
1955
  await adapter.init(queryOpts);
1880
1956
  }
1881
1957
  throw new Error("[yoke/codex] Adapter not initialized. Call init() first.");
@@ -2015,8 +2091,14 @@ function createCodexAdapter(opts) {
2015
2091
  // the user installed, which fixes the version, and the version decides
2016
2092
  // which config keys exist: so the console's own keys are added to the
2017
2093
  // config after the binary is known and before the process starts.
2094
+ var startedFrom = _binaryProbe.locate();
2018
2095
  var server = new CodexAppServer(null, serverOpts);
2019
2096
  var binaryVersion = server.resolution && server.resolution.version;
2097
+ inst.binary = {
2098
+ path: startedFrom,
2099
+ version: binaryVersion || null,
2100
+ fileId: startedFrom ? _binaryProbe.fileId(startedFrom) : null,
2101
+ };
2020
2102
  var spawnFeatures = codexProtocol.protocolFeatures(binaryVersion);
2021
2103
  serverOpts.config = mergeConfig(codexProtocol.sessionConfig(spawnFeatures), serverOpts.config);
2022
2104
  inst.appServer = server;
@@ -2078,6 +2160,8 @@ function createCodexAdapter(opts) {
2078
2160
  }
2079
2161
  inst.defaultModel = (defaultEntry && (defaultEntry.model || defaultEntry.id)) || inst.defaultModel;
2080
2162
  console.log("[codex] model/list: " + inst.models.length + " models, default=" + inst.defaultModel);
2163
+ // Only a live listing is a vendor report; the fallback table below is not.
2164
+ vendorCatalog.report("codex", { models: inst.models });
2081
2165
  } else {
2082
2166
  throw new Error("empty or missing data");
2083
2167
  }
@@ -176,6 +176,62 @@ function resolveCodexBinary(options) {
176
176
  return { state: "absent", code: CODES.absent, reason: INSTALL_REASON };
177
177
  }
178
178
 
179
+ /**
180
+ * Where the lookup would find Codex now, in the same order as
181
+ * resolveCodexBinary, without starting a process: a stat per candidate. This is
182
+ * what a running app-server's binary is compared against on every turn.
183
+ * @returns {?string}
184
+ */
185
+ function locateCodexPath(options) {
186
+ var opts = options || {};
187
+ var env = opts.env || process.env;
188
+ var deps = opts.deps || defaultDeps(env, opts.commandDeps);
189
+
190
+ var override = env[CODEX_PATH_ENV];
191
+ if (typeof override === "string" && override.trim()) {
192
+ var chosen = override.trim();
193
+ return path.isAbsolute(chosen) && deps.isExecutable(chosen) ? chosen : null;
194
+ }
195
+ var onPath = deps.pathLookup();
196
+ if (onPath.path) return onPath.path;
197
+ var locations = commonLocations(deps.home());
198
+ for (var i = 0; i < locations.length; i++) {
199
+ if (deps.isExecutable(locations[i])) return locations[i];
200
+ }
201
+ return null;
202
+ }
203
+
204
+ /**
205
+ * A cheap identity of the file at a path (modification time, size, inode),
206
+ * following symlinks so an upgrade of the target shows. Null when there is no
207
+ * such file.
208
+ * @returns {?string}
209
+ */
210
+ function fileIdentity(candidate) {
211
+ try {
212
+ var st = fs.statSync(candidate);
213
+ return st.mtimeMs + ":" + st.size + ":" + st.ino;
214
+ } catch (e) {
215
+ if (e && (e.code === "ENOENT" || e.code === "ENOTDIR" || e.code === "EACCES" || e.code === "EPERM")) return null;
216
+ throw e;
217
+ }
218
+ }
219
+
220
+ /**
221
+ * The three questions the adapter asks about the binary a running app-server
222
+ * was started from; a test supplies its own with the same shape. Only
223
+ * `resolve` runs Codex, and the adapter asks it only after `fileId` or `locate`
224
+ * showed a change.
225
+ */
226
+ var probe = {
227
+ locate: function () { return locateCodexPath(); },
228
+ fileId: fileIdentity,
229
+ resolve: function () {
230
+ var result = resolveCached({ fresh: true });
231
+ return result.path && result.version ? { path: result.path, version: result.version } : null;
232
+ },
233
+ };
234
+
179
235
  /** The error a caller that cannot go on without a usable Codex throws. */
180
236
  function errorFor(result) {
181
237
  var err = new Error(result.reason || "Codex is not available");
@@ -249,6 +305,9 @@ module.exports = {
249
305
  errorFor: errorFor,
250
306
  describe: describe,
251
307
  invalidate: invalidate,
308
+ locateCodexPath: locateCodexPath,
309
+ fileIdentity: fileIdentity,
310
+ probe: probe,
252
311
  // Exported so a test can show every value the lookup reads is in the key.
253
312
  _test_cacheKey: cacheKey,
254
313
  };
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "publishConfig": {
4
4
  "access": "public"
5
5
  },
6
- "version": "1.12.0-beta.3",
6
+ "version": "1.13.0-beta.1",
7
7
  "description": "Self-hosted console for Claude Code and Codex. Multi-user, browser-based, persistent AI sessions.",
8
8
  "bin": {
9
9
  "clagentic-console": "./bin/cli.js"
@@ -405,7 +405,12 @@ if (require.main === module) {
405
405
  // needs its own tighter bound sets the `timeout` option on itself.
406
406
  var testTimeoutMs = Number(process.env.CHECK_TEST_COUNT_TEST_TIMEOUT_MS) || 300000;
407
407
 
408
+ // Gives each test process its own temp root, removed on exit (see the
409
+ // helper's header); without it every os.tmpdir()-based test dir is left behind.
410
+ var TMPDIR_PRELOAD = path.join(__dirname, "..", "test", "helpers", "per-process-tmpdir.js");
411
+
408
412
  var result = spawnSync(process.execPath, [
413
+ "--require", TMPDIR_PRELOAD,
409
414
  "--test",
410
415
  "--test-timeout=" + testTimeoutMs,
411
416
  "--test-reporter=tap", "--test-reporter-destination=stdout",