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
@@ -25,7 +25,21 @@ export interface IInferenceGatewayRequestFailure {
25
25
  code: string;
26
26
  protocol?: TProtocol;
27
27
  error?: string;
28
+ /**
29
+ * For a request refused before its client was known (AGL-304): the path it asked for, without its query, and the
30
+ * client's own name for itself (`user-agent`), each printable ASCII and cut short (`refusalText`), so a looping
31
+ * client can be found from the journal. Never a header value beyond those, never the credential.
32
+ */
33
+ path?: string;
34
+ userAgent?: string;
35
+ /** For a 401: what the request presented (`TInferenceGatewayCredentialRefusal`). */
36
+ credential?: TInferenceGatewayCredentialRefusal;
28
37
  }
38
+ /**
39
+ * What a refused request presented as its gateway credential: none, one the gateway cannot read (not a bearer token or
40
+ * `x-api-key`, or over 512 characters), one no client holds, or one of a client of the other listener.
41
+ */
42
+ export type TInferenceGatewayCredentialRefusal = 'missing' | 'malformed' | 'unknown' | 'other_listener';
29
43
  export interface IInferenceGatewayOptions {
30
44
  router: InferenceRouter;
31
45
  signatureKey: Uint8Array;
@@ -81,6 +95,11 @@ export interface IInferenceGatewayStreamCut {
81
95
  /** The failure's class, and its system code where it names one, such as `TypeError UND_ERR_SOCKET`. */
82
96
  error: string;
83
97
  }
98
+ /**
99
+ * The proxy's journal line per refusal, the same line at most once a minute (AGL-304): a client that repeats a refused
100
+ * request in a loop gets its line once, and the next one after the minute says how many like it the minute held.
101
+ */
102
+ export declare const inferenceRequestFailureWriter: (writeArg?: (textArg: string) => void, nowArg?: () => number) => ((failureArg: IInferenceGatewayRequestFailure) => void);
84
103
  /** A named client's use, credential-free. Unnamed clients are leases. */
85
104
  export interface IInferenceGatewayClientStatus {
86
105
  name: string;
@@ -134,6 +153,12 @@ export interface IInferenceGatewayRestoredLease {
134
153
  }
135
154
  /** Codex's Responses, Messages answered by a ChatGPT pool, or Claude Code's own Messages sent to a Claude pool. */
136
155
  type TProtocol = 'responses' | 'messages' | 'claude';
156
+ /**
157
+ * Whether a Claude pool's request comes from Claude Code (AGL-1146): its client is one AGL runs Claude Code on, or the
158
+ * request names Claude Code itself (`user-agent: claude-cli/…`, as Claude Code and the Agent SDK send it). The header
159
+ * can only narrow the accounts a request may use, never widen them.
160
+ */
161
+ export declare const inferenceClaudeCodeRequest: (sessionScopeArg: string, headersArg: Headers) => boolean;
137
162
  /** The digest under which the gateway knows a credential, as `IInferenceGatewayGrant.digest` reports it. */
138
163
  export declare const inferenceGatewayCredentialDigest: (tokenArg: string) => string;
139
164
  /** These payloads carry provider/account-owned state and cannot move to another account. */
@@ -149,8 +174,11 @@ export declare const inferenceRequestHasAccountState: (bodyArg: Record<string, u
149
174
  * with HTTP 429 whose `error.code` names the cause (`credit_balance_exhausted`, `organization_spend_limit_exceeded`,
150
175
  * `project_spend_limit_exceeded`, `organization_usage_limit_exceeded`) and whose `error.type` can be
151
176
  * `insufficient_quota`; retrying does not help (https://developers.openai.com/api/docs/guides/error-codes). A Claude
152
- * account's subscription states only the billing error; a spend limit set in the Claude Console (HTTP 400
153
- * `invalid_request_error`) is not read as one.
177
+ * account's subscription states only the billing error. Undocumented but observed (2026-10-29, AGL-1147): Anthropic
178
+ * refuses every request on an API key whose organization has no credit left with HTTP 400 `invalid_request_error`
179
+ * whose message says the credit balance is too low (`anthropicCreditBalanceTooLow`, the phrase Claude Code itself reads as
180
+ * a billing error); that is a billing problem of the key. Any other 400, a spend limit set in the Claude Console among
181
+ * them, is not read as one.
154
182
  */
155
183
  export declare const inferencePaymentCause: (providerArg: TInferenceProvider, credentialArg: TInferenceCredential, statusArg: number, bodyArg: unknown) => TInferencePaymentCause | undefined;
156
184
  /**