@vectorx/agent-runtime 0.5.1 → 0.6.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.
@@ -30,7 +30,7 @@ class AgentDriver {
30
30
  }
31
31
  const apiFuncs = {
32
32
  "POST:send-message": this.sendMessageFunc.bind(this),
33
- "POST:upload-file": this.uploadFileFunc.bind(this),
33
+ "POST:upload-openai-file": this.uploadFileFunc.bind(this),
34
34
  "GET:query-tasks": this.queryTasksFunc.bind(this),
35
35
  "GET:messages": this.getHistoryMessagesFunc.bind(this),
36
36
  "GET:info": this.getAgentInfoFunc.bind(this),
@@ -112,8 +112,7 @@ class AgentDriver {
112
112
  return __awaiter(this, void 0, void 0, function* () {
113
113
  var _a, _b;
114
114
  try {
115
- const parsedEvent = schema_1.uploadFileInputSchema.passthrough().parse(event);
116
- return yield ((_b = (_a = this.agent).uploadFile) === null || _b === void 0 ? void 0 : _b.call(_a, parsedEvent));
115
+ return yield ((_b = (_a = this.agent).uploadFile) === null || _b === void 0 ? void 0 : _b.call(_a, event));
117
116
  }
118
117
  catch (e) {
119
118
  return (0, integration_response_1.createIntegrationResponse)(500, codes_1.CODES.AGENT_API_ERROR, `Agent API 'uploadFile' failed, message: ${e}`);
package/lib/agent.js CHANGED
@@ -1,4 +1,37 @@
1
1
  "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
2
35
  var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
36
  function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
37
  return new (P || (P = Promise))(function (resolve, reject) {
@@ -640,43 +673,82 @@ class AgentRuntime {
640
673
  }
641
674
  uploadFile(input) {
642
675
  return __awaiter(this, void 0, void 0, function* () {
676
+ var _a, _b;
677
+ const fs = yield Promise.resolve().then(() => __importStar(require("fs")));
678
+ const path = yield Promise.resolve().then(() => __importStar(require("path")));
679
+ const os = yield Promise.resolve().then(() => __importStar(require("os")));
680
+ let tempFilePath = null;
643
681
  try {
644
- const validatedInput = schema_1.uploadFileInputSchema.passthrough().parse(input);
682
+ const fileData = input.file;
683
+ const rawFilename = fileData.newFilename || fileData.name || fileData.originalFilename || "unknown";
684
+ const baseName = (yield Promise.resolve().then(() => __importStar(require("path")))).basename(String(rawFilename));
685
+ const safeFilename = baseName.replace(/[\/\\:*?"<>|]/g, "_");
686
+ const filename = safeFilename;
687
+ const purpose = input.purpose || "file-extract";
688
+ const mimeType = fileData.type || fileData.mimetype || "application/octet-stream";
689
+ const fileBuffer = fileData.buffer || fileData;
690
+ if (!Buffer.isBuffer(fileBuffer)) {
691
+ throw new Error("无法从上传的文件对象中提取文件内容:buffer 不存在或格式错误");
692
+ }
693
+ this.logger.logAccesslog(functions_framework_1.LogLevel.INFO, safeJsonStringify({
694
+ type: AgentEventType.FRAMEWORK_EVENT,
695
+ scene: "AI_SDK_UPLOAD_FILE_PARSE",
696
+ message: "Parsed upload file metadata",
697
+ eventId: this.context.eventID,
698
+ timestamp: new Date().toISOString(),
699
+ data: {
700
+ filename,
701
+ rawFilename,
702
+ mimeType,
703
+ purpose,
704
+ size: typeof (fileData === null || fileData === void 0 ? void 0 : fileData.size) === "number" ? fileData.size : fileBuffer.length,
705
+ hasBuffer: true,
706
+ source: {
707
+ name: fileData === null || fileData === void 0 ? void 0 : fileData.name,
708
+ newFilename: fileData === null || fileData === void 0 ? void 0 : fileData.newFilename,
709
+ originalFilename: fileData === null || fileData === void 0 ? void 0 : fileData.originalFilename,
710
+ mimetype: fileData === null || fileData === void 0 ? void 0 : fileData.mimetype,
711
+ type: fileData === null || fileData === void 0 ? void 0 : fileData.type,
712
+ filepath: fileData === null || fileData === void 0 ? void 0 : fileData.filepath,
713
+ },
714
+ },
715
+ }));
716
+ const tempDir = os.tmpdir();
717
+ const timestamp = Date.now();
718
+ const randomStr = Math.random().toString(36).substring(2, 15);
719
+ const ext = path.extname(filename) || "";
720
+ tempFilePath = path.join(tempDir, `upload_${timestamp}_${randomStr}${ext}`);
721
+ fs.writeFileSync(tempFilePath, fileBuffer);
645
722
  this.logger.logAccesslog(functions_framework_1.LogLevel.INFO, safeJsonStringify({
646
723
  type: AgentEventType.FRAMEWORK_EVENT,
647
724
  scene: "AI_SDK_UPLOAD_FILE",
648
725
  method: "POST",
649
726
  url: "https://dashscope.aliyuncs.com/compatible-mode/v1/files",
650
727
  headers: {},
651
- data: { filename: validatedInput.filename, purpose: validatedInput.purpose },
728
+ data: { filename, purpose, tempFilePath },
652
729
  eventId: this.context.eventID,
653
730
  timestamp: new Date().toISOString(),
654
731
  }));
655
732
  const token = yield this.ai.tokenManager.getValidToken();
656
- const fileBuffer = Buffer.from(validatedInput.fileContent, "base64");
657
- const formData = {
658
- file: {
659
- value: fileBuffer,
660
- options: {
661
- filename: validatedInput.filename,
662
- contentType: validatedInput.mimeType || "application/octet-stream",
663
- },
664
- },
665
- purpose: validatedInput.purpose || "file-extract",
666
- };
667
- const response = yield this.request.upload({
733
+ const FormData = (yield Promise.resolve().then(() => __importStar(require("form-data")))).default;
734
+ const formData = new FormData();
735
+ formData.append("file", fs.createReadStream(tempFilePath), {
736
+ filename,
737
+ contentType: mimeType,
738
+ });
739
+ formData.append("purpose", purpose);
740
+ const response = yield this.request.fetch({
668
741
  url: "https://dashscope.aliyuncs.com/compatible-mode/v1/files",
669
- headers: {
670
- Authorization: `Bearer ${token}`,
671
- },
672
- data: formData,
742
+ headers: Object.assign({ Authorization: `Bearer ${token}` }, formData.getHeaders()),
743
+ method: "POST",
744
+ body: formData,
673
745
  });
674
746
  this.logger.logAccesslog(functions_framework_1.LogLevel.INFO, safeJsonStringify({
675
747
  type: AgentEventType.FRAMEWORK_EVENT,
676
748
  scene: "AI_SDK_UPLOAD_FILE",
677
749
  method: "POST",
678
750
  url: "https://dashscope.aliyuncs.com/compatible-mode/v1/files",
679
- status: response.status,
751
+ status: response.statusCode,
680
752
  data: response.data,
681
753
  eventId: this.context.eventID,
682
754
  timestamp: new Date().toISOString(),
@@ -690,8 +762,8 @@ class AgentRuntime {
690
762
  }
691
763
  else {
692
764
  return {
693
- code: response.status,
694
- msg: response.statusText || "文件上传失败",
765
+ code: response.statusCode,
766
+ msg: ((_b = (_a = response.data) === null || _a === void 0 ? void 0 : _a.error) === null || _b === void 0 ? void 0 : _b.message) || "文件上传失败",
695
767
  data: response.data,
696
768
  };
697
769
  }
@@ -712,6 +784,24 @@ class AgentRuntime {
712
784
  msg: error instanceof Error ? error.message : "文件上传失败",
713
785
  };
714
786
  }
787
+ finally {
788
+ if (tempFilePath) {
789
+ try {
790
+ fs.unlinkSync(tempFilePath);
791
+ }
792
+ catch (cleanupError) {
793
+ this.logger.logAccesslog(functions_framework_1.LogLevel.WARN, safeJsonStringify({
794
+ type: AgentEventType.FRAMEWORK_EVENT,
795
+ scene: "AI_SDK_UPLOAD_FILE_CLEANUP",
796
+ message: "临时文件清理失败",
797
+ tempFilePath,
798
+ error: cleanupError instanceof Error ? cleanupError.message : "未知错误",
799
+ eventId: this.context.eventID,
800
+ timestamp: new Date().toISOString(),
801
+ }));
802
+ }
803
+ }
804
+ }
715
805
  });
716
806
  }
717
807
  }
@@ -101,13 +101,13 @@ export declare const participantInfoSchema: z.ZodObject<{
101
101
  avatar_url: z.ZodString;
102
102
  }, "strip", z.ZodTypeAny, {
103
103
  name?: string;
104
- desc?: string;
105
104
  id?: string;
105
+ desc?: string;
106
106
  avatar_url?: string;
107
107
  }, {
108
108
  name?: string;
109
- desc?: string;
110
109
  id?: string;
110
+ desc?: string;
111
111
  avatar_url?: string;
112
112
  }>;
113
113
  export declare const conversationSchema: z.ZodObject<{
@@ -7,12 +7,12 @@ export declare const uploadFileInputSchema: z.ZodObject<{
7
7
  }, "strip", z.ZodTypeAny, {
8
8
  filename?: string;
9
9
  purpose?: string;
10
- fileContent?: string;
11
10
  mimeType?: string;
11
+ fileContent?: string;
12
12
  }, {
13
13
  filename?: string;
14
14
  purpose?: string;
15
- fileContent?: string;
16
15
  mimeType?: string;
16
+ fileContent?: string;
17
17
  }>;
18
18
  export type UploadFileInputSchema = z.infer<typeof uploadFileInputSchema>;
@@ -84,6 +84,19 @@ export declare const videoUrlContentSchema: z.ZodObject<{
84
84
  url?: string;
85
85
  };
86
86
  }>;
87
+ export declare const docUrlContentSchema: z.ZodObject<{
88
+ type: z.ZodLiteral<"doc_url">;
89
+ doc_url: z.ZodArray<z.ZodString, "many">;
90
+ file_parsing_strategy: z.ZodOptional<z.ZodString>;
91
+ }, "strip", z.ZodTypeAny, {
92
+ type?: "doc_url";
93
+ doc_url?: string[];
94
+ file_parsing_strategy?: string;
95
+ }, {
96
+ type?: "doc_url";
97
+ doc_url?: string[];
98
+ file_parsing_strategy?: string;
99
+ }>;
87
100
  export declare const messageContentSchema: z.ZodUnion<[z.ZodObject<{
88
101
  type: z.ZodLiteral<"text">;
89
102
  text: z.ZodString;
@@ -164,6 +177,18 @@ export declare const messageContentSchema: z.ZodUnion<[z.ZodObject<{
164
177
  video_url?: {
165
178
  url?: string;
166
179
  };
180
+ }>, z.ZodObject<{
181
+ type: z.ZodLiteral<"doc_url">;
182
+ doc_url: z.ZodArray<z.ZodString, "many">;
183
+ file_parsing_strategy: z.ZodOptional<z.ZodString>;
184
+ }, "strip", z.ZodTypeAny, {
185
+ type?: "doc_url";
186
+ doc_url?: string[];
187
+ file_parsing_strategy?: string;
188
+ }, {
189
+ type?: "doc_url";
190
+ doc_url?: string[];
191
+ file_parsing_strategy?: string;
167
192
  }>]>;
168
193
  export declare const baseMessageSchema: z.ZodObject<{
169
194
  role: z.ZodUnion<[z.ZodLiteral<"system">, z.ZodLiteral<"user">, z.ZodLiteral<"assistant">]>;
@@ -247,6 +272,18 @@ export declare const baseMessageSchema: z.ZodObject<{
247
272
  video_url?: {
248
273
  url?: string;
249
274
  };
275
+ }>, z.ZodObject<{
276
+ type: z.ZodLiteral<"doc_url">;
277
+ doc_url: z.ZodArray<z.ZodString, "many">;
278
+ file_parsing_strategy: z.ZodOptional<z.ZodString>;
279
+ }, "strip", z.ZodTypeAny, {
280
+ type?: "doc_url";
281
+ doc_url?: string[];
282
+ file_parsing_strategy?: string;
283
+ }, {
284
+ type?: "doc_url";
285
+ doc_url?: string[];
286
+ file_parsing_strategy?: string;
250
287
  }>]>, "many">]>;
251
288
  }, "strip", z.ZodTypeAny, {
252
289
  role?: "user" | "assistant" | "system";
@@ -272,6 +309,10 @@ export declare const baseMessageSchema: z.ZodObject<{
272
309
  video_url?: {
273
310
  url?: string;
274
311
  };
312
+ } | {
313
+ type?: "doc_url";
314
+ doc_url?: string[];
315
+ file_parsing_strategy?: string;
275
316
  })[];
276
317
  }, {
277
318
  role?: "user" | "assistant" | "system";
@@ -297,6 +338,10 @@ export declare const baseMessageSchema: z.ZodObject<{
297
338
  video_url?: {
298
339
  url?: string;
299
340
  };
341
+ } | {
342
+ type?: "doc_url";
343
+ doc_url?: string[];
344
+ file_parsing_strategy?: string;
300
345
  })[];
301
346
  }>;
302
347
  export declare const toolCallMessageSchema: z.ZodObject<{
@@ -410,6 +455,18 @@ export declare const messageItemSchema: z.ZodUnion<[z.ZodObject<{
410
455
  video_url?: {
411
456
  url?: string;
412
457
  };
458
+ }>, z.ZodObject<{
459
+ type: z.ZodLiteral<"doc_url">;
460
+ doc_url: z.ZodArray<z.ZodString, "many">;
461
+ file_parsing_strategy: z.ZodOptional<z.ZodString>;
462
+ }, "strip", z.ZodTypeAny, {
463
+ type?: "doc_url";
464
+ doc_url?: string[];
465
+ file_parsing_strategy?: string;
466
+ }, {
467
+ type?: "doc_url";
468
+ doc_url?: string[];
469
+ file_parsing_strategy?: string;
413
470
  }>]>, "many">]>;
414
471
  }, "strip", z.ZodTypeAny, {
415
472
  role?: "user" | "assistant" | "system";
@@ -435,6 +492,10 @@ export declare const messageItemSchema: z.ZodUnion<[z.ZodObject<{
435
492
  video_url?: {
436
493
  url?: string;
437
494
  };
495
+ } | {
496
+ type?: "doc_url";
497
+ doc_url?: string[];
498
+ file_parsing_strategy?: string;
438
499
  })[];
439
500
  }, {
440
501
  role?: "user" | "assistant" | "system";
@@ -460,6 +521,10 @@ export declare const messageItemSchema: z.ZodUnion<[z.ZodObject<{
460
521
  video_url?: {
461
522
  url?: string;
462
523
  };
524
+ } | {
525
+ type?: "doc_url";
526
+ doc_url?: string[];
527
+ file_parsing_strategy?: string;
463
528
  })[];
464
529
  }>, z.ZodObject<{
465
530
  role: z.ZodLiteral<"tool">;
@@ -571,6 +636,18 @@ export declare const messageHistorySchema: z.ZodArray<z.ZodUnion<[z.ZodObject<{
571
636
  video_url?: {
572
637
  url?: string;
573
638
  };
639
+ }>, z.ZodObject<{
640
+ type: z.ZodLiteral<"doc_url">;
641
+ doc_url: z.ZodArray<z.ZodString, "many">;
642
+ file_parsing_strategy: z.ZodOptional<z.ZodString>;
643
+ }, "strip", z.ZodTypeAny, {
644
+ type?: "doc_url";
645
+ doc_url?: string[];
646
+ file_parsing_strategy?: string;
647
+ }, {
648
+ type?: "doc_url";
649
+ doc_url?: string[];
650
+ file_parsing_strategy?: string;
574
651
  }>]>, "many">]>;
575
652
  }, "strip", z.ZodTypeAny, {
576
653
  role?: "user" | "assistant" | "system";
@@ -596,6 +673,10 @@ export declare const messageHistorySchema: z.ZodArray<z.ZodUnion<[z.ZodObject<{
596
673
  video_url?: {
597
674
  url?: string;
598
675
  };
676
+ } | {
677
+ type?: "doc_url";
678
+ doc_url?: string[];
679
+ file_parsing_strategy?: string;
599
680
  })[];
600
681
  }, {
601
682
  role?: "user" | "assistant" | "system";
@@ -621,6 +702,10 @@ export declare const messageHistorySchema: z.ZodArray<z.ZodUnion<[z.ZodObject<{
621
702
  video_url?: {
622
703
  url?: string;
623
704
  };
705
+ } | {
706
+ type?: "doc_url";
707
+ doc_url?: string[];
708
+ file_parsing_strategy?: string;
624
709
  })[];
625
710
  }>, z.ZodObject<{
626
711
  role: z.ZodLiteral<"tool">;
@@ -734,6 +819,18 @@ export declare const sendMessageInputSchema: z.ZodObject<{
734
819
  video_url?: {
735
820
  url?: string;
736
821
  };
822
+ }>, z.ZodObject<{
823
+ type: z.ZodLiteral<"doc_url">;
824
+ doc_url: z.ZodArray<z.ZodString, "many">;
825
+ file_parsing_strategy: z.ZodOptional<z.ZodString>;
826
+ }, "strip", z.ZodTypeAny, {
827
+ type?: "doc_url";
828
+ doc_url?: string[];
829
+ file_parsing_strategy?: string;
830
+ }, {
831
+ type?: "doc_url";
832
+ doc_url?: string[];
833
+ file_parsing_strategy?: string;
737
834
  }>]>, "many">]>;
738
835
  }, "strip", z.ZodTypeAny, {
739
836
  role?: "user" | "assistant" | "system";
@@ -759,6 +856,10 @@ export declare const sendMessageInputSchema: z.ZodObject<{
759
856
  video_url?: {
760
857
  url?: string;
761
858
  };
859
+ } | {
860
+ type?: "doc_url";
861
+ doc_url?: string[];
862
+ file_parsing_strategy?: string;
762
863
  })[];
763
864
  }, {
764
865
  role?: "user" | "assistant" | "system";
@@ -784,6 +885,10 @@ export declare const sendMessageInputSchema: z.ZodObject<{
784
885
  video_url?: {
785
886
  url?: string;
786
887
  };
888
+ } | {
889
+ type?: "doc_url";
890
+ doc_url?: string[];
891
+ file_parsing_strategy?: string;
787
892
  })[];
788
893
  }>, z.ZodObject<{
789
894
  role: z.ZodLiteral<"tool">;
@@ -813,6 +918,46 @@ export declare const sendMessageInputSchema: z.ZodObject<{
813
918
  content?: string | any[] | Record<string, any>;
814
919
  name?: string;
815
920
  }>]>, "many">;
921
+ files: z.ZodOptional<z.ZodArray<z.ZodUnion<[z.ZodObject<{
922
+ id: z.ZodOptional<z.ZodString>;
923
+ filename: z.ZodOptional<z.ZodString>;
924
+ purpose: z.ZodOptional<z.ZodString>;
925
+ bytes: z.ZodOptional<z.ZodNumber>;
926
+ created_at: z.ZodOptional<z.ZodNumber>;
927
+ }, "passthrough", z.ZodTypeAny, z.objectOutputType<{
928
+ id: z.ZodOptional<z.ZodString>;
929
+ filename: z.ZodOptional<z.ZodString>;
930
+ purpose: z.ZodOptional<z.ZodString>;
931
+ bytes: z.ZodOptional<z.ZodNumber>;
932
+ created_at: z.ZodOptional<z.ZodNumber>;
933
+ }, z.ZodTypeAny, "passthrough">, z.objectInputType<{
934
+ id: z.ZodOptional<z.ZodString>;
935
+ filename: z.ZodOptional<z.ZodString>;
936
+ purpose: z.ZodOptional<z.ZodString>;
937
+ bytes: z.ZodOptional<z.ZodNumber>;
938
+ created_at: z.ZodOptional<z.ZodNumber>;
939
+ }, z.ZodTypeAny, "passthrough">>, z.ZodObject<{
940
+ url: z.ZodOptional<z.ZodString>;
941
+ type: z.ZodOptional<z.ZodString>;
942
+ size: z.ZodOptional<z.ZodNumber>;
943
+ mimeType: z.ZodOptional<z.ZodString>;
944
+ fileSource: z.ZodOptional<z.ZodString>;
945
+ filename: z.ZodOptional<z.ZodString>;
946
+ }, "passthrough", z.ZodTypeAny, z.objectOutputType<{
947
+ url: z.ZodOptional<z.ZodString>;
948
+ type: z.ZodOptional<z.ZodString>;
949
+ size: z.ZodOptional<z.ZodNumber>;
950
+ mimeType: z.ZodOptional<z.ZodString>;
951
+ fileSource: z.ZodOptional<z.ZodString>;
952
+ filename: z.ZodOptional<z.ZodString>;
953
+ }, z.ZodTypeAny, "passthrough">, z.objectInputType<{
954
+ url: z.ZodOptional<z.ZodString>;
955
+ type: z.ZodOptional<z.ZodString>;
956
+ size: z.ZodOptional<z.ZodNumber>;
957
+ mimeType: z.ZodOptional<z.ZodString>;
958
+ fileSource: z.ZodOptional<z.ZodString>;
959
+ filename: z.ZodOptional<z.ZodString>;
960
+ }, z.ZodTypeAny, "passthrough">>]>, "many">>;
816
961
  }, "strip", z.ZodTypeAny, {
817
962
  msg?: string;
818
963
  history?: ({
@@ -839,6 +984,10 @@ export declare const sendMessageInputSchema: z.ZodObject<{
839
984
  video_url?: {
840
985
  url?: string;
841
986
  };
987
+ } | {
988
+ type?: "doc_url";
989
+ doc_url?: string[];
990
+ file_parsing_strategy?: string;
842
991
  })[];
843
992
  } | {
844
993
  function?: string;
@@ -850,6 +999,20 @@ export declare const sendMessageInputSchema: z.ZodObject<{
850
999
  content?: string | any[] | Record<string, any>;
851
1000
  name?: string;
852
1001
  })[];
1002
+ files?: (z.objectOutputType<{
1003
+ id: z.ZodOptional<z.ZodString>;
1004
+ filename: z.ZodOptional<z.ZodString>;
1005
+ purpose: z.ZodOptional<z.ZodString>;
1006
+ bytes: z.ZodOptional<z.ZodNumber>;
1007
+ created_at: z.ZodOptional<z.ZodNumber>;
1008
+ }, z.ZodTypeAny, "passthrough"> | z.objectOutputType<{
1009
+ url: z.ZodOptional<z.ZodString>;
1010
+ type: z.ZodOptional<z.ZodString>;
1011
+ size: z.ZodOptional<z.ZodNumber>;
1012
+ mimeType: z.ZodOptional<z.ZodString>;
1013
+ fileSource: z.ZodOptional<z.ZodString>;
1014
+ filename: z.ZodOptional<z.ZodString>;
1015
+ }, z.ZodTypeAny, "passthrough">)[];
853
1016
  }, {
854
1017
  msg?: string;
855
1018
  history?: ({
@@ -876,6 +1039,10 @@ export declare const sendMessageInputSchema: z.ZodObject<{
876
1039
  video_url?: {
877
1040
  url?: string;
878
1041
  };
1042
+ } | {
1043
+ type?: "doc_url";
1044
+ doc_url?: string[];
1045
+ file_parsing_strategy?: string;
879
1046
  })[];
880
1047
  } | {
881
1048
  function?: string;
@@ -887,12 +1054,27 @@ export declare const sendMessageInputSchema: z.ZodObject<{
887
1054
  content?: string | any[] | Record<string, any>;
888
1055
  name?: string;
889
1056
  })[];
1057
+ files?: (z.objectInputType<{
1058
+ id: z.ZodOptional<z.ZodString>;
1059
+ filename: z.ZodOptional<z.ZodString>;
1060
+ purpose: z.ZodOptional<z.ZodString>;
1061
+ bytes: z.ZodOptional<z.ZodNumber>;
1062
+ created_at: z.ZodOptional<z.ZodNumber>;
1063
+ }, z.ZodTypeAny, "passthrough"> | z.objectInputType<{
1064
+ url: z.ZodOptional<z.ZodString>;
1065
+ type: z.ZodOptional<z.ZodString>;
1066
+ size: z.ZodOptional<z.ZodNumber>;
1067
+ mimeType: z.ZodOptional<z.ZodString>;
1068
+ fileSource: z.ZodOptional<z.ZodString>;
1069
+ filename: z.ZodOptional<z.ZodString>;
1070
+ }, z.ZodTypeAny, "passthrough">)[];
890
1071
  }>;
891
1072
  export type TextContent = z.infer<typeof textContentSchema>;
892
1073
  export type ImageContent = z.infer<typeof imageContentSchema>;
893
1074
  export type AudioContent = z.infer<typeof audioContentSchema>;
894
1075
  export type VideoContent = z.infer<typeof videoContentSchema>;
895
1076
  export type VideoUrlContent = z.infer<typeof videoUrlContentSchema>;
1077
+ export type DocUrlContent = z.infer<typeof docUrlContentSchema>;
896
1078
  export type MessageContent = z.infer<typeof messageContentSchema>;
897
1079
  export type BaseMessage = z.infer<typeof baseMessageSchema>;
898
1080
  export type ToolCallMessage = z.infer<typeof toolCallMessageSchema>;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.sendMessageInputSchema = exports.messageHistorySchema = exports.messageItemSchema = exports.toolResultMessageSchema = exports.toolCallMessageSchema = exports.baseMessageSchema = exports.messageContentSchema = exports.videoUrlContentSchema = exports.videoContentSchema = exports.audioContentSchema = exports.imageContentSchema = exports.textContentSchema = void 0;
3
+ exports.sendMessageInputSchema = exports.messageHistorySchema = exports.messageItemSchema = exports.toolResultMessageSchema = exports.toolCallMessageSchema = exports.baseMessageSchema = exports.messageContentSchema = exports.docUrlContentSchema = exports.videoUrlContentSchema = exports.videoContentSchema = exports.audioContentSchema = exports.imageContentSchema = exports.textContentSchema = void 0;
4
4
  const zod_1 = require("zod");
5
5
  exports.textContentSchema = zod_1.z.object({
6
6
  type: zod_1.z.literal("text"),
@@ -29,12 +29,18 @@ exports.videoUrlContentSchema = zod_1.z.object({
29
29
  url: zod_1.z.string(),
30
30
  }),
31
31
  });
32
+ exports.docUrlContentSchema = zod_1.z.object({
33
+ type: zod_1.z.literal("doc_url"),
34
+ doc_url: zod_1.z.array(zod_1.z.string()),
35
+ file_parsing_strategy: zod_1.z.string().optional(),
36
+ });
32
37
  exports.messageContentSchema = zod_1.z.union([
33
38
  exports.textContentSchema,
34
39
  exports.imageContentSchema,
35
40
  exports.audioContentSchema,
36
41
  exports.videoContentSchema,
37
42
  exports.videoUrlContentSchema,
43
+ exports.docUrlContentSchema,
38
44
  ]);
39
45
  exports.baseMessageSchema = zod_1.z.object({
40
46
  role: zod_1.z.union([zod_1.z.literal("system"), zod_1.z.literal("user"), zod_1.z.literal("assistant")]),
@@ -59,4 +65,27 @@ exports.messageHistorySchema = zod_1.z.array(exports.messageItemSchema);
59
65
  exports.sendMessageInputSchema = zod_1.z.object({
60
66
  msg: zod_1.z.string(),
61
67
  history: exports.messageHistorySchema,
68
+ files: zod_1.z
69
+ .array(zod_1.z.union([
70
+ zod_1.z
71
+ .object({
72
+ id: zod_1.z.string().optional(),
73
+ filename: zod_1.z.string().optional(),
74
+ purpose: zod_1.z.string().optional(),
75
+ bytes: zod_1.z.number().optional(),
76
+ created_at: zod_1.z.number().optional(),
77
+ })
78
+ .passthrough(),
79
+ zod_1.z
80
+ .object({
81
+ url: zod_1.z.string().optional(),
82
+ type: zod_1.z.string().optional(),
83
+ size: zod_1.z.number().optional(),
84
+ mimeType: zod_1.z.string().optional(),
85
+ fileSource: zod_1.z.string().optional(),
86
+ filename: zod_1.z.string().optional(),
87
+ })
88
+ .passthrough(),
89
+ ]))
90
+ .optional(),
62
91
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vectorx/agent-runtime",
3
- "version": "0.5.1",
3
+ "version": "0.6.2",
4
4
  "description": "Cloud AI agent runtime",
5
5
  "main": "lib/index.js",
6
6
  "files": [
@@ -20,13 +20,15 @@
20
20
  "node": ">=18.0.0"
21
21
  },
22
22
  "dependencies": {
23
- "@vectorx/ai-sdk": "0.5.1",
24
- "@vectorx/functions-framework": "0.5.1",
23
+ "@vectorx/ai-sdk": "0.6.2",
24
+ "@vectorx/functions-framework": "0.6.2",
25
+ "form-data": "^4.0.0",
25
26
  "langfuse": "^3.38.4",
26
27
  "query-string": "^6.14.1",
27
28
  "zod": "^3.24.2"
28
29
  },
29
30
  "devDependencies": {
31
+ "@types/form-data": "^2.5.0",
30
32
  "@types/jest": "^29.5.12",
31
33
  "@types/node": "^20.11.24",
32
34
  "@typescript-eslint/eslint-plugin": "^7.1.0",