@farthershore/client 0.5.0 → 0.6.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.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,15 @@
1
1
  # Changelog — @farthershore/client
2
2
 
3
+ ## [0.6.0] - 2026-11-18
4
+
5
+ - Use `/agent/v1/whoami` for credential validation; the retired `/management/whoami` endpoint is no longer supported.
6
+
7
+ ## [Unreleased]
8
+
9
+ - **Breaking:** Removed `businesses.rollback`; the retired publish workflow cannot produce a valid rollback target. Recover a Business contract through a reviewed repository fix and a new release.
10
+
11
+ - Stop frontend build waits on supersession and keep the awaited build identity fixed, including when it is missing from a status response.
12
+
3
13
  ## [0.5.0] - 2026-11-09
4
14
 
5
15
  - **Breaking:** `businesses.rollback` takes `publishId` and returns
package/README.md CHANGED
@@ -5,8 +5,8 @@ namespaced, typed operation surface (`fs.runtimeTokens.revoke(…)`) over an
5
5
  authenticated `fetch` transport with exact retry and outcome semantics,
6
6
  pluggable credential sources, and typed errors.
7
7
 
8
- > **Status: `0.5.0`.** Pre-1.0: minor releases may include breaking changes.
9
- > Every response is typed. All but the publish-rollback receipt are generated
8
+ > **Status: `0.6.0`.** Pre-1.0: minor releases may include breaking changes.
9
+ > Every response is typed. Responses are generated
10
10
  > from the platform's zod schemas (through the API's OpenAPI components), so a
11
11
  > field exists in a type exactly when the server sends it.
12
12
 
