agl 42.0.0 → 42.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (168) hide show
  1. package/changelog.md +44 -0
  2. package/dist_serve/bundle.js +2520 -2158
  3. package/dist_serve/bundle.js.map +2 -2
  4. package/dist_ts/00_commitinfo_data.js +1 -1
  5. package/dist_ts/aglapi/aglapisurface.document.js +124 -10
  6. package/dist_ts/classes.accountsactions.d.ts +3 -1
  7. package/dist_ts/classes.accountsactions.js +16 -1
  8. package/dist_ts/classes.authstore.d.ts +2 -0
  9. package/dist_ts/classes.authstore.js +58 -17
  10. package/dist_ts/classes.cli.js +19 -49
  11. package/dist_ts/classes.configurationauthority.js +2 -2
  12. package/dist_ts/classes.controller.d.ts +71 -2
  13. package/dist_ts/classes.controller.js +500 -113
  14. package/dist_ts/classes.controllerdevices.d.ts +128 -0
  15. package/dist_ts/classes.controllerdevices.js +472 -0
  16. package/dist_ts/classes.controllerservice.d.ts +20 -2
  17. package/dist_ts/classes.controllerservice.js +42 -6
  18. package/dist_ts/classes.flexservice.js +8 -3
  19. package/dist_ts/classes.inferencegateway.d.ts +30 -2
  20. package/dist_ts/classes.inferencegateway.js +115 -20
  21. package/dist_ts/classes.inferencerouter.d.ts +16 -0
  22. package/dist_ts/classes.inferencerouter.js +5 -3
  23. package/dist_ts/classes.inferenceservice.js +7 -3
  24. package/dist_ts/classes.sessionfeed.d.ts +10 -1
  25. package/dist_ts/classes.sessionfeed.js +12 -2
  26. package/dist_ts/classes.ticketmodels.js +4 -3
  27. package/dist_ts/classes.ticketnotifier.js +9 -2
  28. package/dist_ts/classes.ticketstore.js +9 -5
  29. package/dist_ts/classes.upgradecoordinator.d.ts +6 -1
  30. package/dist_ts/classes.upgradecoordinator.js +9 -2
  31. package/dist_ts/classes.upgradetransaction.d.ts +27 -1
  32. package/dist_ts/classes.upgradetransaction.js +92 -2
  33. package/dist_ts/classes.validation.d.ts +2 -0
  34. package/dist_ts/classes.validation.js +2 -2
  35. package/dist_ts/configuration/functions.master.d.ts +7 -2
  36. package/dist_ts/configuration/functions.master.js +7 -4
  37. package/dist_ts/driver/classes.drivereventrelay.d.ts +1 -1
  38. package/dist_ts/driver/classes.drivereventrelay.js +3 -3
  39. package/dist_ts/fleet/classes.boardpump.d.ts +1 -1
  40. package/dist_ts/fleet/classes.boardpump.js +7 -4
  41. package/dist_ts/fleet/classes.claudeworkers.d.ts +6 -0
  42. package/dist_ts/fleet/classes.claudeworkers.js +17 -7
  43. package/dist_ts/fleet/classes.deploymodels.d.ts +19 -0
  44. package/dist_ts/fleet/classes.deploymodels.js +140 -0
  45. package/dist_ts/fleet/functions.validation.d.ts +8 -1
  46. package/dist_ts/fleet/functions.validation.js +65 -3
  47. package/dist_ts/fleet/interfaces.workers.d.ts +6 -0
  48. package/dist_ts/fleet/interfaces.workers.js +65 -2
  49. package/dist_ts/functions.deviceapi.d.ts +28 -0
  50. package/dist_ts/functions.deviceapi.js +246 -0
  51. package/dist_ts/functions.deviceproof.d.ts +33 -0
  52. package/dist_ts/functions.deviceproof.js +93 -0
  53. package/dist_ts/functions.fleetworkercli.d.ts +16 -3
  54. package/dist_ts/functions.fleetworkercli.js +21 -7
  55. package/dist_ts/functions.inferencecli.js +4 -2
  56. package/dist_ts/functions.mcptickettools.d.ts +1 -0
  57. package/dist_ts/functions.remotecli.d.ts +1 -1
  58. package/dist_ts/functions.remotecli.js +12 -7
  59. package/dist_ts/functions.ticketvalidation.d.ts +36 -3
  60. package/dist_ts/functions.ticketvalidation.js +45 -14
  61. package/dist_ts/interfaces.auth.d.ts +1 -1
  62. package/dist_ts/interfaces.auth.js +7 -1
  63. package/dist_ts_authswitch/authority-contract.d.ts +23 -0
  64. package/dist_ts_authswitch/authority-contract.js +1 -1
  65. package/dist_ts_authswitch/classes.authoritybroker.d.ts +6 -0
  66. package/dist_ts_authswitch/classes.authoritybroker.js +31 -4
  67. package/dist_ts_authswitch/classes.authoritycli.d.ts +1 -0
  68. package/dist_ts_authswitch/classes.authoritycli.js +26 -1
  69. package/dist_ts_authswitch/classes.authorityclient.d.ts +3 -1
  70. package/dist_ts_authswitch/classes.authorityclient.js +10 -4
  71. package/dist_ts_authswitch/classes.authoritydaemon.js +7 -1
  72. package/dist_ts_authswitch/classes.authorityimport.js +2 -2
  73. package/dist_ts_authswitch/classes.authoritymodels.d.ts +3 -0
  74. package/dist_ts_authswitch/classes.authoritymodels.js +10 -3
  75. package/dist_ts_authswitch/testsupport.js +4 -4
  76. package/dist_ts_authswitch/ts_migration/0012_account_claude_code.d.ts +11 -0
  77. package/dist_ts_authswitch/ts_migration/0012_account_claude_code.js +18 -0
  78. package/dist_ts_authswitch/ts_migration/index.js +3 -1
  79. package/dist_ts_interfaces/deployments.d.ts +104 -0
  80. package/dist_ts_interfaces/deployments.js +8 -0
  81. package/dist_ts_interfaces/devices.d.ts +331 -0
  82. package/dist_ts_interfaces/devices.js +34 -0
  83. package/dist_ts_interfaces/fleet.d.ts +2 -0
  84. package/dist_ts_interfaces/index.d.ts +3 -0
  85. package/dist_ts_interfaces/index.js +4 -1
  86. package/dist_ts_interfaces/interfaces.d.ts +4 -2
  87. package/dist_ts_interfaces/interfaces.js +3 -2
  88. package/dist_ts_interfaces/mcprequests.d.ts +1 -1
  89. package/dist_ts_interfaces/requests.accounts.d.ts +18 -0
  90. package/dist_ts_interfaces/requests.accounts.js +1 -1
  91. package/dist_ts_interfaces/requests.d.ts +3 -2
  92. package/dist_ts_interfaces/requests.devices.d.ts +89 -0
  93. package/dist_ts_interfaces/requests.devices.js +2 -0
  94. package/dist_ts_interfaces/requests.js +1 -1
  95. package/dist_ts_interfaces/tickets.d.ts +53 -4
  96. package/dist_ts_interfaces/tickets.js +6 -2
  97. package/dist_ts_migration/index.d.ts +1 -0
  98. package/dist_ts_migration/index.js +2 -1
  99. package/dist_ts_migration/v41_ticketmigrationmarkers.d.ts +19 -0
  100. package/dist_ts_migration/v41_ticketmigrationmarkers.js +85 -0
  101. package/docs/authswitch.md +6 -0
  102. package/package.json +5 -5
  103. package/readme.md +84 -16
  104. package/ts/00_commitinfo_data.ts +1 -1
  105. package/ts/aglapi/aglapisurface.document.ts +123 -9
  106. package/ts/classes.accountsactions.ts +24 -0
  107. package/ts/classes.authstore.ts +54 -14
  108. package/ts/classes.cli.ts +17 -54
  109. package/ts/classes.configurationauthority.ts +1 -1
  110. package/ts/classes.controller.ts +697 -167
  111. package/ts/classes.controllerdevices.ts +469 -0
  112. package/ts/classes.controllerservice.ts +49 -6
  113. package/ts/classes.flexservice.ts +7 -2
  114. package/ts/classes.inferencegateway.ts +133 -19
  115. package/ts/classes.inferencerouter.ts +20 -2
  116. package/ts/classes.inferenceservice.ts +6 -3
  117. package/ts/classes.sessionfeed.ts +13 -1
  118. package/ts/classes.ticketmodels.ts +3 -2
  119. package/ts/classes.ticketnotifier.ts +8 -1
  120. package/ts/classes.ticketstore.ts +8 -4
  121. package/ts/classes.upgradecoordinator.ts +14 -4
  122. package/ts/classes.upgradetransaction.ts +118 -0
  123. package/ts/classes.validation.ts +1 -1
  124. package/ts/configuration/functions.master.ts +6 -3
  125. package/ts/driver/classes.drivereventrelay.ts +2 -2
  126. package/ts/fleet/classes.boardpump.ts +7 -4
  127. package/ts/fleet/classes.claudeworkers.ts +16 -6
  128. package/ts/fleet/classes.deploymodels.ts +44 -0
  129. package/ts/fleet/functions.validation.ts +50 -2
  130. package/ts/fleet/interfaces.workers.ts +56 -1
  131. package/ts/functions.deviceapi.ts +295 -0
  132. package/ts/functions.deviceproof.ts +118 -0
  133. package/ts/functions.fleetworkercli.ts +26 -8
  134. package/ts/functions.inferencecli.ts +3 -1
  135. package/ts/functions.remotecli.ts +11 -5
  136. package/ts/functions.ticketvalidation.ts +48 -13
  137. package/ts/interfaces.auth.ts +6 -0
  138. package/ts_authswitch/authority-contract.ts +18 -0
  139. package/ts_authswitch/classes.authoritybroker.ts +29 -3
  140. package/ts_authswitch/classes.authoritycli.ts +29 -0
  141. package/ts_authswitch/classes.authorityclient.ts +12 -4
  142. package/ts_authswitch/classes.authoritydaemon.ts +8 -1
  143. package/ts_authswitch/classes.authorityimport.ts +1 -1
  144. package/ts_authswitch/classes.authoritymodels.ts +5 -1
  145. package/ts_authswitch/native-contracts.md +10 -0
  146. package/ts_authswitch/testsupport.ts +3 -3
  147. package/ts_authswitch/ts_migration/0012_account_claude_code.ts +17 -0
  148. package/ts_authswitch/ts_migration/index.ts +2 -0
  149. package/ts_interfaces/deployments.ts +98 -0
  150. package/ts_interfaces/devices.schema.json +890 -0
  151. package/ts_interfaces/devices.ts +392 -0
  152. package/ts_interfaces/fleet.ts +2 -0
  153. package/ts_interfaces/index.ts +3 -0
  154. package/ts_interfaces/interfaces.ts +4 -1
  155. package/ts_interfaces/mcprequests.ts +1 -1
  156. package/ts_interfaces/requests.accounts.ts +16 -0
  157. package/ts_interfaces/requests.devices.ts +95 -0
  158. package/ts_interfaces/requests.ts +12 -0
  159. package/ts_interfaces/tickets.ts +34 -4
  160. package/ts_migration/index.ts +1 -0
  161. package/ts_migration/v41_ticketmigrationmarkers.ts +28 -0
  162. package/ts_web/00_commitinfo_data.ts +1 -1
  163. package/ts_web/classes.accountsreadmodel.ts +12 -1
  164. package/ts_web/classes.controllersocketclient.ts +27 -0
  165. package/ts_web/elements.accounts.ts +44 -0
  166. package/ts_web/elements.devices.ts +752 -0
  167. package/ts_web/elements.harnesscontrollerapp.ts +18 -1
  168. package/ts_web/elements.ticketboard.ts +15 -4
