codemie-sdk 0.1.228 → 0.1.230

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
@@ -755,6 +755,8 @@ declare const AssistantChatParamsSchema: z.ZodReadonly<z.ZodObject<{
755
755
  }>, "many">, z.ZodString]>;
756
756
  history_index: z.ZodOptional<z.ZodNumber>;
757
757
  stream: z.ZodOptional<z.ZodBoolean>;
758
+ propagate_headers: z.ZodOptional<z.ZodBoolean>;
759
+ custom_metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
758
760
  top_k: z.ZodOptional<z.ZodNumber>;
759
761
  system_prompt: z.ZodOptional<z.ZodString>;
760
762
  background_task: z.ZodOptional<z.ZodBoolean>;
@@ -775,6 +777,8 @@ declare const AssistantChatParamsSchema: z.ZodReadonly<z.ZodObject<{
775
777
  llm_model?: string | undefined;
776
778
  history_index?: number | undefined;
777
779
  stream?: boolean | undefined;
780
+ propagate_headers?: boolean | undefined;
781
+ custom_metadata?: Record<string, unknown> | undefined;
778
782
  top_k?: number | undefined;
779
783
  background_task?: boolean | undefined;
780
784
  metadata?: Record<string, unknown> | undefined;
@@ -794,6 +798,8 @@ declare const AssistantChatParamsSchema: z.ZodReadonly<z.ZodObject<{
794
798
  llm_model?: string | undefined;
795
799
  history_index?: number | undefined;
796
800
  stream?: boolean | undefined;
801
+ propagate_headers?: boolean | undefined;
802
+ custom_metadata?: Record<string, unknown> | undefined;
797
803
  top_k?: number | undefined;
798
804
  background_task?: boolean | undefined;
799
805
  metadata?: Record<string, unknown> | undefined;
@@ -864,7 +870,11 @@ declare class AssistantService {
864
870
  /**
865
871
  * Send a chat request to an assistant.
866
872
  */
867
- chat(assistantId: string, _params: AssistantChatParams): Promise<BaseModelResponse>;
873
+ chat(assistantId: string, _params: AssistantChatParams, headers?: Record<string, string>): Promise<BaseModelResponse>;
874
+ /**
875
+ * Send a chat request to an assistant by slug.
876
+ */
877
+ chatBySlug(assistantSlug: string, _params: AssistantChatParams, headers?: Record<string, string>): Promise<BaseModelResponse>;
868
878
  /**
869
879
  * Compare two assistant versions.
870
880
  */
@@ -2043,11 +2053,17 @@ type WorkflowExecutionListParams = Partial<z.infer<typeof WorkflowExecutionListP
2043
2053
  * Workflow execution create parameters schema
2044
2054
  */
2045
2055
  declare const WorkflowExecutionCreateParamsSchema: z.ZodReadonly<z.ZodObject<{
2046
- user_input: z.ZodDefault<z.ZodString>;
2056
+ user_input: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodRecord<z.ZodString, z.ZodUnknown>, z.ZodArray<z.ZodUnknown, "many">, z.ZodNumber, z.ZodBoolean]>>;
2057
+ file_name: z.ZodOptional<z.ZodString>;
2058
+ propagate_headers: z.ZodOptional<z.ZodBoolean>;
2047
2059
  }, "strip", z.ZodTypeAny, {
2048
- user_input: string;
2060
+ propagate_headers?: boolean | undefined;
2061
+ user_input?: string | number | boolean | unknown[] | Record<string, unknown> | undefined;
2062
+ file_name?: string | undefined;
2049
2063
  }, {
2050
- user_input?: string | undefined;
2064
+ propagate_headers?: boolean | undefined;
2065
+ user_input?: string | number | boolean | unknown[] | Record<string, unknown> | undefined;
2066
+ file_name?: string | undefined;
2051
2067
  }>>;
2052
2068
  type WorkflowExecutionCreateParams = z.infer<typeof WorkflowExecutionCreateParamsSchema>;
2053
2069
  /**
@@ -2069,10 +2085,14 @@ declare class ApiRequestHandler {
2069
2085
  private client;
2070
2086
  constructor(apiDomain: string, token: string, verifySSL?: boolean);
2071
2087
  private request;
2072
- get<T>(path: string, params?: Record<string, unknown>, config?: Record<string, unknown>): Promise<T>;
2073
- post<T>(path: string, data?: unknown, config?: Record<string, unknown>): Promise<T>;
2088
+ /**
2089
+ * Merge extra headers into the request (used for X-* propagation)
2090
+ */
2091
+ private withHeaders;
2092
+ get<T>(path: string, params?: Record<string, unknown>, config?: Record<string, unknown>, extraHeaders?: Record<string, string>): Promise<T>;
2093
+ post<T>(path: string, data?: unknown, config?: Record<string, unknown>, extraHeaders?: Record<string, string>): Promise<T>;
2094
+ put<T>(path: string, data?: unknown, config?: Record<string, unknown>, extraHeaders?: Record<string, string>): Promise<T>;
2074
2095
  postMultipart<T>(url: string, formData: FormData, params?: Record<string, unknown>): Promise<T>;
2075
- put<T>(path: string, data?: unknown, config?: Record<string, unknown>): Promise<T>;
2076
2096
  delete<T>(path: string, config?: Record<string, unknown>): Promise<T>;
2077
2097
  stream(path: string, data?: unknown, config?: Record<string, unknown>): Promise<AxiosResponse>;
2078
2098
  private processFailedResponse;
@@ -2104,7 +2124,7 @@ declare class WorkflowExecutionService {
2104
2124
  /**
2105
2125
  * Create a new workflow execution.
2106
2126
  */
2107
- create(userInput?: string): Promise<AnyJson>;
2127
+ create(userInput?: string | Record<string, unknown> | unknown[] | number | boolean, fileName?: string, propagateHeaders?: boolean, headers?: Record<string, string>): Promise<AnyJson>;
2108
2128
  /**
2109
2129
  * Get workflow execution by ID.
2110
2130
  */
@@ -2124,7 +2144,7 @@ declare class WorkflowExecutionService {
2124
2144
  /**
2125
2145
  * Resume an interrupted workflow execution.
2126
2146
  */
2127
- resume(executionId: string): Promise<AnyJson>;
2147
+ resume(executionId: string, propagateHeaders?: boolean, headers?: Record<string, string>): Promise<AnyJson>;
2128
2148
  }
2129
2149
 
2130
2150
  declare class WorkflowService {
@@ -2157,7 +2177,7 @@ declare class WorkflowService {
2157
2177
  /**
2158
2178
  * Run a workflow by ID.
2159
2179
  */
2160
- run(workflowId: string, userInput?: string): Promise<AnyJson>;
2180
+ run(workflowId: string, userInput?: string | Record<string, unknown> | unknown[] | number | boolean, fileName?: string, propagateHeaders?: boolean, headers?: Record<string, string>): Promise<AnyJson>;
2161
2181
  /**
2162
2182
  * Get workflow execution service for the specified workflow.
2163
2183
  */
package/dist/index.d.ts CHANGED
@@ -755,6 +755,8 @@ declare const AssistantChatParamsSchema: z.ZodReadonly<z.ZodObject<{
755
755
  }>, "many">, z.ZodString]>;
756
756
  history_index: z.ZodOptional<z.ZodNumber>;
757
757
  stream: z.ZodOptional<z.ZodBoolean>;
758
+ propagate_headers: z.ZodOptional<z.ZodBoolean>;
759
+ custom_metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
758
760
  top_k: z.ZodOptional<z.ZodNumber>;
759
761
  system_prompt: z.ZodOptional<z.ZodString>;
760
762
  background_task: z.ZodOptional<z.ZodBoolean>;
@@ -775,6 +777,8 @@ declare const AssistantChatParamsSchema: z.ZodReadonly<z.ZodObject<{
775
777
  llm_model?: string | undefined;
776
778
  history_index?: number | undefined;
777
779
  stream?: boolean | undefined;
780
+ propagate_headers?: boolean | undefined;
781
+ custom_metadata?: Record<string, unknown> | undefined;
778
782
  top_k?: number | undefined;
779
783
  background_task?: boolean | undefined;
780
784
  metadata?: Record<string, unknown> | undefined;
@@ -794,6 +798,8 @@ declare const AssistantChatParamsSchema: z.ZodReadonly<z.ZodObject<{
794
798
  llm_model?: string | undefined;
795
799
  history_index?: number | undefined;
796
800
  stream?: boolean | undefined;
801
+ propagate_headers?: boolean | undefined;
802
+ custom_metadata?: Record<string, unknown> | undefined;
797
803
  top_k?: number | undefined;
798
804
  background_task?: boolean | undefined;
799
805
  metadata?: Record<string, unknown> | undefined;
@@ -864,7 +870,11 @@ declare class AssistantService {
864
870
  /**
865
871
  * Send a chat request to an assistant.
866
872
  */
867
- chat(assistantId: string, _params: AssistantChatParams): Promise<BaseModelResponse>;
873
+ chat(assistantId: string, _params: AssistantChatParams, headers?: Record<string, string>): Promise<BaseModelResponse>;
874
+ /**
875
+ * Send a chat request to an assistant by slug.
876
+ */
877
+ chatBySlug(assistantSlug: string, _params: AssistantChatParams, headers?: Record<string, string>): Promise<BaseModelResponse>;
868
878
  /**
869
879
  * Compare two assistant versions.
870
880
  */
@@ -2043,11 +2053,17 @@ type WorkflowExecutionListParams = Partial<z.infer<typeof WorkflowExecutionListP
2043
2053
  * Workflow execution create parameters schema
2044
2054
  */
2045
2055
  declare const WorkflowExecutionCreateParamsSchema: z.ZodReadonly<z.ZodObject<{
2046
- user_input: z.ZodDefault<z.ZodString>;
2056
+ user_input: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodRecord<z.ZodString, z.ZodUnknown>, z.ZodArray<z.ZodUnknown, "many">, z.ZodNumber, z.ZodBoolean]>>;
2057
+ file_name: z.ZodOptional<z.ZodString>;
2058
+ propagate_headers: z.ZodOptional<z.ZodBoolean>;
2047
2059
  }, "strip", z.ZodTypeAny, {
2048
- user_input: string;
2060
+ propagate_headers?: boolean | undefined;
2061
+ user_input?: string | number | boolean | unknown[] | Record<string, unknown> | undefined;
2062
+ file_name?: string | undefined;
2049
2063
  }, {
2050
- user_input?: string | undefined;
2064
+ propagate_headers?: boolean | undefined;
2065
+ user_input?: string | number | boolean | unknown[] | Record<string, unknown> | undefined;
2066
+ file_name?: string | undefined;
2051
2067
  }>>;
2052
2068
  type WorkflowExecutionCreateParams = z.infer<typeof WorkflowExecutionCreateParamsSchema>;
2053
2069
  /**
@@ -2069,10 +2085,14 @@ declare class ApiRequestHandler {
2069
2085
  private client;
2070
2086
  constructor(apiDomain: string, token: string, verifySSL?: boolean);
2071
2087
  private request;
2072
- get<T>(path: string, params?: Record<string, unknown>, config?: Record<string, unknown>): Promise<T>;
2073
- post<T>(path: string, data?: unknown, config?: Record<string, unknown>): Promise<T>;
2088
+ /**
2089
+ * Merge extra headers into the request (used for X-* propagation)
2090
+ */
2091
+ private withHeaders;
2092
+ get<T>(path: string, params?: Record<string, unknown>, config?: Record<string, unknown>, extraHeaders?: Record<string, string>): Promise<T>;
2093
+ post<T>(path: string, data?: unknown, config?: Record<string, unknown>, extraHeaders?: Record<string, string>): Promise<T>;
2094
+ put<T>(path: string, data?: unknown, config?: Record<string, unknown>, extraHeaders?: Record<string, string>): Promise<T>;
2074
2095
  postMultipart<T>(url: string, formData: FormData, params?: Record<string, unknown>): Promise<T>;
2075
- put<T>(path: string, data?: unknown, config?: Record<string, unknown>): Promise<T>;
2076
2096
  delete<T>(path: string, config?: Record<string, unknown>): Promise<T>;
2077
2097
  stream(path: string, data?: unknown, config?: Record<string, unknown>): Promise<AxiosResponse>;
2078
2098
  private processFailedResponse;
@@ -2104,7 +2124,7 @@ declare class WorkflowExecutionService {
2104
2124
  /**
2105
2125
  * Create a new workflow execution.
2106
2126
  */
2107
- create(userInput?: string): Promise<AnyJson>;
2127
+ create(userInput?: string | Record<string, unknown> | unknown[] | number | boolean, fileName?: string, propagateHeaders?: boolean, headers?: Record<string, string>): Promise<AnyJson>;
2108
2128
  /**
2109
2129
  * Get workflow execution by ID.
2110
2130
  */
@@ -2124,7 +2144,7 @@ declare class WorkflowExecutionService {
2124
2144
  /**
2125
2145
  * Resume an interrupted workflow execution.
2126
2146
  */
2127
- resume(executionId: string): Promise<AnyJson>;
2147
+ resume(executionId: string, propagateHeaders?: boolean, headers?: Record<string, string>): Promise<AnyJson>;
2128
2148
  }
2129
2149
 
2130
2150
  declare class WorkflowService {
@@ -2157,7 +2177,7 @@ declare class WorkflowService {
2157
2177
  /**
2158
2178
  * Run a workflow by ID.
2159
2179
  */
2160
- run(workflowId: string, userInput?: string): Promise<AnyJson>;
2180
+ run(workflowId: string, userInput?: string | Record<string, unknown> | unknown[] | number | boolean, fileName?: string, propagateHeaders?: boolean, headers?: Record<string, string>): Promise<AnyJson>;
2161
2181
  /**
2162
2182
  * Get workflow execution service for the specified workflow.
2163
2183
  */
package/dist/index.js CHANGED
@@ -159,6 +159,8 @@ var AssistantChatParamsSchema = z.object({
159
159
  ]),
160
160
  history_index: z.number().optional(),
161
161
  stream: z.boolean().optional(),
162
+ propagate_headers: z.boolean().optional(),
163
+ custom_metadata: z.record(z.unknown()).optional(),
162
164
  top_k: z.number().optional(),
163
165
  system_prompt: z.string().optional(),
164
166
  background_task: z.boolean().optional(),
@@ -229,11 +231,22 @@ var ApiRequestHandler = class {
229
231
  });
230
232
  return response.data;
231
233
  }
232
- async get(path, params, config = {}) {
233
- return this.request("get", path, { ...config, params });
234
+ /**
235
+ * Merge extra headers into the request (used for X-* propagation)
236
+ */
237
+ withHeaders(config = {}, extraHeaders) {
238
+ if (!extraHeaders || Object.keys(extraHeaders).length === 0) return config;
239
+ const headers = config.headers ?? {};
240
+ return { ...config, headers: { ...headers, ...extraHeaders } };
241
+ }
242
+ async get(path, params, config = {}, extraHeaders) {
243
+ return this.request("get", path, this.withHeaders({ ...config, params }, extraHeaders));
244
+ }
245
+ async post(path, data, config = {}, extraHeaders) {
246
+ return this.request("post", path, this.withHeaders({ ...config, data }, extraHeaders));
234
247
  }
235
- async post(path, data, config = {}) {
236
- return this.request("post", path, { ...config, data });
248
+ async put(path, data, config = {}, extraHeaders) {
249
+ return this.request("put", path, this.withHeaders({ ...config, data }, extraHeaders));
237
250
  }
238
251
  async postMultipart(url, formData, params) {
239
252
  const response = await this.client.post(url, formData, {
@@ -244,9 +257,6 @@ var ApiRequestHandler = class {
244
257
  });
245
258
  return response.data;
246
259
  }
247
- async put(path, data, config = {}) {
248
- return this.request("put", path, { ...config, data });
249
- }
250
260
  async delete(path, config = {}) {
251
261
  return this.request("delete", path, config);
252
262
  }
@@ -379,7 +389,7 @@ var AssistantService = class {
379
389
  /**
380
390
  * Send a chat request to an assistant.
381
391
  */
382
- async chat(assistantId, _params) {
392
+ async chat(assistantId, _params, headers) {
383
393
  let zodSchema = void 0;
384
394
  let params = { ..._params };
385
395
  if (params.output_schema && params.output_schema instanceof z2.ZodType) {
@@ -394,7 +404,33 @@ var AssistantService = class {
394
404
  params,
395
405
  {
396
406
  responseType: params.stream ? "stream" : void 0
397
- }
407
+ },
408
+ headers
409
+ );
410
+ const mapped = AssistantMapper.mapBaseModelApiResponse(response);
411
+ if (!params.stream && zodSchema && mapped.generated) {
412
+ mapped.generated = zodSchema.parse(mapped.generated);
413
+ }
414
+ return mapped;
415
+ }
416
+ /**
417
+ * Send a chat request to an assistant by slug.
418
+ */
419
+ async chatBySlug(assistantSlug, _params, headers) {
420
+ let zodSchema = void 0;
421
+ let params = { ..._params };
422
+ if (params.output_schema && params.output_schema instanceof z2.ZodType) {
423
+ zodSchema = params.output_schema;
424
+ params.output_schema = zodToJsonSchema(zodSchema, { definitions: {} });
425
+ }
426
+ params = AssistantChatParamsSchema.parse(params);
427
+ const response = await this.api.post(
428
+ `/v1/assistants/slug/${assistantSlug}/model`,
429
+ params,
430
+ {
431
+ responseType: params.stream ? "stream" : void 0
432
+ },
433
+ headers
398
434
  );
399
435
  const mapped = AssistantMapper.mapBaseModelApiResponse(response);
400
436
  if (!params.stream && zodSchema && mapped.generated) {
@@ -1091,7 +1127,9 @@ var WorkflowExecutionListParamsSchema = z5.object({
1091
1127
  per_page: z5.number().default(10)
1092
1128
  }).readonly();
1093
1129
  var WorkflowExecutionCreateParamsSchema = z5.object({
1094
- user_input: z5.string().default("")
1130
+ user_input: z5.union([z5.string(), z5.record(z5.unknown()), z5.array(z5.unknown()), z5.number(), z5.boolean()]).optional(),
1131
+ file_name: z5.string().optional(),
1132
+ propagate_headers: z5.boolean().optional()
1095
1133
  }).readonly();
1096
1134
  var WorkflowExecutionStateListParamsSchema = z5.object({
1097
1135
  page: z5.number().default(0),
@@ -1154,9 +1192,13 @@ var WorkflowExecutionService = class {
1154
1192
  /**
1155
1193
  * Create a new workflow execution.
1156
1194
  */
1157
- async create(userInput = "") {
1158
- const params = WorkflowExecutionCreateParamsSchema.parse({ user_input: userInput });
1159
- return this.api.post(`/v1/workflows/${this.workflowId}/executions`, params);
1195
+ async create(userInput, fileName, propagateHeaders, headers) {
1196
+ const params = WorkflowExecutionCreateParamsSchema.parse({
1197
+ user_input: userInput,
1198
+ file_name: fileName,
1199
+ propagate_headers: propagateHeaders
1200
+ });
1201
+ return this.api.post(`/v1/workflows/${this.workflowId}/executions`, params, {}, headers);
1160
1202
  }
1161
1203
  /**
1162
1204
  * Get workflow execution by ID.
@@ -1188,8 +1230,9 @@ var WorkflowExecutionService = class {
1188
1230
  /**
1189
1231
  * Resume an interrupted workflow execution.
1190
1232
  */
1191
- async resume(executionId) {
1192
- return this.api.put(`/v1/workflows/${this.workflowId}/executions/${executionId}/resume`);
1233
+ async resume(executionId, propagateHeaders, headers) {
1234
+ const config = { params: { propagate_headers: propagateHeaders } };
1235
+ return this.api.put(`/v1/workflows/${this.workflowId}/executions/${executionId}/resume`, {}, config, headers);
1193
1236
  }
1194
1237
  };
1195
1238
 
@@ -1252,8 +1295,8 @@ var WorkflowService = class {
1252
1295
  /**
1253
1296
  * Run a workflow by ID.
1254
1297
  */
1255
- async run(workflowId, userInput = "") {
1256
- return this.executions(workflowId).create(userInput);
1298
+ async run(workflowId, userInput, fileName, propagateHeaders, headers) {
1299
+ return this.executions(workflowId).create(userInput, fileName, propagateHeaders, headers);
1257
1300
  }
1258
1301
  /**
1259
1302
  * Get workflow execution service for the specified workflow.