@clocknext/sdk 0.15.0 → 0.17.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
@@ -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,259 @@ 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 model's id — the same one a usage signal sends as `usage.model`.
717
+ * `null` only when the model was removed from the workspace after this
718
+ * bundle was saved (the line keeps its name and stored price). */
719
+ modelId: string | null;
720
+ /** The model's display name, filled in by the server. */
721
+ modelName: string;
722
+ /** Average tokens one LLM call uses on this model. */
723
+ averageTokensPerLLMCall: number;
724
+ /** Whole-percent split of those tokens; the four add up to 100. */
725
+ input: number;
726
+ output: number;
727
+ cache: number;
728
+ /** 0 on a model with no cache-write price. */
729
+ cacheWrite: number;
730
+ }
731
+ /** One model line as you send it. Several lines (one per model) are allowed;
732
+ * the price is the sum of their costs, worked out on the server from the
733
+ * models' live prices. */
734
+ interface ModelBundleLineInput {
735
+ /** The model's id, e.g. `"gpt-4o"` — the same one a usage signal sends as
736
+ * `usage.model`. Matched ignoring case; it must be enabled in your
737
+ * workspace. */
738
+ modelId: string;
739
+ /** Above 0. */
740
+ averageTokensPerLLMCall: number;
741
+ input: number;
742
+ output: number;
743
+ cache: number;
744
+ /** Default 0. Only on a model that has a cache-write price. */
745
+ cacheWrite?: number;
639
746
  }
