@synova-cloud/sdk 2.0.0 → 2.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.cts CHANGED
@@ -48,9 +48,10 @@ interface ISchemaAdapter<TSchema = unknown> {
48
48
  */
49
49
  canHandle(schema: unknown): schema is TSchema;
50
50
  /**
51
- * Convert the schema to JSON Schema format
51
+ * Convert the schema to JSON Schema format.
52
+ * Async to support dynamic imports for bundler compatibility (Next.js, Turbopack, etc.)
52
53
  */
53
- toJsonSchema(schema: TSchema): IJsonSchema;
54
+ toJsonSchema(schema: TSchema): Promise<IJsonSchema>;
54
55
  }
55
56
 
56
57
  /**
@@ -109,6 +110,7 @@ declare class SchemaResolver {
109
110
  static resetAdapters(): void;
110
111
  /**
111
112
  * Resolve a schema input to JSON Schema format.
113
+ * Async to support dynamic imports for bundler compatibility (Next.js, Turbopack, etc.)
112
114
  *
113
115
  * @param schema - Schema from Zod, Yup, Joi, or raw JSON Schema
114
116
  * @returns JSON Schema representation
@@ -118,22 +120,22 @@ declare class SchemaResolver {
118
120
  * ```typescript
119
121
  * // Zod
120
122
  * const zodSchema = z.object({ title: z.string() });
121
- * const jsonSchema = SchemaResolver.resolve(zodSchema);
123
+ * const jsonSchema = await SchemaResolver.resolve(zodSchema);
122
124
  *
123
125
  * // Yup
124
126
  * const yupSchema = yup.object({ title: yup.string().required() });
125
- * const jsonSchema = SchemaResolver.resolve(yupSchema);
127
+ * const jsonSchema = await SchemaResolver.resolve(yupSchema);
126
128
  *
127
129
  * // Joi
128
130
  * const joiSchema = Joi.object({ title: Joi.string() });
129
- * const jsonSchema = SchemaResolver.resolve(joiSchema);
131
+ * const jsonSchema = await SchemaResolver.resolve(joiSchema);
130
132
  *
131
133
  * // Raw JSON Schema (passthrough)
132
134
  * const rawSchema = { type: 'object', properties: { title: { type: 'string' } } };
133
- * const jsonSchema = SchemaResolver.resolve(rawSchema);
135
+ * const jsonSchema = await SchemaResolver.resolve(rawSchema);
134
136
  * ```
135
137
  */
136
- static resolve(schema: TSchemaInput): IJsonSchema;
138
+ static resolve(schema: TSchemaInput): Promise<IJsonSchema>;
137
139
  /**
138
140
  * Check if a schema is supported.
139
141
  *
@@ -350,6 +352,14 @@ interface ISynovaExecuteResponse {
350
352
  /** Span ID (for observability - individual call within trace) */
351
353
  spanId?: string;
352
354
  }
355
+ /**
356
+ * Typed execute response - returned when responseSchema is provided.
357
+ * Contains the typed object along with all metadata (usage, spans, etc.)
358
+ */
359
+ interface ISynovaTypedExecuteResponse<T> extends Omit<ISynovaExecuteResponse, 'object'> {
360
+ /** Typed structured output object */
361
+ object: T;
362
+ }
353
363
  interface ISynovaModelCapabilities {
354
364
  text_generation?: boolean;
355
365
  function_calling?: boolean;
@@ -561,14 +571,15 @@ declare class PromptsResource {
561
571
  *
562
572
  * @example
563
573
  * ```ts
564
- * // With Zod schema
574
+ * // With Zod schema - returns full response with typed object
565
575
  * const schema = z.object({ title: z.string() });
566
576
  * const result = await client.prompts.execute<z.infer<typeof schema>>('prm_abc123', {
567
577
  * provider: 'openai',
568
578
  * model: 'gpt-4o',
569
579
  * responseSchema: schema,
570
580
  * });
571
- * console.log(result.title); // Typed as string
581
+ * console.log(result.object.title); // Typed as string
582
+ * console.log(result.executionUsage); // Token usage available
572
583
  *
573
584
  * // With raw JSON Schema
574
585
  * const result = await client.prompts.execute<{ title: string }>('prm_abc123', {
@@ -576,11 +587,12 @@ declare class PromptsResource {
576
587
  * model: 'gpt-4o',
577
588
  * responseSchema: { type: 'object', properties: { title: { type: 'string' } } },
578
589
  * });
590
+ * console.log(result.object.title); // Typed
579
591
  * ```
580
592
  */
581
593
  execute<T>(promptId: string, options: ISynovaExecuteOptions & {
582
594
  responseSchema: NonNullable<ISynovaExecuteOptions['responseSchema']>;
583
- }): Promise<T>;
595
+ }): Promise<ISynovaTypedExecuteResponse<T>>;
584
596
  /**
585
597
  * Execute a prompt
586
598
  *
@@ -602,7 +614,7 @@ declare class PromptsResource {
602
614
  */
