agl 42.1.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 (134) hide show
  1. package/changelog.md +38 -0
  2. package/dist_serve/bundle.js +797 -785
  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.js +9 -1
  9. package/dist_ts/classes.cli.js +19 -49
  10. package/dist_ts/classes.configurationauthority.js +2 -2
  11. package/dist_ts/classes.controllerservice.d.ts +20 -2
  12. package/dist_ts/classes.controllerservice.js +42 -6
  13. package/dist_ts/classes.flexservice.js +8 -3
  14. package/dist_ts/classes.inferencegateway.d.ts +30 -2
  15. package/dist_ts/classes.inferencegateway.js +115 -20
  16. package/dist_ts/classes.inferencerouter.d.ts +16 -0
  17. package/dist_ts/classes.inferencerouter.js +5 -3
  18. package/dist_ts/classes.inferenceservice.js +7 -3
  19. package/dist_ts/classes.ticketmodels.js +4 -3
  20. package/dist_ts/classes.ticketnotifier.js +9 -2
  21. package/dist_ts/classes.ticketstore.js +9 -5
  22. package/dist_ts/classes.upgradecoordinator.d.ts +6 -1
  23. package/dist_ts/classes.upgradecoordinator.js +9 -2
  24. package/dist_ts/classes.upgradetransaction.d.ts +27 -1
  25. package/dist_ts/classes.upgradetransaction.js +92 -2
  26. package/dist_ts/configuration/functions.master.d.ts +7 -2
  27. package/dist_ts/configuration/functions.master.js +7 -4
  28. package/dist_ts/driver/classes.drivereventrelay.d.ts +1 -1
  29. package/dist_ts/driver/classes.drivereventrelay.js +3 -3
  30. package/dist_ts/fleet/classes.boardpump.d.ts +1 -1
  31. package/dist_ts/fleet/classes.boardpump.js +7 -4
  32. package/dist_ts/fleet/classes.claudeworkers.d.ts +6 -0
  33. package/dist_ts/fleet/classes.claudeworkers.js +17 -7
  34. package/dist_ts/fleet/classes.deploymodels.d.ts +19 -0
  35. package/dist_ts/fleet/classes.deploymodels.js +140 -0
  36. package/dist_ts/fleet/functions.validation.d.ts +8 -1
  37. package/dist_ts/fleet/functions.validation.js +65 -3
  38. package/dist_ts/fleet/interfaces.workers.d.ts +6 -0
  39. package/dist_ts/fleet/interfaces.workers.js +65 -2
  40. package/dist_ts/functions.fleetworkercli.d.ts +16 -3
  41. package/dist_ts/functions.fleetworkercli.js +21 -7
  42. package/dist_ts/functions.inferencecli.js +4 -2
  43. package/dist_ts/functions.mcptickettools.d.ts +1 -0
  44. package/dist_ts/functions.ticketvalidation.d.ts +36 -3
  45. package/dist_ts/functions.ticketvalidation.js +45 -14
  46. package/dist_ts/interfaces.auth.d.ts +1 -1
  47. package/dist_ts/interfaces.auth.js +2 -1
  48. package/dist_ts_authswitch/authority-contract.d.ts +23 -0
  49. package/dist_ts_authswitch/authority-contract.js +1 -1
  50. package/dist_ts_authswitch/classes.authoritybroker.d.ts +6 -0
  51. package/dist_ts_authswitch/classes.authoritybroker.js +31 -4
  52. package/dist_ts_authswitch/classes.authoritycli.d.ts +1 -0
  53. package/dist_ts_authswitch/classes.authoritycli.js +26 -1
  54. package/dist_ts_authswitch/classes.authorityclient.d.ts +3 -1
  55. package/dist_ts_authswitch/classes.authorityclient.js +10 -4
  56. package/dist_ts_authswitch/classes.authoritydaemon.js +7 -1
  57. package/dist_ts_authswitch/classes.authorityimport.js +2 -2
  58. package/dist_ts_authswitch/classes.authoritymodels.d.ts +3 -0
  59. package/dist_ts_authswitch/classes.authoritymodels.js +10 -3
  60. package/dist_ts_authswitch/testsupport.js +4 -4
  61. package/dist_ts_authswitch/ts_migration/0012_account_claude_code.d.ts +11 -0
  62. package/dist_ts_authswitch/ts_migration/0012_account_claude_code.js +18 -0
  63. package/dist_ts_authswitch/ts_migration/index.js +3 -1
  64. package/dist_ts_interfaces/deployments.d.ts +104 -0
  65. package/dist_ts_interfaces/deployments.js +8 -0
  66. package/dist_ts_interfaces/fleet.d.ts +2 -0
  67. package/dist_ts_interfaces/index.d.ts +1 -0
  68. package/dist_ts_interfaces/index.js +2 -1
  69. package/dist_ts_interfaces/interfaces.d.ts +1 -1
  70. package/dist_ts_interfaces/interfaces.js +1 -1
  71. package/dist_ts_interfaces/requests.accounts.d.ts +18 -0
  72. package/dist_ts_interfaces/requests.accounts.js +1 -1
  73. package/dist_ts_interfaces/requests.d.ts +2 -2
  74. package/dist_ts_interfaces/requests.js +1 -1
  75. package/dist_ts_interfaces/tickets.d.ts +53 -4
  76. package/dist_ts_interfaces/tickets.js +6 -2
  77. package/dist_ts_migration/index.d.ts +1 -0
  78. package/dist_ts_migration/index.js +2 -1
  79. package/dist_ts_migration/v41_ticketmigrationmarkers.d.ts +19 -0
  80. package/dist_ts_migration/v41_ticketmigrationmarkers.js +85 -0
  81. package/docs/authswitch.md +6 -0
  82. package/package.json +5 -5
  83. package/readme.md +48 -12
  84. package/ts/00_commitinfo_data.ts +1 -1
  85. package/ts/aglapi/aglapisurface.document.ts +123 -9
  86. package/ts/classes.accountsactions.ts +24 -0
  87. package/ts/classes.authstore.ts +8 -0
  88. package/ts/classes.cli.ts +17 -54
  89. package/ts/classes.configurationauthority.ts +1 -1
  90. package/ts/classes.controllerservice.ts +49 -6
  91. package/ts/classes.flexservice.ts +7 -2
  92. package/ts/classes.inferencegateway.ts +133 -19
  93. package/ts/classes.inferencerouter.ts +20 -2
  94. package/ts/classes.inferenceservice.ts +6 -3
  95. package/ts/classes.ticketmodels.ts +3 -2
  96. package/ts/classes.ticketnotifier.ts +8 -1
  97. package/ts/classes.ticketstore.ts +8 -4
  98. package/ts/classes.upgradecoordinator.ts +14 -4
  99. package/ts/classes.upgradetransaction.ts +118 -0
  100. package/ts/configuration/functions.master.ts +6 -3
  101. package/ts/driver/classes.drivereventrelay.ts +2 -2
  102. package/ts/fleet/classes.boardpump.ts +7 -4
  103. package/ts/fleet/classes.claudeworkers.ts +16 -6
  104. package/ts/fleet/classes.deploymodels.ts +44 -0
  105. package/ts/fleet/functions.validation.ts +50 -2
  106. package/ts/fleet/interfaces.workers.ts +56 -1
  107. package/ts/functions.fleetworkercli.ts +26 -8
  108. package/ts/functions.inferencecli.ts +3 -1
  109. package/ts/functions.ticketvalidation.ts +48 -13
  110. package/ts/interfaces.auth.ts +1 -0
  111. package/ts_authswitch/authority-contract.ts +18 -0
  112. package/ts_authswitch/classes.authoritybroker.ts +29 -3
  113. package/ts_authswitch/classes.authoritycli.ts +29 -0
  114. package/ts_authswitch/classes.authorityclient.ts +12 -4
  115. package/ts_authswitch/classes.authoritydaemon.ts +8 -1
  116. package/ts_authswitch/classes.authorityimport.ts +1 -1
  117. package/ts_authswitch/classes.authoritymodels.ts +5 -1
  118. package/ts_authswitch/native-contracts.md +10 -0
  119. package/ts_authswitch/testsupport.ts +3 -3
  120. package/ts_authswitch/ts_migration/0012_account_claude_code.ts +17 -0
  121. package/ts_authswitch/ts_migration/index.ts +2 -0
  122. package/ts_interfaces/deployments.ts +98 -0
  123. package/ts_interfaces/fleet.ts +2 -0
  124. package/ts_interfaces/index.ts +1 -0
  125. package/ts_interfaces/interfaces.ts +1 -1
  126. package/ts_interfaces/requests.accounts.ts +16 -0
  127. package/ts_interfaces/requests.ts +2 -0
  128. package/ts_interfaces/tickets.ts +34 -4
  129. package/ts_migration/index.ts +1 -0
  130. package/ts_migration/v41_ticketmigrationmarkers.ts +28 -0
  131. package/ts_web/00_commitinfo_data.ts +1 -1
  132. package/ts_web/classes.accountsreadmodel.ts +12 -1
  133. package/ts_web/elements.accounts.ts +44 -0
  134. package/ts_web/elements.ticketboard.ts +15 -4
