@modelrelay/sdk 1.3.2 → 1.10.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts CHANGED
@@ -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
  /**
@@ -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;
@@ -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
  */
@@ -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,56 @@ 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
+ };
2996
3173
  }
2997
3174
  type webhooks = Record<string, never>;
2998
3175
  interface components {
@@ -3106,8 +3283,9 @@ interface components {
3106
3283
  */
3107
3284
  spend_limit_cents?: number;
3108
3285
  models?: components["schemas"]["TierModel"][];
3109
- /** @description Stripe price ID for this tier */
3110
- stripe_price_id?: string;
3286
+ billing_provider?: components["schemas"]["BillingProvider"];
3287
+ /** @description Billing provider price reference for this tier */
3288
+ billing_price_ref?: string;
3111
3289
  /**
3112
3290
  * Format: uint64
3113
3291
  * @description Subscription price amount in cents
@@ -3136,6 +3314,7 @@ interface components {
3136
3314
  */
3137
3315
  spend_limit_cents: number;
3138
3316
  models: components["schemas"]["TierModelCreate"][];
3317
+ billing_provider?: components["schemas"]["BillingProvider"];
3139
3318
  /**
3140
3319
  * Format: uint64
3141
3320
  * @description Subscription price amount in cents (paid tiers)
@@ -3158,6 +3337,7 @@ interface components {
3158
3337
  */
3159
3338
  spend_limit_cents: number;
3160
3339
  models?: components["schemas"]["TierModelCreate"][];
3340
+ billing_provider?: components["schemas"]["BillingProvider"];
3161
3341
  /**
3162
3342
  * Format: uint64
3163
3343
  * @description Subscription price amount in cents (paid tiers)
@@ -3170,14 +3350,25 @@ interface components {
3170
3350
  */
3171
3351
  trial_days?: number;
3172
3352
  };
3353
+ /** @description Arbitrary customer metadata (max 10KB). Keys are limited to 40 characters. Values can be any JSON type. Nesting depth limited to 5 levels. */
3354
+ CustomerMetadata: {
3355
+ [key: string]: unknown;
3356
+ };
3357
+ /**
3358
+ * @description Subscription status (active, past_due, canceled, etc.)
3359
+ * @enum {string}
3360
+ */
3361
+ SubscriptionStatusKind: "active" | "trialing" | "past_due" | "canceled" | "unpaid" | "incomplete" | "incomplete_expired" | "paused";
3362
+ /**
3363
+ * @description Billing provider backing the subscription or tier.
3364
+ * @enum {string}
3365
+ */
3366
+ BillingProvider: "stripe" | "crypto" | "app_store" | "external";
3173
3367
  Customer: {
3174
3368
  /** Format: uuid */
3175
3369
  id?: string;
3176
3370
  /** Format: uuid */
3177
3371
  project_id?: string;
3178
- /** Format: uuid */
3179
- tier_id?: string;
3180
- tier_code?: components["schemas"]["TierCode"];
3181
3372
  /** @description External customer identifier from your system */
3182
3373
  external_id?: string;
3183
3374
  /**
@@ -3185,16 +3376,28 @@ interface components {
3185
3376
  * @description Customer email address
3186
3377
  */
3187
3378
  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;
3379
+ metadata?: components["schemas"]["CustomerMetadata"];
3380
+ /** Format: date-time */
3381
+ created_at?: string;
3382
+ /** Format: date-time */
3383
+ updated_at?: string;
3384
+ };
3385
+ Subscription: {
3386
+ /** Format: uuid */
3387
+ id?: string;
3388
+ /** Format: uuid */
3389
+ project_id?: string;
3390
+ /** Format: uuid */
3391
+ customer_id?: string;
3392
+ /** Format: uuid */
3393
+ tier_id?: string;
3394
+ tier_code?: components["schemas"]["TierCode"];
3395
+ billing_provider?: components["schemas"]["BillingProvider"];
3396
+ /** @description Billing customer ID from the provider */
3397
+ billing_customer_id?: string;
3398
+ /** @description Billing subscription ID from the provider */
3399
+ billing_subscription_id?: string;
3400
+ subscription_status?: components["schemas"]["SubscriptionStatusKind"];
3198
3401
  /**
3199
3402
  * Format: date-time
3200
3403
  * @description Start of the current billing period
@@ -3210,8 +3413,14 @@ interface components {
3210
3413
  /** Format: date-time */
3211
3414
  updated_at?: string;
3212
3415
  };
3213
- CustomerMe: components["schemas"]["Customer"] & {
3214
- tier: components["schemas"]["Tier"];
3416
+ CustomerWithSubscription: {
3417
+ customer: components["schemas"]["Customer"];
3418
+ subscription?: components["schemas"]["Subscription"];
3419
+ };
3420
+ CustomerMe: {
3421
+ customer: components["schemas"]["Customer"];
3422
+ subscription?: components["schemas"]["Subscription"];
3423
+ tier?: components["schemas"]["Tier"];
3215
3424
  };
3216
3425
  CustomerMeResponse: {
3217
3426
  customer: components["schemas"]["CustomerMe"];
@@ -3226,6 +3435,8 @@ interface components {
3226
3435
  requests: number;
3227
3436
  /** Format: int64 */
3228
3437
  tokens: number;
3438
+ /** Format: int64 */
3439
+ images?: number;
3229
3440
  /**
3230
3441
  * Format: int64
3231
3442
  * @description Credits used in this day bucket (only for paid tiers)
@@ -3248,6 +3459,8 @@ interface components {
3248
3459
  requests: number;
3249
3460
  /** Format: int64 */
3250
3461
  tokens: number;
3462
+ /** Format: int64 */
3463
+ images: number;
3251
3464
  /**
3252
3465
  * Format: int64
3253
3466
  * @description Credits granted for this billing window (only for paid tiers)
@@ -3288,11 +3501,7 @@ interface components {
3288
3501
  /** @description Currency code for the price (e.g., 'usd') */
3289
3502
  price_currency?: string;
3290
3503
  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";
3504
+ subscription_status?: components["schemas"]["SubscriptionStatusKind"];
3296
3505
  /**
3297
3506
  * Format: date-time
3298
3507
  * @description Start of the current billing period
@@ -3308,19 +3517,14 @@ interface components {
3308
3517
  subscription: components["schemas"]["CustomerMeSubscription"];
3309
3518
  };
3310
3519
  CustomerCreate: {
3311
- /** Format: uuid */
3312
- tier_id: string;
3313
3520
  /** @description External customer identifier from your system */
3314
3521
  external_id: string;
3315
3522
  /**
3316
3523
  * Format: email
3317
3524
  * @description Customer email address
3318
3525
  */
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
- };
3526
+ email: string;
3527
+ metadata?: components["schemas"]["CustomerMetadata"];
3324
3528
  };
3325
3529
  /** @enum {string} */
3326
3530
  MessageRole: "system" | "user" | "assistant" | "tool";
@@ -3359,7 +3563,7 @@ interface components {
3359
3563
  };
3360
3564
  Tool: {
3361
3565
  /** @enum {string} */
3362
- type: "function" | "web" | "x_search" | "code_execution";
3566
+ type: "function" | "web" | "x_search" | "code_execution" | "image_generation";
3363
3567
  function?: {
3364
3568
  name?: components["schemas"]["ToolName"];
3365
3569
  description?: string;
@@ -3376,6 +3580,11 @@ interface components {
3376
3580
  code_execution?: {
3377
3581
  [key: string]: unknown;
3378
3582
  };
3583
+ /** @description Configuration for server-side image generation tool */
3584
+ image_generation?: {
3585
+ /** @description Image generation model ID (e.g., gemini-2.5-flash-image) */
3586
+ model: string;
3587
+ };
3379
3588
  };
3380
3589
  ToolChoice: {
3381
3590
  /** @enum {string} */
@@ -3559,7 +3768,7 @@ interface components {
3559
3768
  ToolCall: {
3560
3769
  id: components["schemas"]["ToolCallId"];
3561
3770
  /** @enum {string} */
3562
- type: "function" | "web" | "x_search" | "code_execution";
3771
+ type: "function" | "web" | "x_search" | "code_execution" | "image_generation";
3563
3772
  function?: {
3564
3773
  name?: components["schemas"]["ToolName"];
3565
3774
  /** @description JSON string of function arguments */
@@ -3597,6 +3806,15 @@ interface components {
3597
3806
  customer_external_id: string;
3598
3807
  tier_code: components["schemas"]["TierCode"];
3599
3808
  };
3809
+ CheckoutSessionResponse: {
3810
+ /** @description Stripe checkout session ID */
3811
+ session_id: string;
3812
+ /**
3813
+ * Format: uri
3814
+ * @description Checkout URL
3815
+ */
3816
+ url: string;
3817
+ };
3600
3818
  DeviceStartResponse: {
3601
3819
  /** @description Device code used for polling /auth/device/token */
3602
3820
  device_code: string;
@@ -3639,8 +3857,7 @@ interface components {
3639
3857
  active: boolean;
3640
3858
  /** @description Stripe subscription ID */
3641
3859
  subscription_id?: string;
3642
- /** @description Subscription status (active, past_due, canceled, etc.) */
3643
- status?: string;
3860
+ status?: components["schemas"]["SubscriptionStatusKind"];
3644
3861
  /**
3645
3862
  * Format: date-time
3646
3863
  * @description Start of the current billing period
@@ -3844,59 +4061,190 @@ interface components {
3844
4061
  NodeTypeV0: "llm.responses" | "join.all" | "transform.json";
3845
4062
  /** @description Tier code identifier (e.g., free, pro, enterprise). */
3846
4063
  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;
4064
+ /** @description Request to generate images from a text prompt. */
4065
+ ImageRequest: {
4066
+ /** @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. */
4067
+ model?: string;
4068
+ /** @description Text description of the image to generate */
4069
+ prompt: string;
4070
+ response_format?: components["schemas"]["ImageResponseFormat"];
3865
4071
  };
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
- };
4072
+ /**
4073
+ * @description Output format for generated images.
4074
+ * @default url
4075
+ * @enum {string}
4076
+ */
4077
+ ImageResponseFormat: "url" | "b64_json";
4078
+ /** @description Response containing generated images. */
4079
+ ImageResponse: {
4080
+ /** @description Unique identifier for this generation request */
4081
+ id: string;
4082
+ /** @description Model used for generation */
4083
+ model: string;
4084
+ /** @description Generated images */
4085
+ data: components["schemas"]["ImageData"][];
4086
+ usage: components["schemas"]["ImageUsage"];
4087
+ };
4088
+ /** @description A single generated image. */
4089
+ ImageData: {
4090
+ /** @description URL of the generated image (when response_format is 'url') */
4091
+ url?: string;
4092
+ /** @description Base64-encoded image data (when response_format is 'b64_json') */
4093
+ b64_json?: string;
4094
+ /** @description MIME type of the image (e.g., 'image/png', 'image/webp') */
4095
+ mime_type?: string;
3877
4096
  };
3878
- };
3879
- getRunEventV0Schema: {
3880
- parameters: {
3881
- query?: never;
3882
- header?: never;
3883
- path?: never;
3884
- cookie?: never;
4097
+ /** @description Usage statistics for image generation. */
4098
+ ImageUsage: {
4099
+ /**
4100
+ * Format: int32
4101
+ * @description Number of images generated
4102
+ */
4103
+ images: number;
3885
4104
  };
3886
- requestBody?: never;
3887
- responses: {
3888
- /** @description Schema document */
3889
- 200: {
3890
- headers: {
3891
- [name: string]: unknown;
3892
- };
3893
- content: {
3894
- "application/schema+json": Record<string, never>;
3895
- };
4105
+ /** @description Request body for creating a session. */
4106
+ SessionCreateRequest: {
4107
+ /**
4108
+ * Format: uuid
4109
+ * @description Optional end user ID to associate with the session
4110
+ */
4111
+ end_user_id?: string;
4112
+ /** @description Optional metadata for the session */
4113
+ metadata?: {
4114
+ [key: string]: unknown;
3896
4115
  };
3897
4116
  };
3898
- };
3899
- registerOwner: {
4117
+ /** @description A session resource. */
4118
+ SessionResponse: {
4119
+ /**
4120
+ * Format: uuid
4121
+ * @description Session unique identifier
4122
+ */
4123
+ id: string;
4124
+ /**
4125
+ * Format: uuid
4126
+ * @description Project the session belongs to
4127
+ */
4128
+ project_id: string;
4129
+ /**
4130
+ * Format: uuid
4131
+ * @description End user associated with the session (if any)
4132
+ */
4133
+ end_user_id?: string;
4134
+ /** @description Session metadata */
4135
+ metadata: {
4136
+ [key: string]: unknown;
4137
+ };
4138
+ /**
4139
+ * Format: int64
4140
+ * @description Number of messages in the session
4141
+ */
4142
+ message_count: number;
4143
+ /**
4144
+ * Format: date-time
4145
+ * @description Session creation timestamp
4146
+ */
4147
+ created_at: string;
4148
+ /**
4149
+ * Format: date-time
4150
+ * @description Session last update timestamp
4151
+ */
4152
+ updated_at: string;
4153
+ };
4154
+ /** @description A message within a session. */
4155
+ SessionMessageResponse: {
4156
+ /**
4157
+ * Format: uuid
4158
+ * @description Message unique identifier
4159
+ */
4160
+ id: string;
4161
+ /**
4162
+ * Format: int32
4163
+ * @description Sequence number within the session
4164
+ */
4165
+ seq: number;
4166
+ /** @description Message role (user, assistant, tool) */
4167
+ role: string;
4168
+ /** @description Message content parts */
4169
+ content: {
4170
+ [key: string]: unknown;
4171
+ }[];
4172
+ /**
4173
+ * Format: uuid
4174
+ * @description Run ID that generated this message (for assistant messages)
4175
+ */
4176
+ run_id?: string;
4177
+ /**
4178
+ * Format: date-time
4179
+ * @description Message creation timestamp
4180
+ */
4181
+ created_at: string;
4182
+ };
4183
+ /** @description A session with its full message history. */
4184
+ SessionWithMessagesResponse: components["schemas"]["SessionResponse"] & {
4185
+ /** @description All messages in the session */
4186
+ messages: components["schemas"]["SessionMessageResponse"][];
4187
+ };
4188
+ /** @description Paginated list of sessions. */
4189
+ SessionListResponse: {
4190
+ /** @description List of sessions */
4191
+ sessions: components["schemas"]["SessionResponse"][];
4192
+ /** @description Cursor for fetching the next page (if more results exist) */
4193
+ next_cursor?: string;
4194
+ };
4195
+ };
4196
+ responses: never;
4197
+ parameters: {
4198
+ ProjectID: string;
4199
+ WebhookID: string;
4200
+ };
4201
+ requestBodies: never;
4202
+ headers: never;
4203
+ pathItems: never;
4204
+ }
4205
+ type $defs = Record<string, never>;
4206
+ interface operations {
4207
+ getWorkflowV0Schema: {
4208
+ parameters: {
4209
+ query?: never;
4210
+ header?: never;
4211
+ path?: never;
4212
+ cookie?: never;
4213
+ };
4214
+ requestBody?: never;
4215
+ responses: {
4216
+ /** @description Schema document */
4217
+ 200: {
4218
+ headers: {
4219
+ [name: string]: unknown;
4220
+ };
4221
+ content: {
4222
+ "application/schema+json": Record<string, never>;
4223
+ };
4224
+ };
4225
+ };
4226
+ };
4227
+ getRunEventV0Schema: {
4228
+ parameters: {
4229
+ query?: never;
4230
+ header?: never;
4231
+ path?: never;
4232
+ cookie?: never;
4233
+ };
4234
+ requestBody?: never;
4235
+ responses: {
4236
+ /** @description Schema document */
4237
+ 200: {
4238
+ headers: {
4239
+ [name: string]: unknown;
4240
+ };
4241
+ content: {
4242
+ "application/schema+json": Record<string, never>;
4243
+ };
4244
+ };
4245
+ };
4246
+ };
4247
+ registerOwner: {
3900
4248
  parameters: {
3901
4249
  query?: never;
3902
4250
  header?: never;
@@ -4034,11 +4382,6 @@ interface operations {
4034
4382
  requestBody: {
4035
4383
  content: {
4036
4384
  "application/json": {
4037
- /**
4038
- * Format: uuid
4039
- * @description Project ID the customer belongs to
4040
- */
4041
- project_id: string;
4042
4385
  /**
4043
4386
  * Format: uuid
4044
4387
  * @description Internal customer UUID (provide exactly one of customer_id or customer_external_id)
@@ -4256,11 +4599,7 @@ interface operations {
4256
4599
  headers: {
4257
4600
  [name: string]: unknown;
4258
4601
  };
4259
- content: {
4260
- "application/json": {
4261
- customer?: components["schemas"]["Customer"];
4262
- };
4263
- };
4602
+ content?: never;
4264
4603
  };
4265
4604
  /** @description Customer not found */
4266
4605
  404: {
@@ -4278,7 +4617,7 @@ interface operations {
4278
4617
  };
4279
4618
  };
4280
4619
  };
4281
- getCustomerMe: {
4620
+ listCustomers: {
4282
4621
  parameters: {
4283
4622
  query?: never;
4284
4623
  header?: never;
@@ -4287,113 +4626,133 @@ interface operations {
4287
4626
  };
4288
4627
  requestBody?: never;
4289
4628
  responses: {
4290
- /** @description Customer details */
4629
+ /** @description Customer list */
4291
4630
  200: {
4292
4631
  headers: {
4293
4632
  [name: string]: unknown;
4294
4633
  };
4295
4634
  content: {
4296
- "application/json": components["schemas"]["CustomerMeResponse"];
4297
- };
4298
- };
4299
- /** @description Unauthorized */
4300
- 401: {
4301
- headers: {
4302
- [name: string]: unknown;
4635
+ "application/json": {
4636
+ customers?: components["schemas"]["CustomerWithSubscription"][];
4637
+ };
4303
4638
  };
4304
- content?: never;
4305
4639
  };
4306
4640
  };
4307
4641
  };
4308
- getCustomerMeUsage: {
4642
+ upsertCustomer: {
4309
4643
  parameters: {
4310
4644
  query?: never;
4311
4645
  header?: never;
4312
4646
  path?: never;
4313
4647
  cookie?: never;
4314
4648
  };
4315
- requestBody?: never;
4649
+ requestBody: {
4650
+ content: {
4651
+ "application/json": components["schemas"]["CustomerCreate"];
4652
+ };
4653
+ };
4316
4654
  responses: {
4317
- /** @description Usage summary */
4655
+ /** @description Customer updated */
4318
4656
  200: {
4319
4657
  headers: {
4320
4658
  [name: string]: unknown;
4321
4659
  };
4322
4660
  content: {
4323
- "application/json": components["schemas"]["CustomerMeUsageResponse"];
4661
+ "application/json": {
4662
+ customer?: components["schemas"]["CustomerWithSubscription"];
4663
+ };
4324
4664
  };
4325
4665
  };
4326
- /** @description Unauthorized */
4327
- 401: {
4666
+ /** @description Customer created */
4667
+ 201: {
4328
4668
  headers: {
4329
4669
  [name: string]: unknown;
4330
4670
  };
4331
- content?: never;
4332
- };
4333
- /** @description Customer not found */
4334
- 404: {
4335
- headers: {
4336
- [name: string]: unknown;
4671
+ content: {
4672
+ "application/json": {
4673
+ customer?: components["schemas"]["CustomerWithSubscription"];
4674
+ };
4337
4675
  };
4338
- content?: never;
4339
4676
  };
4340
- /** @description Failed to calculate usage */
4341
- 500: {
4342
- headers: {
4343
- [name: string]: unknown;
4344
- };
4345
- content?: never;
4677
+ };
4678
+ };
4679
+ createProjectCustomer: {
4680
+ parameters: {
4681
+ query?: never;
4682
+ header?: never;
4683
+ path?: never;
4684
+ cookie?: never;
4685
+ };
4686
+ requestBody: {
4687
+ content: {
4688
+ "application/json": components["schemas"]["CustomerCreate"];
4346
4689
  };
4347
- /** @description Service unavailable */
4348
- 503: {
4690
+ };
4691
+ responses: {
4692
+ /** @description Customer created */
4693
+ 201: {
4349
4694
  headers: {
4350
4695
  [name: string]: unknown;
4351
4696
  };
4352
- content?: never;
4697
+ content: {
4698
+ "application/json": {
4699
+ customer?: components["schemas"]["CustomerWithSubscription"];
4700
+ };
4701
+ };
4353
4702
  };
4354
4703
  };
4355
4704
  };
4356
- getCustomerMeSubscription: {
4705
+ getCustomer: {
4357
4706
  parameters: {
4358
4707
  query?: never;
4359
4708
  header?: never;
4360
- path?: never;
4709
+ path: {
4710
+ customer_id: string;
4711
+ };
4361
4712
  cookie?: never;
4362
4713
  };
4363
4714
  requestBody?: never;
4364
4715
  responses: {
4365
- /** @description Subscription details */
4716
+ /** @description Customer */
4366
4717
  200: {
4367
4718
  headers: {
4368
4719
  [name: string]: unknown;
4369
4720
  };
4370
4721
  content: {
4371
- "application/json": components["schemas"]["CustomerMeSubscriptionResponse"];
4372
- };
4373
- };
4374
- /** @description Unauthorized */
4375
- 401: {
4376
- headers: {
4377
- [name: string]: unknown;
4722
+ "application/json": {
4723
+ customer?: components["schemas"]["CustomerWithSubscription"];
4724
+ };
4378
4725
  };
4379
- content?: never;
4380
4726
  };
4381
- /** @description Customer or tier not found */
4727
+ /** @description Customer not found */
4382
4728
  404: {
4383
4729
  headers: {
4384
4730
  [name: string]: unknown;
4385
4731
  };
4386
4732
  content?: never;
4387
4733
  };
4388
- /** @description Internal server error */
4389
- 500: {
4734
+ };
4735
+ };
4736
+ deleteProjectCustomer: {
4737
+ parameters: {
4738
+ query?: never;
4739
+ header?: never;
4740
+ path: {
4741
+ customer_id: string;
4742
+ };
4743
+ cookie?: never;
4744
+ };
4745
+ requestBody?: never;
4746
+ responses: {
4747
+ /** @description Customer deleted */
4748
+ 204: {
4390
4749
  headers: {
4391
4750
  [name: string]: unknown;
4392
4751
  };
4393
4752
  content?: never;
4394
4753
  };
4395
- /** @description Service unavailable */
4396
- 503: {
4754
+ /** @description Customer not found */
4755
+ 404: {
4397
4756
  headers: {
4398
4757
  [name: string]: unknown;
4399
4758
  };
@@ -4401,42 +4760,63 @@ interface operations {
4401
4760
  };
4402
4761
  };
4403
4762
  };
4404
- listModels: {
4763
+ subscribeCustomer: {
4405
4764
  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
- };
4765
+ query?: never;
4412
4766
  header?: never;
4413
- path?: never;
4767
+ path: {
4768
+ customer_id: string;
4769
+ };
4414
4770
  cookie?: never;
4415
4771
  };
4416
- requestBody?: never;
4772
+ requestBody: {
4773
+ content: {
4774
+ "application/json": {
4775
+ /** Format: uuid */
4776
+ tier_id: string;
4777
+ /** Format: uri */
4778
+ success_url: string;
4779
+ /** Format: uri */
4780
+ cancel_url: string;
4781
+ };
4782
+ };
4783
+ };
4417
4784
  responses: {
4418
- /** @description Models list */
4419
- 200: {
4785
+ /** @description Checkout session created */
4786
+ 201: {
4420
4787
  headers: {
4421
4788
  [name: string]: unknown;
4422
4789
  };
4423
4790
  content: {
4424
- "application/json": components["schemas"]["ModelsResponse"];
4791
+ "application/json": components["schemas"]["CheckoutSessionResponse"];
4425
4792
  };
4426
4793
  };
4427
4794
  };
4428
4795
  };
4429
- handleBillingWebhook: {
4796
+ getCustomerSubscription: {
4430
4797
  parameters: {
4431
4798
  query?: never;
4432
4799
  header?: never;
4433
- path?: never;
4800
+ path: {
4801
+ customer_id: string;
4802
+ };
4434
4803
  cookie?: never;
4435
4804
  };
4436
4805
  requestBody?: never;
4437
4806
  responses: {
4438
- /** @description Event accepted */
4439
- 202: {
4807
+ /** @description Subscription details */
4808
+ 200: {
4809
+ headers: {
4810
+ [name: string]: unknown;
4811
+ };
4812
+ content: {
4813
+ "application/json": {
4814
+ subscription?: components["schemas"]["Subscription"];
4815
+ };
4816
+ };
4817
+ };
4818
+ /** @description Subscription not found */
4819
+ 404: {
4440
4820
  headers: {
4441
4821
  [name: string]: unknown;
4442
4822
  };
@@ -4444,17 +4824,185 @@ interface operations {
4444
4824
  };
4445
4825
  };
4446
4826
  };
4447
- listProjects: {
4827
+ cancelCustomerSubscription: {
4448
4828
  parameters: {
4449
4829
  query?: never;
4450
4830
  header?: never;
4451
- path?: never;
4831
+ path: {
4832
+ customer_id: string;
4833
+ };
4452
4834
  cookie?: never;
4453
4835
  };
4454
4836
  requestBody?: never;
4455
4837
  responses: {
4456
- /** @description Project list */
4457
- 200: {
4838
+ /** @description Subscription canceled */
4839
+ 204: {
4840
+ headers: {
4841
+ [name: string]: unknown;
4842
+ };
4843
+ content?: never;
4844
+ };
4845
+ };
4846
+ };
4847
+ getCustomerMe: {
4848
+ parameters: {
4849
+ query?: never;
4850
+ header?: never;
4851
+ path?: never;
4852
+ cookie?: never;
4853
+ };
4854
+ requestBody?: never;
4855
+ responses: {
4856
+ /** @description Customer details */
4857
+ 200: {
4858
+ headers: {
4859
+ [name: string]: unknown;
4860
+ };
4861
+ content: {
4862
+ "application/json": components["schemas"]["CustomerMeResponse"];
4863
+ };
4864
+ };
4865
+ /** @description Unauthorized */
4866
+ 401: {
4867
+ headers: {
4868
+ [name: string]: unknown;
4869
+ };
4870
+ content?: never;
4871
+ };
4872
+ };
4873
+ };
4874
+ getCustomerMeUsage: {
4875
+ parameters: {
4876
+ query?: never;
4877
+ header?: never;
4878
+ path?: never;
4879
+ cookie?: never;
4880
+ };
4881
+ requestBody?: never;
4882
+ responses: {
4883
+ /** @description Usage summary */
4884
+ 200: {
4885
+ headers: {
4886
+ [name: string]: unknown;
4887
+ };
4888
+ content: {
4889
+ "application/json": components["schemas"]["CustomerMeUsageResponse"];
4890
+ };
4891
+ };
4892
+ /** @description Unauthorized */
4893
+ 401: {
4894
+ headers: {
4895
+ [name: string]: unknown;
4896
+ };
4897
+ content?: never;
4898
+ };
4899
+ /** @description Customer not found */
4900
+ 404: {
4901
+ headers: {
4902
+ [name: string]: unknown;
4903
+ };
4904
+ content?: never;
4905
+ };
4906
+ /** @description Failed to calculate usage */
4907
+ 500: {
4908
+ headers: {
4909
+ [name: string]: unknown;
4910
+ };
4911
+ content?: never;
4912
+ };
4913
+ /** @description Service unavailable */
4914
+ 503: {
4915
+ headers: {
4916
+ [name: string]: unknown;
4917
+ };
4918
+ content?: never;
4919
+ };
4920
+ };
4921
+ };
4922
+ getCustomerMeSubscription: {
4923
+ parameters: {
4924
+ query?: never;
4925
+ header?: never;
4926
+ path?: never;
4927
+ cookie?: never;
4928
+ };
4929
+ requestBody?: never;
4930
+ responses: {
4931
+ /** @description Subscription details */
4932
+ 200: {
4933
+ headers: {
4934
+ [name: string]: unknown;
4935
+ };
4936
+ content: {
4937
+ "application/json": components["schemas"]["CustomerMeSubscriptionResponse"];
4938
+ };
4939
+ };
4940
+ /** @description Unauthorized */
4941
+ 401: {
4942
+ headers: {
4943
+ [name: string]: unknown;
4944
+ };
4945
+ content?: never;
4946
+ };
4947
+ /** @description Customer or tier not found */
4948
+ 404: {
4949
+ headers: {
4950
+ [name: string]: unknown;
4951
+ };
4952
+ content?: never;
4953
+ };
4954
+ /** @description Internal server error */
4955
+ 500: {
4956
+ headers: {
4957
+ [name: string]: unknown;
4958
+ };
4959
+ content?: never;
4960
+ };
4961
+ /** @description Service unavailable */
4962
+ 503: {
4963
+ headers: {
4964
+ [name: string]: unknown;
4965
+ };
4966
+ content?: never;
4967
+ };
4968
+ };
4969
+ };
4970
+ listModels: {
4971
+ parameters: {
4972
+ query?: {
4973
+ /** @description Filter results to a specific provider */
4974
+ provider?: components["schemas"]["ProviderId"];
4975
+ /** @description Filter results to models that support a capability */
4976
+ capability?: components["schemas"]["ModelCapability"];
4977
+ };
4978
+ header?: never;
4979
+ path?: never;
4980
+ cookie?: never;
4981
+ };
4982
+ requestBody?: never;
4983
+ responses: {
4984
+ /** @description Models list */
4985
+ 200: {
4986
+ headers: {
4987
+ [name: string]: unknown;
4988
+ };
4989
+ content: {
4990
+ "application/json": components["schemas"]["ModelsResponse"];
4991
+ };
4992
+ };
4993
+ };
4994
+ };
4995
+ listProjects: {
4996
+ parameters: {
4997
+ query?: never;
4998
+ header?: never;
4999
+ path?: never;
5000
+ cookie?: never;
5001
+ };
5002
+ requestBody?: never;
5003
+ responses: {
5004
+ /** @description Project list */
5005
+ 200: {
4458
5006
  headers: {
4459
5007
  [name: string]: unknown;
4460
5008
  };
@@ -4694,7 +5242,7 @@ interface operations {
4694
5242
  };
4695
5243
  content: {
4696
5244
  "application/json": {
4697
- customers?: components["schemas"]["Customer"][];
5245
+ customers?: components["schemas"]["CustomerWithSubscription"][];
4698
5246
  };
4699
5247
  };
4700
5248
  };
@@ -4722,37 +5270,12 @@ interface operations {
4722
5270
  };
4723
5271
  content: {
4724
5272
  "application/json": {
4725
- customer?: components["schemas"]["Customer"];
5273
+ customer?: components["schemas"]["CustomerWithSubscription"];
4726
5274
  };
4727
5275
  };
4728
5276
  };
4729
5277
  };
4730
5278
  };
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
5279
  deleteCustomer: {
4757
5280
  parameters: {
4758
5281
  query?: never;
@@ -4976,6 +5499,30 @@ interface operations {
4976
5499
  };
4977
5500
  };
4978
5501
  };
5502
+ generateImage: {
5503
+ parameters: {
5504
+ query?: never;
5505
+ header?: never;
5506
+ path?: never;
5507
+ cookie?: never;
5508
+ };
5509
+ requestBody: {
5510
+ content: {
5511
+ "application/json": components["schemas"]["ImageRequest"];
5512
+ };
5513
+ };
5514
+ responses: {
5515
+ /** @description Generated images */
5516
+ 200: {
5517
+ headers: {
5518
+ [name: string]: unknown;
5519
+ };
5520
+ content: {
5521
+ "application/json": components["schemas"]["ImageResponse"];
5522
+ };
5523
+ };
5524
+ };
5525
+ };
4979
5526
  createRun: {
4980
5527
  parameters: {
4981
5528
  query?: never;
@@ -5068,62 +5615,210 @@ interface operations {
5068
5615
  };
5069
5616
  };
5070
5617
  };
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;
5618
+ listSessions: {
5619
+ parameters: {
5620
+ query?: {
5621
+ /** @description Maximum number of sessions to return */
5622
+ limit?: number;
5623
+ /** @description Number of sessions to skip */
5624
+ offset?: number;
5625
+ /** @description Filter sessions by end user ID */
5626
+ end_user_id?: string;
5627
+ };
5628
+ header?: never;
5629
+ path?: never;
5630
+ cookie?: never;
5631
+ };
5632
+ requestBody?: never;
5633
+ responses: {
5634
+ /** @description Session list */
5635
+ 200: {
5636
+ headers: {
5637
+ [name: string]: unknown;
5638
+ };
5639
+ content: {
5640
+ "application/json": components["schemas"]["SessionListResponse"];
5641
+ };
5642
+ };
5643
+ /** @description API key required */
5644
+ 401: {
5645
+ headers: {
5646
+ [name: string]: unknown;
5647
+ };
5648
+ content?: never;
5649
+ };
5650
+ };
5651
+ };
5652
+ createSession: {
5653
+ parameters: {
5654
+ query?: never;
5655
+ header?: never;
5656
+ path?: never;
5657
+ cookie?: never;
5658
+ };
5659
+ requestBody: {
5660
+ content: {
5661
+ "application/json": components["schemas"]["SessionCreateRequest"];
5662
+ };
5663
+ };
5664
+ responses: {
5665
+ /** @description Session created */
5666
+ 201: {
5667
+ headers: {
5668
+ [name: string]: unknown;
5669
+ };
5670
+ content: {
5671
+ "application/json": components["schemas"]["SessionResponse"];
5672
+ };
5673
+ };
5674
+ /** @description Invalid request */
5675
+ 400: {
5676
+ headers: {
5677
+ [name: string]: unknown;
5678
+ };
5679
+ content?: never;
5680
+ };
5681
+ /** @description API key required */
5682
+ 401: {
5683
+ headers: {
5684
+ [name: string]: unknown;
5685
+ };
5686
+ content?: never;
5687
+ };
5688
+ };
5689
+ };
5690
+ getSession: {
5691
+ parameters: {
5692
+ query?: never;
5693
+ header?: never;
5694
+ path: {
5695
+ session_id: string;
5696
+ };
5697
+ cookie?: never;
5698
+ };
5699
+ requestBody?: never;
5700
+ responses: {
5701
+ /** @description Session with messages */
5702
+ 200: {
5703
+ headers: {
5704
+ [name: string]: unknown;
5705
+ };
5706
+ content: {
5707
+ "application/json": components["schemas"]["SessionWithMessagesResponse"];
5708
+ };
5709
+ };
5710
+ /** @description Session not found */
5711
+ 404: {
5712
+ headers: {
5713
+ [name: string]: unknown;
5714
+ };
5715
+ content?: never;
5716
+ };
5717
+ };
5718
+ };
5719
+ deleteSession: {
5720
+ parameters: {
5721
+ query?: never;
5722
+ header?: never;
5723
+ path: {
5724
+ session_id: string;
5725
+ };
5726
+ cookie?: never;
5727
+ };
5728
+ requestBody?: never;
5729
+ responses: {
5730
+ /** @description Session deleted */
5731
+ 204: {
5732
+ headers: {
5733
+ [name: string]: unknown;
5734
+ };
5735
+ content?: never;
5736
+ };
5737
+ /** @description Secret key required for deletion */
5738
+ 403: {
5739
+ headers: {
5740
+ [name: string]: unknown;
5741
+ };
5742
+ content?: never;
5743
+ };
5744
+ /** @description Session not found */
5745
+ 404: {
5746
+ headers: {
5747
+ [name: string]: unknown;
5748
+ };
5749
+ content?: never;
5750
+ };
5751
+ };
5752
+ };
5753
+ }
5754
+
5755
+ /**
5756
+ * Customer represents a customer in a ModelRelay project.
5757
+ */
5758
+ interface Customer {
5759
+ id: string;
5760
+ project_id: string;
5761
+ external_id: string;
5762
+ email: string;
5763
+ metadata?: CustomerMetadata;
5764
+ created_at: string;
5765
+ updated_at: string;
5766
+ }
5767
+ /**
5768
+ * Subscription represents billing state for a customer.
5769
+ */
5770
+ interface Subscription {
5771
+ id: string;
5772
+ project_id: string;
5773
+ customer_id: string;
5774
+ tier_id: string;
5775
+ tier_code?: TierCode;
5776
+ billing_provider?: BillingProvider;
5777
+ billing_customer_id?: string;
5778
+ billing_subscription_id?: string;
5779
+ subscription_status?: SubscriptionStatusKind;
5780
+ current_period_start?: string;
5781
+ current_period_end?: string;
5782
+ created_at: string;
5783
+ updated_at: string;
5784
+ }
5785
+ /**
5786
+ * CustomerWithSubscription bundles customer identity with optional subscription state.
5787
+ */
5788
+ interface CustomerWithSubscription {
5789
+ customer: Customer;
5790
+ subscription?: Subscription;
5791
+ }
5792
+ /**
5793
+ * Request to create a customer.
5794
+ */
5795
+ interface CustomerCreateRequest {
5796
+ external_id: string;
5797
+ email: string;
5798
+ metadata?: CustomerMetadata;
5799
+ }
5800
+ /**
5801
+ * Request to upsert a customer by external_id.
5802
+ */
5803
+ interface CustomerUpsertRequest {
5804
+ external_id: string;
5805
+ email: string;
5806
+ metadata?: CustomerMetadata;
5807
+ }
5808
+ /**
5809
+ * Request to link a customer identity to a customer by email.
5810
+ * Used when a customer subscribes via Stripe Checkout (email only) and later authenticates to the app.
5811
+ */
5812
+ interface CustomerClaimRequest {
5813
+ email: string;
5814
+ provider: string;
5121
5815
  subject: string;
5122
5816
  }
5123
5817
  /**
5124
- * Request to create a checkout session.
5818
+ * Request to create a checkout session for a customer subscription.
5125
5819
  */
5126
- interface CheckoutSessionRequest {
5820
+ interface CustomerSubscribeRequest {
5821
+ tier_id: string;
5127
5822
  success_url: string;
5128
5823
  cancel_url: string;
5129
5824
  }
@@ -5134,16 +5829,6 @@ interface CheckoutSession {
5134
5829
  session_id: string;
5135
5830
  url: string;
5136
5831
  }
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
5832
  interface CustomersClientConfig {
5148
5833
  apiKey?: ApiKey;
5149
5834
  accessToken?: string;
@@ -5184,23 +5869,23 @@ declare class CustomersClient {
5184
5869
  /**
5185
5870
  * List all customers in the project.
5186
5871
  */
5187
- list(): Promise<Customer[]>;
5872
+ list(): Promise<CustomerWithSubscription[]>;
5188
5873
  /**
5189
5874
  * Create a new customer in the project.
5190
5875
  */
5191
- create(request: CustomerCreateRequest): Promise<Customer>;
5876
+ create(request: CustomerCreateRequest): Promise<CustomerWithSubscription>;
5192
5877
  /**
5193
5878
  * Get a customer by ID.
5194
5879
  */
5195
- get(customerId: string): Promise<Customer>;
5880
+ get(customerId: string): Promise<CustomerWithSubscription>;
5196
5881
  /**
5197
5882
  * Upsert a customer by external_id.
5198
5883
  * If a customer with the given external_id exists, it is updated.
5199
5884
  * Otherwise, a new customer is created.
5200
5885
  */
5201
- upsert(request: CustomerUpsertRequest): Promise<Customer>;
5886
+ upsert(request: CustomerUpsertRequest): Promise<CustomerWithSubscription>;
5202
5887
  /**
5203
- * Link an end-user identity (provider + subject) to a customer found by email.
5888
+ * Link a customer identity (provider + subject) to a customer found by email.
5204
5889
  * Used when a customer subscribes via Stripe Checkout (email only) and later authenticates to the app.
5205
5890
  *
5206
5891
  * This is a user self-service operation that works with publishable keys,
@@ -5211,19 +5896,23 @@ declare class CustomersClient {
5211
5896
  * @throws {APIError} with status 404 if customer not found by email
5212
5897
  * @throws {APIError} with status 409 if the identity is already linked to a different customer
5213
5898
  */
5214
- claim(request: CustomerClaimRequest): Promise<Customer>;
5899
+ claim(request: CustomerClaimRequest): Promise<void>;
5215
5900
  /**
5216
5901
  * Delete a customer by ID.
5217
5902
  */
5218
5903
  delete(customerId: string): Promise<void>;
5219
5904
  /**
5220
- * Create a Stripe checkout session for a customer.
5905
+ * Create a Stripe checkout session for a customer subscription.
5906
+ */
5907
+ subscribe(customerId: string, request: CustomerSubscribeRequest): Promise<CheckoutSession>;
5908
+ /**
5909
+ * Get the subscription details for a customer.
5221
5910
  */
5222
- createCheckoutSession(customerId: string, request: CheckoutSessionRequest): Promise<CheckoutSession>;
5911
+ getSubscription(customerId: string): Promise<Subscription>;
5223
5912
  /**
5224
- * Get the subscription status for a customer.
5913
+ * Cancel a customer's subscription at period end.
5225
5914
  */
5226
- getSubscription(customerId: string): Promise<SubscriptionStatus>;
5915
+ unsubscribe(customerId: string): Promise<void>;
5227
5916
  }
5228
5917
 
5229
5918
  /**
@@ -5259,7 +5948,8 @@ interface Tier {
5259
5948
  display_name: string;
5260
5949
  spend_limit_cents: number;
5261
5950
  models: TierModel[];
5262
- stripe_price_id?: string;
5951
+ billing_provider?: components["schemas"]["BillingProvider"];
5952
+ billing_price_ref?: string;
5263
5953
  price_amount_cents?: number;
5264
5954
  price_currency?: string;
5265
5955
  price_interval?: PriceInterval;
@@ -5268,7 +5958,7 @@ interface Tier {
5268
5958
  updated_at: string;
5269
5959
  }
5270
5960
  /**
5271
- * Request to create a tier checkout session (Stripe-first flow).
5961
+ * Request to create a tier checkout session (checkout-first flow).
5272
5962
  * Stripe collects the customer's email during checkout.
5273
5963
  */
5274
5964
  interface TierCheckoutRequest {
@@ -5297,50 +5987,707 @@ declare class TiersClient {
5297
5987
  private ensureApiKey;
5298
5988
  private ensureSecretKey;
5299
5989
  /**
5300
- * List all tiers in the project.
5990
+ * List all tiers in the project.
5991
+ */
5992
+ list(): Promise<Tier[]>;
5993
+ /**
5994
+ * Get a tier by ID.
5995
+ */
5996
+ get(tierId: string): Promise<Tier>;
5997
+ /**
5998
+ * Create a Stripe checkout session for a tier (Stripe-first flow).
5999
+ *
6000
+ * This enables users to subscribe before authenticating. Stripe collects
6001
+ * the customer's email during checkout. After checkout completes, a
6002
+ * customer record is created with the email from Stripe. The customer
6003
+ * can later be linked to an identity via POST /customers/claim.
6004
+ *
6005
+ * Requires a secret key (mr_sk_*).
6006
+ *
6007
+ * @param tierId - The tier ID to create a checkout session for
6008
+ * @param request - Checkout session request with redirect URLs
6009
+ * @returns Checkout session with Stripe URL
6010
+ */
6011
+ checkout(tierId: string, request: TierCheckoutRequest): Promise<TierCheckoutSession>;
6012
+ }
6013
+
6014
+ type ModelCapability = components["schemas"]["ModelCapability"];
6015
+ type ProviderId = components["schemas"]["ProviderId"];
6016
+ type CatalogModel = components["schemas"]["Model"];
6017
+ interface ModelsListParams {
6018
+ provider?: ProviderId;
6019
+ capability?: ModelCapability;
6020
+ }
6021
+ /**
6022
+ * ModelsClient provides methods to list models and their rich metadata.
6023
+ *
6024
+ * Note: The underlying API endpoint is public (no auth required), but the SDK's
6025
+ * HTTP client may still send auth headers if configured.
6026
+ */
6027
+ declare class ModelsClient {
6028
+ private readonly http;
6029
+ constructor(http: HTTPClient);
6030
+ /**
6031
+ * List active models with rich metadata.
6032
+ */
6033
+ list(params?: ModelsListParams): Promise<CatalogModel[]>;
6034
+ }
6035
+
6036
+ /**
6037
+ * Request to generate images from a text prompt.
6038
+ */
6039
+ type ImageRequest = components["schemas"]["ImageRequest"];
6040
+ /**
6041
+ * Response containing generated images.
6042
+ */
6043
+ type ImageResponse = components["schemas"]["ImageResponse"];
6044
+ /**
6045
+ * A single generated image.
6046
+ */
6047
+ type ImageData = components["schemas"]["ImageData"];
6048
+ /**
6049
+ * Usage statistics for image generation.
6050
+ */
6051
+ type ImageUsage = components["schemas"]["ImageUsage"];
6052
+ /**
6053
+ * Output format for generated images.
6054
+ * - "url" (default): Returns hosted URLs, requires storage configuration
6055
+ * - "b64_json": Returns base64-encoded data, for testing/development
6056
+ */
6057
+ type ImageResponseFormat = components["schemas"]["ImageResponseFormat"];
6058
+ /**
6059
+ * ImagesClient provides methods for generating images using AI models.
6060
+ *
6061
+ * @example
6062
+ * ```typescript
6063
+ * // Production use (default) - returns URLs
6064
+ * const response = await client.images.generate({
6065
+ * model: "gemini-2.5-flash-image",
6066
+ * prompt: "A futuristic cityscape",
6067
+ * });
6068
+ * console.log(response.data[0].url);
6069
+ * console.log(response.data[0].mime_type);
6070
+ *
6071
+ * // Testing/development - returns base64
6072
+ * const testResponse = await client.images.generate({
6073
+ * model: "gemini-2.5-flash-image",
6074
+ * prompt: "A futuristic cityscape",
6075
+ * response_format: "b64_json"
6076
+ * });
6077
+ * ```
6078
+ */
6079
+ declare class ImagesClient {
6080
+ private readonly http;
6081
+ private readonly auth;
6082
+ constructor(http: HTTPClient, auth: AuthClient);
6083
+ /**
6084
+ * Generate images from a text prompt.
6085
+ *
6086
+ * By default, returns URLs (requires storage configuration).
6087
+ * Use response_format: "b64_json" for testing without storage.
6088
+ *
6089
+ * @param request - Image generation request (model optional if tier defines default)
6090
+ * @returns Generated images with URLs or base64 data
6091
+ * @throws {Error} If prompt is empty
6092
+ */
6093
+ generate(request: ImageRequest): Promise<ImageResponse>;
6094
+ }
6095
+
6096
+ /**
6097
+ * Session types for multi-turn conversations.
6098
+ *
6099
+ * Sessions provide stateful multi-turn conversation management with two modes:
6100
+ * - LocalSession: Client-managed history with optional persistence (memory, file, SQLite)
6101
+ * - RemoteSession: Server-managed persistence with cross-device continuity
6102
+ *
6103
+ * Both implement the common Session interface for seamless switching.
6104
+ *
6105
+ * @module
6106
+ */
6107
+
6108
+ declare const sessionIdBrand: unique symbol;
6109
+ /**
6110
+ * Branded type for session identifiers.
6111
+ * Prevents accidental use of arbitrary strings where a session ID is expected.
6112
+ */
6113
+ type SessionId = string & {
6114
+ readonly [sessionIdBrand]: true;
6115
+ };
6116
+ /**
6117
+ * Cast a string to a SessionId.
6118
+ */
6119
+ declare function asSessionId(value: string): SessionId;
6120
+ /**
6121
+ * Generate a new session ID (UUID v4).
6122
+ */
6123
+ declare function generateSessionId(): SessionId;
6124
+ /**
6125
+ * A message in the session history.
6126
+ * Extends InputItem with session-specific metadata.
6127
+ */
6128
+ interface SessionMessage extends InputItem {
6129
+ /** Sequence number within the session (1-based). */
6130
+ readonly seq: number;
6131
+ /** When this message was added to the session. */
6132
+ readonly createdAt: Date;
6133
+ /** The run ID that produced this message (for assistant messages). */
6134
+ readonly runId?: RunId;
6135
+ }
6136
+ /**
6137
+ * Artifacts produced during a session (files, code, etc.).
6138
+ */
6139
+ type SessionArtifacts = Map<string, unknown>;
6140
+ /**
6141
+ * Options for a session run.
6142
+ */
6143
+ interface SessionRunOptions {
6144
+ /** Override the model for this run. */
6145
+ model?: ModelId;
6146
+ /** Override the provider for this run. */
6147
+ provider?: ProviderId$1;
6148
+ /** Additional tools for this run (merged with session defaults). */
6149
+ tools?: Tool[];
6150
+ /** Maximum number of LLM turns (for tool loops). */
6151
+ maxTurns?: number;
6152
+ /** Customer ID for attributed requests. */
6153
+ customerId?: string;
6154
+ /** Abort signal for cancellation. */
6155
+ signal?: AbortSignal;
6156
+ }
6157
+ /**
6158
+ * Status of a session run.
6159
+ */
6160
+ type SessionRunStatus = "complete" | "waiting_for_tools" | "error" | "canceled";
6161
+ /**
6162
+ * Pending tool call that needs client-side execution.
6163
+ */
6164
+ interface SessionPendingToolCall {
6165
+ readonly toolCallId: string;
6166
+ readonly name: string;
6167
+ readonly arguments: string;
6168
+ }
6169
+ /**
6170
+ * Usage summary for a session run.
6171
+ */
6172
+ interface SessionUsageSummary {
6173
+ readonly inputTokens: number;
6174
+ readonly outputTokens: number;
6175
+ readonly totalTokens: number;
6176
+ readonly llmCalls: number;
6177
+ readonly toolCalls: number;
6178
+ }
6179
+ /**
6180
+ * Result of a session run.
6181
+ */
6182
+ interface SessionRunResult {
6183
+ /** Run status. */
6184
+ readonly status: SessionRunStatus;
6185
+ /** Final text output (for complete runs). */
6186
+ readonly output?: string;
6187
+ /** Pending tool calls (when status is 'waiting_for_tools'). */
6188
+ readonly pendingTools?: SessionPendingToolCall[];
6189
+ /** Error message (when status is 'error'). */
6190
+ readonly error?: string;
6191
+ /** The run ID from the server. */
6192
+ readonly runId: RunId;
6193
+ /** Token and call usage. */
6194
+ readonly usage: SessionUsageSummary;
6195
+ /** All events from this run. */
6196
+ readonly events: RunEventV0[];
6197
+ }
6198
+ /**
6199
+ * Session type discriminator.
6200
+ */
6201
+ type SessionType = "local" | "remote";
6202
+ /**
6203
+ * Common interface for all session types.
6204
+ *
6205
+ * Sessions manage multi-turn conversation state, executing runs with
6206
+ * accumulated context and optionally persisting history.
6207
+ */
6208
+ interface Session {
6209
+ /** Unique session identifier. */
6210
+ readonly id: SessionId;
6211
+ /** Session type: 'local' (client-managed) or 'remote' (server-managed). */
6212
+ readonly type: SessionType;
6213
+ /** Full conversation history (read-only). */
6214
+ readonly history: readonly SessionMessage[];
6215
+ /**
6216
+ * Execute a prompt as a new turn in this session.
6217
+ *
6218
+ * The prompt is added to history, a run is created with the full context,
6219
+ * and the response is appended to history. Tool calls are automatically
6220
+ * handled via the session's ToolRegistry.
6221
+ *
6222
+ * @param prompt - The user's input for this turn
6223
+ * @param options - Optional run configuration
6224
+ * @returns The run result with status, output, and usage
6225
+ */
6226
+ run(prompt: string, options?: SessionRunOptions): Promise<SessionRunResult>;
6227
+ /**
6228
+ * Submit tool results for a waiting run.
6229
+ *
6230
+ * Called when a previous run returned status 'waiting_for_tools'.
6231
+ * The results are submitted to continue the run.
6232
+ *
6233
+ * @param results - Tool execution results
6234
+ * @returns Updated run result
6235
+ */
6236
+ submitToolResults(results: ToolExecutionResult[]): Promise<SessionRunResult>;
6237
+ /**
6238
+ * Get all artifacts produced during this session.
6239
+ */
6240
+ getArtifacts(): SessionArtifacts;
6241
+ /**
6242
+ * Close the session and release resources.
6243
+ *
6244
+ * For LocalSession with persistence, this flushes pending writes.
6245
+ * For RemoteSession, this is a no-op (server manages lifecycle).
6246
+ */
6247
+ close(): Promise<void>;
6248
+ }
6249
+ /**
6250
+ * Persistence mode for local sessions.
6251
+ */
6252
+ type LocalSessionPersistence = "memory" | "file" | "sqlite";
6253
+ /**
6254
+ * Options for creating a local session.
6255
+ */
6256
+ interface LocalSessionOptions {
6257
+ /** Tool registry for handling tool calls. */
6258
+ toolRegistry?: ToolRegistry;
6259
+ /** Default model for runs (can be overridden per-run). */
6260
+ defaultModel?: ModelId;
6261
+ /** Default provider for runs (can be overridden per-run). */
6262
+ defaultProvider?: ProviderId$1;
6263
+ /** Default tools for runs (merged with per-run tools). */
6264
+ defaultTools?: Tool[];
6265
+ /** Persistence mode (default: 'memory'). */
6266
+ persistence?: LocalSessionPersistence;
6267
+ /** Storage path for file/sqlite persistence (default: ~/.modelrelay/sessions/). */
6268
+ storagePath?: string;
6269
+ /** Session ID to use (default: generate new). */
6270
+ sessionId?: SessionId;
6271
+ /** Session metadata. */
6272
+ metadata?: Record<string, unknown>;
6273
+ }
6274
+ /**
6275
+ * Options for creating a remote session.
6276
+ */
6277
+ interface RemoteSessionOptions {
6278
+ /** Tool registry for handling client-side tool calls. */
6279
+ toolRegistry?: ToolRegistry;
6280
+ /** Default model for runs (can be overridden per-run). */
6281
+ defaultModel?: ModelId;
6282
+ /** Default provider for runs (can be overridden per-run). */
6283
+ defaultProvider?: ProviderId$1;
6284
+ /** Default tools for runs (merged with per-run tools). */
6285
+ defaultTools?: Tool[];
6286
+ /** Session metadata (stored on server). */
6287
+ metadata?: Record<string, unknown>;
6288
+ /** End user ID to associate with the session. */
6289
+ endUserId?: string;
6290
+ }
6291
+ /**
6292
+ * Options for listing remote sessions.
6293
+ */
6294
+ interface ListSessionsOptions {
6295
+ /** Maximum number of sessions to return. */
6296
+ limit?: number;
6297
+ /** Cursor for pagination. */
6298
+ cursor?: string;
6299
+ /** End user ID to filter by. */
6300
+ endUserId?: string;
6301
+ }
6302
+ /**
6303
+ * Response from listing sessions.
6304
+ */
6305
+ interface ListSessionsResponse {
6306
+ sessions: RemoteSessionInfo[];
6307
+ nextCursor?: string;
6308
+ }
6309
+ /**
6310
+ * Summary info for a remote session (from list).
6311
+ */
6312
+ interface RemoteSessionInfo {
6313
+ readonly id: SessionId;
6314
+ readonly messageCount: number;
6315
+ readonly metadata: Record<string, unknown>;
6316
+ readonly createdAt: Date;
6317
+ readonly updatedAt: Date;
6318
+ }
6319
+ /**
6320
+ * Serialized session state for persistence.
6321
+ */
6322
+ interface SessionState {
6323
+ id: SessionId;
6324
+ messages: SessionMessage[];
6325
+ artifacts: Record<string, unknown>;
6326
+ metadata: Record<string, unknown>;
6327
+ createdAt: string;
6328
+ updatedAt: string;
6329
+ }
6330
+ /**
6331
+ * Interface for session storage backends.
6332
+ */
6333
+ interface SessionStore {
6334
+ /** Load a session by ID. Returns null if not found. */
6335
+ load(id: SessionId): Promise<SessionState | null>;
6336
+ /** Save a session state. */
6337
+ save(state: SessionState): Promise<void>;
6338
+ /** Delete a session by ID. */
6339
+ delete(id: SessionId): Promise<void>;
6340
+ /** List all session IDs. */
6341
+ list(): Promise<SessionId[]>;
6342
+ /** Close the store and release resources. */
6343
+ close(): Promise<void>;
6344
+ }
6345
+
6346
+ /**
6347
+ * Client-managed session implementation.
6348
+ *
6349
+ * LocalSession keeps conversation history on the client side with optional
6350
+ * persistence to memory, file, or SQLite. Use for:
6351
+ * - Local AI coding agents (Claude Code, Cursor)
6352
+ * - Privacy-sensitive workflows (history never leaves device)
6353
+ * - Offline-capable agents
6354
+ *
6355
+ * @module
6356
+ */
6357
+
6358
+ /**
6359
+ * Client-managed session with optional persistence.
6360
+ *
6361
+ * @example
6362
+ * ```typescript
6363
+ * import { ModelRelay, LocalSession } from "modelrelay";
6364
+ *
6365
+ * const client = ModelRelay.fromSecretKey(process.env.MODELRELAY_SECRET_KEY!);
6366
+ * const session = LocalSession.create(client, {
6367
+ * toolRegistry: createLocalFSTools({ root: process.cwd() }),
6368
+ * persistence: "sqlite",
6369
+ * });
6370
+ *
6371
+ * const result1 = await session.run("Create a file called hello.txt with 'Hello World'");
6372
+ * const result2 = await session.run("Now read that file back to me");
6373
+ * ```
6374
+ */
6375
+ declare class LocalSession implements Session {
6376
+ readonly type: "local";
6377
+ readonly id: SessionId;
6378
+ private readonly client;
6379
+ private readonly store;
6380
+ private readonly toolRegistry?;
6381
+ private readonly defaultModel?;
6382
+ private readonly defaultProvider?;
6383
+ private readonly defaultTools?;
6384
+ private readonly metadata;
6385
+ private messages;
6386
+ private artifacts;
6387
+ private nextSeq;
6388
+ private createdAt;
6389
+ private updatedAt;
6390
+ private currentRunId?;
6391
+ private currentNodeId?;
6392
+ private currentWaiting?;
6393
+ private currentEvents;
6394
+ private currentUsage;
6395
+ private constructor();
6396
+ /**
6397
+ * Create a new local session.
6398
+ *
6399
+ * @param client - ModelRelay client
6400
+ * @param options - Session configuration
6401
+ * @returns A new LocalSession instance
6402
+ */
6403
+ static create(client: ModelRelay, options?: LocalSessionOptions): LocalSession;
6404
+ /**
6405
+ * Resume an existing session from storage.
6406
+ *
6407
+ * @param client - ModelRelay client
6408
+ * @param sessionId - ID of the session to resume
6409
+ * @param options - Session configuration (must match original persistence settings)
6410
+ * @returns The resumed LocalSession, or null if not found
6411
+ */
6412
+ static resume(client: ModelRelay, sessionId: string | SessionId, options?: LocalSessionOptions): Promise<LocalSession | null>;
6413
+ get history(): readonly SessionMessage[];
6414
+ run(prompt: string, options?: SessionRunOptions): Promise<SessionRunResult>;
6415
+ submitToolResults(results: ToolExecutionResult[]): Promise<SessionRunResult>;
6416
+ getArtifacts(): SessionArtifacts;
6417
+ close(): Promise<void>;
6418
+ private addMessage;
6419
+ private buildInput;
6420
+ private processRunEvents;
6421
+ private executeTools;
6422
+ private persist;
6423
+ }
6424
+ /**
6425
+ * Create a new local session.
6426
+ * Convenience function for LocalSession.create().
6427
+ */
6428
+ declare function createLocalSession(client: ModelRelay, options?: LocalSessionOptions): LocalSession;
6429
+
6430
+ /**
6431
+ * Server-managed session implementation.
6432
+ *
6433
+ * RemoteSession stores conversation history on the server for:
6434
+ * - Cross-device continuity (start on CLI, continue in browser)
6435
+ * - Team collaboration and session sharing
6436
+ * - Persistent audit trails
6437
+ *
6438
+ * @module
6439
+ */
6440
+
6441
+ /**
6442
+ * Server-managed session with cross-device continuity.
6443
+ *
6444
+ * @example
6445
+ * ```typescript
6446
+ * import { ModelRelay, RemoteSession } from "modelrelay";
6447
+ *
6448
+ * const client = ModelRelay.fromSecretKey(process.env.MODELRELAY_SECRET_KEY!);
6449
+ *
6450
+ * // Create a new remote session
6451
+ * const session = await RemoteSession.create(client, {
6452
+ * metadata: { name: "Feature implementation" },
6453
+ * });
6454
+ *
6455
+ * // Run prompts with server-managed history
6456
+ * const result1 = await session.run("Explain the codebase structure");
6457
+ * const result2 = await session.run("Now implement the login feature");
6458
+ *
6459
+ * // Later, from another device:
6460
+ * const resumed = await RemoteSession.get(client, session.id);
6461
+ * const result3 = await resumed.run("Continue with the tests");
6462
+ * ```
6463
+ */
6464
+ declare class RemoteSession implements Session {
6465
+ readonly type: "remote";
6466
+ readonly id: SessionId;
6467
+ private readonly client;
6468
+ private readonly http;
6469
+ private readonly toolRegistry?;
6470
+ private readonly defaultModel?;
6471
+ private readonly defaultProvider?;
6472
+ private readonly defaultTools?;
6473
+ private metadata;
6474
+ private endUserId?;
6475
+ private messages;
6476
+ private artifacts;
6477
+ private nextSeq;
6478
+ private createdAt;
6479
+ private updatedAt;
6480
+ private currentRunId?;
6481
+ private currentNodeId?;
6482
+ private currentWaiting?;
6483
+ private currentEvents;
6484
+ private currentUsage;
6485
+ private constructor();
6486
+ /**
6487
+ * Create a new remote session on the server.
6488
+ *
6489
+ * @param client - ModelRelay client
6490
+ * @param options - Session configuration
6491
+ * @returns A new RemoteSession instance
6492
+ */
6493
+ static create(client: ModelRelay, options?: RemoteSessionOptions): Promise<RemoteSession>;
6494
+ /**
6495
+ * Get an existing remote session by ID.
6496
+ *
6497
+ * @param client - ModelRelay client
6498
+ * @param sessionId - ID of the session to retrieve
6499
+ * @param options - Optional configuration (toolRegistry, defaults)
6500
+ * @returns The RemoteSession instance
6501
+ */
6502
+ static get(client: ModelRelay, sessionId: string | SessionId, options?: RemoteSessionOptions): Promise<RemoteSession>;
6503
+ /**
6504
+ * List remote sessions.
6505
+ *
6506
+ * @param client - ModelRelay client
6507
+ * @param options - List options
6508
+ * @returns Paginated list of session info
6509
+ */
6510
+ static list(client: ModelRelay, options?: {
6511
+ limit?: number;
6512
+ offset?: number;
6513
+ endUserId?: string;
6514
+ }): Promise<{
6515
+ sessions: RemoteSessionInfo[];
6516
+ nextCursor?: string;
6517
+ }>;
6518
+ /**
6519
+ * Delete a remote session.
6520
+ *
6521
+ * @param client - ModelRelay client
6522
+ * @param sessionId - ID of the session to delete
6523
+ */
6524
+ static delete(client: ModelRelay, sessionId: string | SessionId): Promise<void>;
6525
+ /**
6526
+ * Full conversation history (read-only).
6527
+ */
6528
+ get history(): readonly SessionMessage[];
6529
+ /**
6530
+ * Execute a prompt as a new turn in this session.
6531
+ */
6532
+ run(prompt: string, options?: SessionRunOptions): Promise<SessionRunResult>;
6533
+ /**
6534
+ * Submit tool results for a waiting run.
6535
+ */
6536
+ submitToolResults(results: ToolExecutionResult[]): Promise<SessionRunResult>;
6537
+ /**
6538
+ * Get all artifacts produced during this session.
6539
+ */
6540
+ getArtifacts(): SessionArtifacts;
6541
+ /**
6542
+ * Close the session (no-op for remote sessions).
6543
+ */
6544
+ close(): Promise<void>;
6545
+ /**
6546
+ * Refresh the session state from the server.
6547
+ */
6548
+ refresh(): Promise<void>;
6549
+ private addMessage;
6550
+ private buildInput;
6551
+ private resetRunState;
6552
+ private processRunEvents;
6553
+ private executeToolsLocally;
6554
+ }
6555
+
6556
+ /**
6557
+ * SessionsClient - Entry point for session management.
6558
+ *
6559
+ * Provides factory methods for creating local and remote sessions.
6560
+ *
6561
+ * @module
6562
+ */
6563
+
6564
+ /**
6565
+ * Client for managing sessions.
6566
+ *
6567
+ * Provides access to both local (client-managed) and remote (server-managed) sessions.
6568
+ *
6569
+ * @example
6570
+ * ```typescript
6571
+ * import { ModelRelay } from "modelrelay";
6572
+ *
6573
+ * const client = ModelRelay.fromSecretKey(process.env.MODELRELAY_SECRET_KEY!);
6574
+ *
6575
+ * // Local session (history stays on device)
6576
+ * const localSession = client.sessions.createLocal({
6577
+ * toolRegistry: createLocalFSTools({ root: process.cwd() }),
6578
+ * persistence: "sqlite",
6579
+ * });
6580
+ *
6581
+ * // Remote session (history stored on server) - coming soon
6582
+ * // const remoteSession = await client.sessions.create({ metadata: { name: "My Session" } });
6583
+ * ```
6584
+ */
6585
+ declare class SessionsClient {
6586
+ private readonly modelRelay;
6587
+ private readonly http;
6588
+ private readonly auth;
6589
+ constructor(modelRelay: ModelRelay, http: HTTPClient, auth: AuthClient);
6590
+ /**
6591
+ * Create a new local session.
6592
+ *
6593
+ * Local sessions keep history on the client side with optional persistence.
6594
+ * Use for privacy-sensitive workflows or offline-capable agents.
6595
+ *
6596
+ * @param options - Session configuration
6597
+ * @returns A new LocalSession instance
6598
+ *
6599
+ * @example
6600
+ * ```typescript
6601
+ * const session = client.sessions.createLocal({
6602
+ * toolRegistry: createLocalFSTools({ root: process.cwd() }),
6603
+ * persistence: "memory", // or "file", "sqlite"
6604
+ * });
6605
+ *
6606
+ * const result = await session.run("Create a hello world file");
6607
+ * ```
6608
+ */
6609
+ createLocal(options?: LocalSessionOptions): LocalSession;
6610
+ /**
6611
+ * Resume an existing local session from storage.
6612
+ *
6613
+ * @param sessionId - ID of the session to resume
6614
+ * @param options - Session configuration (must match original persistence settings)
6615
+ * @returns The resumed LocalSession, or null if not found
6616
+ *
6617
+ * @example
6618
+ * ```typescript
6619
+ * const session = await client.sessions.resumeLocal("session-id", {
6620
+ * persistence: "sqlite",
6621
+ * });
6622
+ *
6623
+ * if (session) {
6624
+ * console.log(`Resumed session with ${session.history.length} messages`);
6625
+ * const result = await session.run("Continue where we left off");
6626
+ * }
6627
+ * ```
5301
6628
  */
5302
- list(): Promise<Tier[]>;
6629
+ resumeLocal(sessionId: string | SessionId, options?: LocalSessionOptions): Promise<LocalSession | null>;
5303
6630
  /**
5304
- * Get a tier by ID.
6631
+ * Create a new remote session.
6632
+ *
6633
+ * Remote sessions store history on the server for cross-device continuity.
6634
+ * Use for browser-based agents or team collaboration.
6635
+ *
6636
+ * @param options - Session configuration
6637
+ * @returns A new RemoteSession instance
6638
+ *
6639
+ * @example
6640
+ * ```typescript
6641
+ * const session = await client.sessions.create({
6642
+ * metadata: { name: "Feature implementation" },
6643
+ * });
6644
+ *
6645
+ * const result = await session.run("Implement the login feature");
6646
+ * ```
5305
6647
  */
5306
- get(tierId: string): Promise<Tier>;
6648
+ create(options?: RemoteSessionOptions): Promise<RemoteSession>;
5307
6649
  /**
5308
- * Create a Stripe checkout session for a tier (Stripe-first flow).
6650
+ * Get an existing remote session by ID.
5309
6651
  *
5310
- * This enables users to subscribe before authenticating. Stripe collects
5311
- * the customer's email during checkout. After checkout completes, a
5312
- * customer record is created with the email from Stripe. The customer
5313
- * can later be linked to an identity via POST /customers/claim.
6652
+ * @param sessionId - ID of the session to retrieve
6653
+ * @param options - Optional configuration (toolRegistry, defaults)
6654
+ * @returns The RemoteSession instance
5314
6655
  *
5315
- * Requires a secret key (mr_sk_*).
6656
+ * @example
6657
+ * ```typescript
6658
+ * const session = await client.sessions.get("session-id");
6659
+ * console.log(`Session has ${session.history.length} messages`);
6660
+ * ```
6661
+ */
6662
+ get(sessionId: string | SessionId, options?: RemoteSessionOptions): Promise<RemoteSession>;
6663
+ /**
6664
+ * List remote sessions.
5316
6665
  *
5317
- * @param tierId - The tier ID to create a checkout session for
5318
- * @param request - Checkout session request with redirect URLs
5319
- * @returns Checkout session with Stripe URL
6666
+ * @param options - List options (limit, cursor, endUserId)
6667
+ * @returns Paginated list of session summaries
6668
+ *
6669
+ * @example
6670
+ * ```typescript
6671
+ * const { sessions, nextCursor } = await client.sessions.list({ limit: 10 });
6672
+ * for (const info of sessions) {
6673
+ * console.log(`Session ${info.id}: ${info.messageCount} messages`);
6674
+ * }
6675
+ * ```
5320
6676
  */
5321
- checkout(tierId: string, request: TierCheckoutRequest): Promise<TierCheckoutSession>;
5322
- }
5323
-
5324
- type ModelCapability = components["schemas"]["ModelCapability"];
5325
- type ProviderId = components["schemas"]["ProviderId"];
5326
- type CatalogModel = components["schemas"]["Model"];
5327
- interface ModelsListParams {
5328
- provider?: ProviderId;
5329
- capability?: ModelCapability;
5330
- }
5331
- /**
5332
- * ModelsClient provides methods to list models and their rich metadata.
5333
- *
5334
- * Note: The underlying API endpoint is public (no auth required), but the SDK's
5335
- * HTTP client may still send auth headers if configured.
5336
- */
5337
- declare class ModelsClient {
5338
- private readonly http;
5339
- constructor(http: HTTPClient);
6677
+ list(options?: ListSessionsOptions): Promise<ListSessionsResponse>;
5340
6678
  /**
5341
- * List active models with rich metadata.
6679
+ * Delete a remote session.
6680
+ *
6681
+ * Requires a secret key (not publishable key).
6682
+ *
6683
+ * @param sessionId - ID of the session to delete
6684
+ *
6685
+ * @example
6686
+ * ```typescript
6687
+ * await client.sessions.delete("session-id");
6688
+ * ```
5342
6689
  */
5343
- list(params?: ModelsListParams): Promise<CatalogModel[]>;
6690
+ delete(sessionId: string | SessionId): Promise<void>;
5344
6691
  }
5345
6692
 
5346
6693
  declare class CustomerResponsesClient {
@@ -5844,6 +7191,501 @@ declare function parseSecretKey(raw: string): SecretKey;
5844
7191
  declare function isPublishableKey(key: ApiKey): key is PublishableKey;
5845
7192
  declare function isSecretKey(key: ApiKey): key is SecretKey;
5846
7193
 
7194
+ /**
7195
+ * Local filesystem tool pack for client-side tool execution.
7196
+ *
7197
+ * Implements tools.v0 contract:
7198
+ * - fs.read_file - Read workspace-relative files
7199
+ * - fs.list_files - List files recursively
7200
+ * - fs.search - Regex search (ripgrep or JS fallback)
7201
+ *
7202
+ * Safety features:
7203
+ * - Root sandbox with symlink resolution
7204
+ * - Path traversal prevention
7205
+ * - Size limits with hard caps
7206
+ * - Ignore patterns for common large directories
7207
+ * - UTF-8 validation
7208
+ *
7209
+ * @module
7210
+ */
7211
+
7212
+ /** Reserved tool names from tools.v0 specification. */
7213
+ declare const ToolNames: {
7214
+ readonly FS_READ_FILE: "fs.read_file";
7215
+ readonly FS_LIST_FILES: "fs.list_files";
7216
+ readonly FS_SEARCH: "fs.search";
7217
+ };
7218
+ /** Default size limits and caps from wire contract. */
7219
+ declare const FSDefaults: {
7220
+ readonly MAX_READ_BYTES: 64000;
7221
+ readonly HARD_MAX_READ_BYTES: 1000000;
7222
+ readonly MAX_LIST_ENTRIES: 2000;
7223
+ readonly HARD_MAX_LIST_ENTRIES: 20000;
7224
+ readonly MAX_SEARCH_MATCHES: 100;
7225
+ readonly HARD_MAX_SEARCH_MATCHES: 2000;
7226
+ readonly SEARCH_TIMEOUT_MS: 5000;
7227
+ readonly MAX_SEARCH_BYTES_PER_FILE: 1000000;
7228
+ };
7229
+ /** Default directories to skip during list/search operations. */
7230
+ declare const DEFAULT_IGNORE_DIRS: Set<string>;
7231
+ /** Configuration options for LocalFSToolPack. */
7232
+ interface LocalFSToolPackOptions {
7233
+ /** Root directory for sandboxing (required). All paths are relative to this. */
7234
+ root: string;
7235
+ /** Directory names to skip during list/search. Defaults to DEFAULT_IGNORE_DIRS. */
7236
+ ignoreDirs?: Set<string>;
7237
+ /** Default max_bytes for fs.read_file. Defaults to 64KB. */
7238
+ maxReadBytes?: number;
7239
+ /** Hard cap for fs.read_file max_bytes. Defaults to 1MB. */
7240
+ hardMaxReadBytes?: number;
7241
+ /** Default max_entries for fs.list_files. Defaults to 2000. */
7242
+ maxListEntries?: number;
7243
+ /** Hard cap for fs.list_files max_entries. Defaults to 20000. */
7244
+ hardMaxListEntries?: number;
7245
+ /** Default max_matches for fs.search. Defaults to 100. */
7246
+ maxSearchMatches?: number;
7247
+ /** Hard cap for fs.search max_matches. Defaults to 2000. */
7248
+ hardMaxSearchMatches?: number;
7249
+ /** Timeout for fs.search in milliseconds. Defaults to 5000. */
7250
+ searchTimeoutMs?: number;
7251
+ /** Max bytes to read per file during JS fallback search. Defaults to 1MB. */
7252
+ maxSearchBytesPerFile?: number;
7253
+ }
7254
+ /**
7255
+ * Tool pack providing safe filesystem access for LLM workflows.
7256
+ *
7257
+ * @example
7258
+ * ```typescript
7259
+ * const pack = new LocalFSToolPack({ root: process.cwd() });
7260
+ * const registry = pack.toRegistry();
7261
+ *
7262
+ * // Use tools in a workflow
7263
+ * const response = await client.responses.create({
7264
+ * model: "anthropic/claude-sonnet-4-20250514",
7265
+ * input: [{ type: "message", role: "user", content: [{ type: "text", text: "List all TypeScript files" }] }],
7266
+ * tools: pack.getToolDefinitions(),
7267
+ * });
7268
+ *
7269
+ * // Execute tool calls
7270
+ * const results = await registry.executeAll(response.output.filter(o => o.type === "tool_use"));
7271
+ * ```
7272
+ */
7273
+ declare class LocalFSToolPack {
7274
+ private readonly rootAbs;
7275
+ private readonly cfg;
7276
+ private rgPath;
7277
+ private rgChecked;
7278
+ constructor(options: LocalFSToolPackOptions);
7279
+ /**
7280
+ * Returns the tool definitions for LLM requests.
7281
+ * Use these when constructing the tools array for /responses requests.
7282
+ */
7283
+ getToolDefinitions(): Tool[];
7284
+ /**
7285
+ * Registers handlers into an existing ToolRegistry.
7286
+ * @param registry - The registry to register into
7287
+ * @returns The registry for chaining
7288
+ */
7289
+ registerInto(registry: ToolRegistry): ToolRegistry;
7290
+ /**
7291
+ * Creates a new ToolRegistry with fs.* tools pre-registered.
7292
+ */
7293
+ toRegistry(): ToolRegistry;
7294
+ private readFile;
7295
+ private listFiles;
7296
+ private search;
7297
+ /**
7298
+ * Resolves a workspace-relative path and validates it stays within the sandbox.
7299
+ * @throws {ToolArgumentError} if path is invalid
7300
+ * @throws {PathEscapeError} if resolved path escapes root
7301
+ */
7302
+ private resolveAndValidatePath;
7303
+ private detectRipgrep;
7304
+ private searchWithRipgrep;
7305
+ private normalizeRipgrepLine;
7306
+ private searchWithJS;
7307
+ private parseArgs;
7308
+ private toolArgumentError;
7309
+ private requireString;
7310
+ private optionalString;
7311
+ private optionalPositiveInt;
7312
+ private isValidUtf8;
7313
+ /**
7314
+ * Recursively walks a directory, calling visitor for each entry.
7315
+ * Visitor returns true to continue, false to skip (for dirs) or stop.
7316
+ */
7317
+ private walkDir;
7318
+ }
7319
+ /**
7320
+ * Creates a LocalFSToolPack with the given options.
7321
+ *
7322
+ * @example
7323
+ * ```typescript
7324
+ * const pack = createLocalFSToolPack({ root: process.cwd() });
7325
+ * ```
7326
+ */
7327
+ declare function createLocalFSToolPack(options: LocalFSToolPackOptions): LocalFSToolPack;
7328
+ /**
7329
+ * Creates a ToolRegistry with fs.* tools pre-registered.
7330
+ * Shorthand for createLocalFSToolPack(options).toRegistry().
7331
+ *
7332
+ * @example
7333
+ * ```typescript
7334
+ * const registry = createLocalFSTools({ root: process.cwd() });
7335
+ * const result = await registry.execute(toolCall);
7336
+ * ```
7337
+ */
7338
+ declare function createLocalFSTools(options: LocalFSToolPackOptions): ToolRegistry;
7339
+
7340
+ /**
7341
+ * Browser automation tools using Playwright with accessibility tree extraction.
7342
+ *
7343
+ * Uses CDP (Chrome DevTools Protocol) for semantic element targeting instead of
7344
+ * pixel-based screenshots, making it 10-100x cheaper than vision-based automation.
7345
+ *
7346
+ * @example
7347
+ * ```typescript
7348
+ * import { BrowserToolPack, createBrowserTools } from "@modelrelay/sdk";
7349
+ *
7350
+ * // Create a browser tool pack with domain restrictions
7351
+ * const pack = new BrowserToolPack({
7352
+ * allowedDomains: ["example.com", "docs.example.com"],
7353
+ * headless: true,
7354
+ * });
7355
+ *
7356
+ * // Initialize the browser (must be called before use)
7357
+ * await pack.initialize();
7358
+ *
7359
+ * // Get tool definitions for LLM
7360
+ * const tools = pack.getToolDefinitions();
7361
+ *
7362
+ * // Get registry for executing tool calls
7363
+ * const registry = pack.toRegistry();
7364
+ *
7365
+ * // Clean up when done
7366
+ * await pack.close();
7367
+ * ```
7368
+ *
7369
+ * @module
7370
+ */
7371
+
7372
+ type Browser = any;
7373
+ type BrowserContext = any;
7374
+ /**
7375
+ * Tool names for browser automation.
7376
+ */
7377
+ declare const BrowserToolNames: {
7378
+ /** Navigate to a URL and return accessibility tree */
7379
+ readonly NAVIGATE: "browser.navigate";
7380
+ /** Click an element by accessible name/role */
7381
+ readonly CLICK: "browser.click";
7382
+ /** Type text into an input field */
7383
+ readonly TYPE: "browser.type";
7384
+ /** Get current accessibility tree */
7385
+ readonly SNAPSHOT: "browser.snapshot";
7386
+ /** Scroll the page */
7387
+ readonly SCROLL: "browser.scroll";
7388
+ /** Capture a screenshot */
7389
+ readonly SCREENSHOT: "browser.screenshot";
7390
+ /** Extract data using CSS selectors */
7391
+ readonly EXTRACT: "browser.extract";
7392
+ };
7393
+ /**
7394
+ * Default configuration values for browser tools.
7395
+ */
7396
+ declare const BrowserDefaults: {
7397
+ /** Navigation timeout in milliseconds */
7398
+ readonly NAVIGATION_TIMEOUT_MS: 30000;
7399
+ /** Action timeout in milliseconds */
7400
+ readonly ACTION_TIMEOUT_MS: 5000;
7401
+ /** Maximum nodes to include in accessibility tree output */
7402
+ readonly MAX_SNAPSHOT_NODES: 500;
7403
+ /** Maximum screenshot size in bytes */
7404
+ readonly MAX_SCREENSHOT_BYTES: 5000000;
7405
+ };
7406
+ /**
7407
+ * Configuration options for BrowserToolPack.
7408
+ */
7409
+ interface BrowserToolPackOptions {
7410
+ /**
7411
+ * Whitelist of allowed domains. If set, only URLs matching these domains
7412
+ * will be allowed. Supports suffix matching (e.g., "example.com" matches
7413
+ * "sub.example.com").
7414
+ */
7415
+ allowedDomains?: string[];
7416
+ /**
7417
+ * Blacklist of blocked domains. URLs matching these domains will be rejected.
7418
+ * Supports suffix matching.
7419
+ */
7420
+ blockedDomains?: string[];
7421
+ /**
7422
+ * Navigation timeout in milliseconds. Default: 30000
7423
+ */
7424
+ navigationTimeoutMs?: number;
7425
+ /**
7426
+ * Action timeout in milliseconds. Default: 5000
7427
+ */
7428
+ actionTimeoutMs?: number;
7429
+ /**
7430
+ * Maximum nodes to include in accessibility tree. Default: 500
7431
+ */
7432
+ maxSnapshotNodes?: number;
7433
+ /**
7434
+ * Run browser in headless mode. Default: true
7435
+ */
7436
+ headless?: boolean;
7437
+ /**
7438
+ * Existing Browser instance to use instead of creating a new one.
7439
+ */
7440
+ browser?: Browser;
7441
+ /**
7442
+ * Existing BrowserContext to use instead of creating a new one.
7443
+ */
7444
+ context?: BrowserContext;
7445
+ }
7446
+ /**
7447
+ * A tool pack for browser automation using Playwright.
7448
+ *
7449
+ * Uses accessibility tree extraction via CDP for efficient, semantic-based
7450
+ * browser automation. This is much cheaper than vision-based approaches
7451
+ * because it works with structured text instead of screenshots.
7452
+ *
7453
+ * @example
7454
+ * ```typescript
7455
+ * const pack = new BrowserToolPack({
7456
+ * allowedDomains: ["example.com"],
7457
+ * });
7458
+ * await pack.initialize();
7459
+ *
7460
+ * const registry = pack.toRegistry();
7461
+ * const result = await registry.execute(toolCall);
7462
+ *
7463
+ * await pack.close();
7464
+ * ```
7465
+ */
7466
+ declare class BrowserToolPack {
7467
+ private browser;
7468
+ private context;
7469
+ private page;
7470
+ private cdpSession;
7471
+ private ownsBrowser;
7472
+ private ownsContext;
7473
+ private cfg;
7474
+ constructor(options?: BrowserToolPackOptions);
7475
+ /**
7476
+ * Initialize the browser. Must be called before using any tools.
7477
+ */
7478
+ initialize(): Promise<void>;
7479
+ /**
7480
+ * Close the browser and clean up resources.
7481
+ */
7482
+ close(): Promise<void>;
7483
+ /**
7484
+ * Get tool definitions for use with LLM APIs.
7485
+ */
7486
+ getToolDefinitions(): Tool[];
7487
+ /**
7488
+ * Register tool handlers into an existing registry.
7489
+ */
7490
+ registerInto(registry: ToolRegistry): ToolRegistry;
7491
+ /**
7492
+ * Create a new registry with just this pack's tools.
7493
+ */
7494
+ toRegistry(): ToolRegistry;
7495
+ private ensureInitialized;
7496
+ private parseArgs;
7497
+ private validateUrl;
7498
+ /**
7499
+ * Validates the current page URL against allowlist/blocklist.
7500
+ * Called after navigation and before any action to catch redirects
7501
+ * and in-session navigation to blocked domains.
7502
+ */
7503
+ private ensureCurrentUrlAllowed;
7504
+ private getAccessibilityTree;
7505
+ private formatAXTree;
7506
+ private navigate;
7507
+ private click;
7508
+ private type;
7509
+ private snapshot;
7510
+ private scroll;
7511
+ private screenshot;
7512
+ private extract;
7513
+ }
7514
+ /**
7515
+ * Create a BrowserToolPack with the given options.
7516
+ */
7517
+ declare function createBrowserToolPack(options?: BrowserToolPackOptions): BrowserToolPack;
7518
+ /**
7519
+ * Create a ToolRegistry with browser tools registered.
7520
+ *
7521
+ * Note: You must call `pack.initialize()` before using the registry.
7522
+ *
7523
+ * @example
7524
+ * ```typescript
7525
+ * const { pack, registry } = createBrowserTools({ headless: true });
7526
+ * await pack.initialize();
7527
+ *
7528
+ * // Use registry to execute tool calls
7529
+ * const result = await registry.execute(toolCall);
7530
+ *
7531
+ * await pack.close();
7532
+ * ```
7533
+ */
7534
+ declare function createBrowserTools(options?: BrowserToolPackOptions): {
7535
+ pack: BrowserToolPack;
7536
+ registry: ToolRegistry;
7537
+ };
7538
+
7539
+ /**
7540
+ * Tool runner for executing client-side tools in workflow runs.
7541
+ *
7542
+ * Handles node_waiting events by executing local tool handlers
7543
+ * and submitting results back to the server.
7544
+ *
7545
+ * @module
7546
+ */
7547
+
7548
+ /** Configuration options for ToolRunner. */
7549
+ interface ToolRunnerOptions {
7550
+ /** Tool registry containing handlers for tool names. */
7551
+ registry: ToolRegistry;
7552
+ /** Runs client for submitting results back to the server. */
7553
+ runsClient: RunsClient;
7554
+ /** Customer ID for attributed requests (optional). */
7555
+ customerId?: string;
7556
+ /** Called before executing each tool call (optional). */
7557
+ onBeforeExecute?: (pending: PendingToolCallV0) => void | Promise<void>;
7558
+ /** Called after each tool execution (optional). */
7559
+ onAfterExecute?: (result: ToolExecutionResult) => void | Promise<void>;
7560
+ /** Called when results are successfully submitted (optional). */
7561
+ onSubmitted?: (runId: RunId, count: number, status: RunStatusV0) => void | Promise<void>;
7562
+ /** Called when an error occurs during execution (optional). */
7563
+ onError?: (error: Error, pending?: PendingToolCallV0) => void | Promise<void>;
7564
+ }
7565
+ /** Response from handling a node_waiting event. */
7566
+ interface HandleWaitingResult {
7567
+ /** Number of results accepted by the server. */
7568
+ accepted: number;
7569
+ /** New run status after submitting results. */
7570
+ status: RunStatusV0;
7571
+ /** Execution results for each tool call. */
7572
+ results: ToolExecutionResult[];
7573
+ }
7574
+ /**
7575
+ * Executes client-side tools for workflow runs.
7576
+ *
7577
+ * Handles `node_waiting` events from the run event stream, executes the
7578
+ * corresponding tool handlers from the registry, and submits results
7579
+ * back to the server.
7580
+ *
7581
+ * @example
7582
+ * ```typescript
7583
+ * import { ModelRelay, createLocalFSTools, ToolRunner } from "modelrelay";
7584
+ *
7585
+ * const client = ModelRelay.fromSecretKey(process.env.MODELRELAY_SECRET_KEY!);
7586
+ * const registry = createLocalFSTools({ root: process.cwd() });
7587
+ *
7588
+ * const runner = new ToolRunner({
7589
+ * registry,
7590
+ * runsClient: client.runs,
7591
+ * });
7592
+ *
7593
+ * // Create a run and process events
7594
+ * const run = await client.runs.create(workflowSpec);
7595
+ * for await (const event of runner.processEvents(run.run_id, client.runs.events(run.run_id))) {
7596
+ * console.log(event.type);
7597
+ * }
7598
+ * ```
7599
+ */
7600
+ declare class ToolRunner {
7601
+ private readonly registry;
7602
+ private readonly runsClient;
7603
+ private readonly customerId?;
7604
+ private readonly onBeforeExecute?;
7605
+ private readonly onAfterExecute?;
7606
+ private readonly onSubmitted?;
7607
+ private readonly onError?;
7608
+ constructor(options: ToolRunnerOptions);
7609
+ /**
7610
+ * Handles a node_waiting event by executing tools and submitting results.
7611
+ *
7612
+ * @param runId - The run ID
7613
+ * @param nodeId - The node ID that is waiting
7614
+ * @param waiting - The waiting state with pending tool calls
7615
+ * @returns The submission response with accepted count and new status
7616
+ *
7617
+ * @example
7618
+ * ```typescript
7619
+ * for await (const event of client.runs.events(runId)) {
7620
+ * if (event.type === "node_waiting") {
7621
+ * const result = await runner.handleNodeWaiting(
7622
+ * runId,
7623
+ * event.node_id,
7624
+ * event.waiting
7625
+ * );
7626
+ * console.log(`Submitted ${result.accepted} results, status: ${result.status}`);
7627
+ * }
7628
+ * }
7629
+ * ```
7630
+ */
7631
+ handleNodeWaiting(runId: RunId, nodeId: NodeId, waiting: NodeWaitingV0): Promise<HandleWaitingResult>;
7632
+ /**
7633
+ * Processes a stream of run events, automatically handling node_waiting events.
7634
+ *
7635
+ * This is the main entry point for running a workflow with client-side tools.
7636
+ * It yields all events through (including node_waiting after handling).
7637
+ *
7638
+ * @param runId - The run ID to process
7639
+ * @param events - AsyncIterable of run events (from RunsClient.events())
7640
+ * @yields All run events, with node_waiting events handled automatically
7641
+ *
7642
+ * @example
7643
+ * ```typescript
7644
+ * const run = await client.runs.create(workflowSpec);
7645
+ * const eventStream = client.runs.events(run.run_id);
7646
+ *
7647
+ * for await (const event of runner.processEvents(run.run_id, eventStream)) {
7648
+ * switch (event.type) {
7649
+ * case "node_started":
7650
+ * console.log(`Node ${event.node_id} started`);
7651
+ * break;
7652
+ * case "node_succeeded":
7653
+ * console.log(`Node ${event.node_id} succeeded`);
7654
+ * break;
7655
+ * case "run_succeeded":
7656
+ * console.log("Run completed!");
7657
+ * break;
7658
+ * }
7659
+ * }
7660
+ * ```
7661
+ */
7662
+ processEvents(runId: RunId, events: AsyncIterable<RunEventV0>): AsyncGenerator<RunEventV0, void, undefined>;
7663
+ /**
7664
+ * Checks if a run event is a node_waiting event.
7665
+ * Utility for filtering events when not using processEvents().
7666
+ */
7667
+ static isNodeWaiting(event: RunEventV0): event is RunEventNodeWaitingV0;
7668
+ /**
7669
+ * Checks if a run status is terminal (succeeded, failed, or canceled).
7670
+ * Utility for determining when to stop polling.
7671
+ */
7672
+ static isTerminalStatus(status: RunStatusV0): boolean;
7673
+ }
7674
+ /**
7675
+ * Creates a ToolRunner with the given options.
7676
+ *
7677
+ * @example
7678
+ * ```typescript
7679
+ * const runner = createToolRunner({
7680
+ * registry: createLocalFSTools({ root: process.cwd() }),
7681
+ * runsClient: client.runs,
7682
+ * onBeforeExecute: (pending) => console.log(`Executing ${pending.name}`),
7683
+ * onAfterExecute: (result) => console.log(`Result: ${result.result}`),
7684
+ * });
7685
+ * ```
7686
+ */
7687
+ declare function createToolRunner(options: ToolRunnerOptions): ToolRunner;
7688
+
5847
7689
  type index_$defs = $defs;
5848
7690
  type index_components = components;
5849
7691
  type index_operations = operations;
@@ -5853,14 +7695,50 @@ declare namespace index {
5853
7695
  export type { index_$defs as $defs, index_components as components, index_operations as operations, index_paths as paths, index_webhooks as webhooks };
5854
7696
  }
5855
7697
 
7698
+ /**
7699
+ * In-memory session store.
7700
+ *
7701
+ * Session data is lost when the process exits. Use for:
7702
+ * - Development/testing
7703
+ * - Short-lived sessions that don't need persistence
7704
+ * - Environments without filesystem access
7705
+ *
7706
+ * @module
7707
+ */
7708
+
7709
+ /**
7710
+ * In-memory implementation of SessionStore.
7711
+ *
7712
+ * All operations are synchronous but wrapped in promises for interface compatibility.
7713
+ */
7714
+ declare class MemorySessionStore implements SessionStore {
7715
+ private readonly sessions;
7716
+ load(id: SessionId): Promise<SessionState | null>;
7717
+ save(state: SessionState): Promise<void>;
7718
+ delete(id: SessionId): Promise<void>;
7719
+ list(): Promise<SessionId[]>;
7720
+ close(): Promise<void>;
7721
+ /**
7722
+ * Get the number of sessions in the store.
7723
+ * Useful for testing.
7724
+ */
7725
+ get size(): number;
7726
+ }
7727
+ /**
7728
+ * Create a new in-memory session store.
7729
+ */
7730
+ declare function createMemorySessionStore(): MemorySessionStore;
7731
+
5856
7732
  declare class ModelRelay {
5857
7733
  readonly responses: ResponsesClient;
5858
7734
  readonly runs: RunsClient;
5859
7735
  readonly workflows: WorkflowsClient;
7736
+ readonly images: ImagesClient;
5860
7737
  readonly auth: AuthClient;
5861
7738
  readonly customers: CustomersClient;
5862
7739
  readonly tiers: TiersClient;
5863
7740
  readonly models: ModelsClient;
7741
+ readonly sessions: SessionsClient;
5864
7742
  readonly baseUrl: string;
5865
7743
  static fromSecretKey(secretKey: string, options?: Omit<ModelRelayKeyOptions, "key">): ModelRelay;
5866
7744
  static fromPublishableKey(publishableKey: string, options?: Omit<ModelRelayKeyOptions, "key">): ModelRelay;
@@ -5869,4 +7747,4 @@ declare class ModelRelay {
5869
7747
  forCustomer(customerId: string): CustomerScopedModelRelay;
5870
7748
  }
5871
7749
 
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 };
7750
+ 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, 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, type ListSessionsOptions, type ListSessionsResponse, LocalFSToolPack, type LocalFSToolPackOptions, LocalSession, type LocalSessionOptions, type LocalSessionPersistence, 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, 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, PathEscapeError, type PayloadInfoV0, type 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, 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, 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, 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 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 };