603
615
  executeByTag<T>(promptId: string, tag: string, options: ISynovaExecuteOptions & {
604
616
  responseSchema: NonNullable<ISynovaExecuteOptions['responseSchema']>;
605
- }): Promise<T>;
617
+ }): Promise<ISynovaTypedExecuteResponse<T>>;
606
618
  /**
607
619
  * Execute a prompt by tag
608
620
  */
@@ -612,7 +624,7 @@ declare class PromptsResource {
612
624
  */
613
625
  executeByVersion<T>(promptId: string, version: string, options: ISynovaExecuteOptions & {
614
626
  responseSchema: NonNullable<ISynovaExecuteOptions['responseSchema']>;
615
- }): Promise<T>;
627
+ }): Promise<ISynovaTypedExecuteResponse<T>>;
616
628
  /**
617
629
  * Execute a prompt by version
618
630
  */
@@ -965,7 +977,7 @@ declare class ExecutionSynovaError extends SynovaError {
965
977
  declare class JsonSchemaAdapter implements ISchemaAdapter<IJsonSchema> {
966
978
  private static readonly VALID_JSON_SCHEMA_TYPES;
967
979
  canHandle(schema: unknown): schema is IJsonSchema;
968
- toJsonSchema(schema: IJsonSchema): IJsonSchema;
980
+ toJsonSchema(schema: IJsonSchema): Promise<IJsonSchema>;
969
981
  /**
970
982
  * Recursively transform `nullable: true` to `type: ["...", "null"]`
971
983
  */
@@ -982,14 +994,15 @@ interface IZodSchema {
982
994
  safeParse: (data: unknown) => {
983
995
  success: boolean;
984
996
  };
997
+ toJsonSchema?: () => IJsonSchema;
985
998
  }
986
999
  /**
987
1000
  * Adapter for Zod schemas.
988
- * Uses zod-to-json-schema for conversion.
1001
+ * Supports both Zod v4 (native toJsonSchema) and Zod v3 (via zod-to-json-schema).
989
1002
  */
990
1003
  declare class ZodAdapter implements ISchemaAdapter<IZodSchema> {
991
1004
  canHandle(schema: unknown): schema is IZodSchema;
992
- toJsonSchema(schema: IZodSchema): IJsonSchema;
1005
+ toJsonSchema(schema: IZodSchema): Promise<IJsonSchema>;
993
1006
  }
994
1007
 
995
1008
  /**
@@ -1006,16 +1019,20 @@ interface IYupSchema {
1006
1019
  */
1007
1020
  declare class YupAdapter implements ISchemaAdapter<IYupSchema> {
1008
1021
  canHandle(schema: unknown): schema is IYupSchema;
1009
- toJsonSchema(schema: IYupSchema): IJsonSchema;
1022
+ toJsonSchema(schema: IYupSchema): Promise<IJsonSchema>;
1010
1023
  }
1011
1024
 
1012
1025
  /**
1013
1026
  * Joi schema type definition
1014
1027
  */
1015
1028
  interface IJoiSchema {
1029
+ type: string;
1016
1030
  describe: () => {
1017
1031
  type: string;
1018
1032
  };
1033
+ $_root?: {
1034
+ isSchema?: (schema: unknown) => boolean;
1035
+ };
1019
1036
  }
1020
1037
  /**
1021
1038
  * Adapter for Joi schemas.
@@ -1025,7 +1042,7 @@ interface IJoiSchema {
1025
1042
  */
1026
1043
  declare class JoiAdapter implements ISchemaAdapter<IJoiSchema> {
1027
1044
  canHandle(schema: unknown): schema is IJoiSchema;
1028
- toJsonSchema(schema: IJoiSchema): IJsonSchema;
1045
+ toJsonSchema(schema: IJoiSchema): Promise<IJsonSchema>;
1029
1046
  }
1030
1047
 
1031
- export { ApiSynovaError, AuthSynovaError, ExecutionSynovaError, type IJsonSchema, type ISchemaAdapter, type ISynovaConfig, type ISynovaCreateSpanOptions, type ISynovaEndSpanOptions, type ISynovaExecuteOptions, type ISynovaExecuteResponse, type ISynovaExecutionError, type ISynovaExecutionErrorDetails, type ISynovaExecutionUsage, type ISynovaFileAttachment, type ISynovaFileThumbnails, type ISynovaGetPromptOptions, type ISynovaListModelsOptions, type ISynovaLogger, type ISynovaMessage, type ISynovaModel, type ISynovaModelCapabilities, type ISynovaModelLimits, type ISynovaModelPricing, type ISynovaModelsResponse, type ISynovaPrompt, type ISynovaPromptVariable, type ISynovaProvider, type ISynovaProviderResponse, type ISynovaRetryConfig, type ISynovaSpan, type ISynovaSpanData, type ISynovaToolCall, type ISynovaToolResult, type ISynovaUploadOptions, type ISynovaUploadResponse, type ISynovaUploadedFile, type ISynovaWrapOptions, type ISynovaWrapToolOptions, JoiAdapter, JsonSchemaAdapter, NetworkSynovaError, NotFoundSynovaError, RateLimitSynovaError, SchemaResolver, ServerSynovaError, SynovaCloudSdk, SynovaError, type TJsonSchemaFormat, type TJsonSchemaType, type TSchemaInput, type TSchemaType, type TSynovaMessageRole, type TSynovaModelType, type TSynovaResponseType, type TSynovaRetryStrategy, type TSynovaSpanLevel, type TSynovaSpanStatus, type TSynovaSpanType, type TSynovaUsageType, TimeoutSynovaError, YupAdapter, ZodAdapter };
1048
+ export { ApiSynovaError, AuthSynovaError, ExecutionSynovaError, type IJsonSchema, type ISchemaAdapter, type ISynovaConfig, type ISynovaCreateSpanOptions, type ISynovaEndSpanOptions, type ISynovaExecuteOptions, type ISynovaExecuteResponse, type ISynovaExecutionError, type ISynovaExecutionErrorDetails, type ISynovaExecutionUsage, type ISynovaFileAttachment, type ISynovaFileThumbnails, type ISynovaGetPromptOptions, type ISynovaListModelsOptions, type ISynovaLogger, type ISynovaMessage, type ISynovaModel, type ISynovaModelCapabilities, type ISynovaModelLimits, type ISynovaModelPricing, type ISynovaModelsResponse, type ISynovaPrompt, type ISynovaPromptVariable, type ISynovaProvider, type ISynovaProviderResponse, type ISynovaRetryConfig, type ISynovaSpan, type ISynovaSpanData, type ISynovaToolCall, type ISynovaToolResult, type ISynovaTypedExecuteResponse, type ISynovaUploadOptions, type ISynovaUploadResponse, type ISynovaUploadedFile, type ISynovaWrapOptions, type ISynovaWrapToolOptions, JoiAdapter, JsonSchemaAdapter, NetworkSynovaError, NotFoundSynovaError, RateLimitSynovaError, SchemaResolver, ServerSynovaError, SynovaCloudSdk, SynovaError, type TJsonSchemaFormat, type TJsonSchemaType, type TSchemaInput, type TSchemaType, type TSynovaMessageRole, type TSynovaModelType, type TSynovaResponseType, type TSynovaRetryStrategy, type TSynovaSpanLevel, type TSynovaSpanStatus, type TSynovaSpanType, type TSynovaUsageType, TimeoutSynovaError, YupAdapter, ZodAdapter };
package/dist/index.d.ts CHANGED
@@ -48,9 +48,10 @@ interface ISchemaAdapter<TSchema = unknown> {
48
48
  */
49
49
  canHandle(schema: unknown): schema is TSchema;
50
50
  /**
51
- * Convert the schema to JSON Schema format
51
+ * Convert the schema to JSON Schema format.
52
+ * Async to support dynamic imports for bundler compatibility (Next.js, Turbopack, etc.)
52
53
  */
53
- toJsonSchema(schema: TSchema): IJsonSchema;
54
+ toJsonSchema(schema: TSchema): Promise<IJsonSchema>;
54
55
  }
55
56
 
56
57
  /**
@@ -109,6 +110,7 @@ declare class SchemaResolver {
109
110
  static resetAdapters(): void;
110
111
  /**
111
112
  * Resolve a schema input to JSON Schema format.
113
+ * Async to support dynamic imports for bundler compatibility (Next.js, Turbopack, etc.)
112
114
  *
113
115
  * @param schema - Schema from Zod, Yup, Joi, or raw JSON Schema
114
116
  * @returns JSON Schema representation
@@ -118,22 +120,22 @@ declare class SchemaResolver {
118
120
  * ```typescript
119
121
  * // Zod
120
122
  * const zodSchema = z.object({ title: z.string() });
121
- * const jsonSchema = SchemaResolver.resolve(zodSchema);
123
+ * const jsonSchema = await SchemaResolver.resolve(zodSchema);
122
124
  *
123
125
  * // Yup
124
126
  * const yupSchema = yup.object({ title: yup.string().required() });
125
- * const jsonSchema = SchemaResolver.resolve(yupSchema);
127
+ * const jsonSchema = await SchemaResolver.resolve(yupSchema);
126
128
  *
127
129
  * // Joi
128
130
  * const joiSchema = Joi.object({ title: Joi.string() });
129
- * const jsonSchema = SchemaResolver.resolve(joiSchema);
131
+ * const jsonSchema = await SchemaResolver.resolve(joiSchema);
130
132
  *
131
133
  * // Raw JSON Schema (passthrough)
132
134
  * const rawSchema = { type: 'object', properties: { title: { type: 'string' } } };
133
- * const jsonSchema = SchemaResolver.resolve(rawSchema);
135
+ * const jsonSchema = await SchemaResolver.resolve(rawSchema);
134
136
  * ```
135
137
  */
136
- static resolve(schema: TSchemaInput): IJsonSchema;
138
+ static resolve(schema: TSchemaInput): Promise<IJsonSchema>;
137
139
  /**
138
140
  * Check if a schema is supported.
139
141
  *
@@ -350,6 +352,14 @@ interface ISynovaExecuteResponse {
350
352
  /** Span ID (for observability - individual call within trace) */
351
353
  spanId?: string;
352
354
  }
355
+ /**
356
+ * Typed execute response - returned when responseSchema is provided.
357
+ * Contains the typed object along with all metadata (usage, spans, etc.)
358
+ */
359
+ interface ISynovaTypedExecuteResponse<T> extends Omit<ISynovaExecuteResponse, 'object'> {
360
+ /** Typed structured output object */
361
+ object: T;
362
+ }
353
363
  interface ISynovaModelCapabilities {
354
364
  text_generation?: boolean;
355
365
  function_calling?: boolean;
@@ -561,14 +571,15 @@ declare class PromptsResource {
561
571
  *
562
572
  * @example
563
573
  * ```ts
564
- * // With Zod schema
574
+ * // With Zod schema - returns full response with typed object
565
575
  * const schema = z.object({ title: z.string() });
566
576
  * const result = await client.prompts.execute<z.infer<typeof schema>>('prm_abc123', {
567
577
  * provider: 'openai',
568
578
  * model: 'gpt-4o',
569
579
  * responseSchema: schema,
570
580
  * });
571
- * console.log(result.title); // Typed as string
581
+ * console.log(result.object.title); // Typed as string
582
+ * console.log(result.executionUsage); // Token usage available
572
583
  *
573
584
  * // With raw JSON Schema
574
585
  * const result = await client.prompts.execute<{ title: string }>('prm_abc123', {
@@ -576,11 +587,12 @@ declare class PromptsResource {
576
587
  * model: 'gpt-4o',
577
588
  * responseSchema: { type: 'object', properties: { title: { type: 'string' } } },
578
589
  * });
590
+ * console.log(result.object.title); // Typed
579
591
  * ```
580
592
  */
581
593
  execute<T>(promptId: string, options: ISynovaExecuteOptions & {
582
594
  responseSchema: NonNullable<ISynovaExecuteOptions['responseSchema']>;
583
- }): Promise<T>;
595
+ }): Promise<ISynovaTypedExecuteResponse<T>>;
584
596
  /**
585
597
  * Execute a prompt
586
598
  *
@@ -602,7 +614,7 @@ declare class PromptsResource {
602
614
  */
603
615
  executeByTag<T>(promptId: string, tag: string, options: ISynovaExecuteOptions & {
604
616
  responseSchema: NonNullable<ISynovaExecuteOptions['responseSchema']>;
605
- }): Promise<T>;
617
+ }): Promise<ISynovaTypedExecuteResponse<T>>;
606
618
  /**
607
619
  * Execute a prompt by tag
608
620
  */
