@beacon-build/sdk 2.18.0 → 3.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (48) hide show
  1. package/CHANGELOG.md +39 -0
  2. package/dist/clients/billing-requests.types.d.ts +48 -0
  3. package/dist/clients/billing-requests.types.d.ts.map +1 -0
  4. package/dist/clients/billing-requests.types.js +2 -0
  5. package/dist/clients/billing-requests.types.js.map +1 -0
  6. package/dist/clients/billing-seat-fees.types.d.ts +105 -0
  7. package/dist/clients/billing-seat-fees.types.d.ts.map +1 -0
  8. package/dist/clients/billing-seat-fees.types.js +2 -0
  9. package/dist/clients/billing-seat-fees.types.js.map +1 -0
  10. package/dist/clients/billing.client.d.ts +121 -0
  11. package/dist/clients/billing.client.d.ts.map +1 -0
  12. package/dist/clients/billing.client.js +116 -0
  13. package/dist/clients/billing.client.js.map +1 -0
  14. package/dist/clients/capture.client.d.ts +12 -1
  15. package/dist/clients/capture.client.d.ts.map +1 -1
  16. package/dist/clients/capture.client.js.map +1 -1
  17. package/dist/factory/tenant-agent-sdk.d.ts +2 -2
  18. package/dist/factory/tenant-agent-sdk.d.ts.map +1 -1
  19. package/dist/factory/tenant-agent-sdk.js +13 -31
  20. package/dist/factory/tenant-agent-sdk.js.map +1 -1
  21. package/dist/factory/user-sdk.d.ts +11 -0
  22. package/dist/factory/user-sdk.d.ts.map +1 -1
  23. package/dist/factory/user-sdk.js +16 -0
  24. package/dist/factory/user-sdk.js.map +1 -1
  25. package/dist/index.d.ts +6 -2
  26. package/dist/index.d.ts.map +1 -1
  27. package/dist/index.js +6 -2
  28. package/dist/index.js.map +1 -1
  29. package/dist/manifest.negative-list.d.ts.map +1 -1
  30. package/dist/manifest.negative-list.js +10 -0
  31. package/dist/manifest.negative-list.js.map +1 -1
  32. package/dist/manifest.public-entries.d.ts +1 -1
  33. package/dist/manifest.public-entries.d.ts.map +1 -1
  34. package/dist/manifest.public-entries.js +3 -1
  35. package/dist/manifest.public-entries.js.map +1 -1
  36. package/dist/transport/errors.d.ts +7 -1
  37. package/dist/transport/errors.d.ts.map +1 -1
  38. package/dist/transport/errors.js +6 -1
  39. package/dist/transport/errors.js.map +1 -1
  40. package/dist/transport/http-client.d.ts +12 -2
  41. package/dist/transport/http-client.d.ts.map +1 -1
  42. package/dist/transport/http-client.js +23 -9
  43. package/dist/transport/http-client.js.map +1 -1
  44. package/dist/transport/request-origin.d.ts +44 -0
  45. package/dist/transport/request-origin.d.ts.map +1 -0
  46. package/dist/transport/request-origin.js +99 -0
  47. package/dist/transport/request-origin.js.map +1 -0
  48. package/package.json +2 -2
package/CHANGELOG.md CHANGED
@@ -1,5 +1,44 @@
1
1
  # @beacon-build/sdk Changelog
2
2
 
3
+ ## 3.1.0
4
+
5
+ ### Patch Changes
6
+
7
+ - 7fb17e4: F716 AC-15: server-side quota-account attribution for oauth_quota entries from local producers (claude/antigravity/opencode) via a 3-step session-trigger/agent-controller resolution.
8
+ - ec57e48: B1009: createTenantAgentClient presents the AS token directly — no /v1/oauth/token-exchange round trip
9
+ - Updated dependencies [e0b06d7]
10
+ - Updated dependencies [3004194]
11
+ - Updated dependencies [1d4d63b]
12
+ - Updated dependencies [89fb227]
13
+ - Updated dependencies [74c4d19]
14
+ - Updated dependencies [e9d671e]
15
+ - Updated dependencies [338f526]
16
+ - Updated dependencies [c88c742]
17
+ - Updated dependencies [35cca5c]
18
+ - Updated dependencies [51e8a8b]
19
+ - @beacon-build/core@3.1.0
20
+
21
+ ## 3.0.0
22
+
23
+ ### Minor Changes
24
+
25
+ - b32af03: F564 seat fees & gating (FS64-B): seat tiers from the role history (highest role held in the month), fee-bearing periods (trial free, pro-rata start/reactivation month, deploy-backfill start), company/personal seat fees with forecast and cost-centre allocation, invoice positions (first, monthly, reactivation; credits carried), write-once seat snapshots with the billing-tier-snapshot / billing-start-snapshot workers, GET /api/v1/billing/seat-fees and /billing/entities (scoped) + SDK, company-wide contributor gating on every org-role write path with ceiling degradation, onboarding Solo/Community choice, readable gating errors in the org administration. The SDK reads apiCode also from the nested { error: { code } } envelope. `@beacon-build/ops`'s `clean-completed-jobs.mjs` gains the new `billing-tier-snapshot`/`billing-start-snapshot` queue names to its known-queues cleanup list.
26
+ - 14ea748: FS64 billing read side and model spend. C907: billable windows (activation periods ∩ metering start ∩ inactive cut) shared by seat fees, the new GET /api/v1/billing/requests read API (+ SDK `billing.getBillableRequests`) and a fail-closed monthly request compaction (`billing_request_months`, 35-day minute detail, 10-year aggregate). F567: Cost Cockpit with two tabs — "Platform-Gebühr" (default; tier/segment, billable requests human vs agents, seat fee to date + forecast, collar band, seat table, read-only price table editable by vendors, requests drilldown person → agent → project, org-admin link) and "Modell-Spend (BYOK)" with spend-vs-budget; seat-fee read carries the period price version and the company-fee forecast. F706: payment method per turn (`api_key | oauth_quota | unknown`) and quota account on messages, ledger and rollup; reconcile never treats OAuth-quota turns as unpriced; BYOK payment split, quota cards and quota settings (`quota.config`), GET /api/v1/usage/quota; budget DM notifier, user/org budgets and weekly periods.
27
+
28
+ ### Patch Changes
29
+
30
+ - 23d25e1: F709: add the new public asset read route and asset content route to the API<->SDK negative list — both are browser byte streams with no SDK method, verified by the INV-3 drift test.
31
+ - Updated dependencies [27eb246]
32
+ - Updated dependencies [55a8d7d]
33
+ - Updated dependencies [b32af03]
34
+ - Updated dependencies [e952551]
35
+ - Updated dependencies [9514f22]
36
+ - Updated dependencies [14ea748]
37
+ - Updated dependencies [02227ba]
38
+ - Updated dependencies [23d25e1]
39
+ - Updated dependencies [b1cb09c]
40
+ - @beacon-build/core@3.0.0
41
+
3
42
  ## 2.18.0
4
43
 
5
44
  ### Minor Changes
@@ -0,0 +1,48 @@
1
+ /**
2
+ * C907 AC-6 — wire types of `GET /api/v1/billing/requests`: billable requests of one billing
3
+ * entity × UTC month, final (reconciled) vs. provisional, per person / agent / project / cost
4
+ * centre, plus the coverage gap (`unattributed`).
5
+ */
6
+ import type { SeatFeesQuery } from './billing-seat-fees.types.js';
7
+ /** Same addressing as the seat-fee read (C907 D7 default without billingOrgId / userId). */
8
+ export type BillableRequestsQuery = SeatFeesQuery;
9
+ export interface ProjectRequestsDto {
10
+ project: string;
11
+ requests: number;
12
+ }
13
+ export interface BillableRequestsPersonDto {
14
+ userId: string;
15
+ billableFinal: number;
16
+ billableProvisional: number;
17
+ human: number;
18
+ agents: Array<{
19
+ agentId: string;
20
+ name: string;
21
+ requests: number;
22
+ byProject: ProjectRequestsDto[];
23
+ }>;
24
+ byProject: ProjectRequestsDto[];
25
+ byCostCenter: Array<{
26
+ orgId: string;
27
+ requests: number;
28
+ }>;
29
+ }
30
+ export interface BillableRequestsDto {
31
+ period: string;
32
+ billingEntity: {
33
+ type: 'org' | 'user';
34
+ id: string;
35
+ };
36
+ isFinal: boolean;
37
+ reconciledThrough: string | null;
38
+ persons: BillableRequestsPersonDto[];
39
+ unattributed: {
40
+ requests: number;
41
+ };
42
+ totals: {
43
+ billableFinal: number;
44
+ billableProvisional: number;
45
+ unattributed: number;
46
+ };
47
+ }
48
+ //# sourceMappingURL=billing-requests.types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"billing-requests.types.d.ts","sourceRoot":"","sources":["../../src/clients/billing-requests.types.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,8BAA8B,CAAA;AAEjE,4FAA4F;AAC5F,MAAM,MAAM,qBAAqB,GAAG,aAAa,CAAA;AAEjD,MAAM,WAAW,kBAAkB;IAC/B,OAAO,EAAE,MAAM,CAAA;IACf,QAAQ,EAAE,MAAM,CAAA;CACnB;AAED,MAAM,WAAW,yBAAyB;IACtC,MAAM,EAAE,MAAM,CAAA;IACd,aAAa,EAAE,MAAM,CAAA;IACrB,mBAAmB,EAAE,MAAM,CAAA;IAC3B,KAAK,EAAE,MAAM,CAAA;IACb,MAAM,EAAE,KAAK,CAAC;QACV,OAAO,EAAE,MAAM,CAAA;QACf,IAAI,EAAE,MAAM,CAAA;QACZ,QAAQ,EAAE,MAAM,CAAA;QAChB,SAAS,EAAE,kBAAkB,EAAE,CAAA;KAClC,CAAC,CAAA;IACF,SAAS,EAAE,kBAAkB,EAAE,CAAA;IAC/B,YAAY,EAAE,KAAK,CAAC;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,QAAQ,EAAE,MAAM,CAAA;KAAE,CAAC,CAAA;CAC3D;AAED,MAAM,WAAW,mBAAmB;IAChC,MAAM,EAAE,MAAM,CAAA;IACd,aAAa,EAAE;QAAE,IAAI,EAAE,KAAK,GAAG,MAAM,CAAC;QAAC,EAAE,EAAE,MAAM,CAAA;KAAE,CAAA;IACnD,OAAO,EAAE,OAAO,CAAA;IAChB,iBAAiB,EAAE,MAAM,GAAG,IAAI,CAAA;IAChC,OAAO,EAAE,yBAAyB,EAAE,CAAA;IACpC,YAAY,EAAE;QAAE,QAAQ,EAAE,MAAM,CAAA;KAAE,CAAA;IAClC,MAAM,EAAE;QAAE,aAAa,EAAE,MAAM,CAAC;QAAC,mBAAmB,EAAE,MAAM,CAAC;QAAC,YAAY,EAAE,MAAM,CAAA;KAAE,CAAA;CACvF"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=billing-requests.types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"billing-requests.types.js","sourceRoot":"","sources":["../../src/clients/billing-requests.types.ts"],"names":[],"mappings":""}
@@ -0,0 +1,105 @@
1
+ /**
2
+ * F564 Scope 8 — wire types of `GET /api/v1/billing/seat-fees` and `GET /api/v1/billing/entities`
3
+ * (canonical field names, amounts as 2-digit decimal strings, ISO instants).
4
+ */
5
+ import type { BillingStatusValue, InactiveReasonValue } from './billing.client.js';
6
+ export type LadderRoleDto = 'viewer' | 'reviewer' | 'contributor';
7
+ export type BillingTierDto = 'viewer' | 'community' | 'solo' | 'org_contributor' | 'org_reviewer';
8
+ export interface InvoiceDto {
9
+ invoiceDate: string | null;
10
+ isFirstInvoice: boolean;
11
+ isReactivationInvoice: boolean;
12
+ hasPositions: boolean;
13
+ advanceFloorChf: string | null;
14
+ trueUpChf: string | null;
15
+ creditBroughtForwardChf: string;
16
+ amountDueChf: string;
17
+ creditCarriedChf: string;
18
+ }
19
+ export interface SeatFeePersonDto {
20
+ userId: string;
21
+ name: string;
22
+ tier: BillingTierDto;
23
+ highestRoleSource: Array<{
24
+ orgId: string;
25
+ role: LadderRoleDto;
26
+ }>;
27
+ departmentRoles: Array<{
28
+ orgId: string;
29
+ orgName: string | null;
30
+ role: LadderRoleDto;
31
+ heldUntil: string | null;
32
+ }>;
33
+ requests: number;
34
+ feeChf: string;
35
+ forecastFeeChf: string | null;
36
+ byCostCenter: Array<{
37
+ orgId: string;
38
+ requests: number;
39
+ feeShareChf: string;
40
+ }>;
41
+ }
42
+ export interface SeatFeesDto {
43
+ period: string;
44
+ isFinal: boolean;
45
+ billingEntity: {
46
+ type: 'org' | 'user';
47
+ id: string;
48
+ name: string;
49
+ billingStatus: BillingStatusValue;
50
+ inactiveReason: InactiveReasonValue | null;
51
+ trialEndsAt: string | null;
52
+ billingStartsAt: string | null;
53
+ reactivatedAt: string | null;
54
+ proRataDays: number | null;
55
+ proRataFactor: string | null;
56
+ firstInvoiceChf: string | null;
57
+ cancelEffectiveAt: string | null;
58
+ };
59
+ orgFee: {
60
+ sum: string;
61
+ total: string;
62
+ floorApplied: boolean;
63
+ /** Company fee at month end — running month only, else `null`. */
64
+ forecastTotal: string | null;
65
+ } | null;
66
+ /** The price version in effect for this period (collar formula / band). */
67
+ pricing: {
68
+ version: number;
69
+ unitPriceChf: string;
70
+ tiers: Array<{
71
+ tier: BillingTierDto;
72
+ floorChf: string;
73
+ capChf: string;
74
+ }>;
75
+ };
76
+ invoice: InvoiceDto | null;
77
+ reactivationInvoice: InvoiceDto | null;
78
+ persons: SeatFeePersonDto[];
79
+ }
80
+ export interface SeatFeesQuery {
81
+ period: string;
82
+ billingOrgId?: string;
83
+ userId?: string;
84
+ costCenterOrgId?: string;
85
+ }
86
+ export interface BillingEntityRowDto {
87
+ id: string;
88
+ type: 'org' | 'user';
89
+ name: string;
90
+ segment: string | null;
91
+ billingStatus: BillingStatusValue;
92
+ inactiveReason: InactiveReasonValue | null;
93
+ trialEndsAt: string | null;
94
+ billingStartsAt: string | null;
95
+ firstInvoiceChf: string | null;
96
+ cancelEffectiveAt: string | null;
97
+ persons: number;
98
+ requests: number;
99
+ feeSoFarChf: string | null;
100
+ feeError: {
101
+ code: string;
102
+ message: string;
103
+ } | null;
104
+ }
105
+ //# sourceMappingURL=billing-seat-fees.types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"billing-seat-fees.types.d.ts","sourceRoot":"","sources":["../../src/clients/billing-seat-fees.types.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,KAAK,EAAE,kBAAkB,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAA;AAElF,MAAM,MAAM,aAAa,GAAG,QAAQ,GAAG,UAAU,GAAG,aAAa,CAAA;AACjE,MAAM,MAAM,cAAc,GAAG,QAAQ,GAAG,WAAW,GAAG,MAAM,GAAG,iBAAiB,GAAG,cAAc,CAAA;AAEjG,MAAM,WAAW,UAAU;IACvB,WAAW,EAAE,MAAM,GAAG,IAAI,CAAA;IAC1B,cAAc,EAAE,OAAO,CAAA;IACvB,qBAAqB,EAAE,OAAO,CAAA;IAC9B,YAAY,EAAE,OAAO,CAAA;IACrB,eAAe,EAAE,MAAM,GAAG,IAAI,CAAA;IAC9B,SAAS,EAAE,MAAM,GAAG,IAAI,CAAA;IACxB,uBAAuB,EAAE,MAAM,CAAA;IAC/B,YAAY,EAAE,MAAM,CAAA;IACpB,gBAAgB,EAAE,MAAM,CAAA;CAC3B;AAED,MAAM,WAAW,gBAAgB;IAC7B,MAAM,EAAE,MAAM,CAAA;IACd,IAAI,EAAE,MAAM,CAAA;IACZ,IAAI,EAAE,cAAc,CAAA;IACpB,iBAAiB,EAAE,KAAK,CAAC;QAAE,KAAK,EAAE,MA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,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=billing-seat-fees.types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"billing-seat-fees.types.js","sourceRoot":"","sources":["../../src/clients/billing-seat-fees.types.ts"],"names":[],"mappings":""}
@@ -0,0 +1,121 @@
1
+ /**
2
+ * billing.client.ts — FS64: typed SDK client for pricing (F564) and the subscription lifecycle
3
+ * (F705). `pricing()` is PUBLIC (no token needed) — beacon-web reads the same values as the
4
+ * cockpit (one source, no drift). Billing errors surface as typed subclasses of SdkError.
5
+ */
6
+ import type { HttpClient } from '../transport/http-client.js';
7
+ import { SdkError } from '../transport/errors.js';
8
+ import type { BillingEntityRowDto, SeatFeesDto, SeatFeesQuery } from './billing-seat-fees.types.js';
9
+ import type { BillableRequestsDto, BillableRequestsQuery } from './billing-requests.types.js';
10
+ export type BillingStatusValue = 'trialing' | 'active' | 'cancelling' | 'past_due' | 'inactive';
11
+ export type InactiveReasonValue = 'cancelled' | 'payment_overdue' | 'payment_required';
12
+ export interface PricingTierDto {
13
+ tier: 'community' | 'solo' | 'org_contributor' | 'org_reviewer' | 'viewer';
14
+ segment: 'individual' | 'org' | 'any';
15
+ floorChf: string;
16
+ capChf: string;
17
+ condition: 'osi_public_repo' | 'requires_active_contributor' | null;
18
+ }
19
+ export interface PricingDto {
20
+ version: number;
21
+ effectiveFrom: string;
22
+ unitPriceChf: string;
23
+ trialDays: number;
24
+ tiers: PricingTierDto[];
25
+ }
26
+ export interface PricingVersionDto extends PricingDto {
27
+ id: string;
28
+ createdAt: string;
29
+ createdBy: string;
30
+ isEffective: boolean;
31
+ isPending: boolean;
32
+ }
33
+ export interface PricingInputDto {
34
+ unitPriceChf: string;
35
+ trialDays: number;
36
+ tiers: Array<{
37
+ tier: 'community' | 'solo' | 'org_contributor' | 'org_reviewer';
38
+ floorChf: string;
39
+ capChf: string;
40
+ }>;
41
+ }
42
+ export interface BillingStatusDto {
43
+ status: BillingStatusValue;
44
+ inactiveReason: InactiveReasonValue | null;
45
+ subscribedAt: string | null;
46
+ trialEndsAt: string | null;
47
+ billingStartsAt: string | null;
48
+ cancelledAt: string | null;
49
+ cancelEffectiveAt: string | null;
50
+ reactivatedAt: string | null;
51
+ pastDueAt: string | null;
52
+ }
53
+ export interface CompanyBillingStatusDto {
54
+ rootOrgId: string;
55
+ rootOrgName: string;
56
+ status: BillingStatusValue;
57
+ inactiveReason: InactiveReasonValue | null;
58
+ trialEndsAt: string | null;
59
+ billingStartsAt: string | null;
60
+ cancelEffectiveAt: string | null;
61
+ }
62
+ export interface UserBillingStatusDto {
63
+ personal: (BillingStatusDto & {
64
+ segment: 'solo' | 'community' | null;
65
+ }) | null;
66
+ companies: CompanyBillingStatusDto[];
67
+ }
68
+ /** 403/409 BILLING_ENTITY_INACTIVE — writes to a resource of an inactive entity. */
69
+ export declare class BillingEntityInactiveError extends SdkError {
70
+ readonly entity: 'company' | 'personal';
71
+ readonly rootOrgId: string | null;
72
+ readonly inactiveReason: InactiveReasonValue | null;
73
+ constructor(e: SdkError);
74
+ }
75
+ export declare class PersonalSubscriptionRequiredError extends SdkError {
76
+ }
77
+ export declare class ProjectOwnerRequiredError extends SdkError {
78
+ }
79
+ export declare class PaymentOverdueError extends SdkError {
80
+ }
81
+ export declare class PaymentRequiredError extends SdkError {
82
+ }
83
+ /** Maps a raw SdkError to its typed billing subclass (unchanged when not a billing code). */
84
+ export declare function toTypedBillingError(err: unknown): unknown;
85
+ export declare class BillingClient {
86
+ private http;
87
+ constructor(http: HttpClient);
88
+ /** GET /pricing — the currently effective price version (public, F564 AC-3). */
89
+ pricing(): Promise<PricingDto>;
90
+ /** GET /pricing/versions — history + pending version (vendor-only). */
91
+ pricingVersions(): Promise<PricingVersionDto[]>;
92
+ /** PUT /pricing — new version effective next UTC month (vendor-only). */
93
+ updatePricing(input: PricingInputDto): Promise<{
94
+ version: number;
95
+ effectiveFrom: string;
96
+ }>;
97
+ /** GET /users/me/billing/status — personal subscription + companies (banner source). */
98
+ myStatus(): Promise<UserBillingStatusDto>;
99
+ /** POST /users/me/billing/subscribe — take out the personal subscription. */
100
+ subscribe(input: {
101
+ segment: 'solo' | 'community';
102
+ repoUrl?: string | null;
103
+ }): Promise<BillingStatusDto & {
104
+ segment: 'solo' | 'community';
105
+ }>;
106
+ cancelPersonal(): Promise<BillingStatusDto>;
107
+ revokePersonalCancellation(): Promise<BillingStatusDto>;
108
+ reactivatePersonal(): Promise<BillingStatusDto>;
109
+ /** Company (root org) subscription — root-org admin for writes, any member for status. */
110
+ orgStatus(orgId: string): Promise<BillingStatusDto>;
111
+ cancelOrg(orgId: string): Promise<BillingStatusDto>;
112
+ revokeOrgCancellation(orgId: string): Promise<BillingStatusDto>;
113
+ reactivateOrg(orgId: string): Promise<BillingStatusDto>;
114
+ /** GET /billing/seat-fees — seat fees of one entity × month, scoped by the caller (F564). */
115
+ seatFees(query: SeatFeesQuery): Promise<SeatFeesDto>;
116
+ /** GET /billing/requests — billable requests of one entity × month, scoped (C907 AC-6). */
117
+ getBillableRequests(query: BillableRequestsQuery): Promise<BillableRequestsDto>;
118
+ /** GET /billing/entities — every billing entity with status and fees so far (vendor-only). */
119
+ entities(period?: string): Promise<BillingEntityRowDto[]>;
120
+ }
121
+ //# sourceMappingURL=billing.client.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"billing.client.d.ts","sourceRoot":"","sources":["../../src/clients/billing.client.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,6BAA6B,CAAA;AAC7D,OAAO,EAAE,QAAQ,EAAE,MAAM,wBAAwB,CAAA;AACjD,OAAO,KAAK,EAAE,mBAAmB,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,8BAA8B,CAAA;AACnG,OAAO,KAAK,EAAE,mBAAmB,EAAE,qBAAqB,EAAE,MAAM,6BAA6B,CAAA;AAE7F,MAAM,MAAM,kBAAkB,GAAG,UAAU,GAAG,QAAQ,GAAG,YAAY,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;IAG/E,8FAA8F;IAC9F,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,mBAAmB,EAAE,CAAC;CAI5D"}
@@ -0,0 +1,116 @@
1
+ import { SdkError } from '../transport/errors.js';
2
+ /** 403/409 BILLING_ENTITY_INACTIVE — writes to a resource of an inactive entity. */
3
+ export class BillingEntityInactiveError extends SdkError {
4
+ entity;
5
+ rootOrgId;
6
+ inactiveReason;
7
+ constructor(e) {
8
+ super(e.code, e.message, e.status, e.apiCode, e.details);
9
+ this.name = 'BillingEntityInactiveError';
10
+ this.entity = e.details?.entity ?? 'company';
11
+ this.rootOrgId = e.details?.rootOrgId ?? null;
12
+ this.inactiveReason = e.details?.inactiveReason ?? null;
13
+ }
14
+ }
15
+ export class PersonalSubscriptionRequiredError extends SdkError {
16
+ }
17
+ export class ProjectOwnerRequiredError extends SdkError {
18
+ }
19
+ export class PaymentOverdueError extends SdkError {
20
+ }
21
+ export class PaymentRequiredError extends SdkError {
22
+ }
23
+ const TYPED = {
24
+ BILLING_ENTITY_INACTIVE: (e) => new BillingEntityInactiveError(e),
25
+ PERSONAL_SUBSCRIPTION_REQUIRED: (e) => new PersonalSubscriptionRequiredError(e.code, e.message, e.status, e.apiCode, e.details),
26
+ PROJECT_OWNER_REQUIRED: (e) => new ProjectOwnerRequiredError(e.code, e.message, e.status, e.apiCode, e.details),
27
+ PAYMENT_OVERDUE: (e) => new PaymentOverdueError(e.code, e.message, e.status, e.apiCode, e.details),
28
+ PAYMENT_REQUIRED: (e) => new PaymentRequiredError(e.code, e.message, e.status, e.apiCode, e.details),
29
+ };
30
+ /** Maps a raw SdkError to its typed billing subclass (unchanged when not a billing code). */
31
+ export function toTypedBillingError(err) {
32
+ if (err instanceof SdkError && err.apiCode && TYPED[err.apiCode])
33
+ return TYPED[err.apiCode](err);
34
+ return err;
35
+ }
36
+ async function typed(p) {
37
+ try {
38
+ return await p;
39
+ }
40
+ catch (err) {
41
+ throw toTypedBillingError(err);
42
+ }
43
+ }
44
+ /** Query string of the billing read endpoints (seat fees, requests). */
45
+ function readQuery(query) {
46
+ const params = new URLSearchParams({ period: query.period });
47
+ if (query.billingOrgId)
48
+ params.set('billingOrgId', query.billingOrgId);
49
+ if (query.userId)
50
+ params.set('userId', query.userId);
51
+ if (query.costCenterOrgId)
52
+ params.set('costCenterOrgId', query.costCenterOrgId);
53
+ return params.toString();
54
+ }
55
+ export class BillingClient {
56
+ http;
57
+ constructor(http) {
58
+ this.http = http;
59
+ }
60
+ /** GET /pricing — the currently effective price version (public, F564 AC-3). */
61
+ pricing() {
62
+ return this.http.get('/pricing');
63
+ }
64
+ /** GET /pricing/versions — history + pending version (vendor-only). */
65
+ pricingVersions() {
66
+ return this.http.get('/pricing/versions');
67
+ }
68
+ /** PUT /pricing — new version effective next UTC month (vendor-only). */
69
+ updatePricing(input) {
70
+ return this.http.put('/pricing', input);
71
+ }
72
+ /** GET /users/me/billing/status — personal subscription + companies (banner source). */
73
+ myStatus() {
74
+ return typed(this.http.get('/users/me/billing/status'));
75
+ }
76
+ /** POST /users/me/billing/subscribe — take out the personal subscription. */
77
+ subscribe(input) {
78
+ return typed(this.http.post('/users/me/billing/subscribe', input));
79
+ }
80
+ cancelPersonal() {
81
+ return typed(this.http.post('/users/me/billing/cancel', {}));
82
+ }
83
+ revokePersonalCancellation() {
84
+ return typed(this.http.post('/users/me/billing/cancel/revoke', {}));
85
+ }
86
+ reactivatePersonal() {
87
+ return typed(this.http.post('/users/me/billing/reactivate', {}));
88
+ }
89
+ /** Company (root org) subscription — root-org admin for writes, any member for status. */
90
+ orgStatus(orgId) {
91
+ return typed(this.http.get(`/organizations/${encodeURIComponent(orgId)}/billing/status`));
92
+ }
93
+ cancelOrg(orgId) {
94
+ return typed(this.http.post(`/organizations/${encodeURIComponent(orgId)}/billing/cancel`, {}));
95
+ }
96
+ revokeOrgCancellation(orgId) {
97
+ return typed(this.http.post(`/organizations/${encodeURIComponent(orgId)}/billing/cancel/revoke`, {}));
98
+ }
99
+ reactivateOrg(orgId) {
100
+ return typed(this.http.post(`/organizations/${encodeURIComponent(orgId)}/billing/reactivate`, {}));
101
+ }
102
+ /** GET /billing/seat-fees — seat fees of one entity × month, scoped by the caller (F564). */
103
+ seatFees(query) {
104
+ return typed(this.http.get(`/billing/seat-fees?${readQuery(query)}`));
105
+ }
106
+ /** GET /billing/requests — billable requests of one entity × month, scoped (C907 AC-6). */
107
+ getBillableRequests(query) {
108
+ return typed(this.http.get(`/billing/requests?${readQuery(query)}`));
109
+ }
110
+ /** GET /billing/entities — every billing entity with status and fees so far (vendor-only). */
111
+ entities(period) {
112
+ const qs = period ? `?period=${encodeURIComponent(period)}` : '';
113
+ return typed(this.http.get(`/billing/entities${qs}`));
114
+ }
115
+ }
116
+ //# sourceMappingURL=billing.client.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"billing.client.js","sourceRoot":"","sources":["../../src/clients/billing.client.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,QAAQ,EAAE,MAAM,wBAAwB,CAAA;AAoEjD,oFAAoF;AACpF,MAAM,OAAO,0BAA2B,SAAQ,QAAQ;IAC3C,MAAM,CAAwB;IAC9B,SAAS,CAAe;IACxB,cAAc,CAA4B;IACnD,YAAY,CAAW;QACnB,KAAK,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC,OAAO,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,CAAC,OAAO,EAAE,CAAC,CAAC,OAAO,CAAC,CAAA;QACxD,IAAI,CAAC,IAAI,GAAG,4BAA4B,CAAA;QACxC,IAAI,CAAC,MAAM,GAAI,CAAC,CAAC,OAAO,EAAE,MAAiC,IAAI,SAAS,CAAA;QACxE,IAAI,CAAC,SAAS,GAAI,CAAC,CAAC,OAAO,EAAE,SAAgC,IAAI,IAAI,CAAA;QACrE,IAAI,CAAC,cAAc,GAAI,CAAC,CAAC,OAAO,EAAE,cAAkD,IAAI,IAAI,CAAA;IAChG,CAAC;CACJ;AACD,MA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BAAkB,CAAC,KAAK,CAAC,qBAAqB,EAChE,EAAE,CACL,CACJ,CAAA;IACL,CAAC;IAED,6FAA6F;IAC7F,QAAQ,CAAC,KAAoB;QACzB,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAc,sBAAsB,SAAS,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC,CAAA;IACtF,CAAC;IACD,2FAA2F;IAC3F,mBAAmB,CAAC,KAA4B;QAC5C,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAsB,qBAAqB,SAAS,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC,CAAA;IAC7F,CAAC;IACD,8FAA8F;IAC9F,QAAQ,CAAC,MAAe;QACpB,MAAM,EAAE,GAAG,MAAM,CAAC,CAAC,CAAC,WAAW,kBAAkB,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,CAAA;QAChE,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAwB,oBAAoB,EAAE,EAAE,CAAC,CAAC,CAAA;IAChF,CAAC;CACJ"}
@@ -13,7 +13,7 @@
13
13
  * Retry: on 503/network failure the caller retains the batch and retries on the