@@ -61,6 +61,7 @@ export interface IAuthSwitchAuthorityCliClient {
61
61
  setAccountLapse(accountId: string, expectedRevision: number, lapsesAt: string | null): Promise<IAuthSwitchAccount>;
62
62
  setAccountSpendLimit(accountId: string, expectedRevision: number,
63
63
  spendLimitMicroUsd: number | null): Promise<IAuthSwitchAccount>;
64
+ setAccountClaudeCode(accountId: string, expectedRevision: number, claudeCode: boolean): Promise<IAuthSwitchAccount>;
64
65
  close(reason?: Error): void;
65
66
  }
66
67
 
@@ -102,6 +103,7 @@ type TAuthorityCliCommand =
102
103
  | { kind: 'setMaxUsage'; accountId: string; maxUsagePercent: number | null; json: boolean }
103
104
  | { kind: 'setLapse'; accountId: string; lapsesAt: string | null; json: boolean }
104
105
  | { kind: 'setSpendLimit'; accountId: string; spendLimitMicroUsd: number | null; json: boolean }
106
+ | { kind: 'setClaudeCode'; accountId: string; claudeCode: boolean; json: boolean }
105
107
  | { kind: 'get'; operationId: string; json: boolean }
106
108
  | { kind: 'cancel'; operationId: string; json: boolean }
107
109
  | { kind: 'resume'; operationId: string; json: boolean }
@@ -176,6 +178,10 @@ Usage
176
178
  what AGL's proxy relayed on it: at the limit the proxy places
177
179
  nothing more on the key until the month ends;
178
180
  --clear-spend-limit removes it
181
+ authswitch account set <account-id> --claude-code on|off [--json]
182
+ whether an API key may serve Claude Code: off keeps AGL's
183
+ proxy from placing Claude Code on it (a key whose credit is
184
+ not for Claude Code); other clients still use it
179
185
  authswitch account operation get|cancel|resume <operation-id> [--json]
180
186
  follow a sign-in that is still running
181
187
  authswitch account preuse <account-id> <login-id>|--all [--prompt <text>] [--model <id>] [--json]
@@ -385,6 +391,9 @@ const parse = (argv: readonly string[]): TAuthorityCliCommand | null => {
385
391
  if (options.length === 2 && options[0] === '--spend-limit' && authSwitchParseUsd(options[1]!) !== null) {
386
392
  return { kind: 'setSpendLimit', accountId: argv[2], spendLimitMicroUsd: authSwitchParseUsd(options[1]!), json };
387
393
  }
394
+ if (options.length === 2 && options[0] === '--claude-code' && (options[1] === 'on' || options[1] === 'off')) {
395
+ return { kind: 'setClaudeCode', accountId: argv[2], claudeCode: options[1] === 'on', json };
396
+ }
388
397
  return null;
389
398
  }
