@vectorx/agent-runtime 0.1.3 → 0.4.0

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.
@@ -9,4 +9,6 @@ export declare class AgentDriver {
9
9
  private getHistoryMessagesFunc;
10
10
  private getAgentInfoFunc;
11
11
  private getConversationsFunc;
12
+ private queryTasksFunc;
13
+ private uploadFileFunc;
12
14
  }
@@ -30,6 +30,8 @@ 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),
34
+ "GET:query-tasks": this.queryTasksFunc.bind(this),
33
35
  "GET:messages": this.getHistoryMessagesFunc.bind(this),
34
36
  "GET:info": this.getAgentInfoFunc.bind(this),
35
37
  "GET:conversations": this.getConversationsFunc.bind(this),
@@ -90,5 +92,33 @@ class AgentDriver {
90
92
  }
91
93
  });
92
94
  }
95
+ queryTasksFunc(event, context) {
96
+ return __awaiter(this, void 0, void 0, function* () {
97
+ var _a, _b;
98
+ try {
99
+ const pathTaskId = (0, agent_helper_1.parseTaskIdFromPath)(context.httpContext.url);
100
+ const query = (0, agent_helper_1.parseQueryFromCtx)(context);
101
+ const parsed = schema_1.queryTasksParamsSchema.passthrough().parse({
102
+ task_id: query.task_id || pathTaskId,
103
+ });
104
+ return yield ((_b = (_a = this.agent).queryTasks) === null || _b === void 0 ? void 0 : _b.call(_a, parsed.task_id));
105
+ }
106
+ catch (e) {
107
+ return (0, integration_response_1.createIntegrationResponse)(500, codes_1.CODES.AGENT_API_ERROR, `Agent API 'queryTasks' failed, message: ${e}`);
108
+ }
109
+ });
110
+ }
111
+ uploadFileFunc(event, context) {
112
+ return __awaiter(this, void 0, void 0, function* () {
113
+ var _a, _b;
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));
117
+ }
118
+ catch (e) {
119
+ return (0, integration_response_1.createIntegrationResponse)(500, codes_1.CODES.AGENT_API_ERROR, `Agent API 'uploadFile' failed, message: ${e}`);
120
+ }
121
+ });
122
+ }
93
123
  }
94
124
  exports.AgentDriver = AgentDriver;
@@ -79,3 +79,40 @@ export interface GetAgentInfoResponse {
79
79
  agentInfo: AgentInfo;
80
80
  };
81
81
  }
82
+ export interface QueryTasksData {
83
+ request_id: string;
84
+ output: {
85
+ task_id: string;
86
+ task_status: "PENDING" | "RUNNING" | "SUCCEEDED" | "FAILED" | "CANCELED" | "UNKNOWN";
87
+ results?: Array<{
88
+ url?: string;
89
+ [key: string]: any;
90
+ }>;
91
+ task_metrics?: {
92
+ TOTAL: number;
93
+ SUCCEEDED: number;
94
+ FAILED: number;
95
+ };
96
+ };
97
+ usage?: {
98
+ image_count?: number;
99
+ };
100
+ }
101
+ export type RawQueryTasksResponse = QueryTasksData;
102
+ export type QueryTasksResponse = BaseResponse<QueryTasksData>;
103
+ export interface UploadFileInput {
104
+ file: File | Buffer | string;
105
+ filename: string;
106
+ purpose?: string;
107
+ }
108
+ export interface UploadFileData {
109
+ id: string;
110
+ object: string;
111
+ bytes: number;
112
+ created_at: number;
113
+ filename: string;
114
+ purpose: string;
115
+ status: string;
116
+ status_details?: any;
117
+ }
118
+ export type UploadFileResponse = BaseResponse<UploadFileData>;
@@ -1,6 +1,6 @@
1
1
  import { type AI, type models } from "@vectorx/ai-sdk";
2
2
  import { type RcbContext } from "@vectorx/functions-framework";
