@aigne/core 1.64.0 → 1.65.0-beta

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/CHANGELOG.md CHANGED
@@ -1,5 +1,26 @@
1
1
  # Changelog
2
2
 
3
+ ## [1.65.0-beta](https://github.com/AIGNE-io/aigne-framework/compare/core-v1.64.1-beta...core-v1.65.0-beta) (2025-10-24)
4
+
5
+
6
+ ### Features
7
+
8
+ * **model:** support video model ([#647](https://github.com/AIGNE-io/aigne-framework/issues/647)) ([de81742](https://github.com/AIGNE-io/aigne-framework/commit/de817421ef1dd3246d0d8c51ff12f0a855658f9f))
9
+
10
+ ## [1.64.1-beta](https://github.com/AIGNE-io/aigne-framework/compare/core-v1.64.0...core-v1.64.1-beta) (2025-10-23)
11
+
12
+
13
+ ### Bug Fixes
14
+
15
+ * **models:** improve message structure handling and enable auto-message options ([#657](https://github.com/AIGNE-io/aigne-framework/issues/657)) ([233d70c](https://github.com/AIGNE-io/aigne-framework/commit/233d70cb292b937200fada8434f33d957d766ad6))
16
+
17
+
18
+ ### Dependencies
19
+
20
+ * The following workspace dependencies were updated
21
+ * dependencies
22
+ * @aigne/afs bumped to 1.1.1-beta
23
+
3
24
  ## [1.64.0](https://github.com/AIGNE-io/aigne-framework/compare/core-v1.64.0-beta.1...core-v1.64.0) (2025-10-22)
4
25
 
5
26
 
@@ -147,8 +147,8 @@ class AIAgent extends agent_js_1.Agent {
147
147
  typeof options.instructions === "string"
148
148
  ? prompt_builder_js_1.PromptBuilder.from(options.instructions)
149
149
  : (options.instructions ?? new prompt_builder_js_1.PromptBuilder());
150
- this.autoReorderSystemMessages = options.autoReorderSystemMessages ?? false;
151
- this.autoMergeSystemMessages = options.autoMergeSystemMessages ?? false;
150
+ this.autoReorderSystemMessages = options.autoReorderSystemMessages ?? true;
151
+ this.autoMergeSystemMessages = options.autoMergeSystemMessages ?? true;
152
152
  this.inputKey = options.inputKey;
153
153
  this.inputFileKey = options.inputFileKey;
154
154
  this.outputKey = options.outputKey || exports.DEFAULT_OUTPUT_KEY;
@@ -0,0 +1,174 @@
1
+ import { type ZodType, z } from "zod";
2
+ import type { PromiseOrValue } from "../utils/type-utils.js";
3
+ import type { AgentInvokeOptions, AgentOptions, AgentProcessResult, AgentResponse, AgentResponseStream, Message } from "./agent.js";
4
+ import { type ChatModelOutputUsage } from "./chat-model.js";
5
+ import { type FileType, type FileUnionContent, Model } from "./model.js";
6
+ export interface VideoModelOptions<I extends VideoModelInput = VideoModelInput, O extends VideoModelOutput = VideoModelOutput> extends Omit<AgentOptions<I, O>, "model"> {
7
+ model?: string;
8
+ }
9
+ export declare abstract class VideoModel<I extends VideoModelInput = VideoModelInput, O extends VideoModelOutput = VideoModelOutput> extends Model<I, O> {
10
+ options?: VideoModelOptions<I, O> | undefined;
11
+ tag: string;
12
+ constructor(options?: VideoModelOptions<I, O> | undefined);
13
+ get credential(): PromiseOrValue<{
14
+ url?: string;
15
+ apiKey?: string;
16
+ model?: string;
17
+ }>;
18
+ protected preprocess(input: I, options: AgentInvokeOptions): Promise<void>;
19
+ protected postprocess(input: I, output: O, options: AgentInvokeOptions): Promise<void>;
20
+ abstract process(input: I, options: AgentInvokeOptions): PromiseOrValue<AgentProcessResult<O>>;
21
+ protected processAgentOutput(input: I, output: Exclude<AgentResponse<O>, AgentResponseStream<O>>, options: AgentInvokeOptions): Promise<O>;
22
+ }
23
+ export interface VideoModelInput extends Message {
24
+ prompt: string;
25
+ model?: string;
26
+ size?: string;
27
+ seconds?: string;
28
+ outputFileType?: FileType;
29
+ }
30
+ export declare const videoModelInputSchema: z.ZodObject<{
31
+ prompt: z.ZodString;
32
+ model: z.ZodOptional<z.ZodString>;
33
+ size: z.ZodOptional<z.ZodString>;
34
+ seconds: z.ZodOptional<z.ZodString>;
35
+ outputFileType: z.ZodOptional<z.ZodEnum<["local", "file"]>>;
36
+ }, "strip", z.ZodTypeAny, {
37
+ prompt: string;
38
+ model?: string | undefined;
39
+ outputFileType?: "local" | "file" | undefined;
40
+ size?: string | undefined;
41
+ seconds?: string | undefined;
42
+ }, {
43
+ prompt: string;
44
+ model?: string | undefined;
45
+ outputFileType?: "local" | "file" | undefined;
46
+ size?: string | undefined;
47
+ seconds?: string | undefined;
48
+ }>;
49
+ export interface VideoModelOutput extends Message {
50
+ videos: FileUnionContent[];
51
+ /**
52
+ * Token usage statistics
53
+ */
54
+ usage?: ChatModelOutputUsage;
55
+ /**
56
+ * Model name or version used
57
+ */
58
+ model?: string;
59
+ seconds?: number;
60
+ }
61
+ export declare const videoModelOutputSchema: z.ZodObject<{
62
+ videos: z.ZodArray<z.ZodDiscriminatedUnion<"type", [z.ZodObject<{
63
+ filename: ZodType<string | undefined, z.ZodTypeDef, string | undefined>;
64
+ mimeType: ZodType<string | undefined, z.ZodTypeDef, string | undefined>;
65
+ } & {
66
+ type: z.ZodLiteral<"local">;
67
+ path: z.ZodString;
68
+ }, "strip", z.ZodTypeAny, {
69
+ path: string;
70
+ type: "local";
71
+ filename?: string | undefined;
72
+ mimeType?: string | undefined;
73
+ }, {
74
+ path: string;
75
+ type: "local";
76
+ filename?: string | undefined;
77
+ mimeType?: string | undefined;
78
+ }>, z.ZodObject<{
79
+ filename: ZodType<string | undefined, z.ZodTypeDef, string | undefined>;
80
+ mimeType: ZodType<string | undefined, z.ZodTypeDef, string | undefined>;
81
+ } & {
82
+ type: z.ZodLiteral<"url">;
83
+ url: z.ZodString;
84
+ }, "strip", z.ZodTypeAny, {
85
+ type: "url";
86
+ url: string;
87
+ filename?: string | undefined;
88
+ mimeType?: string | undefined;
89
+ }, {
90
+ type: "url";
91
+ url: string;
92
+ filename?: string | undefined;
93
+ mimeType?: string | undefined;
94
+ }>, z.ZodObject<{
95
+ filename: ZodType<string | undefined, z.ZodTypeDef, string | undefined>;
96
+ mimeType: ZodType<string | undefined, z.ZodTypeDef, string | undefined>;
97
+ } & {
98
+ type: z.ZodLiteral<"file">;
99
+ data: z.ZodString;
100
+ }, "strip", z.ZodTypeAny, {
101
+ type: "file";
102
+ data: string;
103
+ filename?: string | undefined;
104
+ mimeType?: string | undefined;
105
+ }, {
106
+ type: "file";
107
+ data: string;
108
+ filename?: string | undefined;
109
+ mimeType?: string | undefined;
110
+ }>]>, "many">;
111
+ usage: z.ZodOptional<z.ZodObject<{
112
+ inputTokens: z.ZodNumber;
113
+ outputTokens: z.ZodNumber;
114
+ aigneHubCredits: z.ZodOptional<z.ZodNumber>;
115
+ }, "strip", z.ZodTypeAny, {
116
+ inputTokens: number;
117
+ outputTokens: number;
118
+ aigneHubCredits?: number | undefined;
119
+ }, {
120
+ inputTokens: number;
121
+ outputTokens: number;
122
+ aigneHubCredits?: number | undefined;
123
+ }>>;
124
+ model: z.ZodOptional<z.ZodString>;
125
+ seconds: z.ZodOptional<z.ZodNumber>;
126
+ }, "strip", z.ZodTypeAny, {
127
+ videos: ({
128
+ type: "url";
129
+ url: string;
130
+ filename?: string | undefined;
131
+ mimeType?: string | undefined;
132
+ } | {
133
+ type: "file";
134
+ data: string;
135
+ filename?: string | undefined;
136
+ mimeType?: string | undefined;
137
+ } | {
138
+ path: string;
139
+ type: "local";
140
+ filename?: string | undefined;
141
+ mimeType?: string | undefined;
142
+ })[];
143
+ model?: string | undefined;
144
+ usage?: {
145
+ inputTokens: number;
146
+ outputTokens: number;
147
+ aigneHubCredits?: number | undefined;
148
+ } | undefined;
149
+ seconds?: number | undefined;
150
+ }, {
151
+ videos: ({
152
+ type: "url";
153
+ url: string;
154
+ filename?: string | undefined;
155
+ mimeType?: string | undefined;
156
+ } | {
157
+ type: "file";
158
+ data: string;
159
+ filename?: string | undefined;
160
+ mimeType?: string | undefined;
161
+ } | {
162
+ path: string;
163
+ type: "local";
164
+ filename?: string | undefined;
165
+ mimeType?: string | undefined;
166
+ })[];
167
+ model?: string | undefined;
168
+ usage?: {
169
+ inputTokens: number;
170
+ outputTokens: number;
171
+ aigneHubCredits?: number | undefined;
172
+ } | undefined;
173
+ seconds?: number | undefined;
174
+ }>;
@@ -0,0 +1,64 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.videoModelOutputSchema = exports.videoModelInputSchema = exports.VideoModel = void 0;
4
+ const zod_1 = require("zod");
5
+ const chat_model_js_1 = require("./chat-model.js");
6
+ const model_js_1 = require("./model.js");
7
+ class VideoModel extends model_js_1.Model {
8
+ options;
9
+ tag = "VideoModelAgent";
10
+ constructor(options) {
11
+ super({
12
+ inputSchema: exports.videoModelInputSchema,
13
+ outputSchema: exports.videoModelOutputSchema,
14
+ ...options,
15
+ model: undefined,
16
+ });
17
+ this.options = options;
18
+ }
19
+ get credential() {
20
+ return {};
21
+ }
22
+ async preprocess(input, options) {
23
+ super.preprocess(input, options);
24
+ const { limits, usage } = options.context;
25
+ const usedTokens = usage.outputTokens + usage.inputTokens;
26
+ if (limits?.maxTokens && usedTokens >= limits.maxTokens) {
27
+ throw new Error(`Exceeded max tokens ${usedTokens}/${limits.maxTokens}`);
28
+ }
29
+ }
30
+ async postprocess(input, output, options) {
31
+ super.postprocess(input, output, options);
32
+ const { usage } = output;
33
+ if (usage) {
34
+ options.context.usage.outputTokens += usage.outputTokens;
35
+ options.context.usage.inputTokens += usage.inputTokens;
36
+ if (usage.aigneHubCredits)
37
+ options.context.usage.aigneHubCredits += usage.aigneHubCredits;
38
+ }
39
+ }
40
+ async processAgentOutput(input, output, options) {
41
+ if (output.videos) {
42
+ const videos = zod_1.z.array(model_js_1.fileUnionContentSchema).parse(output.videos);
43
+ output = {
44
+ ...output,
45
+ videos: await Promise.all(videos.map((video) => this.transformFileType(input.outputFileType, video, options))),
46
+ };
47
+ }
48
+ return super.processAgentOutput(input, output, options);
49
+ }
50
+ }
51
+ exports.VideoModel = VideoModel;
52
+ exports.videoModelInputSchema = zod_1.z.object({
53
+ prompt: zod_1.z.string().describe("Text prompt describing the video to generate"),
54
+ model: zod_1.z.string().optional().describe("Model to use for video generation"),
55
+ size: zod_1.z.string().optional().describe("Size/resolution of the video"),
56
+ seconds: zod_1.z.string().optional().describe("Duration of the video in seconds"),
57
+ outputFileType: model_js_1.fileTypeSchema.optional(),
58
+ });
59
+ exports.videoModelOutputSchema = zod_1.z.object({
60
+ videos: zod_1.z.array(model_js_1.fileUnionContentSchema),
61
+ usage: chat_model_js_1.chatModelOutputUsageSchema.optional(),
62
+ model: zod_1.z.string().optional(),
63
+ seconds: zod_1.z.number().optional(),
64
+ });
@@ -10,6 +10,7 @@ export * from "./agents/team-agent.js";
10
10
  export * from "./agents/transform-agent.js";
11
11
  export * from "./agents/types.js";
12
12
  export * from "./agents/user-agent.js";
13
+ export * from "./agents/video-model.js";
13
14
  export * from "./aigne/index.js";
14
15
  export * from "./memory/index.js";
15
16
  export * from "./prompt/prompt-builder.js";
package/lib/cjs/index.js CHANGED
@@ -26,6 +26,7 @@ __exportStar(require("./agents/team-agent.js"), exports);
26
26
  __exportStar(require("./agents/transform-agent.js"), exports);
27
27
  __exportStar(require("./agents/types.js"), exports);
28
28
  __exportStar(require("./agents/user-agent.js"), exports);
29
+ __exportStar(require("./agents/video-model.js"), exports);
29
30
  __exportStar(require("./aigne/index.js"), exports);
30
31
  __exportStar(require("./memory/index.js"), exports);
31
32
  __exportStar(require("./prompt/prompt-builder.js"), exports);
@@ -0,0 +1,174 @@
1
+ import { type ZodType, z } from "zod";
2
+ import type { PromiseOrValue } from "../utils/type-utils.js";
3
+ import type { AgentInvokeOptions, AgentOptions, AgentProcessResult, AgentResponse, AgentResponseStream, Message } from "./agent.js";
4
+ import { type ChatModelOutputUsage } from "./chat-model.js";
5
+ import { type FileType, type FileUnionContent, Model } from "./model.js";
6
+ export interface VideoModelOptions<I extends VideoModelInput = VideoModelInput, O extends VideoModelOutput = VideoModelOutput> extends Omit<AgentOptions<I, O>, "model"> {
7
+ model?: string;
8
+ }
9
+ export declare abstract class VideoModel<I extends VideoModelInput = VideoModelInput, O extends VideoModelOutput = VideoModelOutput> extends Model<I, O> {
10
+ options?: VideoModelOptions<I, O> | undefined;
11
+ tag: string;
12
+ constructor(options?: VideoModelOptions<I, O> | undefined);
13
+ get credential(): PromiseOrValue<{
14
+ url?: string;
15
+ apiKey?: string;
16
+ model?: string;
17
+ }>;
18
+ protected preprocess(input: I, options: AgentInvokeOptions): Promise<void>;
19
+ protected postprocess(input: I, output: O, options: AgentInvokeOptions): Promise<void>;
20
+ abstract process(input: I, options: AgentInvokeOptions): PromiseOrValue<AgentProcessResult<O>>;
21
+ protected processAgentOutput(input: I, output: Exclude<AgentResponse<O>, AgentResponseStream<O>>, options: AgentInvokeOptions): Promise<O>;
22
+ }
23
+ export interface VideoModelInput extends Message {
24
+ prompt: string;
25
+ model?: string;
26
+ size?: string;
27
+ seconds?: string;
28
+ outputFileType?: FileType;
29
+ }
30
+ export declare const videoModelInputSchema: z.ZodObject<{
31
+ prompt: z.ZodString;
32
+ model: z.ZodOptional<z.ZodString>;
33
+ size: z.ZodOptional<z.ZodString>;
34
+ seconds: z.ZodOptional<z.ZodString>;
35
+ outputFileType: z.ZodOptional<z.ZodEnum<["local", "file"]>>;
36
+ }, "strip", z.ZodTypeAny, {
37
+ prompt: string;
38
+ model?: string | undefined;
39
+ outputFileType?: "local" | "file" | undefined;
40
+ size?: string | undefined;
41
+ seconds?: string | undefined;
42
+ }, {
43
+ prompt: string;
44
+ model?: string | undefined;
45
+ outputFileType?: "local" | "file" | undefined;
46
+ size?: string | undefined;
47
+ seconds?: string | undefined;
48
+ }>;
49
+ export interface VideoModelOutput extends Message {
50
+ videos: FileUnionContent[];
51
+ /**
52
+ * Token usage statistics
53
+ */
54
+ usage?: ChatModelOutputUsage;
55
+ /**
56
+ * Model name or version used
57
+ */
58
+ model?: string;
59
+ seconds?: number;
60
+ }
61
+ export declare const videoModelOutputSchema: z.ZodObject<{
62
+ videos: z.ZodArray<z.ZodDiscriminatedUnion<"type", [z.ZodObject<{
63
+ filename: ZodType<string | undefined, z.ZodTypeDef, string | undefined>;
64
+ mimeType: ZodType<string | undefined, z.ZodTypeDef, string | undefined>;
65
+ } & {
66
+ type: z.ZodLiteral<"local">;
67
+ path: z.ZodString;
68
+ }, "strip", z.ZodTypeAny, {
69
+ path: string;
70
+ type: "local";
71
+ filename?: string | undefined;
72
+ mimeType?: string | undefined;
73
+ }, {
74
+ path: string;
75
+ type: "local";
76
+ filename?: string | undefined;
77
+ mimeType?: string | undefined;
78
+ }>, z.ZodObject<{
79
+ filename: ZodType<string | undefined, z.ZodTypeDef, string | undefined>;
80
+ mimeType: ZodType<string | undefined, z.ZodTypeDef, string | undefined>;
81
+ } & {
82
+ type: z.ZodLiteral<"url">;
83
+ url: z.ZodString;
84
+ }, "strip", z.ZodTypeAny, {
85
+ type: "url";
86
+ url: string;
87
+ filename?: string | undefined;
88
+ mimeType?: string | undefined;
89
+ }, {
90
+ type: "url";
91
+ url: string;
92
+ filename?: string | undefined;
93
+ mimeType?: string | undefined;
94
+ }>, z.ZodObject<{
95
+ filename: ZodType<string | undefined, z.ZodTypeDef, string | undefined>;
96
+ mimeType: ZodType<string | undefined, z.ZodTypeDef, string | undefined>;
97
+ } & {
98
+ type: z.ZodLiteral<"file">;
99
+ data: z.ZodString;
100
+ }, "strip", z.ZodTypeAny, {
101
+ type: "file";
102
+ data: string;
103
+ filename?: string | undefined;
104
+ mimeType?: string | undefined;
105
+ }, {
106
+ type: "file";
107
+ data: string;
108
+ filename?: string | undefined;
109
+ mimeType?: string | undefined;
110
+ }>]>, "many">;
111
+ usage: z.ZodOptional<z.ZodObject<{
112
+ inputTokens: z.ZodNumber;
113
+ outputTokens: z.ZodNumber;
114
+ aigneHubCredits: z.ZodOptional<z.ZodNumber>;
115
+ }, "strip", z.ZodTypeAny, {
116
+ inputTokens: number;
117
+ outputTokens: number;
118
+ aigneHubCredits?: number | undefined;
119
+ }, {
120
+ inputTokens: number;
121
+ outputTokens: number;
122
+ aigneHubCredits?: number | undefined;
123
+ }>>;
124
+ model: z.ZodOptional<z.ZodString>;
125
+ seconds: z.ZodOptional<z.ZodNumber>;
126
+ }, "strip", z.ZodTypeAny, {
127
+ videos: ({
128
+ type: "url";
129
+ url: string;
130
+ filename?: string | undefined;
131
+ mimeType?: string | undefined;
132
+ } | {
133
+ type: "file";
134
+ data: string;
135
+ filename?: string | undefined;
136
+ mimeType?: string | undefined;
137
+ } | {
138
+ path: string;
139
+ type: "local";
140
+ filename?: string | undefined;
141
+ mimeType?: string | undefined;
142
+ })[];
143
+ model?: string | undefined;
144
+ usage?: {
145
+ inputTokens: number;
146
+ outputTokens: number;
147
+ aigneHubCredits?: number | undefined;
148
+ } | undefined;
149
+ seconds?: number | undefined;
150
+ }, {
151
+ videos: ({
152
+ type: "url";
153
+ url: string;
154
+ filename?: string | undefined;
155
+ mimeType?: string | undefined;
156
+ } | {
157
+ type: "file";
158
+ data: string;
159
+ filename?: string | undefined;
160
+ mimeType?: string | undefined;
161
+ } | {
162
+ path: string;
163
+ type: "local";
164
+ filename?: string | undefined;
165
+ mimeType?: string | undefined;
166
+ })[];
167
+ model?: string | undefined;
168
+ usage?: {
169
+ inputTokens: number;
170
+ outputTokens: number;
171
+ aigneHubCredits?: number | undefined;
172
+ } | undefined;
173
+ seconds?: number | undefined;
174
+ }>;
@@ -10,6 +10,7 @@ export * from "./agents/team-agent.js";
10
10
  export * from "./agents/transform-agent.js";
11
11
  export * from "./agents/types.js";
12
12
  export * from "./agents/user-agent.js";
13
+ export * from "./agents/video-model.js";
13
14
  export * from "./aigne/index.js";
14
15
  export * from "./memory/index.js";
15
16
  export * from "./prompt/prompt-builder.js";
@@ -111,8 +111,8 @@ export class AIAgent extends Agent {
111
111
  typeof options.instructions === "string"
112
112
  ? PromptBuilder.from(options.instructions)
113
113
  : (options.instructions ?? new PromptBuilder());
114
- this.autoReorderSystemMessages = options.autoReorderSystemMessages ?? false;
115
- this.autoMergeSystemMessages = options.autoMergeSystemMessages ?? false;
114
+ this.autoReorderSystemMessages = options.autoReorderSystemMessages ?? true;
115
+ this.autoMergeSystemMessages = options.autoMergeSystemMessages ?? true;
116
116
  this.inputKey = options.inputKey;
117
117
  this.inputFileKey = options.inputFileKey;
118
118
  this.outputKey = options.outputKey || DEFAULT_OUTPUT_KEY;
@@ -0,0 +1,174 @@
1
+ import { type ZodType, z } from "zod";
2
+ import type { PromiseOrValue } from "../utils/type-utils.js";
3
+ import type { AgentInvokeOptions, AgentOptions, AgentProcessResult, AgentResponse, AgentResponseStream, Message } from "./agent.js";
4
+ import { type ChatModelOutputUsage } from "./chat-model.js";
5
+ import { type FileType, type FileUnionContent, Model } from "./model.js";
6
+ export interface VideoModelOptions<I extends VideoModelInput = VideoModelInput, O extends VideoModelOutput = VideoModelOutput> extends Omit<AgentOptions<I, O>, "model"> {
7
+ model?: string;
8
+ }
9
+ export declare abstract class VideoModel<I extends VideoModelInput = VideoModelInput, O extends VideoModelOutput = VideoModelOutput> extends Model<I, O> {
10
+ options?: VideoModelOptions<I, O> | undefined;
11
+ tag: string;
12
+ constructor(options?: VideoModelOptions<I, O> | undefined);
13
+ get credential(): PromiseOrValue<{
14
+ url?: string;
15
+ apiKey?: string;
16
+ model?: string;
17
+ }>;
18
+ protected preprocess(input: I, options: AgentInvokeOptions): Promise<void>;
19
+ protected postprocess(input: I, output: O, options: AgentInvokeOptions): Promise<void>;
20
+ abstract process(input: I, options: AgentInvokeOptions): PromiseOrValue<AgentProcessResult<O>>;
21
+ protected processAgentOutput(input: I, output: Exclude<AgentResponse<O>, AgentResponseStream<O>>, options: AgentInvokeOptions): Promise<O>;
22
+ }
23
+ export interface VideoModelInput extends Message {
24
+ prompt: string;
25
+ model?: string;
26
+ size?: string;
27
+ seconds?: string;
28
+ outputFileType?: FileType;
29
+ }
30
+ export declare const videoModelInputSchema: z.ZodObject<{
31
+ prompt: z.ZodString;
32
+ model: z.ZodOptional<z.ZodString>;
33
+ size: z.ZodOptional<z.ZodString>;
34
+ seconds: z.ZodOptional<z.ZodString>;
35
+ outputFileType: z.ZodOptional<z.ZodEnum<["local", "file"]>>;
36
+ }, "strip", z.ZodTypeAny, {
37
+ prompt: string;
38
+ model?: string | undefined;
39
+ outputFileType?: "local" | "file" | undefined;
40
+ size?: string | undefined;
41
+ seconds?: string | undefined;
42
+ }, {
43
+ prompt: string;
44
+ model?: string | undefined;
45
+ outputFileType?: "local" | "file" | undefined;
46
+ size?: string | undefined;
47
+ seconds?: string | undefined;
48
+ }>;
49
+ export interface VideoModelOutput extends Message {
50
+ videos: FileUnionContent[];
51
+ /**
52
+ * Token usage statistics
53
+ */
54
+ usage?: ChatModelOutputUsage;
55
+ /**
56
+ * Model name or version used
57
+ */
58
+ model?: string;
59
+ seconds?: number;
60
+ }
61
+ export declare const videoModelOutputSchema: z.ZodObject<{
62
+ videos: z.ZodArray<z.ZodDiscriminatedUnion<"type", [z.ZodObject<{
63
+ filename: ZodType<string | undefined, z.ZodTypeDef, string | undefined>;
64
+ mimeType: ZodType<string | undefined, z.ZodTypeDef, string | undefined>;
65
+ } & {
66
+ type: z.ZodLiteral<"local">;
67
+ path: z.ZodString;
68
+ }, "strip", z.ZodTypeAny, {
69
+ path: string;
70
+ type: "local";
71
+ filename?: string | undefined;
72
+ mimeType?: string | undefined;
73
+ }, {
74
+ path: string;
75
+ type: "local";
76
+ filename?: string | undefined;
77
+ mimeType?: string | undefined;
78
+ }>, z.ZodObject<{
79
+ filename: ZodType<string | undefined, z.ZodTypeDef, string | undefined>;
80
+ mimeType: ZodType<string | undefined, z.ZodTypeDef, string | undefined>;
81
+ } & {
82
+ type: z.ZodLiteral<"url">;
83
+ url: z.ZodString;
84
+ }, "strip", z.ZodTypeAny, {
85
+ type: "url";
86
+ url: string;
87
+ filename?: string | undefined;
88
+ mimeType?: string | undefined;
89
+ }, {
90
+ type: "url";
91
+ url: string;
92
+ filename?: string | undefined;
93
+ mimeType?: string | undefined;
94
+ }>, z.ZodObject<{
95
+ filename: ZodType<string | undefined, z.ZodTypeDef, string | undefined>;
96
+ mimeType: ZodType<string | undefined, z.ZodTypeDef, string | undefined>;
97
+ } & {
98
+ type: z.ZodLiteral<"file">;
99
+ data: z.ZodString;
100
+ }, "strip", z.ZodTypeAny, {
101
+ type: "file";
102
+ data: string;
103
+ filename?: string | undefined;
104
+ mimeType?: string | undefined;
105
+ }, {
106
+ type: "file";
107
+ data: string;
108
+ filename?: string | undefined;
109
+ mimeType?: string | undefined;
110
+ }>]>, "many">;
111
+ usage: z.ZodOptional<z.ZodObject<{
112
+ inputTokens: z.ZodNumber;
113
+ outputTokens: z.ZodNumber;
114
+ aigneHubCredits: z.ZodOptional<z.ZodNumber>;
115
+ }, "strip", z.ZodTypeAny, {
116
+ inputTokens: number;
117
+ outputTokens: number;
118
+ aigneHubCredits?: number | undefined;
119
+ }, {
120
+ inputTokens: number;
121
+ outputTokens: number;
122
+ aigneHubCredits?: number | undefined;
123
+ }>>;
124
+ model: z.ZodOptional<z.ZodString>;
125
+ seconds: z.ZodOptional<z.ZodNumber>;
126
+ }, "strip", z.ZodTypeAny, {
127
+ videos: ({
128
+ type: "url";
129
+ url: string;
130
+ filename?: string | undefined;
131
+ mimeType?: string | undefined;
132
+ } | {
133
+ type: "file";
134
+ data: string;
135
+ filename?: string | undefined;
136
+ mimeType?: string | undefined;
137
+ } | {
138
+ path: string;
139
+ type: "local";
140
+ filename?: string | undefined;
141
+ mimeType?: string | undefined;
142
+ })[];
143
+ model?: string | undefined;
144
+ usage?: {
145
+ inputTokens: number;
146
+ outputTokens: number;
147
+ aigneHubCredits?: number | undefined;
148
+ } | undefined;
149
+ seconds?: number | undefined;
150
+ }, {
151
+ videos: ({
152
+ type: "url";
153
+ url: string;
154
+ filename?: string | undefined;
155
+ mimeType?: string | undefined;
156
+ } | {
157
+ type: "file";
158
+ data: string;
159
+ filename?: string | undefined;
160
+ mimeType?: string | undefined;
161
+ } | {
162
+ path: string;
163
+ type: "local";
164
+ filename?: string | undefined;
165
+ mimeType?: string | undefined;
166
+ })[];
167
+ model?: string | undefined;
168
+ usage?: {
169
+ inputTokens: number;
170
+ outputTokens: number;
171
+ aigneHubCredits?: number | undefined;
172
+ } | undefined;
173
+ seconds?: number | undefined;
174
+ }>;
@@ -0,0 +1,60 @@
1
+ import { z } from "zod";
2
+ import { chatModelOutputUsageSchema } from "./chat-model.js";
3
+ import { fileTypeSchema, fileUnionContentSchema, Model, } from "./model.js";
4
+ export class VideoModel extends Model {
5
+ options;
6
+ tag = "VideoModelAgent";
7
+ constructor(options) {
8
+ super({
9
+ inputSchema: videoModelInputSchema,
10
+ outputSchema: videoModelOutputSchema,
11
+ ...options,
12
+ model: undefined,
13
+ });
14
+ this.options = options;
15
+ }
16
+ get credential() {
17
+ return {};
18
+ }
19
+ async preprocess(input, options) {
20
+ super.preprocess(input, options);
21
+ const { limits, usage } = options.context;
22
+ const usedTokens = usage.outputTokens + usage.inputTokens;
23
+ if (limits?.maxTokens && usedTokens >= limits.maxTokens) {
24
+ throw new Error(`Exceeded max tokens ${usedTokens}/${limits.maxTokens}`);
25
+ }
26
+ }
27
+ async postprocess(input, output, options) {
28
+ super.postprocess(input, output, options);
29
+ const { usage } = output;
30
+ if (usage) {
31
+ options.context.usage.outputTokens += usage.outputTokens;
32
+ options.context.usage.inputTokens += usage.inputTokens;
33
+ if (usage.aigneHubCredits)
34
+ options.context.usage.aigneHubCredits += usage.aigneHubCredits;
35
+ }
36
+ }
37
+ async processAgentOutput(input, output, options) {
38
+ if (output.videos) {
39
+ const videos = z.array(fileUnionContentSchema).parse(output.videos);
40
+ output = {
41
+ ...output,
42
+ videos: await Promise.all(videos.map((video) => this.transformFileType(input.outputFileType, video, options))),
43
+ };
44
+ }
45
+ return super.processAgentOutput(input, output, options);
46
+ }
47
+ }
48
+ export const videoModelInputSchema = z.object({
49
+ prompt: z.string().describe("Text prompt describing the video to generate"),
50
+ model: z.string().optional().describe("Model to use for video generation"),
51
+ size: z.string().optional().describe("Size/resolution of the video"),
52
+ seconds: z.string().optional().describe("Duration of the video in seconds"),
53
+ outputFileType: fileTypeSchema.optional(),
54
+ });
55
+ export const videoModelOutputSchema = z.object({
56
+ videos: z.array(fileUnionContentSchema),
57
+ usage: chatModelOutputUsageSchema.optional(),
58
+ model: z.string().optional(),
59
+ seconds: z.number().optional(),
60
+ });
@@ -10,6 +10,7 @@ export * from "./agents/team-agent.js";
10
10
  export * from "./agents/transform-agent.js";
11
11
  export * from "./agents/types.js";
12
12
  export * from "./agents/user-agent.js";
13
+ export * from "./agents/video-model.js";
13
14
  export * from "./aigne/index.js";
14
15
  export * from "./memory/index.js";
15
16
  export * from "./prompt/prompt-builder.js";
package/lib/esm/index.js CHANGED
@@ -10,6 +10,7 @@ export * from "./agents/team-agent.js";
10
10
  export * from "./agents/transform-agent.js";
11
11
  export * from "./agents/types.js";
12
12
  export * from "./agents/user-agent.js";
13
+ export * from "./agents/video-model.js";
13
14
  export * from "./aigne/index.js";
14
15
  export * from "./memory/index.js";
15
16
  export * from "./prompt/prompt-builder.js";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aigne/core",
3
- "version": "1.64.0",
3
+ "version": "1.65.0-beta",
4
4
  "description": "The functional core of agentic AI",
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -91,9 +91,9 @@
91
91
  "zod": "^3.25.67",
92
92
  "zod-from-json-schema": "^0.0.5",
93
93
  "zod-to-json-schema": "^3.24.6",
94
+ "@aigne/afs": "^1.1.1-beta",
94
95
  "@aigne/observability-api": "^0.11.3",
95
- "@aigne/platform-helpers": "^0.6.3",
96
- "@aigne/afs": "^1.1.0"
96
+ "@aigne/platform-helpers": "^0.6.3"
97
97
  },
98
98
  "devDependencies": {
99
99
  "@types/bun": "^1.2.22",