agl 40.4.0 → 40.5.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (156) hide show
  1. package/changelog.md +33 -0
  2. package/dist_serve/bundle.js +2228 -2177
  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 +2 -2
  6. package/dist_ts/classes.accountsactions.d.ts +11 -1
  7. package/dist_ts/classes.accountsactions.js +59 -2
  8. package/dist_ts/classes.controller.js +5 -5
  9. package/dist_ts/classes.flexaccountaccess.js +3 -2
  10. package/dist_ts/classes.harnessreleases.d.ts +14 -4
  11. package/dist_ts/classes.harnessreleases.js +28 -4
  12. package/dist_ts/classes.inferencegateway.d.ts +28 -3
  13. package/dist_ts/classes.inferencegateway.js +177 -61
  14. package/dist_ts/classes.inferenceplacement.d.ts +5 -3
  15. package/dist_ts/classes.inferenceplacement.js +2 -2
  16. package/dist_ts/classes.inferencerouter.d.ts +349 -91
  17. package/dist_ts/classes.inferencerouter.js +804 -297
  18. package/dist_ts/classes.inferenceservice.d.ts +14 -2
  19. package/dist_ts/classes.inferenceservice.js +53 -14
  20. package/dist_ts/classes.inferencespend.d.ts +339 -0
  21. package/dist_ts/classes.inferencespend.js +815 -0
  22. package/dist_ts/classes.inferenceusagecache.d.ts +8 -0
  23. package/dist_ts/classes.inferenceusagecache.js +9 -5
  24. package/dist_ts/classes.inferenceusagetap.d.ts +50 -9
  25. package/dist_ts/classes.inferenceusagetap.js +185 -31
  26. package/dist_ts/classes.proxycontrol.d.ts +3 -2
  27. package/dist_ts/classes.proxycontrol.js +1 -2
  28. package/dist_ts/classes.proxydaemon.js +3 -2
  29. package/dist_ts/classes.proxystore.d.ts +6 -0
  30. package/dist_ts/classes.proxystore.js +11 -2
  31. package/dist_ts/fleet/classes.claudeworkers.d.ts +5 -4
  32. package/dist_ts/fleet/classes.claudeworkers.js +10 -9
  33. package/dist_ts/functions.claudecoderelease.d.ts +12 -6
  34. package/dist_ts/functions.claudecoderelease.js +13 -7
  35. package/dist_ts/functions.inferencecli.js +12 -8
  36. package/dist_ts/interfaces.auth.d.ts +1 -1
  37. package/dist_ts/interfaces.auth.js +3 -1
  38. package/dist_ts/plugins.d.ts +3 -1
  39. package/dist_ts/plugins.js +7 -2
  40. package/dist_ts_authswitch/authority-apikeys.d.ts +32 -0
  41. package/dist_ts_authswitch/authority-apikeys.js +65 -0
  42. package/dist_ts_authswitch/authority-contract.d.ts +172 -33
  43. package/dist_ts_authswitch/authority-contract.js +54 -1
  44. package/dist_ts_authswitch/authority-overview.js +8 -1
  45. package/dist_ts_authswitch/authority-placement.d.ts +7 -2
  46. package/dist_ts_authswitch/authority-placement.js +10 -3
  47. package/dist_ts_authswitch/authority-runtime-contract.d.ts +2 -2
  48. package/dist_ts_authswitch/authority-spend.d.ts +103 -0
  49. package/dist_ts_authswitch/authority-spend.js +110 -0
  50. package/dist_ts_authswitch/authority-subscription.d.ts +12 -1
  51. package/dist_ts_authswitch/authority-subscription.js +24 -1
  52. package/dist_ts_authswitch/authority-usagelimit.d.ts +7 -4
  53. package/dist_ts_authswitch/authority-usagelimit.js +89 -39
  54. package/dist_ts_authswitch/authority-usagewindows.d.ts +4 -1
  55. package/dist_ts_authswitch/authority-usagewindows.js +41 -16
  56. package/dist_ts_authswitch/classes.authoritybroker.d.ts +30 -19
  57. package/dist_ts_authswitch/classes.authoritybroker.js +152 -61
  58. package/dist_ts_authswitch/classes.authoritycli.d.ts +9 -4
  59. package/dist_ts_authswitch/classes.authoritycli.js +99 -30
  60. package/dist_ts_authswitch/classes.authorityclient.d.ts +24 -7
  61. package/dist_ts_authswitch/classes.authorityclient.js +45 -15
  62. package/dist_ts_authswitch/classes.authoritydaemon.js +39 -12
  63. package/dist_ts_authswitch/classes.authoritydatabase.d.ts +28 -5
  64. package/dist_ts_authswitch/classes.authoritydatabase.js +171 -9
  65. package/dist_ts_authswitch/classes.authorityimport.js +2 -2
  66. package/dist_ts_authswitch/classes.authoritymodels.d.ts +71 -3
  67. package/dist_ts_authswitch/classes.authoritymodels.js +249 -20
  68. package/dist_ts_authswitch/classes.authorityregistry.js +4 -2
  69. package/dist_ts_authswitch/classes.authorityusage.d.ts +69 -7
  70. package/dist_ts_authswitch/classes.authorityusage.js +118 -4
  71. package/dist_ts_authswitch/classes.claudenative.d.ts +23 -8
  72. package/dist_ts_authswitch/classes.claudenative.js +49 -21
  73. package/dist_ts_authswitch/classes.claudesignin.d.ts +14 -2
  74. package/dist_ts_authswitch/classes.claudesignin.js +72 -23
  75. package/dist_ts_authswitch/classes.codexmanaged.d.ts +8 -0
  76. package/dist_ts_authswitch/classes.codexmanaged.js +33 -18
  77. package/dist_ts_authswitch/classes.harnessprocesses.d.ts +8 -0
  78. package/dist_ts_authswitch/classes.harnessprocesses.js +41 -9
  79. package/dist_ts_authswitch/testsupport.d.ts +24 -5
  80. package/dist_ts_authswitch/testsupport.js +56 -12
  81. package/dist_ts_authswitch/ts_migration/0011_account_api_key_fields.d.ts +12 -0
  82. package/dist_ts_authswitch/ts_migration/0011_account_api_key_fields.js +21 -0
  83. package/dist_ts_authswitch/ts_migration/index.js +3 -1
  84. package/dist_ts_interfaces/functions.authorityscope.d.ts +18 -7
  85. package/dist_ts_interfaces/functions.authorityscope.js +35 -8
  86. package/dist_ts_interfaces/interfaces.d.ts +1 -1
  87. package/dist_ts_interfaces/interfaces.js +1 -1
  88. package/dist_ts_interfaces/plugins.d.ts +2 -1
  89. package/dist_ts_interfaces/plugins.js +7 -4
  90. package/dist_ts_interfaces/requests.accounts.d.ts +56 -0
  91. package/dist_ts_interfaces/requests.accounts.js +11 -1
  92. package/dist_ts_interfaces/requests.d.ts +2 -2
  93. package/dist_ts_interfaces/requests.js +1 -1
  94. package/docs/authswitch.md +75 -12
  95. package/package.json +5 -5
  96. package/readme.md +199 -22
  97. package/ts/00_commitinfo_data.ts +1 -1
  98. package/ts/aglapi/aglapisurface.document.ts +2 -2
  99. package/ts/classes.accountsactions.ts +75 -1
  100. package/ts/classes.controller.ts +4 -4
  101. package/ts/classes.flexaccountaccess.ts +2 -1
  102. package/ts/classes.harnessreleases.ts +25 -4
  103. package/ts/classes.inferencegateway.ts +184 -64
  104. package/ts/classes.inferenceplacement.ts +6 -4
  105. package/ts/classes.inferencerouter.ts +1026 -314
  106. package/ts/classes.inferenceservice.ts +56 -13
  107. package/ts/classes.inferencespend.ts +870 -0
  108. package/ts/classes.inferenceusagecache.ts +16 -4
  109. package/ts/classes.inferenceusagetap.ts +159 -34
  110. package/ts/classes.proxycontrol.ts +3 -3
  111. package/ts/classes.proxydaemon.ts +2 -1
  112. package/ts/classes.proxystore.ts +11 -1
  113. package/ts/fleet/classes.claudeworkers.ts +9 -8
  114. package/ts/functions.claudecoderelease.ts +13 -6
  115. package/ts/functions.inferencecli.ts +11 -7
  116. package/ts/interfaces.auth.ts +2 -0
  117. package/ts/plugins.ts +7 -0
  118. package/ts_authswitch/authority-apikeys.ts +85 -0
  119. package/ts_authswitch/authority-contract.ts +201 -34
  120. package/ts_authswitch/authority-overview.ts +7 -0
  121. package/ts_authswitch/authority-placement.ts +12 -4
  122. package/ts_authswitch/authority-runtime-contract.ts +2 -2
  123. package/ts_authswitch/authority-spend.ts +168 -0
  124. package/ts_authswitch/authority-subscription.ts +28 -1
  125. package/ts_authswitch/authority-usagelimit.ts +95 -40
  126. package/ts_authswitch/authority-usagewindows.ts +42 -17
  127. package/ts_authswitch/classes.authoritybroker.ts +161 -68
  128. package/ts_authswitch/classes.authoritycli.ts +112 -32
  129. package/ts_authswitch/classes.authorityclient.ts +66 -19
  130. package/ts_authswitch/classes.authoritydaemon.ts +43 -13
  131. package/ts_authswitch/classes.authoritydatabase.ts +178 -8
  132. package/ts_authswitch/classes.authorityimport.ts +1 -1
  133. package/ts_authswitch/classes.authoritymodels.ts +165 -19
  134. package/ts_authswitch/classes.authorityregistry.ts +3 -0
  135. package/ts_authswitch/classes.authorityusage.ts +171 -10
  136. package/ts_authswitch/classes.claudenative.ts +51 -22
  137. package/ts_authswitch/classes.claudesignin.ts +74 -24
  138. package/ts_authswitch/classes.codexmanaged.ts +30 -16
  139. package/ts_authswitch/classes.harnessprocesses.ts +39 -8
  140. package/ts_authswitch/native-contracts.md +82 -21
  141. package/ts_authswitch/readme.md +1 -1
  142. package/ts_authswitch/testsupport.ts +58 -11
  143. package/ts_authswitch/ts_migration/0011_account_api_key_fields.ts +20 -0
  144. package/ts_authswitch/ts_migration/index.ts +2 -0
  145. package/ts_interfaces/functions.authorityscope.ts +43 -8
  146. package/ts_interfaces/interfaces.ts +1 -1
  147. package/ts_interfaces/plugins.ts +6 -3
  148. package/ts_interfaces/requests.accounts.ts +48 -0
  149. package/ts_interfaces/requests.ts +4 -0
  150. package/ts_web/00_commitinfo_data.ts +1 -1
  151. package/ts_web/accounts.plugins.ts +7 -1
  152. package/ts_web/accounts.templates.ts +20 -11
  153. package/ts_web/classes.accountsreadmodel.ts +326 -71
  154. package/ts_web/elements.accounts.ts +219 -20
  155. package/ts_web/elements.codexconnections.ts +3 -1
  156. package/ts_web/plugins.ts +4 -2
