@aigne/core 1.72.0-beta.1 → 1.72.0-beta.3
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 +31 -0
- package/lib/cjs/agents/chat-model.d.ts +160 -0
- package/lib/cjs/agents/chat-model.js +38 -1
- package/lib/cjs/agents/image-model.d.ts +15 -0
- package/lib/cjs/agents/image-model.js +2 -0
- package/lib/cjs/agents/video-model.d.ts +15 -0
- package/lib/cjs/agents/video-model.js +2 -0
- package/lib/cjs/aigne/usage.d.ts +5 -0
- package/lib/cjs/aigne/usage.js +6 -0
- package/lib/cjs/loader/agent-yaml.d.ts +4 -0
- package/lib/cjs/loader/agent-yaml.js +15 -5
- package/lib/cjs/prompt/context/afs/index.js +1 -2
- package/lib/cjs/prompt/skills/afs/base.d.ts +4 -0
- package/lib/cjs/prompt/skills/afs/base.js +8 -0
- package/lib/cjs/prompt/skills/afs/delete.d.ts +3 -2
- package/lib/cjs/prompt/skills/afs/delete.js +2 -2
- package/lib/cjs/prompt/skills/afs/edit.d.ts +3 -2
- package/lib/cjs/prompt/skills/afs/edit.js +2 -2
- package/lib/cjs/prompt/skills/afs/exec.d.ts +3 -2
- package/lib/cjs/prompt/skills/afs/exec.js +7 -4
- package/lib/cjs/prompt/skills/afs/list.d.ts +3 -2
- package/lib/cjs/prompt/skills/afs/list.js +6 -13
- package/lib/cjs/prompt/skills/afs/read.d.ts +3 -2
- package/lib/cjs/prompt/skills/afs/read.js +2 -2
- package/lib/cjs/prompt/skills/afs/rename.d.ts +3 -2
- package/lib/cjs/prompt/skills/afs/rename.js +2 -2
- package/lib/cjs/prompt/skills/afs/search.d.ts +3 -2
- package/lib/cjs/prompt/skills/afs/search.js +2 -2
- package/lib/cjs/prompt/skills/afs/write.d.ts +3 -2
- package/lib/cjs/prompt/skills/afs/write.js +2 -2
- package/lib/cjs/prompt/template.d.ts +82 -7
- package/lib/cjs/prompt/template.js +46 -17
- package/lib/dts/agents/chat-model.d.ts +160 -0
- package/lib/dts/agents/image-model.d.ts +15 -0
- package/lib/dts/agents/video-model.d.ts +15 -0
- package/lib/dts/aigne/usage.d.ts +5 -0
- package/lib/dts/loader/agent-yaml.d.ts +4 -0
- package/lib/dts/prompt/skills/afs/base.d.ts +4 -0
- package/lib/dts/prompt/skills/afs/delete.d.ts +3 -2
- package/lib/dts/prompt/skills/afs/edit.d.ts +3 -2
- package/lib/dts/prompt/skills/afs/exec.d.ts +3 -2
- package/lib/dts/prompt/skills/afs/list.d.ts +3 -2
- package/lib/dts/prompt/skills/afs/read.d.ts +3 -2
- package/lib/dts/prompt/skills/afs/rename.d.ts +3 -2
- package/lib/dts/prompt/skills/afs/search.d.ts +3 -2
- package/lib/dts/prompt/skills/afs/write.d.ts +3 -2
- package/lib/dts/prompt/template.d.ts +82 -7
- package/lib/esm/agents/chat-model.d.ts +160 -0
- package/lib/esm/agents/chat-model.js +37 -0
- package/lib/esm/agents/image-model.d.ts +15 -0
- package/lib/esm/agents/image-model.js +2 -0
- package/lib/esm/agents/video-model.d.ts +15 -0
- package/lib/esm/agents/video-model.js +2 -0
- package/lib/esm/aigne/usage.d.ts +5 -0
- package/lib/esm/aigne/usage.js +6 -0
- package/lib/esm/loader/agent-yaml.d.ts +4 -0
- package/lib/esm/loader/agent-yaml.js +15 -5
- package/lib/esm/prompt/context/afs/index.js +1 -2
- package/lib/esm/prompt/skills/afs/base.d.ts +4 -0
- package/lib/esm/prompt/skills/afs/base.js +4 -0
- package/lib/esm/prompt/skills/afs/delete.d.ts +3 -2
- package/lib/esm/prompt/skills/afs/delete.js +2 -2
- package/lib/esm/prompt/skills/afs/edit.d.ts +3 -2
- package/lib/esm/prompt/skills/afs/edit.js +2 -2
- package/lib/esm/prompt/skills/afs/exec.d.ts +3 -2
- package/lib/esm/prompt/skills/afs/exec.js +7 -4
- package/lib/esm/prompt/skills/afs/list.d.ts +3 -2
- package/lib/esm/prompt/skills/afs/list.js +6 -13
- package/lib/esm/prompt/skills/afs/read.d.ts +3 -2
- package/lib/esm/prompt/skills/afs/read.js +2 -2
- package/lib/esm/prompt/skills/afs/rename.d.ts +3 -2
- package/lib/esm/prompt/skills/afs/rename.js +2 -2
- package/lib/esm/prompt/skills/afs/search.d.ts +3 -2
- package/lib/esm/prompt/skills/afs/search.js +2 -2
- package/lib/esm/prompt/skills/afs/write.d.ts +3 -2
- package/lib/esm/prompt/skills/afs/write.js +2 -2
- package/lib/esm/prompt/template.d.ts +82 -7
- package/lib/esm/prompt/template.js +46 -17
- package/package.json +5 -5
|
@@ -2,15 +2,18 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.AFSExecAgent = void 0;
|
|
4
4
|
const zod_1 = require("zod");
|
|
5
|
-
const
|
|
6
|
-
class AFSExecAgent extends
|
|
5
|
+
const base_js_1 = require("./base.js");
|
|
6
|
+
class AFSExecAgent extends base_js_1.AFSSkillBase {
|
|
7
7
|
constructor(options) {
|
|
8
8
|
super({
|
|
9
9
|
name: "afs_exec",
|
|
10
|
-
description:
|
|
10
|
+
description: `
|
|
11
|
+
Execute files marked as executable in the Agentic File System (AFS).
|
|
12
|
+
Use this to run executable files registered at a given path with specified arguments.
|
|
13
|
+
`.trim(),
|
|
11
14
|
...options,
|
|
12
15
|
inputSchema: zod_1.z.object({
|
|
13
|
-
path: zod_1.z.string().describe("Absolute path to the executable
|
|
16
|
+
path: zod_1.z.string().describe("Absolute path to the executable file in AFS"),
|
|
14
17
|
args: zod_1.z.string().describe("JSON string of arguments matching the function's input schema"),
|
|
15
18
|
}),
|
|
16
19
|
outputSchema: zod_1.z.object({
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { AFSListOptions } from "@aigne/afs";
|
|
2
|
-
import {
|
|
2
|
+
import type { AgentInvokeOptions, AgentOptions, Message } from "../../../agents/agent.js";
|
|
3
|
+
import { AFSSkillBase } from "./base.js";
|
|
3
4
|
export interface AFSListInput extends Message {
|
|
4
5
|
path: string;
|
|
5
6
|
options?: AFSListOptions;
|
|
@@ -15,7 +16,7 @@ export interface AFSListOutput extends Message {
|
|
|
15
16
|
export interface AFSListAgentOptions extends AgentOptions<AFSListInput, AFSListOutput> {
|
|
16
17
|
afs: NonNullable<AgentOptions<AFSListInput, AFSListOutput>["afs"]>;
|
|
17
18
|
}
|
|
18
|
-
export declare class AFSListAgent extends
|
|
19
|
+
export declare class AFSListAgent extends AFSSkillBase<AFSListInput, AFSListOutput> {
|
|
19
20
|
constructor(options: AFSListAgentOptions);
|
|
20
21
|
process(input: AFSListInput, _options: AgentInvokeOptions): Promise<AFSListOutput>;
|
|
21
22
|
}
|
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.AFSListAgent = void 0;
|
|
4
4
|
const zod_1 = require("zod");
|
|
5
|
-
const
|
|
6
|
-
class AFSListAgent extends
|
|
5
|
+
const base_js_1 = require("./base.js");
|
|
6
|
+
class AFSListAgent extends base_js_1.AFSSkillBase {
|
|
7
7
|
constructor(options) {
|
|
8
8
|
super({
|
|
9
9
|
name: "afs_list",
|
|
@@ -23,10 +23,10 @@ class AFSListAgent extends agent_js_1.Agent {
|
|
|
23
23
|
.optional()
|
|
24
24
|
.describe("Maximum number of children to list per directory"),
|
|
25
25
|
format: zod_1.z
|
|
26
|
-
.union([zod_1.z.literal("
|
|
26
|
+
.union([zod_1.z.literal("simple-list"), zod_1.z.literal("tree")])
|
|
27
27
|
.optional()
|
|
28
|
-
.default("
|
|
29
|
-
.describe("Output format, either '
|
|
28
|
+
.default("simple-list")
|
|
29
|
+
.describe("Output format, either 'simple-list', or 'tree', default is 'simple-list'"),
|
|
30
30
|
})
|
|
31
31
|
.optional(),
|
|
32
32
|
}),
|
|
@@ -34,14 +34,7 @@ class AFSListAgent extends agent_js_1.Agent {
|
|
|
34
34
|
status: zod_1.z.string(),
|
|
35
35
|
tool: zod_1.z.string(),
|
|
36
36
|
path: zod_1.z.string(),
|
|
37
|
-
options: zod_1.z
|
|
38
|
-
.object({
|
|
39
|
-
maxDepth: zod_1.z.number().optional(),
|
|
40
|
-
disableGitignore: zod_1.z.boolean().optional(),
|
|
41
|
-
maxChildren: zod_1.z.number().optional(),
|
|
42
|
-
format: zod_1.z.union([zod_1.z.literal("tree"), zod_1.z.literal("list")]).optional(),
|
|
43
|
-
})
|
|
44
|
-
.optional(),
|
|
37
|
+
options: zod_1.z.record(zod_1.z.any()).optional(),
|
|
45
38
|
message: zod_1.z.string().optional(),
|
|
46
39
|
data: zod_1.z.unknown(),
|
|
47
40
|
}),
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { AFSEntry } from "@aigne/afs";
|
|
2
|
-
import {
|
|
2
|
+
import type { AgentInvokeOptions, AgentOptions, Message } from "../../../agents/agent.js";
|
|
3
|
+
import { AFSSkillBase } from "./base.js";
|
|
3
4
|
export interface AFSReadInput extends Message {
|
|
4
5
|
path: string;
|
|
5
6
|
withLineNumbers?: boolean;
|
|
@@ -15,7 +16,7 @@ export interface AFSReadOutput extends Message {
|
|
|
15
16
|
export interface AFSReadAgentOptions extends AgentOptions<AFSReadInput, AFSReadOutput> {
|
|
16
17
|
afs: NonNullable<AgentOptions<AFSReadInput, AFSReadOutput>["afs"]>;
|
|
17
18
|
}
|
|
18
|
-
export declare class AFSReadAgent extends
|
|
19
|
+
export declare class AFSReadAgent extends AFSSkillBase<AFSReadInput, AFSReadOutput> {
|
|
19
20
|
constructor(options: AFSReadAgentOptions);
|
|
20
21
|
process(input: AFSReadInput, _options: AgentInvokeOptions): Promise<AFSReadOutput>;
|
|
21
22
|
}
|
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.AFSReadAgent = void 0;
|
|
4
4
|
const zod_1 = require("zod");
|
|
5
|
-
const
|
|
6
|
-
class AFSReadAgent extends
|
|
5
|
+
const base_js_1 = require("./base.js");
|
|
6
|
+
class AFSReadAgent extends base_js_1.AFSSkillBase {
|
|
7
7
|
constructor(options) {
|
|
8
8
|
super({
|
|
9
9
|
name: "afs_read",
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { AgentInvokeOptions, AgentOptions, Message } from "../../../agents/agent.js";
|
|
2
|
+
import { AFSSkillBase } from "./base.js";
|
|
2
3
|
export interface AFSRenameInput extends Message {
|
|
3
4
|
oldPath: string;
|
|
4
5
|
newPath: string;
|
|
@@ -14,7 +15,7 @@ export interface AFSRenameOutput extends Message {
|
|
|
14
15
|
export interface AFSRenameAgentOptions extends AgentOptions<AFSRenameInput, AFSRenameOutput> {
|
|
15
16
|
afs: NonNullable<AgentOptions<AFSRenameInput, AFSRenameOutput>["afs"]>;
|
|
16
17
|
}
|
|
17
|
-
export declare class AFSRenameAgent extends
|
|
18
|
+
export declare class AFSRenameAgent extends AFSSkillBase<AFSRenameInput, AFSRenameOutput> {
|
|
18
19
|
constructor(options: AFSRenameAgentOptions);
|
|
19
20
|
process(input: AFSRenameInput, _options: AgentInvokeOptions): Promise<AFSRenameOutput>;
|
|
20
21
|
}
|
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.AFSRenameAgent = void 0;
|
|
4
4
|
const zod_1 = require("zod");
|
|
5
|
-
const
|
|
6
|
-
class AFSRenameAgent extends
|
|
5
|
+
const base_js_1 = require("./base.js");
|
|
6
|
+
class AFSRenameAgent extends base_js_1.AFSSkillBase {
|
|
7
7
|
constructor(options) {
|
|
8
8
|
super({
|
|
9
9
|
name: "afs_rename",
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { AFSEntry, AFSSearchOptions } from "@aigne/afs";
|
|
2
|
-
import {
|
|
2
|
+
import type { AgentInvokeOptions, AgentOptions, Message } from "../../../agents/agent.js";
|
|
3
|
+
import { AFSSkillBase } from "./base.js";
|
|
3
4
|
export interface AFSSearchInput extends Message {
|
|
4
5
|
path: string;
|
|
5
6
|
query: string;
|
|
@@ -17,7 +18,7 @@ export interface AFSSearchOutput extends Message {
|
|
|
17
18
|
export interface AFSSearchAgentOptions extends AgentOptions<AFSSearchInput, AFSSearchOutput> {
|
|
18
19
|
afs: NonNullable<AgentOptions<AFSSearchInput, AFSSearchOutput>["afs"]>;
|
|
19
20
|
}
|
|
20
|
-
export declare class AFSSearchAgent extends
|
|
21
|
+
export declare class AFSSearchAgent extends AFSSkillBase<AFSSearchInput, AFSSearchOutput> {
|
|
21
22
|
constructor(options: AFSSearchAgentOptions);
|
|
22
23
|
process(input: AFSSearchInput, _options: AgentInvokeOptions): Promise<AFSSearchOutput>;
|
|
23
24
|
}
|
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.AFSSearchAgent = void 0;
|
|
4
4
|
const zod_1 = require("zod");
|
|
5
|
-
const
|
|
6
|
-
class AFSSearchAgent extends
|
|
5
|
+
const base_js_1 = require("./base.js");
|
|
6
|
+
class AFSSearchAgent extends base_js_1.AFSSkillBase {
|
|
7
7
|
constructor(options) {
|
|
8
8
|
super({
|
|
9
9
|
name: "afs_search",
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { AgentInvokeOptions, AgentOptions, Message } from "../../../agents/agent.js";
|
|
2
|
+
import { AFSSkillBase } from "./base.js";
|
|
2
3
|
export interface AFSWriteInput extends Message {
|
|
3
4
|
path: string;
|
|
4
5
|
content: string;
|
|
@@ -13,7 +14,7 @@ export interface AFSWriteOutput extends Message {
|
|
|
13
14
|
export interface AFSWriteAgentOptions extends AgentOptions<AFSWriteInput, AFSWriteOutput> {
|
|
14
15
|
afs: NonNullable<AgentOptions<AFSWriteInput, AFSWriteOutput>["afs"]>;
|
|
15
16
|
}
|
|
16
|
-
export declare class AFSWriteAgent extends
|
|
17
|
+
export declare class AFSWriteAgent extends AFSSkillBase<AFSWriteInput, AFSWriteOutput> {
|
|
17
18
|
constructor(options: AFSWriteAgentOptions);
|
|
18
19
|
process(input: AFSWriteInput, _options: AgentInvokeOptions): Promise<AFSWriteOutput>;
|
|
19
20
|
}
|
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.AFSWriteAgent = void 0;
|
|
4
4
|
const zod_1 = require("zod");
|
|
5
|
-
const
|
|
6
|
-
class AFSWriteAgent extends
|
|
5
|
+
const base_js_1 = require("./base.js");
|
|
6
|
+
class AFSWriteAgent extends base_js_1.AFSSkillBase {
|
|
7
7
|
constructor(options) {
|
|
8
8
|
super({
|
|
9
9
|
name: "afs_write",
|
|
@@ -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
45
|
role: "agent" | "system" | "user" | "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
57
|
role: "agent" | "system" | "user" | "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,6 +160,16 @@ 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;
|
|
@@ -133,6 +182,10 @@ declare const chatMessageSchema: z.ZodUnion<[z.ZodObject<{
|
|
|
133
182
|
type: "function";
|
|
134
183
|
id: string;
|
|
135
184
|
}[] | undefined;
|
|
185
|
+
cacheControl?: {
|
|
186
|
+
type: "ephemeral";
|
|
187
|
+
ttl?: "5m" | "1h" | undefined;
|
|
188
|
+
} | undefined;
|
|
136
189
|
}, {
|
|
137
190
|
role: "agent";
|
|
138
191
|
name?: string | undefined;
|
|
@@ -145,21 +198,43 @@ declare const chatMessageSchema: z.ZodUnion<[z.ZodObject<{
|
|
|
145
198
|
type: "function";
|
|
146
199
|
id: string;
|
|
147
200
|
}[] | undefined;
|
|
201
|
+
cacheControl?: {
|
|
202
|
+
type: "ephemeral";
|
|
203
|
+
ttl?: "5m" | "1h" | undefined;
|
|
204
|
+
} | undefined;
|
|
148
205
|
}>, z.ZodObject<{
|
|
149
206
|
role: z.ZodLiteral<"tool">;
|
|
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
|
}
|