@@ -1,5 +1,5 @@
1
1
  import * as plugins from './plugins.js';
2
- import { inferenceCredentials, inferencePlanPattern, inferenceProviders, type TInferenceCredential,
2
+ import { aglProxyConfinedClient, inferenceCredentials, inferencePlanPattern, inferenceProviders, type TInferenceCredential,
3
3
  type TInferenceProvider } from './functions.proxycontract.js';
4
4
  import { InferenceRouter, InferenceRoutingError, inferenceSpendLimitText, type IInferenceAccountUnavailable,
5
5
  type IInferenceClaudeRoute, type IInferenceRoute, type IInferenceRoutingPolicy,
@@ -40,8 +40,34 @@ export interface IInferenceGatewayRequestFailure {
40
40
  code: string;
41
41
  protocol?: TProtocol;
42
42
  error?: string;
43
+ /**
44
+ * For a request refused before its client was known (AGL-304): the path it asked for, without its query, and the
45
+ * client's own name for itself (`user-agent`), each printable ASCII and cut short (`refusalText`), so a looping
46
+ * client can be found from the journal. Never a header value beyond those, never the credential.
47
+ */
48
+ path?: string;
49
+ userAgent?: string;
50
+ /** For a 401: what the request presented (`TInferenceGatewayCredentialRefusal`). */
51
+ credential?: TInferenceGatewayCredentialRefusal;
52
+ }
53
+
54
+ /**
55
+ * What a refused request presented as its gateway credential: none, one the gateway cannot read (not a bearer token or
56
+ * `x-api-key`, or over 512 characters), one no client holds, or one of a client of the other listener.
57
+ */
58
+ export type TInferenceGatewayCredentialRefusal = 'missing' | 'malformed' | 'unknown' | 'other_listener';
59
+
60
+ /** A 401 that says what the request presented (`TInferenceGatewayCredentialRefusal`); its answer stays the same. */
61
+ class InferenceCredentialRefusal extends InferenceRoutingError {
62
+ constructor(public readonly credential: TInferenceGatewayCredentialRefusal) {
63
+ super(401, 'authentication_error', 'The gateway credential is invalid or expired.');
64
+ }
43
65
  }
44
66
 
67
+ /** A header value or path as a refusal line may carry it: printable ASCII only, at most `maximumArg` characters. */
68
+ const refusalText = (valueArg: string, maximumArg: number): string =>
69
+ valueArg.replace(/[^\x20-\x7e]/gu, '?').replace(/"/gu, '\'').slice(0, maximumArg);
70
+
45
71
  export interface IInferenceGatewayOptions {
46
72
  router: InferenceRouter;
47
73
  signatureKey: Uint8Array;
@@ -110,16 +136,61 @@ export interface IInferenceGatewayStreamCut {
110
136
  error: string;
111
137
  }
112
138
 
139
+ /**
140
+ * The highest `sequence_number` a Responses stream relayed so far, read across chunk boundaries (AGL-375): a
141
+ * `response.failed` the gateway ends a cut stream with continues the numbering, as the AI SDK's chunk schema, which
142
+ * Flex validates every event against, requires the number on it.
143
+ */
144
+ class ResponsesSequence {
145
+ private readonly decoder = new TextDecoder();
146
+ /** The end of the text read so far, so a number split between two chunks is still read whole. */
147
+ private tail = '';
148
+ private highest = -1;
149
+
150
+ public feed(chunkArg: Uint8Array): void {
151
+ const text = this.tail + this.decoder.decode(chunkArg, { stream: true });
152
+ for (const match of text.matchAll(/"sequence_number"\s*:\s*(\d{1,15})/gu)) {
153
+ this.highest = Math.max(this.highest, Number(match[1]));
154
+ }
155
+ this.tail = text.slice(-40);
156
+ }
157
+
158
+ /** The number the next event takes: one past the highest relayed, 0 when none was. */
159
+ public get next(): number { return this.highest + 1; }
160
+ }
161
+
113
162
  const writeStreamCut = (cutArg: IInferenceGatewayStreamCut): void => {
114
163
  process.stderr.write(`AGL proxy cut a ${cutArg.protocol} stream of account ${cutArg.account} after ${cutArg.bytes} bytes: `
115
164
  + `${cutArg.cause} (${cutArg.error})\n`);
116
165
  };
117
166
 
118
- const writeRequestFailure = (failureArg: IInferenceGatewayRequestFailure): void => {
119
- process.stderr.write(`AGL proxy refused ${failureArg.protocol ?? 'http'} request: HTTP ${failureArg.status} ${failureArg.code}`
120
- + `${failureArg.error ? ` (${failureArg.error})` : ''}\n`);
167
+ const refusalRepeatWindowMs = 60_000;
168
+
169
+ /**
170
+ * The proxy's journal line per refusal, the same line at most once a minute (AGL-304): a client that repeats a refused
171
+ * request in a loop gets its line once, and the next one after the minute says how many like it the minute held.
172
+ */
173
+ export const inferenceRequestFailureWriter = (writeArg: (textArg: string) => void = (textArg) => { process.stderr.write(textArg); },
174
+ nowArg: () => number = Date.now): ((failureArg: IInferenceGatewayRequestFailure) => void) => {
175
+ /** Each line's last write and the like ones since. */
176
+ const written = new Map<string, { at: number; since: number }>();
177
+ return (failureArg) => {
178
+ const line = `AGL proxy refused ${failureArg.protocol ?? 'http'} request: HTTP ${failureArg.status} ${failureArg.code}`
179
+ + `${failureArg.error ? ` (${failureArg.error})` : ''}`
180
+ + `${failureArg.path === undefined ? '' : ` for ${failureArg.path}`}`
181
+ + `${failureArg.userAgent === undefined ? '' : ` from "${failureArg.userAgent}"`}`
182
+ + `${failureArg.credential === undefined ? '' : `, credential ${failureArg.credential}`}`;
183
+ const now = nowArg();
184
+ const last = written.get(line);
185
+ if (last && now - last.at < refusalRepeatWindowMs) { last.since += 1; return; }
186
+ if (written.size >= 256) for (const [key, entry] of written) if (now - entry.at >= refusalRepeatWindowMs) written.delete(key);
187
+ written.set(line, { at: now, since: 0 });
188
+ writeArg(`${line}${last?.since ? ` (and ${last.since} more like it in the minute before)` : ''}\n`);
189
+ };
121
190
  };
122
191
 
192
+ const writeRequestFailure = inferenceRequestFailureWriter();
193
+
123
194
  /** A failure's class and system code; never its message, which can quote what the provider sent. */
124
195
  const describeStreamFailure = (errorArg: unknown): string => {
125
196
  if (errorArg instanceof InferenceOutputError) return `${errorArg.name} ${errorArg.providerCode ?? errorArg.message}`;
@@ -207,6 +278,20 @@ interface IClient {
207
278
  /** Codex's Responses, Messages answered by a ChatGPT pool, or Claude Code's own Messages sent to a Claude pool. */
208
279
  type TProtocol = 'responses' | 'messages' | 'claude';
209
280
 
281
+ /**
282
+ * The clients AGL runs Claude Code on: `agl proxy credential claude` and `agl proxy run claude`, the controller's own
283
+ * Claude Code sessions, and confined runs (`aglProxyConfinedClient`).
284
+ */
285
+ const claudeCodeSessionScopes = new Set(['client:claude', `client:${aglProxyConfinedClient}`]);
286
+
287
+ /**
288
+ * Whether a Claude pool's request comes from Claude Code (AGL-1146): its client is one AGL runs Claude Code on, or the
289
+ * request names Claude Code itself (`user-agent: claude-cli/…`, as Claude Code and the Agent SDK send it). The header
290
+ * can only narrow the accounts a request may use, never widen them.
291
+ */
292
+ export const inferenceClaudeCodeRequest = (sessionScopeArg: string, headersArg: Headers): boolean =>
293
+ claudeCodeSessionScopes.has(sessionScopeArg) || /^claude-cli\//i.test(headersArg.get('user-agent') ?? '');
294
+
210
295
  /** Claude Code's request headers sent on to Anthropic beside the body; its credential never is. */
211
296
  const forwardedClaudeRequestHeaders = new Set(['accept', 'anthropic-version', 'anthropic-beta', 'user-agent', 'x-app',
212
297
  'x-claude-code-session-id']);
@@ -352,6 +437,9 @@ const readErrorBody = async (responseArg: Response): Promise<string | undefined>
352
437
  } catch { return undefined; }
353
438
  };
354
439
 
440
+ /** The phrase of Anthropic's 400 for an API key whose organization has no credit left (`inferencePaymentCause`). */
441
+ const anthropicCreditBalanceTooLow = /credit balance is too low/i;
442
+
355
443
  /** OpenAI's `error.code` values of a 429 that no retry heals: no prepaid credit left, or a spend or usage limit reached. */
356
444
  const openAiQuotaCodes = new Set(['credit_balance_exhausted', 'organization_spend_limit_exceeded',
357
445
  'project_spend_limit_exceeded', 'organization_usage_limit_exceeded']);
@@ -367,8 +455,11 @@ const openAiQuotaCodes = new Set(['credit_balance_exhausted', 'organization_spen
367
455
  * with HTTP 429 whose `error.code` names the cause (`credit_balance_exhausted`, `organization_spend_limit_exceeded`,
368
456
  * `project_spend_limit_exceeded`, `organization_usage_limit_exceeded`) and whose `error.type` can be
369
457
  * `insufficient_quota`; retrying does not help (https://developers.openai.com/api/docs/guides/error-codes). A Claude
370
- * account's subscription states only the billing error; a spend limit set in the Claude Console (HTTP 400
371
- * `invalid_request_error`) is not read as one.
458
+ * account's subscription states only the billing error. Undocumented but observed (2026-10-29, AGL-1147): Anthropic
459
+ * refuses every request on an API key whose organization has no credit left with HTTP 400 `invalid_request_error`
460
+ * whose message says the credit balance is too low (`anthropicCreditBalanceTooLow`, the phrase Claude Code itself reads as
461
+ * a billing error); that is a billing problem of the key. Any other 400, a spend limit set in the Claude Console among
462
+ * them, is not read as one.
372
463
  */
373
464
  export const inferencePaymentCause = (providerArg: TInferenceProvider, credentialArg: TInferenceCredential,
374
465
  statusArg: number, bodyArg: unknown): TInferencePaymentCause | undefined => {
@@ -376,6 +467,8 @@ export const inferencePaymentCause = (providerArg: TInferenceProvider, credentia
376
467
  if (!error) return undefined;
377
468
  if (providerArg === 'anthropic') {
378
469
  if (statusArg === 402 && error.type === 'billing_error') return 'billing';
470
+ if (credentialArg === 'api_key' && statusArg === 400 && error.type === 'invalid_request_error'
471
+ && typeof error.message === 'string' && anthropicCreditBalanceTooLow.test(error.message)) return 'billing';
379
472
  if (credentialArg === 'api_key' && statusArg === 429 && error.type === 'rate_limit_error' && record(error.details)
380
473
  && error.details.error_code === 'enforced_spend_limit_reached') return 'spend_cap';
381
474
  return undefined;
@@ -389,10 +482,12 @@ export const inferencePaymentCause = (providerArg: TInferenceProvider, credentia
389
482
 
390
483
  /**
391
484
  * Whether a provider answer on the route may state a payment problem of its account (`inferencePaymentCause`), so the
392
- * gateway reads its body before a byte reaches the client: a Claude account's 402, an API key's 402 or 429.
485
+ * gateway reads its body before a byte reaches the client: a Claude account's 402, an API key's 429, an Anthropic API
486
+ * key's 400 or 402.
393
487
  */
394
488
  const mayStatePaymentProblem = (routeArg: IInferenceRoute | IInferenceClaudeRoute, statusArg: number): boolean =>
395
- routeArg.credential === 'api_key' ? statusArg === 429 || (statusArg === 402 && routeArg.provider === 'anthropic')
489
+ routeArg.credential === 'api_key'
490
+ ? statusArg === 429 || (routeArg.provider === 'anthropic' && (statusArg === 400 || statusArg === 402))
396
491
  : statusArg === 402 && routeArg.provider === 'anthropic';
397
492
 
398
493
  /**
@@ -703,10 +798,15 @@ export class InferenceGateway {
703
798
  const token = authorization?.startsWith('Bearer ') ? authorization.slice(7) : requestArg.headers.get('x-api-key');
704
799
  const presented = token && token.length <= 512 ? digest(token) : undefined;
705
800
  let client: IClient | undefined;
801
+ let otherListener = false;
706
802
  if (presented) for (const candidate of this.clients) {
707
- if (plugins.crypto.timingSafeEqual(candidate.digest, presented) && candidate.route === routeArg) client = candidate;
803
+ if (!plugins.crypto.timingSafeEqual(candidate.digest, presented)) continue;
804
+ if (candidate.route === routeArg) client = candidate; else otherListener = true;
805
+ }
806
+ if (!client) {
807
+ throw new InferenceCredentialRefusal(otherListener ? 'other_listener' : presented ? 'unknown'
808
+ : authorization === null && !requestArg.headers.has('x-api-key') ? 'missing' : 'malformed');
708
809
  }
709
- if (!client) throw new InferenceRoutingError(401, 'authentication_error', 'The gateway credential is invalid or expired.');
710
810
  return client;
711
811
  }
712
812
 
@@ -743,6 +843,9 @@ export class InferenceGateway {
743
843
  const pathname = url.pathname.replace(/^\/(openai|anthropic)(?=\/)/, '');
744
844
  // A Claude pool serves Claude Code's own Messages requests; a ChatGPT pool serves Responses and translated Messages.
745
845
  const claude = client.policy.provider === 'anthropic';
846
+ // A Claude Code request is never placed on an API key that may not serve Claude Code (AGL-1146).
847
+ const policy: IInferenceRoutingPolicy = claude && inferenceClaudeCodeRequest(client.sessionScope, request.headers)
848
+ ? { ...client.policy, claudeCode: true } : client.policy;
746
849
  if (claude) {
747
850
  protocol = 'claude';
748
851
  if (!anthropic) throw new InferenceRoutingError(404, 'not_found',
@@ -750,7 +853,7 @@ export class InferenceGateway {
750
853
  }
751
854
  if (request.method === 'GET' && pathname === '/v1/models') {
752
855
  if (claude) {
753
- const models = await this.options.router.claudeModels(client.policy, signal);
856
+ const models = await this.options.router.claudeModels(policy, signal);
754
857
  return Response.json({
755
858
  data: models.map((model) => ({ type: 'model', id: model.modelId, display_name: model.displayName,
756
859
  created_at: model.createdAt ?? '1970-01-01T00:00:00Z',
@@ -807,7 +910,7 @@ export class InferenceGateway {
807
910
  // Of the query, only Claude Code's `beta=true` marker travels upstream.
808
911
  const claudeSearch = url.searchParams.get('beta') === 'true' ? '?beta=true' : '';
809
912
  if (claude && pathname === '/v1/messages/count_tokens') {
810
- return await this.claudeCountTokens(admitted, sessionKey, model, bytes, claudeSearch, request.headers, signal,
913
+ return await this.claudeCountTokens(admitted, policy, sessionKey, model, bytes, claudeSearch, request.headers, signal,
811
914
  (routeArg) => { releaseRoute = routeArg.release; });
812
915
  }
813
916
  // What of the request has no price: an API key with a monthly spend limit takes no such request. Only a Responses
@@ -835,7 +938,7 @@ export class InferenceGateway {
835
938
  let response: Response;
836
939
  let quotaError: InferenceRoutingError | undefined;
837
940
  const acquire = (accountIdArg: string | undefined): Promise<IInferenceRoute | IInferenceClaudeRoute> => claude
838
- ? this.options.router.acquireClaude(model, admitted.policy, signal, { exclude: excluded, excludedBecause,
941
+ ? this.options.router.acquireClaude(model, policy, signal, { exclude: excluded, excludedBecause,
839
942
  ...(unpriced === undefined ? {} : { unpriced }),
840
943
  // A Claude session carries no state bound to its account: one placed on an API key returns to a Claude account
841
944
  // as soon as one can take its request.
@@ -1028,8 +1131,13 @@ export class InferenceGateway {
1028
1131
  const error = errorArg instanceof InferenceRoutingError ? errorArg
1029
1132
  : new InferenceRoutingError(503, 'gateway_unavailable', 'The gateway could not complete the request. Check the account service and provider availability.');
1030
1133
  if (!requestArg.signal.aborted && !client?.abort.signal.aborted && !this.abort.signal.aborted) {
1134
+ // A request refused before its client is known names what it asked for and what it presented (AGL-304).
1135
+ const userAgent = requestArg.headers.get('user-agent');
1031
1136
  this.reportRequestFailure({ status: error.status, code: error.code, protocol,
1032
- ...(errorArg instanceof InferenceRoutingError ? {} : { error: describeStreamFailure(errorArg) }) });
1137
+ ...(errorArg instanceof InferenceRoutingError ? {} : { error: describeStreamFailure(errorArg) }),
1138
+ ...(client === undefined ? { path: refusalText(new URL(requestArg.url).pathname, 128),
1139
+ ...(userAgent === null ? {} : { userAgent: refusalText(userAgent, 96) }) } : {}),
1140
+ ...(errorArg instanceof InferenceCredentialRefusal ? { credential: errorArg.credential } : {}) });
1033
1141
  }
1034
1142
  return errorResponse(error, protocol);
1035
1143
  } finally {
@@ -1198,19 +1306,20 @@ export class InferenceGateway {
1198
1306
  * limit, or by any account of the pool when the session has none there or its account takes no request for a reason
1199
1307
  * of its own, and it never moves the session.
1200
1308
  */
1201
- private async claudeCountTokens(clientArg: IClient, sessionKeyArg: string, modelArg: string,
1309
+ private async claudeCountTokens(clientArg: IClient, policyArg: IInferenceRoutingPolicy, sessionKeyArg: string,
1310
+ modelArg: string,
1202
1311
  bytesArg: Uint8Array<ArrayBuffer>, searchArg: string, headersArg: Headers, signalArg: AbortSignal,
1203
1312
  holdArg: (routeArg: IInferenceClaudeRoute) => void): Promise<Response> {
1204
1313
  const binding = await this.options.affinity.session(sessionKeyArg, signalArg);
1205
1314
  let route: IInferenceClaudeRoute;
1206
1315
  try {
1207
- route = await this.options.router.acquireClaude(modelArg, clientArg.policy, signalArg,
1316
+ route = await this.options.router.acquireClaude(modelArg, policyArg, signalArg,
1208
1317
  { ignoreLimits: true, ...(binding ? { accountId: binding.accountId } : {}) });
1209
1318
  } catch (errorArg) {
1210
1319
  if (!binding || !(sessionAccountOutsidePool(errorArg) || sessionAccountUnavailable(errorArg, binding.accountId))) {
1211
1320
  throw errorArg;
1212
1321
  }
1213
- route = await this.options.router.acquireClaude(modelArg, clientArg.policy, signalArg, { ignoreLimits: true });
1322
+ route = await this.options.router.acquireClaude(modelArg, policyArg, signalArg, { ignoreLimits: true });
1214
1323
  }
1215
1324
  holdArg(route);
1216
1325
  const response = await this.claudeMessages(route, '/v1/messages/count_tokens', searchArg, headersArg, bytesArg, signalArg);
@@ -1311,6 +1420,8 @@ export class InferenceGateway {
1311
1420
  /** The provider's body was read to its end. */
1312
1421
  let whole = false;
1313
1422
  let relayed = 0;
1423
+ // A cut Responses stream ends in a response.failed numbered after what the client already has (AGL-375).
1424
+ const sequence = streamArg.responsesSse ? new ResponsesSequence() : undefined;
1314
1425
  const report = this.options.reportStreamCut ?? writeStreamCut;
1315
1426
  const failure = (errorArg: unknown): InferenceRoutingError => {
1316
1427
  const cause = errorArg instanceof InferenceOutputError ? errorArg.code : 'provider_stream_failed';
@@ -1363,12 +1474,15 @@ export class InferenceGateway {
1363
1474
  // the listener's abort once that request is collected.
1364
1475
  if (cancelled) return;
1365
1476
  if (result.done) { whole = true; controllerArg.close(); finish(); }
1366
- else { relayed += result.value.byteLength; controllerArg.enqueue(result.value); tap?.chunk(result.value); }
1477
+ else {
1478
+ relayed += result.value.byteLength; controllerArg.enqueue(result.value); tap?.chunk(result.value); sequence?.feed(result.value);
1479
+ }
1367
1480
  } catch (errorArg) {
1368
1481
  const error = failure(errorArg);
1369
1482
  if (streamArg.responsesSse && !signalArg.aborted && !cancelled) {
1370
1483
  controllerArg.enqueue(new TextEncoder().encode(`\n\nevent: response.failed\ndata: ${JSON.stringify({
1371
- type: 'response.failed', response: { status: 'failed', error: { code: error.code, message: error.message } },
1484
+ type: 'response.failed', sequence_number: sequence?.next ?? 0,
1485
+ response: { status: 'failed', error: { code: error.code, message: error.message } },
1372
1486
  })}\n\n`));
1373
1487
  controllerArg.close();
1374
1488
  } else {
@@ -84,6 +84,11 @@ export interface IInferenceAccount {
84
84
  * a limit may not (`spend_unread`). A spend reading carries the limit the key is judged against.
85
85
  */
86
86
  spendLimitMicroUsd: number | null;
87
+ /**
88
+ * Whether the account may serve Claude Code (`IAuthSwitchAccount.claudeCode`): a key set to `false` takes no request
89
+ * of a policy with `claudeCode`, and every other request as before. Always `true` for a sign-in.
90
+ */
91
+ claudeCode: boolean;
87
92
  /**
88
93
  * The login the account's requests are served on (the account service's gateway login of it), as the pool was read;
89
94
  * `null` when the account service names none. An API key's spend is reported on it.
@@ -103,6 +108,12 @@ export interface IInferenceRoutingPolicy {
103
108
  credential?: TInferenceCredential;
104
109
  /** Omitted means all eligible authority-owned accounts of the provider. */
105
110
  accountIds?: readonly string[];
111
+ /**
112
+ * The request comes from Claude Code (`inferenceClaudeCodeRequest`, AGL-1146): an API key that may not serve Claude
113
+ * Code (`IInferenceAccount.claudeCode`) is outside the pool, so a session on one moves. The gateway sets it per
114
+ * request; it is never part of a lease.
115
+ */
116
+ claudeCode?: boolean;
106
117
  /** Exact current provider plan names; omission accepts every entitled plan. A key has no plan, so this leaves keys out. */
107
118
  plans?: readonly string[];
108
119
  }
@@ -700,6 +711,11 @@ export interface IInferenceAccountStatus {
700
711
  placementRank: number | null;
701
712
  /** The account lapses within `lapseHorizonMs`: it takes a new session only while no other account can. */
702
713
  lastResort: boolean;
714
+ /**
715
+ * Whether the account may serve Claude Code (`IInferenceAccount.claudeCode`); a key that may not still takes every
716
+ * other client's requests at its `placementRank`. A proxy of an earlier AGL reports none.
717
+ */
718
+ claudeCode?: boolean;
703
719
  }
704
720
 
705
721
  /** One model entry of a ChatGPT account's catalog exactly as the Codex backend states it. */
@@ -978,8 +994,10 @@ export class InferenceRouter {
978
994
  const provider = policyArg.provider ?? 'openai';
979
995
  const tiers = this.tiers(policyArg);
980
996
  const now = this.now();
997
+ // A Claude Code request's pool holds no API key that may not serve Claude Code: for it the key left the pool.
981
998
  const inPool = (accountArg: IInferenceAccount) => accountArg.providerId === provider
982
- && tiers.includes(accountArg.credential);
999
+ && tiers.includes(accountArg.credential)
1000
+ && !(policyArg.claudeCode && accountArg.credential === 'api_key' && !accountArg.claudeCode);
983
1001
  const lapsed = new Set(everyAccount.filter((account) => inPool(account)
984
1002
  && plugins.authswitchPlacement.authSwitchAccountLifecycle(account.lapsesAt, now) === 'lapsed').map((account) => account.id));
985
1003
  const allAccounts = everyAccount.filter((account) => inPool(account) && !lapsed.has(account.id));
@@ -1937,7 +1955,7 @@ export class InferenceRouter {
1937
1955
  const base = { id: account.id, label: account.label, provider: account.providerId, credential: account.credential,
1938
1956
  maxUsagePercent: account.maxUsagePercent, reserveLiftUntil: account.reserveLiftUntil, inFlight: this.active.get(account.id) ?? 0,
1939
1957
  lifecycle: placement.lifecycle, lapsesAt: account.lapsesAt, placementScore: placement.score, placementRank: null,
1940
- lastResort: placement.eligibility === 'last_resort',
1958
+ lastResort: placement.eligibility === 'last_resort', claudeCode: account.claudeCode,
1941
1959
  readingSource: held?.observation ? 'headers' as const : held?.reading ? 'poll' as const : null,
1942
1960
  readingObservedAt: held?.reading ? held.observedAt : null,
1943
1961
  readingReadAt: held?.reading ? held.readAt : null,
@@ -154,7 +154,7 @@ export class InferenceService {
154
154
  const login = findAuthorityGatewayLogin(projection, account.id);
155
155
  return pool ? [{ id: account.id, label: account.label, revision: String(account.revision), providerId: pool.provider,
156
156
  credential: pool.credential, maxUsagePercent: account.maxUsagePercent, reserveLiftUntil: account.reserveLiftUntil, lapsesAt: account.lapsesAt,
157
- spendLimitMicroUsd: account.spendLimitMicroUsd, loginId: typeof login === 'string' ? null : login.id }] : [];
157
+ spendLimitMicroUsd: account.spendLimitMicroUsd, claudeCode: account.claudeCode, loginId: typeof login === 'string' ? null : login.id }] : [];
158
158
  });
159
159
  }
160
160
 
@@ -219,8 +219,11 @@ export class InferenceService {
219
219
  .map(async (accountArg) => [accountArg.id, await this.usage.current(accountArg.id, signalArg)] as const)));
220
220
  const accounts = this.router.accountStatus(pool, (accountIdArg) => readings.get(accountIdArg));
221
221
  const recent = await this.options.placements.recent(recentPlacementCount, signalArg);
222
- const next = (providerArg: TInferenceProvider): string | null =>
223
- accounts.find((accountArg) => accountArg.provider === providerArg && accountArg.placementRank === 1)?.id ?? null;
222
+ // Claude's next new session is Claude Code's: the best ranked account that may serve it (AGL-1146).
223
+ const next = (providerArg: TInferenceProvider): string | null => accounts
224
+ .filter((accountArg) => accountArg.provider === providerArg && accountArg.placementRank !== null
225
+ && (providerArg !== 'anthropic' || accountArg.claudeCode !== false))
226
+ .sort((left, right) => left.placementRank! - right.placementRank!)[0]?.id ?? null;
224
227
  return { ...this.gateway.status(), baseUrl: this.baseUrl ?? '', usageObservations: this.observer.status(),
225
228
  authority: this.ready && this.authority.getProjection().state === 'ready' ? 'ready' : 'unavailable',
226
229
  accounts,
@@ -138,7 +138,7 @@ const threadName = (titleArg: string): string => {
138
138
  * A row's id. A Codex session is named by its raw thread id: the fleet and the shared app-server name it so, while a
139
139
  * tracked conversation carries the id qualified with its connection profile.
140
140
  */
141
- const sessionFeedRowId = (harnessArg: TControllerSessionFeedHarness, nativeIdArg: string): string => (
141
+ export const sessionFeedRowId = (harnessArg: TControllerSessionFeedHarness, nativeIdArg: string): string => (
142
142
  `${harnessArg}:${harnessArg === 'codex' ? codexQualifiedIdentity(nativeIdArg)?.rawThreadId ?? nativeIdArg : nativeIdArg}`
143
143
  );
144
144
  const workerState = (viewArg: IControllerFleetWorkerView): TControllerSessionFeedState => {
@@ -257,6 +257,18 @@ export class SessionFeed {
257
257
  return { epoch: this.epoch, revision: this.revision, rows: [...this.published.values()].map((entry) => entry.row) };
258
258
  }
259
259
 
260
+ /** A row as the feed published it last, without reading anything: what events about the session may name. */
261
+ public publishedRow(rowIdArg: string): IControllerSessionFeedRow | undefined {
262
+ return this.published.get(rowIdArg)?.row;
263
+ }
264
+
265
+ /** A row after reading every stale source, as `list()` reads; undefined while the feed does not list it. */
266
+ public async find(rowIdArg: string): Promise<IControllerSessionFeedRow | undefined> {
267
+ this.abort.signal.throwIfAborted();
268
+ await this.flush(true);
269
+ return this.published.get(rowIdArg)?.row;
270
+ }
271
+
260
272
  /**
261
273
  * Acknowledges the failed row `rowIdArg` as the owner saw it, published with `updatedAtArg`: the row leaves the feed
262
274
  * while it stays failed and its `updatedAt` is not newer. Acknowledging the same row and `updatedAt` again changes
@@ -1,6 +1,6 @@
1
1
  import * as plugins from './plugins.js';
2
2
  import type { TTicketData, ITicketComment, ITicketActivity, ITicketQuestion, TTicketFleetEvent, ITicketFleetEventResult } from '../ts_interfaces/tickets.js';
3
- import { ticketSchema, ticketCommentSchema, ticketActivitySchema, ticketQuestionSchema, ticketFleetEventSchema } from './functions.ticketvalidation.js';
3
+ import { ticketSchema, ticketCommentSchema, ticketActivitySchema, ticketQuestionSchema, ticketFleetEventSchema, ticketReleaseLink } from './functions.ticketvalidation.js';
4
4
 
5
5
  export interface ITicketDocument { id: string; ticket: TTicketData; }
6
6
  export interface ITicketBoardDocument { id: string; sequence: number; revision: number; }
@@ -49,7 +49,8 @@ const assertFleetEventDocument = (valueArg: unknown): void => {
49
49
  }
50
50
  const expectedLink = value.event.kind === 'landed'
51
51
  ? { kind: 'branch', repo: value.event.repo, branch: value.event.branch, sha: value.event.sha }
52
- : value.event.kind === 'released' ? { kind: 'release', package: value.event.package, version: value.event.version } : undefined;
52
+ : value.event.kind === 'released' ? ticketReleaseLink(value.event)
53
+ : undefined;
53
54
  const body = typeof value.event.body === 'string' ? [{ type: 'text', text: value.event.body }] : value.event.body;
54
55
  if (!plugins.util.isDeepStrictEqual(value.result.ticket.updatedBy, value.event.actor)
55
56
  || (expectedLink && (value.result.ticket.columnId !== value.event.kind
@@ -37,7 +37,8 @@ const personName = (personArg: ITicketPerson | undefined, recipientArg?: string)
37
37
  );
38
38
  const linkText = (linkArg: TTicketLink): string => (
39
39
  linkArg.kind === 'branch' ? `branch ${linkArg.repo} ${linkArg.branch} at ${linkArg.sha.slice(0, 12)}`
40
- : linkArg.kind === 'commit' ? `commit ${linkArg.repo} ${linkArg.sha.slice(0, 12)}` : `release ${linkArg.package}@${linkArg.version}`
40
+ : linkArg.kind === 'commit' ? `commit ${linkArg.repo} ${linkArg.sha.slice(0, 12)}`
41
+ : linkArg.kind === 'affects' ? `found in ${linkArg.repo}@${linkArg.version}` : `release ${linkArg.package ?? linkArg.repo}@${linkArg.version}`
41
42
  );
42
43
  const fieldText = (keyArg: string, changeArg: { before?: unknown; after?: unknown }, recipientArg?: string): string => {
43
44
  if (keyArg === 'description') return 'the description';
@@ -76,6 +77,12 @@ export const ticketChangeText = (changeArg: ITicketChange, recipientArg?: string
76
77
  const link = (changes.links?.after as TTicketLink[] | undefined)?.at(-1);
77
78
  return link ? `${actor} linked ${linkText(link)}` : `${actor} confirmed an existing link`;
78
79
  }
80
+ case 'unlinked': {
81
+ const after = (changes.links?.after as TTicketLink[] | undefined) ?? [];
82
+ const removed = ((changes.links?.before as TTicketLink[] | undefined) ?? [])
83
+ .find((linkArg) => !after.some((keptArg) => JSON.stringify(keptArg) === JSON.stringify(linkArg)));
84
+ return removed ? `${actor} removed the link ${linkText(removed)}` : `${actor} removed a link`;
85
+ }
79
86
  case 'asked': {
80
87
  const question = changes.question!.after as ITicketQuestion;
81
88
  const options = question.options.length
@@ -1,6 +1,6 @@
1
1
  import * as plugins from './plugins.js';
2
2
  import {
3
- isTicketAutoLabel, ticketColumns, ticketErrorMessages, type ITicket, type ITicketActor, type ITicketActivity, type ITicketBoard,
3
+ isTicketAutoLabel, ticketColumns, ticketDoneColumns, ticketErrorMessages, type ITicket, type ITicketActor, type ITicketActivity, type ITicketBoard,
4
4
  type ITicketChanges, type ITicketCreate, type ITicketFilters, type ITicketMove, type ITicketPerson, type ITicketQuestion,
5
5
  type TTicketLink, type TTicketOperation, type TTicketRequest, type TTicketResponse,
6
6
  type TTicketFleetEvent, type ITicketFleetEventResult, type ITicketComment, type TTicketData, type ITicketOpenQuestion,
@@ -9,7 +9,7 @@ import {
9
9
  import {
10
10
  TicketModel, TicketBoardModel, TicketCommentModel, TicketActivityModel, TicketQuestionModel, TicketFleetEventModel,
11
11
  } from './classes.ticketmodels.js';
12
- import { assertTicketRequest, ticketActorSchema, ticketFleetEventSchema } from './functions.ticketvalidation.js';
12
+ import { assertTicketRequest, ticketActorSchema, ticketFleetEventSchema, ticketReleaseLink } from './functions.ticketvalidation.js';
13
13
  import { ticketAutoLabelsFor } from './functions.ticketautolabels.js';
14
14
 
15
15
  type TTicketStored = NonNullable<Awaited<ReturnType<typeof TicketModel.exact.findStoredOne>>>;
@@ -120,7 +120,7 @@ export class TicketStore {
120
120
  if (event.kind !== 'comment') {
121
121
  const link: TTicketLink = event.kind === 'landed'
122
122
  ? { kind: 'branch', repo: event.repo, branch: event.branch, sha: event.sha }
123
- : { kind: 'release', package: event.package, version: event.version };
123
+ : ticketReleaseLink(event);
124
124
  await this.perform('link', { ticketId: event.ticketKey, link }, event.actor, transactionArg,
125
125
  now, board.sequence + 1, revision, track);
126
126
  await this.perform('move', { ticketId: event.ticketKey, columnId: event.kind }, event.actor, transactionArg,
@@ -521,7 +521,7 @@ export class TicketStore {
521
521
  if (!actorArg) throw new TicketError('ticket_identity_required', ticketErrorMessages.ticket_identity_required);
522
522
  const { role: _role, ...viewer } = actorArg;
523
523
  return { revision: revisionArg, tickets, columns: ticketColumns.map((idArg) => ({ id: idArg,
524
- title: `${idArg[0].toUpperCase()}${idArg.slice(1).replaceAll('_', ' ')}`, ...(idArg === 'released' ? { done: true } : {}) })),
524
+ title: `${idArg[0].toUpperCase()}${idArg.slice(1).replaceAll('_', ' ')}`, ...(ticketDoneColumns.includes(idArg) ? { done: true } : {}) })),
525
525
  viewer } satisfies ITicketBoard;
526
526
  }
527
527
  if (methodArg === 'create') {
@@ -601,6 +601,10 @@ export class TicketStore {
601
601
  const stored = await TicketQuestionModel.exact.findStoredOne({ id: `${ticketId}:${input.questionId}` }, { session: sessionArg });
602
602
  if (!stored) throw new TicketError('ticket_question_not_found', ticketErrorMessages.ticket_question_not_found);
603
603
  const question = structuredClone(stored.question);
604
+ // The answer to a deploy plan's or a maintenance window's question is the owner's go: the owner's alone.
605
+ if (actorArg.role !== 'owner' && (ticket.deployPlan?.questionId === input.questionId || ticket.maintenanceWindow?.questionId === input.questionId)) {
606
+ throw new TicketError('ticket_go_owner_only', ticketErrorMessages.ticket_go_owner_only);
607
+ }
604
608
  const choices = question.options.filter((optionArg) => input.choices?.includes(optionArg.id)).map((optionArg) => optionArg.id);
605
609
  if (choices.length !== (input.choices?.length ?? 0) || (!question.multiSelect && choices.length > 1)
606
610
  || (input.text !== undefined && !question.allowCustom)) {
@@ -3915,11 +3915,21 @@ export class UpgradeCoordinator {
3915
3915
  await writePrivateJson(this.tokenFilePath('grant', optionsArg.token), grant);
3916
3916
  }
3917
3917
 
3918
- public async removeLaunchGrant(tokenArg: string): Promise<void> {
3919
- await plugins.fs.promises.unlink(this.tokenFilePath('grant', tokenArg)).catch((errorArg) => {
3920
- if ((errorArg as NodeJS.ErrnoException).code !== 'ENOENT') throw errorArg;
3921
- });
3918
+ /**
3919
+ * Revokes the launch grant of `tokenArg`. True when it removed a grant no controller consumed: `consumeLaunchGrant`
3920
+ * renames the grant away before the controller launches a worker, so a revoked grant proves that no worker was
3921
+ * launched for it, and none can be any more (AGL-327). False when there was none, consumed or never written.
3922
+ */
3923
+ public async removeLaunchGrant(tokenArg: string): Promise<boolean> {
3924
+ const revoked = await plugins.fs.promises.unlink(this.tokenFilePath('grant', tokenArg)).then(
3925
+ () => true,
3926
+ (errorArg) => {
3927
+ if ((errorArg as NodeJS.ErrnoException).code !== 'ENOENT') throw errorArg;
3928
+ return false;
3929
+ },
3930
+ );
3922
3931
  await syncDirectory(this.baseDirectory);
3932
+ return revoked;
3923
3933
  }
3924
3934
 
3925
3935
  public async consumeLaunchGrant(optionsArg: {