390
399
  if (argv[0] === 'account' && argv[1] === 'operation'
@@ -520,6 +529,10 @@ class ScopedAuthorityCliClient implements IAuthSwitchAuthorityCliClient {
520
529
  return this.client.setAccountSpendLimit(accountId, expectedRevision, spendLimitMicroUsd, this.controller.signal);
521
530
  }
522
531
 
532
+ public setAccountClaudeCode(accountId: string, expectedRevision: number, claudeCode: boolean): Promise<IAuthSwitchAccount> {
533
+ return this.client.setAccountClaudeCode(accountId, expectedRevision, claudeCode, this.controller.signal);
534
+ }
535
+
523
536
  public close(reason = new Error('Authswitch authority CLI closed.')): void {
524
537
  if (!this.controller.signal.aborted) this.controller.abort(reason);
525
538
  }
@@ -546,6 +559,11 @@ const renderApiKeyAdded = (account: IAuthSwitchAccount): string =>
546
559
  const renderSpendLimit = (account: IAuthSwitchAccount): string =>
547
560
  `Account ${safe(account.label)} (${safe(account.id)}): ${spendLimitText(account)}.\n`;
548
561
 
562
+ const renderClaudeCode = (account: IAuthSwitchAccount): string =>
563
+ `Account ${safe(account.label)} (${safe(account.id)}): ${account.claudeCode ? 'serves Claude Code'
564
+ : 'serves no Claude Code; AGL\'s inference proxy places Claude Code requests on other accounts, and other clients '
565
+ + 'still use it'}.\n`;
566
+
549
567
  /**
550
568
  * The key `account add anthropic-api-key` adds, from standard input: a line typed at a terminal, which is not echoed
551
569
  * (a muted output for the line editor), or everything a pipe or file supplies. A cancelled command stops reading, so
@@ -1492,6 +1510,17 @@ export const runAuthSwitchAuthorityCli = async (argv: readonly string[],
1492
1510
  await writeOutput(command.json ? JSON.stringify({ account: changed }) + '\n' : renderSpendLimit(changed));
1493
1511
  return 0;
1494
1512
  }
1513
+ if (command.kind === 'setClaudeCode') {
1514
+ const account = (await activeClient.snapshotAll()).accounts.find(item => item.id === command.accountId && !item.removed);
1515
+ if (!account) {
1516
+ await writeDiagnostic('No authority account has this id. Run `authswitch account list` for the ids.\n');
1517
+ return 1;
1518
+ }
1519
+ const changed = await activeClient.setAccountClaudeCode(account.id, account.revision, command.claudeCode);
1520
+ if (changed.id !== account.id || changed.claudeCode !== command.claudeCode) throw new AuthorityCliFailure('response');
1521
+ await writeOutput(command.json ? JSON.stringify({ account: changed }) + '\n' : renderClaudeCode(changed));
1522
+ return 0;
1523
+ }
1495
1524
  if (command.kind === 'addApiKey') {
1496
1525
  const apiKey = (await withinDeadline(() => (options.readApiKey ?? readStandardInputApiKey)(operationController.signal,
1497
1526
  command.providerId))).trim();
@@ -11,7 +11,7 @@ import type {
11
11
  IReq_AuthSwitchCancelPreuse, IReq_AuthSwitchGetPreuse, IReq_AuthSwitchSnapshot,
12
12
  IReq_AuthSwitchStartPreuse, IReq_AuthSwitchUsage, IReq_AuthSwitchObserveUsage, IReq_AuthSwitchReportPaymentProblem,
13
13
  IReq_AuthSwitchRecordSpend, IAuthSwitchSpendAnswer, TAuthSwitchPaymentProblemCause, TAuthSwitchApiKeyProvider,
14
- IReq_AuthSwitchSetAccountSpendLimit,
14
+ IReq_AuthSwitchSetAccountSpendLimit, IReq_AuthSwitchSetAccountClaudeCode,
15
15
  IReq_AuthSwitchRecheckUsage, IReq_AuthSwitchMoveClaudeHomeIn, IReq_AuthSwitchMoveClaudeHomeOut,
16
16
  IReq_AuthSwitchRegisterClaudeHome, IReq_AuthSwitchResolveClaudeHome, IReq_AuthSwitchUnregisterClaudeHome,
17
17
  IAuthSwitchClaudeSignInOperation, IReq_AuthSwitchCancelClaudeSignIn, IReq_AuthSwitchGetClaudeSignIn,
@@ -121,8 +121,9 @@ export class AuthSwitchDaemonOutdatedError extends Error {
121
121
  /**
122
122
  * A snapshot page carries every member of this release's contract. `schemaVersion` is not bumped for an
123
123
  * additive member; version 3 adds the gateway runtime, every account states its `maxUsagePercent` from 38.3.0
124
- * on, its `lapsesAt` from 38.4.0 on, its `reserveLiftUntil` with reserve lifts, and its `spendLimitMicroUsd` and
125
- * `keyHint` with API keys of both providers. Consumers still check their supported version.
124
+ * on, its `lapsesAt` from 38.4.0 on, its `reserveLiftUntil` with reserve lifts, its `spendLimitMicroUsd` and
125
+ * `keyHint` with API keys of both providers, and its `claudeCode` from AGL-1146 on. Consumers still check their
126
+ * supported version.
126
127
  */
127
128
  const assertCurrentSnapshot = (snapshot: IAuthSwitchSnapshot): IAuthSwitchSnapshot => {
128
129
  const page: Partial<IAuthSwitchSnapshot> = snapshot;
@@ -132,7 +133,8 @@ const assertCurrentSnapshot = (snapshot: IAuthSwitchSnapshot): IAuthSwitchSnapsh
132
133
  || (account as Partial<IAuthSwitchAccount>).lapsesAt === undefined
133
134
  || (account as Partial<IAuthSwitchAccount>).reserveLiftUntil === undefined
134
135
  || (account as Partial<IAuthSwitchAccount>).spendLimitMicroUsd === undefined
135
- || (account as Partial<IAuthSwitchAccount>).keyHint === undefined)) {
136
+ || (account as Partial<IAuthSwitchAccount>).keyHint === undefined
137
+ || (account as Partial<IAuthSwitchAccount>).claudeCode === undefined)) {
136
138
  throw new AuthSwitchDaemonOutdatedError();
137
139
  }
138
140
  return snapshot;
@@ -526,6 +528,12 @@ export class AuthSwitchClient {
526
528
  return (await this.request<IReq_AuthSwitchSetAccountSpendLimit>('authswitch.authority.spendlimit',
527
529
  { accountId, expectedRevision, spendLimitMicroUsd }, 10_000, false, signal)).account;
528
530
  }
531
+ /** Sets whether an API key account may serve Claude Code (see `IReq_AuthSwitchSetAccountClaudeCode`). */
532
+ public async setAccountClaudeCode(accountId: string, expectedRevision: number, claudeCode: boolean,
533
+ signal?: AbortSignal): Promise<IReq_AuthSwitchSetAccountClaudeCode['response']['account']> {
534
+ return (await this.request<IReq_AuthSwitchSetAccountClaudeCode>('authswitch.authority.claudecode',
535
+ { accountId, expectedRevision, claudeCode }, 10_000, false, signal)).account;
536
+ }
529
537
 
530
538
  /** Sets an account's usage threshold, or clears it with `null` (see `IReq_AuthSwitchSetAccountMaxUsage`). */
