@clocknext/sdk 0.15.0 → 0.16.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.cts CHANGED
@@ -15,12 +15,15 @@ type SignalStatus = "SUCCESS" | "FAILURE" | "PENDING";
15
15
  /**
16
16
  * Token counts for a signal. `input` and `output` are required — every metered
17
17
  * call has them, and the server requires them. `cache` (provider-specific
18
- * prompt-cache reads) is optional and defaults to 0 server-side when omitted.
18
+ * prompt-cache reads) and `cacheWrite` (tokens written into the prompt cache,
19
+ * priced at the model's separate cache-write rate) are optional and default to
20
+ * 0 server-side when omitted.
19
21
  */
20
22
  interface Tokens {
21
23
  input: number;
22
24
  output: number;
23
25
  cache?: number;
26
+ cacheWrite?: number;
24
27
  }
25
28
  /**
26
29
  * Groups a signal into one occurrence of a **composite** — a bundle of credits
@@ -239,7 +242,10 @@ interface SerializedUsageLog {
239
242
  member: string | null;
240
243
  inputTokens: number;
241
244
  outputTokens: number;
245
+ /** Cache-read tokens. */
242
246
  cacheTokens: number;
247
+ /** Cache-write tokens, priced separately from cache reads. */
248
+ cacheWriteTokens: number;
243
249
  /** Total credits deducted: the call's real per-model provider cost as a
244
250
  * fraction of the credit's base price (i.e. cost + your margin), plus any
245
251
  * credit-rule add-ons; 0 for wallet-money calls. */