@@ -97,6 +97,8 @@ export type TControllerAccountNativeAssignment = plugins.authswitchAuthority.IAu
97
97
  export type TControllerAccountOperation = plugins.authswitchAuthority.IAuthSwitchOperation;
98
98
  export type TControllerAccountPreuse = plugins.authswitchAuthority.IAuthSwitchPreuseOperation;
99
99
  export type TControllerAccountUsage = plugins.authswitchAuthority.IAuthSwitchUsageSnapshot;
100
+ /** An API key's month, the reading of an API key account's usage (`kind: 'spend'`). */
101
+ export type TControllerAccountSpendReading = plugins.authswitchAuthority.IAuthSwitchSpendReading;
100
102
  /** A re-check of a Claude login: the usage held once its read finished, and how that read went. */
101
103
  export type TControllerAccountUsageRecheck = plugins.authswitchAuthority.IAuthSwitchUsageRecheck;
102
104
  export type TControllerAccountsDoctorPage = plugins.authswitchAuthority.IAuthSwitchDoctorPage;
@@ -187,6 +189,52 @@ export interface IReq_ControllerAccountsMaxUsage extends plugins.typedrequestInt
187
189
  response: { answer: TControllerAccountsAnswer<TControllerAccount> };
188
190
  }
189
191
 
