@aigne/core 1.72.0-beta.2 → 1.72.0-beta.23
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 +261 -0
- package/lib/cjs/agents/agent.d.ts +42 -11
- package/lib/cjs/agents/agent.js +34 -8
- package/lib/cjs/agents/ai-agent.d.ts +63 -4
- package/lib/cjs/agents/ai-agent.js +154 -20
- package/lib/cjs/agents/chat-model.d.ts +157 -0
- package/lib/cjs/agents/chat-model.js +71 -6
- 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 +12 -2
- package/lib/cjs/agents/image-model.js +1 -1
- package/lib/cjs/agents/mcp-agent.d.ts +17 -0
- package/lib/cjs/agents/mcp-agent.js +18 -0
- package/lib/cjs/agents/model.d.ts +3 -3
- package/lib/cjs/agents/model.js +2 -2
- 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 +10 -0
- package/lib/cjs/agents/video-model.js +1 -1
- package/lib/cjs/aigne/context.js +1 -3
- package/lib/cjs/aigne/usage.d.ts +4 -0
- package/lib/cjs/aigne/usage.js +6 -0
- package/lib/cjs/index.d.ts +1 -0
- package/lib/cjs/index.js +1 -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 +16 -12
- 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/memory/recorder.d.ts +4 -4
- package/lib/cjs/memory/retriever.d.ts +4 -4
- package/lib/cjs/prompt/agent-session.d.ts +163 -0
- package/lib/cjs/prompt/agent-session.js +1008 -0
- package/lib/cjs/prompt/compact/compactor.d.ts +7 -0
- package/lib/cjs/prompt/compact/compactor.js +52 -0
- package/lib/cjs/prompt/compact/session-memory-extractor.d.ts +7 -0
- package/lib/cjs/prompt/compact/session-memory-extractor.js +143 -0
- package/lib/cjs/prompt/compact/types.d.ts +336 -0
- package/lib/cjs/prompt/compact/types.js +53 -0
- package/lib/cjs/prompt/compact/user-memory-extractor.d.ts +7 -0
- package/lib/cjs/prompt/compact/user-memory-extractor.js +124 -0
- package/lib/cjs/prompt/context/afs/history.d.ts +5 -1
- package/lib/cjs/prompt/context/afs/history.js +3 -2
- package/lib/cjs/prompt/context/afs/index.js +8 -1
- package/lib/cjs/prompt/prompt-builder.d.ts +11 -9
- package/lib/cjs/prompt/prompt-builder.js +79 -120
- package/lib/cjs/prompt/skills/afs/agent-skill/agent-skill.d.ts +19 -0
- package/lib/cjs/prompt/skills/afs/agent-skill/agent-skill.js +69 -0
- package/lib/cjs/prompt/skills/afs/agent-skill/skill-loader.d.ts +12 -0
- package/lib/cjs/prompt/skills/afs/agent-skill/skill-loader.js +50 -0
- package/lib/cjs/prompt/skills/afs/delete.js +15 -3
- package/lib/cjs/prompt/skills/afs/edit.d.ts +6 -9
- package/lib/cjs/prompt/skills/afs/edit.js +85 -59
- 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.d.ts +2 -0
- package/lib/cjs/prompt/skills/afs/list.js +35 -11
- package/lib/cjs/prompt/skills/afs/read.d.ts +9 -3
- package/lib/cjs/prompt/skills/afs/read.js +67 -15
- 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 +20 -6
- package/lib/cjs/prompt/template.d.ts +84 -9
- package/lib/cjs/prompt/template.js +46 -17
- package/lib/cjs/utils/mcp-utils.js +1 -1
- package/lib/cjs/utils/token-estimator.js +1 -1
- package/lib/dts/agents/agent.d.ts +42 -11
- package/lib/dts/agents/ai-agent.d.ts +63 -4
- package/lib/dts/agents/chat-model.d.ts +157 -0
- package/lib/dts/agents/image-agent.d.ts +17 -1
- package/lib/dts/agents/image-model.d.ts +12 -2
- package/lib/dts/agents/mcp-agent.d.ts +17 -0
- package/lib/dts/agents/model.d.ts +3 -3
- 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 +10 -0
- package/lib/dts/aigne/context.d.ts +2 -2
- package/lib/dts/aigne/usage.d.ts +4 -0
- package/lib/dts/index.d.ts +1 -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 +16 -12
- package/lib/dts/loader/schema.d.ts +21 -6
- package/lib/dts/memory/recorder.d.ts +4 -4
- package/lib/dts/memory/retriever.d.ts +4 -4
- package/lib/dts/prompt/agent-session.d.ts +163 -0
- package/lib/dts/prompt/compact/compactor.d.ts +7 -0
- package/lib/dts/prompt/compact/session-memory-extractor.d.ts +7 -0
- package/lib/dts/prompt/compact/types.d.ts +336 -0
- package/lib/dts/prompt/compact/user-memory-extractor.d.ts +7 -0
- package/lib/dts/prompt/context/afs/history.d.ts +5 -1
- package/lib/dts/prompt/prompt-builder.d.ts +11 -9
- package/lib/dts/prompt/skills/afs/agent-skill/agent-skill.d.ts +19 -0
- package/lib/dts/prompt/skills/afs/agent-skill/skill-loader.d.ts +12 -0
- package/lib/dts/prompt/skills/afs/edit.d.ts +6 -9
- package/lib/dts/prompt/skills/afs/list.d.ts +2 -0
- package/lib/dts/prompt/skills/afs/read.d.ts +9 -3
- package/lib/dts/prompt/template.d.ts +84 -9
- package/lib/esm/agents/agent.d.ts +42 -11
- package/lib/esm/agents/agent.js +34 -8
- package/lib/esm/agents/ai-agent.d.ts +63 -4
- package/lib/esm/agents/ai-agent.js +154 -20
- package/lib/esm/agents/chat-model.d.ts +157 -0
- package/lib/esm/agents/chat-model.js +70 -5
- 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 +12 -2
- package/lib/esm/agents/image-model.js +1 -1
- package/lib/esm/agents/mcp-agent.d.ts +17 -0
- package/lib/esm/agents/mcp-agent.js +18 -0
- package/lib/esm/agents/model.d.ts +3 -3
- package/lib/esm/agents/model.js +2 -2
- 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 +10 -0
- package/lib/esm/agents/video-model.js +1 -1
- package/lib/esm/aigne/context.d.ts +2 -2
- package/lib/esm/aigne/context.js +2 -4
- package/lib/esm/aigne/usage.d.ts +4 -0
- package/lib/esm/aigne/usage.js +6 -0
- package/lib/esm/index.d.ts +1 -0
- package/lib/esm/index.js +1 -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 +16 -12
- 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/memory/recorder.d.ts +4 -4
- package/lib/esm/memory/retriever.d.ts +4 -4
- package/lib/esm/prompt/agent-session.d.ts +163 -0
- package/lib/esm/prompt/agent-session.js +968 -0
- package/lib/esm/prompt/compact/compactor.d.ts +7 -0
- package/lib/esm/prompt/compact/compactor.js +48 -0
- package/lib/esm/prompt/compact/session-memory-extractor.d.ts +7 -0
- package/lib/esm/prompt/compact/session-memory-extractor.js +139 -0
- package/lib/esm/prompt/compact/types.d.ts +336 -0
- package/lib/esm/prompt/compact/types.js +50 -0
- package/lib/esm/prompt/compact/user-memory-extractor.d.ts +7 -0
- package/lib/esm/prompt/compact/user-memory-extractor.js +120 -0
- package/lib/esm/prompt/context/afs/history.d.ts +5 -1
- package/lib/esm/prompt/context/afs/history.js +3 -2
- package/lib/esm/prompt/context/afs/index.js +8 -1
- package/lib/esm/prompt/prompt-builder.d.ts +11 -9
- package/lib/esm/prompt/prompt-builder.js +80 -121
- package/lib/esm/prompt/skills/afs/agent-skill/agent-skill.d.ts +19 -0
- package/lib/esm/prompt/skills/afs/agent-skill/agent-skill.js +65 -0
- package/lib/esm/prompt/skills/afs/agent-skill/skill-loader.d.ts +12 -0
- package/lib/esm/prompt/skills/afs/agent-skill/skill-loader.js +43 -0
- package/lib/esm/prompt/skills/afs/delete.js +15 -3
- package/lib/esm/prompt/skills/afs/edit.d.ts +6 -9
- package/lib/esm/prompt/skills/afs/edit.js +85 -59
- 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.d.ts +2 -0
- package/lib/esm/prompt/skills/afs/list.js +35 -11
- package/lib/esm/prompt/skills/afs/read.d.ts +9 -3
- package/lib/esm/prompt/skills/afs/read.js +67 -15
- 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 +20 -6
- package/lib/esm/prompt/template.d.ts +84 -9
- package/lib/esm/prompt/template.js +46 -17
- package/lib/esm/utils/mcp-utils.js +1 -1
- package/lib/esm/utils/token-estimator.js +1 -1
- package/package.json +7 -6
|
@@ -7,16 +7,30 @@ class AFSWriteAgent extends base_js_1.AFSSkillBase {
|
|
|
7
7
|
constructor(options) {
|
|
8
8
|
super({
|
|
9
9
|
name: "afs_write",
|
|
10
|
-
description:
|
|
10
|
+
description: `Write or create files in the Agentic File System (AFS)
|
|
11
|
+
- Creates a new file or overwrites an existing file with the provided content
|
|
12
|
+
- Supports append mode to add content to the end of existing files
|
|
13
|
+
- Use this tool when creating new files or completely replacing file contents
|
|
14
|
+
|
|
15
|
+
Usage:
|
|
16
|
+
- The path must be an absolute AFS path starting with "/" (e.g., "/docs/new-file.md", "/memory/user/notes")
|
|
17
|
+
- This is NOT a local system file path - it operates within the AFS virtual file system
|
|
18
|
+
- By default, this tool overwrites the entire file content
|
|
19
|
+
- Use append mode to add content to the end of an existing file without replacing it
|
|
20
|
+
- For partial edits to existing files, prefer using afs_edit instead`,
|
|
11
21
|
...options,
|
|
12
22
|
inputSchema: zod_1.z.object({
|
|
13
|
-
path: zod_1.z
|
|
14
|
-
|
|
23
|
+
path: zod_1.z
|
|
24
|
+
.string()
|
|
25
|
+
.describe("Absolute AFS path for the file to write (e.g., '/docs/new-file.md'). Must start with '/'"),
|
|
26
|
+
content: zod_1.z
|
|
27
|
+
.string()
|
|
28
|
+
.describe("The content to write to the file. In overwrite mode, this replaces the entire file"),
|
|
15
29
|
append: zod_1.z
|
|
16
30
|
.boolean()
|
|
17
31
|
.optional()
|
|
18
32
|
.default(false)
|
|
19
|
-
.describe("
|
|
33
|
+
.describe("Set to true to append content to the end of an existing file. Default: false (overwrites entire file)"),
|
|
20
34
|
}),
|
|
21
35
|
outputSchema: zod_1.z.object({
|
|
22
36
|
status: zod_1.z.string(),
|
|
@@ -29,7 +43,7 @@ class AFSWriteAgent extends base_js_1.AFSSkillBase {
|
|
|
29
43
|
async process(input, _options) {
|
|
30
44
|
if (!this.afs)
|
|
31
45
|
throw new Error("AFS is not configured for this agent.");
|
|
32
|
-
const
|
|
46
|
+
const _result = await this.afs.write(input.path, {
|
|
33
47
|
content: input.content,
|
|
34
48
|
}, {
|
|
35
49
|
append: input.append ?? false,
|
|
@@ -38,7 +52,7 @@ class AFSWriteAgent extends base_js_1.AFSSkillBase {
|
|
|
38
52
|
status: "success",
|
|
39
53
|
tool: "afs_write",
|
|
40
54
|
path: input.path,
|
|
41
|
-
|
|
55
|
+
message: "File written successfully",
|
|
42
56
|
};
|
|
43
57
|
}
|
|
44
58
|
}
|
|
@@ -27,35 +27,38 @@ export declare class ChatMessageTemplate {
|
|
|
27
27
|
content?: ChatModelInputMessage["content"];
|
|
28
28
|
name?: string | undefined;
|
|
29
29
|
options?: FormatOptions | undefined;
|
|
30
|
-
|
|
30
|
+
cacheControl?: ChatModelInputMessage["cacheControl"];
|
|
31
|
+
constructor(role: "system" | "user" | "agent" | "tool", content?: ChatModelInputMessage["content"], name?: string | undefined, options?: FormatOptions | undefined, cacheControl?: ChatModelInputMessage["cacheControl"]);
|
|
31
32
|
format(variables?: Record<string, unknown>, options?: FormatOptions): Promise<ChatModelInputMessage>;
|
|
32
33
|
}
|
|
33
34
|
export declare class SystemMessageTemplate extends ChatMessageTemplate {
|
|
34
|
-
static from(content: string, name?: string, options?: FormatOptions): SystemMessageTemplate;
|
|
35
|
+
static from(content: string, name?: string, options?: FormatOptions, cacheControl?: ChatModelInputMessage["cacheControl"]): SystemMessageTemplate;
|
|
35
36
|
}
|
|
36
37
|
export declare class UserMessageTemplate extends ChatMessageTemplate {
|
|
37
|
-
static from(template: ChatModelInputMessageContent, name?: string, options?: FormatOptions): UserMessageTemplate;
|
|
38
|
+
static from(template: ChatModelInputMessageContent, name?: string, options?: FormatOptions, cacheControl?: ChatModelInputMessage["cacheControl"]): UserMessageTemplate;
|
|
38
39
|
}
|
|
39
40
|
export declare class AgentMessageTemplate extends ChatMessageTemplate {
|
|
40
41
|
toolCalls?: ChatModelOutputToolCall[] | undefined;
|
|
41
|
-
static from(template?: ChatModelInputMessage["content"], toolCalls?: ChatModelOutputToolCall[], name?: string, options?: FormatOptions): AgentMessageTemplate;
|
|
42
|
-
constructor(content?: ChatModelInputMessage["content"], toolCalls?: ChatModelOutputToolCall[] | undefined, name?: string, options?: FormatOptions);
|
|
42
|
+
static from(template?: ChatModelInputMessage["content"], toolCalls?: ChatModelOutputToolCall[], name?: string, options?: FormatOptions, cacheControl?: ChatModelInputMessage["cacheControl"]): AgentMessageTemplate;
|
|
43
|
+
constructor(content?: ChatModelInputMessage["content"], toolCalls?: ChatModelOutputToolCall[] | undefined, name?: string, options?: FormatOptions, cacheControl?: ChatModelInputMessage["cacheControl"]);
|
|
43
44
|
format(_variables?: Record<string, unknown>, _options?: FormatOptions): Promise<{
|
|
44
|
-
role: "agent" | "
|
|
45
|
+
role: "agent" | "user" | "system" | "tool";
|
|
45
46
|
name: string | undefined;
|
|
46
47
|
content: ChatModelInputMessageContent | undefined;
|
|
47
48
|
toolCalls: ChatModelOutputToolCall[] | undefined;
|
|
49
|
+
cacheControl: import("../agents/chat-model.js").CacheControl | undefined;
|
|
48
50
|
}>;
|
|
49
51
|
}
|
|
50
52
|
export declare class ToolMessageTemplate extends ChatMessageTemplate {
|
|
51
53
|
toolCallId: string;
|
|
52
|
-
static from(content: object | string, toolCallId: string, name?: string, options?: FormatOptions): ToolMessageTemplate;
|
|
53
|
-
constructor(content: object | string, toolCallId: string, name?: string, options?: FormatOptions);
|
|
54
|
+
static from(content: object | string, toolCallId: string, name?: string, options?: FormatOptions, cacheControl?: ChatModelInputMessage["cacheControl"]): ToolMessageTemplate;
|
|
55
|
+
constructor(content: object | string, toolCallId: string, name?: string, options?: FormatOptions, cacheControl?: ChatModelInputMessage["cacheControl"]);
|
|
54
56
|
format(_variables?: Record<string, unknown>, _options?: FormatOptions): Promise<{
|
|
55
|
-
role: "agent" | "
|
|
57
|
+
role: "agent" | "user" | "system" | "tool";
|
|
56
58
|
name: string | undefined;
|
|
57
59
|
content: ChatModelInputMessageContent | undefined;
|
|
58
60
|
toolCallId: string;
|
|
61
|
+
cacheControl: import("../agents/chat-model.js").CacheControl | undefined;
|
|
59
62
|
}>;
|
|
60
63
|
}
|
|
61
64
|
export declare class ChatMessagesTemplate {
|
|
@@ -69,26 +72,62 @@ declare const chatMessageSchema: z.ZodUnion<[z.ZodObject<{
|
|
|
69
72
|
role: z.ZodLiteral<"system">;
|
|
70
73
|
content: z.ZodString;
|
|
71
74
|
name: z.ZodOptional<z.ZodString>;
|
|
75
|
+
cacheControl: z.ZodOptional<z.ZodObject<{
|
|
76
|
+
type: z.ZodLiteral<"ephemeral">;
|
|
77
|
+
ttl: z.ZodOptional<z.ZodUnion<[z.ZodLiteral<"5m">, z.ZodLiteral<"1h">]>>;
|
|
78
|
+
}, "strip", z.ZodTypeAny, {
|
|
79
|
+
type: "ephemeral";
|
|
80
|
+
ttl?: "5m" | "1h" | undefined;
|
|
81
|
+
}, {
|
|
82
|
+
type: "ephemeral";
|
|
83
|
+
ttl?: "5m" | "1h" | undefined;
|
|
84
|
+
}>>;
|
|
72
85
|
}, "strip", z.ZodTypeAny, {
|
|
73
86
|
role: "system";
|
|
74
87
|
content: string;
|
|
75
88
|
name?: string | undefined;
|
|
89
|
+
cacheControl?: {
|
|
90
|
+
type: "ephemeral";
|
|
91
|
+
ttl?: "5m" | "1h" | undefined;
|
|
92
|
+
} | undefined;
|
|
76
93
|
}, {
|
|
77
94
|
role: "system";
|
|
78
95
|
content: string;
|
|
79
96
|
name?: string | undefined;
|
|
97
|
+
cacheControl?: {
|
|
98
|
+
type: "ephemeral";
|
|
99
|
+
ttl?: "5m" | "1h" | undefined;
|
|
100
|
+
} | undefined;
|
|
80
101
|
}>, z.ZodObject<{
|
|
81
102
|
role: z.ZodLiteral<"user">;
|
|
82
103
|
content: z.ZodString;
|
|
83
104
|
name: z.ZodOptional<z.ZodString>;
|
|
105
|
+
cacheControl: z.ZodOptional<z.ZodObject<{
|
|
106
|
+
type: z.ZodLiteral<"ephemeral">;
|
|
107
|
+
ttl: z.ZodOptional<z.ZodUnion<[z.ZodLiteral<"5m">, z.ZodLiteral<"1h">]>>;
|
|
108
|
+
}, "strip", z.ZodTypeAny, {
|
|
109
|
+
type: "ephemeral";
|
|
110
|
+
ttl?: "5m" | "1h" | undefined;
|
|
111
|
+
}, {
|
|
112
|
+
type: "ephemeral";
|
|
113
|
+
ttl?: "5m" | "1h" | undefined;
|
|
114
|
+
}>>;
|
|
84
115
|
}, "strip", z.ZodTypeAny, {
|
|
85
116
|
role: "user";
|
|
86
117
|
content: string;
|
|
87
118
|
name?: string | undefined;
|
|
119
|
+
cacheControl?: {
|
|
120
|
+
type: "ephemeral";
|
|
121
|
+
ttl?: "5m" | "1h" | undefined;
|
|
122
|
+
} | undefined;
|
|
88
123
|
}, {
|
|
89
124
|
role: "user";
|
|
90
125
|
content: string;
|
|
91
126
|
name?: string | undefined;
|
|
127
|
+
cacheControl?: {
|
|
128
|
+
type: "ephemeral";
|
|
129
|
+
ttl?: "5m" | "1h" | undefined;
|
|
130
|
+
} | undefined;
|
|
92
131
|
}>, z.ZodObject<{
|
|
93
132
|
role: z.ZodLiteral<"agent">;
|
|
94
133
|
content: z.ZodOptional<z.ZodString>;
|
|
@@ -121,10 +160,24 @@ declare const chatMessageSchema: z.ZodUnion<[z.ZodObject<{
|
|
|
121
160
|
id: string;
|
|
122
161
|
}>, "many">>;
|
|
123
162
|
name: z.ZodOptional<z.ZodString>;
|
|
163
|
+
cacheControl: z.ZodOptional<z.ZodObject<{
|
|
164
|
+
type: z.ZodLiteral<"ephemeral">;
|
|
165
|
+
ttl: z.ZodOptional<z.ZodUnion<[z.ZodLiteral<"5m">, z.ZodLiteral<"1h">]>>;
|
|
166
|
+
}, "strip", z.ZodTypeAny, {
|
|
167
|
+
type: "ephemeral";
|
|
168
|
+
ttl?: "5m" | "1h" | undefined;
|
|
169
|
+
}, {
|
|
170
|
+
type: "ephemeral";
|
|
171
|
+
ttl?: "5m" | "1h" | undefined;
|
|
172
|
+
}>>;
|
|
124
173
|
}, "strip", z.ZodTypeAny, {
|
|
125
174
|
role: "agent";
|
|
126
175
|
name?: string | undefined;
|
|
127
176
|
content?: string | undefined;
|
|
177
|
+
cacheControl?: {
|
|
178
|
+
type: "ephemeral";
|
|
179
|
+
ttl?: "5m" | "1h" | undefined;
|
|
180
|
+
} | undefined;
|
|
128
181
|
toolCalls?: {
|
|
129
182
|
function: {
|
|
130
183
|
name: string;
|
|
@@ -137,6 +190,10 @@ declare const chatMessageSchema: z.ZodUnion<[z.ZodObject<{
|
|
|
137
190
|
role: "agent";
|
|
138
191
|
name?: string | undefined;
|
|
139
192
|
content?: string | undefined;
|
|
193
|
+
cacheControl?: {
|
|
194
|
+
type: "ephemeral";
|
|
195
|
+
ttl?: "5m" | "1h" | undefined;
|
|
196
|
+
} | undefined;
|
|
140
197
|
toolCalls?: {
|
|
141
198
|
function: {
|
|
142
199
|
name: string;
|
|
@@ -150,16 +207,34 @@ declare const chatMessageSchema: z.ZodUnion<[z.ZodObject<{
|
|
|
150
207
|
content: z.ZodEffects<z.ZodUnion<[z.ZodString, z.ZodRecord<z.ZodString, z.ZodUnknown>]>, string, string | Record<string, unknown>>;
|
|
151
208
|
toolCallId: z.ZodString;
|
|
152
209
|
name: z.ZodOptional<z.ZodString>;
|
|
210
|
+
cacheControl: z.ZodOptional<z.ZodObject<{
|
|
211
|
+
type: z.ZodLiteral<"ephemeral">;
|
|
212
|
+
ttl: z.ZodOptional<z.ZodUnion<[z.ZodLiteral<"5m">, z.ZodLiteral<"1h">]>>;
|
|
213
|
+
}, "strip", z.ZodTypeAny, {
|
|
214
|
+
type: "ephemeral";
|
|
215
|
+
ttl?: "5m" | "1h" | undefined;
|
|
216
|
+
}, {
|
|
217
|
+
type: "ephemeral";
|
|
218
|
+
ttl?: "5m" | "1h" | undefined;
|
|
219
|
+
}>>;
|
|
153
220
|
}, "strip", z.ZodTypeAny, {
|
|
154
221
|
role: "tool";
|
|
155
222
|
content: string;
|
|
156
223
|
toolCallId: string;
|
|
157
224
|
name?: string | undefined;
|
|
225
|
+
cacheControl?: {
|
|
226
|
+
type: "ephemeral";
|
|
227
|
+
ttl?: "5m" | "1h" | undefined;
|
|
228
|
+
} | undefined;
|
|
158
229
|
}, {
|
|
159
230
|
role: "tool";
|
|
160
231
|
content: string | Record<string, unknown>;
|
|
161
232
|
toolCallId: string;
|
|
162
233
|
name?: string | undefined;
|
|
234
|
+
cacheControl?: {
|
|
235
|
+
type: "ephemeral";
|
|
236
|
+
ttl?: "5m" | "1h" | undefined;
|
|
237
|
+
} | undefined;
|
|
163
238
|
}>]>;
|
|
164
239
|
export declare function safeParseChatMessages(messages: unknown): ChatMessageTemplate[] | undefined;
|
|
165
240
|
export declare function parseChatMessages(messages: (z.infer<typeof chatMessageSchema> & {
|
|
@@ -80,11 +80,13 @@ class ChatMessageTemplate {
|
|
|
80
80
|
content;
|
|
81
81
|
name;
|
|
82
82
|
options;
|
|
83
|
-
|
|
83
|
+
cacheControl;
|
|
84
|
+
constructor(role, content, name, options, cacheControl) {
|
|
84
85
|
this.role = role;
|
|
85
86
|
this.content = content;
|
|
86
87
|
this.name = name;
|
|
87
88
|
this.options = options;
|
|
89
|
+
this.cacheControl = cacheControl;
|
|
88
90
|
}
|
|
89
91
|
async format(variables, options) {
|
|
90
92
|
options = { ...this.options, ...(0, type_utils_js_1.omitBy)(options ?? {}, (v) => (0, type_utils_js_1.isNil)(v)) };
|
|
@@ -103,29 +105,30 @@ class ChatMessageTemplate {
|
|
|
103
105
|
role: this.role,
|
|
104
106
|
content,
|
|
105
107
|
name: this.name,
|
|
108
|
+
cacheControl: this.cacheControl,
|
|
106
109
|
};
|
|
107
110
|
}
|
|
108
111
|
}
|
|
109
112
|
exports.ChatMessageTemplate = ChatMessageTemplate;
|
|
110
113
|
class SystemMessageTemplate extends ChatMessageTemplate {
|
|
111
|
-
static from(content, name, options) {
|
|
112
|
-
return new SystemMessageTemplate("system", content, name, options);
|
|
114
|
+
static from(content, name, options, cacheControl) {
|
|
115
|
+
return new SystemMessageTemplate("system", content, name, options, cacheControl);
|
|
113
116
|
}
|
|
114
117
|
}
|
|
115
118
|
exports.SystemMessageTemplate = SystemMessageTemplate;
|
|
116
119
|
class UserMessageTemplate extends ChatMessageTemplate {
|
|
117
|
-
static from(template, name, options) {
|
|
118
|
-
return new UserMessageTemplate("user", template, name, options);
|
|
120
|
+
static from(template, name, options, cacheControl) {
|
|
121
|
+
return new UserMessageTemplate("user", template, name, options, cacheControl);
|
|
119
122
|
}
|
|
120
123
|
}
|
|
121
124
|
exports.UserMessageTemplate = UserMessageTemplate;
|
|
122
125
|
class AgentMessageTemplate extends ChatMessageTemplate {
|
|
123
126
|
toolCalls;
|
|
124
|
-
static from(template, toolCalls, name, options) {
|
|
125
|
-
return new AgentMessageTemplate(template, toolCalls, name, options);
|
|
127
|
+
static from(template, toolCalls, name, options, cacheControl) {
|
|
128
|
+
return new AgentMessageTemplate(template, toolCalls, name, options, cacheControl);
|
|
126
129
|
}
|
|
127
|
-
constructor(content, toolCalls, name, options) {
|
|
128
|
-
super("agent", content, name, options);
|
|
130
|
+
constructor(content, toolCalls, name, options, cacheControl) {
|
|
131
|
+
super("agent", content, name, options, cacheControl);
|
|
129
132
|
this.toolCalls = toolCalls;
|
|
130
133
|
}
|
|
131
134
|
async format(_variables, _options) {
|
|
@@ -135,17 +138,18 @@ class AgentMessageTemplate extends ChatMessageTemplate {
|
|
|
135
138
|
// NOTE: agent message should not rendered by template
|
|
136
139
|
content: this.content,
|
|
137
140
|
toolCalls: this.toolCalls,
|
|
141
|
+
cacheControl: this.cacheControl,
|
|
138
142
|
};
|
|
139
143
|
}
|
|
140
144
|
}
|
|
141
145
|
exports.AgentMessageTemplate = AgentMessageTemplate;
|
|
142
146
|
class ToolMessageTemplate extends ChatMessageTemplate {
|
|
143
147
|
toolCallId;
|
|
144
|
-
static from(content, toolCallId, name, options) {
|
|
145
|
-
return new ToolMessageTemplate(content, toolCallId, name, options);
|
|
148
|
+
static from(content, toolCallId, name, options, cacheControl) {
|
|
149
|
+
return new ToolMessageTemplate(content, toolCallId, name, options, cacheControl);
|
|
146
150
|
}
|
|
147
|
-
constructor(content, toolCallId, name, options) {
|
|
148
|
-
super("tool", typeof content === "string" ? content : (0, yaml_1.stringify)(content), name, options);
|
|
151
|
+
constructor(content, toolCallId, name, options, cacheControl) {
|
|
152
|
+
super("tool", typeof content === "string" ? content : (0, yaml_1.stringify)(content), name, options, cacheControl);
|
|
149
153
|
this.toolCallId = toolCallId;
|
|
150
154
|
}
|
|
151
155
|
async format(_variables, _options) {
|
|
@@ -155,6 +159,7 @@ class ToolMessageTemplate extends ChatMessageTemplate {
|
|
|
155
159
|
// NOTE: tool result should not rendered by template
|
|
156
160
|
content: this.content,
|
|
157
161
|
toolCallId: this.toolCallId,
|
|
162
|
+
cacheControl: this.cacheControl,
|
|
158
163
|
};
|
|
159
164
|
}
|
|
160
165
|
}
|
|
@@ -179,11 +184,23 @@ const systemChatMessageSchema = zod_1.z.object({
|
|
|
179
184
|
role: zod_1.z.literal("system"),
|
|
180
185
|
content: zod_1.z.string(),
|
|
181
186
|
name: zod_1.z.string().optional(),
|
|
187
|
+
cacheControl: zod_1.z
|
|
188
|
+
.object({
|
|
189
|
+
type: zod_1.z.literal("ephemeral"),
|
|
190
|
+
ttl: zod_1.z.union([zod_1.z.literal("5m"), zod_1.z.literal("1h")]).optional(),
|
|
191
|
+
})
|
|
192
|
+
.optional(),
|
|
182
193
|
});
|
|
183
194
|
const userChatMessageSchema = zod_1.z.object({
|
|
184
195
|
role: zod_1.z.literal("user"),
|
|
185
196
|
content: zod_1.z.string(),
|
|
186
197
|
name: zod_1.z.string().optional(),
|
|
198
|
+
cacheControl: zod_1.z
|
|
199
|
+
.object({
|
|
200
|
+
type: zod_1.z.literal("ephemeral"),
|
|
201
|
+
ttl: zod_1.z.union([zod_1.z.literal("5m"), zod_1.z.literal("1h")]).optional(),
|
|
202
|
+
})
|
|
203
|
+
.optional(),
|
|
187
204
|
});
|
|
188
205
|
const chatModelOutputToolCallSchema = zod_1.z.object({
|
|
189
206
|
id: zod_1.z.string(),
|
|
@@ -198,6 +215,12 @@ const agentChatMessageSchema = zod_1.z.object({
|
|
|
198
215
|
content: zod_1.z.string().optional(),
|
|
199
216
|
toolCalls: zod_1.z.array(chatModelOutputToolCallSchema).optional(),
|
|
200
217
|
name: zod_1.z.string().optional(),
|
|
218
|
+
cacheControl: zod_1.z
|
|
219
|
+
.object({
|
|
220
|
+
type: zod_1.z.literal("ephemeral"),
|
|
221
|
+
ttl: zod_1.z.union([zod_1.z.literal("5m"), zod_1.z.literal("1h")]).optional(),
|
|
222
|
+
})
|
|
223
|
+
.optional(),
|
|
201
224
|
});
|
|
202
225
|
const toolChatMessageSchema = zod_1.z.object({
|
|
203
226
|
role: zod_1.z.literal("tool"),
|
|
@@ -206,6 +229,12 @@ const toolChatMessageSchema = zod_1.z.object({
|
|
|
206
229
|
.transform((val) => (typeof val !== "string" ? JSON.stringify(val) : val)),
|
|
207
230
|
toolCallId: zod_1.z.string(),
|
|
208
231
|
name: zod_1.z.string().optional(),
|
|
232
|
+
cacheControl: zod_1.z
|
|
233
|
+
.object({
|
|
234
|
+
type: zod_1.z.literal("ephemeral"),
|
|
235
|
+
ttl: zod_1.z.union([zod_1.z.literal("5m"), zod_1.z.literal("1h")]).optional(),
|
|
236
|
+
})
|
|
237
|
+
.optional(),
|
|
209
238
|
});
|
|
210
239
|
const chatMessageSchema = zod_1.z.union([
|
|
211
240
|
systemChatMessageSchema,
|
|
@@ -224,13 +253,13 @@ function parseChatMessages(messages) {
|
|
|
224
253
|
return messages.map((message) => {
|
|
225
254
|
switch (message.role) {
|
|
226
255
|
case "system":
|
|
227
|
-
return SystemMessageTemplate.from(message.content, message.name, message.options);
|
|
256
|
+
return SystemMessageTemplate.from(message.content, message.name, message.options, message.cacheControl);
|
|
228
257
|
case "user":
|
|
229
|
-
return UserMessageTemplate.from(message.content, message.name, message.options);
|
|
258
|
+
return UserMessageTemplate.from(message.content, message.name, message.options, message.cacheControl);
|
|
230
259
|
case "agent":
|
|
231
|
-
return AgentMessageTemplate.from(message.content, message.toolCalls, message.name, message.options);
|
|
260
|
+
return AgentMessageTemplate.from(message.content, message.toolCalls, message.name, message.options, message.cacheControl);
|
|
232
261
|
case "tool":
|
|
233
|
-
return ToolMessageTemplate.from(message.content, message.toolCallId, message.name, message.options);
|
|
262
|
+
return ToolMessageTemplate.from(message.content, message.toolCallId, message.name, message.options, message.cacheControl);
|
|
234
263
|
}
|
|
235
264
|
});
|
|
236
265
|
}
|
|
@@ -8,7 +8,7 @@ exports.estimateTokens = estimateTokens;
|
|
|
8
8
|
const CHAR_TYPE_RATIOS = {
|
|
9
9
|
chinese: 1.5, // Chinese characters: ~1.5 characters per token
|
|
10
10
|
word: 0.75, // English words: ~0.75 tokens per word (accounting for subword tokenization)
|
|
11
|
-
other:
|
|
11
|
+
other: 1, // Other characters (punctuation, numbers, etc.): ~1 character per token
|
|
12
12
|
};
|
|
13
13
|
/**
|
|
14
14
|
* Regular expressions for character type detection
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { AFS, type AFSExecOptions, type AFSExecResult, type AFSListOptions, type AFSListResult, type AFSModule, type AFSOptions, type AFSReadResult, type AFSSearchOptions } from "@aigne/afs";
|
|
2
2
|
import { nodejs } from "@aigne/platform-helpers/nodejs/index.js";
|
|
3
3
|
import type * as prompts from "@inquirer/prompts";
|
|
4
|
-
import { type ZodObject, type ZodType } from "zod";
|
|
4
|
+
import { type ZodObject, type ZodType, z } from "zod";
|
|
5
5
|
import type { AgentEvent, Context, UserContext } from "../aigne/context.js";
|
|
6
6
|
import type { MessagePayload } from "../aigne/message-queue.js";
|
|
7
7
|
import type { ContextUsage } from "../aigne/usage.js";
|
|
@@ -9,7 +9,7 @@ import type { Memory, MemoryAgent } from "../memory/memory.js";
|
|
|
9
9
|
import type { MemoryRecorderInput } from "../memory/recorder.js";
|
|
10
10
|
import type { MemoryRetrieverInput } from "../memory/retriever.js";
|
|
11
11
|
import { type Nullish, type PromiseOrValue, type XOr } from "../utils/type-utils.js";
|
|
12
|
-
import type { ChatModel } from "./chat-model.js";
|
|
12
|
+
import type { ChatModel, ChatModelInputMessage } from "./chat-model.js";
|
|
13
13
|
import type { GuideRailAgent, GuideRailAgentOutput } from "./guide-rail-agent.js";
|
|
14
14
|
import type { ImageModel } from "./image-model.js";
|
|
15
15
|
import { type GetterSchema, type TransferAgentOutput } from "./types.js";
|
|
@@ -118,7 +118,6 @@ export interface AgentOptions<I extends Message = Message, O extends Message = M
|
|
|
118
118
|
* agentSucceed, or agentFailed
|
|
119
119
|
*/
|
|
120
120
|
disableEvents?: boolean;
|
|
121
|
-
historyConfig?: Agent["historyConfig"];
|
|
122
121
|
/**
|
|
123
122
|
* One or more memory agents this agent can use
|
|
124
123
|
*/
|
|
@@ -173,6 +172,10 @@ export interface AgentInvokeOptions<U extends UserContext = UserContext> {
|
|
|
173
172
|
* This property only exists in the CLI context by command `aigne run`
|
|
174
173
|
*/
|
|
175
174
|
prompts?: typeof prompts;
|
|
175
|
+
/**
|
|
176
|
+
* The caller agent that invoked this agent
|
|
177
|
+
*/
|
|
178
|
+
caller?: Agent;
|
|
176
179
|
}
|
|
177
180
|
/**
|
|
178
181
|
* Agent is the base class for all agents.
|
|
@@ -211,15 +214,15 @@ export declare abstract class Agent<I extends Message = any, O extends Message =
|
|
|
211
214
|
parsed: object;
|
|
212
215
|
}): Promise<Agent<I, O>>;
|
|
213
216
|
constructor(options?: AgentOptions<I, O>);
|
|
217
|
+
afs?: AFS;
|
|
218
|
+
tag?: string;
|
|
214
219
|
/**
|
|
215
220
|
* List of memories this agent can use
|
|
216
221
|
*
|
|
217
222
|
* @deprecated use afs instead
|
|
218
223
|
*/
|
|
219
224
|
readonly memories: MemoryAgent[];
|
|
220
|
-
afs?: AFS;
|
|
221
225
|
asyncMemoryRecord?: boolean;
|
|
222
|
-
tag?: string;
|
|
223
226
|
/**
|
|
224
227
|
* Maximum number of memory items to retrieve
|
|
225
228
|
*/
|
|
@@ -349,11 +352,6 @@ export declare abstract class Agent<I extends Message = any, O extends Message =
|
|
|
349
352
|
* agentSucceed, or agentFailed
|
|
350
353
|
*/
|
|
351
354
|
private disableEvents?;
|
|
352
|
-
historyConfig?: {
|
|
353
|
-
disabled?: boolean;
|
|
354
|
-
maxTokens?: number;
|
|
355
|
-
maxItems?: number;
|
|
356
|
-
};
|
|
357
355
|
private subscriptions;
|
|
358
356
|
/**
|
|
359
357
|
* Attach agent to context:
|
|
@@ -455,7 +453,9 @@ export declare abstract class Agent<I extends Message = any, O extends Message =
|
|
|
455
453
|
* @param options Invocation options
|
|
456
454
|
* @returns Final processed output
|
|
457
455
|
*/
|
|
458
|
-
protected processAgentOutput(input: I, output: Exclude<AgentResponse<O>, AgentResponseStream<O>>, options: AgentInvokeOptions
|
|
456
|
+
protected processAgentOutput(input: I, output: Exclude<AgentResponse<O>, AgentResponseStream<O>>, { messages, ...options }: AgentInvokeOptions & {
|
|
457
|
+
messages?: ChatModelInputMessage[];
|
|
458
|
+
}): Promise<O>;
|
|
459
459
|
/**
|
|
460
460
|
* Process errors that occur during agent execution
|
|
461
461
|
*
|
|
@@ -517,6 +517,7 @@ export declare abstract class Agent<I extends Message = any, O extends Message =
|
|
|
517
517
|
*/
|
|
518
518
|
protected postprocess(input: I, output: O, options: AgentInvokeOptions): Promise<void>;
|
|
519
519
|
protected publishToTopics(output: Message, options: AgentInvokeOptions): Promise<void>;
|
|
520
|
+
formatOutput(output: O): PromiseOrValue<string>;
|
|
520
521
|
/**
|
|
521
522
|
* Core processing method of the agent, must be implemented in subclasses
|
|
522
523
|
*
|
|
@@ -783,12 +784,31 @@ export interface AgentResponseProgress {
|
|
|
783
784
|
} | {
|
|
784
785
|
event: "agentFailed";
|
|
785
786
|
error: Error;
|
|
787
|
+
} | {
|
|
788
|
+
event: "message";
|
|
789
|
+
message: ChatModelInputMessage;
|
|
786
790
|
}) & Omit<AgentEvent, "agent"> & {
|
|
787
791
|
agent: {
|
|
788
792
|
name: string;
|
|
789
793
|
};
|
|
790
794
|
};
|
|
791
795
|
}
|
|
796
|
+
export type AgentResponseProgressMessageItem = {
|
|
797
|
+
type: "text";
|
|
798
|
+
content: string;
|
|
799
|
+
} | {
|
|
800
|
+
type: "thinking";
|
|
801
|
+
thoughts: string;
|
|
802
|
+
} | {
|
|
803
|
+
type: "tool_use";
|
|
804
|
+
toolUseId: string;
|
|
805
|
+
name: string;
|
|
806
|
+
input: unknown;
|
|
807
|
+
} | {
|
|
808
|
+
type: "tool_result";
|
|
809
|
+
toolUseId: string;
|
|
810
|
+
content: unknown;
|
|
811
|
+
};
|
|
792
812
|
export declare function isAgentResponseProgress<T>(chunk: AgentResponseChunk<T>): chunk is AgentResponseProgress;
|
|
793
813
|
/**
|
|
794
814
|
* Creates a text delta for streaming responses
|
|
@@ -870,6 +890,17 @@ export interface FunctionAgentOptions<I extends Message = Message, O extends Mes
|
|
|
870
890
|
*/
|
|
871
891
|
export declare class FunctionAgent<I extends Message = Message, O extends Message = Message> extends Agent<I, O> {
|
|
872
892
|
tag: string;
|
|
893
|
+
static schema(): ZodObject<{
|
|
894
|
+
process: ZodType<FunctionAgentFn>;
|
|
895
|
+
}, "strip", z.ZodTypeAny, {
|
|
896
|
+
process: FunctionAgentFn<any, any, FunctionAgent<any, any>>;
|
|
897
|
+
}, {
|
|
898
|
+
process: FunctionAgentFn<any, any, FunctionAgent<any, any>>;
|
|
899
|
+
}>;
|
|
900
|
+
static load<I extends Message = any, O extends Message = any>(options: {
|
|
901
|
+
filepath: string;
|
|
902
|
+
parsed: object;
|
|
903
|
+
}): Promise<Agent<I, O>>;
|
|
873
904
|
/**
|
|
874
905
|
* Create a function agent from a function or options
|
|
875
906
|
*
|
|
@@ -1,4 +1,8 @@
|
|
|
1
1
|
import { type ZodObject, type ZodType, z } from "zod";
|
|
2
|
+
import { type NestAgentSchema } from "../loader/agent-yaml.js";
|
|
3
|
+
import type { AgentLoadOptions } from "../loader/index.js";
|
|
4
|
+
import { type Instructions } from "../loader/schema.js";
|
|
5
|
+
import type { CompactConfig, SessionMemoryConfig, UserMemoryConfig } from "../prompt/agent-session.js";
|
|
2
6
|
import { PromptBuilder } from "../prompt/prompt-builder.js";
|
|
3
7
|
import { Agent, type AgentInvokeOptions, type AgentOptions, type AgentProcessAsyncGenerator, type AgentProcessResult, type Message } from "./agent.js";
|
|
4
8
|
import type { ChatModel, ChatModelInput } from "./chat-model.js";
|
|
@@ -23,8 +27,6 @@ export interface AIAgentOptions<I extends Message = Message, O extends Message =
|
|
|
23
27
|
* more complex prompt templates
|
|
24
28
|
*/
|
|
25
29
|
instructions?: string | PromptBuilder;
|
|
26
|
-
autoReorderSystemMessages?: boolean;
|
|
27
|
-
autoMergeSystemMessages?: boolean;
|
|
28
30
|
/**
|
|
29
31
|
* Pick a message from input to use as the user's message
|
|
30
32
|
*/
|
|
@@ -124,6 +126,53 @@ export interface AIAgentOptions<I extends Message = Message, O extends Message =
|
|
|
124
126
|
*/
|
|
125
127
|
memoryPromptTemplate?: string;
|
|
126
128
|
useMemoriesFromContext?: boolean;
|
|
129
|
+
/**
|
|
130
|
+
* Agent session configuration
|
|
131
|
+
*
|
|
132
|
+
* Controls history recording, memory extraction, and conversation compaction.
|
|
133
|
+
* By default, mode is "auto" (enabled). Set `{ mode: "disabled" }` to disable
|
|
134
|
+
* for internal utility agents (extractors, compactors, etc.).
|
|
135
|
+
*
|
|
136
|
+
* @example
|
|
137
|
+
* ```typescript
|
|
138
|
+
* // Default behavior - session features enabled
|
|
139
|
+
* new AIAgent({
|
|
140
|
+
* session: {
|
|
141
|
+
* compact: { mode: "auto" },
|
|
142
|
+
* sessionMemory: { mode: "auto" },
|
|
143
|
+
* userMemory: { mode: "auto" }
|
|
144
|
+
* }
|
|
145
|
+
* })
|
|
146
|
+
*
|
|
147
|
+
* // Disable for internal utility agents
|
|
148
|
+
* new AIAgent({
|
|
149
|
+
* session: { mode: "disabled" }
|
|
150
|
+
* })
|
|
151
|
+
* ```
|
|
152
|
+
*/
|
|
153
|
+
session?: Partial<Omit<import("../prompt/agent-session.js").AgentSessionOptions, "sessionId" | "userId" | "agentId" | "afs">>;
|
|
154
|
+
}
|
|
155
|
+
export interface AIAgentLoadSchema {
|
|
156
|
+
instructions?: Instructions;
|
|
157
|
+
inputKey?: string;
|
|
158
|
+
inputFileKey?: string;
|
|
159
|
+
outputKey?: string;
|
|
160
|
+
outputFileKey?: string;
|
|
161
|
+
toolChoice?: AIAgentToolChoice;
|
|
162
|
+
toolCallsConcurrency?: number;
|
|
163
|
+
keepTextInToolUses?: boolean;
|
|
164
|
+
session?: {
|
|
165
|
+
mode?: "auto" | "disabled";
|
|
166
|
+
compact?: Omit<CompactConfig, "compactor"> & {
|
|
167
|
+
compactor?: NestAgentSchema;
|
|
168
|
+
};
|
|
169
|
+
sessionMemory?: Omit<SessionMemoryConfig, "extractor"> & {
|
|
170
|
+
extractor?: NestAgentSchema;
|
|
171
|
+
};
|
|
172
|
+
userMemory?: Omit<UserMemoryConfig, "extractor"> & {
|
|
173
|
+
extractor?: NestAgentSchema;
|
|
174
|
+
};
|
|
175
|
+
};
|
|
127
176
|
}
|
|
128
177
|
/**
|
|
129
178
|
* Tool choice options for AI agents
|
|
@@ -188,6 +237,14 @@ export declare const aiAgentOptionsSchema: ZodObject<{
|
|
|
188
237
|
*/
|
|
189
238
|
export declare class AIAgent<I extends Message = any, O extends Message = any> extends Agent<I, O> {
|
|
190
239
|
tag: string;
|
|
240
|
+
static schema<T>({ filepath }: {
|
|
241
|
+
filepath: string;
|
|
242
|
+
}): ZodType<T>;
|
|
243
|
+
static load<I extends Message = any, O extends Message = any>(options: {
|
|
244
|
+
filepath: string;
|
|
245
|
+
parsed: object;
|
|
246
|
+
options?: AgentLoadOptions;
|
|
247
|
+
}): Promise<Agent<I, O>>;
|
|
191
248
|
/**
|
|
192
249
|
* Create an AIAgent with the specified options
|
|
193
250
|
*
|
|
@@ -218,8 +275,6 @@ export declare class AIAgent<I extends Message = any, O extends Message = any> e
|
|
|
218
275
|
* {@includeCode ../../test/agents/ai-agent.test.ts#example-ai-agent-prompt-builder}
|
|
219
276
|
*/
|
|
220
277
|
instructions: PromptBuilder;
|
|
221
|
-
autoReorderSystemMessages?: boolean;
|
|
222
|
-
autoMergeSystemMessages?: boolean;
|
|
223
278
|
/**
|
|
224
279
|
* Pick a message from input to use as the user's message
|
|
225
280
|
*/
|
|
@@ -315,6 +370,10 @@ export declare class AIAgent<I extends Message = any, O extends Message = any> e
|
|
|
315
370
|
metadataEnd: string;
|
|
316
371
|
parse: (raw: string) => object;
|
|
317
372
|
};
|
|
373
|
+
/**
|
|
374
|
+
* Agent session configuration
|
|
375
|
+
*/
|
|
376
|
+
session?: Partial<Omit<import("../prompt/agent-session.js").AgentSessionOptions, "sessionId" | "userId" | "agentId" | "afs">>;
|
|
318
377
|
get inputSchema(): ZodType<I>;
|
|
319
378
|
/**
|
|
320
379
|
* Process an input message and generate a response
|