@@ -612,7 +624,7 @@ declare class PromptsResource {
612
624
  */
613
625
  executeByVersion<T>(promptId: string, version: string, options: ISynovaExecuteOptions & {
614
626
  responseSchema: NonNullable<ISynovaExecuteOptions['responseSchema']>;
615
- }): Promise<T>;
627
+ }): Promise<ISynovaTypedExecuteResponse<T>>;
616
628
  /**
617
629
  * Execute a prompt by version
618
630
  */
@@ -965,7 +977,7 @@ declare class ExecutionSynovaError extends SynovaError {
965
977
  declare class JsonSchemaAdapter implements ISchemaAdapter<IJsonSchema> {
966
978
  private static readonly VALID_JSON_SCHEMA_TYPES;
967
979
  canHandle(schema: unknown): schema is IJsonSchema;
968
- toJsonSchema(schema: IJsonSchema): IJsonSchema;
980
+ toJsonSchema(schema: IJsonSchema): Promise<IJsonSchema>;
969
981
  /**
970
982
  * Recursively transform `nullable: true` to `type: ["...", "null"]`
971
983
  */
@@ -982,14 +994,15 @@ interface IZodSchema {
982
994
  safeParse: (data: unknown) => {
983
995
  success: boolean;
984
996
  };
997
+ toJsonSchema?: () => IJsonSchema;
985
998
  }
986
999
  /**
987
1000
  * Adapter for Zod schemas.
988
- * Uses zod-to-json-schema for conversion.
1001
+ * Supports both Zod v4 (native toJsonSchema) and Zod v3 (via zod-to-json-schema).
989
1002
  */
990
1003
  declare class ZodAdapter implements ISchemaAdapter<IZodSchema> {
991
1004
  canHandle(schema: unknown): schema is IZodSchema;
992
- toJsonSchema(schema: IZodSchema): IJsonSchema;
1005
+ toJsonSchema(schema: IZodSchema): Promise<IJsonSchema>;
993
1006
  }
994
1007
 
995
1008
  /**
@@ -1006,16 +1019,20 @@ interface IYupSchema {
1006
1019
  */
1007
1020
  declare class YupAdapter implements ISchemaAdapter<IYupSchema> {
1008
1021
  canHandle(schema: unknown): schema is IYupSchema;
1009
- toJsonSchema(schema: IYupSchema): IJsonSchema;
1022
+ toJsonSchema(schema: IYupSchema): Promise<IJsonSchema>;
1010
1023
  }
1011
1024
 
1012
1025
  /**
1013
1026
  * Joi schema type definition
1014
1027
  */
1015
1028
  interface IJoiSchema {
1029
+ type: string;
1016
1030
  describe: () => {
1017
1031
  type: string;
1018
1032
  };
1033
+ $_root?: {
1034
+ isSchema?: (schema: unknown) => boolean;
1035
+ };
1019
1036
  }
1020
1037
  /**
1021
1038
  * Adapter for Joi schemas.
@@ -1025,7 +1042,7 @@ interface IJoiSchema {
1025
1042
  */
1026
1043
  declare class JoiAdapter implements ISchemaAdapter<IJoiSchema> {
1027
1044
  canHandle(schema: unknown): schema is IJoiSchema;
1028
- toJsonSchema(schema: IJoiSchema): IJsonSchema;
1045
+ toJsonSchema(schema: IJoiSchema): Promise<IJsonSchema>;
1029
1046
  }
1030
1047
 
1031
- export { ApiSynovaError, AuthSynovaError, ExecutionSynovaError, type IJsonSchema, type ISchemaAdapter, type ISynovaConfig, type ISynovaCreateSpanOptions, type ISynovaEndSpanOptions, type ISynovaExecuteOptions, type ISynovaExecuteResponse, type ISynovaExecutionError, type ISynovaExecutionErrorDetails, type ISynovaExecutionUsage, type ISynovaFileAttachment, type ISynovaFileThumbnails, type ISynovaGetPromptOptions, type ISynovaListModelsOptions, type ISynovaLogger, type ISynovaMessage, type ISynovaModel, type ISynovaModelCapabilities, type ISynovaModelLimits, type ISynovaModelPricing, type ISynovaModelsResponse, type ISynovaPrompt, type ISynovaPromptVariable, type ISynovaProvider, type ISynovaProviderResponse, type ISynovaRetryConfig, type ISynovaSpan, type ISynovaSpanData, type ISynovaToolCall, type ISynovaToolResult, type ISynovaUploadOptions, type ISynovaUploadResponse, type ISynovaUploadedFile, type ISynovaWrapOptions, type ISynovaWrapToolOptions, JoiAdapter, JsonSchemaAdapter, NetworkSynovaError, NotFoundSynovaError, RateLimitSynovaError, SchemaResolver, ServerSynovaError, SynovaCloudSdk, SynovaError, type TJsonSchemaFormat, type TJsonSchemaType, type TSchemaInput, type TSchemaType, type TSynovaMessageRole, type TSynovaModelType, type TSynovaResponseType, type TSynovaRetryStrategy, type TSynovaSpanLevel, type TSynovaSpanStatus, type TSynovaSpanType, type TSynovaUsageType, TimeoutSynovaError, YupAdapter, ZodAdapter };
1048
+ export { ApiSynovaError, AuthSynovaError, ExecutionSynovaError, type IJsonSchema, type ISchemaAdapter, type ISynovaConfig, type ISynovaCreateSpanOptions, type ISynovaEndSpanOptions, type ISynovaExecuteOptions, type ISynovaExecuteResponse, type ISynovaExecutionError, type ISynovaExecutionErrorDetails, type ISynovaExecutionUsage, type ISynovaFileAttachment, type ISynovaFileThumbnails, type ISynovaGetPromptOptions, type ISynovaListModelsOptions, type ISynovaLogger, type ISynovaMessage, type ISynovaModel, type ISynovaModelCapabilities, type ISynovaModelLimits, type ISynovaModelPricing, type ISynovaModelsResponse, type ISynovaPrompt, type ISynovaPromptVariable, type ISynovaProvider, type ISynovaProviderResponse, type ISynovaRetryConfig, type ISynovaSpan, type ISynovaSpanData, type ISynovaToolCall, type ISynovaToolResult, type ISynovaTypedExecuteResponse, type ISynovaUploadOptions, type ISynovaUploadResponse, type ISynovaUploadedFile, type ISynovaWrapOptions, type ISynovaWrapToolOptions, JoiAdapter, JsonSchemaAdapter, NetworkSynovaError, NotFoundSynovaError, RateLimitSynovaError, SchemaResolver, ServerSynovaError, SynovaCloudSdk, SynovaError, type TJsonSchemaFormat, type TJsonSchemaType, type TSchemaInput, type TSchemaType, type TSynovaMessageRole, type TSynovaModelType, type TSynovaResponseType, type TSynovaRetryStrategy, type TSynovaSpanLevel, type TSynovaSpanStatus, type TSynovaSpanType, type TSynovaUsageType, TimeoutSynovaError, YupAdapter, ZodAdapter };
package/dist/index.js CHANGED
@@ -1,10 +1,3 @@
1
- var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
2
- get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
3
- }) : x)(function(x) {
4
- if (typeof require !== "undefined") return require.apply(this, arguments);
5
- throw Error('Dynamic require of "' + x + '" is not supported');
6
- });
7
-
8
1
  // src/errors/index.ts