192
+ /** The providers whose API keys the Accounts screen adds as accounts. */
193
+ export type TControllerApiKeyProvider = plugins.authswitchAuthority.TAuthSwitchApiKeyProvider;
194
+
195
+ /**
196
+ * The spend limit rule, as the accounts service publishes and applies it: a whole number of cents from
197
+ * `controllerSpendLimitRange.min` to `.max`, in micro-dollars. A view checks a value with it before it offers the
198
+ * change, and the service refuses any other value with `invalid_input`.
199
+ */
200
+ export const isControllerSpendLimitMicroUsd = plugins.authswitchSpend.isAuthSwitchSpendLimitMicroUsd;
201
+ /** The range of a spend limit, in micro-dollars. */
202
+ export const controllerSpendLimitRange = plugins.authswitchSpend.authSwitchSpendLimitRange;
203
+
204
+ /** The longest API key the accounts service holds, in characters; a longer value is refused before it is sent. */
205
+ export const controllerApiKeyMaxLength = 512;
206
+
207
+ /**
208
+ * Adds an Anthropic or OpenAI API key as an account, with an optional label and monthly spend limit
209
+ * (`isControllerSpendLimitMicroUsd`). The accounts service asks the provider whether it accepts the key before it holds
210
+ * it, and answers why when it does not (`api_key_unverified`, `invalid_input`). The key is never answered, logged or
211
+ * audited; the account names it only by how it ends (`keyHint`). The answer arrives only once the controller's own
212
+ * projection shows the account; it can take up to 35 seconds, the provider's answer included.
213
+ */
214
+ export interface IReq_ControllerAccountsApiKeyAdd extends plugins.typedrequestInterfaces.implementsTR<
215
+ plugins.typedrequestInterfaces.ITypedRequest,
216
+ IReq_ControllerAccountsApiKeyAdd
217
+ > {
218
+ method: 'controller.accounts.apikey.add';
219
+ request: { providerId: TControllerApiKeyProvider; apiKey: string; label?: string; spendLimitMicroUsd?: number };
220
+ response: { answer: TControllerAccountsAnswer<{ account: TControllerAccount; loginId: string }> };
221
+ }
222
+
223
+ /**
224
+ * Sets an API key account's monthly spend limit, or clears it with `null`: at the limit AGL's inference proxy places
225
+ * nothing more on the key until the month ends (UTC). `expectedRevision` is the revision the view showed, so a change of
226
+ * an account that changed meanwhile is refused as `account_changed`, and a value that breaks the rule, or an account on
227
+ * a sign-in, as `invalid_input`, both by the service. The answer arrives only once the projection shows the result.
228
+ */
229
+ export interface IReq_ControllerAccountsSpendLimit extends plugins.typedrequestInterfaces.implementsTR<
230
+ plugins.typedrequestInterfaces.ITypedRequest,
231
+ IReq_ControllerAccountsSpendLimit
232
+ > {
233
+ method: 'controller.accounts.spendlimit';
234
+ request: { accountId: string; expectedRevision: number; spendLimitMicroUsd: number | null };
235
+ response: { answer: TControllerAccountsAnswer<TControllerAccount> };
236
+ }
237
+
190
238
  /** Duration validation shared with the authority; no implicit duration is supplied. */
