@modelrelay/sdk 1.3.3 → 1.14.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (6) hide show
  1. package/README.md +258 -141
  2. package/dist/index.cjs +4934 -5654
  3. package/dist/index.d.cts +2953 -398
  4. package/dist/index.d.ts +2953 -398
  5. package/dist/index.js +4884 -5654
  6. package/package.json +18 -6
package/dist/index.d.ts CHANGED
@@ -55,6 +55,26 @@ declare function asModelId(value: string): ModelId;
55
55
  * Cast a string to a TierCode. Use for known tier codes.
56
56
  */
57
57
  declare function asTierCode(value: string): TierCode;
58
+ declare const SubscriptionStatuses: {
59
+ readonly Active: "active";
60
+ readonly Trialing: "trialing";
61
+ readonly PastDue: "past_due";
62
+ readonly Canceled: "canceled";
63
+ readonly Unpaid: "unpaid";
64
+ readonly Incomplete: "incomplete";
65
+ readonly IncompleteExpired: "incomplete_expired";
66
+ readonly Paused: "paused";
67
+ };
68
+ type SubscriptionStatusKind = (typeof SubscriptionStatuses)[keyof typeof SubscriptionStatuses];
69
+ declare const BillingProviders: {
70
+ readonly Stripe: "stripe";
71
+ readonly Crypto: "crypto";
72
+ readonly AppStore: "app_store";
73
+ readonly External: "external";
74
+ };
75
+ type BillingProvider = (typeof BillingProviders)[keyof typeof BillingProviders];
76
+ /** Arbitrary customer metadata. Values can be any JSON type. */
77
+ type CustomerMetadata = Record<string, unknown>;
58
78
  type PublishableKey = string & {
59
79
  readonly __brand: "PublishableKey";
60
80
  };
@@ -272,7 +292,6 @@ interface FrontendToken {
272
292
  identitySubject?: string;
273
293
  }