3
- import type { CreateRecordPairResponse, GetAgentInfoResponse, GetConversationsResponse, GetHistoryMessagesResponse, KnowledgeBaseRetrieveResponse } from "./agent-types";
3
+ import type { CreateRecordPairResponse, GetAgentInfoResponse, GetConversationsResponse, GetHistoryMessagesResponse, KnowledgeBaseRetrieveResponse, QueryTasksResponse, UploadFileResponse } from "./agent-types";
4
4
  import { type CreateRecordPairParams, type GetHistoryMessagesParams, type KnowledgeSearchInput } from "./schema";
5
5
  import { SSESender } from "./sse-sender";
6
6
  export declare enum AgentType {
@@ -11,7 +11,8 @@ export declare enum AgentType {
11
11
  AI_SDK_CREATE_RECORD_PAIR = "AI_SDK_CREATE_RECORD_PAIR",
12
12
  AI_SDK_GET_HISTORY_MESSAGES = "AI_SDK_GET_HISTORY_MESSAGES",
13
13
  AI_SDK_GET_CONVERSATIONS = "AI_SDK_GET_CONVERSATIONS",
14
- Ai_SDK_POST_KNOWLEDGE_BASE = "Ai_SDK_POST_KNOWLEDGE_BASE"
14
+ Ai_SDK_POST_KNOWLEDGE_BASE = "Ai_SDK_POST_KNOWLEDGE_BASE",
15
+ AI_SDK_QUERY_TASKS = "AI_SDK_QUERY_TASKS"
15
16
  }
16
17
  export declare enum AgentEventType {
17
18
  FRAMEWORK_EVENT = "FRAMEWORK_EVENT",
@@ -28,10 +29,12 @@ export declare class AgentRuntime {
28
29
  get version(): string;
29
30
  constructor(context: RcbContext);
30
31
  private createLoggedRequest;
31
- protected createModel(modelName: models.ModelName): models.ReactModel;
32
+ protected createModel(modelName: models.ModelName): models.ReActModel;
32
33
  protected createRecordPair(params: CreateRecordPairParams): Promise<CreateRecordPairResponse>;
33
34
  protected getHistoryMessages(params: GetHistoryMessagesParams): Promise<GetHistoryMessagesResponse>;
34
35
  protected getConversations(): Promise<GetConversationsResponse>;
35
36
  getAgentInfo(): Promise<GetAgentInfoResponse>;
36
37
  knowledgeBaseRetrieve(params: KnowledgeSearchInput): Promise<KnowledgeBaseRetrieveResponse>;
38
+ queryTasks(task_id?: string): Promise<QueryTasksResponse>;
39
+ uploadFile(input: any): Promise<UploadFileResponse>;
37
40
  }
package/lib/agent.js CHANGED
@@ -25,6 +25,7 @@ var AgentType;
25
25
  AgentType["AI_SDK_GET_HISTORY_MESSAGES"] = "AI_SDK_GET_HISTORY_MESSAGES";
26
26
  AgentType["AI_SDK_GET_CONVERSATIONS"] = "AI_SDK_GET_CONVERSATIONS";
27
27
  AgentType["Ai_SDK_POST_KNOWLEDGE_BASE"] = "Ai_SDK_POST_KNOWLEDGE_BASE";
28
+ AgentType["AI_SDK_QUERY_TASKS"] = "AI_SDK_QUERY_TASKS";
28
29
  })(AgentType || (exports.AgentType = AgentType = {}));
29
30
  var AgentEventType;
30
31
  (function (AgentEventType) {
@@ -573,5 +574,145 @@ class AgentRuntime {
573
574
  }
574
575
  });
575
576
  }
