@tangle-network/agent-app 4.0.13 → 4.0.15

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 (32) hide show
  1. package/dist/billing/identity-bound.d.ts +14 -9
  2. package/dist/billing/index.js +1 -1
  3. package/dist/chat-routes/detached-turn.d.ts +1 -1
  4. package/dist/chat-routes/failure-wording.d.ts +3 -4
  5. package/dist/chat-routes/index.js +5 -5
  6. package/dist/chat-routes/index.js.map +1 -1
  7. package/dist/{chunk-XCUT2I52.js → chunk-5QQBQS7W.js} +8 -2
  8. package/dist/{chunk-XCUT2I52.js.map → chunk-5QQBQS7W.js.map} +1 -1
  9. package/dist/{chunk-GWATTXFR.js → chunk-FYF564KJ.js} +2 -2
  10. package/dist/{chunk-QPD42X6A.js → chunk-G4NHCLYA.js} +17 -9
  11. package/dist/chunk-G4NHCLYA.js.map +1 -0
  12. package/dist/{chunk-TMWUWKLU.js → chunk-GE242CLI.js} +2 -2
  13. package/dist/{chunk-RNDWCT4O.js → chunk-MZZMOGFN.js} +101 -89
  14. package/dist/{chunk-RNDWCT4O.js.map → chunk-MZZMOGFN.js.map} +1 -1
  15. package/dist/{chunk-CD4SJXYC.js → chunk-RFXROORA.js} +12 -12
  16. package/dist/chunk-RFXROORA.js.map +1 -0
  17. package/dist/platform/delegated-keys.d.ts +5 -1
  18. package/dist/platform/index.js +8 -2
  19. package/dist/platform/index.js.map +1 -1
  20. package/dist/preset-cloudflare/index.js +3 -3
  21. package/dist/public-consultation/index.js +3 -3
  22. package/dist/runtime/index.js +2 -2
  23. package/dist/runtime/router-turn.js +1 -1
  24. package/dist/spend/delegate-budget.d.ts +4 -0
  25. package/dist/spend/index.js.map +1 -1
  26. package/dist/turn-health/index.js +3 -1
  27. package/dist/turn-health/index.js.map +1 -1
  28. package/package.json +1 -1
  29. package/dist/chunk-CD4SJXYC.js.map +0 -1
  30. package/dist/chunk-QPD42X6A.js.map +0 -1
  31. /package/dist/{chunk-GWATTXFR.js.map → chunk-FYF564KJ.js.map} +0 -0
  32. /package/dist/{chunk-TMWUWKLU.js.map → chunk-GE242CLI.js.map} +0 -0
@@ -186,16 +186,19 @@ export interface DelegatedKeyProvisioner {
186
186
  name: string;
187
187
  product: string;
188
188
  budgetUsd: number;
189
+ spendThrough?: true;
189
190
  expiresAt: string;
190
191
  idempotencyKey: string;
191
192
  }): Promise<{
192
193
  id: string;
193
194
  key: string;
194
195
  budgetUsd?: number | null;
196
+ spendThrough?: true;
195
197
  expiresAt?: string | null;
196
198
  }>;
197
199
  getKey(id: string): Promise<{
198
200
  budgetUsd?: number | null;
201
+ budgetRemaining?: number;
199
202
  expiresAt?: string | null;
200
203
  }>;
201
204
  revokeKey(id: string, slot?: {
@@ -229,7 +232,8 @@ export declare class DelegatedKeyRefusalError extends Error {
229
232
  *
230
233
  * `getKey` reads Platform's verdict: a key gone for good is reported missing
231
234
  * (the manager marks it revoked and mints again); a spent key is reported
232
- * exhausted (the manager revokes it remotely and mints again); a funding or
235
+ * exhausted (the manager revokes a sized child and mints again, and keeps a
236
+ * spend-through child, whose spent source Router refuses per request); a funding or
233
237
  * eligibility refusal is a typed error, so a lapse never retires a key that
234
238
  * still works.
235
239
  */
@@ -1162,13 +1162,17 @@ function createDelegatedKeyProvisioner(input) {
1162
1162
  product,
1163
1163
  ...input.resource ? { resource: input.resource } : {},
1164
1164
  ...input.allowedModels ? { allowedModels: input.allowedModels } : {},
1165
- budget: { usd: create.budgetUsd, ...input.monthlyBudgetUsd !== void 0 ? { monthlyUsd: input.monthlyBudgetUsd } : {} },
1165
+ budget: {
1166
+ ...create.spendThrough ? { spendThrough: true } : { usd: create.budgetUsd },
1167
+ ...input.monthlyBudgetUsd !== void 0 ? { monthlyUsd: input.monthlyBudgetUsd } : {}
1168
+ },
1166
1169
  ...input.rpmLimit !== void 0 ? { rpmLimit: input.rpmLimit } : {},
1167
1170
  expiresAt: new Date(create.expiresAt),
1168
1171
  ...input.expect ? { expect: input.expect } : {}
1169
1172
  });
1170
1173
  if (!minted.succeeded) throw new DelegatedKeyRefusalError(minted.error);
1171
- return { id: minted.value.id, key: minted.value.key, budgetUsd: minted.value.budgetUsd, expiresAt: minted.value.expiresAt.toISOString() };
1174
+ const spendThrough = create.spendThrough && minted.value.budgetUsd === null ? { spendThrough: true } : {};
1175
+ return { id: minted.value.id, key: minted.value.key, budgetUsd: minted.value.budgetUsd, ...spendThrough, expiresAt: minted.value.expiresAt.toISOString() };
1172
1176
  },
1173
1177
  async getKey(id) {
1174
1178
  const verdict = await input.client.verify({ keyId: id, product });
@@ -1178,6 +1182,8 @@ function createDelegatedKeyProvisioner(input) {
1178
1182
  return {
1179
1183
  ...v.budgetUsd !== void 0 ? { budgetUsd: v.budgetUsd } : {},
1180
1184
  ...v.budgetUsd !== void 0 && v.budgetRemaining !== void 0 ? { budgetSpent: Math.max(0, v.budgetUsd - v.budgetRemaining) } : {},
1185
+ // No budget of its own: a spend-through child, whose remainder is its source's.
1186
+ ...v.budgetUsd === void 0 && v.budgetRemaining !== void 0 ? { budgetRemaining: v.budgetRemaining } : {},
1181
1187
  ...v.expiresAt ? { expiresAt: v.expiresAt } : {}
1182
1188
  };
1183
1189
  }