@aigne/core 1.72.0-beta.2 → 1.72.0-beta.4
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 +34 -0
- package/lib/cjs/agents/agent.d.ts +31 -1
- package/lib/cjs/agents/agent.js +13 -0
- package/lib/cjs/agents/ai-agent.d.ts +7 -0
- package/lib/cjs/agents/ai-agent.js +85 -3
- package/lib/cjs/agents/chat-model.d.ts +153 -0
- package/lib/cjs/agents/chat-model.js +35 -1
- package/lib/cjs/agents/image-agent.d.ts +17 -1
- package/lib/cjs/agents/image-agent.js +16 -0
- package/lib/cjs/agents/image-model.d.ts +14 -4
- package/lib/cjs/agents/mcp-agent.d.ts +17 -0
- package/lib/cjs/agents/mcp-agent.js +18 -0
- package/lib/cjs/agents/team-agent.d.ts +55 -0
- package/lib/cjs/agents/team-agent.js +31 -0
- package/lib/cjs/agents/transform-agent.d.ts +12 -0
- package/lib/cjs/agents/transform-agent.js +13 -0
- package/lib/cjs/agents/video-model.d.ts +14 -4
- package/lib/cjs/aigne/usage.d.ts +4 -0
- package/lib/cjs/aigne/usage.js +6 -0
- package/lib/cjs/loader/agent-yaml.d.ts +5 -63
- package/lib/cjs/loader/agent-yaml.js +4 -129
- package/lib/cjs/loader/agents.d.ts +4 -0
- package/lib/cjs/loader/agents.js +17 -0
- package/lib/cjs/loader/index.d.ts +18 -14
- package/lib/cjs/loader/index.js +20 -81
- package/lib/cjs/loader/schema.d.ts +21 -6
- package/lib/cjs/loader/schema.js +60 -1
- package/lib/cjs/prompt/prompt-builder.js +0 -1
- package/lib/cjs/prompt/skills/afs/agent-skill/agent-skill.d.ts +17 -0
- package/lib/cjs/prompt/skills/afs/agent-skill/agent-skill.js +63 -0
- package/lib/cjs/prompt/skills/afs/agent-skill/skill-loader.d.ts +13 -0
- package/lib/cjs/prompt/skills/afs/agent-skill/skill-loader.js +61 -0
- package/lib/cjs/prompt/skills/afs/delete.js +15 -3
- package/lib/cjs/prompt/skills/afs/edit.js +30 -7
- package/lib/cjs/prompt/skills/afs/exec.js +17 -6
- package/lib/cjs/prompt/skills/afs/index.js +4 -1
- package/lib/cjs/prompt/skills/afs/list.js +26 -10
- package/lib/cjs/prompt/skills/afs/read.js +14 -3
- package/lib/cjs/prompt/skills/afs/rename.js +18 -4
- package/lib/cjs/prompt/skills/afs/search.js +21 -5
- package/lib/cjs/prompt/skills/afs/write.js +18 -4
- package/lib/cjs/prompt/template.d.ts +92 -17
- package/lib/cjs/prompt/template.js +46 -17
- package/lib/dts/agents/agent.d.ts +31 -1
- package/lib/dts/agents/ai-agent.d.ts +7 -0
- package/lib/dts/agents/chat-model.d.ts +153 -0
- package/lib/dts/agents/image-agent.d.ts +17 -1
- package/lib/dts/agents/image-model.d.ts +14 -4
- package/lib/dts/agents/mcp-agent.d.ts +17 -0
- package/lib/dts/agents/team-agent.d.ts +55 -0
- package/lib/dts/agents/transform-agent.d.ts +12 -0
- package/lib/dts/agents/video-model.d.ts +14 -4
- package/lib/dts/aigne/context.d.ts +2 -2
- package/lib/dts/aigne/usage.d.ts +4 -0
- package/lib/dts/loader/agent-yaml.d.ts +5 -63
- package/lib/dts/loader/agents.d.ts +4 -0
- package/lib/dts/loader/index.d.ts +18 -14
- package/lib/dts/loader/schema.d.ts +21 -6
- package/lib/dts/prompt/skills/afs/agent-skill/agent-skill.d.ts +17 -0
- package/lib/dts/prompt/skills/afs/agent-skill/skill-loader.d.ts +13 -0
- package/lib/dts/prompt/template.d.ts +92 -17
- package/lib/esm/agents/agent.d.ts +31 -1
- package/lib/esm/agents/agent.js +13 -0
- package/lib/esm/agents/ai-agent.d.ts +7 -0
- package/lib/esm/agents/ai-agent.js +85 -3
- package/lib/esm/agents/chat-model.d.ts +153 -0
- package/lib/esm/agents/chat-model.js +34 -0
- package/lib/esm/agents/image-agent.d.ts +17 -1
- package/lib/esm/agents/image-agent.js +16 -0
- package/lib/esm/agents/image-model.d.ts +14 -4
- package/lib/esm/agents/mcp-agent.d.ts +17 -0
- package/lib/esm/agents/mcp-agent.js +18 -0
- package/lib/esm/agents/team-agent.d.ts +55 -0
- package/lib/esm/agents/team-agent.js +31 -0
- package/lib/esm/agents/transform-agent.d.ts +12 -0
- package/lib/esm/agents/transform-agent.js +13 -0
- package/lib/esm/agents/video-model.d.ts +14 -4
- package/lib/esm/aigne/context.d.ts +2 -2
- package/lib/esm/aigne/usage.d.ts +4 -0
- package/lib/esm/aigne/usage.js +6 -0
- package/lib/esm/loader/agent-yaml.d.ts +5 -63
- package/lib/esm/loader/agent-yaml.js +4 -128
- package/lib/esm/loader/agents.d.ts +4 -0
- package/lib/esm/loader/agents.js +14 -0
- package/lib/esm/loader/index.d.ts +18 -14
- package/lib/esm/loader/index.js +21 -81
- package/lib/esm/loader/schema.d.ts +21 -6
- package/lib/esm/loader/schema.js +57 -0
- package/lib/esm/prompt/prompt-builder.js +1 -2
- package/lib/esm/prompt/skills/afs/agent-skill/agent-skill.d.ts +17 -0
- package/lib/esm/prompt/skills/afs/agent-skill/agent-skill.js +59 -0
- package/lib/esm/prompt/skills/afs/agent-skill/skill-loader.d.ts +13 -0
- package/lib/esm/prompt/skills/afs/agent-skill/skill-loader.js +53 -0
- package/lib/esm/prompt/skills/afs/delete.js +15 -3
- package/lib/esm/prompt/skills/afs/edit.js +30 -7
- package/lib/esm/prompt/skills/afs/exec.js +17 -6
- package/lib/esm/prompt/skills/afs/index.js +4 -1
- package/lib/esm/prompt/skills/afs/list.js +26 -10
- package/lib/esm/prompt/skills/afs/read.js +14 -3
- package/lib/esm/prompt/skills/afs/rename.js +18 -4
- package/lib/esm/prompt/skills/afs/search.js +21 -5
- package/lib/esm/prompt/skills/afs/write.js +18 -4
- package/lib/esm/prompt/template.d.ts +92 -17
- package/lib/esm/prompt/template.js +46 -17
- package/package.json +5 -4
|
@@ -91,6 +91,7 @@ export declare const imageModelInputSchema: z.ZodObject<{
|
|
|
91
91
|
}, "strip", z.ZodTypeAny, {
|
|
92
92
|
prompt: string;
|
|
93
93
|
modelOptions?: Record<string, unknown> | undefined;
|
|
94
|
+
outputFileType?: "local" | "url" | "file" | undefined;
|
|
94
95
|
image?: ({
|
|
95
96
|
type: "url";
|
|
96
97
|
url: string;
|
|
@@ -107,11 +108,11 @@ export declare const imageModelInputSchema: z.ZodObject<{
|
|
|
107
108
|
filename?: string | undefined;
|
|
108
109
|
mimeType?: string | undefined;
|
|
109
110
|
})[] | undefined;
|
|
110
|
-
outputFileType?: "local" | "file" | "url" | undefined;
|
|
111
111
|
n?: number | undefined;
|
|
112
112
|
}, {
|
|
113
113
|
prompt: string;
|
|
114
114
|
modelOptions?: Record<string, unknown> | undefined;
|
|
115
|
+
outputFileType?: "local" | "url" | "file" | undefined;
|
|
115
116
|
image?: ({
|
|
116
117
|
type: "url";
|
|
117
118
|
url: string;
|
|
@@ -128,7 +129,6 @@ export declare const imageModelInputSchema: z.ZodObject<{
|
|
|
128
129
|
filename?: string | undefined;
|
|
129
130
|
mimeType?: string | undefined;
|
|
130
131
|
})[] | undefined;
|
|
131
|
-
outputFileType?: "local" | "file" | "url" | undefined;
|
|
132
132
|
n?: number | undefined;
|
|
133
133
|
}>;
|
|
134
134
|
export interface ImageModelOutput extends Message {
|
|
@@ -196,16 +196,22 @@ export declare const imageModelOutputSchema: z.ZodObject<{
|
|
|
196
196
|
inputTokens: z.ZodNumber;
|
|
197
197
|
outputTokens: z.ZodNumber;
|
|
198
198
|
aigneHubCredits: ZodType<number | undefined, z.ZodTypeDef, number | undefined>;
|
|
199
|
+
cacheCreationInputTokens: ZodType<number | undefined, z.ZodTypeDef, number | undefined>;
|
|
200
|
+
cacheReadInputTokens: ZodType<number | undefined, z.ZodTypeDef, number | undefined>;
|
|
199
201
|
creditPrefix: ZodType<"$" | "€" | "¥" | undefined, z.ZodTypeDef, "$" | "€" | "¥" | undefined>;
|
|
200
202
|
}, "strip", z.ZodTypeAny, {
|
|
201
203
|
inputTokens: number;
|
|
202
204
|
outputTokens: number;
|
|
203
205
|
aigneHubCredits?: number | undefined;
|
|
206
|
+
cacheCreationInputTokens?: number | undefined;
|
|
207
|
+
cacheReadInputTokens?: number | undefined;
|
|
204
208
|
creditPrefix?: "$" | "€" | "¥" | undefined;
|
|
205
209
|
}, {
|
|
206
210
|
inputTokens: number;
|
|
207
211
|
outputTokens: number;
|
|
208
212
|
aigneHubCredits?: number | undefined;
|
|
213
|
+
cacheCreationInputTokens?: number | undefined;
|
|
214
|
+
cacheReadInputTokens?: number | undefined;
|
|
209
215
|
creditPrefix?: "$" | "€" | "¥" | undefined;
|
|
210
216
|
}>>;
|
|
211
217
|
model: z.ZodOptional<z.ZodString>;
|
|
@@ -226,13 +232,15 @@ export declare const imageModelOutputSchema: z.ZodObject<{
|
|
|
226
232
|
filename?: string | undefined;
|
|
227
233
|
mimeType?: string | undefined;
|
|
228
234
|
})[];
|
|
229
|
-
model?: string | undefined;
|
|
230
235
|
usage?: {
|
|
231
236
|
inputTokens: number;
|
|
232
237
|
outputTokens: number;
|
|
233
238
|
aigneHubCredits?: number | undefined;
|
|
239
|
+
cacheCreationInputTokens?: number | undefined;
|
|
240
|
+
cacheReadInputTokens?: number | undefined;
|
|
234
241
|
creditPrefix?: "$" | "€" | "¥" | undefined;
|
|
235
242
|
} | undefined;
|
|
243
|
+
model?: string | undefined;
|
|
236
244
|
}, {
|
|
237
245
|
images: ({
|
|
238
246
|
type: "url";
|
|
@@ -250,11 +258,13 @@ export declare const imageModelOutputSchema: z.ZodObject<{
|
|
|
250
258
|
filename?: string | undefined;
|
|
251
259
|
mimeType?: string | undefined;
|
|
252
260
|
})[];
|
|
253
|
-
model?: string | undefined;
|
|
254
261
|
usage?: {
|
|
255
262
|
inputTokens: number;
|
|
256
263
|
outputTokens: number;
|
|
257
264
|
aigneHubCredits?: number | undefined;
|
|
265
|
+
cacheCreationInputTokens?: number | undefined;
|
|
266
|
+
cacheReadInputTokens?: number | undefined;
|
|
258
267
|
creditPrefix?: "$" | "€" | "¥" | undefined;
|
|
259
268
|
} | undefined;
|
|
269
|
+
model?: string | undefined;
|
|
260
270
|
}>;
|
|
@@ -58,6 +58,23 @@ export type SSEServerParameters = {
|
|
|
58
58
|
*/
|
|
59
59
|
export declare class MCPAgent extends Agent {
|
|
60
60
|
tag: string;
|
|
61
|
+
static schema(): z.ZodObject<{
|
|
62
|
+
url: ZodType<string | undefined, z.ZodTypeDef, string | undefined>;
|
|
63
|
+
command: ZodType<string | undefined, z.ZodTypeDef, string | undefined>;
|
|
64
|
+
args: ZodType<string[] | undefined, z.ZodTypeDef, string[] | undefined>;
|
|
65
|
+
}, "strip", z.ZodTypeAny, {
|
|
66
|
+
url?: string | undefined;
|
|
67
|
+
args?: string[] | undefined;
|
|
68
|
+
command?: string | undefined;
|
|
69
|
+
}, {
|
|
70
|
+
url?: string | undefined;
|
|
71
|
+
args?: string[] | undefined;
|
|
72
|
+
command?: string | undefined;
|
|
73
|
+
}>;
|
|
74
|
+
static load<I extends Message = any, O extends Message = any>(options: {
|
|
75
|
+
filepath: string;
|
|
76
|
+
parsed: object;
|
|
77
|
+
}): Promise<Agent<I, O>>;
|
|
61
78
|
/**
|
|
62
79
|
* Create an MCPAgent from a connection to an SSE server.
|
|
63
80
|
*
|
|
@@ -41,6 +41,7 @@ const sse_js_1 = require("@modelcontextprotocol/sdk/client/sse.js");
|
|
|
41
41
|
const streamableHttp_js_1 = require("@modelcontextprotocol/sdk/client/streamableHttp.js");
|
|
42
42
|
const uriTemplate_js_1 = require("@modelcontextprotocol/sdk/shared/uriTemplate.js");
|
|
43
43
|
const zod_1 = require("zod");
|
|
44
|
+
const schema_js_1 = require("../loader/schema.js");
|
|
44
45
|
const logger_js_1 = require("../utils/logger.js");
|
|
45
46
|
const mcp_utils_js_1 = require("../utils/mcp-utils.js");
|
|
46
47
|
const type_utils_js_1 = require("../utils/type-utils.js");
|
|
@@ -85,6 +86,23 @@ function getMCPServerString(options) {
|
|
|
85
86
|
*/
|
|
86
87
|
class MCPAgent extends agent_js_1.Agent {
|
|
87
88
|
tag = "MCPAgent";
|
|
89
|
+
static schema() {
|
|
90
|
+
return zod_1.z.object({
|
|
91
|
+
url: (0, schema_js_1.optionalize)(zod_1.z.string()),
|
|
92
|
+
command: (0, schema_js_1.optionalize)(zod_1.z.string()),
|
|
93
|
+
args: (0, schema_js_1.optionalize)(zod_1.z.array(zod_1.z.string())),
|
|
94
|
+
});
|
|
95
|
+
}
|
|
96
|
+
static async load(options) {
|
|
97
|
+
const valid = await MCPAgent.schema().parseAsync(options.parsed);
|
|
98
|
+
if (!valid.url && !valid.command) {
|
|
99
|
+
throw new Error(`Missing url or command in mcp agent: ${options.filepath}`);
|
|
100
|
+
}
|
|
101
|
+
return MCPAgent.from({
|
|
102
|
+
...options.parsed,
|
|
103
|
+
...valid,
|
|
104
|
+
});
|
|
105
|
+
}
|
|
88
106
|
static from(options) {
|
|
89
107
|
(0, type_utils_js_1.checkArguments)("MCPAgent.from", mcpAgentOptionsSchema, options);
|
|
90
108
|
if (isSSEServerParameters(options)) {
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import type { AgentLoadOptions } from "../loader/index.js";
|
|
1
3
|
import { type PromiseOrValue } from "../utils/type-utils.js";
|
|
2
4
|
import { Agent, type AgentInvokeOptions, type AgentOptions, type AgentProcessResult, type Message } from "./agent.js";
|
|
3
5
|
/**
|
|
@@ -200,6 +202,59 @@ export interface TeamAgentOptions<I extends Message, O extends Message> extends
|
|
|
200
202
|
*/
|
|
201
203
|
export declare class TeamAgent<I extends Message, O extends Message> extends Agent<I, O> {
|
|
202
204
|
tag: string;
|
|
205
|
+
static schema({ filepath }: {
|
|
206
|
+
filepath: string;
|
|
207
|
+
}): z.ZodObject<{
|
|
208
|
+
mode: z.ZodType<ProcessMode | undefined, z.ZodTypeDef, ProcessMode | undefined>;
|
|
209
|
+
iterateOn: z.ZodType<string | undefined, z.ZodTypeDef, string | undefined>;
|
|
210
|
+
concurrency: z.ZodType<number | undefined, z.ZodTypeDef, number | undefined>;
|
|
211
|
+
iterateWithPreviousOutput: z.ZodType<boolean | undefined, z.ZodTypeDef, boolean | undefined>;
|
|
212
|
+
includeAllStepsOutput: z.ZodType<boolean | undefined, z.ZodTypeDef, boolean | undefined>;
|
|
213
|
+
reflection: z.ZodType<{
|
|
214
|
+
reviewer: import("../loader/agent-yaml.js").NestAgentSchema;
|
|
215
|
+
isApproved: string;
|
|
216
|
+
maxIterations?: number | undefined;
|
|
217
|
+
returnLastOnMaxIterations?: boolean | undefined;
|
|
218
|
+
customErrorMessage?: string | undefined;
|
|
219
|
+
} | undefined, z.ZodTypeDef, {
|
|
220
|
+
reviewer: import("../loader/agent-yaml.js").NestAgentSchema;
|
|
221
|
+
isApproved: string;
|
|
222
|
+
maxIterations?: number | undefined;
|
|
223
|
+
returnLastOnMaxIterations?: boolean | undefined;
|
|
224
|
+
customErrorMessage?: string | undefined;
|
|
225
|
+
} | undefined>;
|
|
226
|
+
}, "strip", z.ZodTypeAny, {
|
|
227
|
+
mode?: ProcessMode | undefined;
|
|
228
|
+
reflection?: {
|
|
229
|
+
reviewer: import("../loader/agent-yaml.js").NestAgentSchema;
|
|
230
|
+
isApproved: string;
|
|
231
|
+
maxIterations?: number | undefined;
|
|
232
|
+
returnLastOnMaxIterations?: boolean | undefined;
|
|
233
|
+
customErrorMessage?: string | undefined;
|
|
234
|
+
} | undefined;
|
|
235
|
+
iterateOn?: string | undefined;
|
|
236
|
+
concurrency?: number | undefined;
|
|
237
|
+
iterateWithPreviousOutput?: boolean | undefined;
|
|
238
|
+
includeAllStepsOutput?: boolean | undefined;
|
|
239
|
+
}, {
|
|
240
|
+
mode?: ProcessMode | undefined;
|
|
241
|
+
reflection?: {
|
|
242
|
+
reviewer: import("../loader/agent-yaml.js").NestAgentSchema;
|
|
243
|
+
isApproved: string;
|
|
244
|
+
maxIterations?: number | undefined;
|
|
245
|
+
returnLastOnMaxIterations?: boolean | undefined;
|
|
246
|
+
customErrorMessage?: string | undefined;
|
|
247
|
+
} | undefined;
|
|
248
|
+
iterateOn?: string | undefined;
|
|
249
|
+
concurrency?: number | undefined;
|
|
250
|
+
iterateWithPreviousOutput?: boolean | undefined;
|
|
251
|
+
includeAllStepsOutput?: boolean | undefined;
|
|
252
|
+
}>;
|
|
253
|
+
static load<I extends Message = any, O extends Message = any>(options: {
|
|
254
|
+
filepath: string;
|
|
255
|
+
parsed: object;
|
|
256
|
+
options: AgentLoadOptions;
|
|
257
|
+
}): Promise<Agent<I, O>>;
|
|
203
258
|
/**
|
|
204
259
|
* Create a TeamAgent from the provided options.
|
|
205
260
|
*
|
|
@@ -39,6 +39,9 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
39
39
|
exports.TeamAgent = exports.DEFAULT_REFLECTION_MAX_ITERATIONS = exports.ProcessMode = void 0;
|
|
40
40
|
const node_assert_1 = __importDefault(require("node:assert"));
|
|
41
41
|
const immer_1 = require("immer");
|
|
42
|
+
const zod_1 = require("zod");
|
|
43
|
+
const agent_yaml_js_1 = require("../loader/agent-yaml.js");
|
|
44
|
+
const schema_js_1 = require("../loader/schema.js");
|
|
42
45
|
const fastq = __importStar(require("../utils/queue.js"));
|
|
43
46
|
const stream_utils_js_1 = require("../utils/stream-utils.js");
|
|
44
47
|
const type_utils_js_1 = require("../utils/type-utils.js");
|
|
@@ -86,6 +89,34 @@ exports.DEFAULT_REFLECTION_MAX_ITERATIONS = 3;
|
|
|
86
89
|
*/
|
|
87
90
|
class TeamAgent extends agent_js_1.Agent {
|
|
88
91
|
tag = "TeamAgent";
|
|
92
|
+
static schema({ filepath }) {
|
|
93
|
+
const nestAgentSchema = (0, agent_yaml_js_1.getNestAgentSchema)({ filepath });
|
|
94
|
+
return zod_1.z.object({
|
|
95
|
+
mode: (0, schema_js_1.optionalize)(zod_1.z.nativeEnum(ProcessMode)),
|
|
96
|
+
iterateOn: (0, schema_js_1.optionalize)(zod_1.z.string()),
|
|
97
|
+
concurrency: (0, schema_js_1.optionalize)(zod_1.z.number().int().min(1)),
|
|
98
|
+
iterateWithPreviousOutput: (0, schema_js_1.optionalize)(zod_1.z.boolean()),
|
|
99
|
+
includeAllStepsOutput: (0, schema_js_1.optionalize)(zod_1.z.boolean()),
|
|
100
|
+
reflection: (0, schema_js_1.camelizeSchema)((0, schema_js_1.optionalize)(zod_1.z.object({
|
|
101
|
+
reviewer: nestAgentSchema,
|
|
102
|
+
isApproved: zod_1.z.string(),
|
|
103
|
+
maxIterations: (0, schema_js_1.optionalize)(zod_1.z.number().int().min(1)),
|
|
104
|
+
returnLastOnMaxIterations: (0, schema_js_1.optionalize)(zod_1.z.boolean()),
|
|
105
|
+
customErrorMessage: (0, schema_js_1.optionalize)(zod_1.z.string()),
|
|
106
|
+
}))),
|
|
107
|
+
});
|
|
108
|
+
}
|
|
109
|
+
static async load(options) {
|
|
110
|
+
const valid = await TeamAgent.schema({ filepath: options.filepath }).parseAsync(options.parsed);
|
|
111
|
+
return TeamAgent.from({
|
|
112
|
+
...options.parsed,
|
|
113
|
+
...valid,
|
|
114
|
+
reflection: valid.reflection && {
|
|
115
|
+
...valid.reflection,
|
|
116
|
+
reviewer: await options.options.loadNestAgent(options.filepath, valid.reflection.reviewer, options.options),
|
|
117
|
+
},
|
|
118
|
+
});
|
|
119
|
+
}
|
|
89
120
|
/**
|
|
90
121
|
* Create a TeamAgent from the provided options.
|
|
91
122
|
*
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
1
2
|
import { Agent, type AgentOptions, type Message } from "./agent.js";
|
|
2
3
|
/**
|
|
3
4
|
* Configuration options for TransformAgent
|
|
@@ -47,6 +48,17 @@ export interface TransformAgentOptions<I extends Message, O extends Message> ext
|
|
|
47
48
|
*/
|
|
48
49
|
export declare class TransformAgent<I extends Message = Message, O extends Message = Message> extends Agent<I, O> {
|
|
49
50
|
static type: string;
|
|
51
|
+
static schema(): z.ZodObject<{
|
|
52
|
+
jsonata: z.ZodString;
|
|
53
|
+
}, "strip", z.ZodTypeAny, {
|
|
54
|
+
jsonata: string;
|
|
55
|
+
}, {
|
|
56
|
+
jsonata: string;
|
|
57
|
+
}>;
|
|
58
|
+
static load<I extends Message = any, O extends Message = any>(options: {
|
|
59
|
+
filepath: string;
|
|
60
|
+
parsed: object;
|
|
61
|
+
}): Promise<Agent<I, O>>;
|
|
50
62
|
/**
|
|
51
63
|
* Factory method to create a new TransformAgent instance
|
|
52
64
|
*
|
|
@@ -5,6 +5,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.TransformAgent = void 0;
|
|
7
7
|
const jsonata_1 = __importDefault(require("jsonata"));
|
|
8
|
+
const zod_1 = require("zod");
|
|
8
9
|
const agent_js_1 = require("./agent.js");
|
|
9
10
|
/**
|
|
10
11
|
* TransformAgent - A specialized agent for data transformation using JSONata expressions
|
|
@@ -23,6 +24,18 @@ const agent_js_1 = require("./agent.js");
|
|
|
23
24
|
*/
|
|
24
25
|
class TransformAgent extends agent_js_1.Agent {
|
|
25
26
|
static type = "TransformAgent";
|
|
27
|
+
static schema() {
|
|
28
|
+
return zod_1.z.object({
|
|
29
|
+
jsonata: zod_1.z.string(),
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
static async load(options) {
|
|
33
|
+
const parsed = await TransformAgent.schema().parseAsync(options.parsed);
|
|
34
|
+
return TransformAgent.from({
|
|
35
|
+
...options.parsed,
|
|
36
|
+
...parsed,
|
|
37
|
+
});
|
|
38
|
+
}
|
|
26
39
|
/**
|
|
27
40
|
* Factory method to create a new TransformAgent instance
|
|
28
41
|
*
|
|
@@ -94,6 +94,7 @@ export declare const videoModelInputSchema: z.ZodObject<{
|
|
|
94
94
|
prompt: string;
|
|
95
95
|
model?: string | undefined;
|
|
96
96
|
modelOptions?: Record<string, unknown> | undefined;
|
|
97
|
+
outputFileType?: "local" | "url" | "file" | undefined;
|
|
97
98
|
image?: {
|
|
98
99
|
type: "url";
|
|
99
100
|
url: string;
|
|
@@ -110,13 +111,13 @@ export declare const videoModelInputSchema: z.ZodObject<{
|
|
|
110
111
|
filename?: string | undefined;
|
|
111
112
|
mimeType?: string | undefined;
|
|
112
113
|
} | undefined;
|
|
113
|
-
outputFileType?: "local" | "file" | "url" | undefined;
|
|
114
114
|
size?: string | undefined;
|
|
115
115
|
seconds?: string | undefined;
|
|
116
116
|
}, {
|
|
117
117
|
prompt: string;
|
|
118
118
|
model?: string | undefined;
|
|
119
119
|
modelOptions?: Record<string, unknown> | undefined;
|
|
120
|
+
outputFileType?: "local" | "url" | "file" | undefined;
|
|
120
121
|
image?: {
|
|
121
122
|
type: "url";
|
|
122
123
|
url: string;
|
|
@@ -133,7 +134,6 @@ export declare const videoModelInputSchema: z.ZodObject<{
|
|
|
133
134
|
filename?: string | undefined;
|
|
134
135
|
mimeType?: string | undefined;
|
|
135
136
|
} | undefined;
|
|
136
|
-
outputFileType?: "local" | "file" | "url" | undefined;
|
|
137
137
|
size?: string | undefined;
|
|
138
138
|
seconds?: string | undefined;
|
|
139
139
|
}>;
|
|
@@ -203,16 +203,22 @@ export declare const videoModelOutputSchema: z.ZodObject<{
|
|
|
203
203
|
inputTokens: z.ZodNumber;
|
|
204
204
|
outputTokens: z.ZodNumber;
|
|
205
205
|
aigneHubCredits: ZodType<number | undefined, z.ZodTypeDef, number | undefined>;
|
|
206
|
+
cacheCreationInputTokens: ZodType<number | undefined, z.ZodTypeDef, number | undefined>;
|
|
207
|
+
cacheReadInputTokens: ZodType<number | undefined, z.ZodTypeDef, number | undefined>;
|
|
206
208
|
creditPrefix: ZodType<"$" | "€" | "¥" | undefined, z.ZodTypeDef, "$" | "€" | "¥" | undefined>;
|
|
207
209
|
}, "strip", z.ZodTypeAny, {
|
|
208
210
|
inputTokens: number;
|
|
209
211
|
outputTokens: number;
|
|
210
212
|
aigneHubCredits?: number | undefined;
|
|
213
|
+
cacheCreationInputTokens?: number | undefined;
|
|
214
|
+
cacheReadInputTokens?: number | undefined;
|
|
211
215
|
creditPrefix?: "$" | "€" | "¥" | undefined;
|
|
212
216
|
}, {
|
|
213
217
|
inputTokens: number;
|
|
214
218
|
outputTokens: number;
|
|
215
219
|
aigneHubCredits?: number | undefined;
|
|
220
|
+
cacheCreationInputTokens?: number | undefined;
|
|
221
|
+
cacheReadInputTokens?: number | undefined;
|
|
216
222
|
creditPrefix?: "$" | "€" | "¥" | undefined;
|
|
217
223
|
}>>;
|
|
218
224
|
model: z.ZodOptional<z.ZodString>;
|
|
@@ -234,13 +240,15 @@ export declare const videoModelOutputSchema: z.ZodObject<{
|
|
|
234
240
|
filename?: string | undefined;
|
|
235
241
|
mimeType?: string | undefined;
|
|
236
242
|
})[];
|
|
237
|
-
model?: string | undefined;
|
|
238
243
|
usage?: {
|
|
239
244
|
inputTokens: number;
|
|
240
245
|
outputTokens: number;
|
|
241
246
|
aigneHubCredits?: number | undefined;
|
|
247
|
+
cacheCreationInputTokens?: number | undefined;
|
|
248
|
+
cacheReadInputTokens?: number | undefined;
|
|
242
249
|
creditPrefix?: "$" | "€" | "¥" | undefined;
|
|
243
250
|
} | undefined;
|
|
251
|
+
model?: string | undefined;
|
|
244
252
|
seconds?: number | undefined;
|
|
245
253
|
}, {
|
|
246
254
|
videos: ({
|
|
@@ -259,12 +267,14 @@ export declare const videoModelOutputSchema: z.ZodObject<{
|
|
|
259
267
|
filename?: string | undefined;
|
|
260
268
|
mimeType?: string | undefined;
|
|
261
269
|
})[];
|
|
262
|
-
model?: string | undefined;
|
|
263
270
|
usage?: {
|
|
264
271
|
inputTokens: number;
|
|
265
272
|
outputTokens: number;
|
|
266
273
|
aigneHubCredits?: number | undefined;
|
|
274
|
+
cacheCreationInputTokens?: number | undefined;
|
|
275
|
+
cacheReadInputTokens?: number | undefined;
|
|
267
276
|
creditPrefix?: "$" | "€" | "¥" | undefined;
|
|
268
277
|
} | undefined;
|
|
278
|
+
model?: string | undefined;
|
|
269
279
|
seconds?: number | undefined;
|
|
270
280
|
}>;
|
package/lib/cjs/aigne/usage.d.ts
CHANGED
|
@@ -8,6 +8,10 @@ export interface ContextUsage {
|
|
|
8
8
|
creditPrefix?: "$" | "€" | "¥";
|
|
9
9
|
agentCalls: number;
|
|
10
10
|
duration: number;
|
|
11
|
+
/** Number of tokens written to cache (first time caching) */
|
|
12
|
+
cacheCreationInputTokens: number;
|
|
13
|
+
/** Number of tokens read from cache (cache hit) */
|
|
14
|
+
cacheReadInputTokens: number;
|
|
11
15
|
}
|
|
12
16
|
/**
|
|
13
17
|
* @hidden
|
package/lib/cjs/aigne/usage.js
CHANGED
|
@@ -12,6 +12,8 @@ function newEmptyContextUsage() {
|
|
|
12
12
|
aigneHubCredits: 0,
|
|
13
13
|
agentCalls: 0,
|
|
14
14
|
duration: 0,
|
|
15
|
+
cacheCreationInputTokens: 0,
|
|
16
|
+
cacheReadInputTokens: 0,
|
|
15
17
|
};
|
|
16
18
|
}
|
|
17
19
|
function mergeContextUsage(usage, additional) {
|
|
@@ -25,4 +27,8 @@ function mergeContextUsage(usage, additional) {
|
|
|
25
27
|
usage.agentCalls += additional.agentCalls;
|
|
26
28
|
if (additional.duration)
|
|
27
29
|
usage.duration += additional.duration;
|
|
30
|
+
if (additional.cacheCreationInputTokens)
|
|
31
|
+
usage.cacheCreationInputTokens += additional.cacheCreationInputTokens;
|
|
32
|
+
if (additional.cacheReadInputTokens)
|
|
33
|
+
usage.cacheReadInputTokens += additional.cacheReadInputTokens;
|
|
28
34
|
}
|
|
@@ -1,9 +1,6 @@
|
|
|
1
1
|
import type { AFSOptions } from "@aigne/afs";
|
|
2
2
|
import { type ZodType, z } from "zod";
|
|
3
|
-
import type {
|
|
4
|
-
import { AIAgentToolChoice } from "../agents/ai-agent.js";
|
|
5
|
-
import { type Role } from "../agents/chat-model.js";
|
|
6
|
-
import { ProcessMode, type ReflectionMode } from "../agents/team-agent.js";
|
|
3
|
+
import type { AgentHooks, TaskRenderMode } from "../agents/agent.js";
|
|
7
4
|
import type { LoadOptions } from "./index.js";
|
|
8
5
|
import { chatModelSchema, imageModelSchema } from "./schema.js";
|
|
9
6
|
export interface HooksSchema {
|
|
@@ -45,7 +42,8 @@ export interface AFSContextSchema {
|
|
|
45
42
|
presets?: Record<string, AFSContextPresetSchema>;
|
|
46
43
|
};
|
|
47
44
|
}
|
|
48
|
-
export interface
|
|
45
|
+
export interface AgentSchema {
|
|
46
|
+
type: string;
|
|
49
47
|
name?: string;
|
|
50
48
|
description?: string;
|
|
51
49
|
model?: z.infer<typeof chatModelSchema>;
|
|
@@ -67,67 +65,11 @@ export interface BaseAgentSchema {
|
|
|
67
65
|
context?: AFSContextSchema;
|
|
68
66
|
});
|
|
69
67
|
shareAFS?: boolean;
|
|
68
|
+
[key: string]: unknown;
|
|
70
69
|
}
|
|
71
|
-
export type Instructions = {
|
|
72
|
-
role: Exclude<Role, "tool">;
|
|
73
|
-
content: string;
|
|
74
|
-
path: string;
|
|
75
|
-
}[];
|
|
76
|
-
export interface AIAgentSchema extends BaseAgentSchema {
|
|
77
|
-
type: "ai";
|
|
78
|
-
instructions?: Instructions;
|
|
79
|
-
autoReorderSystemMessages?: boolean;
|
|
80
|
-
autoMergeSystemMessages?: boolean;
|
|
81
|
-
inputKey?: string;
|
|
82
|
-
inputFileKey?: string;
|
|
83
|
-
outputKey?: string;
|
|
84
|
-
outputFileKey?: string;
|
|
85
|
-
toolChoice?: AIAgentToolChoice;
|
|
86
|
-
toolCallsConcurrency?: number;
|
|
87
|
-
keepTextInToolUses?: boolean;
|
|
88
|
-
}
|
|
89
|
-
export interface ImageAgentSchema extends BaseAgentSchema {
|
|
90
|
-
type: "image";
|
|
91
|
-
instructions: Instructions;
|
|
92
|
-
inputFileKey?: string;
|
|
93
|
-
}
|
|
94
|
-
export interface MCPAgentSchema extends BaseAgentSchema {
|
|
95
|
-
type: "mcp";
|
|
96
|
-
url?: string;
|
|
97
|
-
command?: string;
|
|
98
|
-
args?: string[];
|
|
99
|
-
}
|
|
100
|
-
export interface TeamAgentSchema extends BaseAgentSchema {
|
|
101
|
-
type: "team";
|
|
102
|
-
mode?: ProcessMode;
|
|
103
|
-
iterateOn?: string;
|
|
104
|
-
concurrency?: number;
|
|
105
|
-
iterateWithPreviousOutput?: boolean;
|
|
106
|
-
includeAllStepsOutput?: boolean;
|
|
107
|
-
reflection?: Omit<ReflectionMode, "reviewer"> & {
|
|
108
|
-
reviewer: NestAgentSchema;
|
|
109
|
-
};
|
|
110
|
-
}
|
|
111
|
-
export interface TransformAgentSchema extends BaseAgentSchema {
|
|
112
|
-
type: "transform";
|
|
113
|
-
jsonata: string;
|
|
114
|
-
}
|
|
115
|
-
export interface FunctionAgentSchema extends BaseAgentSchema {
|
|
116
|
-
type: "function";
|
|
117
|
-
process: FunctionAgentFn;
|
|
118
|
-
}
|
|
119
|
-
export interface ThirdAgentSchema extends BaseAgentSchema {
|
|
120
|
-
agentClass?: AgentClass;
|
|
121
|
-
type: "";
|
|
122
|
-
[key: string]: any;
|
|
123
|
-
}
|
|
124
|
-
export type AgentSchema = AIAgentSchema | ImageAgentSchema | MCPAgentSchema | TeamAgentSchema | TransformAgentSchema | FunctionAgentSchema | ThirdAgentSchema;
|
|
125
70
|
export declare function parseAgentFile(path: string, data: any, options: LoadOptions): Promise<AgentSchema>;
|
|
126
71
|
export declare function loadAgentFromYamlFile(path: string, options: LoadOptions): Promise<AgentSchema>;
|
|
127
|
-
export declare const
|
|
128
|
-
filepath: string;
|
|
129
|
-
}) => ZodType<Instructions>;
|
|
130
|
-
export declare const getAgentSchema: ({ filepath, options, }: {
|
|
72
|
+
export declare const getAgentSchema: ({ filepath }: {
|
|
131
73
|
filepath: string;
|
|
132
74
|
options?: LoadOptions;
|
|
133
75
|
}) => ZodType<AgentSchema, z.ZodTypeDef, AgentSchema>;
|
|
@@ -1,17 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getNestAgentSchema = exports.getAgentSchema =
|
|
3
|
+
exports.getNestAgentSchema = exports.getAgentSchema = void 0;
|
|
4
4
|
exports.parseAgentFile = parseAgentFile;
|
|
5
5
|
exports.loadAgentFromYamlFile = loadAgentFromYamlFile;
|
|
6
6
|
const json_schema_to_zod_1 = require("@aigne/json-schema-to-zod");
|
|
7
7
|
const index_js_1 = require("@aigne/platform-helpers/nodejs/index.js");
|
|
8
8
|
const yaml_1 = require("yaml");
|
|
9
9
|
const zod_1 = require("zod");
|
|
10
|
-
const ai_agent_js_1 = require("../agents/ai-agent.js");
|
|
11
|
-
const chat_model_js_1 = require("../agents/chat-model.js");
|
|
12
|
-
const team_agent_js_1 = require("../agents/team-agent.js");
|
|
13
10
|
const type_utils_js_1 = require("../utils/type-utils.js");
|
|
14
|
-
const function_agent_js_1 = require("./function-agent.js");
|
|
15
11
|
const schema_js_1 = require("./schema.js");
|
|
16
12
|
async function parseAgentFile(path, data, options) {
|
|
17
13
|
const agentSchema = (0, exports.getAgentSchema)({ filepath: path, options });
|
|
@@ -30,42 +26,7 @@ async function loadAgentFromYamlFile(path, options) {
|
|
|
30
26
|
}, options), (error) => new Error(`Failed to validate agent definition from ${path}: ${error.message}`));
|
|
31
27
|
return agent;
|
|
32
28
|
}
|
|
33
|
-
const
|
|
34
|
-
zod_1.z.object({
|
|
35
|
-
role: chat_model_js_1.roleSchema.default("system"),
|
|
36
|
-
url: zod_1.z.string(),
|
|
37
|
-
}),
|
|
38
|
-
zod_1.z.object({
|
|
39
|
-
role: chat_model_js_1.roleSchema.default("system"),
|
|
40
|
-
content: zod_1.z.string(),
|
|
41
|
-
}),
|
|
42
|
-
]);
|
|
43
|
-
const parseInstructionItem = ({ filepath }) => async ({ role, ...v }) => {
|
|
44
|
-
if (role === "tool")
|
|
45
|
-
throw new Error(`'tool' role is not allowed in instruction item in agent file ${filepath}`);
|
|
46
|
-
if ("content" in v && typeof v.content === "string") {
|
|
47
|
-
return { role, content: v.content, path: filepath };
|
|
48
|
-
}
|
|
49
|
-
if ("url" in v && typeof v.url === "string") {
|
|
50
|
-
const url = index_js_1.nodejs.path.isAbsolute(v.url)
|
|
51
|
-
? v.url
|
|
52
|
-
: index_js_1.nodejs.path.join(index_js_1.nodejs.path.dirname(filepath), v.url);
|
|
53
|
-
return index_js_1.nodejs.fs.readFile(url, "utf8").then((content) => ({ role, content, path: url }));
|
|
54
|
-
}
|
|
55
|
-
throw new Error(`Invalid instruction item in agent file ${filepath}. Expected 'content' or 'url' property`);
|
|
56
|
-
};
|
|
57
|
-
const getInstructionsSchema = ({ filepath }) => zod_1.z
|
|
58
|
-
.union([zod_1.z.string(), instructionItemSchema, zod_1.z.array(instructionItemSchema)])
|
|
59
|
-
.transform(async (v) => {
|
|
60
|
-
if (typeof v === "string")
|
|
61
|
-
return [{ role: "system", content: v, path: filepath }];
|
|
62
|
-
if (Array.isArray(v)) {
|
|
63
|
-
return Promise.all(v.map((item) => parseInstructionItem({ filepath })(item)));
|
|
64
|
-
}
|
|
65
|
-
return [await parseInstructionItem({ filepath })(v)];
|
|
66
|
-
});
|
|
67
|
-
exports.getInstructionsSchema = getInstructionsSchema;
|
|
68
|
-
const getAgentSchema = ({ filepath, options, }) => {
|
|
29
|
+
const getAgentSchema = ({ filepath }) => {
|
|
69
30
|
const agentSchema = zod_1.z.lazy(() => {
|
|
70
31
|
const nestAgentSchema = zod_1.z.lazy(() => zod_1.z.union([
|
|
71
32
|
agentSchema,
|
|
@@ -101,6 +62,7 @@ const getAgentSchema = ({ filepath, options, }) => {
|
|
|
101
62
|
}))),
|
|
102
63
|
});
|
|
103
64
|
const baseAgentSchema = zod_1.z.object({
|
|
65
|
+
type: zod_1.z.string(),
|
|
104
66
|
name: (0, schema_js_1.optionalize)(zod_1.z.string()),
|
|
105
67
|
alias: (0, schema_js_1.optionalize)(zod_1.z.array(zod_1.z.string())),
|
|
106
68
|
description: (0, schema_js_1.optionalize)(zod_1.z.string()),
|
|
@@ -139,94 +101,7 @@ const getAgentSchema = ({ filepath, options, }) => {
|
|
|
139
101
|
])),
|
|
140
102
|
shareAFS: (0, schema_js_1.optionalize)(zod_1.z.boolean()),
|
|
141
103
|
});
|
|
142
|
-
|
|
143
|
-
return (0, schema_js_1.camelizeSchema)((0, schema_js_1.preprocessSchema)(async (json) => {
|
|
144
|
-
if (typeof json === "object" &&
|
|
145
|
-
json &&
|
|
146
|
-
"type" in json &&
|
|
147
|
-
typeof json.type === "string" &&
|
|
148
|
-
!["ai", "image", "mcp", "team", "transform", "function"].includes(json.type)) {
|
|
149
|
-
if (!options?.require)
|
|
150
|
-
throw new Error(`Module loader is not provided to load agent type module ${json.type} from ${filepath}`);
|
|
151
|
-
const Mod = await options.require(json.type, { parent: filepath });
|
|
152
|
-
if (typeof Mod?.default?.prototype?.constructor !== "function") {
|
|
153
|
-
throw new Error(`The agent type module ${json.type} does not export a default Agent class`);
|
|
154
|
-
}
|
|
155
|
-
Object.assign(json, { agentClass: Mod.default });
|
|
156
|
-
}
|
|
157
|
-
return json;
|
|
158
|
-
}, zod_1.z.union([
|
|
159
|
-
zod_1.z
|
|
160
|
-
.object({
|
|
161
|
-
type: zod_1.z.string(),
|
|
162
|
-
agentClass: zod_1.z.custom((v) => typeof v?.prototype?.constructor === "function"),
|
|
163
|
-
})
|
|
164
|
-
.extend(baseAgentSchema.shape)
|
|
165
|
-
.passthrough(),
|
|
166
|
-
zod_1.z.discriminatedUnion("type", [
|
|
167
|
-
zod_1.z
|
|
168
|
-
.object({
|
|
169
|
-
type: zod_1.z.literal("ai"),
|
|
170
|
-
instructions: (0, schema_js_1.optionalize)(instructionsSchema),
|
|
171
|
-
autoReorderSystemMessages: (0, schema_js_1.optionalize)(zod_1.z.boolean()),
|
|
172
|
-
autoMergeSystemMessages: (0, schema_js_1.optionalize)(zod_1.z.boolean()),
|
|
173
|
-
inputKey: (0, schema_js_1.optionalize)(zod_1.z.string()),
|
|
174
|
-
outputKey: (0, schema_js_1.optionalize)(zod_1.z.string()),
|
|
175
|
-
inputFileKey: (0, schema_js_1.optionalize)(zod_1.z.string()),
|
|
176
|
-
outputFileKey: (0, schema_js_1.optionalize)(zod_1.z.string()),
|
|
177
|
-
toolChoice: (0, schema_js_1.optionalize)(zod_1.z.nativeEnum(ai_agent_js_1.AIAgentToolChoice)),
|
|
178
|
-
toolCallsConcurrency: (0, schema_js_1.optionalize)(zod_1.z.number().int().min(0)),
|
|
179
|
-
keepTextInToolUses: (0, schema_js_1.optionalize)(zod_1.z.boolean()),
|
|
180
|
-
catchToolsError: (0, schema_js_1.optionalize)(zod_1.z.boolean()),
|
|
181
|
-
structuredStreamMode: (0, schema_js_1.optionalize)(zod_1.z.boolean()),
|
|
182
|
-
})
|
|
183
|
-
.extend(baseAgentSchema.shape),
|
|
184
|
-
zod_1.z
|
|
185
|
-
.object({
|
|
186
|
-
type: zod_1.z.literal("image"),
|
|
187
|
-
instructions: instructionsSchema,
|
|
188
|
-
inputFileKey: (0, schema_js_1.optionalize)(zod_1.z.string()),
|
|
189
|
-
})
|
|
190
|
-
.extend(baseAgentSchema.shape),
|
|
191
|
-
zod_1.z
|
|
192
|
-
.object({
|
|
193
|
-
type: zod_1.z.literal("mcp"),
|
|
194
|
-
url: (0, schema_js_1.optionalize)(zod_1.z.string()),
|
|
195
|
-
command: (0, schema_js_1.optionalize)(zod_1.z.string()),
|
|
196
|
-
args: (0, schema_js_1.optionalize)(zod_1.z.array(zod_1.z.string())),
|
|
197
|
-
})
|
|
198
|
-
.extend(baseAgentSchema.shape),
|
|
199
|
-
zod_1.z
|
|
200
|
-
.object({
|
|
201
|
-
type: zod_1.z.literal("team"),
|
|
202
|
-
mode: (0, schema_js_1.optionalize)(zod_1.z.nativeEnum(team_agent_js_1.ProcessMode)),
|
|
203
|
-
iterateOn: (0, schema_js_1.optionalize)(zod_1.z.string()),
|
|
204
|
-
concurrency: (0, schema_js_1.optionalize)(zod_1.z.number().int().min(1)),
|
|
205
|
-
iterateWithPreviousOutput: (0, schema_js_1.optionalize)(zod_1.z.boolean()),
|
|
206
|
-
includeAllStepsOutput: (0, schema_js_1.optionalize)(zod_1.z.boolean()),
|
|
207
|
-
reflection: (0, schema_js_1.camelizeSchema)((0, schema_js_1.optionalize)(zod_1.z.object({
|
|
208
|
-
reviewer: nestAgentSchema,
|
|
209
|
-
isApproved: zod_1.z.string(),
|
|
210
|
-
maxIterations: (0, schema_js_1.optionalize)(zod_1.z.number().int().min(1)),
|
|
211
|
-
returnLastOnMaxIterations: (0, schema_js_1.optionalize)(zod_1.z.boolean()),
|
|
212
|
-
customErrorMessage: (0, schema_js_1.optionalize)(zod_1.z.string()),
|
|
213
|
-
}))),
|
|
214
|
-
})
|
|
215
|
-
.extend(baseAgentSchema.shape),
|
|
216
|
-
zod_1.z
|
|
217
|
-
.object({
|
|
218
|
-
type: zod_1.z.literal("transform"),
|
|
219
|
-
jsonata: zod_1.z.string(),
|
|
220
|
-
})
|
|
221
|
-
.extend(baseAgentSchema.shape),
|
|
222
|
-
zod_1.z
|
|
223
|
-
.object({
|
|
224
|
-
type: zod_1.z.literal("function"),
|
|
225
|
-
process: zod_1.z.preprocess((v) => (typeof v === "string" ? (0, function_agent_js_1.codeToFunctionAgentFn)(v) : v), zod_1.z.custom()),
|
|
226
|
-
})
|
|
227
|
-
.extend(baseAgentSchema.shape),
|
|
228
|
-
]),
|
|
229
|
-
])));
|
|
104
|
+
return (0, schema_js_1.camelizeSchema)(baseAgentSchema.passthrough());
|
|
230
105
|
});
|
|
231
106
|
return agentSchema;
|
|
232
107
|
};
|