577
+ queryTasks(task_id) {
578
+ return __awaiter(this, void 0, void 0, function* () {
579
+ const validated = schema_1.queryTasksParamsSchema.passthrough().parse({ task_id });
580
+ this.logger.logAccesslog(functions_framework_1.LogLevel.INFO, safeJsonStringify({
581
+ type: AgentEventType.FRAMEWORK_EVENT,
582
+ scene: AgentType.AI_SDK_QUERY_TASKS,
583
+ method: "GET",
584
+ url: `https://dashscope.aliyuncs.com/api/v1/tasks/${validated.task_id}`,
585
+ headers: {},
586
+ data: { task_id: validated.task_id },
587
+ eventId: this.context.eventID,
588
+ timestamp: new Date().toISOString(),
589
+ }));
590
+ try {
591
+ const token = yield this.ai.tokenManager.getValidToken();
592
+ const response = yield this.request.get({
593
+ url: `https://dashscope.aliyuncs.com/api/v1/tasks/${validated.task_id}`,
594
+ headers: {
595
+ Authorization: `Bearer ${token}`,
596
+ },
597
+ });
598
+ this.logger.logAccesslog(functions_framework_1.LogLevel.INFO, safeJsonStringify({
599
+ type: AgentEventType.FRAMEWORK_EVENT,
600
+ scene: AgentType.AI_SDK_QUERY_TASKS,
601
+ method: "GET",
602
+ url: `https://dashscope.aliyuncs.com/api/v1/tasks/${validated.task_id}`,
603
+ status: response.status,
604
+ data: response.data,
605
+ eventId: this.context.eventID,
606
+ timestamp: new Date().toISOString(),
607
+ }));
608
+ if (response.statusCode >= 200 && response.statusCode < 300) {
609
+ return {
610
+ code: 0,
611
+ msg: "success",
612
+ data: response.data,
613
+ };
614
+ }
615
+ else {
616
+ return {
617
+ code: response.status,
618
+ msg: response.statusText || "请求失败",
619
+ data: response.data,
620
+ };
621
+ }
622
+ }
623
+ catch (error) {
624
+ this.logger.logAccesslog(functions_framework_1.LogLevel.ERROR, safeJsonStringify({
625
+ type: AgentEventType.FRAMEWORK_EVENT,
626
+ scene: AgentType.AI_SDK_QUERY_TASKS,
627
+ method: "GET",
628
+ url: `https://dashscope.aliyuncs.com/api/v1/tasks/${validated.task_id}`,
629
+ error: error instanceof Error ? error.message : "查询任务失败",
630
+ stack: error instanceof Error ? error.stack : undefined,
631
+ eventId: this.context.eventID,
632
+ timestamp: new Date().toISOString(),
633
+ }));
634
+ return {
635
+ code: -1,
636
+ msg: error instanceof Error ? error.message : "查询任务失败",
637
+ };
638
+ }
639
+ });
640
+ }
641
+ uploadFile(input) {
642
+ return __awaiter(this, void 0, void 0, function* () {
643
+ try {
644
+ const validatedInput = schema_1.uploadFileInputSchema.passthrough().parse(input);
645
+ this.logger.logAccesslog(functions_framework_1.LogLevel.INFO, safeJsonStringify({
646
+ type: AgentEventType.FRAMEWORK_EVENT,
647
+ scene: "AI_SDK_UPLOAD_FILE",
648
+ method: "POST",
649
+ url: "https://dashscope.aliyuncs.com/compatible-mode/v1/files",
650
+ headers: {},
651
+ data: { filename: validatedInput.filename, purpose: validatedInput.purpose },
652
+ eventId: this.context.eventID,
653
+ timestamp: new Date().toISOString(),
654
+ }));
655
+ 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({
668
+ url: "https://dashscope.aliyuncs.com/compatible-mode/v1/files",
669
+ headers: {
670
+ Authorization: `Bearer ${token}`,
671
+ },
672
+ data: formData,
673
+ });
674
+ this.logger.logAccesslog(functions_framework_1.LogLevel.INFO, safeJsonStringify({
675
+ type: AgentEventType.FRAMEWORK_EVENT,
676
+ scene: "AI_SDK_UPLOAD_FILE",
677
+ method: "POST",
678
+ url: "https://dashscope.aliyuncs.com/compatible-mode/v1/files",
679
+ status: response.status,
680
+ data: response.data,
681
+ eventId: this.context.eventID,
682
+ timestamp: new Date().toISOString(),
683
+ }));
684
+ if (response.statusCode >= 200 && response.statusCode < 300) {
685
+ return {
686
+ code: 0,
687
+ msg: "success",
688
+ data: response.data,
689
+ };
690
+ }
691
+ else {
692
+ return {
693
+ code: response.status,
694
+ msg: response.statusText || "文件上传失败",
695
+ data: response.data,
696
+ };
697
+ }
698
+ }
699
+ catch (error) {
700
+ this.logger.logAccesslog(functions_framework_1.LogLevel.ERROR, safeJsonStringify({
701
+ type: AgentEventType.FRAMEWORK_EVENT,
702
+ scene: "AI_SDK_UPLOAD_FILE",
703
+ method: "POST",
704
+ url: "https://dashscope.aliyuncs.com/compatible-mode/v1/files",
705
+ error: error instanceof Error ? error.message : "文件上传失败",
706
+ stack: error instanceof Error ? error.stack : undefined,
707
+ eventId: this.context.eventID,
708
+ timestamp: new Date().toISOString(),
709
+ }));
710
+ return {
711
+ code: -1,
712
+ msg: error instanceof Error ? error.message : "文件上传失败",
713
+ };
714
+ }
715
+ });
716
+ }
576
717
  }