747
+ /** A credit — a token-metered entitlement your product draws down by its
748
+ * `agentKey`. */
749
+ interface Credit {
750
+ id: string;
751
+ name: string;
752
+ /** What a credit signal names; unique in the workspace. */
753
+ agentKey: string;
754
+ description: string | null;
755
+ /** Sum of the bundle lines' tokens (display figure). */
756
+ tokensPerCredit: number;
757
+ /** Cost of one credit, worked out from `modelBundle`. */
758
+ basePrice: number;
759
+ modelBundle: ModelBundleLine[];
760
+ marginPercent: number;
761
+ /** `basePrice` plus the margin — what a customer pays per credit. */
762
+ pricePerCredit: number;
763
+ isActive: boolean;
764
+ createdAt: string;
765
+ updatedAt: string;
766
+ }
767
+ /** `credits.create()` body. The price is always worked out on the server from
768
+ * `modelBundle` — it is never typed in. */
769
+ interface CreateCreditInput {
770
+ name: string;
771
+ agentKey: string;
772
+ /** -100 or more. */
773
+ marginPercent: number;
774
+ /** At least one line. */
775
+ modelBundle: ModelBundleLineInput[];
776
+ description?: string | null;
777
+ }
778
+ /** `credits.update()` body — PARTIAL. Send `modelBundle` to re-price; leave it
779
+ * out to keep the stored base price (a new margin is applied on top). */
780
+ type UpdateCreditInput = Partial<CreateCreditInput>;
781
+ /** An outcome — a multi-step deliverable billed per completed outcome. */
782
+ interface Outcome {
783
+ id: string;
784
+ name: string;
785
+ /** The outcome's own key (unique in the workspace) — not what a step signal
786
+ * names; each step has its own `agentKey`. */
787
+ agentKey: string;
788
+ description: string | null;
789
+ isActive: boolean;
790
+ /** Sum of the steps' base prices. */
791
+ basePrice: number;
792
+ marginPercent: number;
793
+ pricePerOutcome: number;
794
+ createdAt: string;
795
+ updatedAt: string;
796
+ }
797
+ /** One step of an outcome. */
798
+ interface OutcomeStep {
799
+ /** Send it back on `outcomes.update()` to keep this step. */
800
+ id: string;
801
+ name: string;
802
+ /** What an outcome step signal names; unique in the workspace. */
803
+ agentKey: string;
804
+ order: number;
805
+ basePrice: number;
806
+ modelBundle: ModelBundleLine[];
807
+ }
808
+ /** `outcomes.get()` — the outcome with its steps in full. */
809
+ interface OutcomeWithSteps extends Outcome {
810
+ steps: OutcomeStep[];
811
+ }
812
+ /** One step as you send it. */
813
+ interface OutcomeStepInput {
814
+ /** An existing step's id, to keep that step (update only). A step sent
815
+ * without an id but with an existing step's `agentKey` is that step too. */
816
+ id?: string;
817
+ name: string;
818
+ agentKey: string;
819
+ /** Required for a new step. Leave it out on an existing step to keep its
820
+ * price. */
821
+ modelBundle?: ModelBundleLineInput[];
822
+ }
823
+ /** `outcomes.create()` body. */
824
+ interface CreateOutcomeInput {
825
+ name: string;
826
+ agentKey: string;
827
+ /** -100 or more. */
828
+ marginPercent: number;
829
+ /** 1–50 steps; names and agent keys unique. */
830
+ steps: OutcomeStepInput[];
831
+ description?: string | null;
832
+ }
833
+ /** `outcomes.update()` body — PARTIAL. Leave `steps` out to leave the steps
834
+ * alone; send it and it is the complete step list (stored steps left out are
835
+ * removed). */
836
+ type UpdateOutcomeInput = Partial<CreateOutcomeInput>;
837
+ /** How a unit is priced. */
838
+ type UnitPricingType = "FLAT" | "SLAB" | "VOLUME";
839
+ /** One price band of a SLAB / VOLUME unit. */
840
+ interface UnitTier {
841
+ id: string;
842
+ /** Inclusive upper bound; `null` on the last tier ("and above"). */
843
+ upTo: number | null;
844
+ /** Per-unit price for this band. */
845
+ price: number;
846
+ order: number;
847
+ }
848
+ /** A unit — a fixed-price, non-LLM event (an upload, a seat, an API call). */
849
+ interface Unit {
850
+ id: string;
851
+ name: string;
852
+ /** What a unit signal names; unique in the workspace. */
853
+ agentKey: string;
854
+ description: string | null;
855
+ pricingType: UnitPricingType;
856
+ /** FLAT only. */
857
+ flatPrice: number;
858
+ /** SLAB / VOLUME only. */
859
+ tiers: UnitTier[];
860
+ isActive: boolean;
861
+ createdAt: string;
862
+ updatedAt: string;
863
+ createdByName: string | null;
864
+ }
865
+ /** `units.create()` body. */
866
+ interface CreateUnitInput {
867
+ name: string;
868
+ agentKey: string;
869
+ pricingType: UnitPricingType;
870
+ /** FLAT only. */
871
+ flatPrice?: number;
872
+ /** SLAB / VOLUME: 1–50 tiers, `upTo` rising; the last one `upTo: null`. */
873
+ tiers?: {
874
+ upTo: number | null;
875
+ price: number;
876
+ }[];
877
+ description?: string | null;
878
+ }
879
+ /** `units.update()` body — PARTIAL. `tiers`, when sent, is the complete list. */
880
+ type UpdateUnitInput = Partial<CreateUnitInput>;
881
+ /** A catalogue item a composite wraps. */
882
+ interface CompositeItem {
883
+ id: string;
884
+ name: string;
885
+ agentKey: string;
886
+ }
887
+ /** A composite — several credits / outcomes / units grouped under one tag and
888
+ * billed as ONE thing, per completed occurrence, once a plan sells it. */
889
+ interface Composite {
890
+ id: string;
891
+ name: string;
892
+ /** The tag your signals send in their `composite` block. */
893
+ refId: string;
894
+ description: string | null;
895
+ /** USD per completed occurrence, once a plan sells it. */
896
+ price: number;
897
+ isActive: boolean;
898
+ createdAt: string;
899
+ updatedAt: string;
900
+ entitlements: {
901
+ credits: CompositeItem[];
902
+ outcomes: CompositeItem[];
903
+ units: CompositeItem[];
904
+ };
905
+ }
906
+ /** `composites.create()` body. */
907
+ interface CreateCompositeInput {
908
+ name: string;
909
+ refId: string;
910
+ price: number;
911
+ description?: string | null;
912
+ /** At least one id across the three lists. Every item must be active, and a
913
+ * unit must be FLAT-priced. */
914
+ entitlements: {
915
+ creditIds?: string[];
916
+ outcomeIds?: string[];
917
+ unitIds?: string[];
918
+ };
919
+ }
920
+ /** `composites.update()` body — PARTIAL. `entitlements`, when sent, is the
921
+ * complete new set. */
922
+ type UpdateCompositeInput = Partial<CreateCompositeInput>;
640
923
  type PurchaseStatus = "SCHEDULED" | "ACTIVE" | "CANCELLED";