14
14
  * next flush cycle (max 3 attempts, then log.warn + discard).
15
15
  */
16
- import type { SessionClient } from '@beacon-build/core';
16
+ import type { PaymentMethod, SessionClient } from '@beacon-build/core';
17
17
  export interface CapturedToolUse {
18
18
  id: string;
19
19
  name: string;
@@ -52,6 +52,17 @@ export interface CapturedEntry {
52
52
  isSidechain: boolean;
53
53
  subagentSessionId?: string | null;
54
54
  agentType?: string | null;
55
+ /** F706: how this turn was paid (missing ⇒ server stores 'unknown'). */
56
+ paymentMethod?: PaymentMethod;
57
+ /** F706: `<provider>:user:<userId>` — only meaningful for `oauth_quota`. */
58
+ quotaAccount?: string | null;
59
+ /**
60
+ * F716/AC-15: the OpenCode provider id for this turn (P3/P5 only) — see the worker
61
+ * contract's own doc comment (`packages/worker/src/conversation-capture.contract.ts`) for
62
+ * why the server needs it (synthesizing a `quotaAccount` for an unattributed `oauth_quota`
63
+ * OpenCode turn).
64
+ */
65
+ providerID?: string | null;
55
66
  toolUses: CapturedToolUse[];
56
67
  }
57
68
  export interface CaptureJob {
@@ -1 +1 @@
1
- {"version":3,"file":"capture.client.d.ts","sourceRoot":"","sources":["../../src/clients/capture.client.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAA;AAOvD,MAAM,WAAW,eAAe;IAC5B,EAAE,EAAE,MAAM,CAAA;IACV,IAAI,EAAE,MAAM,CAAA;IACZ,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;IAC9B,OAAO,CAAC,EAAE,OAAO,CAAA;IACjB,UAAU,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IAC1B,6FAA6F;IAC7F,WAAW,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IAC3B;;;;;OAKG;IACH,UAAU,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;CAC7B;AAED,MAAM,WAAW,aAAa;IAC1B,IAAI,EAAE,MAAM,CAAA;IACZ,iBAAiB,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IACjC,SAAS,EAAE,MAAM,GAAG,IAAI,CAAA;IACxB,IAAI,EAAE,MAAM,GAAG,WAAW,GAAG,QAAQ,CAAA;IACrC,OAAO,EAAE,MAAM,CAAA;IACf,KAAK,EAAE,MAAM,GAAG,IAAI,CAAA;IACpB,WAAW,EAAE,MAAM,GAAG,IAAI,CAAA;IAC1B,YAAY,EAAE,MAAM,GAAG,IAAI,CAAA;IAC3B,eAAe,EAAE,MAAM,GAAG,IAAI,CAAA;IAC9B,gBAAgB,EAAE,MAAM,GAAG,IAAI,CAAA;IAC/B;;;;;;OAMG;IACH,OAAO,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IACvB,WAAW,EAAE,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,EAAE,CAAC,SAAS,CAAA;IAC7B,CAAC;IAED,KAAK,CAAC,MAAM,CAAC,GAAe;QACxB,MAAM,GAAG,GAAG,MAAM,KAAK,CAAC,IAAI,CAAC,SAAS,EAAE;YACpC,MAAM,EAAE,MAAM;YACd,OAAO,EAAE;gBACL,cAAc,EAAE,kBAAkB;gBAClC,aAAa,EAAE,UAAU,MAAM,IAAI,CAAC,YAAY,EAAE,EAAE;aACvD;YACD,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC;SAC5B,CAAC,CAAA;QAEF,IAAI,CAAC,GAAG,CAAC,EAAE,EAAE,CAAC;YACV,wEAAwE;YACxE,0EAA0E;YAC1E,uEAAuE;YACvE,MAAM,IAAI,KAAK,CAAC,0BAA0B,GAAG,CAAC,MAAM,IAAI,GAAG,CAAC,UAAU,EAAE,CAAC,CAAA;QAC7E,CAAC;QAED,MAAM,IAAI,GAAG,CAAC,MAAM,GAAG,CAAC,IAAI,EAAE,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC,CAAqC,CAAA;QACrF,OAAO,EAAE,QAAQ,EAAE,IAAI,CAAC,IAAI,EAAE,QAAQ,IAAI,GAAG,CAAC,OAAO,CAAC,MAAM,EAAE,CAAA;IAClE,CAAC;CACJ"}
@@ -16,12 +16,12 @@ export interface TenantAgentSdkConfig {
16
16
  refreshSkewSeconds?: number;
17
17
  }
18
18
  export interface TenantAgentTokenProvider {
19
- /** A current internal agent token (exchanging/re-obtaining when needed). */
19
+ /** A current AS access token — the credential itself, or re-obtained via client_credentials. */
20
20
  getToken(): Promise<string>;
21
21
  /** Drop every cached token and obtain a fresh one (what a 401 triggers). */
22
22
  refresh(): Promise<string>;
23
23
  }
24
24
  export declare function createTenantAgentTokenProvider(config: TenantAgentSdkConfig): TenantAgentTokenProvider;
25
- /** An Agent SDK authenticated with a tenant credential (exchange + refresh transparent). */
25
+ /** An Agent SDK authenticated with a tenant credential (token refresh transparent). */
26
26
  export declare function createTenantAgentClient(config: TenantAgentSdkConfig): AgentSdk;
27
27
  //# sourceMappingURL=tenant-agent-sdk.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"tenant-agent-sdk.d.ts","sourceRoot":"","sources":["../../src/factory/tenant-agent-sdk.ts"],"names":[],"mappings":"AAgBA,OAAO,EAAqB,KAAK,QAAQ,EAAE,MAAM,gBAAgB,CAAA;AAEjE,MAAM,MAAM,gBAAgB,GACtB;IAAE,IAAI,EAAE,cAAc,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,GACvC;IAAE,IAAI,EAAE,SAAS,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAC;IAAC,YAAY,EAAE,MAAM,CAAA;CAAE,CAAA;AAEjE,MAAM,WAAW,oBAAoB;IACjC,OAAO,EAAE,MAAM,CAAA;IACf,UAAU,EAAE,gBAAgB,CAAA;IAC5B,gDAAgD;IAChD,KAAK,CAAC,EAAE,OAAO,KAAK,CAAA;IACpB,wFAAwF;IACxF,kBAAkB,CAAC,EAAE,MAAM,CAAA;CAC9B;AAED,MAAM,WAAW,wBAAwB;IACrC,4EAA4E;IAC5E,QAAQ,IAAI,OAAO,CAAC,MAAM,CAAC,CAAA;IAC3B,4EAA4E;IAC5E,OAAO,IAAI,OAAO,CAAC,MAAM,CAAC,CAAA;CAC7B;AA2CD,wBAAgB,8BAA8B,CAC1C,MAAM,EAAE,oBAAoB,GAC7B,wBAAwB,CA4E1B;AAED,4FAA4F;AAC5F,wBAAgB,uBAAuB,CAAC,MAAM,EAAE,oBAAoB,GAAG,QAAQ,CAQ9E"}
1
+ {"version":3,"file":"tenant-agent-sdk.d.ts","sourceRoot":"","sources":["../../src/factory/tenant-agent-sdk.ts"],"names":[],"mappings":"AAgBA,OAAO,EAAqB,KAAK,QAAQ,EAAE,MAAM,gBAAgB,CAAA;AAEjE,MAAM,MAAM,gBAAgB,GACtB;IAAE,IAAI,EAAE,cAAc,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,GACvC;IAAE,IAAI,EAAE,SAAS,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAC;IAAC,YAAY,EAAE,MAAM,CAAA;CAAE,CAAA;AAEjE,MAAM,WAAW,oBAAoB;IACjC,OAAO,EAAE,MAAM,CAAA;IACf,UAAU,EAAE,gBAAgB,CAAA;IAC5B,gDAAgD;IAChD,KAAK,CAAC,EAAE,OAAO,KAAK,CAAA;IACpB,wFAAwF;IACxF,kBAAkB,CAAC,EAAE,MAAM,CAAA;CAC9B;AAED,MAAM,WAAW,wBAAwB;IACrC,gGAAgG;IAChG,QAAQ,IAAI,OAAO,CAAC,MAAM,CAAC,CAAA;IAC3B,4EAA4E;IAC5E,OAAO,IAAI,OAAO,CAAC,MAAM,CAAC,CAAA;CAC7B;AA2CD,wBAAgB,8BAA8B,CAC1C,MAAM,EAAE,oBAAoB,GAC7B,wBAAwB,CA0D1B;AAED,uFAAuF;AACvF,wBAAgB,uBAAuB,CAAC,MAAM,EAAE,oBAAoB,GAAG,QAAQ,CAQ9E"}
@@ -1,16 +1,16 @@
1
1
  /**
2
2
  * B987 (F712 AC-7, D1) — `createTenantAgentClient`: an Agent SDK authenticated with a TENANT
3
- * credential (an owner-minted token, or a tenant API key). `services/api` never accepts the
4
- * AS-issued token directly, so this client performs, transparently:
3
+ * credential (an owner-minted token, or a tenant API key):
5
4
  *
6
5
  * api_key: client_credentials at POST /api/oauth/token (client_secret_basic) → AS token
6
+ * (cached until shortly before its expiry, re-obtained on expiry or on a 401 —
7
+ * HttpClient's onUnauthorized hook, one retry, single-flight)
7
8
  * minted_token: the AS token is the credential itself
8
- * both: POST /api/v1/oauth/token-exchange → internal agent token (cached until shortly
9
- * before its expiry), re-obtained on expiry or on a 401 (HttpClient's
10
- * onUnauthorized hook — one retry, single-flight).
11
9
  *
12
- * The secret/token never leaves this module except in the Authorization header of those two
13
- * requests. Raw fetch is deliberate here: these are the bootstrap calls that PRODUCE the bearer
10
+ * B1009: the AS token is presented DIRECTLY as the Bearer — `services/api` verifies that token
11
+ * class itself (same rules as `/v1/oauth/token-exchange`, incl. the tenant-credential branch), so
12
+ * this client no longer exchanges it first. The secret/token never leaves this module except in
13
+ * the Authorization header. Raw fetch is deliberate here: these are the bootstrap calls that PRODUCE the bearer
14
14
  * every other SDK method uses (same rationale as the mcp-core OAuth client).
15
15
  */
16
16
  import { SdkError, statusToSdkCode } from '../transport/errors.js';
@@ -49,7 +49,6 @@ export function createTenantAgentTokenProvider(config) {
49
49
  const skewMs = (config.refreshSkewSeconds ?? 30) * 1000;
50
50
  const base = config.baseUrl.replace(/\/+$/, '');
51
51
  let asToken;
52
- let internal;
53
52
  let inFlight;
54
53
  const fresh = (c) => !!c && c.expiresAtMs - skewMs > Date.now();
55
54
  async function obtainAsToken() {
@@ -84,27 +83,9 @@ export function createTenantAgentTokenProvider(config) {
84
83
  };
85
84
  return asToken.token;
86
85
  }
87
- async function exchange() {
88
- const federated = await obtainAsToken();
89
- let res;
90
- try {
91
- res = await doFetch(`${base}/api/v1/oauth/token-exchange`, {
92
- method: 'POST',
93
- headers: { authorization: `Bearer ${federated}` },
94
- });
95
- }
96
- catch (err) {
97
- throw new SdkError('network_error', `token exchange failed: ${String(err)}`);
98
- }
99
- if (!res.ok)
100
- return failFrom(res, 'token exchange');
101
- const body = (await res.json());
102
- internal = { token: body.data.token, expiresAtMs: Date.parse(body.data.expiresAt) };
103
- return internal.token;
104
- }
105
86
  function singleFlight() {
106
87
  if (!inFlight) {
107
- inFlight = exchange().finally(() => {
88
+ inFlight = obtainAsToken().finally(() => {
108
89
  inFlight = undefined;
109
90
  });
110
91
  }
@@ -112,18 +93,19 @@ export function createTenantAgentTokenProvider(config) {
112
93
  }
113
94
  return {
114
95
  async getToken() {
115
- if (fresh(internal))
116
- return internal.token;
96
+ if (config.credential.kind === 'minted_token')
97
+ return config.credential.token;
98
+ if (fresh(asToken))
99
+ return asToken.token;
117
100
  return singleFlight();
118
101
  },
119
102
  async refresh() {
120
- internal = undefined;
121
103
  asToken = undefined;
122
104
  return singleFlight();
123
105
  },
124
106
  };
125
107
  }
126
- /** An Agent SDK authenticated with a tenant credential (exchange + refresh transparent). */
108
+ /** An Agent SDK authenticated with a tenant credential (token refresh transparent). */
127
109
  export function createTenantAgentClient(config) {
128
110
  const provider = createTenantAgentTokenProvider(config);
129
111
  return createAgentClient({