@@ -66,7 +66,6 @@ The namespace path comes from the operation key (`runtime_token.revoke` →
66
66
  | Namespace | Covers |
67
67
  | -------------------- | --------------------------------------------------------------------------------------- |
68
68
  | `fs.agents` | Operating agents: list, status, runs, enable, disable |
69
- | `fs.agreements` | Economic agreements: read, preview, create, amend, subject pins |
70
69
  | `fs.analytics` | Event analytics: `timeseries`, `latency`, `top`, `log`, `query` |
71
70
  | `fs.auditLogs` | Organization and business audit logs, CSV export |
72
71
  | `fs.auth` | `context.read` (who am I), `context.issue`, `listOrganizations`, `selectedOrganization` |
@@ -74,7 +73,7 @@ The namespace path comes from the operation key (`runtime_token.revoke` →
74
73
  | `fs.backends` | Backends: read, create, bind, delete |
75
74
  | `fs.billing` | `stripe` (status, disconnect) and `taxSettings` |
76
75
  | `fs.bulletin` | Business bulletin: list, read, ack, resolve |
77
- | `fs.businesses` | Businesses, publish/rollback/status, `brand`, `docs`, `previewEnv`, `cors`, `rbac`, … |
76
+ | `fs.businesses` | Businesses, publish/status, `brand`, `docs`, `previewEnv`, `cors`, `rbac`, … |
78
77
  | `fs.changeSets` | Governed ChangeSet proposals and the apply `timeline` |
79
78
  | `fs.consumers` | Subscribers: read, block, remove, migrate, roles, RBAC, API keys |
80
79
  | `fs.environments` | Preview environments: read, create, delete |
@@ -164,6 +163,11 @@ const build = await waitForFrontendBuild(fs, {
164
163
  });
165
164
  ```
166
165
 
166
+ The wait keeps the selected build's identity fixed. `FAILED`, `CANCELLED`, and
167
+ `SUPERSEDED` return immediately with `timedOut: false`; inspect `status` and
168
+ `error` before treating the result as success. A successful build is ready only
169
+ once that exact build is active.
170
+
167
171
  `paginate` fails with `PAGINATION_NOT_ADVANCING` rather than looping when a
168
172
  page does not advance. A starting `offset` or `limit` may be a number or a
169
173
  numeric string (`"50"`); anything else fails with `INVALID_PAGE_PARAMETER`
package/dist/index.js CHANGED
@@ -65,24 +65,6 @@ var PLATFORM_PERMISSION_CATALOG = {
65
65
  defaultRoles: BUILDER_ROLES,
66
66
  delegation: "maker_token"
67
67
  }),
68
- "agreement:amend": permission("agreement:amend", {
69
- effect: "write",
70
- allowedTargetKinds: BUSINESS,
71
- defaultRoles: OWNER_ADMIN,
72
- delegation: "maker_token"
73
- }),
74
- "agreement:create": permission("agreement:create", {
75
- effect: "write",
76
- allowedTargetKinds: BUSINESS,
77
- defaultRoles: OWNER_ADMIN,
78
- delegation: "maker_token"
79
- }),
80
- "agreement:read": permission("agreement:read", {
81
- effect: "read",
82
- allowedTargetKinds: BUSINESS,
83
- defaultRoles: BUILDER_ROLES,
84
- delegation: "maker_token"
85
- }),
86
68
  "analytics:read": permission("analytics:read", {
87
69
  effect: "read",
88
70
  allowedTargetKinds: BUSINESS,
@@ -167,6 +149,16 @@ var PLATFORM_PERMISSION_CATALOG = {
167
149
  defaultRoles: BUILDER_ROLES,
168
150
  delegation: "maker_token"
169
151
  }),
152
+ // CI spec upload (FAR-1490): the one authority a CI maker token needs to
153
+ // push a business's backend spec. Business-targeted, so a token holding it
154
+ // is also limited to the businesses it selects; it carries no plan, price,
155
+ // customer or secret authority.
156
+ "backend_spec:write": permission("backend_spec:write", {
157
+ effect: "write",
158
+ allowedTargetKinds: BUSINESS,
159
+ defaultRoles: OWNER_ADMIN,
160
+ delegation: "maker_token"
161
+ }),
170
162
  "brand:update": permission("brand:update", {
171
163
  effect: "write",
172
164
  allowedTargetKinds: BUSINESS,
@@ -248,12 +240,6 @@ var PLATFORM_PERMISSION_CATALOG = {
248
240
  defaultRoles: BUILDER_ROLES,
249
241
  delegation: "maker_token"
250
242
  }),
251
- "business:rollback": permission("business:rollback", {
252
- effect: "write",
253
- allowedTargetKinds: BUSINESS,
254
- defaultRoles: OWNER_ADMIN,
255
- delegation: "maker_token"
256
- }),
257
243
  "business_dependents:read": permission("business_dependents:read", {
258
244
  effect: "read",
259
245
  allowedTargetKinds: BUSINESS,
@@ -672,8 +658,8 @@ var PLATFORM_PERMISSION_CATALOG = {
672
658
  defaultRoles: OWNER_ADMIN,
673
659
  delegation: "maker_token"
674
660
  }),
675
- // Permanently closing (deleting) a Stripe Connect account — the org default
676
- // or a business override — is an irreversible, money-adjacent decision kept
661
+ // Permanently closing (deleting) the organization Stripe Connect account
662
+ // is an irreversible, money-adjacent decision kept
677
663
  // for a signed-in human owner in the dashboard: no CLI session, no MCP tool,
678
664
  // no MakerToken. A deliberate exception to CLI/MCP authz parity, declared
679
665
  // unavailable on the `stripe_connection.close` operation.
@@ -692,15 +678,7 @@ var PLATFORM_PERMISSION_CATALOG = {
692
678
  delegation: "browser_only"
693
679
  }),
694
680
  // Connecting Stripe is a browser-only OAuth/onboarding handshake, but reading
695
- // Connection status can be read by a signed-in CLI session. Disconnecting
696
- // requires a freshly verified person in the dashboard.
697
- "stripe_connection:delete": permission("stripe_connection:delete", {
698
- effect: "write",
699
- allowedTargetKinds: ORGANIZATION,
700
- defaultRoles: OWNER_ONLY,
701
- humanOnly: true,
702
- delegation: "browser_only"
703
- }),
681
+ // connection status can be read by a signed-in CLI session.
704
682
  "stripe_connection:read": permission("stripe_connection:read", {
705
683
  effect: "read",
706
684
  allowedTargetKinds: ORGANIZATION,
@@ -1258,12 +1236,6 @@ var PLATFORM_OPERATION_DEFINITIONS = [
1258
1236
  },
1259
1237
  { key: "persona.rotate", class: "operate", domain: "personas" },
1260
1238
  { key: "persona.delete", class: "operate", domain: "personas" },
1261
- // FAR-910 — economic agreements are confirm-gated Core API/CLI operations,
1262
- // never repo-authored (plan §2): OPERATE. Amendments append versions; the
1263
- // agreement row itself is immutable.
1264
- { key: "agreement.read", class: "operate", domain: "agreements" },
1265
- { key: "agreement.create", class: "operate", domain: "agreements" },
1266
- { key: "agreement.amend", class: "operate", domain: "agreements" },
1267
1239
  { key: "analytics.timeseries", class: "operate", domain: "analytics" },
1268
1240
  { key: "analytics.latency", class: "operate", domain: "analytics" },
1269
1241
  { key: "analytics.top", class: "operate", domain: "analytics" },
@@ -1475,7 +1447,6 @@ var PLATFORM_OPERATION_DEFINITIONS = [
1475
1447
  { key: "business.routes.read", class: "contract", domain: "businesses" },
1476
1448
  { key: "business.contract.read", class: "contract", domain: "businesses" },
1477
1449
  { key: "business.publish", class: "operate", domain: "lifecycle" },
1478
- { key: "business.rollback", class: "operate", domain: "lifecycle" },
1479
1450
  {
1480
1451
  key: "manifest.apply",
1481
1452
  class: "contract",
@@ -1542,8 +1513,7 @@ var PLATFORM_OPERATION_DEFINITIONS = [
1542
1513
  domain: "authentication"
1543
1514
  })),
1544
1515
  // Connecting Stripe is a browser-only OAuth/onboarding handshake with Stripe
1545
- // (credential administration). Reading the connection and disconnecting a
1546
- // per-business override have distinct read and human-only permissions.
1516
+ // (credential administration). Reading the organization connection is read-only.
1547
1517
  {
1548
1518
  key: "stripe_connection.create",
1549
1519
  class: "operate",
@@ -1563,19 +1533,17 @@ var PLATFORM_OPERATION_DEFINITIONS = [
1563
1533
  }
1564
1534
  },
1565
1535
  // Closing (permanently deleting) a Stripe Connect account is browser-only by
1566
- // product decision: the dashboard owner danger zone is the only surface. The
1567
- // Disconnection (`stripe_connection.delete`) also requires a person in the
1568
- // dashboard, even though it deletes nothing at Stripe.
1536
+ // product decision: the dashboard owner danger zone is the only surface.
1569
1537
  {
1570
1538
  key: "stripe_connection.close",
1571
1539
  class: "operate",
1572
1540
  domain: "billing",
1573
1541
  unavailable: {
1574
1542
  reason: "credential_administration",
1575
- detail: "Close or disconnect a Stripe account from the signed-in dashboard after signing in again and typing the name. Closing is permanent."
1543
+ detail: "Close a Stripe account from the signed-in dashboard after signing in again and typing the name. Closing is permanent."
1576
1544
  }
1577
1545
  },
1578
- ...["read", "delete"].map((action) => ({
1546
+ ...["read"].map((action) => ({
1579
1547
  key: `stripe_connection.${action}`,
1580
1548
  class: "operate",
1581
1549
  domain: "billing"
@@ -1687,10 +1655,6 @@ var AGENT_OPERATION_AUTHORIZATIONS = {
1687
1655
  permission: "stripe_connection:create",
1688
1656
  targetKind: "organization"
1689
1657
  },
1690
- "stripe_connection.delete": {
1691
- permission: "stripe_connection:delete",
1692
- targetKind: "organization"
1693
- },
1694
1658
  "stripe_connection.read": {
1695
1659
  permission: "stripe_connection:read",
1696
1660
  targetKind: "organization"
@@ -1700,12 +1664,6 @@ var AGENT_OPERATION_AUTHORIZATIONS = {
1700
1664
  "agents.list": { permission: "agent:read", targetKind: "business" },
1701
1665
  "agents.runs.show": { permission: "agent:read", targetKind: "business" },
1702
1666
  "agents.status": { permission: "agent:read", targetKind: "business" },
1703
- "agreement.amend": { permission: "agreement:amend", targetKind: "business" },
1704
- "agreement.create": {
1705
- permission: "agreement:create",
1706
- targetKind: "business"
1707
- },
1708
- "agreement.read": { permission: "agreement:read", targetKind: "business" },
1709
1667
  "analytics.latency": { permission: "analytics:read", targetKind: "business" },
1710
1668
  "analytics.log": { permission: "analytics:read", targetKind: "business" },
1711
1669
  "analytics.timeseries": {
@@ -2210,10 +2168,6 @@ var AGENT_OPERATION_AUTHORIZATIONS = {
2210
2168
  "brand.update": {
2211
2169
  permission: "brand:update",
2212
2170
  targetKind: "business"
2213
- },
2214
- "business.rollback": {
2215
- permission: "business:rollback",
2216
- targetKind: "business"
2217
2171
  }
2218
2172
  };
2219
2173
  var EXCLUDED_AGENT_REASONS = /* @__PURE__ */ new Set([
@@ -2440,7 +2394,7 @@ var SPECS = {
2440
2394
  preview: false,
2441
2395
  reconcile: { op: "business.read" }
2442
2396
  },
2443
- // DECISION: Stays NOT destructive: a publish is reversible with `business.rollback`, and the CLI keeps its own y/N prompt.
2397
+ // Publish keeps its explicit preview and the CLI confirmation prompt.
2444
2398
  "business.publish": {
2445
2399
  summary: "Publish a draft business (make it live) and cut a versioned release with an auto-computed semver. Requires at least one plan, a bound backend, and a verified Stripe connection",
2446
2400
  description: "Publish a business \u2014 validate its current spec and queue a versioned release with an auto-computed semver. Use business status to prove it is live.",
@@ -2449,15 +2403,6 @@ var SPECS = {
2449
2403
  preview: true,
2450
2404
  reconcile: { op: "business.status" }
2451
2405
  },
2452
- // DECISION: NEITHER side → destructive. Rollbacks are destructive: they replace the live release customers are served.
2453
- "business.rollback": {
2454
- summary: "Roll back a prior business publish",
2455
- description: "Roll back a prior business publish. Pass the prior publish id as publishId; the receipt returns rollbackPublishId for the new rollback.",
2456
- destructive: true,
2457
- oneTimeSecret: false,
2458
- preview: false,
2459
- reconcile: { op: "business.status" }
2460
- },
2461
2406
  "business.delete": {
2462
2407
  summary: "Permanently delete a business (stage only)",
2463
2408
  description: "(stage only) Permanently delete a business. Requires --yes. Registered only in the stage channel (`make cli-stage`); production businesses are deleted from the dashboard.",
@@ -2854,8 +2799,8 @@ var SPECS = {
2854
2799
  reconcile: { op: "promo_code.read" }
2855
2800
  },
2856
2801
  "consumer.read": {
2857
- summary: "List a business's consumers, one consumer's API keys, or its Managed-RBAC roles",
2858
- description: "Reads a business's consumers (subscribers). The same capability lists one consumer's API keys (metadata only; key material is never returned) and one subscriber's Managed-RBAC roles.",
2802
+ summary: "List a business's consumers, or read one consumer's API keys, balances or Managed-RBAC roles",
2803
+ description: "Reads a business's consumers (subscribers). The same capability lists one consumer's API keys (metadata only; key material is never returned), reads its usage-unit balances (exact amounts, with whether each read is live or an estimate), and lists one subscriber's Managed-RBAC roles.",
2859
2804
  destructive: false,
2860
2805
  oneTimeSecret: false,
2861
2806
  preview: false
@@ -2985,30 +2930,6 @@ var SPECS = {
2985
2930
  oneTimeSecret: false,
2986
2931
  preview: false
2987
2932
  },
2988
- "agreement.read": {
2989
- summary: "List or show a business's economic agreements and their pins",
2990
- description: "Lists a business's economic agreements, shows one agreement with its terms, and shows the agreement pins that bind subscribers to a version.",
2991
- destructive: false,
2992
- oneTimeSecret: false,
2993
- preview: false,
2994
- pagination: "offset"
2995
- },
2996
- "agreement.create": {
2997
- summary: "Create an economic agreement (previews first; commits with the confirmation token)",
2998
- description: "Create an economic agreement (confirm-gated: previews first; pass --confirm <token> to commit)",
2999
- destructive: false,
3000
- oneTimeSecret: false,
3001
- preview: false,
3002
- reconcile: { op: "agreement.read" }
3003
- },
3004
- "agreement.amend": {
3005
- summary: "Amend an agreement's contract terms (append-only; previews first; commits with the confirmation token)",
3006
- description: "Amend an agreement's contract terms (append-only; confirm-gated: previews first; pass --confirm <token> to commit)",
3007
- destructive: false,
3008
- oneTimeSecret: false,
3009
- preview: false,
3010
- reconcile: { op: "agreement.read" }
3011
- },
3012
2933
  "usage.read": {
3013
2934
  summary: "Show usage summary for the last 30 days",
3014
2935
  description: "Read a business's usage summary \u2014 request counts (all time and the last 30 days), active API keys, a per-member breakdown, and served requests that can never be rated. Without environmentId this rolls up EVERY environment. Read-only.",
@@ -3313,20 +3234,12 @@ var SPECS = {
3313
3234
  reconcile: { op: "org_maker_token.list" }
3314
3235
  },
3315
3236
  "stripe_connection.read": {
3316
- summary: "Show the Stripe connection a business bills through (business override or org default)",
3317
- description: "Read whether a business bills through a connected Stripe account \u2014 a per-business override when present, otherwise the organization default \u2014 and whether that account can take charges and card payments. Read-only. Connecting Stripe is browser-only and has no tool.",
3237
+ summary: "Show the organization Stripe connection a business bills through",
3238
+ description: "Read whether a business bills through its organization connected Stripe account and whether that account can take charges and card payments. Read-only. Connecting Stripe is browser-only and has no tool.",
3318
3239
  destructive: false,
3319
3240
  oneTimeSecret: false,
3320
3241
  preview: false
3321
3242
  },
3322
- "stripe_connection.delete": {
3323
- summary: "Remove a business's per-business Stripe override so it bills through the org default again",
3324
- description: "Remove a business's per-business Stripe Connect override so it bills through the organization default again. Refused while any subscription is still money-bearing. Destructive live-state operation; it does not edit repo-authored business behavior.",
3325
- destructive: true,
3326
- oneTimeSecret: false,
3327
- preview: false,
3328
- reconcile: { op: "stripe_connection.read" }
3329
- },
3330
3243
  "audit_log.read": {
3331
3244
  summary: "List organization or business-scoped audit-log rows",
3332
3245
  description: "List organization or business-scoped audit-log rows",
@@ -3749,6 +3662,8 @@ var STREAMING_EXEMPT_CONTENT_TYPE_SET = new Set(STREAMING_EXEMPT_CONTENT_TYPES);
3749
3662
 
3750
3663
  // ../contracts/dist/error-codes.js
3751
3664
  var ERROR_CODES = {
3665
+ MAINTENANCE_JOB_RETIRED: "MAINTENANCE_JOB_RETIRED",
3666
+ INVALID_USAGE_UNIT_LABEL: "INVALID_USAGE_UNIT_LABEL",
3752
3667
  HUMAN_ONLY_ACTION: "HUMAN_ONLY_ACTION",
3753
3668
  // --- Generic / cross-cutting ---------------------------------------
3754
3669
  VALIDATION_ERROR: "VALIDATION_ERROR",
@@ -3772,6 +3687,9 @@ var ERROR_CODES = {
3772
3687
  DRY_RUN_NOT_SUPPORTED: "DRY_RUN_NOT_SUPPORTED",
3773
3688
  // --- Auth ---------------------------------------------------------
3774
3689
  UNAUTHORIZED: "UNAUTHORIZED",
3690
+ /** An internal service JWT whose jti was already used. The token is spent,
3691
+ * not invalid: the caller may retry once with a freshly minted token. */
3692
+ SERVICE_JWT_REPLAYED: "SERVICE_JWT_REPLAYED",
3775
3693
  FORBIDDEN: "FORBIDDEN",
3776
3694
  INVALID_ACCESS_KEY: "INVALID_ACCESS_KEY",
3777
3695
  AUTO_KEY_CREATION_FAILED: "AUTO_KEY_CREATION_FAILED",
@@ -3842,18 +3760,11 @@ var ERROR_CODES = {
3842
3760
  // --- Managed RBAC (Lane E, FAR-698) --------------------------------
3843
3761
  // Org-facing RBAC management APIs (/portal/.../me/rbac/*). All three
3844
3762
  // gates return before any RBAC state is read or written:
3845
- // - RBAC_REQUIRES_TEAM_ORG (400): legacy organization-type restriction;
3846
- // no longer emitted since Unified Organizations.
3847
3763
  // - RBAC_NOT_ENABLED_BY_PRODUCT (400): the accepted spec's
3848
3764
  // `product.rbac` is absent/false — the product never compiled the
3849
3765
  // `permission` constraint, so org role config would be inert.
3850
3766
  // UNKNOWN_PERMISSION (400) rejects role permissions outside the derived
3851
3767
  // catalog (`routePermission` grammar; `"*"` is always allowed).
3852
- /**
3853
- * @deprecated No longer emitted since Unified Organizations; kept one
3854
- * published release for SDK compat.
3855
- */
3856
- RBAC_REQUIRES_TEAM_ORG: "RBAC_REQUIRES_TEAM_ORG",
3857
3768
  RBAC_NOT_ENABLED_BY_PRODUCT: "RBAC_NOT_ENABLED_BY_PRODUCT",
3858
3769
  UNKNOWN_PERMISSION: "UNKNOWN_PERMISSION",
3859
3770
  // FAR-852 — a custom permission subject write collides with a reserved
@@ -3913,6 +3824,9 @@ var ERROR_CODES = {
3913
3824
  // --- Subscriptions / billing --------------------------------------
3914
3825
  BILLING_EVENT_NOT_FOUND: "BILLING_EVENT_NOT_FOUND",
3915
3826
  BILLING_NOT_CONFIGURED: "BILLING_NOT_CONFIGURED",
3827
+ // Their last period's invoice is unpaid after every retry, so this customer
3828
+ // cannot subscribe to this business again until it is paid.
3829
+ UNPAID_USAGE_INVOICE: "UNPAID_USAGE_INVOICE",
3916
3830
  SUBSCRIPTION_NOT_READY: "SUBSCRIPTION_NOT_READY",
3917
3831
  SUBSCRIPTION_FETCH_FAILED: "SUBSCRIPTION_FETCH_FAILED",
3918
3832
  // There is no paid, Stripe-managed subscription to end: the subscription is
@@ -4293,75 +4207,6 @@ var agentOperations = {
4293
4207
  "bulletin.resolve": setStatus("bulletin.resolve", "resolved")
4294
4208
  };
4295
4209
 
4296
- // src/operations/agreements.ts
4297
- var agreements = (businessId) => `/businesses/${seg(businessId)}/agreements`;
4298
- var agreementOperations = {
4299
- "agreements.read": operation({
4300
- op: "agreement.read",
4301
- run: (ctx, { businessId, subjectId, environmentId, limit, offset }) => send(
4302
- ctx,
4303
- "GET",
4304
- withQuery(agreements(businessId), {
4305
- subjectId,
4306
- environmentId,
4307
- limit: num(limit),
4308
- offset: num(offset)
4309
- })
4310
- )
4311
- }),
4312
- "agreements.get": operation({
4313
- op: "agreement.read",
4314
- summary: "Show one economic agreement",
4315
- run: (ctx, { businessId, agreementId }) => send(ctx, "GET", `${agreements(businessId)}/${seg(agreementId)}`)
4316
- }),
4317
- "agreements.pins": operation({
4318
- op: "agreement.read",
4319
- summary: "Show the price pins in force for one subject",
4320
- run: (ctx, { businessId, subjectId }) => send(
4321
- ctx,
4322
- "GET",
4323
- `/businesses/${seg(businessId)}/subjects/${seg(subjectId)}/pins`
4324
- )
4325
- }),
4326
- "agreements.previewCreate": operation({
4327
- op: "agreement.create",
4328
- summary: "Preview a new agreement's effect and get its confirmation token",
4329
- sideEffect: "read",
4330
- run: (ctx, { businessId, body }) => send(
4331
- ctx,
4332
- "POST",
4333
- `${agreements(businessId)}/preview`,
4334
- body,
4335
- readOnly(ctx)
4336
- )
4337
- }),
4338
- "agreements.create": operation({
4339
- op: "agreement.create",
4340
- run: (ctx, { businessId, body }) => send(ctx, "POST", agreements(businessId), body)
4341
- }),
4342
- "agreements.previewAmend": operation({
4343
- op: "agreement.amend",
4344
- summary: "Preview an amendment's effect and get its confirmation token",
4345
- sideEffect: "read",
4346
- run: (ctx, { businessId, agreementId, body }) => send(
4347
- ctx,
4348
- "POST",
4349
- `${agreements(businessId)}/${seg(agreementId)}/amendments/preview`,
4350
- body,
4351
- readOnly(ctx)
4352
- )
4353
- }),
4354
- "agreements.amend": operation({
4355
- op: "agreement.amend",
4356
- run: (ctx, { businessId, agreementId, body }) => send(
4357
- ctx,
4358
- "POST",
4359
- `${agreements(businessId)}/${seg(agreementId)}/amendments`,
4360
- body
4361
- )
4362
- })
4363
- };
4364
-
4365
4210
  // src/operations/analytics.ts
4366
4211
  var runQuery = (ctx, businessId, body) => send(
4367
4212
  ctx,
@@ -4476,11 +4321,7 @@ var authOperations = {
4476
4321
  op: "auth.context.read",
4477
4322
  async run(ctx) {
4478
4323
  if (ctx.transport.credentialKind === "cli_exchange") {
4479
- const who2 = await send(
4480
- ctx,
4481
- "GET",
4482
- "/management/whoami"
4483
- );
4324
+ const who2 = await send(ctx, "GET", "/agent/v1/whoami");
4484
4325
  return who2.credentialType === "cli_session" ? { kind: "cli_user", ...who2 } : { kind: "maker", ...who2 };
4485
4326
  }
4486
4327
  const who = await send(
@@ -4499,7 +4340,7 @@ var authOperations = {
4499
4340
  const res = await send(
4500
4341
  ctx,
4501
4342
  "POST",
4502
- `/management/businesses/${seg(businessId)}/auth/context-token`,
4343
+ `/agent/v1/businesses/${seg(businessId)}/auth/context-token`,
4503
4344
  { ...data, actorType: "user" }
4504
4345
  );
4505
4346
  return res.data;
@@ -4594,7 +4435,7 @@ var billingOperations = {
4594
4435
  run: (ctx, { businessId }) => send(
4595
4436
  ctx,
4596
4437
  "GET",
4597
- `/management/businesses/${seg(businessId)}/tax-settings`
4438
+ `/agent/v1/businesses/${seg(businessId)}/tax-settings`
4598
4439
  )
4599
4440
  }),
4600
4441
  "billing.taxSettings.update": operation({
@@ -4602,7 +4443,7 @@ var billingOperations = {
4602
4443
  run: (ctx, { businessId, body }) => send(
4603
4444
  ctx,
4604
4445
  "POST",
4605
- `/management/businesses/${seg(businessId)}/tax-settings`,
4446
+ `/agent/v1/businesses/${seg(businessId)}/tax-settings`,
4606
4447
  body
4607
4448
  )
4608
4449
  })
@@ -4672,7 +4513,7 @@ var businessOperations = {
4672
4513
  run: (ctx, { subdomain }) => send(
4673
4514
  ctx,
4674
4515
  "GET",
4675
- withQuery("/management/businesses/subdomain-availability", {
4516
+ withQuery("/agent/v1/businesses/subdomain-availability", {
4676
4517
  subdomain
4677
4518
  })
4678
4519
  )
@@ -4696,15 +4537,6 @@ var businessOperations = {
4696
4537
  Object.keys(body).length > 0 ? body : void 0
4697
4538
  )
4698
4539
  }),
4699
- "businesses.rollback": operation({
4700
- op: "business.rollback",
4701
- run: (ctx, { businessId, ...body }) => send(
4702
- ctx,
4703
- "POST",
4704
- `/management/businesses/${seg(businessId)}/rollback`,
4705
- body
4706
- )
4707
- }),
4708
4540
  // A retry may append another diagnostic compilation record; it never
4709
4541
  // applies or publishes the contract.
4710
4542
  "businesses.compile": operation({
@@ -4927,6 +4759,13 @@ var consumerOperations = {
4927
4759
  summary: "List one subscriber's API keys (metadata only)",
4928
4760
  run: (ctx, { businessId, subscriberId }) => send(ctx, "GET", `${consumer(businessId, subscriberId)}/api-keys`)
4929
4761
  }),
4762
+ // Exact amounts, whatever the plan's subscriber-facing disclosure. Each
4763
+ // balance says whether it was read live or is an estimate.
4764
+ "consumers.balance.read": operation({
4765
+ op: "consumer.read",
4766
+ summary: "Read one subscriber's usage-unit balances",
4767
+ run: (ctx, { businessId, subscriberId }) => send(ctx, "GET", `${consumer(businessId, subscriberId)}/balance`)
4768
+ }),
4930
4769
  "consumers.apiKeys.revoke": operation({
4931
4770
  op: "consumer.block",
4932
4771
  summary: "Revoke one subscriber API key",
@@ -5204,7 +5043,7 @@ var personaOperations = {
5204
5043
  };
5205
5044
 
5206
5045
  // src/operations/plans-usage.ts
5207
- var management = (businessId) => `/management/businesses/${seg(businessId)}`;
5046
+ var management = (businessId) => `/agent/v1/businesses/${seg(businessId)}`;
5208
5047
  var plansUsageOperations = {
5209
5048
  "plans.read": operation({
5210
5049
  op: "plan.read",
@@ -5246,7 +5085,7 @@ var plansUsageOperations = {
5246
5085
  };
5247
5086
 
5248
5087
  // src/operations/platform.ts
5249
- var management2 = (businessId) => `/management/businesses/${seg(businessId)}`;
5088
+ var management2 = (businessId) => `/agent/v1/businesses/${seg(businessId)}`;
5250
5089
  var rules = (businessId) => `/businesses/${seg(businessId)}/automation-rules`;
5251
5090
  var platformOperations = {
5252
5091
  "platform.resourceCounts.report": operation({
@@ -5435,6 +5274,14 @@ var portalOperations = {
5435
5274
  {}
5436
5275
  )
5437
5276
  }),
5277
+ "portal.balance.read": operation({
5278
+ op: null,
5279
+ // Amounts on a plan that discloses pricing; only the share of each
5280
+ // allowance used and left on an opaque plan.
5281
+ summary: "Read the signed-in subscriber's usage-unit balances",
5282
+ sideEffect: "read",
5283
+ run: (ctx, { businessId }) => portal(ctx, "GET", `${me(businessId)}/balance`)
5284
+ }),
5438
5285
  "portal.usageLimits.list": operation({
5439
5286
  op: null,
5440
5287
  pagination: "offset",
@@ -5565,7 +5412,7 @@ var variableOperations = {
5565
5412
  };
5566
5413
 
5567
5414
  // src/operations/webhooks.ts
5568
- var webhooks = (businessId) => `/management/businesses/${seg(businessId)}/webhooks`;
5415
+ var webhooks = (businessId) => `/agent/v1/businesses/${seg(businessId)}/webhooks`;
5569
5416
  var webhook = (businessId, webhookId) => `${webhooks(businessId)}/${seg(webhookId)}`;
5570
5417
  var sendTest = operation({
5571
5418
  op: "webhook.test",
@@ -5631,7 +5478,7 @@ var webhookOperations = {
5631
5478
  run: (ctx, { businessId }) => send(
5632
5479
  ctx,
5633
5480
  "GET",
5634
- `/management/businesses/${seg(businessId)}/webhook-event-types`
5481
+ `/agent/v1/businesses/${seg(businessId)}/webhook-event-types`
5635
5482
  )
5636
5483
  }),
5637
5484
  "webhooks.delivery.read": operation({
@@ -5668,7 +5515,6 @@ var webhookOperations = {
5668
5515
  // src/operations/index.ts
5669
5516
  var OPERATION_TABLE = {
5670
5517
  ...agentOperations,
5671
- ...agreementOperations,
5672
5518
  ...analyticsOperations,
5673
5519
  ...auditNotificationOperations,
5674
5520
  ...authOperations,
@@ -6132,8 +5978,7 @@ async function poll(options) {
6132
5978
  }
6133
5979
 
6134
5980
  // src/helpers/wait-for-frontend-build.ts
6135
- var FAILURE = /* @__PURE__ */ new Set(["FAILED", "CANCELLED"]);
6136
- var SUPERSEDED = "SUPERSEDED";
5981
+ var FAILURE = /* @__PURE__ */ new Set(["FAILED", "CANCELLED", "SUPERSEDED"]);
6137
5982
  async function waitForFrontendBuild(source, input) {
6138
5983
  const intervalMs = input.intervalMs ?? 5e3;
6139
5984
  const sleep = input.sleep ?? sleepFor;
@@ -6176,7 +6021,7 @@ async function waitForFrontendBuild(source, input) {
6176
6021
  }
6177
6022
  }
6178
6023
  const eligibleBuilds = input.buildId == null && input.ref === void 0 ? builds.filter((build) => !unpinnedBaselineIds.has(build.id)) : builds;
6179
- const row = (followId ? builds.find((b) => b.id === followId) : void 0) ?? eligibleBuilds[0];
6024
+ const row = followId ? builds.find((b) => b.id === followId) : eligibleBuilds[0];
6180
6025
  if (row) {
6181
6026
  const status = row.status;
6182
6027
  const rowId = row.id;
@@ -6193,12 +6038,6 @@ async function waitForFrontendBuild(source, input) {
6193
6038
  if (followId === null) followId = rowId;
6194
6039
  if (FAILURE.has(status)) return last;
6195
6040
  if (status === "SUCCEEDED" && last.activated) return last;
6196
- if (status === SUPERSEDED) {
6197
- const successor = eligibleBuilds.find(
6198
- (b) => b.ref === row.ref && b.id !== row.id
6199
- );
6200
- followId = successor ? successor.id : null;
6201
- }
6202
6041
  }
6203
6042
  if (now() >= deadline) return { ...last, timedOut: true };
6204
6043
  await sleep(Math.min(intervalMs, Math.max(0, deadline - now())), signal);
@@ -6249,7 +6088,7 @@ function diagnosticsOf(parsed) {
6249
6088
  }
6250
6089
 
6251
6090
  // src/version.ts
6252
- var CLIENT_VERSION = "0.5.0";
6091
+ var CLIENT_VERSION = "0.6.0";
6253
6092
  var CLIENT_PRODUCT = `@farthershore/client/${CLIENT_VERSION}`;
6254
6093
 
6255
6094
  // src/transport.ts
@@ -6297,11 +6136,11 @@ function withDryRun(path) {
6297
6136
  function supportsReadOnlyDryRun(method, path) {
6298
6137
  const pathname = path.split("?")[0];
6299
6138
  if (method.toUpperCase() === "PATCH")
6300
- return /^\/(?:businesses|management\/businesses|agent\/v1\/businesses)\/[^/]+\/backends\/[^/]+\/?$/.test(
6139
+ return /^\/(?:businesses|agent\/v1\/businesses)\/[^/]+\/backends\/[^/]+\/?$/.test(
6301
6140
  pathname
6302
6141
  );
6303
6142
  if (method.toUpperCase() !== "POST") return false;
6304
- return /^\/(?:businesses|management\/businesses|agent\/v1\/businesses)\/[^/]+\/backends\/?$/.test(
6143
+ return /^\/(?:businesses|agent\/v1\/businesses)\/[^/]+\/backends\/?$/.test(
6305
6144
  pathname
6306
6145
  ) || /^\/businesses\/[^/]+\/publish\/?$/.test(pathname) || /^\/businesses\/[^/]+\/frontend\/rollback\/?$/.test(pathname) || /^\/businesses\/[^/]+\/consumers\/[^/]+\/change-sets\/?$/.test(pathname) || /^\/agent\/v1\/(?:replay|rollback-to-config)\/?$/.test(pathname);
6307
6146
  }
@@ -6566,7 +6405,11 @@ function createTransport(options) {
6566
6405
  const credentials = options.credentials;
6567
6406
  const doFetch = (input, init) => (options.fetch ?? globalThis.fetch)(input, init);
6568
6407
  function baseHeaders() {
6569
- return { [SURFACE_HEADER]: surface, [CLIENT_HEADER]: clientHeader };
6408
+ return {
6409
+ [SURFACE_HEADER]: surface,
6410
+ [CLIENT_HEADER]: clientHeader,
6411
+ ...options.cliVersion ? { "x-farthershore-cli-version": options.cliVersion } : {}
6412
+ };
6570
6413
  }
6571
6414
  async function fetchWithRetry(url, init, policy, consume, retryEnabled = true) {
6572
6415
  const callerSignal = init.signal ?? void 0;