641
924
  type CreatePurchaseInput = CustomerRef & {
642
925
  planId: string;
@@ -871,11 +1154,12 @@ interface UpdateMemberInput {
871
1154
  email?: string;
872
1155
  }
873
1156
  /**
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}).
1157
+ * Which of a customer's two wallet balances an entry moves: `"main"` (the
1158
+ * ordinary wallet) or `"reserved"` (the Reserved Wallet — an org-gated second
1159
+ * balance behind it; see {@link WalletAdjustInput.pool}). Lowercase only —
1160
+ * the API refuses `"MAIN"` / `"RESERVED"`.
877
1161
  */
878
- type WalletPool = "MAIN" | "RESERVED";
1162
+ type WalletPool = "main" | "reserved";
879
1163
  /** Top up (positive) or draw down (negative) a customer's wallet. `delta` is
880
1164
  * a non-zero amount in USD (cents allowed); absolute value ≤ 10,000,000. No
881
1165
  * `agentKey` — a customer has exactly one wallet. The wallet can always be
@@ -886,16 +1170,17 @@ interface WalletAdjustInput {
886
1170
  delta: number;
887
1171
  notes?: string;
888
1172
  /**
889
- * Which balance to move. Default `"MAIN"`, the ordinary wallet.
1173
+ * Which balance to move. Default `"main"`, the ordinary wallet (leave it
1174
+ * out; `null` is refused).
890
1175
  *
891
- * `"RESERVED"` moves the Reserved Wallet instead — a second balance behind
1176
+ * `"reserved"` moves the Reserved Wallet instead — a second balance behind
892
1177
  * the wallet that a wallet-funded Arrear charge draws on once the wallet
893
1178
  * runs out (Wallet → Reserved down to 0 → Wallet goes negative). It must be
894
1179
  * switched on for the org (Settings → Organisation → "Enable Reserved
895
1180
  * balance in wallet"), else this is a `PlanError`. It never goes negative:
896
1181
  * a reduce below zero is refused (an `AllowanceError`), not capped — drawing
897
1182
  * down to exactly 0 is fine. `remaining` is then the Reserved balance. A
898
- * `"MAIN"` adjustment never touches it.
1183
+ * `"main"` adjustment never touches it.
899
1184
  */
900
1185
  pool?: WalletPool;
901
1186
  /**
@@ -1310,6 +1595,75 @@ declare class Transport {
1310
1595
  private buildUrl;
1311
1596
  }
1312
1597
 
1598
+ /**
1599
+ * The `composites` resource — several credits / outcomes / units grouped under
1600
+ * one tag (`refId`) and billed as ONE thing per completed occurrence.
1601
+ * `/api/v1/composites`.
1602
+ *
1603
+ * Creating a composite charges nobody: it only bills once a plan sells it as
1604
+ * a `PRICING_METRIC` entitlement (`plans.create()` with its `compositeId`).
1605
+ *
1606
+ * There is no `delete()` — the API never deletes catalogue items. Retire a
1607
+ * composite with `archive()` (new signals stop resolving to it; its history is
1608
+ * kept); `unarchive()` brings it back.
1609
+ */
1610
+ declare class Composites {
1611
+ private readonly transport;
1612
+ constructor(transport: Transport);
1613
+ /** List them. `{ active: true }` returns only active ones, `{ active: false }`
1614
+ * only archived ones; omit it for both. */
1615
+ list(params?: {
1616
+ active?: boolean;
1617
+ }): Promise<Composite[]>;
1618
+ /** One composite's configuration. */
1619
+ get(id: string): Promise<Composite>;
1620
+ /** Create one. It starts active. Not retried on failure — a retry could
1621
+ * create a second row. */
1622
+ create(input: CreateCompositeInput): Promise<Composite>;
1623
+ /** PARTIAL update: only the fields you send change. `entitlements`, when
1624
+ * sent, is the complete new set. Renaming `refId` cuts live traffic over at
1625
+ * once — ship the new tag to your callers first. */
1626
+ update(id: string, input: UpdateCompositeInput): Promise<Composite>;
1627
+ /** Retire it (`isActive` → false). Nothing is deleted. Safe to retry. */
1628
+ archive(id: string): Promise<Composite>;
1629
+ /** Bring an archived one back (`isActive` → true). Safe to retry. */
1630
+ unarchive(id: string): Promise<Composite>;
1631
+ }
1632
+
1633
+ /**
1634
+ * The `credits` resource — the token-metered credits your product draws down
1635
+ * by `agentKey`. `/api/v1/credits`.
1636
+ *
1637
+ * Pricing is never typed in: `create()` takes a `modelBundle` (one line per
1638
+ * model, each with `averageTokensPerLLMCall` and its input / output / cache /
1639
+ * cacheWrite split) and the server works out `basePrice` and
1640
+ * `pricePerCredit` from the models' live prices.
1641
+ *
1642
+ * There is no `delete()` — the API never deletes catalogue items. Retire a
1643
+ * credit with `archive()`; `unarchive()` brings it back unchanged.
1644
+ */
1645
+ declare class Credits {
1646
+ private readonly transport;
1647
+ constructor(transport: Transport);
1648
+ /** List them. `{ active: true }` returns only active ones, `{ active: false }`
1649
+ * only archived ones; omit it for both. */
1650
+ list(params?: {
1651
+ active?: boolean;
1652
+ }): Promise<Credit[]>;
1653
+ /** One credit's configuration. */
1654
+ get(id: string): Promise<Credit>;
1655
+ /** Create one. It starts active. Not retried on failure — a retry could
1656
+ * create a second row. */
1657
+ create(input: CreateCreditInput): Promise<Credit>;
1658
+ /** PARTIAL update: only the fields you send change. Send `modelBundle` to
1659
+ * re-price; leave it out to keep the stored base price. */
1660
+ update(id: string, input: UpdateCreditInput): Promise<Credit>;
1661
+ /** Retire it (`isActive` → false). Nothing is deleted. Safe to retry. */
1662
+ archive(id: string): Promise<Credit>;
1663
+ /** Bring an archived one back (`isActive` → true). Safe to retry. */
1664
+ unarchive(id: string): Promise<Credit>;
1665
+ }
1666
+
1313
1667
  /**
1314
1668
  * The `customers` resource — full CRUD over the org's customers plus the
1315
1669
  * read-only insight endpoints (balances / plan). Every call is scoped
@@ -1414,7 +1768,7 @@ declare class Customers {
1414
1768
  * Top up (positive `delta`) or draw down (negative `delta`) a customer's
1415
1769
  * wallet, in USD — allowed whatever the customer's plan. `remaining` is the
1416
1770
  * resulting USD balance. No `agentKey` — a customer has exactly one wallet.
1417
- * Pass `pool: "RESERVED"` to move the Reserved Wallet instead (then
1771
+ * Pass `pool: "reserved"` to move the Reserved Wallet instead (then
1418
1772
  * `remaining` is its balance). `POST …/:id/wallet/adjust`.
1419
1773
  */
1420
1774
  adjustWallet(id: string, input: WalletAdjustInput): Promise<AdjustResult>;
@@ -1478,6 +1832,40 @@ declare class Invoices {
1478
1832
  payLink(id: string): Promise<PayLink>;
1479
1833
  }
1480
1834
 
1835
+ /**
1836
+ * The `outcomes` resource — multi-step deliverables billed per completed
1837
+ * outcome. `/api/v1/outcomes`.
1838
+ *
1839
+ * `list()` and every write return the outcome without its steps; `get()`
1840
+ * returns it with every step in full (ids included). Each new step is priced
1841
+ * from its own `modelBundle`, on the server.
1842
+ *
1843
+ * There is no `delete()` — the API never deletes catalogue items. Retire an
1844
+ * outcome with `archive()`; `unarchive()` brings it back unchanged.
1845
+ */
1846
+ declare class Outcomes {
1847
+ private readonly transport;
1848
+ constructor(transport: Transport);
1849
+ /** List them. `{ active: true }` returns only active ones, `{ active: false }`
1850
+ * only archived ones; omit it for both. */
1851
+ list(params?: {
1852
+ active?: boolean;
1853
+ }): Promise<Outcome[]>;
1854
+ /** One outcome's configuration, with every step in full. */
1855
+ get(id: string): Promise<OutcomeWithSteps>;
1856
+ /** Create one. It starts active. Not retried on failure — a retry could
1857
+ * create a second row. */
1858
+ create(input: CreateOutcomeInput): Promise<Outcome>;
1859
+ /** PARTIAL update: only the fields you send change. Leave `steps` out to
1860
+ * leave the steps alone; send it and it is the complete list — pass each
1861
+ * existing step's `id` (or its same `agentKey`) to keep it. */
1862
+ update(id: string, input: UpdateOutcomeInput): Promise<Outcome>;
1863
+ /** Retire it (`isActive` → false). Nothing is deleted. Safe to retry. */
1864
+ archive(id: string): Promise<Outcome>;
1865
+ /** Bring an archived one back (`isActive` → true). Safe to retry. */
1866
+ unarchive(id: string): Promise<Outcome>;
1867
+ }
1868
+
1481
1869
  /**
1482
1870
  * The `payments` resource — read-only. A payment is a PAID invoice; the `id`
1483
1871
  * used here is that underlying invoice id. `/api/v1/payments`.
@@ -1495,9 +1883,14 @@ declare class Payments {
1495
1883
  }
1496
1884
 
1497
1885
  /**
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`.
1886
+ * The `plans` resource — the billing plans customers subscribe to. Each plan
1887
+ * is a set of `entitlements` (wallet / credit / outcome / unit / composite /
1888
+ * flat lines) billed on a cycle. `/api/v1/plans`.
1889
+ *
1890
+ * A plan's currency is the workspace's primary currency; it can't be chosen.
1891
+ * There is no `delete()` — the API never deletes plans, so customers already
1892
+ * on one keep what they bought. Retire a plan with `archive()`; `unarchive()`
1893
+ * makes it purchasable again.
1501
1894
  */
1502
1895
  declare class Plans {
1503
1896
  private readonly transport;
@@ -1508,6 +1901,20 @@ declare class Plans {
1508
1901
  list(params?: {
1509
1902
  active?: boolean;
1510
1903
  }): Promise<Plan[]>;
1904
+ /** One plan's configuration. */
1905
+ get(id: string): Promise<Plan>;
1906
+ /** Create a plan. It starts active. Not retried on failure — a retry could
1907
+ * create a second plan. */
1908
+ create(input: CreatePlanInput): Promise<Plan>;
1909
+ /** PARTIAL update: only the fields you send change. `entitlements`, when
1910
+ * sent, is the complete new list — the list `get()` returned can be sent
1911
+ * back as it is. Changes apply to new purchases only. */
1912
+ update(id: string, input: UpdatePlanInput): Promise<Plan>;
1913
+ /** Retire a plan (`isActive` → false): it can't be bought any more; customers
1914
+ * already on it are unaffected. Safe to retry. */
1915
+ archive(id: string): Promise<Plan>;
1916
+ /** Make an archived plan purchasable again (`isActive` → true). Safe to retry. */
1917
+ unarchive(id: string): Promise<Plan>;
1511
1918
  }
1512
1919
 
1513
1920
  /**
@@ -1775,6 +2182,35 @@ declare class Signals {
1775
2182
  usageLog(params: UsageLogListParams): Promise<UsageLogPage>;
1776
2183
  }
1777
2184
 
2185
+ /**
2186
+ * The `units` resource — fixed-price, non-LLM events (uploads, seats, API
2187
+ * calls), priced FLAT, SLAB or VOLUME. `/api/v1/units`.
2188
+ *
2189
+ * There is no `delete()` — the API never deletes catalogue items. Retire a
2190
+ * unit with `archive()`; `unarchive()` brings it back unchanged.
2191
+ */
2192
+ declare class Units {
2193
+ private readonly transport;
2194
+ constructor(transport: Transport);
2195
+ /** List them. `{ active: true }` returns only active ones, `{ active: false }`
2196
+ * only archived ones; omit it for both. */
2197
+ list(params?: {
2198
+ active?: boolean;
2199
+ }): Promise<Unit[]>;
2200
+ /** One unit's configuration. */
2201
+ get(id: string): Promise<Unit>;
2202
+ /** Create one. It starts active. Not retried on failure — a retry could
2203
+ * create a second row. */
2204
+ create(input: CreateUnitInput): Promise<Unit>;
2205
+ /** PARTIAL update: only the fields you send change. `tiers`, when sent, is
2206
+ * the complete new tier list. */
2207
+ update(id: string, input: UpdateUnitInput): Promise<Unit>;
2208
+ /** Retire it (`isActive` → false). Nothing is deleted. Safe to retry. */
2209
+ archive(id: string): Promise<Unit>;
2210
+ /** Bring an archived one back (`isActive` → true). Safe to retry. */
2211
+ unarchive(id: string): Promise<Unit>;
2212
+ }
2213
+
1778
2214
  /**
1779
2215
  * The ClockNext client.
1780
2216
  *
@@ -1797,8 +2233,16 @@ declare class ClockNext {
1797
2233
  readonly signals: Signals;
1798
2234
  /** Manage customers, their members, and balances. */
1799
2235
  readonly customers: Customers;
1800
- /** List billing plans. */
2236
+ /** Billing plans: list, get, create, update, archive, unarchive. */
1801
2237
  readonly plans: Plans;
2238
+ /** Credits: list, get, create, update, archive, unarchive (no delete). */
2239
+ readonly credits: Credits;
2240
+ /** Outcomes: list, get, create, update, archive, unarchive (no delete). */
2241
+ readonly outcomes: Outcomes;
2242
+ /** Units: list, get, create, update, archive, unarchive (no delete). */
2243
+ readonly units: Units;
2244
+ /** Composites: list, get, create, update, archive, unarchive (no delete). */
2245
+ readonly composites: Composites;
1802
2246
  /** Subscribe customers to plans (purchases). */
1803
2247
  readonly purchases: Purchases;
1804
2248
  /** Read invoices and mint hosted pay links. */
@@ -1894,4 +2338,4 @@ declare class NetworkError extends ClockNextError {
1894
2338
  });
1895
2339
  }
1896
2340
 
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 };
2341
+ 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 };