531
539
  public async setAccountMaxUsage(accountId: string, expectedRevision: number, maxUsagePercent: number | null,
@@ -8,7 +8,7 @@ import type {
8
8
  IReq_AuthSwitchRepairClaudeHost,
9
9
  IReq_AuthSwitchEvents, IReq_AuthSwitchGetBinding, IReq_AuthSwitchGetOperation, IReq_AuthSwitchListOperations,
10
10
  IReq_AuthSwitchRemoveAccount,
11
- IReq_AuthSwitchRenameAccount, IReq_AuthSwitchSetAccountLapse, IReq_AuthSwitchSetAccountMaxUsage, IReq_AuthSwitchSetAccountSpendLimit, IReq_AuthSwitchLiftAccountReserve, IReq_AuthSwitchSnapshot,
11
+ IReq_AuthSwitchRenameAccount, IReq_AuthSwitchSetAccountLapse, IReq_AuthSwitchSetAccountMaxUsage, IReq_AuthSwitchSetAccountSpendLimit, IReq_AuthSwitchSetAccountClaudeCode, IReq_AuthSwitchLiftAccountReserve, IReq_AuthSwitchSnapshot,
12
12
  IReq_AuthSwitchCancelPreuse, IReq_AuthSwitchGetPreuse, IReq_AuthSwitchStartPreuse, IReq_AuthSwitchUsage,
13
13
  IReq_AuthSwitchObserveUsage, IReq_AuthSwitchReportPaymentProblem, IReq_AuthSwitchRecheckUsage, IReq_AuthSwitchRecordSpend,
14
14
  IReq_AuthSwitchMoveClaudeHomeIn, IReq_AuthSwitchMoveClaudeHomeOut, IReq_AuthSwitchRegisterClaudeHome,
@@ -733,6 +733,13 @@ export class AuthSwitchAuthorityDaemon {
733
733
  return { account: await this.broker.setAccountSpendLimit(request.accountId, request.expectedRevision,
734
734
  request.spendLimitMicroUsd) };
735
735
  }));