191
239
  export const isControllerReserveLiftHours = plugins.authswitchAuthority.isAuthSwitchReserveLiftHours;
192
240
 
@@ -29,6 +29,8 @@ import type {
29
29
  IReq_ControllerAccountsRename,
30
30
  IReq_ControllerAccountsMaxUsage,
31
31
  IReq_ControllerAccountsReserveLift,
32
+ IReq_ControllerAccountsApiKeyAdd,
33
+ IReq_ControllerAccountsSpendLimit,
32
34
  IReq_ControllerAccountsSnapshot,
33
35
  IReq_ControllerAccountsUsageGet,
34
36
  IReq_ControllerAccountsUsageRecheck,
@@ -399,6 +401,8 @@ export type TControllerRequest =
399
401
  | IReq_ControllerAccountsRename
400
402
  | IReq_ControllerAccountsMaxUsage
401
403
  | IReq_ControllerAccountsReserveLift
404
+ | IReq_ControllerAccountsApiKeyAdd
405
+ | IReq_ControllerAccountsSpendLimit
402
406
  | IReq_ControllerAccountsRemove
403
407
  | IReq_ControllerAccountsAdd
404
408
  | IReq_ControllerAccountsReauth
@@ -3,6 +3,6 @@
3
3
  */
4
4
  export const commitinfo = {
5
5
  name: 'agl',
6
- version: '40.4.0',
6
+ version: '40.5.1',
7
7
  description: 'Agent Gateway Layer for OpenCode, FlexHarness, and Codex sessions'
8
8
  }
@@ -11,5 +11,11 @@ import * as authswitchUsageWindows from '../ts_authswitch/authority-usagewindows
11
11
  import * as authswitchUsageLimit from '../ts_authswitch/authority-usagelimit.js';
12
12
  // A Claude account's subscription facts and payment problem, in the words the authswitch command line uses; types only behind it.
13
13
  import * as authswitchSubscription from '../ts_authswitch/authority-subscription.js';
14
+ // An API key's month: the spend limit rule and dollar amounts, as the command line states them; it imports nothing.
15
+ import * as authswitchSpend from '../ts_authswitch/authority-spend.js';
16
+ // The service's contract, which the controller's interfaces load already: the processes holding a Claude sign-in, in
17
+ // the words the command line uses.
18
+ import * as authswitchAuthority from '../ts_authswitch/authority-contract.js';
14
19
 
15
- export { authswitchPreuseText, authswitchSubscription, authswitchUsageLimit, authswitchUsageWindows };
20
+ export { authswitchAuthority, authswitchPreuseText, authswitchSpend, authswitchSubscription, authswitchUsageLimit,
21
+ authswitchUsageWindows };
@@ -1,10 +1,11 @@
1
1
  import * as plugins from './plugins.js';
2
- import type {
3
- IAccountActionSlot,
4
- IAccountFact,
5
- IAccountRow,
6
- IAccountsSummary,
7
- TAccountsTone,
2
+ import {
3
+ spendAttentionPercent,
4
+ type IAccountActionSlot,
5
+ type IAccountFact,
6
+ type IAccountRow,
7
+ type IAccountsSummary,
8
+ type TAccountsTone,
8
9
  } from './classes.accountsreadmodel.js';
9
10
 
10
11
  /**
@@ -95,7 +96,10 @@ export const renderSlots = (
95
96
  `;
96
97
  };
97
98
 
98
- /** An account as one line of the list: mark, name and who uses it, its tightest window, its one status. */
99
+ /**
100
+ * An account as one line of the list: mark, name and who uses it, its tightest window -- a key's month, which without a
101
+ * limit has its spend and no bar -- and its one status.
102
+ */
99
103
  export const renderListRow = (
100
104
  rowArg: IAccountRow,
101
105
  openArg: (rowArg: IAccountRow) => void,
@@ -113,8 +117,9 @@ export const renderListRow = (
113
117
  ${meter
114
118
  ? plugins.deesElement.html`
115
119
  <span class="meterText"><span>${meter.label}</span><span class="meterValue">${meter.valueText}</span></span>
116
- <dees-meter .size=${'sm'} .value=${meter.percent} .threshold=${meter.threshold} .tone=${meterTone(meter.tone)}
117
- .label=${meter.label} .valueText=${meter.valueText}></dees-meter>`
120
+ ${meter.percent === null ? '' : plugins.deesElement.html`<dees-meter .size=${'sm'} .value=${meter.percent}
121
+ .threshold=${meter.threshold} .tone=${meterTone(meter.tone)} .label=${meter.label}
122
+ .valueText=${meter.valueText}></dees-meter>`}`
118
123
  : plugins.deesElement.html`<span class="meterText"><span>No reading</span><span class="meterValue">—</span></span>`}
119
124
  </span>
120
125
  <dees-badge data-status .type=${badgeType(rowArg.pill.tone)} .text=${rowArg.pill.text}></dees-badge>
@@ -144,17 +149,21 @@ export const renderSummary = (summaryArg: IAccountsSummary): plugins.deesElement
144
149
  </div>
145
150
  `;
146
151
 
147
- /** An account's usage windows, each with its reset, ticked at its maximum; or why there is no reading. */
152
+ /**
153
+ * An account's usage windows, each with its reset, ticked at its maximum; or why there is no reading. A key's month
154
+ * wants attention from `spendAttentionPercent` of its limit, with no tick: a key has no maximum usage.
155
+ */
148
156
  export const renderUsageMeters = (rowArg: IAccountRow, emptyArg: string): plugins.deesElement.TemplateResult => {
149
157
  const meters = rowArg.usage?.meters ?? [];
150
158
  const threshold = rowArg.maxUsagePercent !== null && rowArg.maxUsagePercent < 100 ? rowArg.maxUsagePercent : null;
159
+ const attentionAt = rowArg.apiKey ? spendAttentionPercent : threshold;
151
160
  return plugins.deesElement.html`
152
161
  <mp-usage-meters class=${rowArg.usage?.current === false ? 'stale' : ''} data-usage-meters
153
162
  .windows=${meters.map((meterArg) => ({
154
163
  label: meterArg.label,
155
164
  percent: meterArg.percent,
156
165
  resetText: meterArg.resetText,
157
- tone: meterTone(meterArg.percent >= 100 ? 'neutral' : threshold !== null && meterArg.percent >= threshold
166
+ tone: meterTone(meterArg.percent >= 100 ? 'neutral' : attentionAt !== null && meterArg.percent >= attentionAt
158
167
  ? 'attention' : 'positive'),
159
168
  }))}
160
169
  .threshold=${threshold}