577
718
  exports.AgentRuntime = AgentRuntime;
@@ -0,0 +1,18 @@
1
+ import { z } from "zod";
2
+ export declare const uploadFileInputSchema: z.ZodObject<{
3
+ filename: z.ZodString;
4
+ purpose: z.ZodDefault<z.ZodOptional<z.ZodString>>;
5
+ fileContent: z.ZodString;
6
+ mimeType: z.ZodOptional<z.ZodString>;
7
+ }, "strip", z.ZodTypeAny, {
8
+ filename?: string;
9
+ purpose?: string;
10
+ fileContent?: string;
11
+ mimeType?: string;
12
+ }, {
13
+ filename?: string;
14
+ purpose?: string;
15
+ fileContent?: string;
16
+ mimeType?: string;
17
+ }>;
18
+ export type UploadFileInputSchema = z.infer<typeof uploadFileInputSchema>;
@@ -0,0 +1,10 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.uploadFileInputSchema = void 0;
4
+ const zod_1 = require("zod");
5
+ exports.uploadFileInputSchema = zod_1.z.object({
6
+ filename: zod_1.z.string().min(1, "文件名不能为空"),
7
+ purpose: zod_1.z.string().optional().default("file-extract"),
8
+ fileContent: zod_1.z.string().min(1, "文件内容不能为空"),
9
+ mimeType: zod_1.z.string().optional(),
10
+ });
@@ -2,3 +2,5 @@ export * from "./message.schema";
2
2
  export * from "./conversation.schema";
3
3
  export * from "./memory.schema";
4
4
  export * from "./knowledge.schema";
5
+ export * from "./task.schema";
6
+ export * from "./file.schema";
@@ -18,3 +18,5 @@ __exportStar(require("./message.schema"), exports);
18
18
  __exportStar(require("./conversation.schema"), exports);
19
19
  __exportStar(require("./memory.schema"), exports);
20
20
  __exportStar(require("./knowledge.schema"), exports);
21
+ __exportStar(require("./task.schema"), exports);
22
+ __exportStar(require("./file.schema"), exports);
@@ -58,11 +58,11 @@ export declare const videoContentSchema: z.ZodObject<{
58
58
  type: z.ZodLiteral<"video">;
59
59
  video: z.ZodArray<z.ZodString, "many">;
60
60
  }, "strip", z.ZodTypeAny, {
61
- type?: "video";
62
61
  video?: string[];
63
- }, {
64
62
  type?: "video";
63
+ }, {
65
64
  video?: string[];
65
+ type?: "video";
66
66
  }>;
