@clocknext/sdk 0.14.0 → 0.15.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.d.ts CHANGED
@@ -56,37 +56,31 @@ interface CompositeTag {
56
56
  /** Your correlation value for this occurrence, stored verbatim. */
57
57
  value: string | number;
58
58
  }
59
- /** The organisation + key behind a request — `cnk.workspace.me()`. */
60
- interface WorkspaceIdentity {
61
- organization: {
62
- id: string;
63
- name: string;
64
- slug: string | null;
65
- /** `sandbox` is a disposable staging twin; `live` bills for real. Check
66
- * this before sending production traffic. */
67
- environment: "sandbox" | "live";
68
- };
69
- apiKey: {
70
- prefix: string;
71
- lastFour: string;
72
- expiresAt: string | null;
73
- } | null;
74
- }
75
- /** One model the org has enabled — `cnk.workspace.models()`. The `modelId` is
76
- * what you put in a signal's `model`. Prices are USD per 1,000,000 tokens. */
77
- interface Model {
78
- modelId: string;
79
- modelName: string;
80
- provider: string;
81
- providerName: string;
82
- isActive: boolean;
83
- inputPrice: number;
84
- outputPrice: number;
85
- cachePrice: number;
86
- }
87
- interface SignalBase {
88
- /** The customer this usage belongs to (required). */
59
+ /**
60
+ * How a request names its customer: by OUR id (`customerId`) or by YOUR id for
61
+ * them (`externalId` — the value set on the customer via
62
+ * `customers.create()` / `customers.update()`). At least one is required.
63
+ *
64
+ * When both are sent, `customerId` wins and `externalId` is ignored — the
65
+ * server does not check that they agree. An `externalId` matching no active
66
+ * customer is a `NotFoundError` (or, on an async signal, leaves it Pending
67
+ * with that reason — retry once the customer exists).
68
+ */
69
+ type CustomerRef = {
70
+ /** Our customer id. Wins over `externalId` when both are sent. */
89
71
  customerId: string;
72
+ externalId?: string;
73
+ } | {
74
+ customerId?: undefined;
75
+ /** Your id for the customer: 1–32 letters, numbers or "-", matched
76
+ * exactly (case-sensitive). */
77
+ externalId: string;
78
+ };
79
+ /** `Omit` that keeps a union a union (plain `Omit` flattens it to the
80
+ * members' shared keys, losing the {@link CustomerRef} either/or). */
81
+ type DistributiveOmit<T, K extends PropertyKey> = T extends unknown ? Omit<T, K> : never;
82
+ /** Every signal names its customer — see {@link CustomerRef}. */
83
+ interface SignalFields {
90
84
  /**
91
85
  * The model's catalog id — must be enabled in your ClockNext org
92
86
  * (Settings → Models). Matched case-insensitively against `OrgModel.modelId`.
@@ -108,18 +102,19 @@ interface SignalBase {
108
102
  */
109
103
  idempotencyKey?: string;
110
104
  }
105
+ type SignalBase = CustomerRef & SignalFields;
111
106
  /** Meters a credit, identified by the credit's stable `agentKey`. */
112
- interface CreditSignal extends SignalBase {
107
+ type CreditSignal = SignalBase & {
113
108
  type: "credit";
114
109
  /** The Credit's stable agent key (assigned when the credit was created). */
115
110
  agentKey: string;
116
111
  /** Optional composite this signal belongs to. See {@link CompositeTag}. */
117
112
  composite?: CompositeTag;
118
- }
113
+ };
119
114
  /** Debits the customer's wallet in USD at the model's cost. */
120
- interface WalletSignal extends SignalBase {
115
+ type WalletSignal = SignalBase & {
121
116
  type: "wallet";
122
- }
117
+ };
123
118
  /**
124
119
  * Records one step of a multi-call outcome run. The `agentKey` identifies the
125
120
  * step (and the outcome); `runId` groups every signal of a single run, so a step
@@ -132,7 +127,7 @@ interface WalletSignal extends SignalBase {
132
127
  * carries `complete` — see {@link OutcomeCompletionInput} /
133
128
  * `signals.completeOutcome()`, its own dedicated route.
134
129
  */
135
- interface OutcomeSignal extends SignalBase {
130
+ type OutcomeSignal = SignalBase & {
136
131
  type: "outcome";
137
132
  /** The OutcomeStep's stable agent key — identifies the outcome AND the step. */
138
133
  agentKey: string;
@@ -144,12 +139,12 @@ interface OutcomeSignal extends SignalBase {
144
139
  runId: string;
145
140
  /** Optional composite this signal belongs to. See {@link CompositeTag}. */
146
141
  composite?: CompositeTag;
147
- }
142
+ };
148
143
  type Signal = CreditSignal | WalletSignal | OutcomeSignal;
149
144
  /** Helper input shapes for the per-type convenience methods. */
150
- type CreditInput = Omit<CreditSignal, "type">;
151
- type WalletInput = Omit<WalletSignal, "type">;
152
- type OutcomeInput = Omit<OutcomeSignal, "type">;
145
+ type CreditInput = DistributiveOmit<CreditSignal, "type">;
146
+ type WalletInput = DistributiveOmit<WalletSignal, "type">;
147
+ type OutcomeInput = DistributiveOmit<OutcomeSignal, "type">;
153
148
  /**
154
149
  * Input for `signals.completeOutcome()` — closes ONE outcome run, the outcome
155
150
  * mirror of {@link CompositeCompletionInput}. No `agentKey`, no `usage`: this
@@ -161,17 +156,17 @@ type OutcomeInput = Omit<OutcomeSignal, "type">;
161
156
  * `signals.completeComposite()` — the two completions are independent, and
162
157
  * neither implies the other.
163
158
  */
164
- interface OutcomeCompletionInput {
165
- customerId: string;
159
+ type OutcomeCompletionInput = CustomerRef & {
166
160
  /** The same `runId` the run's step signals were sent with. */
167
161
  runId: string;
168
162
  /** Optional member (email) this completion is attributed to. */
169
163
  member?: string;
170
- /** Idempotency key, auto-generated if omitted. Sending `complete` twice for
171
- * the same run is already a safe no-op server-side, so this only collapses
172
- * a retry into one attempt rather than protecting against a double bill. */
164
+ /** Idempotency key, auto-generated if omitted. Sending this completion twice
165
+ * for the same run is already a safe no-op server-side, so this only
166
+ * collapses a retry into one attempt rather than protecting against a
167
+ * double bill. */
173
168
  idempotencyKey?: string;
174
- }
169
+ };
175
170
  /**
176
171
  * The result of `signals.completeOutcome()`.
177
172
  *
@@ -274,7 +269,7 @@ interface SerializedUsageLog {
274
269
  * exhausted allowance is detected by the worker LATER and never surfaces here —
275
270
  * the signal is simply dropped. A `202` therefore means "accepted", never
276
271
  * "recorded". To confirm a signal actually landed, read it back with
277
- * `signals.list({ customerId })`.
272
+ * `signals.usageLog({ customerId })`.
278
273
  *
279
274
  * When the server has no queue configured it prices inline instead and returns
280
275
  * `queued: false` with a populated `usageLog`, validating synchronously.
@@ -296,7 +291,7 @@ interface TrackResult {
296
291
  * and will price it shortly. It can no longer be lost, but
297
292
  * it is not billed yet and `usageLog` is null. A rejection
298
293
  * discovered during pricing will NOT come back to you here,
299
- * nor on `onError`. `signals.list()` shows what got priced;
294
+ * nor on `onError`. `signals.usageLog()` shows what got priced;
300
295
  * the dashboard's signal log — owner-only, by design — is
301
296
  * where an individual rejection says why.
302
297
  * `"recorded"` — the server priced it inline and `usageLog` is populated.
@@ -341,21 +336,6 @@ interface TrackResult {
341
336
  */
342
337
  rawId?: string;
343
338
  }
344
- interface UsageList {
345
- customer: {
346
- id: string;
347
- name: string;
348
- creditAllowance: number;
349
- };
350
- totals: {
351
- count: number;
352
- cost: number;
353
- revenue: number;
354
- profit: number;
355
- creditsUsed: number;
356
- };
357
- logs: SerializedUsageLog[];
358
- }
359
339
  /** A preset time window, or `"custom"` for an explicit `from`/`to` range. */
360
340
  type UsageLogPeriod = "all" | "today" | "7d" | "30d" | "90d" | "custom";
361
341
  interface UsageLogListParams {
@@ -445,6 +425,9 @@ interface UsageLogPage {
445
425
  }
446
426
  interface ApiCustomer {
447
427
  id: string;
428
+ /** Your own id for this customer, or `null` when unset. See
429
+ * {@link CustomerProfileInput.externalId}. */
430
+ externalId: string | null;
448
431
  slug: string;
449
432
  name: string;
450
433
  description: string | null;
@@ -460,11 +443,23 @@ interface ApiCustomer {
460
443
  taxId: string | null;
461
444
  currencyCode: string;
462
445
  creditAllowance: number;
446
+ recurringTransactionEmail: boolean;
447
+ autoRecurring: boolean;
463
448
  createdAt: string;
464
449
  updatedAt: string;
465
450
  }
466
451
  /** Writable customer profile fields. `null` clears a column; omit to leave it. */
467
452
  interface CustomerProfileInput {
453
+ /**
454
+ * The id YOUR product uses for this customer: 1–32 letters, numbers or "-",
455
+ * case-sensitive. Unique among the org's active customers (a clash is a
456
+ * `ConflictError`; an archived customer's id can be reused). Once set,
457
+ * signals and `purchases.create()` can take `externalId` instead of
458
+ * `customerId`, and `customers.getByExternalId()` / `updateByExternalId()` /
459
+ * `updateRecurringGrantByExternalId()` address the customer by it. `null`
460
+ * clears it on update.
461
+ */
462
+ externalId?: string | null;
468
463
  name?: string;
469
464
  description?: string | null;
470
465
  email?: string | null;
@@ -479,6 +474,10 @@ interface CustomerProfileInput {
479
474
  taxId?: string | null;
480
475
  /** ISO 4217 (3 letters); must be enabled for the org. */
481
476
  currencyCode?: string;
477
+ /** Send the invoice, payment receipt and card-payment-failed emails for recurring invoices. Defaults to `true` on create. */
478
+ recurringTransactionEmail?: boolean;
479
+ /** Issue every recurring invoice as `AUTO_CLOSED` (applied as if paid, never payable). Defaults to `false` on create. */
480
+ autoRecurring?: boolean;
482
481
  }
483
482
  /** `name` and `email` are required on create; every other field is optional. */
484
483
  type CreateCustomerInput = CustomerProfileInput & {
@@ -510,7 +509,7 @@ interface OutcomeBalance {
510
509
  remaining: number;
511
510
  /** Each step's `agentKey` is what `signals.outcome()` and the outcome adjust
512
511
  * API use to address this outcome at runtime. The outcome also has its own
513
- * separate key ({@link Outcome.agentKey}), but neither of those APIs accepts
512
+ * separate key (the outcome's own `agentKey`), but neither of those APIs accepts
514
513
  * it — it identifies the outcome in the catalogue, not in a signal. */
515
514
  steps: {
516
515
  id: string;
@@ -537,9 +536,15 @@ interface CustomerBalances {
537
536
  rateUsd: number;
538
537
  };
539
538
  hasPlan: boolean;
539
+ /** `null` when the plan has no Wallet component. */
540
540
  wallet: {
541
541
  balanceUsd: number;
542
542
  } | null;
543
+ /** The Reserved Wallet; `null` when the org hasn't enabled it. Independent
544
+ * of `wallet` — present whether or not the plan has a Wallet. */
545
+ reservedWallet: {
546
+ balanceUsd: number;
547
+ } | null;
543
548
  credits: CreditBalance[];
544
549
  outcomes: OutcomeBalance[];
545
550
  units: UnitBalance[];
@@ -590,7 +595,6 @@ interface PortalToken {
590
595
  type BillingCycle = "MONTHLY" | "QUARTERLY" | "SEMI_ANNUAL" | "YEARLY" | "EVERY_5_MIN" | "FREE";
591
596
  type PlanType = "WALLET" | "BUNDLE";
592
597
  type PlanKind = "FLAT_PRICE" | "PAY_AS_YOU_GO" | "PAY_PER_SEAT";
593
- /** A plan component's meter type. */
594
598
  /**
595
599
  * A plan component's kind.
596
600
  *
@@ -602,116 +606,6 @@ type PlanKind = "FLAT_PRICE" | "PAY_AS_YOU_GO" | "PAY_PER_SEAT";
602
606
  type ComponentType = "WALLET" | "CREDIT" | "OUTCOME" | "UNIT" | "FLAT" | "PRICING_METRIC";
603
607
  /** ADVANCE bills up-front for the cycle; ARREAR bills for what was consumed. */
604
608
  type BillingMode = "ADVANCE" | "ARREAR";
605
- /** Prepaid USD wallet. `amount` is the funded balance (required). Max one
606
- * wallet component per plan. */
607
- interface WalletComponentInput {
608
- type: "WALLET";
609
- billingMode: BillingMode;
610
- amount: number;
611
- }
612
- /** A one-off flat fee — `amount` is required. Max one flat component per plan;
613
- * not allowed on FREE plans. */
614
- interface FlatComponentInput {
615
- type: "FLAT";
616
- billingMode: BillingMode;
617
- amount: number;
618
- }
619
- /** A credit entitlement, referenced by `creditId`. Billed ADVANCE it needs a
620
- * granted `quantity`; billed ARREAR it meters usage with no upfront grant. */
621
- type CreditComponentInput = {
622
- type: "CREDIT";
623
- billingMode: "ADVANCE";
624
- creditId: string;
625
- quantity: number;
626
- } | {
627
- type: "CREDIT";
628
- billingMode: "ARREAR";
629
- creditId: string;
630
- quantity?: number | null;
631
- };
632
- /** An outcome entitlement, referenced by `outcomeId`. ADVANCE needs a granted
633
- * `quantity`; ARREAR meters usage. */
634
- type OutcomeComponentInput = {
635
- type: "OUTCOME";
636
- billingMode: "ADVANCE";
637
- outcomeId: string;
638
- quantity: number;
639
- } | {
640
- type: "OUTCOME";
641
- billingMode: "ARREAR";
642
- outcomeId: string;
643
- quantity?: number | null;
644
- };
645
- /** A unit entitlement, referenced by `unitId`. ADVANCE needs a granted
646
- * `quantity`; ARREAR meters usage. */
647
- type UnitComponentInput = {
648
- type: "UNIT";
649
- billingMode: "ADVANCE";
650
- unitId: string;
651
- quantity: number;
652
- } | {
653
- type: "UNIT";
654
- billingMode: "ARREAR";
655
- unitId: string;
656
- quantity?: number | null;
657
- };
658
- /**
659
- * A COMPOSITE sold on the plan, referenced by `pricingMetricId` (the id from
660
- * `composites.list()`). This is the line that makes a composite bill: the
661
- * catalogue entry on its own charges nobody, and this component is what turns
662
- * it into money — `quantity × the composite's price`, frozen into the purchase
663
- * snapshot at buy time.
664
- *
665
- * The two billing modes differ in what `quantity` means:
666
- * - **ADVANCE** — a PREPAID POOL of `quantity` flat-rate slots, shared
667
- * across whichever credits / outcomes / units the composite wraps. Each
668
- * distinct tag value claims one slot on completion; repeat signals under a
669
- * value reuse the slot they already claimed, at no extra cost. Once every
670
- * slot is claimed, further occurrences are refused rather than billed.
671
- * - **ARREAR** — nothing prepaid; completed occurrences are counted on the
672
- * cycle-end line.
673
- *
674
- * `type` is the wire value `"PRICING_METRIC"`, not `"COMPOSITE"`: the product
675
- * word changed but the stored enum did not, and the API still speaks the old
676
- * one. That mismatch is the server's, and it is surfaced rather than hidden so
677
- * a response and a request read the same.
678
- */
679
- type CompositeComponentInput = {
680
- type: "PRICING_METRIC";
681
- billingMode: "ADVANCE";
682
- pricingMetricId: string;
683
- quantity: number;
684
- } | {
685
- type: "PRICING_METRIC";
686
- billingMode: "ARREAR";
687
- pricingMetricId: string;
688
- quantity?: number | null;
689
- };
690
- /**
691
- * One entitlement line in a plan — a discriminated union on `type` (and, where
692
- * it matters, `billingMode`) so the per-type fields the server requires are
693
- * enforced at compile time instead of surfacing as runtime 422s:
694
- * - CREDIT / OUTCOME / UNIT require their matching id;
695
- * - PRICING_METRIC (a composite) requires `pricingMetricId`;
696
- * - CREDIT / OUTCOME / UNIT / PRICING_METRIC require `quantity` when billed
697
- * ADVANCE;
698
- * - WALLET / FLAT require `amount`.
699
- */
700
- type PlanComponentInput = WalletComponentInput | FlatComponentInput | CreditComponentInput | OutcomeComponentInput | UnitComponentInput | CompositeComponentInput;
701
- interface CreatePlanInput {
702
- name: string;
703
- description?: string | null;
704
- billingCycle: BillingCycle;
705
- /** Carry an unused balance into the next cycle. Default true. */
706
- carryForward?: boolean;
707
- /** ISO 4217 (3 letters). Default "USD". */
708
- currencyCode?: string;
709
- isActive?: boolean;
710
- /** At least one component. FREE plans must be ADVANCE-only with no FLAT component. */
711
- components: PlanComponentInput[];
712
- }
713
- /** A full-rewrite update carries the complete plan (same shape as create). */
714
- type UpdatePlanInput = CreatePlanInput;
715
609
  interface PlanComponent {
716
610
  id: string;
717
611
  type: ComponentType;
@@ -719,11 +613,9 @@ interface PlanComponent {
719
613
  creditId: string | null;
720
614
  outcomeId: string | null;
721
615
  unitId: string | null;
722
- /** The composite this component sells, on a `PRICING_METRIC` component.
723
- * Without it a plan read back could not be written back: the write shape
724
- * ({@link CompositeComponentInput}) requires this id, so a read-modify-write
725
- * silently dropped every composite component. */
726
- pricingMetricId: string | null;
616
+ /** The id of the composite this component sells, on a `PRICING_METRIC`
617
+ * component. */
618
+ compositeId: string | null;
727
619
  targetName: string | null;
728
620
  quantity: number | null;
729
621
  amount: number | null;
@@ -745,22 +637,8 @@ interface Plan {
745
637
  isActive: boolean;
746
638
  components: PlanComponent[];
747
639
  }
748
- /** The richer plan returned by `plans.get()` (adds aggregate stats). */
749
- interface PlanDetail extends Plan {
750
- createdAt: string;
751
- createdByName: string | null;
752
- customerCount: number;
753
- invoiceCount: number;
754
- openInvoiceCount: number;
755
- stats: {
756
- totalInvoiced: number;
757
- totalCollected: number;
758
- openBalance: number;
759
- };
760
- }
761
640
  type PurchaseStatus = "SCHEDULED" | "ACTIVE" | "CANCELLED";
762
- interface CreatePurchaseInput {
763
- customerId: string;
641
+ type CreatePurchaseInput = CustomerRef & {
764
642
  planId: string;
765
643
  /** `YYYY-MM-DD`. Defaults to today; must be a valid non-past date. */
766
644
  billingDate?: string;
@@ -768,7 +646,7 @@ interface CreatePurchaseInput {
768
646
  autoPayment?: boolean;
769
647
  /** Auto-void the purchase if unpaid after N minutes. */
770
648
  voidAfterMinutes?: number;
771
- }
649
+ };
772
650
  interface Purchase {
773
651
  id: string;
774
652
  purchaseNumber: string;
@@ -826,7 +704,9 @@ interface PurchaseDetail {
826
704
  paidCount: number;
827
705
  };
828
706
  }
829
- type InvoiceStatus = "OPEN" | "PAID" | "VOID";
707
+ /** `AUTO_CLOSED` — a recurring invoice for a customer with `autoRecurring` on:
708
+ * applied as if paid, but never payable. */
709
+ type InvoiceStatus = "OPEN" | "PAID" | "VOID" | "AUTO_CLOSED";
830
710
  /** Trimmed row from `invoices.list()`. */
831
711
  interface InvoiceListRow {
832
712
  id: string;
@@ -990,64 +870,76 @@ interface UpdateMemberInput {
990
870
  /** Must be unique (case-insensitively) among the customer's active members. */
991
871
  email?: string;
992
872
  }
993
- type WalletTransactionType = "CREDIT" | "DEBIT";
994
- /** What produced a wallet entry. `null` on rows written before the column
995
- * existed. */
996
- type WalletTransactionSource = "TOPUP" | "USAGE" | "SETTLE" | "ADJUSTMENT";
997
- /** The entitlement kinds a wallet-funded metering debit can name. */
998
- type WalletEntitlementKind = "CREDIT" | "OUTCOME" | "UNIT";
999
- interface WalletTransaction {
1000
- id: string;
1001
- type: WalletTransactionType;
1002
- /** What produced the entry. Null on rows older than the column. */
1003
- source: WalletTransactionSource | null;
1004
- amount: number;
1005
- amountUsd: number;
1006
- currencyCode: string;
1007
- currencyRateUsd: number;
1008
- notes: string | null;
1009
- batchId: string | null;
1010
- createdAt: string;
1011
- createdByName: string | null;
1012
- /** Set only on a wallet-funded metering debit: which kind of entitlement was
1013
- * consumed. Null on top-ups and manual adjustments. */
1014
- entitlementType: WalletEntitlementKind | null;
1015
- /** Id of the credit / outcome / unit consumed. Null unless
1016
- * `entitlementType` is set. */
1017
- targetId: string | null;
1018
- /** Its name at the time of the debit. */
1019
- targetName: string | null;
1020
- /** The signal this debit paid for (credit / outcome). In wallet-funded mode
1021
- * no invoice exists, so this is the only trail from a charge to its cause. */
1022
- usageLogId: string | null;
1023
- /** The unit event this debit paid for. */
1024
- unitUsageLogId: string | null;
1025
- }
1026
- interface WalletList {
1027
- balanceUsd: number;
1028
- transactions: WalletTransaction[];
1029
- }
1030
- interface WalletEntryInput {
1031
- /** DEBIT spends, CREDIT tops up. */
1032
- type: WalletTransactionType;
1033
- /** Always positive; the sign comes from `type`. */
1034
- amount: number;
873
+ /**
874
+ * Which of a customer's two wallet balances an entry moves: `MAIN` (the
875
+ * ordinary wallet) or `RESERVED` (the Reserved Wallet — an org-gated second
876
+ * balance behind it; see {@link WalletAdjustInput.pool}).
877
+ */
878
+ type WalletPool = "MAIN" | "RESERVED";
879
+ /** Top up (positive) or draw down (negative) a customer's wallet. `delta` is
880
+ * a non-zero amount in USD (cents allowed); absolute value ≤ 10,000,000. No
881
+ * `agentKey` — a customer has exactly one wallet. The wallet can always be
882
+ * adjusted, whatever the customer's plan (even with no plan). A draw-down is
883
+ * never rejected or floored for going below 0 — the wallet may read negative. */
884
+ interface WalletAdjustInput {
885
+ /** Signed change in USD: positive tops up, negative draws down. */
886
+ delta: number;
1035
887
  notes?: string;
888
+ /**
889
+ * Which balance to move. Default `"MAIN"`, the ordinary wallet.
890
+ *
891
+ * `"RESERVED"` moves the Reserved Wallet instead — a second balance behind
892
+ * the wallet that a wallet-funded Arrear charge draws on once the wallet
893
+ * runs out (Wallet → Reserved down to 0 → Wallet goes negative). It must be
894
+ * switched on for the org (Settings → Organisation → "Enable Reserved
895
+ * balance in wallet"), else this is a `PlanError`. It never goes negative:
896
+ * a reduce below zero is refused (an `AllowanceError`), not capped — drawing
897
+ * down to exactly 0 is fine. `remaining` is then the Reserved balance. A
898
+ * `"MAIN"` adjustment never touches it.
899
+ */
900
+ pool?: WalletPool;
901
+ /**
902
+ * Optional idempotency key (1–255 characters) that makes this adjustment
903
+ * safe to retry. The first call with a key adjusts; any repeat with the
904
+ * same key and the same request adjusts nothing and comes back with
905
+ * `replayed: true` (and when the original happened, `adjustedAt`). The same
906
+ * key with a different request is a `ConflictError`. Keys are unique per
907
+ * workspace and per adjust endpoint. **Auto-generated (UUID v4) if
908
+ * omitted** and reused across every retry of this call, so a network blip
909
+ * never adjusts twice — same as signals. Supply your own (e.g. your order
910
+ * id) to also dedupe your OWN retries, across restarts or redelivery.
911
+ */
912
+ idempotencyKey?: string;
1036
913
  }
1037
914
  /** Grant (positive) or claw back (negative) a credit balance. `delta` must be a
1038
- * non-zero whole number. The credit is addressed by its stable `agentKey`. A
1039
- * reduce is never rejected or floored for going below 0 — the resulting
1040
- * balance may read negative, same as a real-usage overdraft already can. */
915
+ * non-zero whole number. The credit is addressed by its stable `agentKey`,
916
+ * and must be a prepaid (ADVANCE) part of the customer's current plan — else
917
+ * a `PlanError` ("… is not part of this customer's plan"). A reduce is never
918
+ * rejected or floored for going below 0 — the resulting balance may read
919
+ * negative, same as a real-usage overdraft already can. */
1041
920
  interface CreditAdjustInput {
1042
921
  /** The credit's stable agent key (the same key used to record usage). */
1043
922
  agentKey: string;
1044
923
  delta: number;
1045
924
  notes?: string;
925
+ /**
926
+ * Optional idempotency key (1–255 characters) that makes this adjustment
927
+ * safe to retry. The first call with a key adjusts; any repeat with the
928
+ * same key and the same request adjusts nothing and comes back with
929
+ * `replayed: true` (and when the original happened, `adjustedAt`). The same
930
+ * key with a different request is a `ConflictError`. Keys are unique per
931
+ * workspace and per adjust endpoint. **Auto-generated (UUID v4) if
932
+ * omitted** and reused across every retry of this call, so a network blip
933
+ * never adjusts twice — same as signals. Supply your own (e.g. your order
934
+ * id) to also dedupe your OWN retries, across restarts or redelivery.
935
+ */
936
+ idempotencyKey?: string;
1046
937
  }
1047
938
  /** Grant/claw an outcome balance. `delta` is a non-zero whole number. The
1048
939
  * outcome is addressed here by a STEP's `agentKey`, which resolves to its
1049
- * parent outcome — NOT by the outcome's own `agentKey` ({@link Outcome.agentKey}),
1050
- * which this endpoint does not accept. A reduce is never rejected or floored
940
+ * parent outcome — NOT by the outcome's own `agentKey`,
941
+ * which this endpoint does not accept. The outcome must be a prepaid
942
+ * (ADVANCE) part of the customer's current plan — else a `PlanError`. A reduce is never rejected or floored
1051
943
  * for going below 0 — the resulting balance may read negative, same as a
1052
944
  * real-usage overdraft already can. */
1053
945
  interface OutcomeAdjustInput {
@@ -1056,16 +948,41 @@ interface OutcomeAdjustInput {
1056
948
  agentKey: string;
1057
949
  delta: number;
1058
950
  notes?: string;
951
+ /**
952
+ * Optional idempotency key (1–255 characters) that makes this adjustment
953
+ * safe to retry. The first call with a key adjusts; any repeat with the
954
+ * same key and the same request adjusts nothing and comes back with
955
+ * `replayed: true` (and when the original happened, `adjustedAt`). The same
956
+ * key with a different request is a `ConflictError`. Keys are unique per
957
+ * workspace and per adjust endpoint. **Auto-generated (UUID v4) if
958
+ * omitted** and reused across every retry of this call, so a network blip
959
+ * never adjusts twice — same as signals. Supply your own (e.g. your order
960
+ * id) to also dedupe your OWN retries, across restarts or redelivery.
961
+ */
962
+ idempotencyKey?: string;
1059
963
  }
1060
964
  /** Grant/claw a unit balance. `delta` is non-zero (fractional allowed). The
1061
- * unit is addressed by its stable `agentKey`. A reduce is never rejected or
1062
- * floored for going below 0 — the resulting balance may read negative, same
1063
- * as a real-usage overdraft already can. */
965
+ * unit is addressed by its stable `agentKey`, and must be a prepaid
966
+ * (ADVANCE) part of the customer's current plan — else a `PlanError`. A
967
+ * reduce is never rejected or floored for going below 0 — the resulting
968
+ * balance may read negative, same as a real-usage overdraft already can. */
1064
969
  interface UnitAdjustInput {
1065
970
  /** The unit's stable agent key (the same key used to record usage). */
1066
971
  agentKey: string;
1067
972
  delta: number;
1068
973
  notes?: string;
974
+ /**
975
+ * Optional idempotency key (1–255 characters) that makes this adjustment
976
+ * safe to retry. The first call with a key adjusts; any repeat with the
977
+ * same key and the same request adjusts nothing and comes back with
978
+ * `replayed: true` (and when the original happened, `adjustedAt`). The same
979
+ * key with a different request is a `ConflictError`. Keys are unique per
980
+ * workspace and per adjust endpoint. **Auto-generated (UUID v4) if
981
+ * omitted** and reused across every retry of this call, so a network blip
982
+ * never adjusts twice — same as signals. Supply your own (e.g. your order
983
+ * id) to also dedupe your OWN retries, across restarts or redelivery.
984
+ */
985
+ idempotencyKey?: string;
1069
986
  }
1070
987
  /**
1071
988
  * Grant (positive) or claw back (negative) slots on a customer's ADVANCE
@@ -1077,7 +994,7 @@ interface UnitAdjustInput {
1077
994
  */
1078
995
  interface CompositeAdjustInput {
1079
996
  /**
1080
- * The composite's stable identifier — its `refId` (see {@link Composite.refId}),
997
+ * The composite's stable identifier — its `refId`,
1081
998
  * the same value signals tag it with, NOT `agentKey` (a composite has no
1082
999
  * `agentKey` column of its own). Named `agentKey` on the wire only so the
1083
1000
  * four adjust endpoints share one request shape.
@@ -1085,248 +1002,66 @@ interface CompositeAdjustInput {
1085
1002
  agentKey: string;
1086
1003
  delta: number;
1087
1004
  notes?: string;
1088
- }
1089
- /** A per-model token bundle attached to a credit or outcome step. */
1090
- interface ModelBundleEntry {
1091
- orgModelId: string;
1092
- /** Display label; the server defaults it from the model when omitted. */
1093
- modelName?: string;
1094
- tokens: number;
1095
- input: number;
1096
- output: number;
1097
- cache: number;
1098
- }
1099
- /** One point on a cost-over-time analytics series. */
1100
- interface CostPoint {
1101
- /** UTC day, `YYYY-MM-DD`. */
1102
- dateIso: string;
1103
- /** Short display label, e.g. "Jun 24". */
1104
- label: string;
1105
- /** Average cost that day, or `null` on days with no usage. */
1106
- cost: number | null;
1107
- reqs: number;
1108
- }
1109
- /** Summary stats across a cost-over-time series. */
1110
- interface CostStats {
1111
- activeDays: number;
1112
- avgCost: number | null;
1113
- peakCost: number | null;
1114
- troughCost: number | null;
1115
- deviationPct: number | null;
1116
- }
1117
- /** Cost-over-time analytics for a credit (`credits.get().analytics`). */
1118
- interface CreditAnalytics {
1119
- basePrice: number;
1120
- pricePerCredit: number;
1121
- marginPercent: number;
1122
- points: CostPoint[];
1123
- stats: CostStats;
1124
- }
1125
- /** Cost-over-time analytics for an outcome (`outcomes.get().analytics`).
1126
- * Each point adds `completions` (workflows finished that day). */
1127
- interface OutcomeAnalytics {
1128
- basePrice: number;
1129
- pricePerOutcome: number;
1130
- marginPercent: number;
1131
- points: (CostPoint & {
1132
- completions: number;
1133
- })[];
1134
- stats: CostStats;
1135
- }
1136
- interface Credit {
1137
- id: string;
1138
- name: string;
1139
- agentKey: string;
1140
- description: string | null;
1141
- tokensPerCredit: number;
1142
- basePrice: number;
1143
- marginPercent: number;
1144
- pricePerCredit: number;
1145
- isActive: boolean;
1146
- createdAt: string;
1147
- }
1148
- /** `credits.get()` — adds the model bundle plus usage stats/analytics. */
1149
- interface CreditDetail extends Credit {
1150
- modelBundle: ModelBundleEntry[];
1151
- createdByName: string;
1152
- stats: {
1153
- customerCount: number;
1154
- planCount: number;
1155
- totalGranted: number;
1156
- totalUsed: number;
1157
- revenue: number;
1158
- usageLogCount: number;
1159
- };
1160
- analytics: CreditAnalytics;
1161
- }
1162
- interface CreateCreditInput {
1163
- name: string;
1164
- /** Lowercased stable key used by `signals.credit({ agentKey })`. */
1165
- agentKey: string;
1166
- basePrice: number;
1167
- marginPercent: number;
1168
- pricePerCredit: number;
1169
- description?: string;
1170
- tokensPerCredit?: number;
1171
- modelBundle?: ModelBundleEntry[];
1172
- }
1173
- type UpdateCreditInput = CreateCreditInput;
1174
- interface OutcomeStepInput {
1175
- id?: string;
1176
- name: string;
1177
- /** Lowercased stable key used by `signals.outcome({ agentKey })`. */
1178
- agentKey: string;
1179
- basePrice: number;
1180
- modelBundle?: ModelBundleEntry[];
1181
- }
1182
- interface Outcome {
1183
- id: string;
1184
- name: string;
1185
- /**
1186
- * The OUTCOME's own stable agent key — its durable identity, mirroring
1187
- * {@link Credit.agentKey}. Lowercased `[a-z0-9._-]`, max 80 chars, unique per
1188
- * organisation. A rename never changes it.
1189
- *
1190
- * Distinct from each step's `agentKey` in `steps`, and in a SEPARATE
1191
- * namespace: usage is always reported against a STEP's key
1192
- * (`signals.outcome({ agentKey })`), never this one. This key identifies the
1193
- * outcome itself when creating or updating it.
1194
- */
1195
- agentKey: string;
1196
- description: string | null;
1197
- isActive: boolean;
1198
- marginPercent: number;
1199
- pricePerOutcome: number;
1200
- }
1201
- /** `outcomes.get()` — adds steps plus in-flight/completed stats. */
1202
- interface OutcomeDetail extends Outcome {
1203
- /** Only the DETAIL row carries these — `outcomes.list()` returns neither.
1204
- * They were previously declared on {@link Outcome} itself, where
1205
- * `createdAt` was typed as a required `string` that is always `undefined`
1206
- * in practice. */
1207
- createdAt: string;
1208
- createdByName: string | null;
1209
- steps: {
1210
- name: string;
1211
- agentKey: string;
1212
- }[];
1213
- stats: {
1214
- stepCount: number;
1215
- customerCount: number;
1216
- inFlight: number;
1217
- completed: number;
1218
- totalRemaining: number;
1219
- };
1220
- analytics: OutcomeAnalytics;
1221
- }
1222
- interface CreateOutcomeInput {
1223
- name: string;
1224
1005
  /**
1225
- * The OUTCOME's own stable agent key — REQUIRED. Lowercased `[a-z0-9._-]`,
1226
- * max 80 chars, unique per organisation (the server lowercases and trims it).
1227
- *
1228
- * Separate namespace from `steps[].agentKey`: this names the outcome, a step
1229
- * key names a step and is what `signals.outcome()` reports against. Omitting
1230
- * it is rejected with a `ValidationError` (400).
1006
+ * Optional idempotency key (1–255 characters) that makes this adjustment
1007
+ * safe to retry. The first call with a key adjusts; any repeat with the
1008
+ * same key and the same request adjusts nothing and comes back with
1009
+ * `replayed: true` (and when the original happened, `adjustedAt`). The same
1010
+ * key with a different request is a `ConflictError`. Keys are unique per
1011
+ * workspace and per adjust endpoint. **Auto-generated (UUID v4) if
1012
+ * omitted** and reused across every retry of this call, so a network blip
1013
+ * never adjusts twice — same as signals. Supply your own (e.g. your order
1014
+ * id) to also dedupe your OWN retries, across restarts or redelivery.
1231
1015
  */
1232
- agentKey: string;
1233
- basePrice: number;
1234
- marginPercent: number;
1235
- pricePerOutcome: number;
1236
- description?: string | null;
1237
- isActive?: boolean;
1238
- /** 1–50 steps; step names and agent keys must be unique. */
1239
- steps: OutcomeStepInput[];
1240
- }
1241
- type UpdateOutcomeInput = CreateOutcomeInput;
1242
- type UnitPricingType = "FLAT" | "SLAB" | "VOLUME";
1243
- /** A tier for SLAB/VOLUME pricing; only the last tier may have `upTo: null`. */
1244
- interface UnitTierInput {
1245
- id?: string;
1246
- upTo: number | null;
1247
- price: number;
1248
- }
1249
- interface UnitTier {
1250
- id: string;
1251
- upTo: number | null;
1252
- price: number;
1253
- order: number;
1254
- }
1255
- interface Unit {
1256
- id: string;
1257
- /** Stable per-org report key — what `signals.unit({ agentKey })` sends.
1258
- * The ONLY identifier accepted when reporting unit consumption. */
1259
- agentKey: string;
1260
- name: string;
1261
- description: string | null;
1262
- pricingType: UnitPricingType;
1263
- flatPrice: number;
1264
- tiers: UnitTier[];
1265
- isActive: boolean;
1266
- createdAt: string;
1267
- createdByName: string | null;
1016
+ idempotencyKey?: string;
1268
1017
  }
1269
- /** One row in a unit's linked-customer sample (`units.get().customers`). */
1270
- interface UnitCustomerRow {
1271
- customerId: string;
1272
- name: string;
1273
- legalName: string | null;
1274
- slug: string;
1275
- logoUrl: string | null;
1276
- granted: number;
1277
- used: number;
1018
+ /**
1019
+ * What every adjust call returns.
1020
+ *
1021
+ * `replayed: true` means this call adjusted NOTHING: an earlier call with the
1022
+ * same `idempotencyKey` already did, at `adjustedAt`. `remaining` is always
1023
+ * the balance as it is now. `customerArchived` is true when the customer is
1024
+ * archived — archived customers follow the same rules (archiving cancels
1025
+ * their plan, so usually only the wallet can still move).
1026
+ */
1027
+ interface AdjustResult {
1278
1028
  remaining: number;
1279
- currentlyMetered: boolean;
1280
- }
1281
- /** `units.get()` — adds linked-customer sample plus stats.
1282
- * `createdByName` is inherited from `Unit`. */
1283
- interface UnitDetail extends Unit {
1284
- stats: {
1285
- planCount: number;
1286
- customerCount: number;
1287
- totalRemaining: number;
1288
- totalUsed: number;
1289
- };
1290
- /** First page (≤10) of customers currently metered on this unit. */
1291
- customers: UnitCustomerRow[];
1292
- }
1293
- /** Flat per-event pricing — a single `flatPrice` (defaults to 0), no tiers. */
1294
- interface FlatUnitInput {
1295
- name: string;
1296
- /** Stable per-org report key (`signals.unit({ agentKey })`); `[a-z0-9._-]`. */
1297
- agentKey: string;
1298
- pricingType: "FLAT";
1299
- /** Price per event; defaults to 0. */
1300
- flatPrice?: number;
1301
- description?: string | null;
1302
- isActive?: boolean;
1303
- }
1304
- /** Tiered pricing (SLAB or VOLUME) — at least one tier is required. */
1305
- interface TieredUnitInput {
1306
- name: string;
1307
- /** Stable per-org report key (`signals.unit({ agentKey })`); `[a-z0-9._-]`. */
1308
- agentKey: string;
1309
- pricingType: "SLAB" | "VOLUME";
1310
- /** At least one tier (≤50). Only the last tier may have `upTo: null`. */
1311
- tiers: UnitTierInput[];
1312
- description?: string | null;
1313
- isActive?: boolean;
1029
+ replayed: boolean;
1030
+ /** Set only on a replay: when the original adjustment happened (ISO 8601). */
1031
+ adjustedAt?: string;
1032
+ customerArchived: boolean;
1314
1033
  }
1315
1034
  /**
1316
- * Create a unit type — a discriminated union on `pricingType`: `FLAT` takes an
1317
- * optional `flatPrice` (defaults to 0); `SLAB`/`VOLUME` require `tiers`, so the
1318
- * server's "add at least one tier" rule is enforced at compile time.
1035
+ * Change how much a customer is granted every billing cycle. The difference is
1036
+ * applied to the current balance immediately (a shrink is never floored — the
1037
+ * balance may read negative). `quantity` is USD for the wallet and a whole
1038
+ * number for everything else. `agentKey` resolves the same way as the adjust
1039
+ * endpoints: a credit's or unit's `agentKey`, an outcome STEP's `agentKey`, or
1040
+ * a composite's `refId`. The wallet needs none — a customer has at most one.
1319
1041
  */
1320
- type CreateUnitInput = FlatUnitInput | TieredUnitInput;
1321
- type UpdateUnitInput = CreateUnitInput;
1042
+ type RecurringGrantInput = {
1043
+ kind: "wallet";
1044
+ quantity: number;
1045
+ } | {
1046
+ kind: "credit" | "outcome" | "unit" | "composite";
1047
+ agentKey: string;
1048
+ quantity: number;
1049
+ };
1050
+ /** Result of `customers.updateRecurringGrant()`. */
1051
+ interface RecurringGrantResult {
1052
+ kind: RecurringGrantInput["kind"];
1053
+ /** The new per-cycle amount. */
1054
+ quantity: number;
1055
+ /** The wallet balance after the change — only present for `kind: "wallet"`. */
1056
+ balanceUsd?: number;
1057
+ }
1322
1058
  /**
1323
1059
  * Record one unit-metered event. The unit is addressed by its `agentKey` (the
1324
1060
  * stable key set when the unit was created) — the ONLY accepted identifier;
1325
1061
  * the display name is deliberately not accepted, so a rename can never redirect
1326
1062
  * a live integration. Keys are matched exactly (they are stored lowercased).
1327
1063
  */
1328
- interface UnitInput {
1329
- customerId: string;
1064
+ type UnitInput = CustomerRef & {
1330
1065
  agentKey: string;
1331
1066
  member?: string;
1332
1067
  /**
@@ -1357,7 +1092,7 @@ interface UnitInput {
1357
1092
  * auto key cannot survive.
1358
1093
  */
1359
1094
  idempotencyKey?: string;
1360
- }
1095
+ };
1361
1096
  /**
1362
1097
  * The result of `signals.unit()`.
1363
1098
  *
@@ -1385,8 +1120,7 @@ interface UnitTrackResult {
1385
1120
  * Input for `signals.completeComposite()` — closes ONE occurrence of a
1386
1121
  * composite, which is the moment it is billed.
1387
1122
  */
1388
- interface CompositeCompletionInput {
1389
- customerId: string;
1123
+ type CompositeCompletionInput = CustomerRef & {
1390
1124
  /** Which occurrence to close: the composite's `refId` and the correlation
1391
1125
  * value the signals were tagged with. */
1392
1126
  composite: CompositeTag;
@@ -1394,71 +1128,7 @@ interface CompositeCompletionInput {
1394
1128
  * safe no-op, so this only collapses retries into one recorded attempt
1395
1129
  * rather than protecting against a double charge. */
1396
1130
  idempotencyKey?: string;
1397
- }
1398
- /** One catalogue item a composite is restricted to. `agentKey` is what a
1399
- * signal names, so it is the field you actually integrate against. */
1400
- interface CompositeCatalogueRef {
1401
- id: string;
1402
- name: string;
1403
- agentKey: string;
1404
- }
1405
- /** One composite in the org's catalogue — `cnk.composites.list()`. */
1406
- interface Composite {
1407
- id: string;
1408
- name: string;
1409
- /** The stable identifier you put in a signal's `composite` block as `ref`. */
1410
- refId: string;
1411
- description: string | null;
1412
- /** USD charged per occurrence WHEN A PLAN SELLS THIS as a composite
1413
- * component (`quantity × price`, frozen into the purchase at buy time). The
1414
- * catalogue row alone bills nothing. */
1415
- price: number;
1416
- /** False once archived. An archived composite stops NEW signals resolving to
1417
- * it but keeps every row it already owns. */
1418
- isActive: boolean;
1419
- createdAt: string;
1420
- /**
1421
- * The credits / outcomes / units this composite is restricted to — only
1422
- * signals naming one of these may carry its tag.
1423
- *
1424
- * All three lists empty means UNRESTRICTED (it accepts any of the org's
1425
- * traffic under this tag). Nothing created through the API can be
1426
- * unrestricted, but rows predating that rule exist — so don't assume
1427
- * non-empty.
1428
- */
1429
- entitlements: {
1430
- credits: CompositeCatalogueRef[];
1431
- outcomes: CompositeCatalogueRef[];
1432
- units: CompositeCatalogueRef[];
1433
- };
1434
- }
1435
- /** Input for `cnk.composites.create()`. */
1436
- interface CreateCompositeInput {
1437
- name: string;
1438
- /**
1439
- * The tag identifier. Lowercased, and restricted to the same characters as
1440
- * an `agentKey` — but validated harder than one, because it may not collide
1441
- * with a field the ingest schemas already own (`customerId`, `usage`,
1442
- * `agentKey`, `runId`, `member`, `custom`, `composite`, …). A colliding
1443
- * `refId` is refused at create time rather than silently ignored at ingest.
1444
- */
1445
- refId: string;
1446
- /** USD per occurrence once a plan sells it. Required — an unpriced composite
1447
- * put on a plan would bill 0, which is a money bug that is hard to see. */
1448
- price: number;
1449
- description?: string | null;
1450
- /**
1451
- * What the composite wraps. At least one id across the three lists is
1452
- * REQUIRED: a composite restricted to nothing would accept every signal in
1453
- * the org. Get the ids from `credits.list()`, `outcomes.list()` and
1454
- * `units.list()`.
1455
- */
1456
- entitlements: {
1457
- creditIds?: string[];
1458
- outcomeIds?: string[];
1459
- unitIds?: string[];
1460
- };
1461
- }
1131
+ };
1462
1132
  /**
1463
1133
  * The result of `signals.completeComposite()`.
1464
1134
  *
@@ -1494,8 +1164,7 @@ interface CompositeCompletionResult {
1494
1164
  /** The durable inbox id — see {@link TrackResult.rawId}. */
1495
1165
  rawId?: string;
1496
1166
  }
1497
- /** One serialized unit-consumption event — the result of `signals.unit()` and
1498
- * each element of `UnitUsageList.events`. */
1167
+ /** One serialized unit-consumption event — the result of `signals.unit()`. */
1499
1168
  interface SerializedUnitUsage {
1500
1169
  id: string;
1501
1170
  customerId: string;
@@ -1510,42 +1179,6 @@ interface SerializedUnitUsage {
1510
1179
  member: string | null;
1511
1180
  createdAt: string;
1512
1181
  }
1513
- interface UnitUsageRow {
1514
- unit: string;
1515
- /** The unit's stable agent key — what to send to report against it. */
1516
- agentKey: string | null;
1517
- billingMode: BillingMode;
1518
- granted?: number;
1519
- used: number;
1520
- remaining?: number;
1521
- }
1522
- interface UnitUsageList {
1523
- customer: {
1524
- id: string;
1525
- name: string;
1526
- };
1527
- units: UnitUsageRow[];
1528
- events: SerializedUnitUsage[];
1529
- }
1530
- type ThresholdKind = "CREDIT" | "OUTCOME" | "WALLET";
1531
- interface Webhook {
1532
- id: string;
1533
- kind: ThresholdKind;
1534
- threshold: number;
1535
- url: string;
1536
- isActive: boolean;
1537
- createdAt: string;
1538
- updatedAt: string;
1539
- createdByName: string | null;
1540
- }
1541
- interface UpsertWebhookInput {
1542
- kind: ThresholdKind;
1543
- /** Fire when the balance crosses this value. */
1544
- threshold: number;
1545
- /** http(s) URL to POST the alert to. */
1546
- url: string;
1547
- isActive?: boolean;
1548
- }
1549
1182
  type FetchLike = (input: string, init?: RequestInit) => Promise<Response>;
1550
1183
  interface Logger {
1551
1184
  debug?: (...args: unknown[]) => void;
@@ -1677,66 +1310,9 @@ declare class Transport {
1677
1310
  private buildUrl;
1678
1311
  }
1679
1312
 
1680
- /**
1681
- * The `composites` resource — manage the org's composite *catalogue*: the
1682
- * bundles of credits / outcomes / units that are grouped under one tag and
1683
- * sold on a plan as a single thing. `/api/v1/composites`.
1684
- *
1685
- * Two things live elsewhere, deliberately:
1686
- * • Tagging a signal into a composite occurrence is `composite: { ref, value }`
1687
- * on the signal itself (see `signals.credit()` / `.outcome()` / `.unit()`).
1688
- * • Closing an occurrence — the moment it is billed — is
1689
- * `signals.completeComposite()`.
1690
- *
1691
- * This resource only defines what composites EXIST. Creating one prices it but
1692
- * charges nobody: an invoice is built from plan components, never from a
1693
- * catalogue entry, so a composite starts costing money only once a plan sells
1694
- * it (`quantity × price`, frozen into the purchase at buy time).
1695
- */
1696
- declare class Composites {
1697
- private readonly transport;
1698
- constructor(transport: Transport);
1699
- /** List composites. Pass `{ active: true }` for only the ones a signal can
1700
- * still be tagged with — the default list INCLUDES archived ones, which
1701
- * keep every row they already own.
1702
- * `{ active: false }` returns only archived ones; omitting it returns
1703
- * both. See `activeQuery` — the API itself only supports `true`. */
1704
- list(params?: {
1705
- active?: boolean;
1706
- }): Promise<Composite[]>;
1707
- /** Create a composite. `POST /api/v1/composites`. */
1708
- create(input: CreateCompositeInput): Promise<Composite>;
1709
- }
1710
-
1711
- /**
1712
- * The `credits` resource — manage the org's credit *types* (the catalog). A
1713
- * credit's stable `agentKey` is what you pass to `signals.credit()` when
1714
- * recording usage against it. `/api/v1/credits`.
1715
- */
1716
- declare class Credits {
1717
- private readonly transport;
1718
- constructor(transport: Transport);
1719
- /** List credit types. Pass `{ active: true }` to only return active ones.
1720
- * `{ active: false }` returns only archived ones; omitting it returns
1721
- * both. See `activeQuery` — the API itself only supports `true`. */
1722
- list(params?: {
1723
- active?: boolean;
1724
- }): Promise<Credit[]>;
1725
- /** Create a credit type; returns the created credit. `POST /api/v1/credits`. */
1726
- create(input: CreateCreditInput): Promise<Credit>;
1727
- /** Fetch one credit type with usage stats. `GET /api/v1/credits/:id`. */
1728
- get(id: string): Promise<CreditDetail>;
1729
- /** Update a credit type's definition; returns the updated credit. `PATCH /api/v1/credits/:id`. */
1730
- update(id: string, input: UpdateCreditInput): Promise<Credit>;
1731
- /** Activate or deactivate a credit type. */
1732
- setActive(id: string, isActive: boolean): Promise<Credit>;
1733
- /** Delete a credit type. Refused while a customer is linked to it. */
1734
- delete(id: string): Promise<void>;
1735
- }
1736
-
1737
1313
  /**
1738
1314
  * The `customers` resource — full CRUD over the org's customers plus the
1739
- * read-only insight endpoints (usage / balances / plan). Every call is scoped
1315
+ * read-only insight endpoints (balances / plan). Every call is scoped
1740
1316
  * to the API key's organisation server-side; a customer in another org
1741
1317
  * resolves as a NotFoundError.
1742
1318
  */
@@ -1763,14 +1339,25 @@ declare class Customers {
1763
1339
  get(id: string): Promise<ApiCustomer>;
1764
1340
  /** Update a customer (partial). `PATCH /api/v1/customers/:id`. */
1765
1341
  update(id: string, input: CustomerProfileInput): Promise<ApiCustomer>;
1342
+ /**
1343
+ * Fetch one customer by YOUR id for them (its `externalId`), instead of
1344
+ * ours. Same result as {@link get}. `GET /api/v1/customers/ext/:externalId`.
1345
+ * An unknown external id is a `NotFoundError`; only active customers match.
1346
+ */
1347
+ getByExternalId(externalId: string): Promise<ApiCustomer>;
1348
+ /** Update a customer (partial), addressed by its `externalId`. Same body as
1349
+ * {@link update}. `PATCH /api/v1/customers/ext/:externalId`. */
1350
+ updateByExternalId(externalId: string, input: CustomerProfileInput): Promise<ApiCustomer>;
1351
+ /** {@link delete}, addressing the customer by its `externalId`.
1352
+ * `DELETE /api/v1/customers/ext/:externalId`. */
1353
+ deleteByExternalId(externalId: string): Promise<void>;
1766
1354
  /** Delete a customer (members, invitations, usage logs cascade). */
1767
1355
  delete(id: string): Promise<void>;
1768
- /** A customer's usage history. `GET /api/v1/usage?customerId=`. */
1769
- usage(id: string, params?: {
1770
- limit?: number;
1771
- }): Promise<UsageList>;
1772
1356
  /** Wallet / credit / outcome / unit balances. `GET …/:id/balances`. */
1773
1357
  balances(id: string): Promise<CustomerBalances>;
1358
+ /** {@link balances}, addressing the customer by its `externalId`.
1359
+ * `GET /api/v1/customers/ext/:externalId/balances`. */
1360
+ balancesByExternalId(externalId: string): Promise<CustomerBalances>;
1774
1361
  /**
1775
1362
  * One credit balance for a customer, matched by `creditId` or `creditName`;
1776
1363
  * `null` when the customer has no plan or no matching credit. Convenience
@@ -1798,6 +1385,9 @@ declare class Customers {
1798
1385
  }): Promise<UnitBalance | null>;
1799
1386
  /** The customer's current plan. `GET …/:id/plan`. */
1800
1387
  plan(id: string): Promise<CustomerPlan>;
1388
+ /** {@link plan}, addressing the customer by its `externalId`.
1389
+ * `GET /api/v1/customers/ext/:externalId/plan`. */
1390
+ planByExternalId(externalId: string): Promise<CustomerPlan>;
1801
1391
  /** List a customer's members. `GET …/:id/members`. */
1802
1392
  listMembers(id: string): Promise<Member[]>;
1803
1393
  /** Add a member to a customer. Duplicate `email` → ConflictError. */
@@ -1806,39 +1396,63 @@ declare class Customers {
1806
1396
  updateMember(id: string, memberId: string, input: UpdateMemberInput): Promise<MemberProfile>;
1807
1397
  /** Remove a member from a customer, returning who was removed. `DELETE …/:id/members/:memberId`. */
1808
1398
  removeMember(id: string, memberId: string): Promise<RemovedMember>;
1809
- /** The customer's wallet balance + transactions. `GET …/:id/wallet`. */
1810
- wallet(id: string, params?: {
1811
- limit?: number;
1812
- }): Promise<WalletList>;
1399
+ /** Grant or claw back a credit balance. The credit must be a prepaid part of
1400
+ * the customer's current plan. Pass `idempotencyKey` to make it safe to
1401
+ * retry. `POST …/:id/credits/adjust`. */
1402
+ adjustCredit(id: string, input: CreditAdjustInput): Promise<AdjustResult>;
1403
+ /** Grant or claw back an outcome balance. The outcome must be a prepaid part
1404
+ * of the customer's current plan. `POST …/:id/outcomes/adjust`. */
1405
+ adjustOutcome(id: string, input: OutcomeAdjustInput): Promise<AdjustResult>;
1406
+ /** Grant or claw back a unit balance. The unit must be a prepaid part of the
1407
+ * customer's current plan. `POST …/:id/units/adjust`. */
1408
+ adjustUnit(id: string, input: UnitAdjustInput): Promise<AdjustResult>;
1409
+ /** Grant or claw back slots on a customer's ADVANCE composite pool for the
1410
+ * current billing cycle. `remaining` is the resulting slot count.
1411
+ * `POST …/:id/composites/adjust`. */
1412
+ adjustComposite(id: string, input: CompositeAdjustInput): Promise<AdjustResult>;
1813
1413
  /**
1814
- * Record a manual wallet entry (top-up or deduction). `amount` is always
1815
- * positive; the sign comes from `type`. `POST …/:id/wallet`.
1414
+ * Top up (positive `delta`) or draw down (negative `delta`) a customer's
1415
+ * wallet, in USD — allowed whatever the customer's plan. `remaining` is the
1416
+ * resulting USD balance. No `agentKey` — a customer has exactly one wallet.
1417
+ * Pass `pool: "RESERVED"` to move the Reserved Wallet instead (then
1418
+ * `remaining` is its balance). `POST …/:id/wallet/adjust`.
1816
1419
  */
1817
- addWalletEntry(id: string, input: WalletEntryInput): Promise<{
1818
- transaction: WalletTransaction;
1819
- balanceUsd: number;
1820
- }>;
1821
- /** Grant or claw back a credit balance. Returns the remaining balance.
1822
- * `POST …/:id/credits/adjust`. */
1823
- adjustCredit(id: string, input: CreditAdjustInput): Promise<{
1824
- remaining: number;
1825
- }>;
1826
- /** Grant or claw back an outcome balance. Returns the remaining balance. */
1827
- adjustOutcome(id: string, input: OutcomeAdjustInput): Promise<{
1828
- remaining: number;
1829
- }>;
1830
- /** Grant or claw back a unit balance. Returns the remaining balance. */
1831
- adjustUnit(id: string, input: UnitAdjustInput): Promise<{
1832
- remaining: number;
1833
- }>;
1420
+ adjustWallet(id: string, input: WalletAdjustInput): Promise<AdjustResult>;
1421
+ /** {@link adjustCredit}, addressing the customer by its `externalId` (`id`
1422
+ * here). `POST /api/v1/customers/ext/:externalId/credits/adjust`. */
1423
+ adjustCreditByExternalId(id: string, input: CreditAdjustInput): Promise<AdjustResult>;
1424
+ /** {@link adjustOutcome}, addressing the customer by its `externalId` (`id`
1425
+ * here). `POST /api/v1/customers/ext/:externalId/outcomes/adjust`. */
1426
+ adjustOutcomeByExternalId(id: string, input: OutcomeAdjustInput): Promise<AdjustResult>;
1427
+ /** {@link adjustUnit}, addressing the customer by its `externalId` (`id`
1428
+ * here). `POST /api/v1/customers/ext/:externalId/units/adjust`. */
1429
+ adjustUnitByExternalId(id: string, input: UnitAdjustInput): Promise<AdjustResult>;
1430
+ /** {@link adjustComposite}, addressing the customer by its `externalId`
1431
+ * (`id` here). `POST /api/v1/customers/ext/:externalId/composites/adjust`. */
1432
+ adjustCompositeByExternalId(id: string, input: CompositeAdjustInput): Promise<AdjustResult>;
1433
+ /** {@link adjustWallet}, addressing the customer by its `externalId` (`id`
1434
+ * here). `POST /api/v1/customers/ext/:externalId/wallet/adjust`. */
1435
+ adjustWalletByExternalId(id: string, input: WalletAdjustInput): Promise<AdjustResult>;
1834
1436
  /**
1835
- * Grant or claw back slots on a customer's ADVANCE composite pool for the
1836
- * current billing cycle. Returns the resulting `remaining` slot count.
1837
- * `POST …/:id/composites/adjust`.
1437
+ * The one body behind all ten adjust calls.
1438
+ *
1439
+ * Every adjustment carries an idempotency key — the caller's, or one
1440
+ * generated here ONCE per call, exactly like signals. The server
1441
+ * deduplicates on it, so a transient failure is safe to retry: the same key
1442
+ * rides every attempt, and a retry of one that already landed comes back as
1443
+ * `replayed: true` instead of adjusting again. The key is also copied onto
1444
+ * any thrown error (`error.idempotencyKey`) so the caller can replay safely.
1838
1445
  */
1839
- adjustComposite(id: string, input: CompositeAdjustInput): Promise<{
1840
- remaining: number;
1841
- }>;
1446
+ private adjust;
1447
+ /**
1448
+ * Change how much a customer is granted every billing cycle (wallet top-up,
1449
+ * credits, outcomes, units or a composite pool). Any increase or decrease
1450
+ * applies to their current balance immediately. `PUT …/:id/recurring-grant`.
1451
+ */
1452
+ updateRecurringGrant(id: string, input: RecurringGrantInput): Promise<RecurringGrantResult>;
1453
+ /** {@link updateRecurringGrant}, addressing the customer by its
1454
+ * `externalId`. `PUT /api/v1/customers/ext/:externalId/recurring-grant`. */
1455
+ updateRecurringGrantByExternalId(externalId: string, input: RecurringGrantInput): Promise<RecurringGrantResult>;
1842
1456
  }
1843
1457
 
1844
1458
  /**
@@ -1858,44 +1472,12 @@ declare class Invoices {
1858
1472
  /** Fetch one full invoice + its plan snapshot. `GET /api/v1/invoices/:id`. */
1859
1473
  get(id: string): Promise<InvoiceDetail>;
1860
1474
  /**
1861
- * Mint a hosted pay link for an OPEN invoice. PAID/VOID invoices are rejected
1475
+ * Mint a hosted pay link for an OPEN invoice. PAID/VOID/AUTO_CLOSED invoices are rejected
1862
1476
  * with a `ConflictError`. `GET /api/v1/invoices/:id/pay-link`.
1863
1477
  */
1864
1478
  payLink(id: string): Promise<PayLink>;
1865
1479
  }
1866
1480
 
1867
- /**
1868
- * The `outcomes` resource — manage the org's outcome *types* (the catalog). An
1869
- * outcome is a multi-step workflow. `/api/v1/outcomes`.
1870
- *
1871
- * Two distinct kinds of agent key, in separate namespaces, each unique per
1872
- * organisation — do not conflate them:
1873
- * - the OUTCOME's own `agentKey`, REQUIRED on `create()` and `update()`, which
1874
- * names the outcome itself in the catalogue;
1875
- * - each STEP's `agentKey`, which is what you pass to `signals.outcome()` to
1876
- * report usage and to the outcome-adjust API.
1877
- */
1878
- declare class Outcomes {
1879
- private readonly transport;
1880
- constructor(transport: Transport);
1881
- /** List outcome types. Pass `{ active: true }` to only return active ones.
1882
- * `{ active: false }` returns only archived ones; omitting it returns
1883
- * both. See `activeQuery` — the API itself only supports `true`. */
1884
- list(params?: {
1885
- active?: boolean;
1886
- }): Promise<Outcome[]>;
1887
- /** Create an outcome type with its steps. `POST /api/v1/outcomes`. */
1888
- create(input: CreateOutcomeInput): Promise<Outcome>;
1889
- /** Fetch one outcome type with steps + stats. `GET /api/v1/outcomes/:id`. */
1890
- get(id: string): Promise<OutcomeDetail>;
1891
- /** Update an outcome type's definition. `PATCH /api/v1/outcomes/:id`. */
1892
- update(id: string, input: UpdateOutcomeInput): Promise<Outcome>;
1893
- /** Activate or deactivate an outcome type; returns the updated outcome. */
1894
- setActive(id: string, isActive: boolean): Promise<Outcome>;
1895
- /** Delete an outcome type. */
1896
- delete(id: string): Promise<void>;
1897
- }
1898
-
1899
1481
  /**
1900
1482
  * The `payments` resource — read-only. A payment is a PAID invoice; the `id`
1901
1483
  * used here is that underlying invoice id. `/api/v1/payments`.
@@ -1913,9 +1495,9 @@ declare class Payments {
1913
1495
  }
1914
1496
 
1915
1497
  /**
1916
- * The `plans` resource — define and manage the billing plans customers
1917
- * subscribe to. Each plan is a set of entitlement components (wallet / credit /
1918
- * outcome / unit / flat) billed on a cycle. `/api/v1/plans`.
1498
+ * The `plans` resource — read the billing plans customers can subscribe to.
1499
+ * Each plan is a set of entitlement components (wallet / credit / outcome /
1500
+ * unit / flat) billed on a cycle. `/api/v1/plans`.
1919
1501
  */
1920
1502
  declare class Plans {
1921
1503
  private readonly transport;
@@ -1926,16 +1508,6 @@ declare class Plans {
1926
1508
  list(params?: {
1927
1509
  active?: boolean;
1928
1510
  }): Promise<Plan[]>;
1929
- /** Create a plan. `POST /api/v1/plans`. */
1930
- create(input: CreatePlanInput): Promise<Plan>;
1931
- /** Fetch one plan with aggregate subscriber/invoice stats. `GET /api/v1/plans/:id`. */
1932
- get(id: string): Promise<PlanDetail>;
1933
- /** Replace a plan's definition (components + settings). `PATCH /api/v1/plans/:id`. */
1934
- update(id: string, input: UpdatePlanInput): Promise<Plan>;
1935
- /** Activate or deactivate a plan without rewriting it. */
1936
- setActive(id: string, isActive: boolean): Promise<Plan>;
1937
- /** Delete a plan. Refused once any customer has purchased it. */
1938
- delete(id: string): Promise<void>;
1939
1511
  }
1940
1512
 
1941
1513
  /**
@@ -2144,19 +1716,6 @@ declare class Signals {
2144
1716
  * not a safe no-op — see {@link OutcomeCompletionResult}.
2145
1717
  */
2146
1718
  completeOutcome(input: OutcomeCompletionInput): Promise<OutcomeCompletionResult>;
2147
- /**
2148
- * Recent usage logs + totals for a customer. `GET /api/v1/usage`.
2149
- *
2150
- * Still the legacy path, deliberately. The `/api/v1/signal/*` family is
2151
- * POST-only — it replaced how usage is INGESTED, not how it is read — so
2152
- * `GET /api/v1/usage` has no successor and is not deprecated. It is also the
2153
- * only way to prove a signal landed, which matters more now that ingestion
2154
- * answers `202` for everything.
2155
- */
2156
- list(params: {
2157
- customerId: string;
2158
- limit?: number;
2159
- }): Promise<UsageList>;
2160
1719
  /**
2161
1720
  * Record one unit-metered event (a fixed-price meter with no tokens),
2162
1721
  * addressed to a catalog unit by its `agentKey`. Sent immediately — unit
@@ -2196,16 +1755,6 @@ declare class Signals {
2196
1755
  * rather than failing it.
2197
1756
  */
2198
1757
  completeComposite(input: CompositeCompletionInput): Promise<CompositeCompletionResult>;
2199
- /**
2200
- * A customer's unit balances + recent unit events. `GET /api/v1/units`.
2201
- *
2202
- * Legacy path for the same reason as {@link list}: the signal family is
2203
- * POST-only, so the read side has no successor and is not deprecated.
2204
- */
2205
- unitUsage(params: {
2206
- customerId: string;
2207
- limit?: number;
2208
- }): Promise<UnitUsageList>;
2209
1758
  /**
2210
1759
  * One customer's usage history, merged from every meter kind — credit,
2211
1760
  * outcome, unit, wallet, and completed composite occurrences — into one
@@ -2226,66 +1775,6 @@ declare class Signals {
2226
1775
  usageLog(params: UsageLogListParams): Promise<UsageLogPage>;
2227
1776
  }
2228
1777
 
2229
- /**
2230
- * The `units` resource — manage the org's unit *types* (the catalog): named,
2231
- * quantity-priced meters (FLAT / SLAB / VOLUME). Record consumption against a
2232
- * unit with `signals.unit()`. `/api/v1/units-catalog`.
2233
- */
2234
- declare class Units {
2235
- private readonly transport;
2236
- constructor(transport: Transport);
2237
- /** List unit types. Pass `{ active: true }` to only return active ones.
2238
- * `{ active: false }` returns only archived ones; omitting it returns
2239
- * both. See `activeQuery` — the API itself only supports `true`. */
2240
- list(params?: {
2241
- active?: boolean;
2242
- }): Promise<Unit[]>;
2243
- /** Create a unit type. `POST /api/v1/units-catalog`. */
2244
- create(input: CreateUnitInput): Promise<Unit>;
2245
- /** Fetch one unit type with stats. `GET /api/v1/units-catalog/:id`. */
2246
- get(id: string): Promise<UnitDetail>;
2247
- /** Update a unit type's definition. `PATCH /api/v1/units-catalog/:id`. */
2248
- update(id: string, input: UpdateUnitInput): Promise<Unit>;
2249
- /** Activate or deactivate a unit type. */
2250
- setActive(id: string, isActive: boolean): Promise<Unit>;
2251
- /** Delete a unit type. */
2252
- delete(id: string): Promise<void>;
2253
- }
2254
-
2255
- /**
2256
- * The `webhooks` resource — threshold alerts. At most one webhook per kind
2257
- * (CREDIT / OUTCOME / WALLET); posting a kind again upserts it. `/api/v1/webhooks`.
2258
- */
2259
- declare class Webhooks {
2260
- private readonly transport;
2261
- constructor(transport: Transport);
2262
- /** List configured webhooks. `GET /api/v1/webhooks`. */
2263
- list(): Promise<Webhook[]>;
2264
- /** Create or replace the webhook for a kind. `POST /api/v1/webhooks`. */
2265
- upsert(input: UpsertWebhookInput): Promise<Webhook>;
2266
- /** Delete the webhook for a kind (idempotent). `DELETE /api/v1/webhooks/:kind`. */
2267
- delete(kind: ThresholdKind): Promise<void>;
2268
- }
2269
-
2270
- /**
2271
- * The `workspace` resource — read-only introspection of the org behind the API
2272
- * key. Grounds an integration (which workspace, and is it `sandbox` or `live`?)
2273
- * and lists the models it may meter against. `/api/v1/me`, `/api/v1/models`.
2274
- */
2275
- declare class Workspace {
2276
- private readonly transport;
2277
- constructor(transport: Transport);
2278
- /** Identify the org + key behind the request, incl. `sandbox` | `live`. */
2279
- me(): Promise<WorkspaceIdentity>;
2280
- /** The org's enabled models with live prices. `{ active: true }` returns only
2281
- * the models that can be metered right now.
2282
- * `{ active: false }` returns only archived ones; omitting it returns
2283
- * both. See `activeQuery` — the API itself only supports `true`. */
2284
- models(params?: {
2285
- active?: boolean;
2286
- }): Promise<Model[]>;
2287
- }
2288
-
2289
1778
  /**
2290
1779
  * The ClockNext client.
2291
1780
  *
@@ -2304,11 +1793,11 @@ declare class Workspace {
2304
1793
  * ```
2305
1794
  */
2306
1795
  declare class ClockNext {
2307
- /** Record + read usage signals (credit / wallet / outcome / unit). */
1796
+ /** Record usage signals (credit / wallet / outcome / unit) and read the usage log. */
2308
1797
  readonly signals: Signals;
2309
- /** Manage customers, their members, wallet, and balances. */
1798
+ /** Manage customers, their members, and balances. */
2310
1799
  readonly customers: Customers;
2311
- /** Define and manage billing plans. */
1800
+ /** List billing plans. */
2312
1801
  readonly plans: Plans;
2313
1802
  /** Subscribe customers to plans (purchases). */
2314
1803
  readonly purchases: Purchases;
@@ -2316,20 +1805,8 @@ declare class ClockNext {
2316
1805
  readonly invoices: Invoices;
2317
1806
  /** Read payments (paid invoices). */
2318
1807
  readonly payments: Payments;
2319
- /** Manage the credit-type catalog. */
2320
- readonly credits: Credits;
2321
- /** Manage the composite catalog — bundles billed as one thing. */
2322
- readonly composites: Composites;
2323
- /** Manage the outcome-type catalog. */
2324
- readonly outcomes: Outcomes;
2325
- /** Manage the unit-type catalog. */
2326
- readonly units: Units;
2327
- /** Configure threshold webhooks. */
2328
- readonly webhooks: Webhooks;
2329
1808
  /** Mint customer-portal embed tokens. */
2330
1809
  readonly portal: Portal;
2331
- /** Identify the workspace (sandbox/live) + list its models. `/me`, `/models`. */
2332
- readonly workspace: Workspace;
2333
1810
  private readonly cfg;
2334
1811
  private readonly flusher;
2335
1812
  constructor(config: ClockNextConfig);
@@ -2417,4 +1894,4 @@ declare class NetworkError extends ClockNextError {
2417
1894
  });
2418
1895
  }
2419
1896
 
2420
- export { type AddMemberInput, AllowanceError, type ApiCustomer, AuthError, type BillingCycle, type BillingMode, ClockNext, type ClockNextConfig, ClockNextError, type ClockNextErrorCode, type ComponentType, type Composite, type CompositeAdjustInput, type CompositeCatalogueRef, type CompositeCompletionInput, type CompositeCompletionResult, type CompositeComponentInput, type CompositeTag, ConflictError, type CostPoint, type CostStats, type CreateCompositeInput, type CreateCreditInput, type CreateCustomerInput, type CreateOutcomeInput, type CreatePlanInput, type CreatePurchaseInput, type CreateUnitInput, type Credit, type CreditAdjustInput, type CreditAnalytics, type CreditBalance, type CreditComponentInput, type CreditDetail, type CreditInput, type CreditSignal, type CustomerBalances, type CustomerList, type CustomerPlan, type CustomerPlanDetails, type CustomerProfileInput, type DropReason, type FetchLike, type FlatComponentInput, type FlatUnitInput, ForbiddenError, type Invoice, type InvoiceDetail, type InvoiceLineItem, type InvoiceListRow, type InvoiceParty, type InvoicePlanSnapshot, type InvoiceStatus, type Logger, type Member, type MemberProfile, type Model, type ModelBundleEntry, NetworkError, NotFoundError, type Outcome, type OutcomeAdjustInput, type OutcomeAnalytics, type OutcomeBalance, type OutcomeCompletionInput, type OutcomeCompletionResult, type OutcomeComponentInput, type OutcomeDetail, type OutcomeInput, type OutcomeSignal, type OutcomeStepInput, type PayLink, type PaymentDetail, type PaymentRow, type Plan, type PlanComponent, type PlanComponentInput, type PlanDetail, PlanError, type PlanKind, type PlanRef, type PlanType, type PortalToken, type PortalTokenInput, type Purchase, type PurchaseDetail, type PurchaseStatus, RateLimitError, type RemovedMember, type SerializedOutcomeAttribution, type SerializedRuleApplication, type SerializedUnitUsage, type SerializedUsageLog, ServerError, type Signal, type SignalDelivery, type SignalStatus, type SignalType, type ThresholdKind, type TieredUnitInput, type Tokens, type TrackResult, type Unit, type UnitAdjustInput, type UnitBalance, type UnitComponentInput, type UnitCustomerRow, type UnitDetail, type UnitInput, type UnitPricingType, type UnitTier, type UnitTierInput, type UnitTrackResult, type UnitUsageList, type UnitUsageRow, type UpdateCreditInput, type UpdateMemberInput, type UpdateOutcomeInput, type UpdatePlanInput, type UpdateUnitInput, type UpsertWebhookInput, type UsageBalance, type UsageList, type UsageLogAppliedRule, type UsageLogEntry, type UsageLogListParams, type UsageLogOutcomeAttribution, type UsageLogPage, type UsageLogPeriod, ValidationError, type WalletComponentInput, type WalletEntitlementKind, type WalletEntryInput, type WalletInput, type WalletList, type WalletSignal, type WalletTransaction, type WalletTransactionSource, type WalletTransactionType, type Webhook, type WorkspaceIdentity, signalToWire };
1897
+ export { type AddMemberInput, type AdjustResult, AllowanceError, type ApiCustomer, AuthError, type BillingCycle, type BillingMode, ClockNext, type ClockNextConfig, ClockNextError, type ClockNextErrorCode, type ComponentType, type CompositeAdjustInput, type CompositeCompletionInput, type CompositeCompletionResult, type CompositeTag, ConflictError, type CreateCustomerInput, type CreatePurchaseInput, type CreditAdjustInput, type CreditBalance, type CreditInput, type CreditSignal, type CustomerBalances, type CustomerList, type CustomerPlan, type CustomerPlanDetails, type CustomerProfileInput, type CustomerRef, type DropReason, type FetchLike, ForbiddenError, type Invoice, type InvoiceDetail, type InvoiceLineItem, type InvoiceListRow, type InvoiceParty, type InvoicePlanSnapshot, type InvoiceStatus, type Logger, type Member, type MemberProfile, NetworkError, NotFoundError, type OutcomeAdjustInput, type OutcomeBalance, type OutcomeCompletionInput, type OutcomeCompletionResult, type OutcomeInput, type OutcomeSignal, type PayLink, type PaymentDetail, type PaymentRow, type Plan, type PlanComponent, PlanError, type PlanKind, type PlanRef, type PlanType, type PortalToken, type PortalTokenInput, type Purchase, type PurchaseDetail, type PurchaseStatus, RateLimitError, type RecurringGrantInput, type RecurringGrantResult, type RemovedMember, type SerializedOutcomeAttribution, type SerializedRuleApplication, type SerializedUnitUsage, type SerializedUsageLog, ServerError, type Signal, type SignalDelivery, type SignalStatus, type SignalType, type Tokens, type TrackResult, type UnitAdjustInput, type UnitBalance, type UnitInput, type UnitTrackResult, type UpdateMemberInput, type UsageBalance, type UsageLogAppliedRule, type UsageLogEntry, type UsageLogListParams, type UsageLogOutcomeAttribution, type UsageLogPage, type UsageLogPeriod, ValidationError, type WalletAdjustInput, type WalletInput, type WalletPool, type WalletSignal, signalToWire };