@farthershore/client 0.5.0 → 0.7.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/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,12 +149,23 @@ var PLATFORM_PERMISSION_CATALOG = {
167
149
  defaultRoles: BUILDER_ROLES,
168
150
  delegation: "maker_token"
169
151
  }),
170
- "brand:update": permission("brand:update", {
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", {
171
157
  effect: "write",
172
158
  allowedTargetKinds: BUSINESS,
173
159
  defaultRoles: OWNER_ADMIN,
174
160
  delegation: "maker_token"
175
161
  }),
162
+ // Business presentation and the organization's seller details.
163
+ "brand:update": permission("brand:update", {
164
+ effect: "write",
165
+ allowedTargetKinds: BUSINESS_OR_ORGANIZATION,
166
+ defaultRoles: OWNER_ADMIN,
167
+ delegation: "maker_token"
168
+ }),
176
169
  "bulletin:ack": permission("bulletin:ack", {
177
170
  effect: "write",
178
171
  allowedTargetKinds: BUSINESS,
@@ -191,6 +184,43 @@ var PLATFORM_PERMISSION_CATALOG = {
191
184
  defaultRoles: OWNER_ADMIN,
192
185
  delegation: "maker_token"
193
186
  }),
187
+ "account_erasure:request": permission("account_erasure:request", {
188
+ selfService: true,
189
+ effect: "write",
190
+ allowedTargetKinds: SELF,
191
+ defaultRoles: BUILDER_ROLES_AND_SUBSCRIBER,
192
+ humanOnly: true,
193
+ delegation: "browser_only"
194
+ }),
195
+ "account_erasure:read": permission("account_erasure:read", {
196
+ selfService: true,
197
+ effect: "read",
198
+ allowedTargetKinds: SELF,
199
+ defaultRoles: BUILDER_ROLES_AND_SUBSCRIBER,
200
+ delegation: "maker_token"
201
+ }),
202
+ "personal_data:export": permission("personal_data:export", {
203
+ selfService: true,
204
+ effect: "read",
205
+ allowedTargetKinds: SELF,
206
+ defaultRoles: BUILDER_ROLES_AND_SUBSCRIBER,
207
+ delegation: "maker_token"
208
+ }),
209
+ "platform_legal:read": permission("platform_legal:read", {
210
+ selfService: true,
211
+ effect: "read",
212
+ allowedTargetKinds: SELF,
213
+ defaultRoles: BUILDER_ROLES_AND_SUBSCRIBER,
214
+ delegation: "maker_token"
215
+ }),
216
+ "platform_legal:accept": permission("platform_legal:accept", {
217
+ selfService: true,
218
+ effect: "write",
219
+ allowedTargetKinds: SELF,
220
+ defaultRoles: BUILDER_ROLES_AND_SUBSCRIBER,
221
+ humanOnly: true,
222
+ delegation: "browser_only"
223
+ }),
194
224
  "business:create": permission("business:create", {
195
225
  effect: "write",
196
226
  allowedTargetKinds: ORGANIZATION,
@@ -248,12 +278,6 @@ var PLATFORM_PERMISSION_CATALOG = {
248
278
  defaultRoles: BUILDER_ROLES,
249
279
  delegation: "maker_token"
250
280
  }),
251
- "business:rollback": permission("business:rollback", {
252
- effect: "write",
253
- allowedTargetKinds: BUSINESS,
254
- defaultRoles: OWNER_ADMIN,
255
- delegation: "maker_token"
256
- }),
257
281
  "business_dependents:read": permission("business_dependents:read", {
258
282
  effect: "read",
259
283
  allowedTargetKinds: BUSINESS,
@@ -672,8 +696,8 @@ var PLATFORM_PERMISSION_CATALOG = {
672
696
  defaultRoles: OWNER_ADMIN,
673
697
  delegation: "maker_token"
674
698
  }),
675
- // Permanently closing (deleting) a Stripe Connect account — the org default
676
- // or a business override — is an irreversible, money-adjacent decision kept
699
+ // Permanently closing (deleting) the organization Stripe Connect account
700
+ // is an irreversible, money-adjacent decision kept
677
701
  // for a signed-in human owner in the dashboard: no CLI session, no MCP tool,
678
702
  // no MakerToken. A deliberate exception to CLI/MCP authz parity, declared
679
703
  // unavailable on the `stripe_connection.close` operation.
@@ -692,15 +716,7 @@ var PLATFORM_PERMISSION_CATALOG = {
692
716
  delegation: "browser_only"
693
717
  }),
694
718
  // 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
- }),
719
+ // connection status can be read by a signed-in CLI session.
704
720
  "stripe_connection:read": permission("stripe_connection:read", {
705
721
  effect: "read",
706
722
  allowedTargetKinds: ORGANIZATION,
@@ -788,6 +804,9 @@ function validatePlatformPermissionCatalog() {
788
804
  throw new Error(`Platform permission must be exact: ${permission2}`);
789
805
  }
790
806
  const metadata = PLATFORM_PERMISSION_CATALOG[permission2];
807
+ if (metadata.selfService && (metadata.allowedTargetKinds.length !== 1 || metadata.allowedTargetKinds[0] !== "self")) {
808
+ throw new Error(`Self-service permission must target only the caller: ${permission2}`);
809
+ }
791
810
  if (metadata.allowedTargetKinds.length === 0) {
792
811
  throw new Error(`Platform permission has no target kind: ${permission2}`);
793
812
  }
@@ -812,6 +831,19 @@ var REPO_AUTHORED = (declaration) => ({
812
831
  });
813
832
  var PLATFORM_OPERATION_DEFINITIONS = [
814
833
  // ── contract — managed as code; repo canonical; MCP read-only ──────────────
834
+ {
835
+ key: "account_erasure.request",
836
+ class: "operate",
837
+ domain: "account",
838
+ unavailable: {
839
+ reason: "human_decision",
840
+ detail: "Only a person can delete their account, in the dashboard settings."
841
+ }
842
+ },
843
+ { key: "account_erasure.read", class: "operate", domain: "account" },
844
+ { key: "personal_data.export", class: "operate", domain: "account" },
845
+ { key: "platform_legal.read", class: "operate", domain: "legal" },
846
+ { key: "platform_legal.accept", class: "operate", domain: "legal" },
815
847
  {
816
848
  key: "plan.create",
817
849
  class: "contract",
@@ -1103,6 +1135,17 @@ var PLATFORM_OPERATION_DEFINITIONS = [
1103
1135
  class: "operate",
1104
1136
  domain: PROMO_CODES_DOMAIN
1105
1137
  },
1138
+ {
1139
+ key: "consumer.data.erase",
1140
+ class: "operate",
1141
+ domain: "consumers",
1142
+ unavailable: {
1143
+ reason: "human_decision",
1144
+ detail: "Only a person can erase customer data, in the dashboard."
1145
+ }
1146
+ },
1147
+ { key: "consumer.data.erasure.read", class: "operate", domain: "consumers" },
1148
+ { key: "consumer.data.export", class: "operate", domain: "consumers" },
1106
1149
  { key: "consumer.read", class: "operate", domain: "consumers" },
1107
1150
  { key: "consumer.block", class: "operate", domain: "consumers" },
1108
1151
  {
@@ -1258,12 +1301,6 @@ var PLATFORM_OPERATION_DEFINITIONS = [
1258
1301
  },
1259
1302
  { key: "persona.rotate", class: "operate", domain: "personas" },
1260
1303
  { 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
1304
  { key: "analytics.timeseries", class: "operate", domain: "analytics" },
1268
1305
  { key: "analytics.latency", class: "operate", domain: "analytics" },
1269
1306
  { key: "analytics.top", class: "operate", domain: "analytics" },
@@ -1373,6 +1410,13 @@ var PLATFORM_OPERATION_DEFINITIONS = [
1373
1410
  class: "operate",
1374
1411
  domain: "organizations"
1375
1412
  },
1413
+ // One seller per organization: every business in the organization sells as
1414
+ // the organization, with the details of its one payment account.
1415
+ {
1416
+ key: "organization.seller_details.read",
1417
+ class: "operate",
1418
+ domain: "organizations"
1419
+ },
1376
1420
  {
1377
1421
  key: "organization.billing.manage",
1378
1422
  class: "operate",
@@ -1475,7 +1519,6 @@ var PLATFORM_OPERATION_DEFINITIONS = [
1475
1519
  { key: "business.routes.read", class: "contract", domain: "businesses" },
1476
1520
  { key: "business.contract.read", class: "contract", domain: "businesses" },
1477
1521
  { key: "business.publish", class: "operate", domain: "lifecycle" },
1478
- { key: "business.rollback", class: "operate", domain: "lifecycle" },
1479
1522
  {
1480
1523
  key: "manifest.apply",
1481
1524
  class: "contract",
@@ -1542,8 +1585,7 @@ var PLATFORM_OPERATION_DEFINITIONS = [
1542
1585
  domain: "authentication"
1543
1586
  })),
1544
1587
  // 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.
1588
+ // (credential administration). Reading the organization connection is read-only.
1547
1589
  {
1548
1590
  key: "stripe_connection.create",
1549
1591
  class: "operate",
@@ -1563,19 +1605,17 @@ var PLATFORM_OPERATION_DEFINITIONS = [
1563
1605
  }
1564
1606
  },
1565
1607
  // 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.
1608
+ // product decision: the dashboard owner danger zone is the only surface.
1569
1609
  {
1570
1610
  key: "stripe_connection.close",
1571
1611
  class: "operate",
1572
1612
  domain: "billing",
1573
1613
  unavailable: {
1574
1614
  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."
1615
+ detail: "Close a Stripe account from the signed-in dashboard after signing in again and typing the name. Closing is permanent."
1576
1616
  }
1577
1617
  },
1578
- ...["read", "delete"].map((action) => ({
1618
+ ...["read"].map((action) => ({
1579
1619
  key: `stripe_connection.${action}`,
1580
1620
  class: "operate",
1581
1621
  domain: "billing"
@@ -1615,6 +1655,26 @@ var MAKER_TOKEN_CREATE_ORG_PERMISSION = "maker_token:create_org";
1615
1655
  var BUSINESS_READ_PERMISSION = "business:read";
1616
1656
  var LOCAL_REPOSITORY_WRITE_PERMISSION = "local_repository:write";
1617
1657
  var AGENT_OPERATION_AUTHORIZATIONS = {
1658
+ "account_erasure.request": {
1659
+ permission: "account_erasure:request",
1660
+ targetKind: "self"
1661
+ },
1662
+ "account_erasure.read": {
1663
+ permission: "account_erasure:read",
1664
+ targetKind: "self"
1665
+ },
1666
+ "personal_data.export": {
1667
+ permission: "personal_data:export",
1668
+ targetKind: "self"
1669
+ },
1670
+ "platform_legal.read": {
1671
+ permission: "platform_legal:read",
1672
+ targetKind: "self"
1673
+ },
1674
+ "platform_legal.accept": {
1675
+ permission: "platform_legal:accept",
1676
+ targetKind: "self"
1677
+ },
1618
1678
  "auth.context.issue": {
1619
1679
  permission: "auth_context:issue",
1620
1680
  targetKind: "business"
@@ -1687,10 +1747,6 @@ var AGENT_OPERATION_AUTHORIZATIONS = {
1687
1747
  permission: "stripe_connection:create",
1688
1748
  targetKind: "organization"
1689
1749
  },
1690
- "stripe_connection.delete": {
1691
- permission: "stripe_connection:delete",
1692
- targetKind: "organization"
1693
- },
1694
1750
  "stripe_connection.read": {
1695
1751
  permission: "stripe_connection:read",
1696
1752
  targetKind: "organization"
@@ -1700,12 +1756,6 @@ var AGENT_OPERATION_AUTHORIZATIONS = {
1700
1756
  "agents.list": { permission: "agent:read", targetKind: "business" },
1701
1757
  "agents.runs.show": { permission: "agent:read", targetKind: "business" },
1702
1758
  "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
1759
  "analytics.latency": { permission: "analytics:read", targetKind: "business" },
1710
1760
  "analytics.log": { permission: "analytics:read", targetKind: "business" },
1711
1761
  "analytics.timeseries": {
@@ -1877,6 +1927,18 @@ var AGENT_OPERATION_AUTHORIZATIONS = {
1877
1927
  permission: "consumer:migrate_latest",
1878
1928
  targetKind: "business"
1879
1929
  },
1930
+ "consumer.data.erase": {
1931
+ permission: "consumer:remove",
1932
+ targetKind: "business"
1933
+ },
1934
+ "consumer.data.erasure.read": {
1935
+ permission: "consumer:read",
1936
+ targetKind: "business"
1937
+ },
1938
+ "consumer.data.export": {
1939
+ permission: "consumer:read",
1940
+ targetKind: "business"
1941
+ },
1880
1942
  "consumer.read": { permission: "consumer:read", targetKind: "business" },
1881
1943
  "consumer.remove": { permission: "consumer:remove", targetKind: "business" },
1882
1944
  "consumer.roles.assign": {
@@ -2010,6 +2072,10 @@ var AGENT_OPERATION_AUTHORIZATIONS = {
2010
2072
  permission: "organization:read",
2011
2073
  targetKind: "organization"
2012
2074
  },
2075
+ "organization.seller_details.read": {
2076
+ permission: "organization:read",
2077
+ targetKind: "organization"
2078
+ },
2013
2079
  "organization.ownership.transfer": {
2014
2080
  permission: "organization:ownership_transfer",
2015
2081
  targetKind: "organization"
@@ -2210,10 +2276,6 @@ var AGENT_OPERATION_AUTHORIZATIONS = {
2210
2276
  "brand.update": {
2211
2277
  permission: "brand:update",
2212
2278
  targetKind: "business"
2213
- },
2214
- "business.rollback": {
2215
- permission: "business:rollback",
2216
- targetKind: "business"
2217
2279
  }
2218
2280
  };
2219
2281
  var EXCLUDED_AGENT_REASONS = /* @__PURE__ */ new Set([
@@ -2336,12 +2398,65 @@ function operationAuthorizationFor(key) {
2336
2398
  return AGENT_OPERATION_AUTHORIZATIONS[key];
2337
2399
  }
2338
2400
  function isHumanOnlyOperation(key) {
2401
+ if (PLATFORM_OPERATION_DEFINITIONS.find((operation2) => operation2.key === key)?.unavailable?.reason === "human_decision")
2402
+ return true;
2339
2403
  const permission2 = operationAuthorizationFor(key)?.permission;
2340
2404
  return permission2 !== void 0 && permission2 !== LOCAL_REPOSITORY_WRITE_PERMISSION && PLATFORM_PERMISSION_CATALOG[permission2].humanOnly === true;
2341
2405
  }
2342
2406
 
2343
2407
  // ../contracts/dist/operation-spec.js
2344
2408
  var SPECS = {
2409
+ "account_erasure.request": {
2410
+ summary: "Delete your account",
2411
+ description: "Request account erasure in the dashboard after typing your account email. Transfer or delete shared organizations and published businesses, and settle money first.",
2412
+ destructive: true,
2413
+ oneTimeSecret: false,
2414
+ preview: false,
2415
+ reconcile: { op: "account_erasure.read" }
2416
+ },
2417
+ "account_erasure.read": {
2418
+ summary: "Read your account deletion status",
2419
+ description: "Read progress or refusal for your own account deletion request.",
2420
+ destructive: false,
2421
+ oneTimeSecret: false,
2422
+ preview: false
2423
+ },
2424
+ "consumer.data.erase": {
2425
+ summary: "Erase customer data",
2426
+ description: "Erase one customer relationship after settlement and dashboard confirmation. Retain financial, usage, legal and audit evidence.",
2427
+ destructive: true,
2428
+ oneTimeSecret: false,
2429
+ preview: false,
2430
+ reconcile: { op: "consumer.data.erasure.read" }
2431
+ },
2432
+ "consumer.data.erasure.read": {
2433
+ summary: "Read customer erasure status",
2434
+ description: "Read the progress or refusal of customer data erasure for one business.",
2435
+ destructive: false,
2436
+ oneTimeSecret: false,
2437
+ preview: false
2438
+ },
2439
+ "consumer.data.export": {
2440
+ summary: "Export a customer's data",
2441
+ description: "Export one customer's data for one business as JSON.",
2442
+ destructive: false,
2443
+ oneTimeSecret: false,
2444
+ preview: false
2445
+ },
2446
+ "personal_data.export": {
2447
+ summary: "Export your personal data",
2448
+ description: "Download your own account data as JSON. Organization credentials cannot export personal data.",
2449
+ destructive: false,
2450
+ oneTimeSecret: false,
2451
+ preview: false
2452
+ },
2453
+ "platform_legal.read": {
2454
+ summary: "Read required legal document acceptance",
2455
+ description: "Read which current platform legal documents the signed-in person has accepted and the dashboard link for outstanding documents. Acceptance is a human decision in the dashboard.",
2456
+ destructive: false,
2457
+ oneTimeSecret: false,
2458
+ preview: false
2459
+ },
2345
2460
  "business.list": {
2346
2461
  summary: "List businesses in the current org",
2347
2462
  description: "List every business in the authenticated FartherShore workspace (id, name, status). Read-only; use this to discover business ids for the other tools.",
@@ -2440,7 +2555,7 @@ var SPECS = {
2440
2555
  preview: false,
2441
2556
  reconcile: { op: "business.read" }
2442
2557
  },
2443
- // DECISION: Stays NOT destructive: a publish is reversible with `business.rollback`, and the CLI keeps its own y/N prompt.
2558
+ // Publish keeps its explicit preview and the CLI confirmation prompt.
2444
2559
  "business.publish": {
2445
2560
  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
2561
  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 +2564,6 @@ var SPECS = {
2449
2564
  preview: true,
2450
2565
  reconcile: { op: "business.status" }
2451
2566
  },
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
2567
  "business.delete": {
2462
2568
  summary: "Permanently delete a business (stage only)",
2463
2569
  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 +2960,8 @@ var SPECS = {
2854
2960
  reconcile: { op: "promo_code.read" }
2855
2961
  },
2856
2962
  "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.",
2963
+ summary: "List a business's consumers, or read one consumer's API keys, balances or Managed-RBAC roles",
2964
+ 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
2965
  destructive: false,
2860
2966
  oneTimeSecret: false,
2861
2967
  preview: false
@@ -2985,30 +3091,6 @@ var SPECS = {
2985
3091
  oneTimeSecret: false,
2986
3092
  preview: false
2987
3093
  },
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
3094
  "usage.read": {
3013
3095
  summary: "Show usage summary for the last 30 days",
3014
3096
  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.",
@@ -3238,6 +3320,13 @@ var SPECS = {
3238
3320
  preview: false,
3239
3321
  pagination: "cursor"
3240
3322
  },
3323
+ "organization.seller_details.read": {
3324
+ summary: "Read the organization's seller details",
3325
+ description: "Read the public seller details every business in the organization shows customers on its site, at checkout, on receipts and in emails. They come from the organization's payment account (legal name, support email, postal address, support URL); a business cannot go live until the account has them.",
3326
+ destructive: false,
3327
+ oneTimeSecret: false,
3328
+ preview: false
3329
+ },
3241
3330
  "org_maker_token.permission_catalog.read": {
3242
3331
  summary: "List the exact permissions a human may delegate to an org MakerToken",
3243
3332
  description: "List the exact permissions a human may delegate to an org MakerToken",
@@ -3313,20 +3402,12 @@ var SPECS = {
3313
3402
  reconcile: { op: "org_maker_token.list" }
3314
3403
  },
3315
3404
  "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.",
3405
+ summary: "Show the organization Stripe connection a business bills through",
3406
+ 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
3407
  destructive: false,
3319
3408
  oneTimeSecret: false,
3320
3409
  preview: false
3321
3410
  },
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
3411
  "audit_log.read": {
3331
3412
  summary: "List organization or business-scoped audit-log rows",
3332
3413
  description: "List organization or business-scoped audit-log rows",
@@ -3655,6 +3736,9 @@ function operationSpecFor(key) {
3655
3736
  return Object.hasOwn(OPERATION_SPECS, key) ? OPERATION_SPECS[key] : void 0;
3656
3737
  }
3657
3738
  var ROOT_NAMESPACES = {
3739
+ account_erasure: ["account", "erasure"],
3740
+ personal_data: ["personalData"],
3741
+ platform_legal: ["platform", "legal"],
3658
3742
  analytics: ["analytics"],
3659
3743
  apply_timeline: ["changeSets", "timeline"],
3660
3744
  auth: ["auth"],
@@ -3749,6 +3833,17 @@ var STREAMING_EXEMPT_CONTENT_TYPE_SET = new Set(STREAMING_EXEMPT_CONTENT_TYPES);
3749
3833
 
3750
3834
  // ../contracts/dist/error-codes.js
3751
3835
  var ERROR_CODES = {
3836
+ CUSTOMER_ERASURE_UNSETTLED_MONEY: "CUSTOMER_ERASURE_UNSETTLED_MONEY",
3837
+ CUSTOMER_ERASURE_ORGANIZATION_AUTHORITY: "CUSTOMER_ERASURE_ORGANIZATION_AUTHORITY",
3838
+ CUSTOMER_ERASURE_CONFIRMATION_MISMATCH: "CUSTOMER_ERASURE_CONFIRMATION_MISMATCH",
3839
+ ACCOUNT_ERASURE_SHARED_ORGANIZATION: "ACCOUNT_ERASURE_SHARED_ORGANIZATION",
3840
+ ACCOUNT_ERASURE_PUBLISHED_BUSINESS: "ACCOUNT_ERASURE_PUBLISHED_BUSINESS",
3841
+ ACCOUNT_ERASURE_UNSETTLED_MONEY: "ACCOUNT_ERASURE_UNSETTLED_MONEY",
3842
+ ACCOUNT_ERASURE_CONFIRMATION_MISMATCH: "ACCOUNT_ERASURE_CONFIRMATION_MISMATCH",
3843
+ SELLER_LAUNCH_REQUIREMENTS_MISSING: "SELLER_LAUNCH_REQUIREMENTS_MISSING",
3844
+ LEGAL_ACCEPTANCE_REQUIRED: "LEGAL_ACCEPTANCE_REQUIRED",
3845
+ MAINTENANCE_JOB_RETIRED: "MAINTENANCE_JOB_RETIRED",
3846
+ INVALID_USAGE_UNIT_LABEL: "INVALID_USAGE_UNIT_LABEL",
3752
3847
  HUMAN_ONLY_ACTION: "HUMAN_ONLY_ACTION",
3753
3848
  // --- Generic / cross-cutting ---------------------------------------
3754
3849
  VALIDATION_ERROR: "VALIDATION_ERROR",
@@ -3772,6 +3867,9 @@ var ERROR_CODES = {
3772
3867
  DRY_RUN_NOT_SUPPORTED: "DRY_RUN_NOT_SUPPORTED",
3773
3868
  // --- Auth ---------------------------------------------------------
3774
3869
  UNAUTHORIZED: "UNAUTHORIZED",
3870
+ /** An internal service JWT whose jti was already used. The token is spent,
3871
+ * not invalid: the caller may retry once with a freshly minted token. */
3872
+ SERVICE_JWT_REPLAYED: "SERVICE_JWT_REPLAYED",
3775
3873
  FORBIDDEN: "FORBIDDEN",
3776
3874
  INVALID_ACCESS_KEY: "INVALID_ACCESS_KEY",
3777
3875
  AUTO_KEY_CREATION_FAILED: "AUTO_KEY_CREATION_FAILED",
@@ -3842,18 +3940,11 @@ var ERROR_CODES = {
3842
3940
  // --- Managed RBAC (Lane E, FAR-698) --------------------------------
3843
3941
  // Org-facing RBAC management APIs (/portal/.../me/rbac/*). All three
3844
3942
  // 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
3943
  // - RBAC_NOT_ENABLED_BY_PRODUCT (400): the accepted spec's
3848
3944
  // `product.rbac` is absent/false — the product never compiled the
3849
3945
  // `permission` constraint, so org role config would be inert.
3850
3946
  // UNKNOWN_PERMISSION (400) rejects role permissions outside the derived
3851
3947
  // 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
3948
  RBAC_NOT_ENABLED_BY_PRODUCT: "RBAC_NOT_ENABLED_BY_PRODUCT",
3858
3949
  UNKNOWN_PERMISSION: "UNKNOWN_PERMISSION",
3859
3950
  // FAR-852 — a custom permission subject write collides with a reserved
@@ -3913,6 +4004,9 @@ var ERROR_CODES = {
3913
4004
  // --- Subscriptions / billing --------------------------------------
3914
4005
  BILLING_EVENT_NOT_FOUND: "BILLING_EVENT_NOT_FOUND",
3915
4006
  BILLING_NOT_CONFIGURED: "BILLING_NOT_CONFIGURED",
4007
+ // Their last period's invoice is unpaid after every retry, so this customer
4008
+ // cannot subscribe to this business again until it is paid.
4009
+ UNPAID_USAGE_INVOICE: "UNPAID_USAGE_INVOICE",
3916
4010
  SUBSCRIPTION_NOT_READY: "SUBSCRIPTION_NOT_READY",
3917
4011
  SUBSCRIPTION_FETCH_FAILED: "SUBSCRIPTION_FETCH_FAILED",
3918
4012
  // There is no paid, Stripe-managed subscription to end: the subscription is
@@ -4293,75 +4387,6 @@ var agentOperations = {
4293
4387
  "bulletin.resolve": setStatus("bulletin.resolve", "resolved")
4294
4388
  };
4295
4389
 
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
4390
  // src/operations/analytics.ts
4366
4391
  var runQuery = (ctx, businessId, body) => send(
4367
4392
  ctx,
@@ -4472,15 +4497,27 @@ var auditNotificationOperations = {
4472
4497
 
4473
4498
  // src/operations/auth.ts
4474
4499
  var authOperations = {
4500
+ "account.erasure.read": operation({
4501
+ op: "account_erasure.read",
4502
+ run: (ctx) => send(ctx, "GET", "/agent/v1/account-erasure")
4503
+ }),
4504
+ "personalData.export": operation({
4505
+ op: "personal_data.export",
4506
+ run: (ctx) => send(ctx, "GET", "/agent/v1/personal-data/export")
4507
+ }),
4508
+ "platform.legal.read": operation({
4509
+ op: "platform_legal.read",
4510
+ run: (ctx) => send(
4511
+ ctx,
4512
+ "GET",
4513
+ "/agent/v1/platform-legal"
4514
+ )
4515
+ }),
4475
4516
  "auth.context.read": operation({
4476
4517
  op: "auth.context.read",
4477
4518
  async run(ctx) {
4478
4519
  if (ctx.transport.credentialKind === "cli_exchange") {
4479
- const who2 = await send(
4480
- ctx,
4481
- "GET",
4482
- "/management/whoami"
4483
- );
4520
+ const who2 = await send(ctx, "GET", "/agent/v1/whoami");
4484
4521
  return who2.credentialType === "cli_session" ? { kind: "cli_user", ...who2 } : { kind: "maker", ...who2 };
4485
4522
  }
4486
4523
  const who = await send(
@@ -4499,7 +4536,7 @@ var authOperations = {
4499
4536
  const res = await send(
4500
4537
  ctx,
4501
4538
  "POST",
4502
- `/management/businesses/${seg(businessId)}/auth/context-token`,
4539
+ `/agent/v1/businesses/${seg(businessId)}/auth/context-token`,
4503
4540
  { ...data, actorType: "user" }
4504
4541
  );
4505
4542
  return res.data;
@@ -4594,7 +4631,7 @@ var billingOperations = {
4594
4631
  run: (ctx, { businessId }) => send(
4595
4632
  ctx,
4596
4633
  "GET",
4597
- `/management/businesses/${seg(businessId)}/tax-settings`
4634
+ `/agent/v1/businesses/${seg(businessId)}/tax-settings`
4598
4635
  )
4599
4636
  }),
4600
4637
  "billing.taxSettings.update": operation({
@@ -4602,7 +4639,7 @@ var billingOperations = {
4602
4639
  run: (ctx, { businessId, body }) => send(
4603
4640
  ctx,
4604
4641
  "POST",
4605
- `/management/businesses/${seg(businessId)}/tax-settings`,
4642
+ `/agent/v1/businesses/${seg(businessId)}/tax-settings`,
4606
4643
  body
4607
4644
  )
4608
4645
  })
@@ -4672,7 +4709,7 @@ var businessOperations = {
4672
4709
  run: (ctx, { subdomain }) => send(
4673
4710
  ctx,
4674
4711
  "GET",
4675
- withQuery("/management/businesses/subdomain-availability", {
4712
+ withQuery("/agent/v1/businesses/subdomain-availability", {
4676
4713
  subdomain
4677
4714
  })
4678
4715
  )
@@ -4696,15 +4733,6 @@ var businessOperations = {
4696
4733
  Object.keys(body).length > 0 ? body : void 0
4697
4734
  )
4698
4735
  }),
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
4736
  // A retry may append another diagnostic compilation record; it never
4709
4737
  // applies or publishes the contract.
4710
4738
  "businesses.compile": operation({
@@ -4861,6 +4889,16 @@ var setRbac = (op, enabled) => operation({
4861
4889
  })
4862
4890
  });
4863
4891
  var consumerOperations = {
4892
+ "consumers.data.export": operation({
4893
+ op: "consumer.data.export",
4894
+ run: (ctx, { businessId, subscriberId }) => send(ctx, "GET", `${consumer(businessId, subscriberId)}/data-export`)
4895
+ }),
4896
+ // Status of a customer's erasure request for this business, or null when
4897
+ // none exists. Starting an erasure is done by a person in the dashboard.
4898
+ "consumers.data.erasure.read": operation({
4899
+ op: "consumer.data.erasure.read",
4900
+ run: (ctx, { businessId, subscriberId }) => send(ctx, "GET", `${consumer(businessId, subscriberId)}/data-erasure`)
4901
+ }),
4864
4902
  "consumers.read": operation({
4865
4903
  op: "consumer.read",
4866
4904
  run: (ctx, { businessId, env }) => send(
@@ -4927,6 +4965,13 @@ var consumerOperations = {
4927
4965
  summary: "List one subscriber's API keys (metadata only)",
4928
4966
  run: (ctx, { businessId, subscriberId }) => send(ctx, "GET", `${consumer(businessId, subscriberId)}/api-keys`)
4929
4967
  }),
4968
+ // Exact amounts, whatever the plan's subscriber-facing disclosure. Each
4969
+ // balance says whether it was read live or is an estimate.
4970
+ "consumers.balance.read": operation({
4971
+ op: "consumer.read",
4972
+ summary: "Read one subscriber's usage-unit balances",
4973
+ run: (ctx, { businessId, subscriberId }) => send(ctx, "GET", `${consumer(businessId, subscriberId)}/balance`)
4974
+ }),
4930
4975
  "consumers.apiKeys.revoke": operation({
4931
4976
  op: "consumer.block",
4932
4977
  summary: "Revoke one subscriber API key",
@@ -5068,6 +5113,10 @@ var organizationOperations = {
5068
5113
  })
5069
5114
  )
5070
5115
  }),
5116
+ "organizations.sellerDetails.read": operation({
5117
+ op: "organization.seller_details.read",
5118
+ run: (ctx, { organizationId }) => send(ctx, "GET", `${org(organizationId)}/seller-details`)
5119
+ }),
5071
5120
  "organizations.role.list": operation({
5072
5121
  op: "organization.role.list",
5073
5122
  run: (ctx, { organizationId, query }) => send(
@@ -5204,7 +5253,7 @@ var personaOperations = {
5204
5253
  };
5205
5254
 
5206
5255
  // src/operations/plans-usage.ts
5207
- var management = (businessId) => `/management/businesses/${seg(businessId)}`;
5256
+ var management = (businessId) => `/agent/v1/businesses/${seg(businessId)}`;
5208
5257
  var plansUsageOperations = {
5209
5258
  "plans.read": operation({
5210
5259
  op: "plan.read",
@@ -5246,7 +5295,7 @@ var plansUsageOperations = {
5246
5295
  };
5247
5296
 
5248
5297
  // src/operations/platform.ts
5249
- var management2 = (businessId) => `/management/businesses/${seg(businessId)}`;
5298
+ var management2 = (businessId) => `/agent/v1/businesses/${seg(businessId)}`;
5250
5299
  var rules = (businessId) => `/businesses/${seg(businessId)}/automation-rules`;
5251
5300
  var platformOperations = {
5252
5301
  "platform.resourceCounts.report": operation({
@@ -5435,6 +5484,14 @@ var portalOperations = {
5435
5484
  {}
5436
5485
  )
5437
5486
  }),
5487
+ "portal.balance.read": operation({
5488
+ op: null,
5489
+ // Amounts on a plan that discloses pricing; only the share of each
5490
+ // allowance used and left on an opaque plan.
5491
+ summary: "Read the signed-in subscriber's usage-unit balances",
5492
+ sideEffect: "read",
5493
+ run: (ctx, { businessId }) => portal(ctx, "GET", `${me(businessId)}/balance`)
5494
+ }),
5438
5495
  "portal.usageLimits.list": operation({
5439
5496
  op: null,
5440
5497
  pagination: "offset",
@@ -5565,7 +5622,7 @@ var variableOperations = {
5565
5622
  };
5566
5623
 
5567
5624
  // src/operations/webhooks.ts
5568
- var webhooks = (businessId) => `/management/businesses/${seg(businessId)}/webhooks`;
5625
+ var webhooks = (businessId) => `/agent/v1/businesses/${seg(businessId)}/webhooks`;
5569
5626
  var webhook = (businessId, webhookId) => `${webhooks(businessId)}/${seg(webhookId)}`;
5570
5627
  var sendTest = operation({
5571
5628
  op: "webhook.test",
@@ -5631,7 +5688,7 @@ var webhookOperations = {
5631
5688
  run: (ctx, { businessId }) => send(
5632
5689
  ctx,
5633
5690
  "GET",
5634
- `/management/businesses/${seg(businessId)}/webhook-event-types`
5691
+ `/agent/v1/businesses/${seg(businessId)}/webhook-event-types`
5635
5692
  )
5636
5693
  }),
5637
5694
  "webhooks.delivery.read": operation({
@@ -5668,7 +5725,6 @@ var webhookOperations = {
5668
5725
  // src/operations/index.ts
5669
5726
  var OPERATION_TABLE = {
5670
5727
  ...agentOperations,
5671
- ...agreementOperations,
5672
5728
  ...analyticsOperations,
5673
5729
  ...auditNotificationOperations,
5674
5730
  ...authOperations,
@@ -6132,8 +6188,7 @@ async function poll(options) {
6132
6188
  }
6133
6189
 
6134
6190
  // src/helpers/wait-for-frontend-build.ts
6135
- var FAILURE = /* @__PURE__ */ new Set(["FAILED", "CANCELLED"]);
6136
- var SUPERSEDED = "SUPERSEDED";
6191
+ var FAILURE = /* @__PURE__ */ new Set(["FAILED", "CANCELLED", "SUPERSEDED"]);
6137
6192
  async function waitForFrontendBuild(source, input) {
6138
6193
  const intervalMs = input.intervalMs ?? 5e3;
6139
6194
  const sleep = input.sleep ?? sleepFor;
@@ -6176,7 +6231,7 @@ async function waitForFrontendBuild(source, input) {
6176
6231
  }
6177
6232
  }
6178
6233
  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];
6234
+ const row = followId ? builds.find((b) => b.id === followId) : eligibleBuilds[0];
6180
6235
  if (row) {
6181
6236
  const status = row.status;
6182
6237
  const rowId = row.id;
@@ -6193,12 +6248,6 @@ async function waitForFrontendBuild(source, input) {
6193
6248
  if (followId === null) followId = rowId;
6194
6249
  if (FAILURE.has(status)) return last;
6195
6250
  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
6251
  }
6203
6252
  if (now() >= deadline) return { ...last, timedOut: true };
6204
6253
  await sleep(Math.min(intervalMs, Math.max(0, deadline - now())), signal);
@@ -6249,7 +6298,7 @@ function diagnosticsOf(parsed) {
6249
6298
  }
6250
6299
 
6251
6300
  // src/version.ts
6252
- var CLIENT_VERSION = "0.5.0";
6301
+ var CLIENT_VERSION = "0.7.0";
6253
6302
  var CLIENT_PRODUCT = `@farthershore/client/${CLIENT_VERSION}`;
6254
6303
 
6255
6304
  // src/transport.ts
@@ -6297,11 +6346,11 @@ function withDryRun(path) {
6297
6346
  function supportsReadOnlyDryRun(method, path) {
6298
6347
  const pathname = path.split("?")[0];
6299
6348
  if (method.toUpperCase() === "PATCH")
6300
- return /^\/(?:businesses|management\/businesses|agent\/v1\/businesses)\/[^/]+\/backends\/[^/]+\/?$/.test(
6349
+ return /^\/(?:businesses|agent\/v1\/businesses)\/[^/]+\/backends\/[^/]+\/?$/.test(
6301
6350
  pathname
6302
6351
  );
6303
6352
  if (method.toUpperCase() !== "POST") return false;
6304
- return /^\/(?:businesses|management\/businesses|agent\/v1\/businesses)\/[^/]+\/backends\/?$/.test(
6353
+ return /^\/(?:businesses|agent\/v1\/businesses)\/[^/]+\/backends\/?$/.test(
6305
6354
  pathname
6306
6355
  ) || /^\/businesses\/[^/]+\/publish\/?$/.test(pathname) || /^\/businesses\/[^/]+\/frontend\/rollback\/?$/.test(pathname) || /^\/businesses\/[^/]+\/consumers\/[^/]+\/change-sets\/?$/.test(pathname) || /^\/agent\/v1\/(?:replay|rollback-to-config)\/?$/.test(pathname);
6307
6356
  }
@@ -6566,7 +6615,11 @@ function createTransport(options) {
6566
6615
  const credentials = options.credentials;
6567
6616
  const doFetch = (input, init) => (options.fetch ?? globalThis.fetch)(input, init);
6568
6617
  function baseHeaders() {
6569
- return { [SURFACE_HEADER]: surface, [CLIENT_HEADER]: clientHeader };
6618
+ return {
6619
+ [SURFACE_HEADER]: surface,
6620
+ [CLIENT_HEADER]: clientHeader,
6621
+ ...options.cliVersion ? { "x-farthershore-cli-version": options.cliVersion } : {}
6622
+ };
6570
6623
  }
6571
6624
  async function fetchWithRetry(url, init, policy, consume, retryEnabled = true) {
6572
6625
  const callerSignal = init.signal ?? void 0;