9
2
  var SynovaError = class extends Error {
10
3
  constructor(message) {
@@ -94,7 +87,7 @@ var ExecutionSynovaError = class extends SynovaError {
94
87
  };
95
88
 
96
89
  // src/version.ts
97
- var SDK_VERSION = "2.0.0" ;
90
+ var SDK_VERSION = "2.0.2" ;
98
91
 
99
92
  // src/utils/http.ts
100
93
  var HttpClient = class {
@@ -312,16 +305,21 @@ var ZodAdapter = class {
312
305
  const s = schema;
313
306
  return typeof s._def === "object" && s._def !== null && typeof s._def.typeName === "string" && s._def.typeName.startsWith("Zod") && typeof s.safeParse === "function";
314
307
  }
315
- toJsonSchema(schema) {
308
+ async toJsonSchema(schema) {
309
+ if (typeof schema.toJsonSchema === "function") {
310
+ const result = { ...schema.toJsonSchema() };
311
+ delete result.$schema;
312
+ return result;
313
+ }
316
314
  try {
317
- const { zodToJsonSchema } = __require("zod-to-json-schema");
315
+ const { zodToJsonSchema } = await import('zod-to-json-schema');
318
316
  const result = { ...zodToJsonSchema(schema, { $refStrategy: "none" }) };
319
317
  delete result.$schema;
320
318
  return result;
321
319
  } catch (error) {
322
- if (error.code === "MODULE_NOT_FOUND") {
320
+ if (error.code === "ERR_MODULE_NOT_FOUND") {
323
321
  throw new Error(
324
- "zod-to-json-schema is required to convert Zod schemas. Install it with: npm install zod-to-json-schema"
322
+ "zod-to-json-schema is required for Zod v3 schemas. Install it with: npm install zod-to-json-schema (or upgrade to Zod v4)"
325
323
  );
326
324
  }
327
325
  throw new Error(`Failed to convert Zod schema: ${error.message}`);
@@ -335,12 +333,12 @@ var YupAdapter = class {
335
333
  if (typeof schema !== "object" || schema === null) return false;
336
334
  return schema.__isYupSchema__ === true;
337
335
  }
338
- toJsonSchema(schema) {
336
+ async toJsonSchema(schema) {
339
337
  try {
340
- const { convertSchema } = __require("@sodaru/yup-to-json-schema");
338
+ const { convertSchema } = await import('@sodaru/yup-to-json-schema');
341
339
  return convertSchema(schema);
342
340
  } catch (error) {
343
- if (error.code === "MODULE_NOT_FOUND") {
341
+ if (error.code === "ERR_MODULE_NOT_FOUND") {
344
342
  throw new Error(
345
343
  "@sodaru/yup-to-json-schema is required to convert Yup schemas. Install it with: npm install @sodaru/yup-to-json-schema"
346
344
  );
@@ -354,19 +352,26 @@ var YupAdapter = class {
354
352
  var JoiAdapter = class {
355
353
  canHandle(schema) {
356
354
  if (typeof schema !== "object" || schema === null) return false;
355
+ const s = schema;
356
+ if (typeof s.describe !== "function" || typeof s.type !== "string") {
357
+ return false;
358
+ }
359
+ if (s.$_root && typeof s.$_root.isSchema === "function") {
360
+ return s.$_root.isSchema(schema);
361
+ }
357
362
  try {
358
- const { isSchema } = __require("joi");
359
- return isSchema(schema);
363
+ const description = s.describe();
364
+ return typeof description === "object" && description !== null && "type" in description;
360
365
  } catch {
361
366
  return false;
362
367
  }
363
368
  }
364
- toJsonSchema(schema) {
369
+ async toJsonSchema(schema) {
365
370
  try {
366
- const joiToJson = __require("joi-to-json");
371
+ const joiToJson = (await import('joi-to-json')).default;
367
372
  return joiToJson(schema);
368
373
  } catch (error) {
369
- if (error.code === "MODULE_NOT_FOUND") {
374
+ if (error.code === "ERR_MODULE_NOT_FOUND") {
370
375
  throw new Error(
371
376
  "joi-to-json is required to convert Joi schemas. Install it with: npm install joi-to-json"
372
377
  );
@@ -413,7 +418,7 @@ var JsonSchemaAdapter = class _JsonSchemaAdapter {
413
418
  if ("enum" in obj && Array.isArray(obj.enum)) return true;
414
419
  return false;
415
420
  }
416
- toJsonSchema(schema) {
421
+ async toJsonSchema(schema) {
417
422
  return this.transformNullable(schema);
418
423
  }
419
424
  /**
@@ -497,6 +502,7 @@ var SchemaResolver = class {
497
502
  }
498
503
  /**
499
504
  * Resolve a schema input to JSON Schema format.
505
+ * Async to support dynamic imports for bundler compatibility (Next.js, Turbopack, etc.)
500
506
  *
501
507
  * @param schema - Schema from Zod, Yup, Joi, or raw JSON Schema
502
508
  * @returns JSON Schema representation
@@ -506,22 +512,22 @@ var SchemaResolver = class {
506
512
  * ```typescript
507
513
  * // Zod
508
514
  * const zodSchema = z.object({ title: z.string() });
509
- * const jsonSchema = SchemaResolver.resolve(zodSchema);
515
+ * const jsonSchema = await SchemaResolver.resolve(zodSchema);
510
516
  *
511
517
  * // Yup
512
518
  * const yupSchema = yup.object({ title: yup.string().required() });
513
- * const jsonSchema = SchemaResolver.resolve(yupSchema);
519
+ * const jsonSchema = await SchemaResolver.resolve(yupSchema);
514
520
  *
515
521
  * // Joi
516
522
  * const joiSchema = Joi.object({ title: Joi.string() });
517
- * const jsonSchema = SchemaResolver.resolve(joiSchema);
523
+ * const jsonSchema = await SchemaResolver.resolve(joiSchema);
518
524
  *
519
525
  * // Raw JSON Schema (passthrough)
520
526
  * const rawSchema = { type: 'object', properties: { title: { type: 'string' } } };
521
- * const jsonSchema = SchemaResolver.resolve(rawSchema);
527
+ * const jsonSchema = await SchemaResolver.resolve(rawSchema);
522
528
  * ```
523
529
  */
524
- static resolve(schema) {
530
+ static async resolve(schema) {
525
531
  for (const adapter of this.adapters) {
526
532
  if (adapter.canHandle(schema)) {
527
533
  return adapter.toJsonSchema(schema);
@@ -606,7 +612,7 @@ var PromptsResource = class {
606
612
  if (options.parameters !== void 0) body.parameters = options.parameters;
607
613
  if (options.sessionId !== void 0) body.sessionId = options.sessionId;
608
614
  if (options.responseSchema !== void 0) {
609
- body.responseSchema = SchemaResolver.resolve(options.responseSchema);
615
+ body.responseSchema = await SchemaResolver.resolve(options.responseSchema);
610
616
  }
611
617
  const response = await this.http.request({
612
618
  method: "POST",
@@ -620,7 +626,7 @@ var PromptsResource = class {
620
626
  if (response.object === void 0) {
621
627
  throw new Error("Expected structured response but received undefined");
622
628
  }
623
- return response.object;
629
+ return response;
624
630
  }
625
631
  return response;
626
632
  }