67
67
  export declare const videoUrlContentSchema: z.ZodObject<{
68
68
  type: z.ZodLiteral<"video_url">;
@@ -140,11 +140,11 @@ export declare const messageContentSchema: z.ZodUnion<[z.ZodObject<{
140
140
  type: z.ZodLiteral<"video">;
141
141
  video: z.ZodArray<z.ZodString, "many">;
142
142
  }, "strip", z.ZodTypeAny, {
143
- type?: "video";
144
143
  video?: string[];
145
- }, {
146
144
  type?: "video";
145
+ }, {
147
146
  video?: string[];
147
+ type?: "video";
148
148
  }>, z.ZodObject<{
149
149
  type: z.ZodLiteral<"video_url">;
150
150
  video_url: z.ZodObject<{
@@ -223,11 +223,11 @@ export declare const baseMessageSchema: z.ZodObject<{
223
223
  type: z.ZodLiteral<"video">;
224
224
  video: z.ZodArray<z.ZodString, "many">;
225
225
  }, "strip", z.ZodTypeAny, {
226
- type?: "video";
227
226
  video?: string[];
228
- }, {
229
227
  type?: "video";
228
+ }, {
230
229
  video?: string[];
230
+ type?: "video";
231
231
  }>, z.ZodObject<{
232
232
  type: z.ZodLiteral<"video_url">;
233
233
  video_url: z.ZodObject<{
@@ -249,7 +249,7 @@ export declare const baseMessageSchema: z.ZodObject<{
249
249
  };
250
250
  }>]>, "many">]>;
251
251
  }, "strip", z.ZodTypeAny, {
252
- role?: "system" | "user" | "assistant";
252
+ role?: "user" | "assistant" | "system";
253
253
  content?: string | ({
254
254
  type?: "text";
255
255
  text?: string;
@@ -265,8 +265,8 @@ export declare const baseMessageSchema: z.ZodObject<{
265
265
  format?: string;
266
266
  };
267
267
  } | {
268
- type?: "video";
269
268
  video?: string[];
269
+ type?: "video";
270
270
  } | {
271
271
  type?: "video_url";
272
272
  video_url?: {
@@ -274,7 +274,7 @@ export declare const baseMessageSchema: z.ZodObject<{
274
274
  };
275
275
  })[];
276
276
  }, {
277
- role?: "system" | "user" | "assistant";
277
+ role?: "user" | "assistant" | "system";
278
278
  content?: string | ({
279
279
  type?: "text";
280
280
  text?: string;
@@ -290,8 +290,8 @@ export declare const baseMessageSchema: z.ZodObject<{
290
290
  format?: string;
291
291
  };
292
292
  } | {
293
- type?: "video";
294
293
  video?: string[];
294
+ type?: "video";
295
295
  } | {
296
296
  type?: "video_url";
297
297
  video_url?: {
@@ -386,11 +386,11 @@ export declare const messageItemSchema: z.ZodUnion<[z.ZodObject<{
386
386
  type: z.ZodLiteral<"video">;
387
387
  video: z.ZodArray<z.ZodString, "many">;
388
388
  }, "strip", z.ZodTypeAny, {
389
- type?: "video";
390
389
  video?: string[];
391
- }, {
392
390
  type?: "video";
391
+ }, {
393
392
  video?: string[];
393
+ type?: "video";
394
394
  }>, z.ZodObject<{
395
395
  type: z.ZodLiteral<"video_url">;
396
396
  video_url: z.ZodObject<{
@@ -412,7 +412,7 @@ export declare const messageItemSchema: z.ZodUnion<[z.ZodObject<{
412
412
  };
413
413
  }>]>, "many">]>;
414
414
  }, "strip", z.ZodTypeAny, {
415
- role?: "system" | "user" | "assistant";
415
+ role?: "user" | "assistant" | "system";
416
416
  content?: string | ({
417
417
  type?: "text";
418
418
  text?: string;
@@ -428,8 +428,8 @@ export declare const messageItemSchema: z.ZodUnion<[z.ZodObject<{
428
428
  format?: string;
429
429
  };
430
430
  } | {
431
- type?: "video";
432
431
  video?: string[];
432
+ type?: "video";
433
433
  } | {
434
434
  type?: "video_url";
435
435
  video_url?: {
@@ -437,7 +437,7 @@ export declare const messageItemSchema: z.ZodUnion<[z.ZodObject<{
437
437
  };
438
438
  })[];
439
439
  }, {
440
- role?: "system" | "user" | "assistant";
440
+ role?: "user" | "assistant" | "system";
441
441
  content?: string | ({
442
442
  type?: "text";
443
443
  text?: string;
@@ -453,8 +453,8 @@ export declare const messageItemSchema: z.ZodUnion<[z.ZodObject<{
453
453
  format?: string;
454
454
  };
455
455
  } | {
456
- type?: "video";
457
456
  video?: string[];
457
+ type?: "video";
458
458
  } | {
459
459
  type?: "video_url";
460
460
  video_url?: {
@@ -547,11 +547,11 @@ export declare const messageHistorySchema: z.ZodArray<z.ZodUnion<[z.ZodObject<{
547
547
  type: z.ZodLiteral<"video">;
548
548
  video: z.ZodArray<z.ZodString, "many">;
549
549
  }, "strip", z.ZodTypeAny, {
550
- type?: "video";
551
550
  video?: string[];
552
- }, {
553
551
  type?: "video";
552
+ }, {
554
553
  video?: string[];
554
+ type?: "video";
555
555
  }>, z.ZodObject<{
556
556
  type: z.ZodLiteral<"video_url">;
557
557
  video_url: z.ZodObject<{
@@ -573,7 +573,7 @@ export declare const messageHistorySchema: z.ZodArray<z.ZodUnion<[z.ZodObject<{
573
573
  };
574
574
  }>]>, "many">]>;
575
575
  }, "strip", z.ZodTypeAny, {
576
- role?: "system" | "user" | "assistant";
576
+ role?: "user" | "assistant" | "system";
577
577
  content?: string | ({
578
578
  type?: "text";
579
579
  text?: string;
@@ -589,8 +589,8 @@ export declare const messageHistorySchema: z.ZodArray<z.ZodUnion<[z.ZodObject<{
589
589
  format?: string;
590
590
  };
591
591
  } | {
592
- type?: "video";
593
592
  video?: string[];
593
+ type?: "video";
594
594
  } | {
595
595
  type?: "video_url";
596
596
  video_url?: {
@@ -598,7 +598,7 @@ export declare const messageHistorySchema: z.ZodArray<z.ZodUnion<[z.ZodObject<{
598
598
  };
599
599
  })[];
600
600
  }, {
601
- role?: "system" | "user" | "assistant";
601
+ role?: "user" | "assistant" | "system";
602
602
  content?: string | ({
603
603
  type?: "text";
604
604
  text?: string;
@@ -614,8 +614,8 @@ export declare const messageHistorySchema: z.ZodArray<z.ZodUnion<[z.ZodObject<{
614
614
  format?: string;
615
615
  };
616
616
  } | {
617
- type?: "video";
618
617
  video?: string[];
618
+ type?: "video";
619
619
  } | {
620
620
  type?: "video_url";
621
621
  video_url?: {
@@ -710,11 +710,11 @@ export declare const sendMessageInputSchema: z.ZodObject<{
710
710
  type: z.ZodLiteral<"video">;
711
711
  video: z.ZodArray<z.ZodString, "many">;
712
712
  }, "strip", z.ZodTypeAny, {
713
- type?: "video";
714
713
  video?: string[];
715
- }, {
716
714
  type?: "video";
715
+ }, {
717
716
  video?: string[];
717
+ type?: "video";
718
718
  }>, z.ZodObject<{
719
719
  type: z.ZodLiteral<"video_url">;
720
720
  video_url: z.ZodObject<{
@@ -736,7 +736,7 @@ export declare const sendMessageInputSchema: z.ZodObject<{
736
736
  };
737
737
  }>]>, "many">]>;
738
738
  }, "strip", z.ZodTypeAny, {
739
- role?: "system" | "user" | "assistant";
739
+ role?: "user" | "assistant" | "system";
740
740
  content?: string | ({
741
741
  type?: "text";
742
742
  text?: string;
@@ -752,8 +752,8 @@ export declare const sendMessageInputSchema: z.ZodObject<{
752
752
  format?: string;
753
753
  };
754
754
  } | {
755
- type?: "video";
756
755
  video?: string[];
756
+ type?: "video";
757
757
  } | {
758
758
  type?: "video_url";
759
759
  video_url?: {
@@ -761,7 +761,7 @@ export declare const sendMessageInputSchema: z.ZodObject<{
761
761
  };
762
762
  })[];
763
763
  }, {
764
- role?: "system" | "user" | "assistant";
764
+ role?: "user" | "assistant" | "system";
765
765
  content?: string | ({
766
766
  type?: "text";
767
767
  text?: string;
@@ -777,8 +777,8 @@ export declare const sendMessageInputSchema: z.ZodObject<{
777
777
  format?: string;
778
778
  };
779
779
  } | {
780
- type?: "video";
781
780
  video?: string[];
781
+ type?: "video";
782
782
  } | {
783
783
  type?: "video_url";
784
784
  video_url?: {
@@ -816,7 +816,7 @@ export declare const sendMessageInputSchema: z.ZodObject<{
816
816
  }, "strip", z.ZodTypeAny, {
817
817
  msg?: string;
818
818
  history?: ({
819
- role?: "system" | "user" | "assistant";
819
+ role?: "user" | "assistant" | "system";
820
820
  content?: string | ({
821
821
  type?: "text";
822
822
  text?: string;
@@ -832,8 +832,8 @@ export declare const sendMessageInputSchema: z.ZodObject<{
832
832
  format?: string;
833
833
  };
834
834
  } | {
835
- type?: "video";
836
835
  video?: string[];
836
+ type?: "video";
837
837
  } | {
838
838
  type?: "video_url";
839
839
  video_url?: {
@@ -853,7 +853,7 @@ export declare const sendMessageInputSchema: z.ZodObject<{
853
853
  }, {
854
854
  msg?: string;
855
855
  history?: ({
856
- role?: "system" | "user" | "assistant";
856
+ role?: "user" | "assistant" | "system";
857
857
  content?: string | ({
858
858
  type?: "text";
859
859
  text?: string;
@@ -869,8 +869,8 @@ export declare const sendMessageInputSchema: z.ZodObject<{
869
869
  format?: string;
870
870
  };
871
871
  } | {
872
- type?: "video";
873
872
  video?: string[];
873
+ type?: "video";
874
874
  } | {
875
875
  type?: "video_url";
876
876
  video_url?: {
@@ -0,0 +1,9 @@
1
+ import { z } from "zod";
2
+ export declare const queryTasksParamsSchema: z.ZodObject<{
3
+ task_id: z.ZodString;
4
+ }, "strip", z.ZodTypeAny, {
5
+ task_id?: string;
6
+ }, {
7
+ task_id?: string;
8
+ }>;
9
+ export type QueryTasksParams = z.infer<typeof queryTasksParamsSchema>;
@@ -0,0 +1,7 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.queryTasksParamsSchema = void 0;
4
+ const zod_1 = require("zod");
5
+ exports.queryTasksParamsSchema = zod_1.z.object({
6
+ task_id: zod_1.z.string().min(1),
7
+ });
@@ -4,5 +4,6 @@ export declare function parseAgentId(url: string): string;
4
4
  export declare function parseAgentTag(url: string): string;
5
5
  export declare function parseApiName(url: string): string;
6
6
  export declare function parseQueryFromCtx(ctx: RcbContext): queryString.ParsedQuery<string | boolean>;
7
+ export declare function parseTaskIdFromPath(url: string): string | null;
7
8
  export declare function genRecordId(): string;
8
9
  export declare function genRandomStr(length: number): string;
@@ -40,11 +40,12 @@ exports.parseAgentId = parseAgentId;
40
40
  exports.parseAgentTag = parseAgentTag;
41
41
  exports.parseApiName = parseApiName;
42
42
  exports.parseQueryFromCtx = parseQueryFromCtx;
43
+ exports.parseTaskIdFromPath = parseTaskIdFromPath;
43
44
  exports.genRecordId = genRecordId;
44
45
  exports.genRandomStr = genRandomStr;
45
46
  const crypto = __importStar(require("crypto"));
46
47
  const query_string_1 = __importDefault(require("query-string"));
47
- const AGENT_REG = /\/v1\/aiagent\/agents\/([^\\]+)\/([^\\]+)/;
48
+ const AGENT_REG = /\/v1\/aiagent\/agents\/([^\/]+)\/(.+)/;
48
49
  function parseAgentId(url) {
49
50
  return parseUrl(url).agentId;
50
51
  }
@@ -67,7 +68,11 @@ function parseUrl(url) {
67
68
  if (!regResult) {
68
69
  throw new Error("Invalid pathname");
69
70
  }
70
- const [_, agentId, apiName] = regResult;
71
+ const [_, agentId, remainingPath] = regResult;
72
+ let apiName = remainingPath;
73
+ if (remainingPath.startsWith("query-tasks/")) {
74
+ apiName = "query-tasks";
75
+ }
71
76
  return { agentId, apiName };
72
77
  }
73
78
  function parseQueryFromCtx(ctx) {
@@ -82,6 +87,20 @@ function parseQueryFromCtx(ctx) {
82
87
  parseFragmentIdentifier: true,
83
88
  });
84
89
  }
90
+ function parseTaskIdFromPath(url) {
91
+ try {
92
+ const { pathname } = new URL(url);
93
+ const parts = pathname.split("/").filter(Boolean);
94
+ const agentsIdx = parts.findIndex((p) => p === "agents");
95
+ if (agentsIdx >= 0 && parts[agentsIdx + 2] === "query-tasks" && parts[agentsIdx + 3]) {
96
+ return parts[agentsIdx + 3];
97
+ }
98
+ return null;
99
+ }
100
+ catch (_a) {
101
+ return null;
102
+ }
103
+ }
85
104
  function genRecordId() {
86
105
  return "record-" + genRandomStr(8);
87
106
  }
package/package.json CHANGED
@@ -1,9 +1,8 @@
1
1
  {
2
2
  "name": "@vectorx/agent-runtime",
3
- "version": "0.1.3",
3
+ "version": "0.4.0",
4
4
  "description": "Cloud AI agent runtime",
5
5
  "main": "lib/index.js",
6
- "types": "types/index.d.ts",
7
6
  "files": [
8
7
  "lib",
9
8
  "types",
@@ -21,8 +20,9 @@
21
20
  "node": ">=18.0.0"
22
21
  },
23
22
  "dependencies": {
24
- "@vectorx/ai-sdk": "0.1.3",
25
- "@vectorx/functions-framework": "0.1.3",
23
+ "@vectorx/ai-sdk": "0.4.0",
24
+ "@vectorx/functions-framework": "0.4.0",
25
+ "langfuse": "^3.38.4",
26
26
  "query-string": "^6.14.1",
27
27
  "zod": "^3.24.2"
28
28
  },
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes