@indigoai-us/hq-cli 5.345.214 → 5.345.215

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 (200) hide show
  1. package/CHANGELOG.md +93 -0
  2. package/assets/scaffold/core/scripts/hq-delegate-verify.sh +5 -2
  3. package/dist/command-catalog.generated.d.ts +180 -13
  4. package/dist/command-catalog.generated.js +221 -13
  5. package/dist/commands/agents.d.ts +51 -1
  6. package/dist/commands/agents.js +154 -2
  7. package/dist/commands/bot-jobs.d.ts +2 -15
  8. package/dist/commands/bot-jobs.js +2 -94
  9. package/dist/commands/bot-runtime.d.ts +46 -5
  10. package/dist/commands/bot-runtime.js +228 -18
  11. package/dist/commands/bot.d.ts +16 -9
  12. package/dist/commands/bot.js +231 -55
  13. package/dist/commands/capacity.d.ts +4 -1
  14. package/dist/commands/capacity.js +46 -10
  15. package/dist/commands/cloud.d.ts +66 -13
  16. package/dist/commands/cloud.js +121 -40
  17. package/dist/commands/company-restore.d.ts +23 -0
  18. package/dist/commands/company-restore.js +128 -0
  19. package/dist/commands/company.js +2 -0
  20. package/dist/commands/core-delegate-w1b.js +15 -1
  21. package/dist/commands/core-policy.js +67 -8
  22. package/dist/commands/daemon.js +5 -0
  23. package/dist/commands/files-browse.d.ts +11 -4
  24. package/dist/commands/files-browse.js +21 -4
  25. package/dist/commands/files.d.ts +1 -1
  26. package/dist/commands/files.js +25 -11
  27. package/dist/commands/integrations-auth-rules.d.ts +27 -0
  28. package/dist/commands/integrations-auth-rules.js +79 -0
  29. package/dist/commands/integrations-connect.d.ts +10 -3
  30. package/dist/commands/integrations-connect.js +87 -13
  31. package/dist/commands/integrations-import.js +124 -12
  32. package/dist/commands/lanes.js +28 -11
  33. package/dist/commands/mesh.d.ts +2 -0
  34. package/dist/commands/mesh.js +60 -35
  35. package/dist/commands/sources.js +6 -0
  36. package/dist/commands/storage-offload.d.ts +12 -0
  37. package/dist/commands/storage-offload.js +41 -3
  38. package/dist/commands/sync-held.js +5 -2
  39. package/dist/commands/sync-mode.js +5 -0
  40. package/dist/commands/whoami.js +4 -0
  41. package/dist/lazy-commands.js +3 -5
  42. package/dist/lib/bot/config.d.ts +1 -0
  43. package/dist/lib/bot/config.js +10 -0
  44. package/dist/lib/bot/eventbridge-cron.d.ts +22 -0
  45. package/dist/lib/bot/eventbridge-cron.js +104 -0
  46. package/dist/lib/bot/fleet-cron.d.ts +8 -0
  47. package/dist/lib/bot/fleet-cron.js +35 -3
  48. package/dist/lib/bot/fleet-daemon.d.ts +46 -0
  49. package/dist/lib/bot/fleet-daemon.js +99 -1
  50. package/dist/lib/bot/fleet-local.d.ts +33 -1
  51. package/dist/lib/bot/fleet-local.js +215 -31
  52. package/dist/lib/bot/fleet-python.d.ts +3 -0
  53. package/dist/lib/bot/fleet-python.js +34 -4
  54. package/dist/lib/bot/fleet-runtime-sources.d.ts +15 -0
  55. package/dist/lib/bot/fleet-runtime-sources.js +30 -0
  56. package/dist/lib/bot/legacy-provider-login.d.ts +8 -0
  57. package/dist/lib/bot/legacy-provider-login.js +19 -2
  58. package/dist/lib/bot/probe.js +7 -1
  59. package/dist/lib/bot/prompt.js +1 -1
  60. package/dist/lib/bot/readiness.d.ts +8 -0
  61. package/dist/lib/bot/readiness.js +17 -3
  62. package/dist/lib/bot/run.js +20 -1
  63. package/dist/lib/bot/runtime/codex.js +1 -1
  64. package/dist/lib/bot/runtime/grok-acp.d.ts +5 -1
  65. package/dist/lib/bot/runtime/grok-acp.js +6 -3
  66. package/dist/lib/bot/runtime/index.js +19 -9
  67. package/dist/lib/bot/runtime/messages-stream.js +2 -2
  68. package/dist/lib/bot/runtime/types.d.ts +15 -0
  69. package/dist/lib/bot/runtime/types.js +9 -0
  70. package/dist/lib/bot/runtime-auth.d.ts +30 -0
  71. package/dist/lib/bot/runtime-auth.js +94 -3
  72. package/dist/lib/bot/runtime-failure.d.ts +23 -0
  73. package/dist/lib/bot/runtime-failure.js +43 -1
  74. package/dist/lib/bot/status.d.ts +2 -0
  75. package/dist/lib/capacity/accounts.d.ts +8 -0
  76. package/dist/lib/capacity/accounts.js +19 -0
  77. package/dist/lib/capacity/available.d.ts +154 -0
  78. package/dist/lib/capacity/available.js +905 -0
  79. package/dist/lib/capacity/codex-availability.d.ts +14 -1
  80. package/dist/lib/capacity/codex-availability.js +26 -1
  81. package/dist/lib/capacity/collectors/claude-oauth.d.ts +29 -2
  82. package/dist/lib/capacity/collectors/claude-oauth.js +104 -7
  83. package/dist/lib/capacity/collectors/codex.js +10 -7
  84. package/dist/lib/capacity/collectors/grok-refresh.d.ts +80 -0
  85. package/dist/lib/capacity/collectors/grok-refresh.js +189 -0
  86. package/dist/lib/capacity/collectors/grok.d.ts +5 -0
  87. package/dist/lib/capacity/collectors/grok.js +56 -5
  88. package/dist/lib/capacity/ledger.d.ts +37 -1
  89. package/dist/lib/capacity/ledger.js +207 -30
  90. package/dist/lib/capacity/project.d.ts +26 -0
  91. package/dist/lib/capacity/project.js +137 -8
  92. package/dist/lib/capacity/refusal-rows.d.ts +31 -0
  93. package/dist/lib/capacity/refusal-rows.js +61 -0
  94. package/dist/lib/capacity/refusal.d.ts +53 -2
  95. package/dist/lib/capacity/refusal.js +284 -65
  96. package/dist/lib/capacity/route.js +46 -11
  97. package/dist/lib/capacity/widget.d.ts +12 -1
  98. package/dist/lib/capacity/widget.js +91 -3
  99. package/dist/lib/daemon/catalog.js +11 -1
  100. package/dist/lib/daemon/resolver.d.ts +2 -0
  101. package/dist/lib/daemon/resolver.js +3 -0
  102. package/dist/lib/daemon/run.d.ts +9 -0
  103. package/dist/lib/daemon/run.js +54 -1
  104. package/dist/lib/daemon/server.d.ts +2 -0
  105. package/dist/lib/daemon/server.js +10 -1
  106. package/dist/lib/daemon/tcc-eperm.d.ts +153 -0
  107. package/dist/lib/daemon/tcc-eperm.js +310 -0
  108. package/dist/lib/db/sqlite-binding.d.ts +1 -0
  109. package/dist/lib/db/sqlite-binding.js +1 -1
  110. package/dist/lib/delivery/admission.d.ts +86 -0
  111. package/dist/lib/delivery/admission.js +148 -0
  112. package/dist/lib/delivery/artifacts.d.ts +105 -0
  113. package/dist/lib/delivery/artifacts.js +567 -0
  114. package/dist/lib/delivery/attempt-id.d.ts +13 -0
  115. package/dist/lib/delivery/attempt-id.js +16 -0
  116. package/dist/lib/delivery/backup.d.ts +78 -0
  117. package/dist/lib/delivery/backup.js +343 -0
  118. package/dist/lib/delivery/cache.d.ts +29 -0
  119. package/dist/lib/delivery/cache.js +33 -0
  120. package/dist/lib/delivery/contracts.d.ts +142 -0
  121. package/dist/lib/delivery/contracts.js +289 -0
  122. package/dist/lib/delivery/credentials.d.ts +54 -0
  123. package/dist/lib/delivery/credentials.js +119 -0
  124. package/dist/lib/delivery/disposable-target.d.ts +42 -0
  125. package/dist/lib/delivery/disposable-target.js +111 -0
  126. package/dist/lib/delivery/effects.d.ts +136 -0
  127. package/dist/lib/delivery/effects.js +541 -0
  128. package/dist/lib/delivery/enrollment.d.ts +146 -0
  129. package/dist/lib/delivery/enrollment.js +460 -0
  130. package/dist/lib/delivery/escalations.d.ts +51 -0
  131. package/dist/lib/delivery/escalations.js +60 -0
  132. package/dist/lib/delivery/identity.d.ts +25 -0
  133. package/dist/lib/delivery/identity.js +82 -0
  134. package/dist/lib/delivery/inbox.d.ts +116 -0
  135. package/dist/lib/delivery/inbox.js +260 -0
  136. package/dist/lib/delivery/lease.d.ts +80 -0
  137. package/dist/lib/delivery/lease.js +134 -0
  138. package/dist/lib/delivery/migrations.d.ts +255 -0
  139. package/dist/lib/delivery/migrations.js +823 -0
  140. package/dist/lib/delivery/mqtt-adapter.d.ts +50 -0
  141. package/dist/lib/delivery/mqtt-adapter.js +242 -0
  142. package/dist/lib/delivery/mqtt.d.ts +63 -0
  143. package/dist/lib/delivery/mqtt.js +119 -0
  144. package/dist/lib/delivery/outbox.d.ts +95 -0
  145. package/dist/lib/delivery/outbox.js +187 -0
  146. package/dist/lib/delivery/provenance.d.ts +129 -0
  147. package/dist/lib/delivery/provenance.js +93 -0
  148. package/dist/lib/delivery/reconciler.d.ts +215 -0
  149. package/dist/lib/delivery/reconciler.js +703 -0
  150. package/dist/lib/delivery/restore.d.ts +35 -0
  151. package/dist/lib/delivery/restore.js +134 -0
  152. package/dist/lib/delivery/rpc/client.d.ts +22 -0
  153. package/dist/lib/delivery/rpc/client.js +159 -0
  154. package/dist/lib/delivery/rpc/port.d.ts +40 -0
  155. package/dist/lib/delivery/rpc/port.js +16 -0
  156. package/dist/lib/delivery/rpc/server.d.ts +30 -0
  157. package/dist/lib/delivery/rpc/server.js +205 -0
  158. package/dist/lib/delivery/rpc/wire.d.ts +85 -0
  159. package/dist/lib/delivery/rpc/wire.js +143 -0
  160. package/dist/lib/delivery/store.d.ts +163 -0
  161. package/dist/lib/delivery/store.js +944 -0
  162. package/dist/lib/delivery/windows-service-install.d.ts +262 -0
  163. package/dist/lib/delivery/windows-service-install.js +892 -0
  164. package/dist/lib/delivery/workers/macos-job-helper.d.ts +103 -0
  165. package/dist/lib/delivery/workers/macos-job-helper.js +927 -0
  166. package/dist/lib/delivery/workers/macos.d.ts +191 -0
  167. package/dist/lib/delivery/workers/macos.js +943 -0
  168. package/dist/lib/delivery/workers/windows-job-helper.d.ts +35 -0
  169. package/dist/lib/delivery/workers/windows-job-helper.js +264 -0
  170. package/dist/lib/delivery/workers/windows-service-live.d.ts +121 -0
  171. package/dist/lib/delivery/workers/windows-service-live.js +711 -0
  172. package/dist/lib/delivery/workers/windows-service-runner.d.ts +33 -0
  173. package/dist/lib/delivery/workers/windows-service-runner.js +82 -0
  174. package/dist/lib/delivery/workers/windows-service.d.ts +140 -0
  175. package/dist/lib/delivery/workers/windows-service.js +584 -0
  176. package/dist/lib/delivery/workers/windows.d.ts +251 -0
  177. package/dist/lib/delivery/workers/windows.js +594 -0
  178. package/dist/lib/hot-channels/adapters/meetings.d.ts +15 -0
  179. package/dist/lib/hot-channels/adapters/meetings.js +36 -3
  180. package/dist/lib/hot-channels/signals-pass.d.ts +10 -0
  181. package/dist/lib/hot-channels/signals-pass.js +71 -2
  182. package/dist/lib/hot-channels/signals-redo.js +10 -2
  183. package/dist/lib/install/provider-wrappers.d.ts +2 -0
  184. package/dist/lib/install/provider-wrappers.js +68 -3
  185. package/dist/lib/lanes/watcher.js +35 -0
  186. package/dist/lib/signals/steps/extract.js +40 -4
  187. package/dist/schemas/hq-available-ai.v1.schema.json +76 -0
  188. package/dist/utils/catalog-runtime-paths.d.ts +34 -0
  189. package/dist/utils/catalog-runtime-paths.js +53 -0
  190. package/dist/utils/cognito-callback-port.d.ts +14 -0
  191. package/dist/utils/cognito-callback-port.js +24 -0
  192. package/dist/utils/cognito-session.js +3 -3
  193. package/dist/utils/deleted-company-notice.d.ts +59 -0
  194. package/dist/utils/deleted-company-notice.js +156 -0
  195. package/dist/utils/files-browse-acl.js +1 -1
  196. package/dist/utils/login-browser.d.ts +1 -1
  197. package/dist/utils/login-browser.js +7 -5
  198. package/dist/utils/resident-package-preload.js +30 -15
  199. package/dist/utils/vault-api.js +7 -0
  200. package/package.json +7 -7
@@ -16,6 +16,7 @@ import { installIntegration, startOAuth } from "./integrations-api.js";
16
16
  import { loadRevealedSecrets } from "./secrets.js";
17
17
  import { registerServer } from "./mcp-registration.js";
18
18
  import { personalConnectorSettingsEnabled } from "./personal-connector-settings-flag.js";
19
+ import { apiKeyIsSendable, authHeaderProblem, MAX_AUTH_HEADER_LENGTH } from "./integrations-auth-rules.js";
19
20
  const OAUTH_REQUIRED_CODE = "INTEGRATION_FACTORY_OAUTH_REQUIRED";
20
21
  /** Claude Desktop's documented connector-config location for the current OS. */
21
22
  export function claudeDesktopConfigPath(platform = process.platform, home = os.homedir(), env = process.env) {
@@ -128,6 +129,63 @@ function isLocal(entry) {
128
129
  function isRemote(entry) {
129
130
  return typeof entry.url === "string";
130
131
  }
132
+ const MAX_BASIC_USERNAME_LENGTH = 256;
133
+ const CONNECT_INSTEAD = "connect it with `hq integrations connect`";
134
+ const KEY_UNSENDABLE_REASON = `its key has a space or a character HQ can't send in a header; copy the key again and ${CONNECT_INSTEAD}`;
135
+ /**
136
+ * feedback_950d8abe: `Authorization: Basic <base64 user:password>` maps to
137
+ * hq-pro's Basic scheme ({ placement: authorization, format: basic }), which
138
+ * stores the password as the key and the username beside it, and rebuilds the
139
+ * same header when it calls the app. Before, the whole `Basic <base64>` value
140
+ * was sent as a raw key with an inner space, which hq-pro refuses.
141
+ */
142
+ function basicCredential(encoded, header) {
143
+ const invalid = { unimportable: "its Authorization: Basic value is not base64-encoded user:password" };
144
+ const unpadded = encoded.replace(/=+$/, "");
145
+ if (!/^[A-Za-z0-9+/]+$/.test(unpadded))
146
+ return invalid;
147
+ const bytes = Buffer.from(unpadded, "base64");
148
+ if (bytes.toString("base64").replace(/=+$/, "") !== unpadded)
149
+ return invalid;
150
+ let pair;
151
+ try {
152
+ pair = new TextDecoder("utf-8", { fatal: true }).decode(bytes);
153
+ }
154
+ catch {
155
+ return invalid;
156
+ }
157
+ const colon = pair.indexOf(":");
158
+ if (colon < 0)
159
+ return invalid;
160
+ const username = pair.slice(0, colon);
161
+ const password = pair.slice(colon + 1);
162
+ const secrets = [header, encoded, unpadded, pair, password];
163
+ // hq-pro refuses control characters (a pasted line break, tab or NUL) in a
164
+ // Basic username or password.
165
+ if (/\p{Cc}/u.test(pair))
166
+ return { unimportable: KEY_UNSENDABLE_REASON };
167
+ if (username === "") {
168
+ // hq-pro's Basic scheme with no username sends `<key>:`, so an empty
169
+ // username with a password has no equivalent there.
170
+ return { unimportable: `its Basic credentials have no username, which HQ can't store; ${CONNECT_INSTEAD}` };
171
+ }
172
+ // hq-pro stores a Basic username of at most this many characters.
173
+ if (username.length > MAX_BASIC_USERNAME_LENGTH) {
174
+ return {
175
+ unimportable: `its Basic username is longer than ${MAX_BASIC_USERNAME_LENGTH} characters, which HQ can't store; ${CONNECT_INSTEAD}`,
176
+ };
177
+ }
178
+ if (password === "") {
179
+ return { value: username, authScheme: { placement: "authorization", format: "basic" }, secrets };
180
+ }
181
+ return { value: password, authScheme: { placement: "authorization", format: "basic", username }, secrets };
182
+ }
183
+ /**
184
+ * Read the connector's static key and how hq-pro should send it. Applies
185
+ * hq-pro's header-name and key rules first (feedback_950d8abe), so a key hq-pro
186
+ * would refuse skips this one connector instead of sending a request that
187
+ * comes back as a 400.
188
+ */
131
189
  function staticCredential(entry) {
132
190
  if (!entry.headers || typeof entry.headers !== "object" || Array.isArray(entry.headers))
133
191
  return undefined;
@@ -136,13 +194,57 @@ function staticCredential(entry) {
136
194
  continue;
137
195
  if (!/(authorization|api[-_]?key|token|secret)/i.test(key))
138
196
  continue;
139
- if (/^authorization$/i.test(key) && /^Bearer\s+/i.test(raw)) {
140
- return { value: raw.replace(/^Bearer\s+/i, "").trim() };
197
+ const value = raw.trim();
198
+ if (/^authorization$/i.test(key)) {
199
+ if (/^Bearer\s+/i.test(value)) {
200
+ const bearer = value.replace(/^Bearer\s+/i, "");
201
+ return apiKeyIsSendable(bearer) ? { value: bearer, secrets: [value, bearer] } : { unimportable: KEY_UNSENDABLE_REASON };
202
+ }
203
+ const basic = /^Basic\s+(\S+)$/i.exec(value);
204
+ if (basic)
205
+ return basicCredential(basic[1], value);
206
+ if (/^Basic\s/i.test(value))
207
+ return basicCredential("", value);
208
+ if (/^\S+\s+\S/.test(value)) {
209
+ return {
210
+ unimportable: `its Authorization header uses a scheme HQ can't import (only Bearer and Basic are imported); ${CONNECT_INSTEAD}`,
211
+ };
212
+ }
141
213
  }
142
- return { value: raw.trim(), authScheme: { placement: "header", header: key } };
214
+ switch (authHeaderProblem(key)) {
215
+ case "invalid":
216
+ return { unimportable: "its credential header name is not a valid HTTP header name" };
217
+ case "denied":
218
+ return {
219
+ unimportable: `HQ can't send a key in the ${key} header; ${CONNECT_INSTEAD} and the header name from the app's docs, such as X-API-Key`,
220
+ };
221
+ case "too-long":
222
+ return {
223
+ unimportable: `its credential header name is longer than ${MAX_AUTH_HEADER_LENGTH} characters, which HQ can't store`,
224
+ };
225
+ case null:
226
+ break;
227
+ }
228
+ if (!apiKeyIsSendable(value))
229
+ return { unimportable: KEY_UNSENDABLE_REASON };
230
+ return { value, authScheme: { placement: "header", header: key }, secrets: [value] };
143
231
  }
144
232
  return undefined;
145
233
  }
234
+ /** hq-pro's message for a refused install, with the connector's key scrubbed out. */
235
+ function refusalReason(error, credential) {
236
+ // hq-pro never quotes a key; scrub every string derived from the header (raw
237
+ // value, base64 with and without padding, decoded pair, password, key) anyway
238
+ // so a future message can't leak it. Any length: a short key is still a key.
239
+ const secrets = [...new Set([credential?.value, ...(credential?.secrets ?? [])])]
240
+ .filter((secret) => typeof secret === "string" && secret !== "")
241
+ .sort((a, b) => b.length - a.length);
242
+ // One pass, longest alternative first: scrubbing one secret at a time lets a
243
+ // short secret match inside an earlier "[redacted]" marker and split it.
244
+ const pattern = secrets.map((secret) => secret.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")).join("|");
245
+ const message = pattern ? error.message.replace(new RegExp(pattern, "g"), "[redacted]") : error.message;
246
+ return `HQ refused this connector${error.code ? ` (${error.code})` : ""}: ${message}`;
247
+ }
146
248
  function oauthRequired(error) {
147
249
  return error instanceof IntegrationsCliError &&
148
250
  (error.code === OAUTH_REQUIRED_CODE || error.oauthProtected === true);
@@ -190,9 +292,12 @@ function writeLocalConnector(hqRoot, name, company, personal, entry) {
190
292
  }
191
293
  async function importRemote(token, companyUid, name, entry, dryRun) {
192
294
  const provider = providerSlug(name);
295
+ const credential = staticCredential(entry);
296
+ if (credential && "unimportable" in credential) {
297
+ return { name, status: "skipped", provider, reason: credential.unimportable };
298
+ }
193
299
  if (dryRun)
194
300
  return { name, status: "imported", reason: "would connect remote MCP endpoint", provider };
195
- const credential = staticCredential(entry);
196
301
  try {
197
302
  return await installRemote(token, companyUid, name, provider, entry, credential);
198
303
  }
@@ -200,14 +305,21 @@ async function importRemote(token, companyUid, name, entry, dryRun) {
200
305
  // Members may import connectors, but not over an app someone else already
201
306
  // connected for the company. Skip that one connector and keep importing
202
307
  // the rest rather than aborting the whole run.
203
- if (!reconnectForbidden(error))
204
- throw error;
205
- return {
206
- name,
207
- status: "skipped",
208
- provider,
209
- reason: "already connected by someone else; ask a company owner or admin to reconnect it",
210
- };
308
+ if (reconnectForbidden(error)) {
309
+ return {
310
+ name,
311
+ status: "skipped",
312
+ provider,
313
+ reason: "already connected by someone else; ask a company owner or admin to reconnect it",
314
+ };
315
+ }
316
+ // feedback_950d8abe: hq-pro refuses one connector's settings (a header or
317
+ // key the checks above did not catch, a bad URL) with a 400. Skip that
318
+ // connector and keep importing the rest.
319
+ if (error instanceof IntegrationsCliError && error.status === 400) {
320
+ return { name, status: "skipped", provider, reason: refusalReason(error, credential) };
321
+ }
322
+ throw error;
211
323
  }
212
324
  }
213
325
  async function installRemote(token, companyUid, name, provider, entry, credential) {
@@ -94,7 +94,7 @@ import { writeQuestionBody } from "../lib/lanes/questions.js";
94
94
  import { compactionAfterUsage, } from "../lib/lanes/compaction.js";
95
95
  import { parseCliEffort, resolveLaneEffort, } from "../lib/lanes/effort.js";
96
96
  import { LanesError } from "../lib/lanes/errors.js";
97
- import { LedgerCorrupt, LedgerMissing, capacityOptionsFromEnv, readCollectorMark, readNow, rebuildNow, } from "../lib/capacity/ledger.js";
97
+ import { LedgerCorrupt, LedgerMissing, capacityOptionsFromEnv, readCollectorMark, readCurrentNow, rebuildNow, } from "../lib/capacity/ledger.js";
98
98
  import { pickAccount, refusalHasNoReadings, refusalHasStaleReading, staleReadingTargets, UNKNOWN_USAGE_SCORE, } from "../lib/capacity/route.js";
99
99
  import { capacityViewAge } from "../lib/capacity/freshness.js";
100
100
  import { applyTerminalToLane, classifyLaneExit, readLatestEnvelopeRecord } from "../lib/lanes/watcher.js";
@@ -1507,17 +1507,17 @@ function laneHostFromCtx(ctx, expectedId) {
1507
1507
  return { kind: "outpost", id: identity.id };
1508
1508
  return recordedLocalHost(ctx);
1509
1509
  }
1510
- async function readOutpostCapacity(ctx, outpostId) {
1511
- return readOutpostCapacityUncached(ctx, outpostId);
1510
+ async function readOutpostCapacity(ctx, outpostId, waitMs = CAPACITY_PROBE_TIMEOUT_MS) {
1511
+ return readOutpostCapacityUncached(ctx, outpostId, waitMs);
1512
1512
  }
1513
- async function readOutpostCapacityUncached(ctx, outpostId) {
1513
+ async function readOutpostCapacityUncached(ctx, outpostId, waitMs = CAPACITY_PROBE_TIMEOUT_MS) {
1514
1514
  let result;
1515
1515
  try {
1516
1516
  result = await ctx.dispatchOutpostExec({
1517
1517
  outpostId,
1518
1518
  command: buildOutpostCapacityCommand(),
1519
- timeoutSeconds: CAPACITY_PROBE_TIMEOUT_MS / 1000,
1520
- waitMs: CAPACITY_PROBE_TIMEOUT_MS,
1519
+ timeoutSeconds: Math.ceil(waitMs / 1000),
1520
+ waitMs,
1521
1521
  });
1522
1522
  }
1523
1523
  catch (err) {
@@ -2268,12 +2268,27 @@ async function loadClaudeBalanceHostSnapshots(ctx, hqRoot, config, options = {})
2268
2268
  }
2269
2269
  const remoteIds = outpostIds.map((id) => id.trim())
2270
2270
  .filter((id) => !isControllerAliasOutpostId(id, localHost))
2271
- .filter((id) => localHost.kind !== "outpost" || id !== localHost.id)
2272
- .sort();
2271
+ .filter((id) => localHost.kind !== "outpost" || id !== localHost.id);
2272
+ const known = new Set(outpostIds.map((id) => id.trim()));
2273
+ const explicitIds = new Set();
2274
+ for (const id of options.includeOutpostIds ?? []) {
2275
+ const trimmed = id.trim();
2276
+ // An explicit target such as --outpost primary is measured even when
2277
+ // `primary` is the controller alias. The generic loop above stays closed.
2278
+ if (trimmed && known.has(trimmed) && !remoteIds.includes(trimmed) &&
2279
+ (localHost.kind !== "outpost" || trimmed !== localHost.id)) {
2280
+ remoteIds.push(trimmed);
2281
+ explicitIds.add(trimmed);
2282
+ }
2283
+ }
2284
+ remoteIds.sort();
2285
+ // An explicit target waits the single-lane pickup interval (120s by
2286
+ // default). The generic capacity loop above keeps the 15s probe.
2287
+ const explicitWaitMs = explicitIds.size > 0 ? outpostSingleLaneWaitMs(ctx.env) : CAPACITY_PROBE_TIMEOUT_MS;
2273
2288
  const remoteResults = await mapWithConcurrency(remoteIds, OUTPOST_HIRE_SUMMARY_CONCURRENCY, async (id) => {
2274
2289
  let capacity;
2275
2290
  try {
2276
- capacity = await readOutpostCapacity(ctx, id);
2291
+ capacity = await readOutpostCapacity(ctx, id, explicitIds.has(id) ? explicitWaitMs : CAPACITY_PROBE_TIMEOUT_MS);
2277
2292
  }
2278
2293
  catch (err) {
2279
2294
  if (isLanesError(err) && err.error !== "outpost_capacity_unavailable") {
@@ -3611,7 +3626,7 @@ async function runCreate(ctx, opts) {
3611
3626
  };
3612
3627
  let view = null;
3613
3628
  try {
3614
- view = readNow(ledgerOptions);
3629
+ view = readCurrentNow(ledgerOptions);
3615
3630
  }
3616
3631
  catch (err) {
3617
3632
  if (err instanceof LedgerCorrupt) {
@@ -4243,7 +4258,9 @@ async function runCreate(ctx, opts) {
4243
4258
  ? { kind: "outpost", id: outpostId }
4244
4259
  : persistedLocalHost);
4245
4260
  balanceTargetHost = targetHost;
4246
- balanceHostLoad = await loadClaudeBalanceHostSnapshots(ctx, hqRoot, config);
4261
+ balanceHostLoad = await loadClaudeBalanceHostSnapshots(ctx, hqRoot, config, {
4262
+ ...(outpostId !== undefined ? { includeOutpostIds: [outpostId] } : {}),
4263
+ });
4247
4264
  const selected = selectClaudeAccount({
4248
4265
  company: accountCompany,
4249
4266
  hosts: balanceHostLoad.snapshots,
@@ -13,6 +13,8 @@ export declare function localPrdWithStory(company: {
13
13
  prdPath: string;
14
14
  source: ProjectPlanSource;
15
15
  } | null;
16
+ /** 404 PROJECT_VIEW_NOT_FOUND: the project has no Board at all yet. */
17
+ export declare function isMissingBoardProject(error: unknown): boolean;
16
18
  type ProjectPlanSource = {
17
19
  name?: string;
18
20
  description?: string;
@@ -211,6 +211,52 @@ function unknownStoryHint(error, company, projectId, storyId, prdPath) {
211
211
  code: error?.code,
212
212
  });
213
213
  }
214
+ /** 404 PROJECT_VIEW_NOT_FOUND: the project has no Board at all yet. */
215
+ export function isMissingBoardProject(error) {
216
+ if (!error || typeof error !== "object" || httpStatus(error) !== 404)
217
+ return false;
218
+ const candidate = error;
219
+ return (candidate.code === "PROJECT_VIEW_NOT_FOUND" ||
220
+ (typeof candidate.message === "string" && candidate.message.includes("PROJECT_VIEW_NOT_FOUND")));
221
+ }
222
+ /**
223
+ * PATCH a story. When the story (or its whole project) is not on the Board but
224
+ * the local prd.json lists it, register the PRD (the same merge `hq mesh
225
+ * project ensure` does) and retry once. `ensure: false` only prints the command.
226
+ */
227
+ async function patchStoryRegisteringLocalPrd(token, company, projectId, storyId, patch, opts) {
228
+ try {
229
+ return { patched: await patchStory(token, company.companyUid, projectId, storyId, patch) };
230
+ }
231
+ catch (err) {
232
+ if (!isUnknownBoardStory(err) && !isMissingBoardProject(err))
233
+ throw err;
234
+ const recovery = localPrdWithStory(company, projectId, storyId);
235
+ if (!recovery)
236
+ throw unknownStoryHint(err, company, projectId, storyId);
237
+ if (opts.ensure === false) {
238
+ throw unknownStoryHint(err, company, projectId, storyId, recovery.prdPath);
239
+ }
240
+ await ensureProjectFromSource({
241
+ token,
242
+ company,
243
+ projectId,
244
+ source: recovery.source,
245
+ current: await getProjectView(token, company.companyUid, projectId).catch((viewErr) => {
246
+ if (httpStatus(viewErr) === 404)
247
+ return undefined;
248
+ throw viewErr;
249
+ }),
250
+ });
251
+ if (!opts.json) {
252
+ console.error(`Work mesh: ${storyId} was not on the ${projectId} Board; registered the project from ${recovery.prdPath}.`);
253
+ }
254
+ return {
255
+ patched: await patchStory(token, company.companyUid, projectId, storyId, patch),
256
+ registeredFrom: recovery.prdPath,
257
+ };
258
+ }
259
+ }
214
260
  async function runStory(opts) {
215
261
  const storyId = opts.story?.trim();
216
262
  const status = opts.status?.trim();
@@ -249,37 +295,7 @@ async function runStory(opts) {
249
295
  let patched;
250
296
  let registeredFrom;
251
297
  try {
252
- try {
253
- patched = await patchStory(token, company.companyUid, projectId, storyId, patch);
254
- }
255
- catch (err) {
256
- if (!isUnknownBoardStory(err))
257
- throw err;
258
- // The story is in the local PRD but not on the Board yet: register the
259
- // PRD (the same merge `hq mesh project ensure` does), then retry once.
260
- const recovery = localPrdWithStory(company, projectId, storyId);
261
- if (!recovery)
262
- throw unknownStoryHint(err, company, projectId, storyId);
263
- if (opts.ensure === false) {
264
- throw unknownStoryHint(err, company, projectId, storyId, recovery.prdPath);
265
- }
266
- await ensureProjectFromSource({
267
- token,
268
- company,
269
- projectId,
270
- source: recovery.source,
271
- current: await getProjectView(token, company.companyUid, projectId).catch((viewErr) => {
272
- if (httpStatus(viewErr) === 404)
273
- return undefined;
274
- throw viewErr;
275
- }),
276
- });
277
- registeredFrom = recovery.prdPath;
278
- if (!opts.json) {
279
- console.error(`Work mesh: ${storyId} was not on the ${projectId} Board; registered the project from ${recovery.prdPath}.`);
280
- }
281
- patched = await patchStory(token, company.companyUid, projectId, storyId, patch);
282
- }
298
+ ({ patched, registeredFrom } = await patchStoryRegisteringLocalPrd(token, company, projectId, storyId, patch, opts));
283
299
  }
284
300
  catch (err) {
285
301
  const conflict = storyConflictFromError(err);
@@ -315,12 +331,13 @@ async function runClaim(opts) {
315
331
  const { token, company } = await withCompany(opts);
316
332
  const me = await requireAssignableSelf(token, "hq mesh claim");
317
333
  let patched;
334
+ let registeredFrom;
318
335
  try {
319
- patched = await patchStory(token, company.companyUid, projectId, storyId, {
336
+ ({ patched, registeredFrom } = await patchStoryRegisteringLocalPrd(token, company, projectId, storyId, {
320
337
  status: "in_progress",
321
338
  assigneeUid: me,
322
339
  ...(opts.force ? { force: true } : {}),
323
- });
340
+ }, opts));
324
341
  }
325
342
  catch (err) {
326
343
  const conflict = storyConflictFromError(err);
@@ -329,7 +346,14 @@ async function runClaim(opts) {
329
346
  throw err;
330
347
  }
331
348
  if (opts.json) {
332
- console.log(JSON.stringify({ ok: true, action: "claim", company, ...patched, storyId }, null, 2));
349
+ console.log(JSON.stringify({
350
+ ok: true,
351
+ action: "claim",
352
+ company,
353
+ ...patched,
354
+ storyId,
355
+ ...(registeredFrom ? { registeredFrom } : {}),
356
+ }, null, 2));
333
357
  return;
334
358
  }
335
359
  console.log(`Work mesh: claimed ${storyId} (in_progress, assignee ${patched.assigneeUid ?? me}) (v${patched.version ?? "?"})`);
@@ -2750,7 +2774,8 @@ export function registerMeshCommand(program, deps = {}) {
2750
2774
  .command("claim")
2751
2775
  .description("Assign a story to yourself and move it to in_progress")
2752
2776
  .requiredOption("--story <id>", "Story id, e.g. US-001")
2753
- .option("--force", "Take the story even when someone else holds it")).action((opts) => wrap(() => runClaim(opts))());
2777
+ .option("--force", "Take the story even when someone else holds it")
2778
+ .option("--no-ensure", "Do not register the project from its local prd.json when the story is not on the Board")).action((opts) => wrap(() => runClaim(opts))());
2754
2779
  mesh
2755
2780
  .command("overlap")
2756
2781
  .description("List other sessions working on the same story, branch, or files")
@@ -25,6 +25,7 @@ import * as fs from "node:fs";
25
25
  import * as path from "node:path";
26
26
  import { InvalidArgumentError } from "commander";
27
27
  import chalk from "chalk";
28
+ import { printDeletedCompanyNotices } from "../utils/deleted-company-notice.js";
28
29
  import { SOURCE_CHANNELS, assertSourceChannel, resolveEntity, listAvailableEntities, listSources, getSource, VaultClient, } from "@indigoai-us/hq-cloud";
29
30
  import { ensureCognitoToken, ensureCognitoIdToken, buildVaultConfig, DEFAULT_COGNITO, DEFAULT_HQ_ROOT, } from "../utils/cognito-session.js";
30
31
  import { getCompanyUid, vaultApiFetch } from "../utils/vault-api.js";
@@ -221,6 +222,11 @@ async function runEntities(options) {
221
222
  const accessToken = await resolveAccessToken();
222
223
  const vaultConfig = buildVaultConfig(accessToken);
223
224
  const entities = await listAvailableEntities({ vaultConfig });
225
+ // An empty list may mean the person's company was deleted. Say so on stderr;
226
+ // stdout (including --json) is unchanged.
227
+ if (entities.length === 0) {
228
+ await printDeletedCompanyNotices({ token: accessToken });
229
+ }
224
230
  if (format === "json") {
225
231
  process.stdout.write(JSON.stringify(entities, null, 2) + "\n");
226
232
  return;
@@ -335,8 +335,20 @@ export interface SyncRecord {
335
335
  /**
336
336
  * `companies/<slug>/<rest>` belongs to that company's vault at key `<rest>`.
337
337
  * Every other path belongs to the personal vault at its HQ-root-relative path.
338
+ * The match is exact-case, the same as companyForPointer. Callers pass a path
339
+ * from hqRelative (below), which spells the HQ companies folder as `companies`.
338
340
  */
339
341
  export declare function resolveOffloadTarget(rel: string): OffloadTarget;
342
+ /**
343
+ * companiesOnDisk is the on-disk name of `<HQ root>/companies` (from native
344
+ * realpath). On a case-insensitive volume whose folder is spelled, say,
345
+ * `Companies`, native realpath returns that spelling, and this maps it back
346
+ * to `companies` so it stays a company path (this is the macOS intent of
347
+ * #2475). On a case-sensitive volume a `COMPANIES/` folder is a different
348
+ * folder, its first segment never equals the on-disk name `companies`, so it
349
+ * stays personal.
350
+ */
351
+ export declare function canonicalCompaniesRel(rel: string, companiesOnDisk: string | null): string;
340
352
  /** Whether current-file offload can run with the installed HQ sync. */
341
353
  export declare function currentSyncReady(deps: Pick<OffloadDeps, "syncExcludesOffload" | "syncHoldsPlaceholders">): boolean;
342
354
  export declare function storageScriptPath(hqRoot: string): string;
@@ -518,14 +518,49 @@ export function s3VaultObjectStore(bucket, s3, opts = {}) {
518
518
  /**
519
519
  * `companies/<slug>/<rest>` belongs to that company's vault at key `<rest>`.
520
520
  * Every other path belongs to the personal vault at its HQ-root-relative path.
521
+ * The match is exact-case, the same as companyForPointer. Callers pass a path
522
+ * from hqRelative (below), which spells the HQ companies folder as `companies`.
521
523
  */
522
524
  export function resolveOffloadTarget(rel) {
523
525
  const posix = toPosix(rel);
524
- const m = /^companies\/([^/]+)\/(.+)$/i.exec(posix);
526
+ const m = /^companies\/([^/]+)\/(.+)$/.exec(posix);
525
527
  if (m)
526
528
  return { vault: "company", slug: m[1], key: m[2] };
527
529
  return { vault: "personal", key: posix };
528
530
  }
531
+ /**
532
+ * companiesOnDisk is the on-disk name of `<HQ root>/companies` (from native
533
+ * realpath). On a case-insensitive volume whose folder is spelled, say,
534
+ * `Companies`, native realpath returns that spelling, and this maps it back
535
+ * to `companies` so it stays a company path (this is the macOS intent of
536
+ * #2475). On a case-sensitive volume a `COMPANIES/` folder is a different
537
+ * folder, its first segment never equals the on-disk name `companies`, so it
538
+ * stays personal.
539
+ */
540
+ export function canonicalCompaniesRel(rel, companiesOnDisk) {
541
+ const slash = rel.indexOf("/");
542
+ const first = slash === -1 ? rel : rel.slice(0, slash);
543
+ if (first !== "companies" && companiesOnDisk !== null && first === companiesOnDisk) {
544
+ const rest = slash === -1 ? "" : rel.slice(slash);
545
+ return `companies${rest}`;
546
+ }
547
+ return rel;
548
+ }
549
+ /** HQ-root-relative path of `abs`, with the companies folder spelled `companies`. */
550
+ function hqRelative(realRoot, abs) {
551
+ const rel = toPosix(path.relative(realRoot, abs));
552
+ let companiesOnDisk = null;
553
+ try {
554
+ const companiesReal = fs.realpathSync.native(path.join(realRoot, "companies"));
555
+ // A symlinked companies folder pointing elsewhere is not renamed.
556
+ if (path.dirname(companiesReal) === realRoot)
557
+ companiesOnDisk = path.basename(companiesReal);
558
+ }
559
+ catch {
560
+ // Missing or unreadable: leave the relative path unchanged.
561
+ }
562
+ return canonicalCompaniesRel(rel, companiesOnDisk);
563
+ }
529
564
  /** Whether current-file offload can run with the installed HQ sync. */
530
565
  export function currentSyncReady(deps) {
531
566
  return deps.syncExcludesOffload() && deps.syncHoldsPlaceholders?.() === true;
@@ -599,6 +634,8 @@ export function worktreeHoldsAllCopy(held) {
599
634
  export function selectHistoryBlobs(blobs, minBytes) {
600
635
  // A blob may have both personal and company names. Never send any such
601
636
  // content to the personal store; historical paths need no longer exist.
637
+ // History paths are git tree names, not on-disk spellings, and excluding a
638
+ // blob keeps it in local history, so a case-insensitive exclusion is the safe direction.
602
639
  return blobs.filter((b) => !b.in_head && b.bytes >= minBytes && b.paths.length > 0 &&
603
640
  b.paths.every((p) => !/^companies(?:\/|$)/i.test(toPosix(path.posix.normalize(toPosix(p))))));
604
641
  }
@@ -677,7 +714,7 @@ export async function offloadCurrentFile(rel, store, deps, fsOps = durablePlaceh
677
714
  if (store.vault !== "personal")
678
715
  throw new Error("Offload only writes to your personal vault.");
679
716
  const abs = containedPath(deps.hqRoot, rel);
680
- rel = toPosix(path.relative(fs.realpathSync.native(deps.hqRoot), abs));
717
+ rel = hqRelative(fs.realpathSync.native(deps.hqRoot), abs);
681
718
  if (resolveOffloadTarget(rel).vault === "company") {
682
719
  throw new Error(`'${rel}' is a company file. Company files are never uploaded to your personal vault.`);
683
720
  }
@@ -1063,7 +1100,7 @@ async function planCurrentFiles(rels, opts, deps, openVault) {
1063
1100
  for (const candidate of rels) {
1064
1101
  const abs = containedPath(deps.hqRoot, candidate);
1065
1102
  // Canonicalise discovery output too, not just explicit path arguments.
1066
- const rel = toPosix(path.relative(fs.realpathSync.native(deps.hqRoot), abs));
1103
+ const rel = hqRelative(fs.realpathSync.native(deps.hqRoot), abs);
1067
1104
  if (skippedByName(rel))
1068
1105
  continue;
1069
1106
  let st;
@@ -1557,6 +1594,7 @@ async function downloadVerified(download, key, dest, expect) {
1557
1594
  }
1558
1595
  /** Company slug for a company-vault placeholder, checked against its key. */
1559
1596
  export function companyForPointer(pointer) {
1597
+ // Must stay exact-case, matching resolveOffloadTarget.
1560
1598
  const m = /^companies\/([^/]+)\/(.+)$/.exec(pointer.path);
1561
1599
  if (!m || (!isCompanyOffloadCopy(pointer) && m[2] !== pointer.key)) {
1562
1600
  throw new Error(`Placeholder for '${pointer.path}' names company vault key '${pointer.key}', which does not match its location. Nothing was changed.`);
@@ -60,7 +60,10 @@ export async function runSyncHeld(deps, json = false) {
60
60
  deps.log("No uploads are held on this computer.");
61
61
  return 0;
62
62
  }
63
- deps.log("Someone else was signed in on this computer, so these uploads are held:");
63
+ // First install also writes this hold (feedback_baa82c96). Do not say
64
+ // another account was signed in; that is often false and reads as a
65
+ // security scare. The hold is still a confirmation before upload.
66
+ deps.log("These uploads are held until you confirm they belong to the signed-in account on this computer:");
64
67
  for (const scope of scopes)
65
68
  for (const line of describe(scope))
66
69
  deps.log(line);
@@ -172,7 +175,7 @@ export function createDefaultSyncHeldDeps() {
172
175
  export function registerSyncHeldCommands(syncCmd) {
173
176
  syncCmd
174
177
  .command("held")
175
- .description("Show uploads held because someone else was signed in on this computer")
178
+ .description("Show uploads held until you confirm they belong to the signed-in account")
176
179
  .option("--json", "Print the held scopes as JSON")
177
180
  .action(async (options) => {
178
181
  process.exitCode = await runSyncHeld(createDefaultSyncHeldDeps(), options.json === true);
@@ -30,6 +30,7 @@
30
30
  * in package.json — revert that line to `^5.20.0` (or whatever the
31
31
  * published cut is) once US-004 ships to npm.
32
32
  */
33
+ import { printDeletedCompanyNotices } from "../utils/deleted-company-notice.js";
33
34
  import { isAccessDeniedError, accessDeniedKeyOf, reportAccessDenied, accessDeniedCompanyOf, } from "../utils/access-denied-hint.js";
34
35
  import chalk from "chalk";
35
36
  import * as fs from "node:fs";
@@ -243,6 +244,10 @@ export function registerSyncModeCommand(syncCmd) {
243
244
  }
244
245
  const rows = await showSyncModes({ vaultClient: client });
245
246
  console.log(formatShowTable(rows));
247
+ // No memberships may mean the person's company was deleted.
248
+ if (rows.length === 0) {
249
+ await printDeletedCompanyNotices({ token: accessToken });
250
+ }
246
251
  return;
247
252
  }
248
253
  if (!modeArg) {
@@ -9,6 +9,7 @@ import { colorizePlanLimitNotice, fetchPlanLimitStatus, renderPlanLine, renderPl
9
9
  import { resolveCompanyFlagGate, } from "../lib/flag-registry.js";
10
10
  import { queuePlanLimitInviteTeammateExposure } from "../utils/cli-telemetry.js";
11
11
  import { resolveCallerPersonUid } from "../utils/vault-api.js";
12
+ import { printDeletedCompanyNotices } from "../utils/deleted-company-notice.js";
12
13
  export const CLI_LIMIT_INVITE_TEAMMATE_FLAG = "cli.limit-invite-teammate-v1";
13
14
  /**
14
15
  * Resolves the person represented by an ID token without pairing a delegated
@@ -228,6 +229,9 @@ export function registerWhoamiCommand(program) {
228
229
  const { email, sub } = resolveWhoamiIdentity(peekIdToken(cached.idToken));
229
230
  console.log(`Logged in as ${email ?? 'unknown'}${sub ? ` (${sub})` : ''}`);
230
231
  await printPlanBlock(opts.company);
232
+ // Person sessions only: a deleted company is otherwise invisible here.
233
+ // Bounded like the person-uid lookup, on stderr, and never a failure.
234
+ await printDeletedCompanyNotices({ timeoutMs: PERSON_UID_LOOKUP_TIMEOUT_MS });
231
235
  }
232
236
  catch (error) {
233
237
  console.error(chalk.red('Error:'), error instanceof Error ? error.message : 'Unknown error');
@@ -1,9 +1,10 @@
1
1
  import { Argument, Command, Option } from "commander";
2
2
  import { existsSync } from "node:fs";
3
3
  import { homedir } from "node:os";
4
- import { dirname, join, resolve } from "node:path";
4
+ import { dirname, join, resolve, sep } from "node:path";
5
5
  import { COMMAND_CATALOG } from "./command-catalog.generated.js";
6
6
  import { installUnknownCommandSuggestions } from "./unknown-command.js";
7
+ import { restoreRuntimeText } from "./utils/catalog-runtime-paths.js";
7
8
  import { MissingRegistrationPlanError } from "./utils/registration-plan-error.js";
8
9
  const commandCatalog = COMMAND_CATALOG;
9
10
  /**
@@ -71,10 +72,7 @@ function commandDefinition(command) {
71
72
  }
72
73
  function restoreRuntimePath(value) {
73
74
  if (typeof value === "string") {
74
- let restored = value.replaceAll("<runtime-home>", homedir());
75
- if (restored.includes("<runtime-path>"))
76
- restored = restored.replaceAll("<runtime-path>", runtimeHqRoot());
77
- return restored;
75
+ return restoreRuntimeText(value, { home: homedir(), hqRoot: runtimeHqRoot }, sep);
78
76
  }
79
77
  if (Array.isArray(value))
80
78
  return value.map(restoreRuntimePath);
@@ -14,6 +14,7 @@ export interface BotEngineMetadata {
14
14
  }
15
15
  export declare function isBotEngineMetadata(value: unknown): value is BotEngineMetadata;
16
16
  export declare function isBotRuntimeId(value: unknown): value is BotRuntimeId;
17
+ export declare function botRuntimeFromBrainName(value: string | undefined | null): BotRuntimeId | null;
17
18
  /**
18
19
  * What a bot is (owner decisions, 2026-09-15):
19
20
  * - "personal": acts as its owner. Every turn (DMs, kickoff, rooms) runs with
@@ -23,6 +23,16 @@ export function isBotEngineMetadata(value) {
23
23
  export function isBotRuntimeId(value) {
24
24
  return typeof value === "string" && BOT_RUNTIMES.includes(value);
25
25
  }
26
+ export function botRuntimeFromBrainName(value) {
27
+ const name = (value ?? "").trim().toLowerCase();
28
+ if (name === "claude")
29
+ return "claude";
30
+ if (name === "codex" || name === "chatgpt")
31
+ return "codex";
32
+ if (name === "grok")
33
+ return "grok";
34
+ return null;
35
+ }
26
36
  /**
27
37
  * What a bot is (owner decisions, 2026-09-15):
28
38
  * - "personal": acts as its owner. Every turn (DMs, kickoff, rooms) runs with