274
294
  interface CustomerTokenRequest {
275
- projectId: string;
276
295
  customerId?: string;
277
296
  customerExternalId?: string;
278
297
  ttlSeconds?: number;
@@ -383,6 +402,7 @@ interface UsageSummary {
383
402
  windowEnd?: Date | string;
384
403
  limit?: number;
385
404
  used?: number;
405
+ images?: number;
386
406
  actionsLimit?: number;
387
407
  actionsUsed?: number;
388
408
  remaining?: number;
@@ -640,6 +660,8 @@ interface ResponseEvent<T = unknown> {
640
660
  toolCallDelta?: ToolCallDelta;
641
661
  /** Completed tool calls when type is tool_use_stop or message_stop. */
642
662
  toolCalls?: ToolCall[];
663
+ /** Tool result payload when type is tool_use_stop. */
664
+ toolResult?: unknown;
643
665
  responseId?: string;
644
666
  model?: ModelId;
645
667
  stopReason?: StopReason;
@@ -939,7 +961,7 @@ type ResponsesRequestOptions = {
939
961
  requestId?: string;
940
962
  /**
941
963
  * Optional customer id header for customer-attributed requests.
942
- * When set, the customer's tier determines the model and `model` can be omitted.
964
+ * When set, the customer's subscription tier determines the model and `model` can be omitted.
943
965
  */
944
966
  customerId?: string;
945
967
  /**
@@ -1744,25 +1766,25 @@ declare class ResponsesClient {
1744
1766
  }
1745
1767
 
1746
1768
  declare const runIdBrand: unique symbol;
1747
- type RunId = string & {
1769
+ type RunId$1 = string & {
1748
1770
  readonly [runIdBrand]: true;
1749
1771
  };
1750
1772
  declare const nodeIdBrand: unique symbol;
1751
- type NodeId = string & {
1773
+ type NodeId$1 = string & {
1752
1774
  readonly [nodeIdBrand]: true;
1753
1775
  };
1754
1776
  declare const planHashBrand: unique symbol;
1755
- type PlanHash = string & {
1777
+ type PlanHash$1 = string & {
1756
1778
  readonly [planHashBrand]: true;
1757
1779
  };
1758
1780
  declare const outputNameBrand: unique symbol;
1759
- type OutputName = string & {
1781
+ type OutputName$1 = string & {
1760
1782
  readonly [outputNameBrand]: true;
1761
1783
  };
1762
- declare function parseRunId(raw: string): RunId;
1763
- declare function parseNodeId(raw: string): NodeId;
1764
- declare function parsePlanHash(raw: string): PlanHash;
1765
- declare function parseOutputName(raw: string): OutputName;
1784
+ declare function parseRunId(raw: string): RunId$1;
1785
+ declare function parseNodeId(raw: string): NodeId$1;
1786
+ declare function parsePlanHash(raw: string): PlanHash$1;
1787
+ declare function parseOutputName(raw: string): OutputName$1;
1766
1788
 
1767
1789
  declare const WorkflowKinds: {
1768
1790
  readonly WorkflowV0: "workflow.v0";
@@ -1787,52 +1809,52 @@ type WorkflowSpecV0 = {
1787
1809
  outputs: ReadonlyArray<WorkflowOutputRefV0>;
1788
1810
  };
1789
1811
  type WorkflowNodeV0 = {
1790
- id: NodeId;
1812
+ id: NodeId$1;
1791
1813
  type: typeof WorkflowNodeTypes.LLMResponses;
1792
1814
  input: {
1793
1815
  request: WireResponsesRequest;
1794
1816
  stream?: boolean;
1795
- tool_execution?: ToolExecutionV0;
1817
+ tool_execution?: ToolExecutionV0$1;
1796
1818
  tool_limits?: LLMResponsesToolLimitsV0;
1797
1819
  bindings?: ReadonlyArray<LLMResponsesBindingV0>;
1798
1820
  };
1799
1821
  } | {
1800
- id: NodeId;
1822
+ id: NodeId$1;
1801
1823
  type: typeof WorkflowNodeTypes.JoinAll;
1802
1824
  input?: Record<string, unknown>;
1803
1825
  } | {
1804
- id: NodeId;
1826
+ id: NodeId$1;
1805
1827
  type: typeof WorkflowNodeTypes.TransformJSON;
1806
1828
  input: {
1807
1829
  object?: Record<string, {
1808
- from: NodeId;
1830
+ from: NodeId$1;
1809
1831
  pointer?: string;
1810
1832
  }>;
1811
1833
  merge?: Array<{
1812
- from: NodeId;
1834
+ from: NodeId$1;
1813
1835
  pointer?: string;
1814
1836
  }>;
1815
1837
  };
1816
1838
  };
1817
1839
  type WorkflowEdgeV0 = {
1818
- from: NodeId;
1819
- to: NodeId;
1840
+ from: NodeId$1;
1841
+ to: NodeId$1;
1820
1842
  };
1821
1843
  type WorkflowOutputRefV0 = {
1822
- name: OutputName;
1823
- from: NodeId;
1844
+ name: OutputName$1;
1845
+ from: NodeId$1;
1824
1846
  pointer?: string;
1825
1847
  };
1826
1848
  type LLMResponsesBindingEncodingV0 = "json" | "json_string";
1827
1849
  type LLMResponsesBindingV0 = {
1828
- from: NodeId;
1850
+ from: NodeId$1;
1829
1851
  pointer?: string;
1830
1852
  to: string;
1831
1853
  encoding?: LLMResponsesBindingEncodingV0;
1832
1854
  };
1833
- type ToolExecutionModeV0 = "server" | "client";
1834
- type ToolExecutionV0 = {
1835
- mode: ToolExecutionModeV0;
1855
+ type ToolExecutionModeV0$1 = "server" | "client";
1856
+ type ToolExecutionV0$1 = {
1857
+ mode: ToolExecutionModeV0$1;
1836
1858
  };
1837
1859
  type LLMResponsesToolLimitsV0 = {
1838
1860
  max_llm_calls?: number;
@@ -1840,147 +1862,147 @@ type LLMResponsesToolLimitsV0 = {
1840
1862
  wait_ttl_ms?: number;
1841
1863
  };
1842
1864
  type RunStatusV0 = "running" | "waiting" | "succeeded" | "failed" | "canceled";
1843
- type PayloadInfoV0 = {
1865
+ type PayloadInfoV0$1 = {
1844
1866
  bytes: number;
1845
1867
  sha256: string;
1846
1868
  included: boolean;
1847
1869
  };
1848
1870
  type RunEventTypeV0 = "run_compiled" | "run_started" | "run_completed" | "run_failed" | "run_canceled" | "node_llm_call" | "node_tool_call" | "node_tool_result" | "node_waiting" | "node_started" | "node_succeeded" | "node_failed" | "node_output_delta" | "node_output";
1849
- type NodeErrorV0 = {
1871
+ type NodeErrorV0$1 = {
1850
1872
  code?: string;
1851
1873
  message: string;
1852
1874
  };
1853
1875
  /**
1854
1876
  * Stream event kind from an LLM provider.
1855
1877
  */
1856
- type StreamEventKind = string;
1857
- type NodeOutputDeltaV0 = {
1858
- kind: StreamEventKind;
1878
+ type StreamEventKind$1 = string;
1879
+ type NodeOutputDeltaV0$1 = {
1880
+ kind: StreamEventKind$1;
1859
1881
  text_delta?: string;
1860
1882
  response_id?: string;
1861
1883
  model?: string;
1862
1884
  };
1863
- type TokenUsageV0 = {
1885
+ type TokenUsageV0$1 = {
1864
1886
  input_tokens?: number;
1865
1887
  output_tokens?: number;
1866
1888
  total_tokens?: number;
1867
1889
  };
1868
- type NodeLLMCallV0 = {
1890
+ type NodeLLMCallV0$1 = {
1869
1891
  step: number;
1870
1892
  request_id: string;
1871
1893
  provider?: string;
1872
1894
  model?: string;
1873
1895
  response_id?: string;
1874
1896
  stop_reason?: string;
1875
- usage?: TokenUsageV0;
1897
+ usage?: TokenUsageV0$1;
1876
1898
  };
1877
- type FunctionToolCallV0 = {
1899
+ type FunctionToolCallV0$1 = {
1878
1900
  id: string;
1879
1901
  name: string;
1880
1902
  arguments: string;
1881
1903
  };
1882
- type NodeToolCallV0 = {
1904
+ type NodeToolCallV0$1 = {
1883
1905
  step: number;
1884
1906
  request_id: string;
1885
- tool_call: FunctionToolCallV0;
1907
+ tool_call: FunctionToolCallV0$1;
1886
1908
  };
1887
- type NodeToolResultV0 = {
1909
+ type NodeToolResultV0$1 = {
1888
1910
  step: number;
1889
1911
  request_id: string;
1890
1912
  tool_call_id: string;
1891
1913
  name: string;
1892
1914
  output: string;
1893
1915
  };
1894
- type PendingToolCallV0 = {
1916
+ type PendingToolCallV0$1 = {
1895
1917
  tool_call_id: string;
1896
1918
  name: string;
1897
1919
  arguments: string;
1898
1920
  };
1899
- type NodeWaitingV0 = {
1921
+ type NodeWaitingV0$1 = {
1900
1922
  step: number;
1901
1923
  request_id: string;
1902
- pending_tool_calls: PendingToolCallV0[];
1924
+ pending_tool_calls: PendingToolCallV0$1[];
1903
1925
  reason: string;
1904
1926
  };
1905
1927
  type RunEventBaseV0 = {
1906
1928
  envelope_version: "v0";
1907
- run_id: RunId;
1929
+ run_id: RunId$1;
1908
1930
  seq: number;
1909
1931
  ts: string;
1910
1932
  };
1911
1933
  type RunEventRunCompiledV0 = RunEventBaseV0 & {
1912
1934
  type: "run_compiled";
1913
- plan_hash: PlanHash;
1935
+ plan_hash: PlanHash$1;
1914
1936
  };
1915
1937
  type RunEventRunStartedV0 = RunEventBaseV0 & {
1916
1938
  type: "run_started";
1917
- plan_hash: PlanHash;
1939
+ plan_hash: PlanHash$1;
1918
1940
  };
1919
1941
  type RunEventRunCompletedV0 = RunEventBaseV0 & {
1920
1942
  type: "run_completed";
1921
- plan_hash: PlanHash;
1943
+ plan_hash: PlanHash$1;
1922
1944
  outputs_artifact_key: string;
1923
- outputs_info: PayloadInfoV0;
1945
+ outputs_info: PayloadInfoV0$1;
1924
1946
  };
1925
1947
  type RunEventRunFailedV0 = RunEventBaseV0 & {
1926
1948
  type: "run_failed";
1927
- plan_hash: PlanHash;
1928
- error: NodeErrorV0;
1949
+ plan_hash: PlanHash$1;
1950
+ error: NodeErrorV0$1;
1929
1951
  };
1930
1952
  type RunEventRunCanceledV0 = RunEventBaseV0 & {
1931
1953
  type: "run_canceled";
1932
- plan_hash: PlanHash;
1933
- error: NodeErrorV0;
1954
+ plan_hash: PlanHash$1;
1955
+ error: NodeErrorV0$1;
1934
1956
  };
1935
1957
  type RunEventNodeStartedV0 = RunEventBaseV0 & {
1936
1958
  type: "node_started";
1937
- node_id: NodeId;
1959
+ node_id: NodeId$1;
1938
1960
  };
1939
1961
  type RunEventNodeSucceededV0 = RunEventBaseV0 & {
1940
1962
  type: "node_succeeded";
1941
- node_id: NodeId;
1963
+ node_id: NodeId$1;
1942
1964
  };
1943
1965
  type RunEventNodeFailedV0 = RunEventBaseV0 & {
1944
1966
  type: "node_failed";
1945
- node_id: NodeId;
1946
- error: NodeErrorV0;
1967
+ node_id: NodeId$1;
1968
+ error: NodeErrorV0$1;
1947
1969
  };
1948
1970
  type RunEventNodeLLMCallV0 = RunEventBaseV0 & {
1949
1971
  type: "node_llm_call";
1950
- node_id: NodeId;
1951
- llm_call: NodeLLMCallV0;
1972
+ node_id: NodeId$1;
1973
+ llm_call: NodeLLMCallV0$1;
1952
1974
  };
1953
1975
  type RunEventNodeToolCallV0 = RunEventBaseV0 & {
1954
1976
  type: "node_tool_call";
1955
- node_id: NodeId;
1956
- tool_call: NodeToolCallV0;
1977
+ node_id: NodeId$1;
1978
+ tool_call: NodeToolCallV0$1;
1957
1979
  };
1958
1980
  type RunEventNodeToolResultV0 = RunEventBaseV0 & {
1959
1981
  type: "node_tool_result";
1960
- node_id: NodeId;
1961
- tool_result: NodeToolResultV0;
1982
+ node_id: NodeId$1;
1983
+ tool_result: NodeToolResultV0$1;
1962
1984
  };
1963
1985
  type RunEventNodeWaitingV0 = RunEventBaseV0 & {
1964
1986
  type: "node_waiting";
1965
- node_id: NodeId;
1966
- waiting: NodeWaitingV0;
1987
+ node_id: NodeId$1;
1988
+ waiting: NodeWaitingV0$1;
1967
1989
  };
1968
1990
  type RunEventNodeOutputDeltaV0 = RunEventBaseV0 & {
1969
1991
  type: "node_output_delta";
1970
- node_id: NodeId;
1971
- delta: NodeOutputDeltaV0;
1992
+ node_id: NodeId$1;
1993
+ delta: NodeOutputDeltaV0$1;
1972
1994
  };
1973
1995
  type RunEventNodeOutputV0 = RunEventBaseV0 & {
1974
1996
  type: "node_output";
1975
- node_id: NodeId;
1997
+ node_id: NodeId$1;
1976
1998
  artifact_key: string;
1977
- output_info: PayloadInfoV0;
1999
+ output_info: PayloadInfoV0$1;
1978
2000
  };
1979
2001
  type RunEventV0 = RunEventRunCompiledV0 | RunEventRunStartedV0 | RunEventRunCompletedV0 | RunEventRunFailedV0 | RunEventRunCanceledV0 | RunEventNodeLLMCallV0 | RunEventNodeToolCallV0 | RunEventNodeToolResultV0 | RunEventNodeWaitingV0 | RunEventNodeStartedV0 | RunEventNodeSucceededV0 | RunEventNodeFailedV0 | RunEventNodeOutputDeltaV0 | RunEventNodeOutputV0;
1980
2002
 
1981
2003
  type NodeStatusV0 = "pending" | "running" | "waiting" | "succeeded" | "failed" | "canceled";
1982
2004
  type RunsToolResultsRequest = {
1983
- node_id: NodeId;
2005
+ node_id: NodeId$1;
1984
2006
  step: number;
1985
2007
  request_id: string;
1986
2008
  results: Array<{
@@ -1994,9 +2016,9 @@ type RunsToolResultsResponse = {
1994
2016
  status: RunStatusV0;
1995
2017
  };
1996
2018
  type RunsPendingToolsResponse = {
1997
- run_id: RunId;
2019
+ run_id: RunId$1;
1998
2020
  pending: Array<{
1999
- node_id: NodeId;
2021
+ node_id: NodeId$1;
2000
2022
  step: number;
2001
2023
  request_id: string;
2002
2024
  tool_calls: Array<{
@@ -2007,14 +2029,14 @@ type RunsPendingToolsResponse = {
2007
2029
  }>;
2008
2030
  };
2009
2031
  type RunsCreateResponse = {
2010
- run_id: RunId;
2032
+ run_id: RunId$1;
2011
2033
  status: RunStatusV0;
2012
- plan_hash: PlanHash;
2034
+ plan_hash: PlanHash$1;
2013
2035
  };
2014
2036
  type RunsGetResponse = {
2015
- run_id: RunId;
2037
+ run_id: RunId$1;
2016
2038
  status: RunStatusV0;
2017
- plan_hash: PlanHash;
2039
+ plan_hash: PlanHash$1;
2018
2040
  cost_summary: RunCostSummaryV0;
2019
2041
  nodes?: NodeResultV0[];
2020
2042
  outputs?: Record<string, unknown>;
@@ -2032,7 +2054,7 @@ type RunCostLineItemV0 = {
2032
2054
  usd_cents: number;
2033
2055
  };
2034
2056
  type NodeResultV0 = {
2035
- id: NodeId;
2057
+ id: NodeId$1;
2036
2058
  type: string;
2037
2059
  status: NodeStatusV0;
2038
2060
  started_at?: string;
@@ -2135,6 +2157,7 @@ declare class RunsClient {
2135
2157
  metrics?: MetricsCallbacks;
2136
2158
  trace?: TraceCallbacks;
2137
2159
  });
2160
+ private applyCustomerHeader;
2138
2161
  create(spec: WorkflowSpecV0, options?: RunsCreateOptions): Promise<RunsCreateResponse>;
2139
2162
  schemaV0(options?: {
2140
2163
  signal?: AbortSignal;
@@ -2154,11 +2177,11 @@ declare class RunsClient {
2154
2177
  metrics?: MetricsCallbacks;
2155
2178
  trace?: TraceCallbacks;
2156
2179
  }): Promise<unknown>;
2157
- get(runId: RunId, options?: RunsGetOptions): Promise<RunsGetResponse>;
2158
- events(runId: RunId, options?: RunsEventsOptions): Promise<RunsEventStream>;
2159
- listEvents(runId: RunId, options?: Omit<RunsEventsOptions, "wait">): Promise<RunEventV0[]>;
2160
- submitToolResults(runId: RunId, req: RunsToolResultsRequest, options?: RunsToolResultsOptions): Promise<RunsToolResultsResponse>;
2161
- pendingTools(runId: RunId, options?: RunsPendingToolsOptions): Promise<RunsPendingToolsResponse>;
2180
+ get(runId: RunId$1, options?: RunsGetOptions): Promise<RunsGetResponse>;
2181
+ events(runId: RunId$1, options?: RunsEventsOptions): Promise<RunsEventStream>;
2182
+ listEvents(runId: RunId$1, options?: Omit<RunsEventsOptions, "wait">): Promise<RunEventV0[]>;
2183
+ submitToolResults(runId: RunId$1, req: RunsToolResultsRequest, options?: RunsToolResultsOptions): Promise<RunsToolResultsResponse>;
2184
+ pendingTools(runId: RunId$1, options?: RunsPendingToolsOptions): Promise<RunsPendingToolsResponse>;
2162
2185
  }
2163
2186
 
2164
2187
  /**
@@ -2295,6 +2318,33 @@ declare class WorkflowValidationError extends ModelRelayError {
2295
2318
  data?: unknown;
2296
2319
  });
2297
2320
  }
2321
+ /**
2322
+ * Error thrown when tool argument parsing or validation fails.
2323
+ * Includes context for the model to retry with corrected arguments.
2324
+ */
2325
+ declare class ToolArgumentError extends ModelRelayError {
2326
+ readonly toolCallId: string;
2327
+ readonly toolName: string;
2328
+ readonly rawArguments: string;
2329
+ constructor(opts: {
2330
+ message: string;
2331
+ toolCallId: string;
2332
+ toolName: string;
2333
+ rawArguments: string;
2334
+ cause?: unknown;
2335
+ });
2336
+ }
2337
+ /**
2338
+ * Error thrown when a tool call tries to access a path outside the sandbox.
2339
+ */
2340
+ declare class PathEscapeError extends ModelRelayError {
2341
+ readonly requestedPath: string;
2342
+ readonly resolvedPath: string;
2343
+ constructor(opts: {
2344
+ requestedPath: string;
2345
+ resolvedPath: string;
2346
+ });
2347
+ }
2298
2348
  /**
2299
2349
  * Returns true if the error indicates email is required for auto-provisioning.
2300
2350
  */
@@ -2335,7 +2385,7 @@ type WorkflowsCompileOptions = {
2335
2385
  };
2336
2386
  type WorkflowsCompileResponseV0 = {
2337
2387
  plan_json: unknown;
2338
- plan_hash: PlanHash;
2388
+ plan_hash: PlanHash$1;
2339
2389
  };
2340
2390
  type WorkflowsCompileV0Result = ({
2341
2391
  ok: true;
@@ -2590,7 +2640,7 @@ interface paths {
2590
2640
  get?: never;
2591
2641
  put?: never;
2592
2642
  /**
2593
- * Link an end-user identity to a customer by email
2643
+ * Link a customer identity to a customer by email
2594
2644
  * @description Used when a customer subscribes via Stripe Checkout (email only) and later authenticates to the app.
2595
2645
  * Links (provider, subject) to the existing customer record found by email.
2596
2646
  */
@@ -2601,6 +2651,84 @@ interface paths {
2601
2651
  patch?: never;
2602
2652
  trace?: never;
2603
2653
  };
2654
+ "/customers": {
2655
+ parameters: {
2656
+ query?: never;
2657
+ header?: never;
2658
+ path?: never;
2659
+ cookie?: never;
2660
+ };
2661
+ /** List customers */
2662
+ get: operations["listCustomers"];
2663
+ /** Upsert a customer by external_id */
2664
+ put: operations["upsertCustomer"];
2665
+ /** Create a customer */
2666
+ post: operations["createProjectCustomer"];
2667
+ delete?: never;
2668
+ options?: never;
2669
+ head?: never;
2670
+ patch?: never;
2671
+ trace?: never;
2672
+ };
2673
+ "/customers/{customer_id}": {
2674
+ parameters: {
2675
+ query?: never;
2676
+ header?: never;
2677
+ path: {
2678
+ customer_id: string;
2679
+ };
2680
+ cookie?: never;
2681
+ };
2682
+ /** Get a customer */
2683
+ get: operations["getCustomer"];
2684
+ put?: never;
2685
+ post?: never;
2686
+ /** Delete a customer */
2687
+ delete: operations["deleteProjectCustomer"];
2688
+ options?: never;
2689
+ head?: never;
2690
+ patch?: never;
2691
+ trace?: never;
2692
+ };
2693
+ "/customers/{customer_id}/subscribe": {
2694
+ parameters: {
2695
+ query?: never;
2696
+ header?: never;
2697
+ path: {
2698
+ customer_id: string;
2699
+ };
2700
+ cookie?: never;
2701
+ };
2702
+ get?: never;
2703
+ put?: never;
2704
+ /** Create a customer subscription checkout session */
2705
+ post: operations["subscribeCustomer"];
2706
+ delete?: never;
2707
+ options?: never;
2708
+ head?: never;
2709
+ patch?: never;
2710
+ trace?: never;
2711
+ };
2712
+ "/customers/{customer_id}/subscription": {
2713
+ parameters: {
2714
+ query?: never;
2715
+ header?: never;
2716
+ path: {
2717
+ customer_id: string;
2718
+ };
2719
+ cookie?: never;
2720
+ };
2721
+ /** Get a customer's subscription */
2722
+ get: operations["getCustomerSubscription"];
2723
+ put?: never;
2724
+ post?: never;
2725
+ /** Cancel a customer's subscription */
2726
+ delete: operations["cancelCustomerSubscription"];
2727
+ options?: never;
2728
+ head?: never;
2729
+ patch?: never;
2730
+ trace?: never;
2731
+ };
2604
2732
  "/customers/me": {
2605
2733
  parameters: {
2606
2734
  query?: never;
@@ -2611,7 +2739,7 @@ interface paths {
2611
2739
  /**
2612
2740
  * Get the authenticated customer
2613
2741
  * @description Returns the current customer associated with the provided customer-scoped bearer token.
2614
- * Includes the customer's tier and allowed models.
2742
+ * Includes the customer's subscription and tier when available.
2615
2743
  */
2616
2744
  get: operations["getCustomerMe"];
2617
2745
  put?: never;
@@ -2685,26 +2813,6 @@ interface paths {
2685
2813
  patch?: never;
2686
2814
  trace?: never;
2687
2815
  };
2688
- "/billing/webhooks": {
2689
- parameters: {
2690
- query?: never;
2691
- header?: never;
2692
- path?: never;
2693
- cookie?: never;
2694
- };
2695
- get?: never;
2696
- put?: never;
2697
- /**
2698
- * Stripe webhook receiver
2699
- * @description Accepts subscription lifecycle events from Stripe.
2700
- */
2701
- post: operations["handleBillingWebhook"];
2702
- delete?: never;
2703
- options?: never;
2704
- head?: never;
2705
- patch?: never;
2706
- trace?: never;
2707
- };
2708
2816
  "/projects": {
2709
2817
  parameters: {
2710
2818
  query?: never;
@@ -2816,8 +2924,7 @@ interface paths {
2816
2924
  cookie?: never;
2817
2925
  };
2818
2926
  get?: never;
2819
- /** Update a customer */
2820
- put: operations["updateCustomer"];
2927
+ put?: never;
2821
2928
  post?: never;
2822
2929
  /** Delete a customer */
2823
2930
  delete: operations["deleteCustomer"];
@@ -2922,6 +3029,26 @@ interface paths {
2922
3029
  patch?: never;
2923
3030
  trace?: never;
2924
3031
  };
3032
+ "/images/generate": {
3033
+ parameters: {
3034
+ query?: never;
3035
+ header?: never;
3036
+ path?: never;
3037
+ cookie?: never;
3038
+ };
3039
+ get?: never;
3040
+ put?: never;
3041
+ /**
3042
+ * Generate images from a text prompt
3043
+ * @description Generate images using AI models. Returns URLs by default (requires storage configuration) or base64-encoded data when response_format is 'b64_json'.
3044
+ */
3045
+ post: operations["generateImage"];
3046
+ delete?: never;
3047
+ options?: never;
3048
+ head?: never;
3049
+ patch?: never;
3050
+ trace?: never;
3051
+ };
2925
3052
  "/runs": {
2926
3053
  parameters: {
2927
3054
  query?: never;
@@ -2993,6 +3120,78 @@ interface paths {
2993
3120
  patch?: never;
2994
3121
  trace?: never;
2995
3122
  };
3123
+ "/sessions": {
3124
+ parameters: {
3125
+ query?: never;
3126
+ header?: never;
3127
+ path?: never;
3128
+ cookie?: never;
3129
+ };
3130
+ /**
3131
+ * List sessions
3132
+ * @description Returns a paginated list of sessions for the project.
3133
+ */
3134
+ get: operations["listSessions"];
3135
+ put?: never;
3136
+ /**
3137
+ * Create a new session
3138
+ * @description Creates a new session for multi-turn conversation management. Sessions persist message history on the server for cross-device continuity.
3139
+ */
3140
+ post: operations["createSession"];
3141
+ delete?: never;
3142
+ options?: never;
3143
+ head?: never;
3144
+ patch?: never;
3145
+ trace?: never;
3146
+ };
3147
+ "/sessions/{session_id}": {
3148
+ parameters: {
3149
+ query?: never;
3150
+ header?: never;
3151
+ path: {
3152
+ session_id: string;
3153
+ };
3154
+ cookie?: never;
3155
+ };
3156
+ /**
3157
+ * Get session with messages
3158
+ * @description Returns a session including its full message history.
3159
+ */
3160
+ get: operations["getSession"];
3161
+ put?: never;
3162
+ post?: never;
3163
+ /**
3164
+ * Delete a session
3165
+ * @description Deletes a session and all its messages. Requires a secret API key (mr_sk_*).
3166
+ */
3167
+ delete: operations["deleteSession"];
3168
+ options?: never;
3169
+ head?: never;
3170
+ patch?: never;
3171
+ trace?: never;
3172
+ };
3173
+ "/sessions/{session_id}/messages": {
3174
+ parameters: {
3175
+ query?: never;
3176
+ header?: never;
3177
+ path: {
3178
+ session_id: string;
3179
+ };
3180
+ cookie?: never;
3181
+ };
3182
+ get?: never;
3183
+ put?: never;
3184
+ /**
3185
+ * Append a session message
3186
+ * @description Appends a message to an existing session.
3187
+ */
3188
+ post: operations["addSessionMessage"];
3189
+ delete?: never;
3190
+ options?: never;
3191
+ head?: never;
3192
+ patch?: never;
3193
+ trace?: never;
3194
+ };
2996
3195
  }
2997
3196
  type webhooks = Record<string, never>;
2998
3197
  interface components {
@@ -3106,8 +3305,9 @@ interface components {
3106
3305
  */
3107
3306
  spend_limit_cents?: number;
3108
3307
  models?: components["schemas"]["TierModel"][];
3109
- /** @description Stripe price ID for this tier */
3110
- stripe_price_id?: string;
3308
+ billing_provider?: components["schemas"]["BillingProvider"];
3309
+ /** @description Billing provider price reference for this tier */
3310
+ billing_price_ref?: string;
3111
3311
  /**
3112
3312
  * Format: uint64
3113
3313
  * @description Subscription price amount in cents
@@ -3136,6 +3336,7 @@ interface components {
3136
3336
  */
3137
3337
  spend_limit_cents: number;
3138
3338
  models: components["schemas"]["TierModelCreate"][];
3339
+ billing_provider?: components["schemas"]["BillingProvider"];
3139
3340
  /**
3140
3341
  * Format: uint64
3141
3342
  * @description Subscription price amount in cents (paid tiers)
@@ -3158,6 +3359,7 @@ interface components {
3158
3359
  */
3159
3360
  spend_limit_cents: number;
3160
3361
  models?: components["schemas"]["TierModelCreate"][];
3362
+ billing_provider?: components["schemas"]["BillingProvider"];
3161
3363
  /**
3162
3364
  * Format: uint64
3163
3365
  * @description Subscription price amount in cents (paid tiers)
@@ -3170,14 +3372,25 @@ interface components {
3170
3372
  */
3171
3373
  trial_days?: number;
3172
3374
  };
3375
+ /** @description Arbitrary customer metadata (max 10KB). Keys are limited to 40 characters. Values can be any JSON type. Nesting depth limited to 5 levels. */
3376
+ CustomerMetadata: {
3377
+ [key: string]: unknown;
3378
+ };
3379
+ /**
3380
+ * @description Subscription status (active, past_due, canceled, etc.)
3381
+ * @enum {string}
3382
+ */
3383
+ SubscriptionStatusKind: "active" | "trialing" | "past_due" | "canceled" | "unpaid" | "incomplete" | "incomplete_expired" | "paused";
3384
+ /**
3385
+ * @description Billing provider backing the subscription or tier.
3386
+ * @enum {string}
3387
+ */
3388
+ BillingProvider: "stripe" | "crypto" | "app_store" | "external";
3173
3389
  Customer: {
3174
3390
  /** Format: uuid */
3175
3391
  id?: string;
3176
3392
  /** Format: uuid */
3177
3393
  project_id?: string;
3178
- /** Format: uuid */
3179
- tier_id?: string;
3180
- tier_code?: components["schemas"]["TierCode"];
3181
3394
  /** @description External customer identifier from your system */
3182
3395
  external_id?: string;
3183
3396
  /**
@@ -3185,16 +3398,28 @@ interface components {
3185
3398
  * @description Customer email address
3186
3399
  */
3187
3400
  email?: string;
3188
- /** @description Arbitrary customer metadata (max 10KB). Keys are limited to 40 characters. Values must be JSON scalars, arrays, or objects. Nesting depth limited to 5 levels. */
3189
- metadata?: {
3190
- [key: string]: unknown;
3191
- };
3192
- /** @description Stripe customer ID */
3193
- stripe_customer_id?: string;
3194
- /** @description Stripe subscription ID */
3195
- stripe_subscription_id?: string;
3196
- /** @description Subscription status (active, past_due, canceled, etc.) */
3197
- subscription_status?: string;
3401
+ metadata?: components["schemas"]["CustomerMetadata"];
3402
+ /** Format: date-time */
3403
+ created_at?: string;
3404
+ /** Format: date-time */
3405
+ updated_at?: string;
3406
+ };
3407
+ Subscription: {
3408
+ /** Format: uuid */
3409
+ id?: string;
3410
+ /** Format: uuid */
3411
+ project_id?: string;
3412
+ /** Format: uuid */
3413
+ customer_id?: string;
3414
+ /** Format: uuid */
3415
+ tier_id?: string;
3416
+ tier_code?: components["schemas"]["TierCode"];
3417
+ billing_provider?: components["schemas"]["BillingProvider"];
3418
+ /** @description Billing customer ID from the provider */
3419
+ billing_customer_id?: string;
3420
+ /** @description Billing subscription ID from the provider */
3421
+ billing_subscription_id?: string;
3422
+ subscription_status?: components["schemas"]["SubscriptionStatusKind"];
3198
3423
  /**
3199
3424
  * Format: date-time
3200
3425
  * @description Start of the current billing period
@@ -3210,8 +3435,14 @@ interface components {
3210
3435
  /** Format: date-time */
3211
3436
  updated_at?: string;
3212
3437
  };
3213
- CustomerMe: components["schemas"]["Customer"] & {
3214
- tier: components["schemas"]["Tier"];
3438
+ CustomerWithSubscription: {
3439
+ customer: components["schemas"]["Customer"];
3440
+ subscription?: components["schemas"]["Subscription"];
3441
+ };
3442
+ CustomerMe: {
3443
+ customer: components["schemas"]["Customer"];
3444
+ subscription?: components["schemas"]["Subscription"];
3445
+ tier?: components["schemas"]["Tier"];
3215
3446
  };
3216
3447
  CustomerMeResponse: {
3217
3448
  customer: components["schemas"]["CustomerMe"];
@@ -3226,6 +3457,8 @@ interface components {
3226
3457
  requests: number;
3227
3458
  /** Format: int64 */
3228
3459
  tokens: number;
3460
+ /** Format: int64 */
3461
+ images?: number;
3229
3462
  /**
3230
3463
  * Format: int64
3231
3464
  * @description Credits used in this day bucket (only for paid tiers)
@@ -3248,6 +3481,8 @@ interface components {
3248
3481
  requests: number;
3249
3482
  /** Format: int64 */
3250
3483
  tokens: number;
3484
+ /** Format: int64 */
3485
+ images: number;
3251
3486
  /**
3252
3487
  * Format: int64
3253
3488
  * @description Credits granted for this billing window (only for paid tiers)
@@ -3288,11 +3523,7 @@ interface components {
3288
3523
  /** @description Currency code for the price (e.g., 'usd') */
3289
3524
  price_currency?: string;
3290
3525
  price_interval?: components["schemas"]["PriceInterval"];
3291
- /**
3292
- * @description Subscription status (omitted when unknown)
3293
- * @enum {string}
3294
- */
3295
- subscription_status?: "active" | "trialing" | "canceled" | "past_due" | "unpaid" | "incomplete";
3526
+ subscription_status?: components["schemas"]["SubscriptionStatusKind"];
3296
3527
  /**
3297
3528
  * Format: date-time
3298
3529
  * @description Start of the current billing period
@@ -3308,19 +3539,14 @@ interface components {
3308
3539
  subscription: components["schemas"]["CustomerMeSubscription"];
3309
3540
  };
3310
3541
  CustomerCreate: {
3311
- /** Format: uuid */
3312
- tier_id: string;
3313
3542
  /** @description External customer identifier from your system */
3314
3543
  external_id: string;
3315
3544
  /**
3316
3545
  * Format: email
3317
3546
  * @description Customer email address
3318
3547
  */
3319
- email?: string;
3320
- /** @description Arbitrary customer metadata (max 10KB). Keys are limited to 40 characters. Values must be JSON scalars, arrays, or objects. Nesting depth limited to 5 levels. */
3321
- metadata?: {
3322
- [key: string]: unknown;
3323
- };
3548
+ email: string;
3549
+ metadata?: components["schemas"]["CustomerMetadata"];
3324
3550
  };
3325
3551
  /** @enum {string} */
3326
3552
  MessageRole: "system" | "user" | "assistant" | "tool";
@@ -3359,7 +3585,7 @@ interface components {
3359
3585
  };
3360
3586
  Tool: {
3361
3587
  /** @enum {string} */
3362
- type: "function" | "web" | "x_search" | "code_execution";
3588
+ type: "function" | "web" | "x_search" | "code_execution" | "image_generation";
3363
3589
  function?: {
3364
3590
  name?: components["schemas"]["ToolName"];
3365
3591
  description?: string;
@@ -3376,6 +3602,11 @@ interface components {
3376
3602
  code_execution?: {
3377
3603
  [key: string]: unknown;
3378
3604
  };
3605
+ /** @description Configuration for server-side image generation tool */
3606
+ image_generation?: {
3607
+ /** @description Image generation model ID (e.g., gemini-2.5-flash-image) */
3608
+ model: string;
3609
+ };
3379
3610
  };
3380
3611
  ToolChoice: {
3381
3612
  /** @enum {string} */
@@ -3559,7 +3790,7 @@ interface components {
3559
3790
  ToolCall: {
3560
3791
  id: components["schemas"]["ToolCallId"];
3561
3792
  /** @enum {string} */
3562
- type: "function" | "web" | "x_search" | "code_execution";
3793
+ type: "function" | "web" | "x_search" | "code_execution" | "image_generation";
3563
3794
  function?: {
3564
3795
  name?: components["schemas"]["ToolName"];
3565
3796
  /** @description JSON string of function arguments */
@@ -3597,6 +3828,15 @@ interface components {
3597
3828
  customer_external_id: string;
3598
3829
  tier_code: components["schemas"]["TierCode"];
3599
3830
  };
3831
+ CheckoutSessionResponse: {
3832
+ /** @description Stripe checkout session ID */
3833
+ session_id: string;
3834
+ /**
3835
+ * Format: uri
3836
+ * @description Checkout URL
3837
+ */
3838
+ url: string;
3839
+ };
3600
3840
  DeviceStartResponse: {
3601
3841
  /** @description Device code used for polling /auth/device/token */
3602
3842
  device_code: string;
@@ -3639,8 +3879,7 @@ interface components {
3639
3879
  active: boolean;
3640
3880
  /** @description Stripe subscription ID */
3641
3881
  subscription_id?: string;
3642
- /** @description Subscription status (active, past_due, canceled, etc.) */
3643
- status?: string;
3882
+ status?: components["schemas"]["SubscriptionStatusKind"];
3644
3883
  /**
3645
3884
  * Format: date-time
3646
3885
  * @description Start of the current billing period
@@ -3844,44 +4083,194 @@ interface components {
3844
4083
  NodeTypeV0: "llm.responses" | "join.all" | "transform.json";
3845
4084
  /** @description Tier code identifier (e.g., free, pro, enterprise). */
3846
4085
  TierCode: string;
3847
- };
3848
- responses: never;
3849
- parameters: {
3850
- ProjectID: string;
3851
- WebhookID: string;
3852
- };
3853
- requestBodies: never;
3854
- headers: never;
3855
- pathItems: never;
3856
- }
3857
- type $defs = Record<string, never>;
3858
- interface operations {
3859
- getWorkflowV0Schema: {
3860
- parameters: {
3861
- query?: never;
3862
- header?: never;
3863
- path?: never;
3864
- cookie?: never;
3865
- };
3866
- requestBody?: never;
3867
- responses: {
3868
- /** @description Schema document */
3869
- 200: {
3870
- headers: {
3871
- [name: string]: unknown;
3872
- };
3873
- content: {
3874
- "application/schema+json": Record<string, never>;
3875
- };
3876
- };
4086
+ /** @description Request to generate images from a text prompt. */
4087
+ ImageRequest: {
4088
+ /** @description Image generation model ID (e.g., gemini-2.5-flash-image). Optional when using a customer token with a tier that defines a default model. */
4089
+ model?: string;
4090
+ /** @description Text description of the image to generate */
4091
+ prompt: string;
4092
+ /**
4093
+ * @description Number of images to generate (1-10, default 1)
4094
+ * @default 1
4095
+ */
4096
+ n: number;
4097
+ response_format?: components["schemas"]["ImageResponseFormat"];
3877
4098
  };
3878
- };
3879
- getRunEventV0Schema: {
3880
- parameters: {
3881
- query?: never;
3882
- header?: never;
3883
- path?: never;
3884
- cookie?: never;
4099
+ /**
4100
+ * @description Output format for generated images.
4101
+ * @default url
4102
+ * @enum {string}
4103
+ */
4104
+ ImageResponseFormat: "url" | "b64_json";
4105
+ /** @description Response containing generated images. */
4106
+ ImageResponse: {
4107
+ /** @description Unique identifier for this generation request */
4108
+ id: string;
4109
+ /** @description Model used for generation */
4110
+ model: string;
4111
+ /** @description Generated images */
4112
+ data: components["schemas"]["ImageData"][];
4113
+ usage: components["schemas"]["ImageUsage"];
4114
+ };
4115
+ /** @description A single generated image. */
4116
+ ImageData: {
4117
+ /** @description URL of the generated image (when response_format is 'url') */
4118
+ url?: string;
4119
+ /** @description Base64-encoded image data (when response_format is 'b64_json') */
4120
+ b64_json?: string;
4121
+ /** @description MIME type of the image (e.g., 'image/png', 'image/webp') */
4122
+ mime_type?: string;
4123
+ };
4124
+ /** @description Usage statistics for image generation. */
4125
+ ImageUsage: {
4126
+ /**
4127
+ * Format: int32
4128
+ * @description Number of images generated
4129
+ */
4130
+ images: number;
4131
+ };
4132
+ /** @description Request body for creating a session. */
4133
+ SessionCreateRequest: {
4134
+ /**
4135
+ * Format: uuid
4136
+ * @description Optional end user ID to associate with the session
4137
+ */
4138
+ end_user_id?: string;
4139
+ /** @description Optional metadata for the session */
4140
+ metadata?: {
4141
+ [key: string]: unknown;
4142
+ };
4143
+ };
4144
+ /** @description A session resource. */
4145
+ SessionResponse: {
4146
+ /**
4147
+ * Format: uuid
4148
+ * @description Session unique identifier
4149
+ */
4150
+ id: string;
4151
+ /**
4152
+ * Format: uuid
4153
+ * @description Project the session belongs to
4154
+ */
4155
+ project_id: string;
4156
+ /**
4157
+ * Format: uuid
4158
+ * @description End user associated with the session (if any)
4159
+ */
4160
+ end_user_id?: string;
4161
+ /** @description Session metadata */
4162
+ metadata: {
4163
+ [key: string]: unknown;
4164
+ };
4165
+ /**
4166
+ * Format: int64
4167
+ * @description Number of messages in the session
4168
+ */
4169
+ message_count: number;
4170
+ /**
4171
+ * Format: date-time
4172
+ * @description Session creation timestamp
4173
+ */
4174
+ created_at: string;
4175
+ /**
4176
+ * Format: date-time
4177
+ * @description Session last update timestamp
4178
+ */
4179
+ updated_at: string;
4180
+ };
4181
+ /** @description A message within a session. */
4182
+ SessionMessageResponse: {
4183
+ /**
4184
+ * Format: uuid
4185
+ * @description Message unique identifier
4186
+ */
4187
+ id: string;
4188
+ /**
4189
+ * Format: int32
4190
+ * @description Sequence number within the session
4191
+ */
4192
+ seq: number;
4193
+ /** @description Message role (user, assistant, tool) */
4194
+ role: string;
4195
+ /** @description Message content parts */
4196
+ content: {
4197
+ [key: string]: unknown;
4198
+ }[];
4199
+ /**
4200
+ * Format: uuid
4201
+ * @description Run ID that generated this message (for assistant messages)
4202
+ */
4203
+ run_id?: string;
4204
+ /**
4205
+ * Format: date-time
4206
+ * @description Message creation timestamp
4207
+ */
4208
+ created_at: string;
4209
+ };
4210
+ /** @description A session with its full message history. */
4211
+ SessionWithMessagesResponse: components["schemas"]["SessionResponse"] & {
4212
+ /** @description All messages in the session */
4213
+ messages: components["schemas"]["SessionMessageResponse"][];
4214
+ };
4215
+ /** @description Paginated list of sessions. */
4216
+ SessionListResponse: {
4217
+ /** @description List of sessions */
4218
+ sessions: components["schemas"]["SessionResponse"][];
4219
+ /** @description Cursor for fetching the next page (if more results exist) */
4220
+ next_cursor?: string;
4221
+ };
4222
+ /** @description Request body for appending a message to a session. */
4223
+ SessionMessageCreateRequest: {
4224
+ /** @description Message role (user, assistant, tool) */
4225
+ role: string;
4226
+ /** @description Message content parts */
4227
+ content: {
4228
+ [key: string]: unknown;
4229
+ }[];
4230
+ /**
4231
+ * Format: uuid
4232
+ * @description Run ID that generated this message (for assistant messages)
4233
+ */
4234
+ run_id?: string;
4235
+ };
4236
+ };
4237
+ responses: never;
4238
+ parameters: {
4239
+ ProjectID: string;
4240
+ WebhookID: string;
4241
+ };
4242
+ requestBodies: never;
4243
+ headers: never;
4244
+ pathItems: never;
4245
+ }
4246
+ type $defs = Record<string, never>;
4247
+ interface operations {
4248
+ getWorkflowV0Schema: {
4249
+ parameters: {
4250
+ query?: never;
4251
+ header?: never;
4252
+ path?: never;
4253
+ cookie?: never;
4254
+ };
4255
+ requestBody?: never;
4256
+ responses: {
4257
+ /** @description Schema document */
4258
+ 200: {
4259
+ headers: {
4260
+ [name: string]: unknown;
4261
+ };
4262
+ content: {
4263
+ "application/schema+json": Record<string, never>;
4264
+ };
4265
+ };
4266
+ };
4267
+ };
4268
+ getRunEventV0Schema: {
4269
+ parameters: {
4270
+ query?: never;
4271
+ header?: never;
4272
+ path?: never;
4273
+ cookie?: never;
3885
4274
  };
3886
4275
  requestBody?: never;
3887
4276
  responses: {
@@ -4034,11 +4423,6 @@ interface operations {
4034
4423
  requestBody: {
4035
4424
  content: {
4036
4425
  "application/json": {
4037
- /**
4038
- * Format: uuid
4039
- * @description Project ID the customer belongs to
4040
- */
4041
- project_id: string;
4042
4426
  /**
4043
4427
  * Format: uuid
4044
4428
  * @description Internal customer UUID (provide exactly one of customer_id or customer_external_id)
@@ -4256,11 +4640,7 @@ interface operations {
4256
4640
  headers: {
4257
4641
  [name: string]: unknown;
4258
4642
  };
4259
- content: {
4260
- "application/json": {
4261
- customer?: components["schemas"]["Customer"];
4262
- };
4263
- };
4643
+ content?: never;
4264
4644
  };
4265
4645
  /** @description Customer not found */
4266
4646
  404: {
@@ -4278,7 +4658,7 @@ interface operations {
4278
4658
  };
4279
4659
  };
4280
4660
  };
4281
- getCustomerMe: {
4661
+ listCustomers: {
4282
4662
  parameters: {
4283
4663
  query?: never;
4284
4664
  header?: never;
@@ -4287,113 +4667,133 @@ interface operations {
4287
4667
  };
4288
4668
  requestBody?: never;
4289
4669
  responses: {
4290
- /** @description Customer details */
4670
+ /** @description Customer list */
4291
4671
  200: {
4292
4672
  headers: {
4293
4673
  [name: string]: unknown;
4294
4674
  };
4295
4675
  content: {
4296
- "application/json": components["schemas"]["CustomerMeResponse"];
4297
- };
4298
- };
4299
- /** @description Unauthorized */
4300
- 401: {
4301
- headers: {
4302
- [name: string]: unknown;
4676
+ "application/json": {
4677
+ customers?: components["schemas"]["CustomerWithSubscription"][];
4678
+ };
4303
4679
  };
4304
- content?: never;
4305
4680
  };
4306
4681
  };
4307
4682
  };
4308
- getCustomerMeUsage: {
4683
+ upsertCustomer: {
4309
4684
  parameters: {
4310
4685
  query?: never;
4311
4686
  header?: never;
4312
4687
  path?: never;
4313
4688
  cookie?: never;
4314
4689
  };
4315
- requestBody?: never;
4690
+ requestBody: {
4691
+ content: {
4692
+ "application/json": components["schemas"]["CustomerCreate"];
4693
+ };
4694
+ };
4316
4695
  responses: {
4317
- /** @description Usage summary */
4696
+ /** @description Customer updated */
4318
4697
  200: {
4319
4698
  headers: {
4320
4699
  [name: string]: unknown;
4321
4700
  };
4322
4701
  content: {
4323
- "application/json": components["schemas"]["CustomerMeUsageResponse"];
4702
+ "application/json": {
4703
+ customer?: components["schemas"]["CustomerWithSubscription"];
4704
+ };
4324
4705
  };
4325
4706
  };
4326
- /** @description Unauthorized */
4327
- 401: {
4707
+ /** @description Customer created */
4708
+ 201: {
4328
4709
  headers: {
4329
4710
  [name: string]: unknown;
4330
4711
  };
4331
- content?: never;
4332
- };
4333
- /** @description Customer not found */
4334
- 404: {
4335
- headers: {
4336
- [name: string]: unknown;
4712
+ content: {
4713
+ "application/json": {
4714
+ customer?: components["schemas"]["CustomerWithSubscription"];
4715
+ };
4337
4716
  };
4338
- content?: never;
4339
4717
  };
4340
- /** @description Failed to calculate usage */
4341
- 500: {
4342
- headers: {
4343
- [name: string]: unknown;
4344
- };
4345
- content?: never;
4718
+ };
4719
+ };
4720
+ createProjectCustomer: {
4721
+ parameters: {
4722
+ query?: never;
4723
+ header?: never;
4724
+ path?: never;
4725
+ cookie?: never;
4726
+ };
4727
+ requestBody: {
4728
+ content: {
4729
+ "application/json": components["schemas"]["CustomerCreate"];
4346
4730
  };
4347
- /** @description Service unavailable */
4348
- 503: {
4731
+ };
4732
+ responses: {
4733
+ /** @description Customer created */
4734
+ 201: {
4349
4735
  headers: {
4350
4736
  [name: string]: unknown;
4351
4737
  };
4352
- content?: never;
4738
+ content: {
4739
+ "application/json": {
4740
+ customer?: components["schemas"]["CustomerWithSubscription"];
4741
+ };
4742
+ };
4353
4743
  };
4354
4744
  };
4355
4745
  };
4356
- getCustomerMeSubscription: {
4746
+ getCustomer: {
4357
4747
  parameters: {
4358
4748
  query?: never;
4359
4749
  header?: never;
4360
- path?: never;
4750
+ path: {
4751
+ customer_id: string;
4752
+ };
4361
4753
  cookie?: never;
4362
4754
  };
4363
4755
  requestBody?: never;
4364
4756
  responses: {
4365
- /** @description Subscription details */
4757
+ /** @description Customer */
4366
4758
  200: {
4367
4759
  headers: {
4368
4760
  [name: string]: unknown;
4369
4761
  };
4370
4762
  content: {
4371
- "application/json": components["schemas"]["CustomerMeSubscriptionResponse"];
4372
- };
4373
- };
4374
- /** @description Unauthorized */
4375
- 401: {
4376
- headers: {
4377
- [name: string]: unknown;
4763
+ "application/json": {
4764
+ customer?: components["schemas"]["CustomerWithSubscription"];
4765
+ };
4378
4766
  };
4379
- content?: never;
4380
4767
  };
4381
- /** @description Customer or tier not found */
4768
+ /** @description Customer not found */
4382
4769
  404: {
4383
4770
  headers: {
4384
4771
  [name: string]: unknown;
4385
4772
  };
4386
4773
  content?: never;
4387
4774
  };
4388
- /** @description Internal server error */
4389
- 500: {
4775
+ };
4776
+ };
4777
+ deleteProjectCustomer: {
4778
+ parameters: {
4779
+ query?: never;
4780
+ header?: never;
4781
+ path: {
4782
+ customer_id: string;
4783
+ };
4784
+ cookie?: never;
4785
+ };
4786
+ requestBody?: never;
4787
+ responses: {
4788
+ /** @description Customer deleted */
4789
+ 204: {
4390
4790
  headers: {
4391
4791
  [name: string]: unknown;
4392
4792
  };
4393
4793
  content?: never;
4394
4794
  };
4395
- /** @description Service unavailable */
4396
- 503: {
4795
+ /** @description Customer not found */
4796
+ 404: {
4397
4797
  headers: {
4398
4798
  [name: string]: unknown;
4399
4799
  };
@@ -4401,42 +4801,63 @@ interface operations {
4401
4801
  };
4402
4802
  };
4403
4803
  };
4404
- listModels: {
4804
+ subscribeCustomer: {
4405
4805
  parameters: {
4406
- query?: {
4407
- /** @description Filter results to a specific provider */
4408
- provider?: components["schemas"]["ProviderId"];
4409
- /** @description Filter results to models that support a capability */
4410
- capability?: components["schemas"]["ModelCapability"];
4411
- };
4806
+ query?: never;
4412
4807
  header?: never;
4413
- path?: never;
4808
+ path: {
4809
+ customer_id: string;
4810
+ };
4414
4811
  cookie?: never;
4415
4812
  };
4416
- requestBody?: never;
4813
+ requestBody: {
4814
+ content: {
4815
+ "application/json": {
4816
+ /** Format: uuid */
4817
+ tier_id: string;
4818
+ /** Format: uri */
4819
+ success_url: string;
4820
+ /** Format: uri */
4821
+ cancel_url: string;
4822
+ };
4823
+ };
4824
+ };
4417
4825
  responses: {
4418
- /** @description Models list */
4419
- 200: {
4826
+ /** @description Checkout session created */
4827
+ 201: {
4420
4828
  headers: {
4421
4829
  [name: string]: unknown;
4422
4830
  };
4423
4831
  content: {
4424
- "application/json": components["schemas"]["ModelsResponse"];
4832
+ "application/json": components["schemas"]["CheckoutSessionResponse"];
4425
4833
  };
4426
4834
  };
4427
4835
  };
4428
4836
  };
4429
- handleBillingWebhook: {
4837
+ getCustomerSubscription: {
4430
4838
  parameters: {
4431
4839
  query?: never;
4432
4840
  header?: never;
4433
- path?: never;
4841
+ path: {
4842
+ customer_id: string;
4843
+ };
4434
4844
  cookie?: never;
4435
4845
  };
4436
4846
  requestBody?: never;
4437
4847
  responses: {
4438
- /** @description Event accepted */
4439
- 202: {
4848
+ /** @description Subscription details */
4849
+ 200: {
4850
+ headers: {
4851
+ [name: string]: unknown;
4852
+ };
4853
+ content: {
4854
+ "application/json": {
4855
+ subscription?: components["schemas"]["Subscription"];
4856
+ };
4857
+ };
4858
+ };
4859
+ /** @description Subscription not found */
4860
+ 404: {
4440
4861
  headers: {
4441
4862
  [name: string]: unknown;
4442
4863
  };
@@ -4444,16 +4865,184 @@ interface operations {
4444
4865
  };
4445
4866
  };
4446
4867
  };
4447
- listProjects: {
4868
+ cancelCustomerSubscription: {
4448
4869
  parameters: {
4449
4870
  query?: never;
4450
4871
  header?: never;
4451
- path?: never;
4872
+ path: {
4873
+ customer_id: string;
4874
+ };
4452
4875
  cookie?: never;
4453
4876
  };
4454
4877
  requestBody?: never;
4455
4878
  responses: {
4456
- /** @description Project list */
4879
+ /** @description Subscription canceled */
4880
+ 204: {
4881
+ headers: {
4882
+ [name: string]: unknown;
4883
+ };
4884
+ content?: never;
4885
+ };
4886
+ };
4887
+ };
4888
+ getCustomerMe: {
4889
+ parameters: {
4890
+ query?: never;
4891
+ header?: never;
4892
+ path?: never;
4893
+ cookie?: never;
4894
+ };
4895
+ requestBody?: never;
4896
+ responses: {
4897
+ /** @description Customer details */
4898
+ 200: {
4899
+ headers: {
4900
+ [name: string]: unknown;
4901
+ };
4902
+ content: {
4903
+ "application/json": components["schemas"]["CustomerMeResponse"];
4904
+ };
4905
+ };
4906
+ /** @description Unauthorized */
4907
+ 401: {
4908
+ headers: {
4909
+ [name: string]: unknown;
4910
+ };
4911
+ content?: never;
4912
+ };
4913
+ };
4914
+ };
4915
+ getCustomerMeUsage: {
4916
+ parameters: {
4917
+ query?: never;
4918
+ header?: never;
4919
+ path?: never;
4920
+ cookie?: never;
4921
+ };
4922
+ requestBody?: never;
4923
+ responses: {
4924
+ /** @description Usage summary */
4925
+ 200: {
4926
+ headers: {
4927
+ [name: string]: unknown;
4928
+ };
4929
+ content: {
4930
+ "application/json": components["schemas"]["CustomerMeUsageResponse"];
4931
+ };
4932
+ };
4933
+ /** @description Unauthorized */
4934
+ 401: {
4935
+ headers: {
4936
+ [name: string]: unknown;
4937
+ };
4938
+ content?: never;
4939
+ };
4940
+ /** @description Customer not found */
4941
+ 404: {
4942
+ headers: {
4943
+ [name: string]: unknown;
4944
+ };
4945
+ content?: never;
4946
+ };
4947
+ /** @description Failed to calculate usage */
4948
+ 500: {
4949
+ headers: {
4950
+ [name: string]: unknown;
4951
+ };
4952
+ content?: never;
4953
+ };
4954
+ /** @description Service unavailable */
4955
+ 503: {
4956
+ headers: {
4957
+ [name: string]: unknown;
4958
+ };
4959
+ content?: never;
4960
+ };
4961
+ };
4962
+ };
4963
+ getCustomerMeSubscription: {
4964
+ parameters: {
4965
+ query?: never;
4966
+ header?: never;
4967
+ path?: never;
4968
+ cookie?: never;
4969
+ };
4970
+ requestBody?: never;
4971
+ responses: {
4972
+ /** @description Subscription details */
4973
+ 200: {
4974
+ headers: {
4975
+ [name: string]: unknown;
4976
+ };
4977
+ content: {
4978
+ "application/json": components["schemas"]["CustomerMeSubscriptionResponse"];
4979
+ };
4980
+ };
4981
+ /** @description Unauthorized */
4982
+ 401: {
4983
+ headers: {
4984
+ [name: string]: unknown;
4985
+ };
4986
+ content?: never;
4987
+ };
4988
+ /** @description Customer or tier not found */
4989
+ 404: {
4990
+ headers: {
4991
+ [name: string]: unknown;
4992
+ };
4993
+ content?: never;
4994
+ };
4995
+ /** @description Internal server error */
4996
+ 500: {
4997
+ headers: {
4998
+ [name: string]: unknown;
4999
+ };
5000
+ content?: never;
5001
+ };
5002
+ /** @description Service unavailable */
5003
+ 503: {
5004
+ headers: {
5005
+ [name: string]: unknown;
5006
+ };
5007
+ content?: never;
5008
+ };
5009
+ };
5010
+ };
5011
+ listModels: {
5012
+ parameters: {
5013
+ query?: {
5014
+ /** @description Filter results to a specific provider */
5015
+ provider?: components["schemas"]["ProviderId"];
5016
+ /** @description Filter results to models that support a capability */
5017
+ capability?: components["schemas"]["ModelCapability"];
5018
+ };
5019
+ header?: never;
5020
+ path?: never;
5021
+ cookie?: never;
5022
+ };
5023
+ requestBody?: never;
5024
+ responses: {
5025
+ /** @description Models list */
5026
+ 200: {
5027
+ headers: {
5028
+ [name: string]: unknown;
5029
+ };
5030
+ content: {
5031
+ "application/json": components["schemas"]["ModelsResponse"];
5032
+ };
5033
+ };
5034
+ };
5035
+ };
5036
+ listProjects: {
5037
+ parameters: {
5038
+ query?: never;
5039
+ header?: never;
5040
+ path?: never;
5041
+ cookie?: never;
5042
+ };
5043
+ requestBody?: never;
5044
+ responses: {
5045
+ /** @description Project list */
4457
5046
  200: {
4458
5047
  headers: {
4459
5048
  [name: string]: unknown;
@@ -4694,7 +5283,7 @@ interface operations {
4694
5283
  };
4695
5284
  content: {
4696
5285
  "application/json": {
4697
- customers?: components["schemas"]["Customer"][];
5286
+ customers?: components["schemas"]["CustomerWithSubscription"][];
4698
5287
  };
4699
5288
  };
4700
5289
  };
@@ -4722,37 +5311,12 @@ interface operations {
4722
5311
  };
4723
5312
  content: {
4724
5313
  "application/json": {
4725
- customer?: components["schemas"]["Customer"];
5314
+ customer?: components["schemas"]["CustomerWithSubscription"];
4726
5315
  };
4727
5316
  };
4728
5317
  };
4729
5318
  };
4730
5319
  };
4731
- updateCustomer: {
4732
- parameters: {
4733
- query?: never;
4734
- header?: never;
4735
- path: {
4736
- id: components["parameters"]["ProjectID"];
4737
- customer_id: string;
4738
- };
4739
- cookie?: never;
4740
- };
4741
- requestBody: {
4742
- content: {
4743
- "application/json": components["schemas"]["CustomerCreate"];
4744
- };
4745
- };
4746
- responses: {
4747
- /** @description Customer updated */
4748
- 200: {
4749
- headers: {
4750
- [name: string]: unknown;
4751
- };
4752
- content?: never;
4753
- };
4754
- };
4755
- };
4756
5320
  deleteCustomer: {
4757
5321
  parameters: {
4758
5322
  query?: never;
@@ -4976,6 +5540,30 @@ interface operations {
4976
5540
  };
4977
5541
  };
4978
5542
  };
5543
+ generateImage: {
5544
+ parameters: {
5545
+ query?: never;
5546
+ header?: never;
5547
+ path?: never;
5548
+ cookie?: never;
5549
+ };
5550
+ requestBody: {
5551
+ content: {
5552
+ "application/json": components["schemas"]["ImageRequest"];
5553
+ };
5554
+ };
5555
+ responses: {
5556
+ /** @description Generated images */
5557
+ 200: {
5558
+ headers: {
5559
+ [name: string]: unknown;
5560
+ };
5561
+ content: {
5562
+ "application/json": components["schemas"]["ImageResponse"];
5563
+ };
5564
+ };
5565
+ };
5566
+ };
4979
5567
  createRun: {
4980
5568
  parameters: {
4981
5569
  query?: never;
@@ -5068,62 +5656,257 @@ interface operations {
5068
5656
  };
5069
5657
  };
5070
5658
  };
5071
- }
5072
-
5073
- /**
5074
- * Customer metadata as an arbitrary key-value object.
5075
- */
5076
- type CustomerMetadata = Record<string, unknown>;
5077
- /**
5078
- * Customer represents a customer in a ModelRelay project.
5079
- */
5080
- interface Customer {
5081
- id: string;
5082
- project_id: string;
5083
- tier_id: string;
5084
- tier_code?: TierCode;
5085
- external_id: string;
5086
- email: string;
5087
- metadata?: CustomerMetadata;
5088
- stripe_customer_id?: string;
5089
- stripe_subscription_id?: string;
5090
- subscription_status?: string;
5091
- current_period_start?: string;
5092
- current_period_end?: string;
5093
- created_at: string;
5094
- updated_at: string;
5095
- }
5096
- /**
5097
- * Request to create a customer.
5098
- */
5099
- interface CustomerCreateRequest {
5100
- tier_id: string;
5101
- external_id: string;
5102
- email: string;
5103
- metadata?: CustomerMetadata;
5104
- }
5105
- /**
5106
- * Request to upsert a customer by external_id.
5107
- */
5108
- interface CustomerUpsertRequest {
5109
- tier_id: string;
5110
- external_id: string;
5111
- email: string;
5112
- metadata?: CustomerMetadata;
5113
- }
5114
- /**
5115
- * Request to link an end-user identity to a customer by email.
5116
- * Used when a customer subscribes via Stripe Checkout (email only) and later authenticates to the app.
5117
- */
5118
- interface CustomerClaimRequest {
5119
- email: string;
5120
- provider: string;
5121
- subject: string;
5659
+ listSessions: {
5660
+ parameters: {
5661
+ query?: {
5662
+ /** @description Maximum number of sessions to return */
5663
+ limit?: number;
5664
+ /** @description Number of sessions to skip */
5665
+ offset?: number;
5666
+ /** @description Filter sessions by end user ID */
5667
+ end_user_id?: string;
5668
+ };
5669
+ header?: never;
5670
+ path?: never;
5671
+ cookie?: never;
5672
+ };
5673
+ requestBody?: never;
5674
+ responses: {
5675
+ /** @description Session list */
5676
+ 200: {
5677
+ headers: {
5678
+ [name: string]: unknown;
5679
+ };
5680
+ content: {
5681
+ "application/json": components["schemas"]["SessionListResponse"];
5682
+ };
5683
+ };
5684
+ /** @description API key required */
5685
+ 401: {
5686
+ headers: {
5687
+ [name: string]: unknown;
5688
+ };
5689
+ content?: never;
5690
+ };
5691
+ };
5692
+ };
5693
+ createSession: {
5694
+ parameters: {
5695
+ query?: never;
5696
+ header?: never;
5697
+ path?: never;
5698
+ cookie?: never;
5699
+ };
5700
+ requestBody: {
5701
+ content: {
5702
+ "application/json": components["schemas"]["SessionCreateRequest"];
5703
+ };
5704
+ };
5705
+ responses: {
5706
+ /** @description Session created */
5707
+ 201: {
5708
+ headers: {
5709
+ [name: string]: unknown;
5710
+ };
5711
+ content: {
5712
+ "application/json": components["schemas"]["SessionResponse"];
5713
+ };
5714
+ };
5715
+ /** @description Invalid request */
5716
+ 400: {
5717
+ headers: {
5718
+ [name: string]: unknown;
5719
+ };
5720
+ content?: never;
5721
+ };
5722
+ /** @description API key required */
5723
+ 401: {
5724
+ headers: {
5725
+ [name: string]: unknown;
5726
+ };
5727
+ content?: never;
5728
+ };
5729
+ };
5730
+ };
5731
+ getSession: {
5732
+ parameters: {
5733
+ query?: never;
5734
+ header?: never;
5735
+ path: {
5736
+ session_id: string;
5737
+ };
5738
+ cookie?: never;
5739
+ };
5740
+ requestBody?: never;
5741
+ responses: {
5742
+ /** @description Session with messages */
5743
+ 200: {
5744
+ headers: {
5745
+ [name: string]: unknown;
5746
+ };
5747
+ content: {
5748
+ "application/json": components["schemas"]["SessionWithMessagesResponse"];
5749
+ };
5750
+ };
5751
+ /** @description Session not found */
5752
+ 404: {
5753
+ headers: {
5754
+ [name: string]: unknown;
5755
+ };
5756
+ content?: never;
5757
+ };
5758
+ };
5759
+ };
5760
+ deleteSession: {
5761
+ parameters: {
5762
+ query?: never;
5763
+ header?: never;
5764
+ path: {
5765
+ session_id: string;
5766
+ };
5767
+ cookie?: never;
5768
+ };
5769
+ requestBody?: never;
5770
+ responses: {
5771
+ /** @description Session deleted */
5772
+ 204: {
5773
+ headers: {
5774
+ [name: string]: unknown;
5775
+ };
5776
+ content?: never;
5777
+ };
5778
+ /** @description Secret key required for deletion */
5779
+ 403: {
5780
+ headers: {
5781
+ [name: string]: unknown;
5782
+ };
5783
+ content?: never;
5784
+ };
5785
+ /** @description Session not found */
5786
+ 404: {
5787
+ headers: {
5788
+ [name: string]: unknown;
5789
+ };
5790
+ content?: never;
5791
+ };
5792
+ };
5793
+ };
5794
+ addSessionMessage: {
5795
+ parameters: {
5796
+ query?: never;
5797
+ header?: never;
5798
+ path: {
5799
+ session_id: string;
5800
+ };
5801
+ cookie?: never;
5802
+ };
5803
+ requestBody: {
5804
+ content: {
5805
+ "application/json": components["schemas"]["SessionMessageCreateRequest"];
5806
+ };
5807
+ };
5808
+ responses: {
5809
+ /** @description Message appended */
5810
+ 201: {
5811
+ headers: {
5812
+ [name: string]: unknown;
5813
+ };
5814
+ content: {
5815
+ "application/json": components["schemas"]["SessionMessageResponse"];
5816
+ };
5817
+ };
5818
+ /** @description Invalid request */
5819
+ 400: {
5820
+ headers: {
5821
+ [name: string]: unknown;
5822
+ };
5823
+ content?: never;
5824
+ };
5825
+ /** @description API key required */
5826
+ 401: {
5827
+ headers: {
5828
+ [name: string]: unknown;
5829
+ };
5830
+ content?: never;
5831
+ };
5832
+ /** @description Session not found */
5833
+ 404: {
5834
+ headers: {
5835
+ [name: string]: unknown;
5836
+ };
5837
+ content?: never;
5838
+ };
5839
+ };
5840
+ };
5841
+ }
5842
+
5843
+ /**
5844
+ * Customer represents a customer in a ModelRelay project.
5845
+ */
5846
+ interface Customer {
5847
+ id: string;
5848
+ project_id: string;
5849
+ external_id: string;
5850
+ email: string;
5851
+ metadata?: CustomerMetadata;
5852
+ created_at: string;
5853
+ updated_at: string;
5854
+ }
5855
+ /**
5856
+ * Subscription represents billing state for a customer.
5857
+ */
5858
+ interface Subscription {
5859
+ id: string;
5860
+ project_id: string;
5861
+ customer_id: string;
5862
+ tier_id: string;
5863
+ tier_code?: TierCode;
5864
+ billing_provider?: BillingProvider;
5865
+ billing_customer_id?: string;
5866
+ billing_subscription_id?: string;
5867
+ subscription_status?: SubscriptionStatusKind;
5868
+ current_period_start?: string;
5869
+ current_period_end?: string;
5870
+ created_at: string;
5871
+ updated_at: string;
5872
+ }
5873
+ /**
5874
+ * CustomerWithSubscription bundles customer identity with optional subscription state.
5875
+ */
5876
+ interface CustomerWithSubscription {
5877
+ customer: Customer;
5878
+ subscription?: Subscription;
5879
+ }
5880
+ /**
5881
+ * Request to create a customer.
5882
+ */
5883
+ interface CustomerCreateRequest {
5884
+ external_id: string;
5885
+ email: string;
5886
+ metadata?: CustomerMetadata;
5887
+ }
5888
+ /**
5889
+ * Request to upsert a customer by external_id.
5890
+ */
5891
+ interface CustomerUpsertRequest {
5892
+ external_id: string;
5893
+ email: string;
5894
+ metadata?: CustomerMetadata;
5895
+ }
5896
+ /**
5897
+ * Request to link a customer identity to a customer by email.
5898
+ * Used when a customer subscribes via Stripe Checkout (email only) and later authenticates to the app.
5899
+ */
5900
+ interface CustomerClaimRequest {
5901
+ email: string;
5902
+ provider: string;
5903
+ subject: string;
5122
5904
  }
5123
5905
  /**
5124
- * Request to create a checkout session.
5906
+ * Request to create a checkout session for a customer subscription.
5125
5907
  */
5126
- interface CheckoutSessionRequest {
5908
+ interface CustomerSubscribeRequest {
5909
+ tier_id: string;
5127
5910
  success_url: string;
5128
5911
  cancel_url: string;
5129
5912
  }
@@ -5134,16 +5917,6 @@ interface CheckoutSession {
5134
5917
  session_id: string;
5135
5918
  url: string;
5136
5919
  }
5137
- /**
5138
- * Subscription status response.
5139
- */
5140
- interface SubscriptionStatus {
5141
- active: boolean;
5142
- subscription_id?: string;
5143
- status?: string;
5144
- current_period_start?: string;
5145
- current_period_end?: string;
5146
- }
5147
5920
  interface CustomersClientConfig {
5148
5921
  apiKey?: ApiKey;
5149
5922
  accessToken?: string;
@@ -5184,23 +5957,23 @@ declare class CustomersClient {
5184
5957
  /**
5185
5958
  * List all customers in the project.
5186
5959
  */
5187
- list(): Promise<Customer[]>;
5960
+ list(): Promise<CustomerWithSubscription[]>;
5188
5961
  /**
5189
5962
  * Create a new customer in the project.
5190
5963
  */
5191
- create(request: CustomerCreateRequest): Promise<Customer>;
5964
+ create(request: CustomerCreateRequest): Promise<CustomerWithSubscription>;
5192
5965
  /**
5193
5966
  * Get a customer by ID.
5194
5967
  */
5195
- get(customerId: string): Promise<Customer>;
5968
+ get(customerId: string): Promise<CustomerWithSubscription>;
5196
5969
  /**
5197
5970
  * Upsert a customer by external_id.
5198
5971
  * If a customer with the given external_id exists, it is updated.
5199
5972
  * Otherwise, a new customer is created.
5200
5973
  */
5201
- upsert(request: CustomerUpsertRequest): Promise<Customer>;
5974
+ upsert(request: CustomerUpsertRequest): Promise<CustomerWithSubscription>;
5202
5975
  /**
5203
- * Link an end-user identity (provider + subject) to a customer found by email.
5976
+ * Link a customer identity (provider + subject) to a customer found by email.
5204
5977
  * Used when a customer subscribes via Stripe Checkout (email only) and later authenticates to the app.
5205
5978
  *
5206
5979
  * This is a user self-service operation that works with publishable keys,
@@ -5211,19 +5984,23 @@ declare class CustomersClient {
5211
5984
  * @throws {APIError} with status 404 if customer not found by email
5212
5985
  * @throws {APIError} with status 409 if the identity is already linked to a different customer
5213
5986
  */
5214
- claim(request: CustomerClaimRequest): Promise<Customer>;
5987
+ claim(request: CustomerClaimRequest): Promise<void>;
5215
5988
  /**
5216
5989
  * Delete a customer by ID.
5217
5990
  */
5218
5991
  delete(customerId: string): Promise<void>;
5219
5992
  /**
5220
- * Create a Stripe checkout session for a customer.
5993
+ * Create a Stripe checkout session for a customer subscription.
5994
+ */
5995
+ subscribe(customerId: string, request: CustomerSubscribeRequest): Promise<CheckoutSession>;
5996
+ /**
5997
+ * Get the subscription details for a customer.
5221
5998
  */
5222
- createCheckoutSession(customerId: string, request: CheckoutSessionRequest): Promise<CheckoutSession>;
5999
+ getSubscription(customerId: string): Promise<Subscription>;
5223
6000
  /**
5224
- * Get the subscription status for a customer.
6001
+ * Cancel a customer's subscription at period end.
5225
6002
  */
5226
- getSubscription(customerId: string): Promise<SubscriptionStatus>;
6003
+ unsubscribe(customerId: string): Promise<void>;
5227
6004
  }
5228
6005
 
5229
6006
  /**
@@ -5259,7 +6036,8 @@ interface Tier {
5259
6036
  display_name: string;
5260
6037
  spend_limit_cents: number;
5261
6038
  models: TierModel[];
5262
- stripe_price_id?: string;
6039
+ billing_provider?: components["schemas"]["BillingProvider"];
6040
+ billing_price_ref?: string;
5263
6041
  price_amount_cents?: number;
5264
6042
  price_currency?: string;
5265
6043
  price_interval?: PriceInterval;
@@ -5268,7 +6046,7 @@ interface Tier {
5268
6046
  updated_at: string;
5269
6047
  }
5270
6048
  /**
5271
- * Request to create a tier checkout session (Stripe-first flow).
6049
+ * Request to create a tier checkout session (checkout-first flow).
5272
6050
  * Stripe collects the customer's email during checkout.
5273
6051
  */
5274
6052
  interface TierCheckoutRequest {
@@ -5343,30 +6121,690 @@ declare class ModelsClient {
5343
6121
  list(params?: ModelsListParams): Promise<CatalogModel[]>;
5344
6122
  }
5345
6123
 
5346
- declare class CustomerResponsesClient {
5347
- private readonly base;
5348
- private readonly customerId;
5349
- constructor(base: ResponsesClient, customerId: string);
5350
- get id(): string;
5351
- new(): ResponseBuilder;
5352
- private ensureRequestCustomer;
5353
- create(request: ResponsesRequest, options?: ResponsesRequestOptions): Promise<Response$1>;
5354
- stream(request: ResponsesRequest, options?: ResponsesRequestOptions): Promise<ResponsesStream>;
5355
- streamJSON<T>(request: ResponsesRequest, options?: ResponsesRequestOptions): Promise<StructuredJSONStream<T>>;
5356
- text(system: string, user: string, options?: ResponsesRequestOptions): Promise<string>;
5357
- streamTextDeltas(system: string, user: string, options?: ResponsesRequestOptions): Promise<AsyncIterable<string>>;
5358
- }
5359
- declare class CustomerScopedModelRelay {
5360
- readonly responses: CustomerResponsesClient;
5361
- readonly customerId: string;
5362
- readonly baseUrl: string;
5363
- constructor(responses: ResponsesClient, customerId: string, baseUrl: string);
6124
+ /**
6125
+ * Request to generate images from a text prompt.
6126
+ */
6127
+ type ImageRequest = components["schemas"]["ImageRequest"];
6128
+ /**
6129
+ * Response containing generated images.
6130
+ */
6131
+ type ImageResponse = components["schemas"]["ImageResponse"];
6132
+ /**
6133
+ * A single generated image.
6134
+ */
6135
+ type ImageData = components["schemas"]["ImageData"];
6136
+ /**
6137
+ * Usage statistics for image generation.
6138
+ */
6139
+ type ImageUsage = components["schemas"]["ImageUsage"];
6140
+ /**
6141
+ * Output format for generated images.
6142
+ * - "url" (default): Returns hosted URLs, requires storage configuration
6143
+ * - "b64_json": Returns base64-encoded data, for testing/development
6144
+ */
6145
+ type ImageResponseFormat = components["schemas"]["ImageResponseFormat"];
6146
+ /**
6147
+ * ImagesClient provides methods for generating images using AI models.
6148
+ *
6149
+ * @example
6150
+ * ```typescript
6151
+ * // Production use (default) - returns URLs
6152
+ * const response = await client.images.generate({
6153
+ * model: "gemini-2.5-flash-image",
6154
+ * prompt: "A futuristic cityscape",
6155
+ * });
6156
+ * console.log(response.data[0].url);
6157
+ * console.log(response.data[0].mime_type);
6158
+ *
6159
+ * // Testing/development - returns base64
6160
+ * const testResponse = await client.images.generate({
6161
+ * model: "gemini-2.5-flash-image",
6162
+ * prompt: "A futuristic cityscape",
6163
+ * response_format: "b64_json"
6164
+ * });
6165
+ * ```
6166
+ */
6167
+ declare class ImagesClient {
6168
+ private readonly http;
6169
+ private readonly auth;
6170
+ constructor(http: HTTPClient, auth: AuthClient);
6171
+ /**
6172
+ * Generate images from a text prompt.
6173
+ *
6174
+ * By default, returns URLs (requires storage configuration).
6175
+ * Use response_format: "b64_json" for testing without storage.
6176
+ *
6177
+ * @param request - Image generation request (model optional if tier defines default)
6178
+ * @returns Generated images with URLs or base64 data
6179
+ * @throws {Error} If prompt is empty
6180
+ */
6181
+ generate(request: ImageRequest): Promise<ImageResponse>;
5364
6182
  }
5365
6183
 
5366
- declare class FrontendTokenProvider implements TokenProvider {
5367
- private readonly auth;
5368
- private readonly customer?;
5369
- private readonly publishableKey;
6184
+ /**
6185
+ * Session types for multi-turn conversations.
6186
+ *
6187
+ * Sessions provide stateful multi-turn conversation management with two modes:
6188
+ * - LocalSession: Client-managed history with optional persistence (memory, file, SQLite)
6189
+ * - RemoteSession: Server-managed persistence with cross-device continuity
6190
+ *
6191
+ * Both implement the common Session interface for seamless switching.
6192
+ *
6193
+ * @module
6194
+ */
6195
+
6196
+ declare const sessionIdBrand: unique symbol;
6197
+ /**
6198
+ * Branded type for session identifiers.
6199
+ * Prevents accidental use of arbitrary strings where a session ID is expected.
6200
+ */
6201
+ type SessionId = string & {
6202
+ readonly [sessionIdBrand]: true;
6203
+ };
6204
+ /**
6205
+ * Cast a string to a SessionId.
6206
+ */
6207
+ declare function asSessionId(value: string): SessionId;
6208
+ /**
6209
+ * Generate a new session ID (UUID v4).
6210
+ */
6211
+ declare function generateSessionId(): SessionId;
6212
+ /**
6213
+ * A message in the session history.
6214
+ * Extends InputItem with session-specific metadata.
6215
+ */
6216
+ interface SessionMessage extends InputItem {
6217
+ /** Sequence number within the session (1-based). */
6218
+ readonly seq: number;
6219
+ /** When this message was added to the session. */
6220
+ readonly createdAt: Date;
6221
+ /** The run ID that produced this message (for assistant messages). */
6222
+ readonly runId?: RunId$1;
6223
+ }
6224
+ /**
6225
+ * Artifacts produced during a session (files, code, etc.).
6226
+ */
6227
+ type SessionArtifacts = Map<string, unknown>;
6228
+ /**
6229
+ * Options for a session run.
6230
+ */
6231
+ interface SessionRunOptions {
6232
+ /** Override the model for this run. */
6233
+ model?: ModelId;
6234
+ /** Override the provider for this run. */
6235
+ provider?: ProviderId$1;
6236
+ /** Additional tools for this run (merged with session defaults). */
6237
+ tools?: Tool[];
6238
+ /** Maximum number of LLM turns (for tool loops). */
6239
+ maxTurns?: number;
6240
+ /** Customer ID for attributed requests. */
6241
+ customerId?: string;
6242
+ /** Abort signal for cancellation. */
6243
+ signal?: AbortSignal;
6244
+ }
6245
+ /**
6246
+ * Status of a session run.
6247
+ */
6248
+ type SessionRunStatus = "complete" | "waiting_for_tools" | "error" | "canceled";
6249
+ /**
6250
+ * Pending tool call that needs client-side execution.
6251
+ */
6252
+ interface SessionPendingToolCall {
6253
+ readonly toolCallId: string;
6254
+ readonly name: string;
6255
+ readonly arguments: string;
6256
+ }
6257
+ /**
6258
+ * Usage summary for a session run.
6259
+ */
6260
+ interface SessionUsageSummary {
6261
+ readonly inputTokens: number;
6262
+ readonly outputTokens: number;
6263
+ readonly totalTokens: number;
6264
+ readonly llmCalls: number;
6265
+ readonly toolCalls: number;
6266
+ }
6267
+ /**
6268
+ * Result of a session run.
6269
+ */
6270
+ interface SessionRunResult {
6271
+ /** Run status. */
6272
+ readonly status: SessionRunStatus;
6273
+ /** Final text output (for complete runs). */
6274
+ readonly output?: string;
6275
+ /** Pending tool calls (when status is 'waiting_for_tools'). */
6276
+ readonly pendingTools?: SessionPendingToolCall[];
6277
+ /** Error message (when status is 'error'). */
6278
+ readonly error?: string;
6279
+ /** The run ID from the server. */
6280
+ readonly runId: RunId$1;
6281
+ /** Token and call usage. */
6282
+ readonly usage: SessionUsageSummary;
6283
+ /** All events from this run. */
6284
+ readonly events: RunEventV0[];
6285
+ }
6286
+ /**
6287
+ * Session type discriminator.
6288
+ */
6289
+ type SessionType = "local" | "remote";
6290
+ /**
6291
+ * Common interface for all session types.
6292
+ *
6293
+ * Sessions manage multi-turn conversation state, executing runs with
6294
+ * accumulated context and optionally persisting history.
6295
+ */
6296
+ interface Session {
6297
+ /** Unique session identifier. */
6298
+ readonly id: SessionId;
6299
+ /** Session type: 'local' (client-managed) or 'remote' (server-managed). */
6300
+ readonly type: SessionType;
6301
+ /** Full conversation history (read-only). */
6302
+ readonly history: readonly SessionMessage[];
6303
+ /**
6304
+ * Execute a prompt as a new turn in this session.
6305
+ *
6306
+ * The prompt is added to history, a run is created with the full context,
6307
+ * and the response is appended to history. Tool calls are automatically
6308
+ * handled via the session's ToolRegistry.
6309
+ *
6310
+ * @param prompt - The user's input for this turn
6311
+ * @param options - Optional run configuration
6312
+ * @returns The run result with status, output, and usage
6313
+ */
6314
+ run(prompt: string, options?: SessionRunOptions): Promise<SessionRunResult>;
6315
+ /**
6316
+ * Submit tool results for a waiting run.
6317
+ *
6318
+ * Called when a previous run returned status 'waiting_for_tools'.
6319
+ * The results are submitted to continue the run.
6320
+ *
6321
+ * @param results - Tool execution results
6322
+ * @returns Updated run result
6323
+ */
6324
+ submitToolResults(results: ToolExecutionResult[]): Promise<SessionRunResult>;
6325
+ /**
6326
+ * Get all artifacts produced during this session.
6327
+ */
6328
+ getArtifacts(): SessionArtifacts;
6329
+ /**
6330
+ * Close the session and release resources.
6331
+ *
6332
+ * For LocalSession with persistence, this flushes pending writes.
6333
+ * For RemoteSession, this is a no-op (server manages lifecycle).
6334
+ */
6335
+ close(): Promise<void>;
6336
+ }
6337
+ /**
6338
+ * Persistence mode for local sessions.
6339
+ */
6340
+ type LocalSessionPersistence = "memory" | "file" | "sqlite";
6341
+ /**
6342
+ * Options for creating a local session.
6343
+ */
6344
+ interface LocalSessionOptions {
6345
+ /** Tool registry for handling tool calls. */
6346
+ toolRegistry?: ToolRegistry;
6347
+ /** Default model for runs (can be overridden per-run). */
6348
+ defaultModel?: ModelId;
6349
+ /** Default provider for runs (can be overridden per-run). */
6350
+ defaultProvider?: ProviderId$1;
6351
+ /** Default tools for runs (merged with per-run tools). */
6352
+ defaultTools?: Tool[];
6353
+ /** Persistence mode (default: 'memory'). */
6354
+ persistence?: LocalSessionPersistence;
6355
+ /** Storage path for file/sqlite persistence (default: ~/.modelrelay/sessions/). */
6356
+ storagePath?: string;
6357
+ /** Session ID to use (default: generate new). */
6358
+ sessionId?: SessionId;
6359
+ /** Session metadata. */
6360
+ metadata?: Record<string, unknown>;
6361
+ }
6362
+ /**
6363
+ * Options for creating a remote session.
6364
+ */
6365
+ interface RemoteSessionOptions {
6366
+ /** Tool registry for handling client-side tool calls. */
6367
+ toolRegistry?: ToolRegistry;
6368
+ /** Default model for runs (can be overridden per-run). */
6369
+ defaultModel?: ModelId;
6370
+ /** Default provider for runs (can be overridden per-run). */
6371
+ defaultProvider?: ProviderId$1;
6372
+ /** Default tools for runs (merged with per-run tools). */
6373
+ defaultTools?: Tool[];
6374
+ /** Session metadata (stored on server). */
6375
+ metadata?: Record<string, unknown>;
6376
+ /** End user ID to associate with the session. */
6377
+ endUserId?: string;
6378
+ }
6379
+ /**
6380
+ * Options for listing remote sessions.
6381
+ */
6382
+ interface ListSessionsOptions {
6383
+ /** Maximum number of sessions to return. */
6384
+ limit?: number;
6385
+ /** Cursor for pagination. */
6386
+ cursor?: string;
6387
+ /** End user ID to filter by. */
6388
+ endUserId?: string;
6389
+ }
6390
+ /**
6391
+ * Response from listing sessions.
6392
+ */
6393
+ interface ListSessionsResponse {
6394
+ sessions: RemoteSessionInfo[];
6395
+ nextCursor?: string;
6396
+ }
6397
+ /**
6398
+ * Summary info for a remote session (from list).
6399
+ */
6400
+ interface RemoteSessionInfo {
6401
+ readonly id: SessionId;
6402
+ readonly messageCount: number;
6403
+ readonly metadata: Record<string, unknown>;
6404
+ readonly createdAt: Date;
6405
+ readonly updatedAt: Date;
6406
+ }
6407
+ /**
6408
+ * Serialized session state for persistence.
6409
+ */
6410
+ interface SessionState {
6411
+ id: SessionId;
6412
+ messages: SessionMessage[];
6413
+ artifacts: Record<string, unknown>;
6414
+ metadata: Record<string, unknown>;
6415
+ createdAt: string;
6416
+ updatedAt: string;
6417
+ }
6418
+ /**
6419
+ * Interface for session storage backends.
6420
+ */
6421
+ interface SessionStore {
6422
+ /** Load a session by ID. Returns null if not found. */
6423
+ load(id: SessionId): Promise<SessionState | null>;
6424
+ /** Save a session state. */
6425
+ save(state: SessionState): Promise<void>;
6426
+ /** Delete a session by ID. */
6427
+ delete(id: SessionId): Promise<void>;
6428
+ /** List all session IDs. */
6429
+ list(): Promise<SessionId[]>;
6430
+ /** Close the store and release resources. */
6431
+ close(): Promise<void>;
6432
+ }
6433
+
6434
+ /**
6435
+ * Client-managed session implementation.
6436
+ *
6437
+ * LocalSession keeps conversation history on the client side with optional
6438
+ * persistence to memory, file, or SQLite. Use for:
6439
+ * - Local AI coding agents (Claude Code, Cursor)
6440
+ * - Privacy-sensitive workflows (history never leaves device)
6441
+ * - Offline-capable agents
6442
+ *
6443
+ * @module
6444
+ */
6445
+
6446
+ /**
6447
+ * Client-managed session with optional persistence.
6448
+ *
6449
+ * @example
6450
+ * ```typescript
6451
+ * import { ModelRelay, LocalSession } from "modelrelay";
6452
+ *
6453
+ * const client = ModelRelay.fromSecretKey(process.env.MODELRELAY_SECRET_KEY!);
6454
+ * const session = LocalSession.create(client, {
6455
+ * toolRegistry: createLocalFSTools({ root: process.cwd() }),
6456
+ * persistence: "sqlite",
6457
+ * });
6458
+ *
6459
+ * const result1 = await session.run("Create a file called hello.txt with 'Hello World'");
6460
+ * const result2 = await session.run("Now read that file back to me");
6461
+ * ```
6462
+ */
6463
+ declare class LocalSession implements Session {
6464
+ readonly type: "local";
6465
+ readonly id: SessionId;
6466
+ private readonly client;
6467
+ private readonly store;
6468
+ private readonly toolRegistry?;
6469
+ private readonly defaultModel?;
6470
+ private readonly defaultProvider?;
6471
+ private readonly defaultTools?;
6472
+ private readonly metadata;
6473
+ private messages;
6474
+ private artifacts;
6475
+ private nextSeq;
6476
+ private createdAt;
6477
+ private updatedAt;
6478
+ private currentRunId?;
6479
+ private currentNodeId?;
6480
+ private currentWaiting?;
6481
+ private currentEvents;
6482
+ private currentUsage;
6483
+ private constructor();
6484
+ /**
6485
+ * Create a new local session.
6486
+ *
6487
+ * @param client - ModelRelay client
6488
+ * @param options - Session configuration
6489
+ * @returns A new LocalSession instance
6490
+ */
6491
+ static create(client: ModelRelay, options?: LocalSessionOptions): LocalSession;
6492
+ /**
6493
+ * Resume an existing session from storage.
6494
+ *
6495
+ * @param client - ModelRelay client
6496
+ * @param sessionId - ID of the session to resume
6497
+ * @param options - Session configuration (must match original persistence settings)
6498
+ * @returns The resumed LocalSession, or null if not found
6499
+ */
6500
+ static resume(client: ModelRelay, sessionId: string | SessionId, options?: LocalSessionOptions): Promise<LocalSession | null>;
6501
+ get history(): readonly SessionMessage[];
6502
+ run(prompt: string, options?: SessionRunOptions): Promise<SessionRunResult>;
6503
+ submitToolResults(results: ToolExecutionResult[]): Promise<SessionRunResult>;
6504
+ getArtifacts(): SessionArtifacts;
6505
+ close(): Promise<void>;
6506
+ private addMessage;
6507
+ private buildInput;
6508
+ private processRunEvents;
6509
+ private executeTools;
6510
+ private persist;
6511
+ }
6512
+ /**
6513
+ * Create a new local session.
6514
+ * Convenience function for LocalSession.create().
6515
+ */
6516
+ declare function createLocalSession(client: ModelRelay, options?: LocalSessionOptions): LocalSession;
6517
+
6518
+ /**
6519
+ * Server-managed session implementation.
6520
+ *
6521
+ * RemoteSession stores conversation history on the server for:
6522
+ * - Cross-device continuity (start on CLI, continue in browser)
6523
+ * - Team collaboration and session sharing
6524
+ * - Persistent audit trails
6525
+ *
6526
+ * @module
6527
+ */
6528
+
6529
+ /**
6530
+ * Server-managed session with cross-device continuity.
6531
+ *
6532
+ * @example
6533
+ * ```typescript
6534
+ * import { ModelRelay, RemoteSession } from "modelrelay";
6535
+ *
6536
+ * const client = ModelRelay.fromSecretKey(process.env.MODELRELAY_SECRET_KEY!);
6537
+ *
6538
+ * // Create a new remote session
6539
+ * const session = await RemoteSession.create(client, {
6540
+ * metadata: { name: "Feature implementation" },
6541
+ * });
6542
+ *
6543
+ * // Run prompts with server-managed history
6544
+ * const result1 = await session.run("Explain the codebase structure");
6545
+ * const result2 = await session.run("Now implement the login feature");
6546
+ *
6547
+ * // Later, from another device:
6548
+ * const resumed = await RemoteSession.get(client, session.id);
6549
+ * const result3 = await resumed.run("Continue with the tests");
6550
+ * ```
6551
+ */
6552
+ declare class RemoteSession implements Session {
6553
+ readonly type: "remote";
6554
+ readonly id: SessionId;
6555
+ private readonly client;
6556
+ private readonly http;
6557
+ private readonly toolRegistry?;
6558
+ private readonly defaultModel?;
6559
+ private readonly defaultProvider?;
6560
+ private readonly defaultTools?;
6561
+ private metadata;
6562
+ private endUserId?;
6563
+ private messages;
6564
+ private artifacts;
6565
+ private nextSeq;
6566
+ private createdAt;
6567
+ private updatedAt;
6568
+ private pendingMessages;
6569
+ private currentRunId?;
6570
+ private currentNodeId?;
6571
+ private currentWaiting?;
6572
+ private currentEvents;
6573
+ private currentUsage;
6574
+ private constructor();
6575
+ /**
6576
+ * Create a new remote session on the server.
6577
+ *
6578
+ * @param client - ModelRelay client
6579
+ * @param options - Session configuration
6580
+ * @returns A new RemoteSession instance
6581
+ */
6582
+ static create(client: ModelRelay, options?: RemoteSessionOptions): Promise<RemoteSession>;
6583
+ /**
6584
+ * Get an existing remote session by ID.
6585
+ *
6586
+ * @param client - ModelRelay client
6587
+ * @param sessionId - ID of the session to retrieve
6588
+ * @param options - Optional configuration (toolRegistry, defaults)
6589
+ * @returns The RemoteSession instance
6590
+ */
6591
+ static get(client: ModelRelay, sessionId: string | SessionId, options?: RemoteSessionOptions): Promise<RemoteSession>;
6592
+ /**
6593
+ * List remote sessions.
6594
+ *
6595
+ * @param client - ModelRelay client
6596
+ * @param options - List options
6597
+ * @returns Paginated list of session info
6598
+ */
6599
+ static list(client: ModelRelay, options?: {
6600
+ limit?: number;
6601
+ offset?: number;
6602
+ endUserId?: string;
6603
+ }): Promise<{
6604
+ sessions: RemoteSessionInfo[];
6605
+ nextCursor?: string;
6606
+ }>;
6607
+ /**
6608
+ * Delete a remote session.
6609
+ *
6610
+ * @param client - ModelRelay client
6611
+ * @param sessionId - ID of the session to delete
6612
+ */
6613
+ static delete(client: ModelRelay, sessionId: string | SessionId): Promise<void>;
6614
+ /**
6615
+ * Full conversation history (read-only).
6616
+ */
6617
+ get history(): readonly SessionMessage[];
6618
+ /**
6619
+ * Execute a prompt as a new turn in this session.
6620
+ */
6621
+ run(prompt: string, options?: SessionRunOptions): Promise<SessionRunResult>;
6622
+ /**
6623
+ * Submit tool results for a waiting run.
6624
+ */
6625
+ submitToolResults(results: ToolExecutionResult[]): Promise<SessionRunResult>;
6626
+ /**
6627
+ * Get all artifacts produced during this session.
6628
+ */
6629
+ getArtifacts(): SessionArtifacts;
6630
+ /**
6631
+ * Close the session (no-op for remote sessions).
6632
+ */
6633
+ close(): Promise<void>;
6634
+ /**
6635
+ * Refresh the session state from the server.
6636
+ */
6637
+ refresh(): Promise<void>;
6638
+ private addMessage;
6639
+ private buildInput;
6640
+ private resetRunState;
6641
+ private processRunEvents;
6642
+ private executeToolsLocally;
6643
+ private flushPendingMessages;
6644
+ private appendMessageToServer;
6645
+ }
6646
+
6647
+ /**
6648
+ * SessionsClient - Entry point for session management.
6649
+ *
6650
+ * Provides factory methods for creating local and remote sessions.
6651
+ *
6652
+ * @module
6653
+ */
6654
+
6655
+ /**
6656
+ * Client for managing sessions.
6657
+ *
6658
+ * Provides access to both local (client-managed) and remote (server-managed) sessions.
6659
+ *
6660
+ * @example
6661
+ * ```typescript
6662
+ * import { ModelRelay } from "modelrelay";
6663
+ *
6664
+ * const client = ModelRelay.fromSecretKey(process.env.MODELRELAY_SECRET_KEY!);
6665
+ *
6666
+ * // Local session (history stays on device)
6667
+ * const localSession = client.sessions.createLocal({
6668
+ * toolRegistry: createLocalFSTools({ root: process.cwd() }),
6669
+ * persistence: "sqlite",
6670
+ * });
6671
+ *
6672
+ * // Remote session (history stored on server) - coming soon
6673
+ * // const remoteSession = await client.sessions.create({ metadata: { name: "My Session" } });
6674
+ * ```
6675
+ */
6676
+ declare class SessionsClient {
6677
+ private readonly modelRelay;
6678
+ private readonly http;
6679
+ private readonly auth;
6680
+ constructor(modelRelay: ModelRelay, http: HTTPClient, auth: AuthClient);
6681
+ /**
6682
+ * Create a new local session.
6683
+ *
6684
+ * Local sessions keep history on the client side with optional persistence.
6685
+ * Use for privacy-sensitive workflows or offline-capable agents.
6686
+ *
6687
+ * @param options - Session configuration
6688
+ * @returns A new LocalSession instance
6689
+ *
6690
+ * @example
6691
+ * ```typescript
6692
+ * const session = client.sessions.createLocal({
6693
+ * toolRegistry: createLocalFSTools({ root: process.cwd() }),
6694
+ * persistence: "memory", // or "file", "sqlite"
6695
+ * });
6696
+ *
6697
+ * const result = await session.run("Create a hello world file");
6698
+ * ```
6699
+ */
6700
+ createLocal(options?: LocalSessionOptions): LocalSession;
6701
+ /**
6702
+ * Resume an existing local session from storage.
6703
+ *
6704
+ * @param sessionId - ID of the session to resume
6705
+ * @param options - Session configuration (must match original persistence settings)
6706
+ * @returns The resumed LocalSession, or null if not found
6707
+ *
6708
+ * @example
6709
+ * ```typescript
6710
+ * const session = await client.sessions.resumeLocal("session-id", {
6711
+ * persistence: "sqlite",
6712
+ * });
6713
+ *
6714
+ * if (session) {
6715
+ * console.log(`Resumed session with ${session.history.length} messages`);
6716
+ * const result = await session.run("Continue where we left off");
6717
+ * }
6718
+ * ```
6719
+ */
6720
+ resumeLocal(sessionId: string | SessionId, options?: LocalSessionOptions): Promise<LocalSession | null>;
6721
+ /**
6722
+ * Create a new remote session.
6723
+ *
6724
+ * Remote sessions store history on the server for cross-device continuity.
6725
+ * Use for browser-based agents or team collaboration.
6726
+ *
6727
+ * @param options - Session configuration
6728
+ * @returns A new RemoteSession instance
6729
+ *
6730
+ * @example
6731
+ * ```typescript
6732
+ * const session = await client.sessions.create({
6733
+ * metadata: { name: "Feature implementation" },
6734
+ * });
6735
+ *
6736
+ * const result = await session.run("Implement the login feature");
6737
+ * ```
6738
+ */
6739
+ create(options?: RemoteSessionOptions): Promise<RemoteSession>;
6740
+ /**
6741
+ * Get an existing remote session by ID.
6742
+ *
6743
+ * @param sessionId - ID of the session to retrieve
6744
+ * @param options - Optional configuration (toolRegistry, defaults)
6745
+ * @returns The RemoteSession instance
6746
+ *
6747
+ * @example
6748
+ * ```typescript
6749
+ * const session = await client.sessions.get("session-id");
6750
+ * console.log(`Session has ${session.history.length} messages`);
6751
+ * ```
6752
+ */
6753
+ get(sessionId: string | SessionId, options?: RemoteSessionOptions): Promise<RemoteSession>;
6754
+ /**
6755
+ * List remote sessions.
6756
+ *
6757
+ * @param options - List options (limit, cursor, endUserId)
6758
+ * @returns Paginated list of session summaries
6759
+ *
6760
+ * @example
6761
+ * ```typescript
6762
+ * const { sessions, nextCursor } = await client.sessions.list({ limit: 10 });
6763
+ * for (const info of sessions) {
6764
+ * console.log(`Session ${info.id}: ${info.messageCount} messages`);
6765
+ * }
6766
+ * ```
6767
+ */
6768
+ list(options?: ListSessionsOptions): Promise<ListSessionsResponse>;
6769
+ /**
6770
+ * Delete a remote session.
6771
+ *
6772
+ * Requires a secret key (not publishable key).
6773
+ *
6774
+ * @param sessionId - ID of the session to delete
6775
+ *
6776
+ * @example
6777
+ * ```typescript
6778
+ * await client.sessions.delete("session-id");
6779
+ * ```
6780
+ */
6781
+ delete(sessionId: string | SessionId): Promise<void>;
6782
+ }
6783
+
6784
+ declare class CustomerResponsesClient {
6785
+ private readonly base;
6786
+ private readonly customerId;
6787
+ constructor(base: ResponsesClient, customerId: string);
6788
+ get id(): string;
6789
+ new(): ResponseBuilder;
6790
+ private ensureRequestCustomer;
6791
+ create(request: ResponsesRequest, options?: ResponsesRequestOptions): Promise<Response$1>;
6792
+ stream(request: ResponsesRequest, options?: ResponsesRequestOptions): Promise<ResponsesStream>;
6793
+ streamJSON<T>(request: ResponsesRequest, options?: ResponsesRequestOptions): Promise<StructuredJSONStream<T>>;
6794
+ text(system: string, user: string, options?: ResponsesRequestOptions): Promise<string>;
6795
+ streamTextDeltas(system: string, user: string, options?: ResponsesRequestOptions): Promise<AsyncIterable<string>>;
6796
+ }
6797
+ declare class CustomerScopedModelRelay {
6798
+ readonly responses: CustomerResponsesClient;
6799
+ readonly customerId: string;
6800
+ readonly baseUrl: string;
6801
+ constructor(responses: ResponsesClient, customerId: string, baseUrl: string);
6802
+ }
6803
+
6804
+ declare class FrontendTokenProvider implements TokenProvider {
6805
+ private readonly auth;
6806
+ private readonly customer?;
6807
+ private readonly publishableKey;
5370
6808
  constructor(cfg: {
5371
6809
  baseUrl?: string;
5372
6810
  fetch?: typeof fetch;
@@ -5469,11 +6907,19 @@ declare function runOAuthDeviceFlowForIDToken(cfg: {
5469
6907
  signal?: AbortSignal;
5470
6908
  }): Promise<string>;
5471
6909
 
6910
+ /**
6911
+ * Semantic JSON pointer constants for LLM responses nodes.
6912
+ * These eliminate magic strings and make bindings self-documenting.
6913
+ */
6914
+ /** JSON pointer to extract text content from an LLM response output. */
6915
+ declare const LLM_TEXT_OUTPUT$1: "/output/0/content/0/text";
6916
+ /** JSON pointer to inject text into the user message of an LLM request. */
6917
+ declare const LLM_USER_MESSAGE_TEXT$1: "/request/input/1/content/0/text";
5472
6918
  type TransformJSONValueV0 = {
5473
- from: NodeId;
6919
+ from: NodeId$1;
5474
6920
  pointer?: string;
5475
6921
  };
5476
- declare function transformJSONValue(from: NodeId, pointer?: string): TransformJSONValueV0;
6922
+ declare function transformJSONValue(from: NodeId$1, pointer?: string): TransformJSONValueV0;
5477
6923
  declare function transformJSONObject(object: Record<string, TransformJSONValueV0>): {
5478
6924
  object: Record<string, TransformJSONValueV0>;
5479
6925
  };
@@ -5495,31 +6941,190 @@ declare class WorkflowBuilderV0 {
5495
6941
  name(name: string): WorkflowBuilderV0;
5496
6942
  execution(execution: WorkflowSpecV0["execution"]): WorkflowBuilderV0;
5497
6943
  node(node: WorkflowNodeV0): WorkflowBuilderV0;
5498
- llmResponses(id: NodeId, request: WireResponsesRequest | ResponsesRequest, options?: {
6944
+ llmResponses(id: NodeId$1, request: WireResponsesRequest | ResponsesRequest, options?: {
5499
6945
  stream?: boolean;
5500
- toolExecution?: ToolExecutionModeV0;
6946
+ toolExecution?: ToolExecutionModeV0$1;
5501
6947
  toolLimits?: LLMResponsesToolLimitsV0;
5502
6948
  bindings?: ReadonlyArray<LLMResponsesBindingV0>;
5503
6949
  }): WorkflowBuilderV0;
5504
- joinAll(id: NodeId): WorkflowBuilderV0;
5505
- transformJSON(id: NodeId, input: Extract<WorkflowNodeV0, {
6950
+ joinAll(id: NodeId$1): WorkflowBuilderV0;
6951
+ transformJSON(id: NodeId$1, input: Extract<WorkflowNodeV0, {
5506
6952
  type: typeof WorkflowNodeTypes.TransformJSON;
5507
6953
  }>["input"]): WorkflowBuilderV0;
5508
- edge(from: NodeId, to: NodeId): WorkflowBuilderV0;
5509
- output(name: OutputName, from: NodeId, pointer?: string): WorkflowBuilderV0;
6954
+ edge(from: NodeId$1, to: NodeId$1): WorkflowBuilderV0;
6955
+ output(name: OutputName$1, from: NodeId$1, pointer?: string): WorkflowBuilderV0;
5510
6956
  build(): WorkflowSpecV0;
5511
6957
  }
5512
6958
  declare function workflowV0(): WorkflowBuilderV0;
5513
-
5514
- var $id = "https://modelrelay.ai/schemas/workflow_v0.schema.json";
5515
- var $schema = "http://json-schema.org/draft-07/schema#";
5516
- var additionalProperties = false;
5517
- var definitions = {
5518
- edge: {
5519
- additionalProperties: false,
5520
- properties: {
5521
- from: {
5522
- minLength: 1,
6959
+ type PendingLLMNode = {
6960
+ id: NodeId$1;
6961
+ request: WireResponsesRequest;
6962
+ stream?: boolean;
6963
+ bindings: LLMResponsesBindingV0[];
6964
+ toolExecution?: ToolExecutionModeV0$1;
6965
+ toolLimits?: LLMResponsesToolLimitsV0;
6966
+ };
6967
+ /**
6968
+ * Ergonomic workflow builder with auto-edge inference from bindings.
6969
+ *
6970
+ * @example
6971
+ * ```typescript
6972
+ * const spec = newWorkflow("tier_generation")
6973
+ * .addLLMNode("tier_generator", tierReq).stream(true)
6974
+ * .addLLMNode("business_summary", summaryReq)
6975
+ * .bindFrom("tier_generator", "/output/0/content/0/text")
6976
+ * .output("tiers", "tier_generator")
6977
+ * .output("summary", "business_summary")
6978
+ * .build();
6979
+ * ```
6980
+ */
6981
+ declare class Workflow {
6982
+ private _name?;
6983
+ private _execution?;
6984
+ private readonly _nodes;
6985
+ private readonly _edges;
6986
+ private readonly _outputs;
6987
+ private _pendingNode;
6988
+ private constructor();
6989
+ /**
6990
+ * Create a new workflow builder with the given name.
6991
+ */
6992
+ static create(name?: string): Workflow;
6993
+ /**
6994
+ * Set the workflow execution configuration.
6995
+ */
6996
+ execution(exec: WorkflowSpecV0["execution"]): Workflow;
6997
+ /**
6998
+ * Add an LLM responses node and return a node builder for configuration.
6999
+ */
7000
+ addLLMNode(id: NodeId$1, request: WireResponsesRequest | ResponsesRequest): LLMNodeBuilder;
7001
+ /**
7002
+ * Add a join.all node that waits for all incoming edges.
7003
+ */
7004
+ addJoinAllNode(id: NodeId$1): Workflow;
7005
+ /**
7006
+ * Add a transform.json node and return a builder for configuration.
7007
+ */
7008
+ addTransformJSONNode(id: NodeId$1): TransformJSONNodeBuilder;
7009
+ /**
7010
+ * Add an output reference extracting the full node output.
7011
+ */
7012
+ output(name: OutputName$1, from: NodeId$1, pointer?: string): Workflow;
7013
+ /**
7014
+ * Add an output reference extracting text content from an LLM response.
7015
+ * This is a convenience method that uses the LLM_TEXT_OUTPUT pointer.
7016
+ */
7017
+ outputText(name: OutputName$1, from: NodeId$1): Workflow;
7018
+ /**
7019
+ * Explicitly add an edge between nodes.
7020
+ * Note: edges are automatically inferred from bindings, so this is rarely needed.
7021
+ */
7022
+ edge(from: NodeId$1, to: NodeId$1): Workflow;
7023
+ /**
7024
+ * Build the workflow specification.
7025
+ */
7026
+ build(): WorkflowSpecV0;
7027
+ /** @internal */
7028
+ _getPendingNode(): PendingLLMNode | null;
7029
+ /** @internal */
7030
+ _addEdge(from: NodeId$1, to: NodeId$1): void;
7031
+ /** @internal */
7032
+ _addNode(node: WorkflowNodeV0): void;
7033
+ private flushPendingNode;
7034
+ }
7035
+ /**
7036
+ * Builder for configuring an LLM responses node.
7037
+ */
7038
+ declare class LLMNodeBuilder {
7039
+ private readonly workflow;
7040
+ constructor(workflow: Workflow);
7041
+ /**
7042
+ * Enable or disable streaming for this node.
7043
+ */
7044
+ stream(enabled: boolean): LLMNodeBuilder;
7045
+ /**
7046
+ * Add a binding from another LLM node's text output to this node's user message.
7047
+ * This is the most common binding pattern: LLM text → user message with json_string encoding.
7048
+ * The edge from the source node is automatically inferred.
7049
+ */
7050
+ bindTextFrom(from: NodeId$1): LLMNodeBuilder;
7051
+ /**
7052
+ * Add a binding from another node's output to this node's user message text.
7053
+ * Use bindTextFrom for the common case of binding LLM text output.
7054
+ * The edge from the source node is automatically inferred.
7055
+ */
7056
+ bindFrom(from: NodeId$1, pointer?: string): LLMNodeBuilder;
7057
+ /**
7058
+ * Add a full binding with explicit source/destination pointers and encoding.
7059
+ * The edge from the source node is automatically inferred.
7060
+ */
7061
+ bindFromTo(from: NodeId$1, fromPointer: string | undefined, toPointer: string, encoding?: LLMResponsesBindingEncodingV0): LLMNodeBuilder;
7062
+ /**
7063
+ * Set the tool execution mode (server or client).
7064
+ */
7065
+ toolExecution(mode: ToolExecutionModeV0$1): LLMNodeBuilder;
7066
+ /**
7067
+ * Set the tool execution limits.
7068
+ */
7069
+ toolLimits(limits: LLMResponsesToolLimitsV0): LLMNodeBuilder;
7070
+ addLLMNode(id: NodeId$1, request: WireResponsesRequest | ResponsesRequest): LLMNodeBuilder;
7071
+ addJoinAllNode(id: NodeId$1): Workflow;
7072
+ addTransformJSONNode(id: NodeId$1): TransformJSONNodeBuilder;
7073
+ edge(from: NodeId$1, to: NodeId$1): Workflow;
7074
+ output(name: OutputName$1, from: NodeId$1, pointer?: string): Workflow;
7075
+ outputText(name: OutputName$1, from: NodeId$1): Workflow;
7076
+ execution(exec: WorkflowSpecV0["execution"]): Workflow;
7077
+ build(): WorkflowSpecV0;
7078
+ }
7079
+ /**
7080
+ * Builder for configuring a transform.json node.
7081
+ */
7082
+ declare class TransformJSONNodeBuilder {
7083
+ private readonly workflow;
7084
+ private readonly id;
7085
+ private _object?;
7086
+ private _merge?;
7087
+ constructor(workflow: Workflow, id: NodeId$1);
7088
+ /**
7089
+ * Set the object transformation with field mappings.
7090
+ */
7091
+ object(fields: Record<string, TransformJSONValueV0>): TransformJSONNodeBuilder;
7092
+ /**
7093
+ * Set the merge transformation with source references.
7094
+ */
7095
+ merge(items: TransformJSONValueV0[]): TransformJSONNodeBuilder;
7096
+ private finalize;
7097
+ addLLMNode(id: NodeId$1, request: WireResponsesRequest | ResponsesRequest): LLMNodeBuilder;
7098
+ addJoinAllNode(id: NodeId$1): Workflow;
7099
+ edge(from: NodeId$1, to: NodeId$1): Workflow;
7100
+ output(name: OutputName$1, from: NodeId$1, pointer?: string): Workflow;
7101
+ execution(exec: WorkflowSpecV0["execution"]): Workflow;
7102
+ build(): WorkflowSpecV0;
7103
+ }
7104
+ /**
7105
+ * Create a new ergonomic workflow builder with the given name.
7106
+ *
7107
+ * @example
7108
+ * ```typescript
7109
+ * const spec = newWorkflow("my_workflow")
7110
+ * .addLLMNode("generator", request).stream(true)
7111
+ * .addLLMNode("summarizer", summaryReq)
7112
+ * .bindFrom("generator", "/output/0/content/0/text")
7113
+ * .output("result", "summarizer")
7114
+ * .build();
7115
+ * ```
7116
+ */
7117
+ declare function newWorkflow(name?: string): Workflow;
7118
+
7119
+ var $id = "https://modelrelay.ai/schemas/workflow_v0.schema.json";
7120
+ var $schema = "http://json-schema.org/draft-07/schema#";
7121
+ var additionalProperties = false;
7122
+ var definitions = {
7123
+ edge: {
7124
+ additionalProperties: false,
7125
+ properties: {
7126
+ from: {
7127
+ minLength: 1,
5523
7128
  type: "string"
5524
7129
  },
5525
7130
  to: {
@@ -5838,29 +7443,979 @@ var workflow_v0_schema = {
5838
7443
  declare const WORKFLOWS_COMPILE_PATH = "/workflows/compile";
5839
7444
  type WorkflowsCompileRequestV0 = WorkflowSpecV0;
5840
7445
 
7446
+ /**
7447
+ * High-level workflow pattern helpers for common workflow structures.
7448
+ *
7449
+ * These helpers reduce boilerplate for common patterns like sequential chains,
7450
+ * parallel execution with aggregation, and map-reduce processing.
7451
+ *
7452
+ * All builders are immutable - each method returns a new builder instance.
7453
+ *
7454
+ * @example
7455
+ * ```typescript
7456
+ * import { Chain, Parallel, MapReduce, LLMStep, MapItem } from 'modelrelay';
7457
+ *
7458
+ * // Chain pattern - sequential steps
7459
+ * const chainSpec = Chain('summarize-translate', [
7460
+ * LLMStep('summarize', summarizeReq),
7461
+ * LLMStep('translate', translateReq).withStream(),
7462
+ * ])
7463
+ * .outputLast('result')
7464
+ * .build();
7465
+ *
7466
+ * // Parallel pattern - concurrent steps with aggregation
7467
+ * const parallelSpec = Parallel('multi-model', [
7468
+ * LLMStep('gpt4', gpt4Req),
7469
+ * LLMStep('claude', claudeReq),
7470
+ * ])
7471
+ * .aggregate('synthesize', synthesizeReq)
7472
+ * .output('result', 'synthesize')
7473
+ * .build();
7474
+ *
7475
+ * // MapReduce pattern - parallel mappers with reducer
7476
+ * const mapReduceSpec = MapReduce('process-docs', [
7477
+ * MapItem('doc1', doc1Req),
7478
+ * MapItem('doc2', doc2Req),
7479
+ * ])
7480
+ * .reduce('combine', combineReq)
7481
+ * .output('result', 'combine')
7482
+ * .build();
7483
+ * ```
7484
+ */
7485
+
7486
+ /**
7487
+ * Configuration for an LLM step in a workflow pattern.
7488
+ */
7489
+ type LLMStepConfig = {
7490
+ readonly id: NodeId$1;
7491
+ readonly request: WireResponsesRequest;
7492
+ readonly stream: boolean;
7493
+ };
7494
+ /**
7495
+ * Creates an LLM step configuration for use with Chain or Parallel patterns.
7496
+ *
7497
+ * @param id - Unique node identifier
7498
+ * @param request - The LLM request configuration
7499
+ * @returns A step configuration object with fluent methods
7500
+ *
7501
+ * @example
7502
+ * ```typescript
7503
+ * const step = LLMStep('summarize', {
7504
+ * model: 'claude-sonnet-4-20250514',
7505
+ * input: [{ type: 'message', role: 'user', content: [{ type: 'text', text: 'Summarize...' }] }],
7506
+ * });
7507
+ *
7508
+ * // Enable streaming
7509
+ * const streamingStep = step.withStream();
7510
+ * ```
7511
+ */
7512
+ declare function LLMStep(id: NodeId$1 | string, request: WireResponsesRequest | ResponsesRequest): LLMStepConfig & {
7513
+ withStream(): LLMStepConfig;
7514
+ };
7515
+ /**
7516
+ * Immutable builder for sequential workflow where each step's output feeds into the next.
7517
+ */
7518
+ declare class ChainBuilder {
7519
+ private readonly state;
7520
+ private constructor();
7521
+ static create(name: string, steps: readonly LLMStepConfig[]): ChainBuilder;
7522
+ private with;
7523
+ /**
7524
+ * Sets the workflow execution configuration.
7525
+ */
7526
+ execution(exec: WorkflowSpecV0["execution"]): ChainBuilder;
7527
+ /**
7528
+ * Adds an output reference from a specific step.
7529
+ */
7530
+ output(name: OutputName$1 | string, from: NodeId$1 | string): ChainBuilder;
7531
+ /**
7532
+ * Adds an output reference from the last step.
7533
+ */
7534
+ outputLast(name: OutputName$1 | string): ChainBuilder;
7535
+ /**
7536
+ * Builds and returns the compiled workflow spec.
7537
+ * @throws Error if no steps are provided
7538
+ */
7539
+ build(): WorkflowSpecV0;
7540
+ }
7541
+ /**
7542
+ * Creates a workflow builder for sequential LLM steps.
7543
+ * Each step after the first automatically binds its input from the previous step's text output.
7544
+ *
7545
+ * @param name - Workflow name
7546
+ * @param steps - Array of LLMStep configurations
7547
+ * @returns A ChainBuilder for further configuration
7548
+ *
7549
+ * @example
7550
+ * ```typescript
7551
+ * const spec = Chain('summarize-translate', [
7552
+ * LLMStep('summarize', summarizeReq),
7553
+ * LLMStep('translate', translateReq).withStream(),
7554
+ * LLMStep('format', formatReq),
7555
+ * ])
7556
+ * .outputLast('result')
7557
+ * .build();
7558
+ * ```
7559
+ */
7560
+ declare function Chain(name: string, steps: readonly LLMStepConfig[]): ChainBuilder;
7561
+ /**
7562
+ * Immutable builder for workflow where multiple LLM steps execute in parallel,
7563
+ * with optional aggregation.
7564
+ */
7565
+ declare class ParallelBuilder {
7566
+ private readonly state;
7567
+ private constructor();
7568
+ static create(name: string, steps: readonly LLMStepConfig[]): ParallelBuilder;
7569
+ private with;
7570
+ /**
7571
+ * Sets the workflow execution configuration.
7572
+ */
7573
+ execution(exec: WorkflowSpecV0["execution"]): ParallelBuilder;
7574
+ /**
7575
+ * Adds a join node that waits for all parallel steps,
7576
+ * followed by an aggregator LLM node that receives the combined output.
7577
+ * The join node ID is automatically generated as "<id>_join".
7578
+ */
7579
+ aggregate(id: NodeId$1 | string, request: WireResponsesRequest | ResponsesRequest): ParallelBuilder;
7580
+ /**
7581
+ * Like aggregate() but enables streaming on the aggregator node.
7582
+ */
7583
+ aggregateWithStream(id: NodeId$1 | string, request: WireResponsesRequest | ResponsesRequest): ParallelBuilder;
7584
+ /**
7585
+ * Adds an output reference from a specific step.
7586
+ */
7587
+ output(name: OutputName$1 | string, from: NodeId$1 | string): ParallelBuilder;
7588
+ /**
7589
+ * Builds and returns the compiled workflow spec.
7590
+ * @throws Error if no steps are provided
7591
+ */
7592
+ build(): WorkflowSpecV0;
7593
+ }
7594
+ /**
7595
+ * Creates a workflow builder for parallel LLM steps.
7596
+ * All steps execute concurrently with no dependencies between them.
7597
+ *
7598
+ * @param name - Workflow name
7599
+ * @param steps - Array of LLMStep configurations
7600
+ * @returns A ParallelBuilder for further configuration
7601
+ *
7602
+ * @example
7603
+ * ```typescript
7604
+ * // Without aggregation - just parallel execution
7605
+ * const spec = Parallel('multi-model', [
7606
+ * LLMStep('gpt4', gpt4Req),
7607
+ * LLMStep('claude', claudeReq),
7608
+ * ])
7609
+ * .output('gpt4_result', 'gpt4')
7610
+ * .output('claude_result', 'claude')
7611
+ * .build();
7612
+ *
7613
+ * // With aggregation - parallel then combine
7614
+ * const spec = Parallel('multi-model', [
7615
+ * LLMStep('gpt4', gpt4Req),
7616
+ * LLMStep('claude', claudeReq),
7617
+ * ])
7618
+ * .aggregate('synthesize', synthesizeReq)
7619
+ * .output('result', 'synthesize')
7620
+ * .build();
7621
+ * ```
7622
+ */
7623
+ declare function Parallel(name: string, steps: readonly LLMStepConfig[]): ParallelBuilder;
7624
+ /**
7625
+ * Configuration for a map item in MapReduce.
7626
+ */
7627
+ type MapItemConfig = {
7628
+ readonly id: string;
7629
+ readonly request: WireResponsesRequest;
7630
+ readonly stream: boolean;
7631
+ };
7632
+ /**
7633
+ * Creates a map item configuration for use with MapReduce pattern.
7634
+ * Each item becomes a separate mapper node that runs in parallel.
7635
+ *
7636
+ * @param id - Unique identifier for this item (becomes part of node ID: "map_<id>")
7637
+ * @param request - The LLM request for processing this item
7638
+ * @returns A map item configuration object with fluent methods
7639
+ *
7640
+ * @example
7641
+ * ```typescript
7642
+ * const item = MapItem('doc1', {
7643
+ * model: 'claude-sonnet-4-20250514',
7644
+ * input: [{ type: 'message', role: 'user', content: [{ type: 'text', text: 'Summarize doc1...' }] }],
7645
+ * });
7646
+ *
7647
+ * // Enable streaming
7648
+ * const streamingItem = item.withStream();
7649
+ * ```
7650
+ */
7651
+ declare function MapItem(id: string, request: WireResponsesRequest | ResponsesRequest): MapItemConfig & {
7652
+ withStream(): MapItemConfig;
7653
+ };
7654
+ /**
7655
+ * Immutable builder for workflow where items are processed in parallel by mapper nodes,
7656
+ * then combined by a reducer node.
7657
+ *
7658
+ * The pattern creates:
7659
+ * - N mapper nodes (one per item), running in parallel
7660
+ * - A join.all node to collect all mapper outputs
7661
+ * - A reducer LLM node that receives the combined outputs
7662
+ *
7663
+ * Note: Items must be known at workflow build time. For dynamic array
7664
+ * processing at runtime, server-side support for dynamic node instantiation
7665
+ * would be required.
7666
+ */
7667
+ declare class MapReduceBuilder {
7668
+ private readonly state;
7669
+ private constructor();
7670
+ static create(name: string, items: readonly MapItemConfig[]): MapReduceBuilder;
7671
+ private with;
7672
+ /**
7673
+ * Adds a mapper item to the workflow.
7674
+ * Each item becomes a separate LLM node that runs in parallel.
7675
+ */
7676
+ item(id: NodeId$1 | string, request: WireResponsesRequest | ResponsesRequest): MapReduceBuilder;
7677
+ /**
7678
+ * Adds a mapper item with streaming enabled.
7679
+ */
7680
+ itemWithStream(id: NodeId$1 | string, request: WireResponsesRequest | ResponsesRequest): MapReduceBuilder;
7681
+ /**
7682
+ * Sets the workflow execution configuration.
7683
+ */
7684
+ execution(exec: WorkflowSpecV0["execution"]): MapReduceBuilder;
7685
+ /**
7686
+ * Adds a reducer node that receives all mapper outputs.
7687
+ * The reducer receives a JSON object mapping each mapper ID to its text output.
7688
+ * The join node ID is automatically generated as "<id>_join".
7689
+ */
7690
+ reduce(id: NodeId$1 | string, request: WireResponsesRequest | ResponsesRequest): MapReduceBuilder;
7691
+ /**
7692
+ * Like reduce() but enables streaming on the reducer node.
7693
+ */
7694
+ reduceWithStream(id: NodeId$1 | string, request: WireResponsesRequest | ResponsesRequest): MapReduceBuilder;
7695
+ /**
7696
+ * Adds an output reference from a specific node.
7697
+ * Typically used to output from the reducer node.
7698
+ */
7699
+ output(name: OutputName$1 | string, from: NodeId$1 | string): MapReduceBuilder;
7700
+ /**
7701
+ * Builds and returns the compiled workflow spec.
7702
+ * @throws Error if no items are provided or no reducer is configured
7703
+ */
7704
+ build(): WorkflowSpecV0;
7705
+ }
7706
+ /**
7707
+ * Creates a workflow builder for parallel map-reduce processing.
7708
+ * Each item is processed by a separate mapper node, and results are combined
7709
+ * by a reducer node.
7710
+ *
7711
+ * @param name - Workflow name
7712
+ * @param items - Optional array of MapItem configurations (can also use .item() builder)
7713
+ * @returns A MapReduceBuilder for further configuration
7714
+ *
7715
+ * @example
7716
+ * ```typescript
7717
+ * // Fluent builder pattern (preferred)
7718
+ * const spec = mapReduce('summarize-docs')
7719
+ * .item('doc1', doc1Req)
7720
+ * .item('doc2', doc2Req)
7721
+ * .reduce('combine', combineReq)
7722
+ * .output(parseOutputName('result'), 'combine')
7723
+ * .build();
7724
+ * ```
7725
+ */
7726
+ declare function MapReduce(name: string, items?: readonly MapItemConfig[]): MapReduceBuilder;
7727
+
5841
7728
  declare function parseApiKey(raw: string): ApiKey;
5842
7729
  declare function parsePublishableKey(raw: string): PublishableKey;
5843
7730
  declare function parseSecretKey(raw: string): SecretKey;
5844
7731
  declare function isPublishableKey(key: ApiKey): key is PublishableKey;
5845
7732
  declare function isSecretKey(key: ApiKey): key is SecretKey;
5846
7733
 
5847
- type index_$defs = $defs;
5848
- type index_components = components;
5849
- type index_operations = operations;
5850
- type index_paths = paths;
5851
- type index_webhooks = webhooks;
7734
+ /**
7735
+ * Local filesystem tool pack for client-side tool execution.
7736
+ *
7737
+ * Implements tools.v0 contract:
7738
+ * - fs.read_file - Read workspace-relative files
7739
+ * - fs.list_files - List files recursively
7740
+ * - fs.search - Regex search (ripgrep or JS fallback)
7741
+ *
7742
+ * Safety features:
7743
+ * - Root sandbox with symlink resolution
7744
+ * - Path traversal prevention
7745
+ * - Size limits with hard caps
7746
+ * - Ignore patterns for common large directories
7747
+ * - UTF-8 validation
7748
+ *
7749
+ * @module
7750
+ */
7751
+
7752
+ /** Reserved tool names from tools.v0 specification. */
7753
+ declare const ToolNames: {
7754
+ readonly FS_READ_FILE: "fs.read_file";
7755
+ readonly FS_LIST_FILES: "fs.list_files";
7756
+ readonly FS_SEARCH: "fs.search";
7757
+ };
7758
+ /** Default size limits and caps from wire contract. */
7759
+ declare const FSDefaults: {
7760
+ readonly MAX_READ_BYTES: 64000;
7761
+ readonly HARD_MAX_READ_BYTES: 1000000;
7762
+ readonly MAX_LIST_ENTRIES: 2000;
7763
+ readonly HARD_MAX_LIST_ENTRIES: 20000;
7764
+ readonly MAX_SEARCH_MATCHES: 100;
7765
+ readonly HARD_MAX_SEARCH_MATCHES: 2000;
7766
+ readonly SEARCH_TIMEOUT_MS: 5000;
7767
+ readonly MAX_SEARCH_BYTES_PER_FILE: 1000000;
7768
+ };
7769
+ /** Default directories to skip during list/search operations. */
7770
+ declare const DEFAULT_IGNORE_DIRS: Set<string>;
7771
+ /** Configuration options for LocalFSToolPack. */
7772
+ interface LocalFSToolPackOptions {
7773
+ /** Root directory for sandboxing (required). All paths are relative to this. */
7774
+ root: string;
7775
+ /** Directory names to skip during list/search. Defaults to DEFAULT_IGNORE_DIRS. */
7776
+ ignoreDirs?: Set<string>;
7777
+ /** Default max_bytes for fs.read_file. Defaults to 64KB. */
7778
+ maxReadBytes?: number;
7779
+ /** Hard cap for fs.read_file max_bytes. Defaults to 1MB. */
7780
+ hardMaxReadBytes?: number;
7781
+ /** Default max_entries for fs.list_files. Defaults to 2000. */
7782
+ maxListEntries?: number;
7783
+ /** Hard cap for fs.list_files max_entries. Defaults to 20000. */
7784
+ hardMaxListEntries?: number;
7785
+ /** Default max_matches for fs.search. Defaults to 100. */
7786
+ maxSearchMatches?: number;
7787
+ /** Hard cap for fs.search max_matches. Defaults to 2000. */
7788
+ hardMaxSearchMatches?: number;
7789
+ /** Timeout for fs.search in milliseconds. Defaults to 5000. */
7790
+ searchTimeoutMs?: number;
7791
+ /** Max bytes to read per file during JS fallback search. Defaults to 1MB. */
7792
+ maxSearchBytesPerFile?: number;
7793
+ }
7794
+ /**
7795
+ * Tool pack providing safe filesystem access for LLM workflows.
7796
+ *
7797
+ * @example
7798
+ * ```typescript
7799
+ * const pack = new LocalFSToolPack({ root: process.cwd() });
7800
+ * const registry = pack.toRegistry();
7801
+ *
7802
+ * // Use tools in a workflow
7803
+ * const response = await client.responses.create({
7804
+ * model: "anthropic/claude-sonnet-4-20250514",
7805
+ * input: [{ type: "message", role: "user", content: [{ type: "text", text: "List all TypeScript files" }] }],
7806
+ * tools: pack.getToolDefinitions(),
7807
+ * });
7808
+ *
7809
+ * // Execute tool calls
7810
+ * const results = await registry.executeAll(response.output.filter(o => o.type === "tool_use"));
7811
+ * ```
7812
+ */
7813
+ declare class LocalFSToolPack {
7814
+ private readonly rootAbs;
7815
+ private readonly cfg;
7816
+ private rgPath;
7817
+ private rgChecked;
7818
+ constructor(options: LocalFSToolPackOptions);
7819
+ /**
7820
+ * Returns the tool definitions for LLM requests.
7821
+ * Use these when constructing the tools array for /responses requests.
7822
+ */
7823
+ getToolDefinitions(): Tool[];
7824
+ /**
7825
+ * Registers handlers into an existing ToolRegistry.
7826
+ * @param registry - The registry to register into
7827
+ * @returns The registry for chaining
7828
+ */
7829
+ registerInto(registry: ToolRegistry): ToolRegistry;
7830
+ /**
7831
+ * Creates a new ToolRegistry with fs.* tools pre-registered.
7832
+ */
7833
+ toRegistry(): ToolRegistry;
7834
+ private readFile;
7835
+ private listFiles;
7836
+ private search;
7837
+ /**
7838
+ * Resolves a workspace-relative path and validates it stays within the sandbox.
7839
+ * @throws {ToolArgumentError} if path is invalid
7840
+ * @throws {PathEscapeError} if resolved path escapes root
7841
+ */
7842
+ private resolveAndValidatePath;
7843
+ private detectRipgrep;
7844
+ private searchWithRipgrep;
7845
+ private normalizeRipgrepLine;
7846
+ private searchWithJS;
7847
+ private parseArgs;
7848
+ private toolArgumentError;
7849
+ private requireString;
7850
+ private optionalString;
7851
+ private optionalPositiveInt;
7852
+ private isValidUtf8;
7853
+ /**
7854
+ * Recursively walks a directory, calling visitor for each entry.
7855
+ * Visitor returns true to continue, false to skip (for dirs) or stop.
7856
+ */
7857
+ private walkDir;
7858
+ }
7859
+ /**
7860
+ * Creates a LocalFSToolPack with the given options.
7861
+ *
7862
+ * @example
7863
+ * ```typescript
7864
+ * const pack = createLocalFSToolPack({ root: process.cwd() });
7865
+ * ```
7866
+ */
7867
+ declare function createLocalFSToolPack(options: LocalFSToolPackOptions): LocalFSToolPack;
7868
+ /**
7869
+ * Creates a ToolRegistry with fs.* tools pre-registered.
7870
+ * Shorthand for createLocalFSToolPack(options).toRegistry().
7871
+ *
7872
+ * @example
7873
+ * ```typescript
7874
+ * const registry = createLocalFSTools({ root: process.cwd() });
7875
+ * const result = await registry.execute(toolCall);
7876
+ * ```
7877
+ */
7878
+ declare function createLocalFSTools(options: LocalFSToolPackOptions): ToolRegistry;
7879
+
7880
+ /**
7881
+ * Browser automation tools using Playwright with accessibility tree extraction.
7882
+ *
7883
+ * Uses CDP (Chrome DevTools Protocol) for semantic element targeting instead of
7884
+ * pixel-based screenshots, making it 10-100x cheaper than vision-based automation.
7885
+ *
7886
+ * @example
7887
+ * ```typescript
7888
+ * import { BrowserToolPack, createBrowserTools } from "@modelrelay/sdk";
7889
+ *
7890
+ * // Create a browser tool pack with domain restrictions
7891
+ * const pack = new BrowserToolPack({
7892
+ * allowedDomains: ["example.com", "docs.example.com"],
7893
+ * headless: true,
7894
+ * });
7895
+ *
7896
+ * // Initialize the browser (must be called before use)
7897
+ * await pack.initialize();
7898
+ *
7899
+ * // Get tool definitions for LLM
7900
+ * const tools = pack.getToolDefinitions();
7901
+ *
7902
+ * // Get registry for executing tool calls
7903
+ * const registry = pack.toRegistry();
7904
+ *
7905
+ * // Clean up when done
7906
+ * await pack.close();
7907
+ * ```
7908
+ *
7909
+ * @module
7910
+ */
7911
+
7912
+ type Browser = any;
7913
+ type BrowserContext = any;
7914
+ /**
7915
+ * Tool names for browser automation.
7916
+ */
7917
+ declare const BrowserToolNames: {
7918
+ /** Navigate to a URL and return accessibility tree */
7919
+ readonly NAVIGATE: "browser.navigate";
7920
+ /** Click an element by accessible name/role */
7921
+ readonly CLICK: "browser.click";
7922
+ /** Type text into an input field */
7923
+ readonly TYPE: "browser.type";
7924
+ /** Get current accessibility tree */
7925
+ readonly SNAPSHOT: "browser.snapshot";
7926
+ /** Scroll the page */
7927
+ readonly SCROLL: "browser.scroll";
7928
+ /** Capture a screenshot */
7929
+ readonly SCREENSHOT: "browser.screenshot";
7930
+ /** Extract data using CSS selectors */
7931
+ readonly EXTRACT: "browser.extract";
7932
+ };
7933
+ /**
7934
+ * Default configuration values for browser tools.
7935
+ */
7936
+ declare const BrowserDefaults: {
7937
+ /** Navigation timeout in milliseconds */
7938
+ readonly NAVIGATION_TIMEOUT_MS: 30000;
7939
+ /** Action timeout in milliseconds */
7940
+ readonly ACTION_TIMEOUT_MS: 5000;
7941
+ /** Maximum nodes to include in accessibility tree output */
7942
+ readonly MAX_SNAPSHOT_NODES: 500;
7943
+ /** Maximum screenshot size in bytes */
7944
+ readonly MAX_SCREENSHOT_BYTES: 5000000;
7945
+ };
7946
+ /**
7947
+ * Configuration options for BrowserToolPack.
7948
+ */
7949
+ interface BrowserToolPackOptions {
7950
+ /**
7951
+ * Whitelist of allowed domains. If set, only URLs matching these domains
7952
+ * will be allowed. Supports suffix matching (e.g., "example.com" matches
7953
+ * "sub.example.com").
7954
+ */
7955
+ allowedDomains?: string[];
7956
+ /**
7957
+ * Blacklist of blocked domains. URLs matching these domains will be rejected.
7958
+ * Supports suffix matching.
7959
+ */
7960
+ blockedDomains?: string[];
7961
+ /**
7962
+ * Navigation timeout in milliseconds. Default: 30000
7963
+ */
7964
+ navigationTimeoutMs?: number;
7965
+ /**
7966
+ * Action timeout in milliseconds. Default: 5000
7967
+ */
7968
+ actionTimeoutMs?: number;
7969
+ /**
7970
+ * Maximum nodes to include in accessibility tree. Default: 500
7971
+ */
7972
+ maxSnapshotNodes?: number;
7973
+ /**
7974
+ * Run browser in headless mode. Default: true
7975
+ */
7976
+ headless?: boolean;
7977
+ /**
7978
+ * Existing Browser instance to use instead of creating a new one.
7979
+ */
7980
+ browser?: Browser;
7981
+ /**
7982
+ * Existing BrowserContext to use instead of creating a new one.
7983
+ */
7984
+ context?: BrowserContext;
7985
+ }
7986
+ /**
7987
+ * A tool pack for browser automation using Playwright.
7988
+ *
7989
+ * Uses accessibility tree extraction via CDP for efficient, semantic-based
7990
+ * browser automation. This is much cheaper than vision-based approaches
7991
+ * because it works with structured text instead of screenshots.
7992
+ *
7993
+ * @example
7994
+ * ```typescript
7995
+ * const pack = new BrowserToolPack({
7996
+ * allowedDomains: ["example.com"],
7997
+ * });
7998
+ * await pack.initialize();
7999
+ *
8000
+ * const registry = pack.toRegistry();
8001
+ * const result = await registry.execute(toolCall);
8002
+ *
8003
+ * await pack.close();
8004
+ * ```
8005
+ */
8006
+ declare class BrowserToolPack {
8007
+ private browser;
8008
+ private context;
8009
+ private page;
8010
+ private cdpSession;
8011
+ private ownsBrowser;
8012
+ private ownsContext;
8013
+ private cfg;
8014
+ constructor(options?: BrowserToolPackOptions);
8015
+ /**
8016
+ * Initialize the browser. Must be called before using any tools.
8017
+ */
8018
+ initialize(): Promise<void>;
8019
+ /**
8020
+ * Close the browser and clean up resources.
8021
+ */
8022
+ close(): Promise<void>;
8023
+ /**
8024
+ * Get tool definitions for use with LLM APIs.
8025
+ */
8026
+ getToolDefinitions(): Tool[];
8027
+ /**
8028
+ * Register tool handlers into an existing registry.
8029
+ */
8030
+ registerInto(registry: ToolRegistry): ToolRegistry;
8031
+ /**
8032
+ * Create a new registry with just this pack's tools.
8033
+ */
8034
+ toRegistry(): ToolRegistry;
8035
+ private ensureInitialized;
8036
+ private parseArgs;
8037
+ private validateUrl;
8038
+ /**
8039
+ * Validates the current page URL against allowlist/blocklist.
8040
+ * Called after navigation and before any action to catch redirects
8041
+ * and in-session navigation to blocked domains.
8042
+ */
8043
+ private ensureCurrentUrlAllowed;
8044
+ private getAccessibilityTree;
8045
+ private formatAXTree;
8046
+ private navigate;
8047
+ private click;
8048
+ private type;
8049
+ private snapshot;
8050
+ private scroll;
8051
+ private screenshot;
8052
+ private extract;
8053
+ }
8054
+ /**
8055
+ * Create a BrowserToolPack with the given options.
8056
+ */
8057
+ declare function createBrowserToolPack(options?: BrowserToolPackOptions): BrowserToolPack;
8058
+ /**
8059
+ * Create a ToolRegistry with browser tools registered.
8060
+ *
8061
+ * Note: You must call `pack.initialize()` before using the registry.
8062
+ *
8063
+ * @example
8064
+ * ```typescript
8065
+ * const { pack, registry } = createBrowserTools({ headless: true });
8066
+ * await pack.initialize();
8067
+ *
8068
+ * // Use registry to execute tool calls
8069
+ * const result = await registry.execute(toolCall);
8070
+ *
8071
+ * await pack.close();
8072
+ * ```
8073
+ */
8074
+ declare function createBrowserTools(options?: BrowserToolPackOptions): {
8075
+ pack: BrowserToolPack;
8076
+ registry: ToolRegistry;
8077
+ };
8078
+
8079
+ /**
8080
+ * Tool runner for executing client-side tools in workflow runs.
8081
+ *
8082
+ * Handles node_waiting events by executing local tool handlers
8083
+ * and submitting results back to the server.
8084
+ *
8085
+ * @module
8086
+ */
8087
+
8088
+ /** Configuration options for ToolRunner. */
8089
+ interface ToolRunnerOptions {
8090
+ /** Tool registry containing handlers for tool names. */
8091
+ registry: ToolRegistry;
8092
+ /** Runs client for submitting results back to the server. */
8093
+ runsClient: RunsClient;
8094
+ /** Customer ID for attributed requests (optional). */
8095
+ customerId?: string;
8096
+ /** Called before executing each tool call (optional). */
8097
+ onBeforeExecute?: (pending: PendingToolCallV0$1) => void | Promise<void>;
8098
+ /** Called after each tool execution (optional). */
8099
+ onAfterExecute?: (result: ToolExecutionResult) => void | Promise<void>;
8100
+ /** Called when results are successfully submitted (optional). */
8101
+ onSubmitted?: (runId: RunId$1, count: number, status: RunStatusV0) => void | Promise<void>;
8102
+ /** Called when an error occurs during execution (optional). */
8103
+ onError?: (error: Error, pending?: PendingToolCallV0$1) => void | Promise<void>;
8104
+ }
8105
+ /** Response from handling a node_waiting event. */
8106
+ interface HandleWaitingResult {
8107
+ /** Number of results accepted by the server. */
8108
+ accepted: number;
8109
+ /** New run status after submitting results. */
8110
+ status: RunStatusV0;
8111
+ /** Execution results for each tool call. */
8112
+ results: ToolExecutionResult[];
8113
+ }
8114
+ /**
8115
+ * Executes client-side tools for workflow runs.
8116
+ *
8117
+ * Handles `node_waiting` events from the run event stream, executes the
8118
+ * corresponding tool handlers from the registry, and submits results
8119
+ * back to the server.
8120
+ *
8121
+ * @example
8122
+ * ```typescript
8123
+ * import { ModelRelay, createLocalFSTools, ToolRunner } from "modelrelay";
8124
+ *
8125
+ * const client = ModelRelay.fromSecretKey(process.env.MODELRELAY_SECRET_KEY!);
8126
+ * const registry = createLocalFSTools({ root: process.cwd() });
8127
+ *
8128
+ * const runner = new ToolRunner({
8129
+ * registry,
8130
+ * runsClient: client.runs,
8131
+ * });
8132
+ *
8133
+ * // Create a run and process events
8134
+ * const run = await client.runs.create(workflowSpec);
8135
+ * for await (const event of runner.processEvents(run.run_id, client.runs.events(run.run_id))) {
8136
+ * console.log(event.type);
8137
+ * }
8138
+ * ```
8139
+ */
8140
+ declare class ToolRunner {
8141
+ private readonly registry;
8142
+ private readonly runsClient;
8143
+ private readonly customerId?;
8144
+ private readonly onBeforeExecute?;
8145
+ private readonly onAfterExecute?;
8146
+ private readonly onSubmitted?;
8147
+ private readonly onError?;
8148
+ constructor(options: ToolRunnerOptions);
8149
+ /**
8150
+ * Handles a node_waiting event by executing tools and submitting results.
8151
+ *
8152
+ * @param runId - The run ID
8153
+ * @param nodeId - The node ID that is waiting
8154
+ * @param waiting - The waiting state with pending tool calls
8155
+ * @returns The submission response with accepted count and new status
8156
+ *
8157
+ * @example
8158
+ * ```typescript
8159
+ * for await (const event of client.runs.events(runId)) {
8160
+ * if (event.type === "node_waiting") {
8161
+ * const result = await runner.handleNodeWaiting(
8162
+ * runId,
8163
+ * event.node_id,
8164
+ * event.waiting
8165
+ * );
8166
+ * console.log(`Submitted ${result.accepted} results, status: ${result.status}`);
8167
+ * }
8168
+ * }
8169
+ * ```
8170
+ */
8171
+ handleNodeWaiting(runId: RunId$1, nodeId: NodeId$1, waiting: NodeWaitingV0$1): Promise<HandleWaitingResult>;
8172
+ /**
8173
+ * Processes a stream of run events, automatically handling node_waiting events.
8174
+ *
8175
+ * This is the main entry point for running a workflow with client-side tools.
8176
+ * It yields all events through (including node_waiting after handling).
8177
+ *
8178
+ * @param runId - The run ID to process
8179
+ * @param events - AsyncIterable of run events (from RunsClient.events())
8180
+ * @yields All run events, with node_waiting events handled automatically
8181
+ *
8182
+ * @example
8183
+ * ```typescript
8184
+ * const run = await client.runs.create(workflowSpec);
8185
+ * const eventStream = client.runs.events(run.run_id);
8186
+ *
8187
+ * for await (const event of runner.processEvents(run.run_id, eventStream)) {
8188
+ * switch (event.type) {
8189
+ * case "node_started":
8190
+ * console.log(`Node ${event.node_id} started`);
8191
+ * break;
8192
+ * case "node_succeeded":
8193
+ * console.log(`Node ${event.node_id} succeeded`);
8194
+ * break;
8195
+ * case "run_succeeded":
8196
+ * console.log("Run completed!");
8197
+ * break;
8198
+ * }
8199
+ * }
8200
+ * ```
8201
+ */
8202
+ processEvents(runId: RunId$1, events: AsyncIterable<RunEventV0>): AsyncGenerator<RunEventV0, void, undefined>;
8203
+ /**
8204
+ * Checks if a run event is a node_waiting event.
8205
+ * Utility for filtering events when not using processEvents().
8206
+ */
8207
+ static isNodeWaiting(event: RunEventV0): event is RunEventNodeWaitingV0;
8208
+ /**
8209
+ * Checks if a run status is terminal (succeeded, failed, or canceled).
8210
+ * Utility for determining when to stop polling.
8211
+ */
8212
+ static isTerminalStatus(status: RunStatusV0): boolean;
8213
+ }
8214
+ /**
8215
+ * Creates a ToolRunner with the given options.
8216
+ *
8217
+ * @example
8218
+ * ```typescript
8219
+ * const runner = createToolRunner({
8220
+ * registry: createLocalFSTools({ root: process.cwd() }),
8221
+ * runsClient: client.runs,
8222
+ * onBeforeExecute: (pending) => console.log(`Executing ${pending.name}`),
8223
+ * onAfterExecute: (result) => console.log(`Result: ${result.result}`),
8224
+ * });
8225
+ * ```
8226
+ */
8227
+ declare function createToolRunner(options: ToolRunnerOptions): ToolRunner;
8228
+
8229
+ type index$1_$defs = $defs;
8230
+ type index$1_components = components;
8231
+ type index$1_operations = operations;
8232
+ type index$1_paths = paths;
8233
+ type index$1_webhooks = webhooks;
8234
+ declare namespace index$1 {
8235
+ export type { index$1_$defs as $defs, index$1_components as components, index$1_operations as operations, index$1_paths as paths, index$1_webhooks as webhooks };
8236
+ }
8237
+
8238
+ /**
8239
+ * Workflow types with clean naming (no Workflow prefix).
8240
+ *
8241
+ * @example
8242
+ * ```typescript
8243
+ * import { workflow } from "@modelrelay/sdk";
8244
+ *
8245
+ * const spec: workflow.SpecV0 = {
8246
+ * kind: workflow.KindV0,
8247
+ * nodes: [{ id: "my_node", type: workflow.NodeTypes.LLMResponses, input: {...} }],
8248
+ * outputs: [],
8249
+ * };
8250
+ * ```
8251
+ */
8252
+
8253
+ type NodeId = NodeId$1;
8254
+ type OutputName = OutputName$1;
8255
+ type RunId = RunId$1;
8256
+ type PlanHash = PlanHash$1;
8257
+
8258
+ type Kind = WorkflowKind;
8259
+ type SpecV0 = WorkflowSpecV0;
8260
+ type NodeV0 = WorkflowNodeV0;
8261
+ type EdgeV0 = WorkflowEdgeV0;
8262
+ type OutputRefV0 = WorkflowOutputRefV0;
8263
+ type BindingV0 = LLMResponsesBindingV0;
8264
+ type BindingEncodingV0 = LLMResponsesBindingEncodingV0;
8265
+ type ToolLimitsV0 = LLMResponsesToolLimitsV0;
8266
+ type ToolExecutionV0 = ToolExecutionV0$1;
8267
+ type ToolExecutionModeV0 = ToolExecutionModeV0$1;
8268
+ type StatusV0 = RunStatusV0;
8269
+ type EventTypeV0 = RunEventTypeV0;
8270
+ type EventV0 = RunEventV0;
8271
+ type EventBaseV0 = RunEventBaseV0;
8272
+ type EventRunCompiledV0 = RunEventRunCompiledV0;
8273
+ type EventRunStartedV0 = RunEventRunStartedV0;
8274
+ type EventRunCompletedV0 = RunEventRunCompletedV0;
8275
+ type EventRunFailedV0 = RunEventRunFailedV0;
8276
+ type EventRunCanceledV0 = RunEventRunCanceledV0;
8277
+ type EventNodeStartedV0 = RunEventNodeStartedV0;
8278
+ type EventNodeSucceededV0 = RunEventNodeSucceededV0;
8279
+ type EventNodeFailedV0 = RunEventNodeFailedV0;
8280
+ type EventNodeLLMCallV0 = RunEventNodeLLMCallV0;
8281
+ type EventNodeToolCallV0 = RunEventNodeToolCallV0;
8282
+ type EventNodeToolResultV0 = RunEventNodeToolResultV0;
8283
+ type EventNodeWaitingV0 = RunEventNodeWaitingV0;
8284
+ type EventNodeOutputDeltaV0 = RunEventNodeOutputDeltaV0;
8285
+ type EventNodeOutputV0 = RunEventNodeOutputV0;
8286
+ type NodeErrorV0 = NodeErrorV0$1;
8287
+ type NodeOutputDeltaV0 = NodeOutputDeltaV0$1;
8288
+ type NodeLLMCallV0 = NodeLLMCallV0$1;
8289
+ type NodeToolCallV0 = NodeToolCallV0$1;
8290
+ type NodeToolResultV0 = NodeToolResultV0$1;
8291
+ type NodeWaitingV0 = NodeWaitingV0$1;
8292
+ type PendingToolCallV0 = PendingToolCallV0$1;
8293
+ type FunctionToolCallV0 = FunctionToolCallV0$1;
8294
+ type TokenUsageV0 = TokenUsageV0$1;
8295
+ type PayloadInfoV0 = PayloadInfoV0$1;
8296
+ type StreamEventKind = StreamEventKind$1;
8297
+ declare const KindV0: "workflow.v0";
8298
+ declare const NodeTypes: {
8299
+ readonly LLMResponses: "llm.responses";
8300
+ readonly JoinAll: "join.all";
8301
+ readonly TransformJSON: "transform.json";
8302
+ };
8303
+ type NodeType = (typeof NodeTypes)[keyof typeof NodeTypes];
8304
+ declare const BindingEncodings: {
8305
+ readonly JSON: "json";
8306
+ readonly JSONString: "json_string";
8307
+ };
8308
+ declare const ToolExecutionModes: {
8309
+ readonly Server: "server";
8310
+ readonly Client: "client";
8311
+ };
8312
+ /** JSON pointer to extract text content from an LLM response output. */
8313
+ declare const LLM_TEXT_OUTPUT = "/output/0/content/0/text";
8314
+ /** JSON pointer to inject text into the user message of an LLM request. */
8315
+ declare const LLM_USER_MESSAGE_TEXT = "/request/input/1/content/0/text";
8316
+
8317
+ type index_BindingEncodingV0 = BindingEncodingV0;
8318
+ declare const index_BindingEncodings: typeof BindingEncodings;
8319
+ type index_BindingV0 = BindingV0;
8320
+ type index_EdgeV0 = EdgeV0;
8321
+ type index_EventBaseV0 = EventBaseV0;
8322
+ type index_EventNodeFailedV0 = EventNodeFailedV0;
8323
+ type index_EventNodeLLMCallV0 = EventNodeLLMCallV0;
8324
+ type index_EventNodeOutputDeltaV0 = EventNodeOutputDeltaV0;
8325
+ type index_EventNodeOutputV0 = EventNodeOutputV0;
8326
+ type index_EventNodeStartedV0 = EventNodeStartedV0;
8327
+ type index_EventNodeSucceededV0 = EventNodeSucceededV0;
8328
+ type index_EventNodeToolCallV0 = EventNodeToolCallV0;
8329
+ type index_EventNodeToolResultV0 = EventNodeToolResultV0;
8330
+ type index_EventNodeWaitingV0 = EventNodeWaitingV0;
8331
+ type index_EventRunCanceledV0 = EventRunCanceledV0;
8332
+ type index_EventRunCompiledV0 = EventRunCompiledV0;
8333
+ type index_EventRunCompletedV0 = EventRunCompletedV0;
8334
+ type index_EventRunFailedV0 = EventRunFailedV0;
8335
+ type index_EventRunStartedV0 = EventRunStartedV0;
8336
+ type index_EventTypeV0 = EventTypeV0;
8337
+ type index_EventV0 = EventV0;
8338
+ type index_FunctionToolCallV0 = FunctionToolCallV0;
8339
+ type index_Kind = Kind;
8340
+ declare const index_KindV0: typeof KindV0;
8341
+ declare const index_LLM_TEXT_OUTPUT: typeof LLM_TEXT_OUTPUT;
8342
+ declare const index_LLM_USER_MESSAGE_TEXT: typeof LLM_USER_MESSAGE_TEXT;
8343
+ type index_NodeErrorV0 = NodeErrorV0;
8344
+ type index_NodeId = NodeId;
8345
+ type index_NodeLLMCallV0 = NodeLLMCallV0;
8346
+ type index_NodeOutputDeltaV0 = NodeOutputDeltaV0;
8347
+ type index_NodeToolCallV0 = NodeToolCallV0;
8348
+ type index_NodeToolResultV0 = NodeToolResultV0;
8349
+ type index_NodeType = NodeType;
8350
+ declare const index_NodeTypes: typeof NodeTypes;
8351
+ type index_NodeV0 = NodeV0;
8352
+ type index_NodeWaitingV0 = NodeWaitingV0;
8353
+ type index_OutputName = OutputName;
8354
+ type index_OutputRefV0 = OutputRefV0;
8355
+ type index_PayloadInfoV0 = PayloadInfoV0;
8356
+ type index_PendingToolCallV0 = PendingToolCallV0;
8357
+ type index_PlanHash = PlanHash;
8358
+ type index_RunId = RunId;
8359
+ type index_SpecV0 = SpecV0;
8360
+ type index_StatusV0 = StatusV0;
8361
+ type index_StreamEventKind = StreamEventKind;
8362
+ type index_TokenUsageV0 = TokenUsageV0;
8363
+ type index_ToolExecutionModeV0 = ToolExecutionModeV0;
8364
+ declare const index_ToolExecutionModes: typeof ToolExecutionModes;
8365
+ type index_ToolExecutionV0 = ToolExecutionV0;
8366
+ type index_ToolLimitsV0 = ToolLimitsV0;
8367
+ declare const index_parseNodeId: typeof parseNodeId;
8368
+ declare const index_parseOutputName: typeof parseOutputName;
8369
+ declare const index_parsePlanHash: typeof parsePlanHash;
8370
+ declare const index_parseRunId: typeof parseRunId;
5852
8371
  declare namespace index {
5853
- export type { index_$defs as $defs, index_components as components, index_operations as operations, index_paths as paths, index_webhooks as webhooks };
8372
+ export { type index_BindingEncodingV0 as BindingEncodingV0, index_BindingEncodings as BindingEncodings, type index_BindingV0 as BindingV0, type index_EdgeV0 as EdgeV0, type index_EventBaseV0 as EventBaseV0, type index_EventNodeFailedV0 as EventNodeFailedV0, type index_EventNodeLLMCallV0 as EventNodeLLMCallV0, type index_EventNodeOutputDeltaV0 as EventNodeOutputDeltaV0, type index_EventNodeOutputV0 as EventNodeOutputV0, type index_EventNodeStartedV0 as EventNodeStartedV0, type index_EventNodeSucceededV0 as EventNodeSucceededV0, type index_EventNodeToolCallV0 as EventNodeToolCallV0, type index_EventNodeToolResultV0 as EventNodeToolResultV0, type index_EventNodeWaitingV0 as EventNodeWaitingV0, type index_EventRunCanceledV0 as EventRunCanceledV0, type index_EventRunCompiledV0 as EventRunCompiledV0, type index_EventRunCompletedV0 as EventRunCompletedV0, type index_EventRunFailedV0 as EventRunFailedV0, type index_EventRunStartedV0 as EventRunStartedV0, type index_EventTypeV0 as EventTypeV0, type index_EventV0 as EventV0, type index_FunctionToolCallV0 as FunctionToolCallV0, type index_Kind as Kind, index_KindV0 as KindV0, index_LLM_TEXT_OUTPUT as LLM_TEXT_OUTPUT, index_LLM_USER_MESSAGE_TEXT as LLM_USER_MESSAGE_TEXT, type index_NodeErrorV0 as NodeErrorV0, type index_NodeId as NodeId, type index_NodeLLMCallV0 as NodeLLMCallV0, type index_NodeOutputDeltaV0 as NodeOutputDeltaV0, type index_NodeToolCallV0 as NodeToolCallV0, type index_NodeToolResultV0 as NodeToolResultV0, type index_NodeType as NodeType, index_NodeTypes as NodeTypes, type index_NodeV0 as NodeV0, type index_NodeWaitingV0 as NodeWaitingV0, type index_OutputName as OutputName, type index_OutputRefV0 as OutputRefV0, type index_PayloadInfoV0 as PayloadInfoV0, type index_PendingToolCallV0 as PendingToolCallV0, type index_PlanHash as PlanHash, type index_RunId as RunId, type index_SpecV0 as SpecV0, type index_StatusV0 as StatusV0, type index_StreamEventKind as StreamEventKind, type index_TokenUsageV0 as TokenUsageV0, type index_ToolExecutionModeV0 as ToolExecutionModeV0, index_ToolExecutionModes as ToolExecutionModes, type index_ToolExecutionV0 as ToolExecutionV0, type index_ToolLimitsV0 as ToolLimitsV0, index_parseNodeId as parseNodeId, index_parseOutputName as parseOutputName, index_parsePlanHash as parsePlanHash, index_parseRunId as parseRunId };
8373
+ }
8374
+
8375
+ /**
8376
+ * In-memory session store.
8377
+ *
8378
+ * Session data is lost when the process exits. Use for:
8379
+ * - Development/testing
8380
+ * - Short-lived sessions that don't need persistence
8381
+ * - Environments without filesystem access
8382
+ *
8383
+ * @module
8384
+ */
8385
+
8386
+ /**
8387
+ * In-memory implementation of SessionStore.
8388
+ *
8389
+ * All operations are synchronous but wrapped in promises for interface compatibility.
8390
+ */
8391
+ declare class MemorySessionStore implements SessionStore {
8392
+ private readonly sessions;
8393
+ load(id: SessionId): Promise<SessionState | null>;
8394
+ save(state: SessionState): Promise<void>;
8395
+ delete(id: SessionId): Promise<void>;
8396
+ list(): Promise<SessionId[]>;
8397
+ close(): Promise<void>;
8398
+ /**
8399
+ * Get the number of sessions in the store.
8400
+ * Useful for testing.
8401
+ */
8402
+ get size(): number;
5854
8403
  }
8404
+ /**
8405
+ * Create a new in-memory session store.
8406
+ */
8407
+ declare function createMemorySessionStore(): MemorySessionStore;
5855
8408
 
5856
8409
  declare class ModelRelay {
5857
8410
  readonly responses: ResponsesClient;
5858
8411
  readonly runs: RunsClient;
5859
8412
  readonly workflows: WorkflowsClient;
8413
+ readonly images: ImagesClient;
5860
8414
  readonly auth: AuthClient;
5861
8415
  readonly customers: CustomersClient;
5862
8416
  readonly tiers: TiersClient;
5863
8417
  readonly models: ModelsClient;
8418
+ readonly sessions: SessionsClient;
5864
8419
  readonly baseUrl: string;
5865
8420
  static fromSecretKey(secretKey: string, options?: Omit<ModelRelayKeyOptions, "key">): ModelRelay;
5866
8421
  static fromPublishableKey(publishableKey: string, options?: Omit<ModelRelayKeyOptions, "key">): ModelRelay;
@@ -5869,4 +8424,4 @@ declare class ModelRelay {
5869
8424
  forCustomer(customerId: string): CustomerScopedModelRelay;
5870
8425
  }
5871
8426
 
5872
- export { type APICheckoutSession, type APICustomerRef, APIError, type APIFrontendToken, type APIKey, type APIResponsesResponse, type APIUsage, type ApiKey, type AttemptRecord, AuthClient, type AuthHeaders, type CatalogModel, type CheckoutSession, type CheckoutSessionRequest, type Citation, type CodeExecConfig, ConfigError, type ContentPart, type ContentPartType, ContentPartTypes, type Customer, type CustomerClaimRequest, type CustomerCreateRequest, type CustomerMetadata, CustomerResponsesClient, CustomerScopedModelRelay, type CustomerToken, CustomerTokenProvider, type CustomerTokenRequest, type CustomerUpsertRequest, CustomersClient, DEFAULT_BASE_URL, DEFAULT_CLIENT_HEADER, DEFAULT_CONNECT_TIMEOUT_MS, DEFAULT_REQUEST_TIMEOUT_MS, type DeepPartial, type DeviceStartRequest, type DeviceStartResponse, type DeviceTokenPending, type DeviceTokenResponse, type DeviceTokenResult, type ErrorCategory, type ErrorCode, ErrorCodes, type FieldError, type FrontendCustomer, type FrontendToken, type FrontendTokenAutoProvisionRequest, FrontendTokenProvider, type FrontendTokenRequest, type FunctionCall, type FunctionCallDelta, type FunctionTool, type HttpRequestMetrics, type InputItem, type InputItemType, InputItemTypes, type JSONSchemaFormat, type JsonSchemaOptions, type KnownStopReason, type MessageDeltaData, type MessageRole, MessageRoles, type MessageStartData, type MessageStopData, type MetricsCallbacks, type ModelCapability, type ModelId, ModelRelay, type ModelRelayBaseOptions, ModelRelayError, type ModelRelayKeyOptions, type ModelRelayOptions, type ModelRelayTokenOptions, type ModelRelayTokenProviderOptions, ModelsClient, type NodeErrorV0, type NodeId, type NonEmptyArray, type OAuthDeviceAuthorization, type OAuthDeviceAuthorizationRequest, type OAuthDeviceToken, type OAuthDeviceTokenPollRequest, type OIDCExchangeRequest, OIDCExchangeTokenProvider, type OutputFormat, type OutputFormatType, OutputFormatTypes, type OutputItem, type OutputItemType, OutputItemTypes, type OutputName, type PayloadInfoV0, type PlanHash, type PriceInterval, type Project, type ProviderId, type PublishableKey, type RequestContext, type Response$1 as Response, type ResponseEvent, type ResponseEventType, ResponsesClient, ResponsesStream, type RetryConfig, type RetryHandler, type RetryMetadata, type RetryOptions, type RunEventTypeV0, type RunEventV0, type RunId, type RunStatusV0, RunsClient, RunsEventStream, SDK_VERSION, type Schema, type SecretKey, type StopReason, StopReasons, type StreamFirstTokenMetrics, StreamProtocolError, StreamTimeoutError, type StreamTimeoutKind, StructuredDecodeError, type StructuredErrorKind, StructuredExhaustedError, type StructuredJSONEvent, type StructuredJSONRecordType, StructuredJSONStream, type StructuredOptions, type StructuredResult, type SubscriptionStatus, type Tier, type TierCheckoutRequest, type TierCheckoutSession, type TierCode, TiersClient, type TokenProvider, type TokenType, type TokenUsageMetrics, type Tool, ToolArgsError, type ToolCall, ToolCallAccumulator, type ToolCallDelta, type ToolChoice, type ToolChoiceType, ToolChoiceTypes, type ToolExecutionResult, type ToolHandler, ToolRegistry, type ToolType, ToolTypes, type TraceCallbacks, type TransformJSONValueV0, TransportError, type TransportErrorKind, type Usage, type UsageSummary, type ValidationIssue, WORKFLOWS_COMPILE_PATH, type WebSearchConfig, type WebToolMode, WebToolModes, WorkflowBuilderV0, type WorkflowBuilderV0State, type WorkflowEdgeV0, type WorkflowKind, WorkflowKinds, type WorkflowNodeType, WorkflowNodeTypes, type WorkflowNodeV0, type WorkflowOutputRefV0, type WorkflowSpecV0, WorkflowValidationError, type WorkflowValidationIssue, WorkflowsClient, type WorkflowsCompileOptions, type WorkflowsCompileRequestV0, type WorkflowsCompileResponseV0, type WorkflowsCompileV0Result, type XSearchConfig, type ZodLikeSchema, asModelId, asProviderId, asTierCode, assistantMessageWithToolCalls, createAccessTokenAuth, createApiKeyAuth, createAssistantMessage, createFunctionCall, createFunctionTool, createFunctionToolFromSchema, createRetryMessages, createSystemMessage, createToolCall, createUsage, createUserMessage, createWebTool, defaultRetryHandler, executeWithRetry, firstToolCall, formatToolErrorForModel, index as generated, getRetryableErrors, hasRetryableErrors, hasToolCalls, isAutoProvisionDisabled, isAutoProvisionMisconfigured, isEmailRequired, isIdentityRequired, isProvisioningError, isPublishableKey, isSecretKey, mergeMetrics, mergeTrace, modelToString, normalizeModelId, normalizeStopReason, outputFormatFromZod, parseApiKey, parseErrorResponse, parseNodeId, parseOutputName, parsePlanHash, parsePublishableKey, parseRunId, parseSecretKey, parseToolArgs, parseToolArgsRaw, pollOAuthDeviceToken, respondToToolCall, runOAuthDeviceFlowForIDToken, startOAuthDeviceAuthorization, stopReasonToString, toolChoiceAuto, toolChoiceNone, toolChoiceRequired, toolResultMessage, transformJSONMerge, transformJSONObject, transformJSONValue, tryParseToolArgs, validateWithZod, workflowV0, workflow_v0_schema as workflowV0Schema, zodToJsonSchema };
8427
+ export { type APICheckoutSession, type APICustomerRef, APIError, type APIFrontendToken, type APIKey, type APIResponsesResponse, type APIUsage, type ApiKey, type AttemptRecord, AuthClient, type AuthHeaders, type BillingProvider, BillingProviders, BrowserDefaults, BrowserToolNames, BrowserToolPack, type BrowserToolPackOptions, type CatalogModel, Chain, ChainBuilder, type CheckoutSession, type Citation, type CodeExecConfig, ConfigError, type ContentPart, type ContentPartType, ContentPartTypes, type Customer, type CustomerClaimRequest, type CustomerCreateRequest, type CustomerMetadata, CustomerResponsesClient, CustomerScopedModelRelay, type CustomerSubscribeRequest, type CustomerToken, CustomerTokenProvider, type CustomerTokenRequest, type CustomerUpsertRequest, type CustomerWithSubscription, CustomersClient, DEFAULT_BASE_URL, DEFAULT_CLIENT_HEADER, DEFAULT_CONNECT_TIMEOUT_MS, DEFAULT_IGNORE_DIRS, DEFAULT_REQUEST_TIMEOUT_MS, type DeepPartial, type DeviceStartRequest, type DeviceStartResponse, type DeviceTokenPending, type DeviceTokenResponse, type DeviceTokenResult, type ErrorCategory, type ErrorCode, ErrorCodes, FSDefaults, ToolNames as FSToolNames, type FieldError, type FrontendCustomer, type FrontendToken, type FrontendTokenAutoProvisionRequest, FrontendTokenProvider, type FrontendTokenRequest, type FunctionCall, type FunctionCallDelta, type FunctionTool, type HandleWaitingResult, type HttpRequestMetrics, type ImageData, type ImageRequest, type ImageResponse, type ImageResponseFormat, type ImageUsage, ImagesClient, type InputItem, type InputItemType, InputItemTypes, type JSONSchemaFormat, type JsonSchemaOptions, type KnownStopReason, LLMNodeBuilder, LLMStep, type LLMStepConfig, LLM_TEXT_OUTPUT$1 as LLM_TEXT_OUTPUT, LLM_USER_MESSAGE_TEXT$1 as LLM_USER_MESSAGE_TEXT, type ListSessionsOptions, type ListSessionsResponse, LocalFSToolPack, type LocalFSToolPackOptions, LocalSession, type LocalSessionOptions, type LocalSessionPersistence, MapItem, type MapItemConfig, MapReduce, MapReduceBuilder, MemorySessionStore, type MessageDeltaData, type MessageRole, MessageRoles, type MessageStartData, type MessageStopData, type MetricsCallbacks, type ModelCapability, type ModelId, ModelRelay, type ModelRelayBaseOptions, ModelRelayError, type ModelRelayKeyOptions, type ModelRelayOptions, type ModelRelayTokenOptions, type ModelRelayTokenProviderOptions, ModelsClient, type NodeErrorV0$1 as NodeErrorV0, type NodeId$1 as NodeId, type NonEmptyArray, type OAuthDeviceAuthorization, type OAuthDeviceAuthorizationRequest, type OAuthDeviceToken, type OAuthDeviceTokenPollRequest, type OIDCExchangeRequest, OIDCExchangeTokenProvider, type OutputFormat, type OutputFormatType, OutputFormatTypes, type OutputItem, type OutputItemType, OutputItemTypes, type OutputName$1 as OutputName, Parallel, ParallelBuilder, PathEscapeError, type PayloadInfoV0$1 as PayloadInfoV0, type PlanHash$1 as PlanHash, type PriceInterval, type Project, type ProviderId, type PublishableKey, type RemoteSessionInfo, type RemoteSessionOptions, type RequestContext, type Response$1 as Response, type ResponseEvent, type ResponseEventType, ResponsesClient, ResponsesStream, type RetryConfig, type RetryHandler, type RetryMetadata, type RetryOptions, type RunEventTypeV0, type RunEventV0, type RunId$1 as RunId, type RunStatusV0, RunsClient, RunsEventStream, SDK_VERSION, type Schema, type SecretKey, type Session, type SessionArtifacts, type SessionId, type SessionMessage, type SessionPendingToolCall, type SessionRunOptions, type SessionRunResult, type SessionRunStatus, type SessionState, type SessionStore, type SessionType, type SessionUsageSummary, SessionsClient, type StopReason, StopReasons, type StreamFirstTokenMetrics, StreamProtocolError, StreamTimeoutError, type StreamTimeoutKind, StructuredDecodeError, type StructuredErrorKind, StructuredExhaustedError, type StructuredJSONEvent, type StructuredJSONRecordType, StructuredJSONStream, type StructuredOptions, type StructuredResult, type Subscription, type SubscriptionStatusKind, SubscriptionStatuses, type Tier, type TierCheckoutRequest, type TierCheckoutSession, type TierCode, TiersClient, type TokenProvider, type TokenType, type TokenUsageMetrics, type Tool, ToolArgsError, ToolArgumentError, type ToolCall, ToolCallAccumulator, type ToolCallDelta, type ToolChoice, type ToolChoiceType, ToolChoiceTypes, type ToolExecutionResult, type ToolHandler, ToolRegistry, ToolRunner, type ToolRunnerOptions, type ToolType, ToolTypes, type TraceCallbacks, TransformJSONNodeBuilder, type TransformJSONValueV0, TransportError, type TransportErrorKind, type Usage, type UsageSummary, type ValidationIssue, WORKFLOWS_COMPILE_PATH, type WebSearchConfig, type WebToolMode, WebToolModes, Workflow, WorkflowBuilderV0, type WorkflowBuilderV0State, type WorkflowEdgeV0, type WorkflowKind, WorkflowKinds, type WorkflowNodeType, WorkflowNodeTypes, type WorkflowNodeV0, type WorkflowOutputRefV0, type WorkflowSpecV0, WorkflowValidationError, type WorkflowValidationIssue, WorkflowsClient, type WorkflowsCompileOptions, type WorkflowsCompileRequestV0, type WorkflowsCompileResponseV0, type WorkflowsCompileV0Result, type XSearchConfig, type ZodLikeSchema, asModelId, asProviderId, asSessionId, asTierCode, assistantMessageWithToolCalls, createAccessTokenAuth, createApiKeyAuth, createAssistantMessage, createBrowserToolPack, createBrowserTools, createFunctionCall, createFunctionTool, createFunctionToolFromSchema, createLocalFSToolPack, createLocalFSTools, createLocalSession, createMemorySessionStore, createRetryMessages, createSystemMessage, createToolCall, createToolRunner, createUsage, createUserMessage, createWebTool, defaultRetryHandler, executeWithRetry, firstToolCall, formatToolErrorForModel, generateSessionId, index$1 as generated, getRetryableErrors, hasRetryableErrors, hasToolCalls, isAutoProvisionDisabled, isAutoProvisionMisconfigured, isEmailRequired, isIdentityRequired, isProvisioningError, isPublishableKey, isSecretKey, mergeMetrics, mergeTrace, modelToString, newWorkflow, normalizeModelId, normalizeStopReason, outputFormatFromZod, parseApiKey, parseErrorResponse, parseNodeId, parseOutputName, parsePlanHash, parsePublishableKey, parseRunId, parseSecretKey, parseToolArgs, parseToolArgsRaw, pollOAuthDeviceToken, respondToToolCall, runOAuthDeviceFlowForIDToken, startOAuthDeviceAuthorization, stopReasonToString, toolChoiceAuto, toolChoiceNone, toolChoiceRequired, toolResultMessage, transformJSONMerge, transformJSONObject, transformJSONValue, tryParseToolArgs, validateWithZod, index as workflow, workflowV0, workflow_v0_schema as workflowV0Schema, zodToJsonSchema };