736
+ this.managementRouter.addTypedHandler(this.handler<IReq_AuthSwitchSetAccountClaudeCode>(
737
+ 'authswitch.authority.claudecode', async request => {
738
+ if (!hasKeys(request, ['accountId', 'expectedRevision', 'claudeCode']) || typeof request.accountId !== 'string'
739
+ || typeof request.expectedRevision !== 'number' || typeof request.claudeCode !== 'boolean') invalid();
740
+ return { account: await this.broker.setAccountClaudeCode(request.accountId, request.expectedRevision,
741
+ request.claudeCode) };
742
+ }));
736
743
  this.managementRouter.addTypedHandler(this.handler<IReq_AuthSwitchLiftAccountReserve>(
737
744
  'authswitch.authority.reserve.lift', async request => {
738
745
  if (!hasKeys(request, ['accountId', 'expectedRevision', 'hours']) || typeof request.accountId !== 'string'
@@ -687,7 +687,7 @@ export class AuthSwitchGrantImport {
687
687
  removed: false, revision: existing.revision + 1, statusObservedAt: this.stamp(), updateId }
688
688
  : { id: identity.accountId, providerId: plan.providerId, issuer: plan.providerId,
689
689
  subject: identity.subject, workspaceId: identity.workspaceId, label, email: record.email,
690
- plan: record.plan, primaryGrantId: grantId, maxUsagePercent: null, reserveLiftUntil: null, lapsesAt: null, spendLimitMicroUsd: null, keyHint: null, removed: false, revision: 1,
690
+ plan: record.plan, primaryGrantId: grantId, maxUsagePercent: null, reserveLiftUntil: null, lapsesAt: null, spendLimitMicroUsd: null, keyHint: null, claudeCode: true, removed: false, revision: 1,
691
691
  statusObservedAt: this.stamp(), updateId };
692
692
  }
693
693
 
@@ -34,6 +34,8 @@ export interface IStoredAuthorityAccount {
34
34
  spendLimitMicroUsd: number | null;
35
35
  /** How an API key account's key ends, or `null` (`IAuthSwitchAccount.keyHint`). */
36
36
  keyHint: string | null;
37
+ /** Whether the account may serve Claude Code (`IAuthSwitchAccount.claudeCode`); always `true` for a sign-in. */
38
+ claudeCode: boolean;
37
39
  removed: boolean;
38
40
  revision: number;
39
41
  statusObservedAt: string;
@@ -728,7 +730,7 @@ export const assertStoredAuthorityMeta: (value: unknown) => asserts value is ISt
728
730
  export const assertStoredAuthorityAccount: (value: unknown) => asserts value is IStoredAuthorityAccount = value => {
729
731
  if (!object(value) || !exactKeys(value, ['id', 'providerId', 'issuer', 'subject', 'workspaceId', 'label',
730
732
  'email', 'plan', 'primaryGrantId', 'maxUsagePercent', 'reserveLiftUntil', 'lapsesAt', 'spendLimitMicroUsd', 'keyHint',
731
- 'removed', 'revision', 'statusObservedAt', 'updateId'])
733
+ 'claudeCode', 'removed', 'revision', 'statusObservedAt', 'updateId'])
732
734
  || !hash(value.id) || typeof value.providerId !== 'string'
733
735
  || !/^[a-z][a-z0-9-]{0,63}$/.test(value.providerId)
734
736
  || !bounded(value.issuer) || !bounded(value.subject) || !bounded(value.workspaceId)
@@ -740,6 +742,7 @@ export const assertStoredAuthorityAccount: (value: unknown) => asserts value is
740
742
  || (value.lapsesAt !== null && (!iso(value.lapsesAt) || !isAuthSwitchLapsesAt(value.lapsesAt)))
741
743
  || (value.spendLimitMicroUsd !== null && !isAuthSwitchSpendLimitMicroUsd(value.spendLimitMicroUsd))
742
744
  || (value.keyHint !== null && !isAuthSwitchKeyHint(value.keyHint))
745
+ || typeof value.claudeCode !== 'boolean'
743
746
  || typeof value.removed !== 'boolean' || !revision(value.revision)
744
747
  || !iso(value.statusObservedAt) || !uuid(value.updateId)) throw new Error('Invalid authswitch account record.');
745
748
  };
@@ -1300,6 +1303,7 @@ export class AuthSwitchAuthorityAccountModel extends plugins.nosqldb.SmartDataDb
1300
1303
  @plugins.nosqldb.svDb() public lapsesAt!: string | null;
1301
1304
  @plugins.nosqldb.svDb() public spendLimitMicroUsd!: number | null;
1302
1305
  @plugins.nosqldb.svDb() public keyHint!: string | null;
1306
+ @plugins.nosqldb.svDb() public claudeCode!: boolean;
1303
1307
  @plugins.nosqldb.svDb() public removed!: boolean;
1304
1308
  @plugins.nosqldb.svDb() public revision!: number;
1305
1309
  @plugins.nosqldb.svDb() public statusObservedAt!: string;
@@ -497,6 +497,16 @@ information", https://platform.claude.com/docs/en/api/errors, read 2026-10-20).
497
497
  on exactly that, read before any byte reaches the client, and passes every other 402 through;
498
498
  a `billing_error` event inside a stream that already started is not read.
499
499
 
500
+ Inference on an Anthropic API key whose organization has no credit left (observed 2026-10-29,
501
+ AGL-1147; not in Anthropic's error reference): HTTP 400 with a JSON body whose `error.type` is
502
+ `invalid_request_error` and whose message says the credit balance is too low ("Your credit balance
503
+ is too low to access the Anthropic API. Please go to Plans & Billing to upgrade or purchase
504
+ credits."; Claude Code shows it as "Credit balance is too low" and tags it `billing_error`). It
505
+ answered every request on the key from 11:59 to 12:03 UTC, a 40k-token one as well as a 755k-token
506
+ one; by 12:43 the same key answered requests of every size again (the cause of the change is not
507
+ visible through the key). The proxy reads it as a billing problem of the key; the balance itself
508
+ is not readable with the key.
509
+
500
510
  Login refresh (`ClaudeTokenRefresh.refreshForAuthority`), with the vendor's grant: POST
501
511
  `https://platform.claude.com/v1/oauth/token` (`s.TOKEN_URL` @12733057), `Content-Type: application/json`, a 30 s
502
512
  timeout, and the body `{grant_type:"refresh_token", refresh_token, client_id: <stored clientId> ?? CLIENT_ID
@@ -444,7 +444,7 @@ export const authSwitchSeedClaudeAccount = async (daemon: AuthSwitchAuthorityDae
444
444
  } else {
445
445
  const account: IStoredAuthorityAccount = { id: accountId, providerId: 'anthropic', issuer: 'anthropic',
446
446
  subject: identity.accountUuid, workspaceId: identity.organizationUuid, label: name,
447
- email: identity.emailAddress, plan: 'max', primaryGrantId: loginId, maxUsagePercent: null, reserveLiftUntil: null, lapsesAt: null, spendLimitMicroUsd: null, keyHint: null, removed: false, revision: 1,
447
+ email: identity.emailAddress, plan: 'max', primaryGrantId: loginId, maxUsagePercent: null, reserveLiftUntil: null, lapsesAt: null, spendLimitMicroUsd: null, keyHint: null, claudeCode: true, removed: false, revision: 1,
448
448
  statusObservedAt: now, updateId };
449
449
  await database.changeAccountAndGrant(updateId, accountId, loginId, () => ({ account, grant }));
450
450
  }
@@ -710,7 +710,7 @@ export class AuthSwitchTestAuthority {
710
710
  await database.changeAccountAndGrant(updateId, account.accountId, account.loginId, () => ({
711
711
  account: { id: account.accountId, providerId: 'anthropic', issuer: 'anthropic', subject: identity.accountUuid,
712
712
  workspaceId: identity.organizationUuid, label: name, email: identity.emailAddress, plan: 'max',
713
- primaryGrantId: account.loginId, maxUsagePercent: null, reserveLiftUntil: null, lapsesAt: null, spendLimitMicroUsd: null, keyHint: null, removed: false, revision: 1, statusObservedAt: now, updateId },
713
+ primaryGrantId: account.loginId, maxUsagePercent: null, reserveLiftUntil: null, lapsesAt: null, spendLimitMicroUsd: null, keyHint: null, claudeCode: true, removed: false, revision: 1, statusObservedAt: now, updateId },
714
714
  grant: { id: account.loginId, accountId: account.accountId, providerId: 'anthropic', purpose: 'claude_host_native',
715
715
  audience: 'claude-code-host', state: 'native', owner: 'claude_native', grantGeneration: 1, authorizationGeneration: 1,
716
716
  revision: 1, ciphertext: null, accessExpiresAt: null, attemptId: null, retryAt: null, retryCount: 0,
@@ -748,7 +748,7 @@ export class AuthSwitchTestAuthority {
748
748
  const identity = authSwitchFixtureOpenAiIdentity(name);
749
749
  return { id: accountId, providerId: 'openai', issuer: 'openai', subject: identity.userId,
750
750
  workspaceId: identity.chatgptAccountId, label: name, email: identity.email, plan: 'pro', primaryGrantId: loginId,
751
- maxUsagePercent: null, reserveLiftUntil: null, lapsesAt: null, spendLimitMicroUsd: null, keyHint: null, removed: false, revision: 1, statusObservedAt: now, updateId };
751
+ maxUsagePercent: null, reserveLiftUntil: null, lapsesAt: null, spendLimitMicroUsd: null, keyHint: null, claudeCode: true, removed: false, revision: 1, statusObservedAt: now, updateId };
752
752
  }
753
753
 
754
754
  /**
@@ -0,0 +1,17 @@
1
+ import * as plugins from '../plugins.js';
2
+
3
+ /**
4
+ * Gives every account recorded before an API key could be kept from Claude Code the member the account record now
5
+ * states (AGL-1146).
6
+ *
7
+ * Every account may serve Claude Code unless its owner set otherwise (`claudeCode`), so every account recorded earlier
8
+ * gains `claudeCode: true`, sign-ins and keys alike, and nothing else about it changes, neither its revision nor its
9
+ * update id, since no one changed the account. A record that already carries the member keeps it exactly as it is,
10
+ * which is what makes an interrupted run safe to repeat.
11
+ */
12
+ export const addAccountClaudeCode = async (db: plugins.nosqldb.SmartdataDb): Promise<void> => {
13
+ const accounts = db.mongoDb.collection('authswitch_authority_accounts');
14
+ const missing = { claudeCode: { $exists: false } };
15
+ if (!await accounts.findOne(missing)) return;
16
+ await accounts.updateMany(missing, { $set: { claudeCode: true } });
17
+ };
@@ -10,6 +10,7 @@ import { addAccountLapse } from './0008_account_lapse.js';
10
10
  import { addAccountReserveLift } from './0009_account_reserve_lift.js';
11
11
  import { prepareCodexHostRelease } from './0010_codex_host_release.js';
12
12
  import { addAccountApiKeyFields } from './0011_account_api_key_fields.js';
13
+ import { addAccountClaudeCode } from './0012_account_claude_code.js';
13
14
 
14
15
  /**
15
16
  * Runs on every start of an existing store, in this fixed order. Each module recognises the published shapes it
@@ -27,4 +28,5 @@ export const runAuthorityMigrations = async (db: plugins.nosqldb.SmartdataDb): P
27
28
  await addAccountReserveLift(db);
28
29
  await prepareCodexHostRelease(db);
29
30
  await addAccountApiKeyFields(db);
31
+ await addAccountClaudeCode(db);
30
32
  };
@@ -0,0 +1,98 @@
1
+ /**
2
+ * Deployments (AGL-909): what runs where, observed rather than claimed. A release is the repository's tag `v<version>`;
3
+ * what a target runs is what its probe answers, recorded as an observation whenever it changes. Everything else (what a
4
+ * release holds, how far a target is behind, open bugs on the running version) is computed when it is read.
5
+ */
6
+
7
+ /**
8
+ * How a target tells what it runs. `controller` is the AGL controller itself (its package version and start time);
9
+ * `http` reads a JSON document and takes the version, and optionally the commit, at JSON pointers.
10
+ */
11
+ export type TFleetDeployProbe =
12
+ | { kind: 'controller' }
13
+ | {
14
+ kind: 'http';
15
+ /** An http(s) URL without credentials. */
16
+ url: string;
17
+ /** RFC 6901 pointer to the version in the JSON answer; absent is `/version`. */
18
+ versionPointer?: string;
19
+ /** RFC 6901 pointer to the commit sha in the JSON answer; absent reads none. */
20
+ shaPointer?: string;
21
+ };
22
+
23
+ /** A deploy target id: lowercase letters, digits, `.`, `_` and `-`, at most 64. */
24
+ export const fleetDeployTargetIdPattern = /^[a-z0-9][a-z0-9._-]{0,63}$/u;
25
+
26
+ /**
27
+ * When a target's deploys may run: at any time, or only inside a maintenance window planned for it. The AGL controller
28
+ * declares neither: it is deployed (upgraded) when no session is busy.
29
+ */
30
+ export type TFleetDeployWhen = 'anytime' | 'window';
31
+
32
+ /** A deploy target in the Configuration master (`fleet.deployTargets`). The AGL controller is built in and needs none. */
33
+ export interface IFleetDeployTarget {
34
+ /** Lowercase letters, digits, `.`, `_` and `-`; `agl-controller` names the built-in controller target. */
35
+ id: string;
36
+ /** The name the views show; absent shows the id. */
37
+ name?: string;
38
+ /** Where it runs, shown under its name: an environment such as `production`, or a host. */
39
+ environment?: string;
40
+ /** The repository it runs, `org/name` as fleet discovery knows it. */
41
+ repo: string;
42
+ probe: TFleetDeployProbe;
43
+ /** How a deploy happens, in words, for the target sheet. */
44
+ deploys?: string;
45
+ /** What a deploy interrupts, in words, for the target sheet. */
46
+ downtime?: string;
47
+ /**
48
+ * The board project that owns the target: its deploy plans are tickets there, and the direct report whose projects
49
+ * hold it deploys it; no report's project is the driver's own.
50
+ */
51
+ project: string;
52
+ /** Absent is `anytime`. A controller target takes none: it waits until no session is busy. */
53
+ deployWhen?: TFleetDeployWhen;
54
+ }
55
+
56
+ /** A SHA-256 digest as `sha256:<64 hex digits>`. */
57
+ export type TSha256Digest = `sha256:${string}`;
58
+ /**
59
+ * What runs, as an artifact a vulnerability can be matched against: a lockfile at a commit (its git blob id), an OCI
60
+ * image (its index digest), the dependency tree a process reports it has installed, or a self-contained binary.
61
+ */
62
+ export type TSecuritySubject =
63
+ | { kind: 'lockfile'; repo: string; sha: string; path: string; blob: string }
64
+ | { kind: 'image'; digest: TSha256Digest }
65
+ | { kind: 'installed'; targetId: string; treeDigest: TSha256Digest }
66
+ | { kind: 'binary'; sha256: TSha256Digest };
67
+ /** One artifact a target runs, and on how many replicas when it runs on several. */
68
+ export interface IFleetDeployArtifact {
69
+ subject: TSecuritySubject;
70
+ replicas?: number;
71
+ }
72
+
73
+ /**
74
+ * What a target ran, recorded only when its probe answered another version, commit or artifact set than the row recorded last. Rows are
75
+ * ordered by their per-target number, never by time: a clock that steps back cannot reorder them, and two controllers
76
+ * on one database cannot record one change twice.
77
+ */
78
+ export interface IFleetDeployObservation {
79
+ /** `<targetId>:<seq>`. */
80
+ id: string;
81
+ targetId: string;
82
+ /** The target's observation number, 1 for its first; unique per target. */
83
+ seq: number;
84
+ /** The repository the target runs, `org/name`, as it was when the row was recorded. */
85
+ repo: string;
86
+ version: string;
87
+ sha?: string;
88
+ /** When the probe first answered this version (the controller's own start time for the controller); for display only. */
89
+ observedAt: string;
90
+ /** The version of the row before; a newer one means a rollback. */
91
+ previousVersion?: string;
92
+ /**
93
+ * What runs, as artifacts: the controller reports the dependency tree it has installed; a target whose probe cannot
94
+ * say reports none. A rebuild under the same version, a reinstall that resolved other dependencies or a rollout that
95
+ * runs two images is a new row.
96
+ */
97
+ artifacts: IFleetDeployArtifact[];
98
+ }
@@ -72,6 +72,8 @@ export interface IFleetConfiguration {
72
72
  workerProfiles?: import('./fleetworkers.js').IFleetWorkerProfile[];
73
73
  driver?: IFleetDriverConfiguration;
74
74
  boardPump?: IFleetBoardPumpConfiguration;
75
+ /** The deploy targets whose running version AGL observes; the AGL controller is built in and needs no entry. */
76
+ deployTargets?: import('./deployments.js').IFleetDeployTarget[];
75
77
  }
76
78
  /** One fleet operation's configuration and the repositories discovered for it. */
77
79
  export interface IFleetScope extends IFleetConfiguration {
@@ -20,6 +20,7 @@ export * from './tickets.js';
20
20
  export * from './requests.tickets.js';
21
21
  export * from './fleet.js';
22
22
  export * from './requests.fleet.js';
23
+ export * from './deployments.js';
23
24
 
24
25
  export * from './fleetworkers.js';
25
26
  export * from './requests.fleetworkers.js';
@@ -5,7 +5,7 @@ import type {
5
5
  TControllerBrowserPaintAvailability,
6
6
  TControllerBrowserPaintTermination,
7
7
  } from './browserpaint.js';
8
- export const controllerProtocolVersion = 49 as const;
8
+ export const controllerProtocolVersion = 50 as const;
9
9
  export const controllerUpgradeManagementVersion = 2 as const;
10
10
  export const controllerPackageName = 'agl' as const;
11
11
  /** The systemd user unit `agl service install` writes; a controller it runs reports it in its status. */
@@ -235,6 +235,22 @@ export interface IReq_ControllerAccountsSpendLimit extends plugins.typedrequestI
235
235
  response: { answer: TControllerAccountsAnswer<TControllerAccount> };
236
236
  }
237
237
 
238
+ /**
239
+ * Sets whether an API key account may serve Claude Code (AGL-1146): `false` keeps AGL's inference proxy from placing a
240
+ * Claude Code request on the key, while its other clients still use it. `expectedRevision` is the revision the view
241
+ * showed, so a change of an account that changed meanwhile is refused as `account_changed`, and an account on a
242
+ * sign-in, which always serves Claude Code, as `invalid_input`, both by the service. The answer arrives only once the
243
+ * projection shows the result.
244
+ */
245
+ export interface IReq_ControllerAccountsClaudeCode extends plugins.typedrequestInterfaces.implementsTR<
246
+ plugins.typedrequestInterfaces.ITypedRequest,
247
+ IReq_ControllerAccountsClaudeCode
248
+ > {
249
+ method: 'controller.accounts.claudecode';
250
+ request: { accountId: string; expectedRevision: number; claudeCode: boolean };
251
+ response: { answer: TControllerAccountsAnswer<TControllerAccount> };
252
+ }
253
+
238
254
  /** Duration validation shared with the authority; no implicit duration is supplied. */
239
255
  export const isControllerReserveLiftHours = plugins.authswitchAuthority.isAuthSwitchReserveLiftHours;
240
256
 
@@ -31,6 +31,7 @@ import type {
31
31
  IReq_ControllerAccountsReserveLift,
32
32
  IReq_ControllerAccountsApiKeyAdd,
33
33
  IReq_ControllerAccountsSpendLimit,
34
+ IReq_ControllerAccountsClaudeCode,
34
35
  IReq_ControllerAccountsSnapshot,
35
36
  IReq_ControllerAccountsUsageGet,
36
37
  IReq_ControllerAccountsUsageRecheck,
@@ -399,6 +400,7 @@ export type TControllerRequest =
399
400
  | IReq_ControllerAccountsReserveLift
400
401
  | IReq_ControllerAccountsApiKeyAdd
401
402
  | IReq_ControllerAccountsSpendLimit
403
+ | IReq_ControllerAccountsClaudeCode
402
404
  | IReq_ControllerAccountsRemove
403
405
  | IReq_ControllerAccountsAdd
404
406
  | IReq_ControllerAccountsReauth
@@ -1,7 +1,10 @@
1
+ /** `closed` holds work that ships no code: done without a landing or a release. */
1
2
  export const ticketColumns = [
2
- 'backlog', 'ready', 'in_progress', 'needs_input', 'review', 'landed', 'released',
3
+ 'backlog', 'ready', 'in_progress', 'needs_input', 'review', 'landed', 'released', 'closed',
3
4
  ] as const;
4
5
  export type TTicketColumn = (typeof ticketColumns)[number];
6
+ /** The columns of finished work; the board folds them. */
7
+ export const ticketDoneColumns: readonly TTicketColumn[] = ['released', 'closed'];
5
8
  export type TTicketKind = 'epic' | 'task' | 'subtask';
6
9
  export type TTicketPriority = 'none' | 'low' | 'normal' | 'high' | 'urgent';
7
10
  export interface ITicketPerson {
@@ -13,10 +16,33 @@ export interface ITicketPerson {
13
16
  export interface ITicketActor extends ITicketPerson {
14
17
  role: 'owner' | 'driver' | 'worker';
15
18
  }
19
+ /**
20
+ * Evidence a ticket carries. A release is a repository's tag `v<version>`: its link names the repository (`org/name`)
21
+ * and the commit the tag points at, and the package it published where there is one; a release linked by hand names
22
+ * the package alone. `affects` records the version of a repository a bug was found in.
23
+ */
16
24
  export type TTicketLink =
17
25
  | { kind: 'branch'; repo: string; branch: string; sha: string }
18
26
  | { kind: 'commit'; repo: string; sha: string }
19
- | { kind: 'release'; package: string; version: string };
27
+ | { kind: 'release'; version: string; package?: string; repo?: string; sha?: string }
28
+ | { kind: 'affects'; repo: string; version: string };
29
+ /**
30
+ * A planned release: the repository (`org/name`, one fleet discovery knows) and, optionally, the version it should
31
+ * reach; without a version it means the next release. A hotfix is the same plan on an urgent ticket.
32
+ */
33
+ export interface ITicketReleasePlan { repo: string; version?: string }
34
+ /**
35
+ * A maintenance window: between `from` and `to` (ISO 8601 instants, `to` after `from`) the deploy targets it lists may
36
+ * be deployed, which a target whose deploys need a window waits for. A window counts while its ticket is not done.
37
+ * `questionId` is the owner's question on the ticket when the driver proposed the window: it counts once the owner
38
+ * approves it there. The owner's own window has none and counts at once.
39
+ */
40
+ export interface ITicketMaintenanceWindow { from: string; to: string; targets: string[]; questionId?: string }
41
+ /**
42
+ * A planned deploy: the deploy target should run `version`, a release of its repository, or a newer one. Setting it
43
+ * asks the owner `questionId` on the ticket; the answer is the owner's go.
44
+ */
45
+ export interface ITicketDeployPlan { target: string; version: string; questionId: string }
20
46
  export interface ITicketAttachment { name: string; url: string; }
21
47
  export interface ITicketSource {
22
48
  kind: 'owner_words' | 'driver' | 'worker';
@@ -39,6 +65,9 @@ export interface ITicket {
39
65
  assignee?: ITicketPerson;
40
66
  labels: string[];
41
67
  links: TTicketLink[];
68
+ releasePlan?: ITicketReleasePlan;
69
+ maintenanceWindow?: ITicketMaintenanceWindow;
70
+ deployPlan?: ITicketDeployPlan;
42
71
  source: ITicketSource;
43
72
  createdBy: ITicketActor;
44
73
  updatedBy: ITicketActor;
@@ -80,7 +109,7 @@ export interface ITicketActivity {
80
109
  ticketId: string;
81
110
  actor: ITicketActor;
82
111
  createdAt: string;
83
- action: 'created' | 'updated' | 'moved' | 'reordered' | 'commented' | 'linked' | 'asked' | 'answered';
112
+ action: 'created' | 'updated' | 'moved' | 'reordered' | 'commented' | 'linked' | 'unlinked' | 'asked' | 'answered';
84
113
  changes: Record<string, { before?: unknown; after?: unknown }>;
85
114
  }
86
115
  /**
@@ -262,7 +291,7 @@ export interface ITicketFleetEventBase {
262
291
  }
263
292
  export type TTicketFleetEvent = ITicketFleetEventBase & (
264
293
  | { kind: 'landed'; repo: string; branch: string; sha: string; body?: string | TTicketReferenceContent }
265
- | { kind: 'released'; package: string; version: string; body?: string | TTicketReferenceContent }
294
+ | { kind: 'released'; version: string; package?: string; repo?: string; sha?: string; body?: string | TTicketReferenceContent }
266
295
  | { kind: 'comment'; body: string | TTicketReferenceContent }
267
296
  );
268
297
  export interface ITicketFleetEventResult {
@@ -288,6 +317,7 @@ export const ticketErrorMessages = {
288
317
  ticket_label_reserved: 'AutoLabels such as openQuestion are computed by AGL and cannot be set by hand.',
289
318
  ticket_ask_forbidden: 'Workers may ask questions only on tickets assigned to their verified session.',
290
319
  ticket_answer_forbidden: 'Only the owner or the driver may answer ticket questions.',
320
+ ticket_go_owner_only: 'Only the owner answers the question of a deploy plan or a maintenance window: the answer is the owner\'s go.',
291
321
  ticket_question_not_found: 'The requested question does not exist on this ticket.',
292
322
  ticket_comment_not_found: 'The requested comment does not exist on this ticket.',
293
323
  ticket_question_answered: 'The question already has a different answer; a second answer is refused. Ask a new question instead.',
@@ -27,3 +27,4 @@ export * from './v38_flextranscripts.js';
27
27
  export * from './v39_fleetrepositorydiscovery.js';
28
28
  export * from './v39_flexcompaction.js';
29
29
  export * from './v39_flexpublicheadpointers.js';
30
+ export * from './v41_ticketmigrationmarkers.js';
@@ -0,0 +1,28 @@
1
+ import * as plugins from './plugins.js';
2
+
3
+ /** A ticket migration that ran: its name, when it finished and the tickets it changed. */
4
+ export interface ITicketMigrationMarkerDocument {
5
+ /** The migration's name, such as `v41_ticketclosedcolumn`. */
6
+ id: string;
7
+ completedAt: string;
8
+ /** The keys of the tickets it changed. */
9
+ tickets: string[];
10
+ }
11
+
12
+ const markerSchema = plugins.z.object({
13
+ id: plugins.z.string().regex(/^v[0-9]+_[a-z0-9]+$/u), completedAt: plugins.z.iso.datetime(),
14
+ tickets: plugins.z.array(plugins.z.string().regex(/^AGL-[1-9][0-9]*$/u)).max(100_000),
15
+ }).strict();
16
+
17
+ /**
18
+ * One record per ticket migration that ran, written in the transaction that ran it: a migration with a marker never
19
+ * runs again, whatever the board looks like at a later start.
20
+ */
21
+ @plugins.nosqldb.managed({ collectionName: 'agl_ticket_migrations' })
22
+ @plugins.nosqldb.exactPersistence({ assertDocument: (input: unknown) => { markerSchema.parse(input); } })
23
+ export class TicketMigrationMarkerModel extends plugins.nosqldb.SmartDataDbDoc<TicketMigrationMarkerModel, ITicketMigrationMarkerDocument> {
24
+ declare static exact: plugins.nosqldb.TExact<TicketMigrationMarkerModel>;
25
+ @plugins.nosqldb.unI() public id!: string;
26
+ @plugins.nosqldb.svDb() public completedAt!: string;
27
+ @plugins.nosqldb.svDb() public tickets!: string[];
28
+ }
@@ -3,6 +3,6 @@
3
3
  */
4
4
  export const commitinfo = {
5
5
  name: 'agl',
6
- version: '42.1.0',
6
+ version: '42.2.0',
7
7
  description: 'Agent Gateway Layer for OpenCode, FlexHarness, and Codex sessions'
8
8
  }
@@ -146,6 +146,7 @@ export type TAccountActionId =
146
146
  | 'clearMaxUsage'
147
147
  | 'spendLimit'
148
148
  | 'clearSpendLimit'
149
+ | 'claudeCode'
149
150
  | 'addApiKey'
150
151
  | 'remove'
151
152
  | 'usage'
@@ -353,6 +354,8 @@ export interface IAccountRow {
353
354
  apiKey: boolean;
354
355
  /** An API key's monthly spend limit in micro-dollars, or `null` for none and for every sign-in. */
355
356
  spendLimitMicroUsd: number | null;
357
+ /** Whether the account may serve Claude Code (AGL-1146); always `true` for a sign-in. */
358
+ claudeCode: boolean;
356
359
  /** What a removal does that the owner must know, said with the removal; empty for a sign-in. */
357
360
  removeNote: string;
358
361
  label: string;
@@ -1437,6 +1440,11 @@ export const spendLimitText = (spendLimitMicroUsdArg: number | null): string =>
1437
1440
  ? 'No monthly limit'
1438
1441
  : `${plugins.authswitchSpend.authSwitchUsdText(spendLimitMicroUsdArg)} per calendar month (UTC)`;
1439
1442
 
1443
+ /** Whether a key serves Claude Code, in words, as its page states it (AGL-1146). */
1444
+ export const claudeCodeText = (claudeCodeArg: boolean): string => claudeCodeArg
1445
+ ? 'Serves Claude Code'
1446
+ : 'Not for Claude Code: AGL places Claude Code requests on other accounts; other clients still use the key';
1447
+
1440
1448
  /**
1441
1449
  * Why the Add API key dialog cannot add yet, or `''` when it can: a key typed, an optional name the service's label rule
1442
1450
  * accepts, and an optional spend limit in dollars its spend limit rule accepts.
@@ -1536,6 +1544,7 @@ const serviceRow = (
1536
1544
  groupId: apiKey ? `${accountArg.providerId}-api-key` : accountArg.providerId,
1537
1545
  apiKey,
1538
1546
  spendLimitMicroUsd: apiKey ? accountArg.spendLimitMicroUsd : null,
1547
+ claudeCode: accountArg.claudeCode,
1539
1548
  removeNote: apiKey
1540
1549
  ? `AGL stops using the key. It stays valid at ${provider.name} until you revoke it in ${provider.console}.`
1541
1550
  : '',
@@ -1585,7 +1594,8 @@ const serviceRow = (
1585
1594
  manage: [
1586
1595
  serviceSlot('rename', 'Rename', 'lucide:PenLine', contextArg.service, removed),
1587
1596
  // A key's limit is its spend; a usage threshold and its reserve are a sign-in's.
1588
- ...(apiKey ? [serviceSlot('spendLimit', 'Spend limit', 'lucide:Wallet', contextArg.service, removed)]
1597
+ ...(apiKey ? [serviceSlot('spendLimit', 'Spend limit', 'lucide:Wallet', contextArg.service, removed),
1598
+ serviceSlot('claudeCode', 'Claude Code', 'lucide:Terminal', contextArg.service, removed)]
1589
1599
  : [serviceSlot('maxUsage', 'Max usage', 'lucide:SlidersHorizontal', contextArg.service, removed)]),
1590
1600
  ...(!apiKey && accountArg.maxUsagePercent !== null && accountArg.maxUsagePercent < 100
1591
1601
  ? [serviceSlot('liftReserve', 'Lift reserve', 'lucide:Clock', contextArg.service, removed)] : []),
@@ -1605,6 +1615,7 @@ const serviceRow = (
1605
1615
  ? plugins.authswitchSubscription.authSwitchSubscriptionFacts(usageRead.usage.reading) : []),
1606
1616
  apiKey ? { label: 'Monthly spend limit', value: spendLimitText(accountArg.spendLimitMicroUsd) }
1607
1617
  : { label: 'Max usage', value: maxUsageFact(accountArg.maxUsagePercent) },
1618
+ ...(apiKey ? [{ label: 'Claude Code', value: claudeCodeText(accountArg.claudeCode) }] : []),
1608
1619
  { label: 'Account reference', value: accountArg.id },
1609
1620
  ],
1610
1621
  accountId: accountArg.id,