codemie-sdk 0.1.227 → 0.1.228

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/README.md CHANGED
@@ -1079,5 +1079,49 @@ Then run the tests:
1079
1079
  npm run test:e2e
1080
1080
  ```
1081
1081
 
1082
+ ### Assistant Versioning via SDK
1083
+
1084
+ The Node.js SDK exposes assistant versioning capabilities delivered in EPMCDME-8285.
1085
+
1086
+ - List versions
1087
+ ```ts
1088
+ const versions = await client.assistants.listVersions("assistant-id", { page: 0, per_page: 20 });
1089
+ console.log(versions.map(v => v.version_number));
1090
+ ```
1091
+
1092
+ - Get specific version
1093
+ ```ts
1094
+ const version = await client.assistants.getVersion("assistant-id", 2);
1095
+ console.log(version.system_prompt);
1096
+ ```
1097
+
1098
+ - Compare two versions
1099
+ ```ts
1100
+ const diff = await client.assistants.compareVersions("assistant-id", 1, 3);
1101
+ console.log(diff.summary);
1102
+ ```
1103
+
1104
+ - Rollback to a version
1105
+ ```ts
1106
+ const resp = await client.assistants.rollbackToVersion("assistant-id", 2);
1107
+ console.log(resp);
1108
+ ```
1109
+
1110
+ - Chat with a specific version
1111
+ ```ts
1112
+ import { z } from "zod";
1113
+
1114
+ const ResponseFormat = z.object({ answer: z.string(), followup_question: z.string() });
1115
+ const params = { text: "Hi", stream: false, output_schema: ResponseFormat };
1116
+
1117
+ const resp = await client.assistants.chatWithVersion("assistant-id", 2, params);
1118
+ console.log(resp.generated);
1119
+ ```
1120
+
1121
+ Quick CLI example
1122
+ ```bash
1123
+ npx ts-node codemie-sdk/sdk/codemie-nodejs/examples/assistant_versions.ts <assistant_id> [version_number]
1124
+ ```
1125
+
1082
1126
  ## Support
1083
1127
  For providing credentials please contact AI/Run CodeMie Team: Vadym_Vlasenko@epam.com or Nikita_Levyankov@epam.com
package/dist/index.cjs CHANGED
@@ -35,6 +35,7 @@ __export(index_exports, {
35
35
  AssistantCreateParamsSchema: () => AssistantCreateParamsSchema,
36
36
  AssistantListParamsSchema: () => AssistantListParamsSchema,
37
37
  AssistantUpdateParamsSchema: () => AssistantUpdateParamsSchema,
38
+ AssistantVersionsListParamsSchema: () => AssistantVersionsListParamsSchema,
38
39
  BackgroundTaskStatus: () => BackgroundTaskStatus,
39
40
  ChatRole: () => ChatRole,
40
41
  CodeDataSourceType: () => CodeDataSourceType,
@@ -230,11 +231,16 @@ var AssistantChatParamsSchema = import_zod.z.object({
230
231
  background_task: import_zod.z.boolean().optional(),
231
232
  metadata: import_zod.z.record(import_zod.z.unknown()).optional(),
232
233
  mcp_server_single_usage: import_zod.z.boolean().optional(),
234
+ version: import_zod.z.number().optional(),
233
235
  output_schema: import_zod.z.union([
234
236
  import_zod.z.custom((val) => val instanceof import_zod.z.ZodType),
235
237
  import_zod.z.record(import_zod.z.unknown())
236
238
  ]).optional()
237
239
  }).readonly();
240
+ var AssistantVersionsListParamsSchema = import_zod.z.object({
241
+ page: import_zod.z.number().optional(),
242
+ per_page: import_zod.z.number().optional()
243
+ }).readonly();
238
244
 
239
245
  // src/utils/http.ts
240
246
  var import_node_https2 = require("https");
@@ -406,6 +412,37 @@ var AssistantService = class {
406
412
  async getPrebuiltBySlug(slug) {
407
413
  return this.api.get(`/v1/assistants/prebuilt/${slug}`);
408
414
  }
415
+ /**
416
+ * List assistant versions.
417
+ */
418
+ async listVersions(assistantId, _params = {}) {
419
+ const params = AssistantVersionsListParamsSchema.parse(_params);
420
+ const response = await this.api.get(
421
+ `/v1/assistants/${assistantId}/versions`,
422
+ params
423
+ );
424
+ if (Array.isArray(response)) {
425
+ return response;
426
+ }
427
+ if (response && "data" in response && Array.isArray(response.data)) {
428
+ return response.data;
429
+ }
430
+ if (response && "versions" in response && Array.isArray(response.versions)) {
431
+ return response.versions;
432
+ }
433
+ if (response && "items" in response && Array.isArray(response.items)) {
434
+ return response.items;
435
+ }
436
+ return [];
437
+ }
438
+ /**
439
+ * Get a specific assistant version by number.
440
+ */
441
+ async getVersion(assistantId, versionNumber) {
442
+ return this.api.get(
443
+ `/v1/assistants/${assistantId}/versions/${versionNumber}`
444
+ );
445
+ }
409
446
  /**
410
447
  * Send a chat request to an assistant.
411
448
  */
@@ -432,6 +469,49 @@ var AssistantService = class {
432
469
  }
433
470
  return mapped;
434
471
  }
472
+ /**
473
+ * Compare two assistant versions.
474
+ */
475
+ async compareVersions(assistantId, v1, v2) {
476
+ return this.api.get(
477
+ `/v1/assistants/${assistantId}/versions/${v1}/compare/${v2}`
478
+ );
479
+ }
480
+ /**
481
+ * Rollback assistant to a specific version. Creates a new version mirroring the target.
482
+ */
483
+ async rollbackToVersion(assistantId, versionNumber) {
484
+ return this.api.post(
485
+ `/v1/assistants/${assistantId}/versions/${versionNumber}/rollback`,
486
+ {}
487
+ );
488
+ }
489
+ /**
490
+ * Send a chat request to a specific assistant version.
491
+ */
492
+ async chatWithVersion(assistantId, versionNumber, _params) {
493
+ let zodSchema = void 0;
494
+ let params = { ..._params };
495
+ if (params.output_schema && params.output_schema instanceof import_zod2.z.ZodType) {
496
+ zodSchema = params.output_schema;
497
+ params.output_schema = (0, import_zod_to_json_schema.zodToJsonSchema)(zodSchema, {
498
+ definitions: {}
499
+ });
500
+ }
501
+ params = AssistantChatParamsSchema.parse(params);
502
+ const response = await this.api.post(
503
+ `/v1/assistants/${assistantId}/model`,
504
+ { ...params, version: versionNumber },
505
+ {
506
+ responseType: params.stream ? "stream" : void 0
507
+ }
508
+ );
509
+ const mapped = AssistantMapper.mapBaseModelApiResponse(response);
510
+ if (!params.stream && zodSchema && mapped.generated) {
511
+ mapped.generated = zodSchema.parse(mapped.generated);
512
+ }
513
+ return mapped;
514
+ }
435
515
  };
436
516
 
437
517
  // src/schemas/conversation.ts
@@ -1409,6 +1489,7 @@ var BackgroundTaskStatus = {
1409
1489
  AssistantCreateParamsSchema,
1410
1490
  AssistantListParamsSchema,
1411
1491
  AssistantUpdateParamsSchema,
1492
+ AssistantVersionsListParamsSchema,
1412
1493
  BackgroundTaskStatus,
1413
1494
  ChatRole,
1414
1495
  CodeDataSourceType,