@@ -392,7 +398,10 @@ interface UsageLogEntry {
392
398
  usage: {
393
399
  inputTokens: number;
394
400
  outputTokens: number;
401
+ /** Cache-read tokens. */
395
402
  cacheTokens: number;
403
+ /** Cache-write tokens, priced separately from cache reads. */
404
+ cacheWriteTokens: number;
396
405
  };
397
406
  /** Formatted USD strings (e.g. `"$0.0064"`). */
398
407
  cost: {
@@ -527,8 +536,25 @@ interface UnitBalance {
527
536
  granted: number;
528
537
  remaining: number;
529
538
  }
530
- /** Wallet / credit / outcome / unit balances for a customer's active plan
531
- * (`customers.balances()`). */
539
+ /** One prepaid (ADVANCE) composite pool on a customer's plan. */
540
+ interface CompositeBalance {
541
+ compositeId: string;
542
+ /** The tag signals send in their `composite` block. */
543
+ refId: string;
544
+ name: string;
545
+ /** The pool size the plan grants this cycle. */
546
+ granted: number;
547
+ /** Slots claimed this cycle — one per distinct tag value. */
548
+ used: number;
549
+ /** `granted - used` plus this cycle's manual adjustments. May be negative:
550
+ * running past the pool is allowed and carries into the next cycle. */
551
+ remaining: number;
552
+ /** What `granted` was before the pool was ever resized for this customer;
553
+ * `null` if it never was. */
554
+ originalGranted: number | null;
555
+ }
556
+ /** Wallet / credit / outcome / unit balances and composite pools for a
557
+ * customer's active plan (`customers.balances()`). */
532
558
  interface CustomerBalances {
533
559
  customerId: string;
534
560
  currency: {
@@ -536,18 +562,21 @@ interface CustomerBalances {
536
562
  rateUsd: number;
537
563
  };
538
564
  hasPlan: boolean;
539
- /** `null` when the plan has no Wallet component. */
565
+ /** Both wallet balances, in USD. Always present. */
540
566
  wallet: {
541
- balanceUsd: number;
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;
567
+ /** The ordinary wallet — always reported, also when the plan has no
568
+ * Wallet component or there's no plan. May be negative. */
569
+ balance: number;
570
+ /** The Reserved Wallet; absent when the org hasn't enabled it, otherwise
571
+ * present whether or not the plan has a Wallet. Never negative. */
572
+ reservedBalance?: number;
573
+ };
548
574
  credits: CreditBalance[];
549
575
  outcomes: OutcomeBalance[];
550
576
  units: UnitBalance[];
577
+ /** ADVANCE composite pools. A composite billed in ARREAR has no pool and
578
+ * isn't listed. */
579
+ composites: CompositeBalance[];
551
580
  }
552
581
  /** The customer's active plan (the `plan` field of `customers.plan()`);
553
582
  * `null` when the customer is unsubscribed. */
@@ -591,8 +620,8 @@ interface PortalToken {
591
620
  /** Seconds until expiry. */
592
621
  expiresIn: number;
593
622
  }
594
- /** How often a plan bills. `FREE` is a one-time grant; `EVERY_5_MIN` is a test cadence. */
595
- type BillingCycle = "MONTHLY" | "QUARTERLY" | "SEMI_ANNUAL" | "YEARLY" | "EVERY_5_MIN" | "FREE";
623
+ /** How often a plan bills. `FREE` is a one-time grant. */
624
+ type BillingCycle = "MONTHLY" | "QUARTERLY" | "SEMI_ANNUAL" | "YEARLY" | "FREE";
596
625
  type PlanType = "WALLET" | "BUNDLE";
597
626
  type PlanKind = "FLAT_PRICE" | "PAY_AS_YOU_GO" | "PAY_PER_SEAT";
598
627
  /**
@@ -606,7 +635,8 @@ type PlanKind = "FLAT_PRICE" | "PAY_AS_YOU_GO" | "PAY_PER_SEAT";
606
635
  type ComponentType = "WALLET" | "CREDIT" | "OUTCOME" | "UNIT" | "FLAT" | "PRICING_METRIC";
607
636
  /** ADVANCE bills up-front for the cycle; ARREAR bills for what was consumed. */
608
637
  type BillingMode = "ADVANCE" | "ARREAR";
609
- interface PlanComponent {
638
+ /** One line of a plan (`plan.entitlements[]`). */
639
+ interface PlanEntitlement {
610
640
  id: string;
611
641
  type: ComponentType;
612
642
  billingMode: BillingMode;
@@ -619,13 +649,17 @@ interface PlanComponent {
619
649
  targetName: string | null;
620
650
  quantity: number | null;
621
651
  amount: number | null;
652
+ /** ADVANCE credit / outcome / composite / wallet components: what's left at
653
+ * the end of a cycle carries into the next one instead of resetting.
654
+ * Always false for unit, flat and ARREAR components and on FREE plans. */
655
+ rollover: boolean;
622
656
  }
657
+ /** @deprecated Renamed to {@link PlanEntitlement} — a plan's lines are `entitlements` now. */
658
+ type PlanComponent = PlanEntitlement;
623
659
  interface Plan {
624
660
  id: string;
625
661
  name: string;
626
662
  description: string | null;
627
- type: PlanType;
628
- kind: PlanKind;
629
663
  billingCycle: BillingCycle;
630
664
  cost: number;
631
665
  /** Signed adjustment applied to the plan's headline price (default 0). */
@@ -633,10 +667,254 @@ interface Plan {
633
667
  /** When true, ARREAR consumption is funded from the customer's wallet as it
634
668
  * happens instead of being invoiced at cycle end. All-or-nothing per plan. */
635
669
  walletFundedArrear: boolean;
670
+ /** The workspace's primary currency when the plan was created. */
636
671
  currencyCode: string;
637
672
  isActive: boolean;
638
- components: PlanComponent[];
673
+ createdAt: string;
674
+ updatedAt: string;
675
+ /** The plan's lines — what a customer on it is granted or metered for. */
676
+ entitlements: PlanEntitlement[];
677
+ }
678
+ /** One line of a plan, as you send it to `plans.create()` / `plans.update()`.
679
+ * Set the id that matches `type`: `creditId` (CREDIT), `outcomeId`
680
+ * (OUTCOME), `unitId` (UNIT) or `compositeId` (PRICING_METRIC — a
681
+ * composite). The lines `plans.get()` returns can be sent back as they are. */
682
+ interface PlanEntitlementInput {
683
+ type: ComponentType;
684
+ billingMode: BillingMode;
685
+ creditId?: string | null;
686
+ outcomeId?: string | null;
687
+ unitId?: string | null;
688
+ compositeId?: string | null;
689
+ /** ADVANCE credit / outcome / unit / composite: granted each cycle (0 allowed). */
690
+ quantity?: number | null;
691
+ /** WALLET (ADVANCE prepaid balance, $0 allowed) or FLAT (fee, above $0), in USD. */
692
+ amount?: number | null;
693
+ /** ADVANCE credit / outcome / composite / wallet: carry leftovers into the next cycle. */
694
+ rollover?: boolean;
695
+ }
696
+ /** `plans.create()` body. The plan's currency is the workspace's primary
697
+ * currency — it can't be chosen. A new plan is active; retire it with
698
+ * `plans.archive()`. */
699
+ interface CreatePlanInput {
700
+ name: string;
701
+ billingCycle: BillingCycle;
702
+ description?: string | null;
703
+ /** Pay ARREAR usage from the prepaid wallet as it happens. Needs an ADVANCE
704
+ * WALLET line and at least one ARREAR credit / outcome / unit / composite. */
705
+ walletFundedArrear?: boolean;
706
+ /** Signed rounding nudge (USD) on the due-at-purchase total. */
707
+ priceAdjustment?: number;
708
+ /** At least one line. At most one WALLET and one FLAT. */
709
+ entitlements: PlanEntitlementInput[];
710
+ }
711
+ /** `plans.update()` body — a PARTIAL update: only the fields you send change.
712
+ * `entitlements`, when sent, is the complete new list. */
713
+ type UpdatePlanInput = Partial<CreatePlanInput>;
714
+ /** One model line of a credit's / outcome step's pricing bundle, as returned. */
715
+ interface ModelBundleLine {
716
+ /** The workspace's model row id (`id` from the Models API). */
717
+ orgModelId: string;
718
+ /** The model's display name, filled in by the server. */
719
+ modelName: string;
720
+ /** Average tokens one LLM call uses on this model. */
721
+ averageTokensPerLLMCall: number;
722
+ /** Whole-percent split of those tokens; the four add up to 100. */
723
+ input: number;
724
+ output: number;
725
+ cache: number;
726
+ /** 0 on a model with no cache-write price. */
727
+ cacheWrite: number;
728
+ }
729
+ /** One model line as you send it. Several lines (one per model) are allowed;
730
+ * the price is the sum of their costs, worked out on the server from the
731
+ * models' live prices. */
732
+ interface ModelBundleLineInput {
733
+ orgModelId: string;
734
+ /** Above 0. */
735
+ averageTokensPerLLMCall: number;
736
+ input: number;
737
+ output: number;
738
+ cache: number;
739
+ /** Default 0. Only on a model that has a cache-write price. */
740
+ cacheWrite?: number;
639
741
  }
742
+ /** A credit — a token-metered entitlement your product draws down by its
743
+ * `agentKey`. */
744
+ interface Credit {
745
+ id: string;
746
+ name: string;
747
+ /** What a credit signal names; unique in the workspace. */
748
+ agentKey: string;
749
+ description: string | null;
750
+ /** Sum of the bundle lines' tokens (display figure). */
751
+ tokensPerCredit: number;
752
+ /** Cost of one credit, worked out from `modelBundle`. */
753
+ basePrice: number;
754
+ modelBundle: ModelBundleLine[];
755
+ marginPercent: number;
756
+ /** `basePrice` plus the margin — what a customer pays per credit. */
757
+ pricePerCredit: number;
758
+ isActive: boolean;
759
+ createdAt: string;
760
+ updatedAt: string;
761
+ }
762
+ /** `credits.create()` body. The price is always worked out on the server from
763
+ * `modelBundle` — it is never typed in. */
764
+ interface CreateCreditInput {
765
+ name: string;
766
+ agentKey: string;
767
+ /** -100 or more. */
768
+ marginPercent: number;
769
+ /** At least one line. */
770
+ modelBundle: ModelBundleLineInput[];
771
+ description?: string | null;
772
+ }
773
+ /** `credits.update()` body — PARTIAL. Send `modelBundle` to re-price; leave it
774
+ * out to keep the stored base price (a new margin is applied on top). */
775
+ type UpdateCreditInput = Partial<CreateCreditInput>;
776
+ /** An outcome — a multi-step deliverable billed per completed outcome. */
777
+ interface Outcome {
778
+ id: string;
779
+ name: string;
780
+ /** The outcome's own key (unique in the workspace) — not what a step signal
781
+ * names; each step has its own `agentKey`. */
782
+ agentKey: string;
783
+ description: string | null;
784
+ isActive: boolean;
785
+ /** Sum of the steps' base prices. */
786
+ basePrice: number;
787
+ marginPercent: number;
788
+ pricePerOutcome: number;
789
+ createdAt: string;
790
+ updatedAt: string;
791
+ }
792
+ /** One step of an outcome. */
793
+ interface OutcomeStep {
794
+ /** Send it back on `outcomes.update()` to keep this step. */
795
+ id: string;
796
+ name: string;
797
+ /** What an outcome step signal names; unique in the workspace. */
798
+ agentKey: string;
799
+ order: number;
800
+ basePrice: number;
801
+ modelBundle: ModelBundleLine[];
802
+ }
803
+ /** `outcomes.get()` — the outcome with its steps in full. */
804
+ interface OutcomeWithSteps extends Outcome {
805
+ steps: OutcomeStep[];
806
+ }
807
+ /** One step as you send it. */
808
+ interface OutcomeStepInput {
809
+ /** An existing step's id, to keep that step (update only). A step sent
810
+ * without an id but with an existing step's `agentKey` is that step too. */
811
+ id?: string;
812
+ name: string;
813
+ agentKey: string;
814
+ /** Required for a new step. Leave it out on an existing step to keep its
815
+ * price. */
816
+ modelBundle?: ModelBundleLineInput[];
817
+ }
818
+ /** `outcomes.create()` body. */
819
+ interface CreateOutcomeInput {
820
+ name: string;
821
+ agentKey: string;
822
+ /** -100 or more. */
823
+ marginPercent: number;
824
+ /** 1–50 steps; names and agent keys unique. */
825
+ steps: OutcomeStepInput[];
826
+ description?: string | null;
827
+ }
828
+ /** `outcomes.update()` body — PARTIAL. Leave `steps` out to leave the steps
829
+ * alone; send it and it is the complete step list (stored steps left out are
830
+ * removed). */
831
+ type UpdateOutcomeInput = Partial<CreateOutcomeInput>;
832
+ /** How a unit is priced. */
833
+ type UnitPricingType = "FLAT" | "SLAB" | "VOLUME";
834
+ /** One price band of a SLAB / VOLUME unit. */
835
+ interface UnitTier {
836
+ id: string;
837
+ /** Inclusive upper bound; `null` on the last tier ("and above"). */
838
+ upTo: number | null;
839
+ /** Per-unit price for this band. */
840
+ price: number;
841
+ order: number;
842
+ }
843
+ /** A unit — a fixed-price, non-LLM event (an upload, a seat, an API call). */
844
+ interface Unit {
845
+ id: string;
846
+ name: string;
847
+ /** What a unit signal names; unique in the workspace. */
848
+ agentKey: string;
849
+ description: string | null;
850
+ pricingType: UnitPricingType;
851
+ /** FLAT only. */
852
+ flatPrice: number;
853
+ /** SLAB / VOLUME only. */
854
+ tiers: UnitTier[];
855
+ isActive: boolean;
856
+ createdAt: string;
857
+ updatedAt: string;
858
+ createdByName: string | null;
859
+ }
860
+ /** `units.create()` body. */
861
+ interface CreateUnitInput {
862
+ name: string;
863
+ agentKey: string;
864
+ pricingType: UnitPricingType;
865
+ /** FLAT only. */
866
+ flatPrice?: number;
867
+ /** SLAB / VOLUME: 1–50 tiers, `upTo` rising; the last one `upTo: null`. */
868
+ tiers?: {
869
+ upTo: number | null;
870
+ price: number;
871
+ }[];
872
+ description?: string | null;
873
+ }
874
+ /** `units.update()` body — PARTIAL. `tiers`, when sent, is the complete list. */
875
+ type UpdateUnitInput = Partial<CreateUnitInput>;
876
+ /** A catalogue item a composite wraps. */
877
+ interface CompositeItem {
878
+ id: string;
879
+ name: string;
880
+ agentKey: string;
881
+ }
882
+ /** A composite — several credits / outcomes / units grouped under one tag and
883
+ * billed as ONE thing, per completed occurrence, once a plan sells it. */
884
+ interface Composite {
885
+ id: string;
886
+ name: string;
887
+ /** The tag your signals send in their `composite` block. */
888
+ refId: string;
889
+ description: string | null;
890
+ /** USD per completed occurrence, once a plan sells it. */
891
+ price: number;
892
+ isActive: boolean;
893
+ createdAt: string;
894
+ updatedAt: string;
895
+ entitlements: {
896
+ credits: CompositeItem[];
897
+ outcomes: CompositeItem[];
898
+ units: CompositeItem[];
899
+ };
900
+ }
901
+ /** `composites.create()` body. */
902
+ interface CreateCompositeInput {
903
+ name: string;
904
+ refId: string;
905
+ price: number;
906
+ description?: string | null;
907
+ /** At least one id across the three lists. Every item must be active, and a
908
+ * unit must be FLAT-priced. */
909
+ entitlements: {
910
+ creditIds?: string[];
911
+ outcomeIds?: string[];
912
+ unitIds?: string[];
913
+ };
914
+ }
915
+ /** `composites.update()` body — PARTIAL. `entitlements`, when sent, is the
916
+ * complete new set. */
917
+ type UpdateCompositeInput = Partial<CreateCompositeInput>;
640
918
  type PurchaseStatus = "SCHEDULED" | "ACTIVE" | "CANCELLED";
641
919
  type CreatePurchaseInput = CustomerRef & {
642
920
  planId: string;
@@ -871,11 +1149,12 @@ interface UpdateMemberInput {
871
1149
  email?: string;
872
1150
  }
873
1151
  /**
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}).
1152
+ * Which of a customer's two wallet balances an entry moves: `"main"` (the
1153
+ * ordinary wallet) or `"reserved"` (the Reserved Wallet — an org-gated second
1154
+ * balance behind it; see {@link WalletAdjustInput.pool}). Lowercase only —
1155
+ * the API refuses `"MAIN"` / `"RESERVED"`.
877
1156
  */
878
- type WalletPool = "MAIN" | "RESERVED";
1157
+ type WalletPool = "main" | "reserved";
879
1158
  /** Top up (positive) or draw down (negative) a customer's wallet. `delta` is
880
1159
  * a non-zero amount in USD (cents allowed); absolute value ≤ 10,000,000. No
881
1160
  * `agentKey` — a customer has exactly one wallet. The wallet can always be
@@ -886,16 +1165,17 @@ interface WalletAdjustInput {
886
1165
  delta: number;
887
1166
  notes?: string;
888
1167
  /**
889
- * Which balance to move. Default `"MAIN"`, the ordinary wallet.
1168
+ * Which balance to move. Default `"main"`, the ordinary wallet (leave it
1169
+ * out; `null` is refused).
890
1170
  *
891
- * `"RESERVED"` moves the Reserved Wallet instead — a second balance behind
1171
+ * `"reserved"` moves the Reserved Wallet instead — a second balance behind
892
1172
  * the wallet that a wallet-funded Arrear charge draws on once the wallet
893
1173
  * runs out (Wallet → Reserved down to 0 → Wallet goes negative). It must be
894
1174
  * switched on for the org (Settings → Organisation → "Enable Reserved
895
1175
  * balance in wallet"), else this is a `PlanError`. It never goes negative:
896
1176
  * a reduce below zero is refused (an `AllowanceError`), not capped — drawing
897
1177
  * down to exactly 0 is fine. `remaining` is then the Reserved balance. A
898
- * `"MAIN"` adjustment never touches it.
1178
+ * `"main"` adjustment never touches it.
899
1179
  */
900
1180
  pool?: WalletPool;
901
1181
  /**
@@ -1310,6 +1590,75 @@ declare class Transport {
1310
1590
  private buildUrl;
1311
1591
  }
1312
1592
 
1593
+ /**
1594
+ * The `composites` resource — several credits / outcomes / units grouped under
1595
+ * one tag (`refId`) and billed as ONE thing per completed occurrence.
1596
+ * `/api/v1/composites`.
1597
+ *
1598
+ * Creating a composite charges nobody: it only bills once a plan sells it as
1599
+ * a `PRICING_METRIC` entitlement (`plans.create()` with its `compositeId`).
1600
+ *
1601
+ * There is no `delete()` — the API never deletes catalogue items. Retire a
1602
+ * composite with `archive()` (new signals stop resolving to it; its history is
1603
+ * kept); `unarchive()` brings it back.
1604
+ */
1605
+ declare class Composites {
1606
+ private readonly transport;
1607
+ constructor(transport: Transport);
1608
+ /** List them. `{ active: true }` returns only active ones, `{ active: false }`
1609
+ * only archived ones; omit it for both. */
1610
+ list(params?: {
1611
+ active?: boolean;
1612
+ }): Promise<Composite[]>;
1613
+ /** One composite's configuration. */
1614
+ get(id: string): Promise<Composite>;
1615
+ /** Create one. It starts active. Not retried on failure — a retry could
1616
+ * create a second row. */
1617
+ create(input: CreateCompositeInput): Promise<Composite>;
1618
+ /** PARTIAL update: only the fields you send change. `entitlements`, when
1619
+ * sent, is the complete new set. Renaming `refId` cuts live traffic over at
1620
+ * once — ship the new tag to your callers first. */
1621
+ update(id: string, input: UpdateCompositeInput): Promise<Composite>;
1622
+ /** Retire it (`isActive` → false). Nothing is deleted. Safe to retry. */
1623
+ archive(id: string): Promise<Composite>;
1624
+ /** Bring an archived one back (`isActive` → true). Safe to retry. */
1625
+ unarchive(id: string): Promise<Composite>;
1626
+ }
1627
+
1628
+ /**
1629
+ * The `credits` resource — the token-metered credits your product draws down
1630
+ * by `agentKey`. `/api/v1/credits`.
1631
+ *
1632
+ * Pricing is never typed in: `create()` takes a `modelBundle` (one line per
1633
+ * model, each with `averageTokensPerLLMCall` and its input / output / cache /
1634
+ * cacheWrite split) and the server works out `basePrice` and
1635
+ * `pricePerCredit` from the models' live prices.
1636
+ *
1637
+ * There is no `delete()` — the API never deletes catalogue items. Retire a
1638
+ * credit with `archive()`; `unarchive()` brings it back unchanged.
1639
+ */
1640
+ declare class Credits {
1641
+ private readonly transport;
1642
+ constructor(transport: Transport);
1643
+ /** List them. `{ active: true }` returns only active ones, `{ active: false }`
1644
+ * only archived ones; omit it for both. */
1645
+ list(params?: {
1646
+ active?: boolean;
1647
+ }): Promise<Credit[]>;
1648
+ /** One credit's configuration. */
1649
+ get(id: string): Promise<Credit>;
1650
+ /** Create one. It starts active. Not retried on failure — a retry could
1651
+ * create a second row. */
1652
+ create(input: CreateCreditInput): Promise<Credit>;
1653
+ /** PARTIAL update: only the fields you send change. Send `modelBundle` to
1654
+ * re-price; leave it out to keep the stored base price. */
1655
+ update(id: string, input: UpdateCreditInput): Promise<Credit>;
1656
+ /** Retire it (`isActive` → false). Nothing is deleted. Safe to retry. */
1657
+ archive(id: string): Promise<Credit>;
1658
+ /** Bring an archived one back (`isActive` → true). Safe to retry. */
1659
+ unarchive(id: string): Promise<Credit>;
1660
+ }
1661
+
1313
1662
  /**
1314
1663
  * The `customers` resource — full CRUD over the org's customers plus the
1315
1664
  * read-only insight endpoints (balances / plan). Every call is scoped
@@ -1414,7 +1763,7 @@ declare class Customers {
1414
1763
  * Top up (positive `delta`) or draw down (negative `delta`) a customer's
1415
1764
  * wallet, in USD — allowed whatever the customer's plan. `remaining` is the
1416
1765
  * resulting USD balance. No `agentKey` — a customer has exactly one wallet.
1417
- * Pass `pool: "RESERVED"` to move the Reserved Wallet instead (then
1766
+ * Pass `pool: "reserved"` to move the Reserved Wallet instead (then
1418
1767
  * `remaining` is its balance). `POST …/:id/wallet/adjust`.
1419
1768
  */
1420
1769
  adjustWallet(id: string, input: WalletAdjustInput): Promise<AdjustResult>;
@@ -1478,6 +1827,40 @@ declare class Invoices {
1478
1827
  payLink(id: string): Promise<PayLink>;
1479
1828
  }
1480
1829
 
1830
+ /**
1831
+ * The `outcomes` resource — multi-step deliverables billed per completed
1832
+ * outcome. `/api/v1/outcomes`.
1833
+ *
1834
+ * `list()` and every write return the outcome without its steps; `get()`
1835
+ * returns it with every step in full (ids included). Each new step is priced
1836
+ * from its own `modelBundle`, on the server.
1837
+ *
1838
+ * There is no `delete()` — the API never deletes catalogue items. Retire an
1839
+ * outcome with `archive()`; `unarchive()` brings it back unchanged.
1840
+ */
1841
+ declare class Outcomes {
1842
+ private readonly transport;
1843
+ constructor(transport: Transport);
1844
+ /** List them. `{ active: true }` returns only active ones, `{ active: false }`
1845
+ * only archived ones; omit it for both. */
1846
+ list(params?: {
1847
+ active?: boolean;
1848
+ }): Promise<Outcome[]>;
1849
+ /** One outcome's configuration, with every step in full. */
1850
+ get(id: string): Promise<OutcomeWithSteps>;
1851
+ /** Create one. It starts active. Not retried on failure — a retry could
1852
+ * create a second row. */
1853
+ create(input: CreateOutcomeInput): Promise<Outcome>;
1854
+ /** PARTIAL update: only the fields you send change. Leave `steps` out to
1855
+ * leave the steps alone; send it and it is the complete list — pass each
1856
+ * existing step's `id` (or its same `agentKey`) to keep it. */
1857
+ update(id: string, input: UpdateOutcomeInput): Promise<Outcome>;
1858
+ /** Retire it (`isActive` → false). Nothing is deleted. Safe to retry. */
1859
+ archive(id: string): Promise<Outcome>;
1860
+ /** Bring an archived one back (`isActive` → true). Safe to retry. */
1861
+ unarchive(id: string): Promise<Outcome>;
1862
+ }
1863
+
1481
1864
  /**
1482
1865
  * The `payments` resource — read-only. A payment is a PAID invoice; the `id`
1483
1866
  * used here is that underlying invoice id. `/api/v1/payments`.
@@ -1495,9 +1878,14 @@ declare class Payments {
1495
1878
  }
1496
1879
 
1497
1880
  /**
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`.
1881
+ * The `plans` resource — the billing plans customers subscribe to. Each plan
1882
+ * is a set of `entitlements` (wallet / credit / outcome / unit / composite /
1883
+ * flat lines) billed on a cycle. `/api/v1/plans`.
1884
+ *
1885
+ * A plan's currency is the workspace's primary currency; it can't be chosen.
1886
+ * There is no `delete()` — the API never deletes plans, so customers already
1887
+ * on one keep what they bought. Retire a plan with `archive()`; `unarchive()`
1888
+ * makes it purchasable again.
1501
1889
  */
1502
1890
  declare class Plans {
1503
1891
  private readonly transport;
@@ -1508,6 +1896,20 @@ declare class Plans {
1508
1896
  list(params?: {
1509
1897
  active?: boolean;
1510
1898
  }): Promise<Plan[]>;
1899
+ /** One plan's configuration. */
1900
+ get(id: string): Promise<Plan>;
1901
+ /** Create a plan. It starts active. Not retried on failure — a retry could
1902
+ * create a second plan. */
1903
+ create(input: CreatePlanInput): Promise<Plan>;
1904
+ /** PARTIAL update: only the fields you send change. `entitlements`, when
1905
+ * sent, is the complete new list — the list `get()` returned can be sent
1906
+ * back as it is. Changes apply to new purchases only. */
1907
+ update(id: string, input: UpdatePlanInput): Promise<Plan>;
1908
+ /** Retire a plan (`isActive` → false): it can't be bought any more; customers
1909
+ * already on it are unaffected. Safe to retry. */
1910
+ archive(id: string): Promise<Plan>;
1911
+ /** Make an archived plan purchasable again (`isActive` → true). Safe to retry. */
1912
+ unarchive(id: string): Promise<Plan>;
1511
1913
  }
1512
1914
 
1513
1915
  /**
@@ -1775,6 +2177,35 @@ declare class Signals {
1775
2177
  usageLog(params: UsageLogListParams): Promise<UsageLogPage>;
1776
2178
  }
1777
2179
 
2180
+ /**
2181
+ * The `units` resource — fixed-price, non-LLM events (uploads, seats, API
2182
+ * calls), priced FLAT, SLAB or VOLUME. `/api/v1/units`.
2183
+ *
2184
+ * There is no `delete()` — the API never deletes catalogue items. Retire a
2185
+ * unit with `archive()`; `unarchive()` brings it back unchanged.
2186
+ */
2187
+ declare class Units {
2188
+ private readonly transport;
2189
+ constructor(transport: Transport);
2190
+ /** List them. `{ active: true }` returns only active ones, `{ active: false }`
2191
+ * only archived ones; omit it for both. */
2192
+ list(params?: {
2193
+ active?: boolean;
2194
+ }): Promise<Unit[]>;
2195
+ /** One unit's configuration. */
2196
+ get(id: string): Promise<Unit>;
2197
+ /** Create one. It starts active. Not retried on failure — a retry could
2198
+ * create a second row. */
2199
+ create(input: CreateUnitInput): Promise<Unit>;
2200
+ /** PARTIAL update: only the fields you send change. `tiers`, when sent, is
2201
+ * the complete new tier list. */
2202
+ update(id: string, input: UpdateUnitInput): Promise<Unit>;
2203
+ /** Retire it (`isActive` → false). Nothing is deleted. Safe to retry. */
2204
+ archive(id: string): Promise<Unit>;
2205
+ /** Bring an archived one back (`isActive` → true). Safe to retry. */
2206
+ unarchive(id: string): Promise<Unit>;
2207
+ }
2208
+
1778
2209
  /**
1779
2210
  * The ClockNext client.
1780
2211
  *
@@ -1797,8 +2228,16 @@ declare class ClockNext {
1797
2228
  readonly signals: Signals;
1798
2229
  /** Manage customers, their members, and balances. */
1799
2230
  readonly customers: Customers;
1800
- /** List billing plans. */
2231
+ /** Billing plans: list, get, create, update, archive, unarchive. */
1801
2232
  readonly plans: Plans;
2233
+ /** Credits: list, get, create, update, archive, unarchive (no delete). */
2234
+ readonly credits: Credits;
2235
+ /** Outcomes: list, get, create, update, archive, unarchive (no delete). */
2236
+ readonly outcomes: Outcomes;
2237
+ /** Units: list, get, create, update, archive, unarchive (no delete). */
2238
+ readonly units: Units;
2239
+ /** Composites: list, get, create, update, archive, unarchive (no delete). */
2240
+ readonly composites: Composites;
1802
2241
  /** Subscribe customers to plans (purchases). */
1803
2242
  readonly purchases: Purchases;
1804
2243
  /** Read invoices and mint hosted pay links. */
@@ -1894,4 +2333,4 @@ declare class NetworkError extends ClockNextError {
1894
2333
  });
1895
2334
  }
1896
2335
 
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 };
2336
+ export { type AddMemberInput, type AdjustResult, AllowanceError, type ApiCustomer, AuthError, type BillingCycle, type BillingMode, ClockNext, type ClockNextConfig, ClockNextError, type ClockNextErrorCode, type ComponentType, type Composite, type CompositeAdjustInput, type CompositeBalance, type CompositeCompletionInput, type CompositeCompletionResult, type CompositeItem, type CompositeTag, ConflictError, type CreateCompositeInput, type CreateCreditInput, type CreateCustomerInput, type CreateOutcomeInput, type CreatePlanInput, type CreatePurchaseInput, type CreateUnitInput, type Credit, 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, type ModelBundleLine, type ModelBundleLineInput, NetworkError, NotFoundError, type Outcome, type OutcomeAdjustInput, type OutcomeBalance, type OutcomeCompletionInput, type OutcomeCompletionResult, type OutcomeInput, type OutcomeSignal, type OutcomeStep, type OutcomeStepInput, type OutcomeWithSteps, type PayLink, type PaymentDetail, type PaymentRow, type Plan, type PlanComponent, type PlanEntitlement, type PlanEntitlementInput, 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 Unit, type UnitAdjustInput, type UnitBalance, type UnitInput, type UnitPricingType, type UnitTier, type UnitTrackResult, type UpdateCompositeInput, type UpdateCreditInput, type UpdateMemberInput, type UpdateOutcomeInput, type UpdatePlanInput, type UpdateUnitInput, type UsageBalance, type UsageLogAppliedRule, type UsageLogEntry, type UsageLogListParams, type UsageLogOutcomeAttribution, type UsageLogPage, type UsageLogPeriod, ValidationError, type WalletAdjustInput, type WalletInput, type WalletPool, type WalletSignal, signalToWire };