create-deepagent-server 0.1.0 → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +83 -8
- package/package.json +1 -1
- package/src/args.js +6 -4
- package/src/cli.js +1 -4
- package/src/dependencies.js +1 -1
- package/src/prompts.js +1 -0
- package/src/registry.js +8 -8
- package/src/scaffold.js +21 -7
- package/src/setup.js +2 -0
- package/src/version.js +1 -1
- package/src/versions.js +1 -1
- package/templates/deepagent/js/scripts/check.js +34 -11
- package/templates/deepagent/js/scripts/dev.js +9 -0
- package/templates/deepagent/js/src/agents/factory.js +2 -1
- package/templates/deepagent/js/src/agents/prompts/loader.js +9 -0
- package/templates/deepagent/js/src/agents/prompts/supervisor.js +4 -0
- package/templates/deepagent/js/src/agents/prompts/supervisor.md +1 -2
- package/templates/deepagent/js/src/agents/state/types.js +1 -0
- package/templates/deepagent/js/src/agents/subagents/analyst.js +4 -3
- package/templates/deepagent/js/src/agents/subagents/coder.js +1 -0
- package/templates/deepagent/js/src/agents/subagents/index.js +5 -4
- package/templates/deepagent/js/src/agents/supervisor.js +12 -4
- package/templates/deepagent/js/src/api/app.js +7 -0
- package/templates/deepagent/js/src/api/middleware/auth.js +9 -0
- package/templates/deepagent/js/src/api/middleware/error.js +4 -0
- package/templates/deepagent/js/src/api/routes/agent.js +19 -49
- package/templates/deepagent/js/src/api/routes/health.js +12 -3
- package/templates/deepagent/js/src/api/routes/session.js +28 -48
- package/templates/deepagent/js/src/app.js +31 -12
- package/templates/deepagent/js/src/backends/composite.js +2 -0
- package/templates/deepagent/js/src/backends/filesystem.js +1 -0
- package/templates/deepagent/js/src/backends/index.js +35 -3
- package/templates/deepagent/js/src/backends/sandbox.js +3 -0
- package/templates/deepagent/js/src/config/agent.js +1 -0
- package/templates/deepagent/js/src/config/database.js +19 -0
- package/templates/deepagent/js/src/config/env.js +46 -23
- package/templates/deepagent/js/src/config/index.js +13 -3
- package/templates/deepagent/js/src/graph/checkpointer.js +10 -2
- package/templates/deepagent/js/src/graph/compile.js +1 -0
- package/templates/deepagent/js/src/graph/store.js +10 -2
- package/templates/deepagent/js/src/index.js +9 -2
- package/templates/deepagent/js/src/memory/index.js +2 -0
- package/templates/deepagent/js/src/memory/manager.js +21 -10
- package/templates/deepagent/js/src/memory/store.js +7 -0
- package/templates/deepagent/js/src/middleware/approval.js +6 -1
- package/templates/deepagent/js/src/middleware/context.js +5 -0
- package/templates/deepagent/js/src/middleware/logging.js +47 -43
- package/templates/deepagent/js/src/middleware/security.js +7 -0
- package/templates/deepagent/js/src/model/config.js +38 -0
- package/templates/deepagent/js/src/model/index.js +9 -0
- package/templates/deepagent/js/src/model/openai-compatible.js +18 -0
- package/templates/deepagent/js/src/model/presets.js +71 -0
- package/templates/deepagent/js/src/sandbox/config.js +12 -0
- package/templates/deepagent/js/src/sandbox/index.js +3 -0
- package/templates/deepagent/js/src/sandbox/manager.js +161 -0
- package/templates/deepagent/js/src/sandbox/opensandbox.js +195 -0
- package/templates/deepagent/js/src/schemas/agent.js +7 -0
- package/templates/deepagent/js/src/schemas/common.js +5 -0
- package/templates/deepagent/js/src/schemas/locale.js +1 -0
- package/templates/deepagent/js/src/schemas/session.js +4 -0
- package/templates/deepagent/js/src/services/{agent.service.js → agent.js} +39 -20
- package/templates/deepagent/js/src/services/{memory.service.js → memory.js} +13 -7
- package/templates/deepagent/js/src/services/{session.service.js → session.js} +43 -17
- package/templates/deepagent/js/src/skills/index.js +4 -0
- package/templates/deepagent/js/src/skills/loader.js +20 -10
- package/templates/deepagent/js/src/storage/database/client.js +57 -0
- package/templates/deepagent/{ts/src/infrastructure → js/src/storage}/database/migrations/001_init.sql +1 -1
- package/templates/deepagent/js/src/{infrastructure → storage}/logger/index.js +2 -0
- package/templates/deepagent/js/src/{infrastructure → storage}/redis/client.js +25 -19
- package/templates/deepagent/js/src/{infrastructure → storage}/shutdown/index.js +20 -13
- package/templates/deepagent/js/src/tools/database/index.js +1 -1
- package/templates/deepagent/js/src/tools/database/query.js +44 -32
- package/templates/deepagent/js/src/tools/filesystem/index.js +16 -0
- package/templates/deepagent/js/src/tools/index.js +6 -11
- package/templates/deepagent/js/src/tools/mcp/client.js +7 -0
- package/templates/deepagent/js/src/tools/mcp/connections.js +13 -3
- package/templates/deepagent/js/src/tools/mcp/index.js +2 -0
- package/templates/deepagent/js/src/tools/mcp/registry.js +15 -11
- package/templates/deepagent/js/src/utils/errors.js +9 -0
- package/templates/deepagent/js/src/utils/helpers.js +15 -0
- package/templates/deepagent/js/src/utils/validation.js +15 -0
- package/templates/deepagent/js/tests/agents/prompts.test.js +9 -3
- package/templates/deepagent/js/tests/agents/supervisor.test.js +13 -5
- package/templates/deepagent/js/tests/config/database.test.js +40 -0
- package/templates/deepagent/js/tests/integration/api.test.js +18 -3
- package/templates/deepagent/js/tests/middleware/security.test.js +4 -1
- package/templates/deepagent/js/tests/model/config.test.js +61 -0
- package/templates/deepagent/js/tests/sandbox/config.test.js +46 -0
- package/templates/deepagent/js/tests/sandbox/manager.test.js +236 -0
- package/templates/deepagent/js/tests/sandbox/opensandbox.test.js +173 -0
- package/templates/deepagent/js/tests/services/session.test.js +41 -0
- package/templates/deepagent/js/tests/tools/query.test.js +5 -1
- package/templates/deepagent/shared/README.md +101 -14
- package/templates/deepagent/shared/_env.example +40 -10
- package/templates/deepagent/shared/deployment/docker-compose.yml +8 -4
- package/templates/deepagent/shared/resources/AGENTS.md +1 -1
- package/templates/deepagent/ts/scripts/check.ts +19 -11
- package/templates/deepagent/ts/scripts/copy-assets.ts +2 -0
- package/templates/deepagent/ts/src/agents/factory.ts +1 -1
- package/templates/deepagent/ts/src/agents/prompts/loader.ts +1 -0
- package/templates/deepagent/ts/src/agents/prompts/supervisor.md +1 -2
- package/templates/deepagent/ts/src/agents/prompts/supervisor.ts +1 -1
- package/templates/deepagent/ts/src/agents/subagents/analyst.ts +7 -3
- package/templates/deepagent/ts/src/agents/subagents/index.ts +4 -5
- package/templates/deepagent/ts/src/agents/supervisor.ts +11 -9
- package/templates/deepagent/ts/src/api/app.ts +4 -4
- package/templates/deepagent/ts/src/api/middleware/auth.ts +1 -0
- package/templates/deepagent/ts/src/api/middleware/error.ts +1 -1
- package/templates/deepagent/ts/src/api/routes/agent.ts +13 -58
- package/templates/deepagent/ts/src/api/routes/health.ts +5 -3
- package/templates/deepagent/ts/src/api/routes/session.ts +21 -51
- package/templates/deepagent/ts/src/app.ts +19 -12
- package/templates/deepagent/ts/src/backends/index.ts +41 -7
- package/templates/deepagent/ts/src/backends/sandbox.ts +1 -0
- package/templates/deepagent/ts/src/config/database.ts +21 -0
- package/templates/deepagent/ts/src/config/env.ts +32 -28
- package/templates/deepagent/ts/src/config/index.ts +12 -4
- package/templates/deepagent/ts/src/graph/checkpointer.ts +5 -2
- package/templates/deepagent/ts/src/graph/store.ts +5 -2
- package/templates/deepagent/ts/src/index.ts +2 -2
- package/templates/deepagent/ts/src/memory/manager.ts +12 -10
- package/templates/deepagent/ts/src/memory/store.ts +2 -0
- package/templates/deepagent/ts/src/middleware/approval.ts +2 -2
- package/templates/deepagent/ts/src/middleware/logging.ts +43 -44
- package/templates/deepagent/ts/src/middleware/security.ts +1 -0
- package/templates/deepagent/ts/src/model/config.ts +56 -0
- package/templates/deepagent/ts/src/model/index.ts +14 -0
- package/templates/deepagent/ts/src/model/openai-compatible.ts +21 -0
- package/templates/deepagent/ts/src/model/presets.ts +82 -0
- package/templates/deepagent/ts/src/sandbox/config.ts +30 -0
- package/templates/deepagent/ts/src/sandbox/index.ts +7 -0
- package/templates/deepagent/ts/src/sandbox/manager.ts +176 -0
- package/templates/deepagent/ts/src/sandbox/opensandbox.ts +216 -0
- package/templates/deepagent/ts/src/services/{agent.service.ts → agent.ts} +22 -22
- package/templates/deepagent/ts/src/services/{memory.service.ts → memory.ts} +7 -7
- package/templates/deepagent/ts/src/services/{session.service.ts → session.ts} +29 -19
- package/templates/deepagent/ts/src/skills/loader.ts +6 -10
- package/templates/deepagent/ts/src/storage/database/client.ts +65 -0
- package/templates/deepagent/{js/src/infrastructure → ts/src/storage}/database/migrations/001_init.sql +1 -1
- package/templates/deepagent/ts/src/{infrastructure → storage}/redis/client.ts +14 -21
- package/templates/deepagent/ts/src/{infrastructure → storage}/shutdown/index.ts +10 -13
- package/templates/deepagent/ts/src/tools/database/index.ts +5 -1
- package/templates/deepagent/ts/src/tools/database/query.ts +40 -32
- package/templates/deepagent/ts/src/tools/filesystem/index.ts +2 -0
- package/templates/deepagent/ts/src/tools/index.ts +10 -8
- package/templates/deepagent/ts/src/tools/mcp/client.ts +1 -0
- package/templates/deepagent/ts/src/tools/mcp/connections.ts +3 -3
- package/templates/deepagent/ts/src/tools/mcp/registry.ts +9 -12
- package/templates/deepagent/ts/src/utils/helpers.ts +5 -0
- package/templates/deepagent/ts/src/utils/validation.ts +17 -0
- package/templates/deepagent/ts/tests/agents/prompts.test.ts +3 -3
- package/templates/deepagent/ts/tests/agents/supervisor.test.ts +5 -5
- package/templates/deepagent/ts/tests/config/database.test.ts +40 -0
- package/templates/deepagent/ts/tests/integration/api.test.ts +5 -6
- package/templates/deepagent/ts/tests/middleware/security.test.ts +1 -1
- package/templates/deepagent/ts/tests/model/config.test.ts +61 -0
- package/templates/deepagent/ts/tests/sandbox/config.test.ts +46 -0
- package/templates/deepagent/ts/tests/sandbox/manager.test.ts +241 -0
- package/templates/deepagent/ts/tests/sandbox/opensandbox.test.ts +188 -0
- package/templates/deepagent/ts/tests/services/session.test.ts +45 -0
- package/templates/deepagent/ts/tests/tools/query.test.ts +1 -1
- package/templates/deepagent/js/src/agents/prompts/subagents/researcher.md +0 -16
- package/templates/deepagent/js/src/agents/subagents/researcher.js +0 -12
- package/templates/deepagent/js/src/config/model.js +0 -34
- package/templates/deepagent/js/src/infrastructure/database/client.js +0 -43
- package/templates/deepagent/js/src/tools/search/index.js +0 -1
- package/templates/deepagent/js/src/tools/search/web-search.js +0 -54
- package/templates/deepagent/shared/skills/research/SKILL.md +0 -31
- package/templates/deepagent/ts/src/agents/prompts/subagents/researcher.md +0 -16
- package/templates/deepagent/ts/src/agents/subagents/researcher.ts +0 -15
- package/templates/deepagent/ts/src/config/model.ts +0 -49
- package/templates/deepagent/ts/src/infrastructure/database/client.ts +0 -61
- package/templates/deepagent/ts/src/tools/search/index.ts +0 -1
- package/templates/deepagent/ts/src/tools/search/web-search.ts +0 -82
- /package/templates/deepagent/ts/src/{infrastructure → storage}/logger/index.ts +0 -0
|
@@ -0,0 +1,241 @@
|
|
|
1
|
+
import assert from "node:assert/strict";
|
|
2
|
+
import test from "node:test";
|
|
3
|
+
|
|
4
|
+
import type { SandboxConfig } from "../../src/sandbox/config.js";
|
|
5
|
+
import {
|
|
6
|
+
SandboxManager,
|
|
7
|
+
threadIdFromRuntime,
|
|
8
|
+
type OpenSandboxBackend,
|
|
9
|
+
} from "../../src/sandbox/index.js";
|
|
10
|
+
|
|
11
|
+
const sandboxConfig = (overrides: Partial<SandboxConfig> = {}): SandboxConfig => ({
|
|
12
|
+
enabled: true,
|
|
13
|
+
domain: "localhost:8080",
|
|
14
|
+
protocol: "http",
|
|
15
|
+
image: "python:3.12",
|
|
16
|
+
workspaceRoot: "/workspace",
|
|
17
|
+
...overrides,
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
const createFactory = () => {
|
|
21
|
+
const created: string[] = [];
|
|
22
|
+
const destroyed: string[] = [];
|
|
23
|
+
const renewed: number[] = [];
|
|
24
|
+
let count = 0;
|
|
25
|
+
|
|
26
|
+
const create = async (): Promise<OpenSandboxBackend> => {
|
|
27
|
+
count += 1;
|
|
28
|
+
const id = `sbx-${count}`;
|
|
29
|
+
created.push(id);
|
|
30
|
+
|
|
31
|
+
return {
|
|
32
|
+
id,
|
|
33
|
+
renew: async (timeoutSeconds: number) => {
|
|
34
|
+
renewed.push(timeoutSeconds);
|
|
35
|
+
},
|
|
36
|
+
destroy: async () => {
|
|
37
|
+
destroyed.push(id);
|
|
38
|
+
},
|
|
39
|
+
} as unknown as OpenSandboxBackend;
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
return { create, created, destroyed, renewed };
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
test("同一会话复用同一个沙箱", async () => {
|
|
46
|
+
const factory = createFactory();
|
|
47
|
+
const manager = new SandboxManager(sandboxConfig(), { create: factory.create });
|
|
48
|
+
|
|
49
|
+
const first = await manager.get("thread-a");
|
|
50
|
+
const second = await manager.get("thread-a");
|
|
51
|
+
|
|
52
|
+
assert.equal(first, second);
|
|
53
|
+
assert.deepEqual(factory.created, ["sbx-1"]);
|
|
54
|
+
assert.equal(manager.size, 1);
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
test("不同会话使用不同的沙箱", async () => {
|
|
58
|
+
const factory = createFactory();
|
|
59
|
+
const manager = new SandboxManager(sandboxConfig(), { create: factory.create });
|
|
60
|
+
|
|
61
|
+
const first = await manager.get("thread-a");
|
|
62
|
+
const second = await manager.get("thread-b");
|
|
63
|
+
|
|
64
|
+
assert.notEqual(first, second);
|
|
65
|
+
assert.deepEqual(factory.created, ["sbx-1", "sbx-2"]);
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
test("释放会话后再次使用时创建新沙箱", async () => {
|
|
69
|
+
const factory = createFactory();
|
|
70
|
+
const manager = new SandboxManager(sandboxConfig(), { create: factory.create });
|
|
71
|
+
|
|
72
|
+
await manager.get("thread-a");
|
|
73
|
+
await manager.release("thread-a");
|
|
74
|
+
|
|
75
|
+
assert.deepEqual(factory.destroyed, ["sbx-1"]);
|
|
76
|
+
assert.equal(manager.size, 0);
|
|
77
|
+
|
|
78
|
+
const next = await manager.get("thread-a");
|
|
79
|
+
assert.equal(next.id, "sbx-2");
|
|
80
|
+
});
|
|
81
|
+
|
|
82
|
+
test("closeAll 销毁所有会话的沙箱", async () => {
|
|
83
|
+
const factory = createFactory();
|
|
84
|
+
const manager = new SandboxManager(sandboxConfig(), { create: factory.create });
|
|
85
|
+
|
|
86
|
+
await manager.get("thread-a");
|
|
87
|
+
await manager.get("thread-b");
|
|
88
|
+
await manager.closeAll();
|
|
89
|
+
|
|
90
|
+
assert.deepEqual(factory.destroyed.sort(), ["sbx-1", "sbx-2"]);
|
|
91
|
+
assert.equal(manager.size, 0);
|
|
92
|
+
});
|
|
93
|
+
|
|
94
|
+
test("创建失败后清理缓存,下一次可重试", async () => {
|
|
95
|
+
const factory = createFactory();
|
|
96
|
+
let attempts = 0;
|
|
97
|
+
|
|
98
|
+
const create = async (): Promise<OpenSandboxBackend> => {
|
|
99
|
+
attempts += 1;
|
|
100
|
+
if (attempts === 1) throw new Error("sandbox server unavailable");
|
|
101
|
+
|
|
102
|
+
return factory.create();
|
|
103
|
+
};
|
|
104
|
+
|
|
105
|
+
const manager = new SandboxManager(sandboxConfig(), { create });
|
|
106
|
+
|
|
107
|
+
await assert.rejects(() => manager.get("thread-a"), /unavailable/);
|
|
108
|
+
assert.equal(manager.size, 0);
|
|
109
|
+
|
|
110
|
+
const backend = await manager.get("thread-a");
|
|
111
|
+
assert.equal(backend.id, "sbx-1");
|
|
112
|
+
assert.equal(attempts, 2);
|
|
113
|
+
});
|
|
114
|
+
|
|
115
|
+
test("未配置 TTL 时不续期", async () => {
|
|
116
|
+
let now = 0;
|
|
117
|
+
const factory = createFactory();
|
|
118
|
+
const manager = new SandboxManager(sandboxConfig(), { create: factory.create, now: () => now });
|
|
119
|
+
|
|
120
|
+
await manager.get("thread-a");
|
|
121
|
+
now += 24 * 60 * 60 * 1_000;
|
|
122
|
+
await manager.get("thread-a");
|
|
123
|
+
|
|
124
|
+
assert.deepEqual(factory.renewed, []);
|
|
125
|
+
assert.equal(factory.created.length, 1);
|
|
126
|
+
});
|
|
127
|
+
|
|
128
|
+
test("使用中按 TTL 的三分之一续期", async () => {
|
|
129
|
+
let now = 0;
|
|
130
|
+
const factory = createFactory();
|
|
131
|
+
const manager = new SandboxManager(sandboxConfig({ timeoutSeconds: 1800 }), {
|
|
132
|
+
create: factory.create,
|
|
133
|
+
now: () => now,
|
|
134
|
+
});
|
|
135
|
+
|
|
136
|
+
const first = await manager.get("thread-a");
|
|
137
|
+
|
|
138
|
+
assert.equal(await manager.get("thread-a"), first);
|
|
139
|
+
assert.deepEqual(factory.renewed, []);
|
|
140
|
+
|
|
141
|
+
now += 600_000;
|
|
142
|
+
assert.equal(await manager.get("thread-a"), first);
|
|
143
|
+
assert.deepEqual(factory.renewed, [1800]);
|
|
144
|
+
assert.equal(factory.created.length, 1);
|
|
145
|
+
});
|
|
146
|
+
|
|
147
|
+
test("续期发现沙箱已被回收时重建", async () => {
|
|
148
|
+
let now = 0;
|
|
149
|
+
let count = 0;
|
|
150
|
+
const destroyed: string[] = [];
|
|
151
|
+
|
|
152
|
+
const create = async (): Promise<OpenSandboxBackend> => {
|
|
153
|
+
count += 1;
|
|
154
|
+
const id = `sbx-${count}`;
|
|
155
|
+
|
|
156
|
+
return {
|
|
157
|
+
id,
|
|
158
|
+
renew: async () => {
|
|
159
|
+
if (id === "sbx-1") throw new Error("sandbox not found");
|
|
160
|
+
},
|
|
161
|
+
destroy: async () => {
|
|
162
|
+
destroyed.push(id);
|
|
163
|
+
},
|
|
164
|
+
} as unknown as OpenSandboxBackend;
|
|
165
|
+
};
|
|
166
|
+
|
|
167
|
+
const manager = new SandboxManager(sandboxConfig({ timeoutSeconds: 1800 }), {
|
|
168
|
+
create,
|
|
169
|
+
now: () => now,
|
|
170
|
+
});
|
|
171
|
+
|
|
172
|
+
const first = await manager.get("thread-a");
|
|
173
|
+
|
|
174
|
+
now += 600_000;
|
|
175
|
+
const second = await manager.get("thread-a");
|
|
176
|
+
|
|
177
|
+
assert.notEqual(first, second);
|
|
178
|
+
assert.equal(second.id, "sbx-2");
|
|
179
|
+
assert.deepEqual(destroyed, ["sbx-1"]);
|
|
180
|
+
assert.equal(manager.size, 1);
|
|
181
|
+
});
|
|
182
|
+
|
|
183
|
+
test("续期失败但沙箱仍在时继续复用", async () => {
|
|
184
|
+
let now = 0;
|
|
185
|
+
let renewals = 0;
|
|
186
|
+
let count = 0;
|
|
187
|
+
|
|
188
|
+
const create = async (): Promise<OpenSandboxBackend> => {
|
|
189
|
+
count += 1;
|
|
190
|
+
|
|
191
|
+
return {
|
|
192
|
+
id: `sbx-${count}`,
|
|
193
|
+
renew: async () => {
|
|
194
|
+
renewals += 1;
|
|
195
|
+
throw new Error("upstream timeout");
|
|
196
|
+
},
|
|
197
|
+
destroy: async () => {},
|
|
198
|
+
} as unknown as OpenSandboxBackend;
|
|
199
|
+
};
|
|
200
|
+
|
|
201
|
+
const manager = new SandboxManager(sandboxConfig({ timeoutSeconds: 1800 }), {
|
|
202
|
+
create,
|
|
203
|
+
now: () => now,
|
|
204
|
+
});
|
|
205
|
+
|
|
206
|
+
const first = await manager.get("thread-a");
|
|
207
|
+
|
|
208
|
+
now += 600_000;
|
|
209
|
+
assert.equal(await manager.get("thread-a"), first);
|
|
210
|
+
assert.equal(renewals, 1);
|
|
211
|
+
assert.equal(count, 1);
|
|
212
|
+
});
|
|
213
|
+
|
|
214
|
+
test("设置 OPEN_SANDBOX_ID 时所有会话共享同一个沙箱", async () => {
|
|
215
|
+
const factory = createFactory();
|
|
216
|
+
const manager = new SandboxManager(sandboxConfig({ sandboxId: "sbx-existing" }), {
|
|
217
|
+
create: factory.create,
|
|
218
|
+
});
|
|
219
|
+
|
|
220
|
+
const first = await manager.get("thread-a");
|
|
221
|
+
const second = await manager.get("thread-b");
|
|
222
|
+
|
|
223
|
+
assert.equal(first, second);
|
|
224
|
+
assert.deepEqual(factory.created, ["sbx-1"]);
|
|
225
|
+
|
|
226
|
+
await manager.release("thread-a");
|
|
227
|
+
assert.deepEqual(factory.destroyed, []);
|
|
228
|
+
|
|
229
|
+
await manager.closeAll();
|
|
230
|
+
assert.deepEqual(factory.destroyed, ["sbx-1"]);
|
|
231
|
+
});
|
|
232
|
+
|
|
233
|
+
test("threadIdFromRuntime 支持 context 与 configurable", () => {
|
|
234
|
+
assert.equal(threadIdFromRuntime({ context: { threadId: "from-context" } }), "from-context");
|
|
235
|
+
assert.equal(
|
|
236
|
+
threadIdFromRuntime({ config: { configurable: { thread_id: "from-config" } } }),
|
|
237
|
+
"from-config",
|
|
238
|
+
);
|
|
239
|
+
assert.equal(threadIdFromRuntime({ state: {} }), undefined);
|
|
240
|
+
assert.equal(threadIdFromRuntime(undefined), undefined);
|
|
241
|
+
});
|
|
@@ -0,0 +1,188 @@
|
|
|
1
|
+
import assert from "node:assert/strict";
|
|
2
|
+
import test from "node:test";
|
|
3
|
+
|
|
4
|
+
import { SandboxApiException, type Sandbox } from "@alibaba-group/opensandbox";
|
|
5
|
+
|
|
6
|
+
import { OpenSandboxBackend } from "../../src/sandbox/index.js";
|
|
7
|
+
|
|
8
|
+
interface FakeSandboxCalls {
|
|
9
|
+
sessions: Array<{ workingDirectory?: string }>;
|
|
10
|
+
run: Array<{ sessionId: string; command: string }>;
|
|
11
|
+
deleted: string[];
|
|
12
|
+
directories: string[];
|
|
13
|
+
writes: string[];
|
|
14
|
+
reads: string[];
|
|
15
|
+
renewals: number[];
|
|
16
|
+
killed: boolean;
|
|
17
|
+
closed: boolean;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
const createFakeSandbox = ({ failFirstRun = false }: { failFirstRun?: boolean } = {}): {
|
|
21
|
+
sandbox: Sandbox;
|
|
22
|
+
calls: FakeSandboxCalls;
|
|
23
|
+
} => {
|
|
24
|
+
const calls: FakeSandboxCalls = {
|
|
25
|
+
sessions: [],
|
|
26
|
+
run: [],
|
|
27
|
+
deleted: [],
|
|
28
|
+
directories: [],
|
|
29
|
+
writes: [],
|
|
30
|
+
reads: [],
|
|
31
|
+
renewals: [],
|
|
32
|
+
killed: false,
|
|
33
|
+
closed: false,
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
let created = 0;
|
|
37
|
+
let remainingFailures = failFirstRun ? 1 : 0;
|
|
38
|
+
|
|
39
|
+
const sandbox = {
|
|
40
|
+
id: "sbx-test",
|
|
41
|
+
commands: {
|
|
42
|
+
createSession: async (options?: { workingDirectory?: string }) => {
|
|
43
|
+
calls.sessions.push({ workingDirectory: options?.workingDirectory });
|
|
44
|
+
created += 1;
|
|
45
|
+
return `session-${created}`;
|
|
46
|
+
},
|
|
47
|
+
runInSession: async (sessionId: string, command: string) => {
|
|
48
|
+
if (remainingFailures > 0) {
|
|
49
|
+
remainingFailures -= 1;
|
|
50
|
+
throw new SandboxApiException({ statusCode: 404, message: "session not found" });
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
calls.run.push({ sessionId, command });
|
|
54
|
+
return {
|
|
55
|
+
logs: {
|
|
56
|
+
stdout: [{ text: "hello", timestamp: 0 }],
|
|
57
|
+
stderr: [{ text: "boom", timestamp: 0 }],
|
|
58
|
+
},
|
|
59
|
+
exitCode: 0,
|
|
60
|
+
};
|
|
61
|
+
},
|
|
62
|
+
deleteSession: async (sessionId: string) => {
|
|
63
|
+
calls.deleted.push(sessionId);
|
|
64
|
+
},
|
|
65
|
+
},
|
|
66
|
+
files: {
|
|
67
|
+
createDirectories: async (entries: Array<{ path: string }>) => {
|
|
68
|
+
calls.directories.push(...entries.map((entry) => entry.path));
|
|
69
|
+
},
|
|
70
|
+
writeFiles: async (entries: Array<{ path: string }>) => {
|
|
71
|
+
calls.writes.push(...entries.map((entry) => entry.path));
|
|
72
|
+
},
|
|
73
|
+
readBytes: async (path: string) => {
|
|
74
|
+
calls.reads.push(path);
|
|
75
|
+
return new Uint8Array([104, 105]);
|
|
76
|
+
},
|
|
77
|
+
},
|
|
78
|
+
renew: async (timeoutSeconds: number) => {
|
|
79
|
+
calls.renewals.push(timeoutSeconds);
|
|
80
|
+
},
|
|
81
|
+
kill: async () => {
|
|
82
|
+
calls.killed = true;
|
|
83
|
+
},
|
|
84
|
+
close: async () => {
|
|
85
|
+
calls.closed = true;
|
|
86
|
+
},
|
|
87
|
+
} as unknown as Sandbox;
|
|
88
|
+
|
|
89
|
+
return { sandbox, calls };
|
|
90
|
+
};
|
|
91
|
+
|
|
92
|
+
test("execute 在持久 session 中组合 stdout/stderr", async () => {
|
|
93
|
+
const { sandbox, calls } = createFakeSandbox();
|
|
94
|
+
const backend = new OpenSandboxBackend({ sandbox, workspaceRoot: "/workspace" });
|
|
95
|
+
|
|
96
|
+
const result = await backend.execute("echo hello");
|
|
97
|
+
|
|
98
|
+
assert.equal(result.output, "hello\n[stderr] boom");
|
|
99
|
+
assert.equal(result.exitCode, 0);
|
|
100
|
+
assert.equal(result.truncated, false);
|
|
101
|
+
assert.deepEqual(calls.sessions, [{ workingDirectory: "/workspace" }]);
|
|
102
|
+
assert.deepEqual(calls.run, [{ sessionId: "session-1", command: "echo hello" }]);
|
|
103
|
+
});
|
|
104
|
+
|
|
105
|
+
test("连续命令复用同一个 session,并按顺序执行", async () => {
|
|
106
|
+
const { sandbox, calls } = createFakeSandbox();
|
|
107
|
+
const backend = new OpenSandboxBackend({ sandbox });
|
|
108
|
+
|
|
109
|
+
await backend.execute("cd /tmp");
|
|
110
|
+
await backend.execute("pwd");
|
|
111
|
+
await Promise.all([backend.execute("echo a"), backend.execute("echo b")]);
|
|
112
|
+
|
|
113
|
+
assert.equal(calls.sessions.length, 1);
|
|
114
|
+
assert.deepEqual(
|
|
115
|
+
calls.run.map(({ sessionId }) => sessionId),
|
|
116
|
+
["session-1", "session-1", "session-1", "session-1"],
|
|
117
|
+
);
|
|
118
|
+
assert.deepEqual(
|
|
119
|
+
calls.run.map(({ command }) => command),
|
|
120
|
+
["cd /tmp", "pwd", "echo a", "echo b"],
|
|
121
|
+
);
|
|
122
|
+
});
|
|
123
|
+
|
|
124
|
+
test("session 失效时重建并重试一次", async () => {
|
|
125
|
+
const { sandbox, calls } = createFakeSandbox({ failFirstRun: true });
|
|
126
|
+
const backend = new OpenSandboxBackend({ sandbox });
|
|
127
|
+
|
|
128
|
+
const result = await backend.execute("echo hello");
|
|
129
|
+
|
|
130
|
+
assert.equal(result.exitCode, 0);
|
|
131
|
+
assert.equal(calls.sessions.length, 2);
|
|
132
|
+
assert.deepEqual(calls.run, [{ sessionId: "session-2", command: "echo hello" }]);
|
|
133
|
+
});
|
|
134
|
+
|
|
135
|
+
test("renew 向服务端续期 TTL", async () => {
|
|
136
|
+
const { sandbox, calls } = createFakeSandbox();
|
|
137
|
+
const backend = new OpenSandboxBackend({ sandbox });
|
|
138
|
+
|
|
139
|
+
await backend.renew(1800);
|
|
140
|
+
|
|
141
|
+
assert.deepEqual(calls.renewals, [1800]);
|
|
142
|
+
});
|
|
143
|
+
|
|
144
|
+
test("uploadFiles 先创建父目录再写入文件", async () => {
|
|
145
|
+
const { sandbox, calls } = createFakeSandbox();
|
|
146
|
+
const backend = new OpenSandboxBackend({ sandbox });
|
|
147
|
+
|
|
148
|
+
const result = await backend.uploadFiles([
|
|
149
|
+
["/workspace/notes/today.md", new Uint8Array([35, 32])],
|
|
150
|
+
]);
|
|
151
|
+
|
|
152
|
+
assert.deepEqual(result, [{ path: "/workspace/notes/today.md", error: null }]);
|
|
153
|
+
assert.deepEqual(calls.directories, ["/workspace/notes"]);
|
|
154
|
+
assert.deepEqual(calls.writes, ["/workspace/notes/today.md"]);
|
|
155
|
+
});
|
|
156
|
+
|
|
157
|
+
test("downloadFiles 返回文件字节", async () => {
|
|
158
|
+
const { sandbox, calls } = createFakeSandbox();
|
|
159
|
+
const backend = new OpenSandboxBackend({ sandbox });
|
|
160
|
+
|
|
161
|
+
const result = await backend.downloadFiles(["/workspace/notes/today.md"]);
|
|
162
|
+
|
|
163
|
+
assert.deepEqual(calls.reads, ["/workspace/notes/today.md"]);
|
|
164
|
+
assert.equal(result[0]?.error, null);
|
|
165
|
+
assert.deepEqual(result[0]?.content, new Uint8Array([104, 105]));
|
|
166
|
+
});
|
|
167
|
+
|
|
168
|
+
test("destroy 删除 session、终止自建沙箱并关闭连接", async () => {
|
|
169
|
+
const { sandbox, calls } = createFakeSandbox();
|
|
170
|
+
const backend = new OpenSandboxBackend({ sandbox });
|
|
171
|
+
|
|
172
|
+
await backend.execute("echo hello");
|
|
173
|
+
await backend.destroy();
|
|
174
|
+
|
|
175
|
+
assert.deepEqual(calls.deleted, ["session-1"]);
|
|
176
|
+
assert.equal(calls.killed, true);
|
|
177
|
+
assert.equal(calls.closed, true);
|
|
178
|
+
});
|
|
179
|
+
|
|
180
|
+
test("复用已有沙箱时只关闭连接,不 kill", async () => {
|
|
181
|
+
const { sandbox, calls } = createFakeSandbox();
|
|
182
|
+
const backend = new OpenSandboxBackend({ sandbox, owned: false });
|
|
183
|
+
|
|
184
|
+
await backend.destroy();
|
|
185
|
+
|
|
186
|
+
assert.equal(calls.killed, false);
|
|
187
|
+
assert.equal(calls.closed, true);
|
|
188
|
+
});
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import assert from "node:assert/strict";
|
|
2
|
+
import test from "node:test";
|
|
3
|
+
|
|
4
|
+
import type { BaseCheckpointSaver, BaseStore } from "@langchain/langgraph";
|
|
5
|
+
|
|
6
|
+
import type { CompiledAgent } from "../../src/graph/index.js";
|
|
7
|
+
import type { SandboxManager } from "../../src/sandbox/index.js";
|
|
8
|
+
import { SessionService } from "../../src/services/session.js";
|
|
9
|
+
|
|
10
|
+
test("删除会话时释放对应沙箱", async () => {
|
|
11
|
+
const deletedThreads: string[] = [];
|
|
12
|
+
const deletedKeys: Array<[string[], string]> = [];
|
|
13
|
+
const released: string[] = [];
|
|
14
|
+
|
|
15
|
+
const checkpointer = {
|
|
16
|
+
deleteThread: async (threadId: string) => {
|
|
17
|
+
deletedThreads.push(threadId);
|
|
18
|
+
},
|
|
19
|
+
} as unknown as BaseCheckpointSaver;
|
|
20
|
+
|
|
21
|
+
const store = {
|
|
22
|
+
delete: async (key: string[], value: string) => {
|
|
23
|
+
deletedKeys.push([key, value]);
|
|
24
|
+
},
|
|
25
|
+
} as unknown as BaseStore;
|
|
26
|
+
|
|
27
|
+
const sandboxes = {
|
|
28
|
+
release: async (threadId: string) => {
|
|
29
|
+
released.push(threadId);
|
|
30
|
+
},
|
|
31
|
+
} as unknown as SandboxManager;
|
|
32
|
+
|
|
33
|
+
const service = new SessionService({
|
|
34
|
+
graph: {} as CompiledAgent,
|
|
35
|
+
checkpointer,
|
|
36
|
+
store,
|
|
37
|
+
sandboxes,
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
await service.remove("thread-1", "tenant-1");
|
|
41
|
+
|
|
42
|
+
assert.deepEqual(deletedThreads, ["thread-1"]);
|
|
43
|
+
assert.deepEqual(deletedKeys, [[["sessions", "tenant-1"], "thread-1"]]);
|
|
44
|
+
assert.deepEqual(released, ["thread-1"]);
|
|
45
|
+
});
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import assert from "node:assert/strict";
|
|
2
2
|
import test from "node:test";
|
|
3
3
|
|
|
4
|
-
import { assertReadOnlyQuery } from "../../src/tools/database/
|
|
4
|
+
import { assertReadOnlyQuery } from "../../src/tools/database/index.js";
|
|
5
5
|
|
|
6
6
|
test("接受 SELECT 与 WITH 语句", () => {
|
|
7
7
|
assert.doesNotThrow(() => assertReadOnlyQuery("select id, name from users"));
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
你是 researcher(研究)子 Agent。你负责收集可验证的信息,并整理成主 Agent 可信赖的笔记。
|
|
2
|
-
|
|
3
|
-
## 工作流程
|
|
4
|
-
|
|
5
|
-
1. 把问题拆成 2-5 个具体的子问题。
|
|
6
|
-
2. 使用 `web_search` 搜索。优先选择一手来源(官方文档、论文、源码),而不是聚合站点。
|
|
7
|
-
3. 阅读最有价值的来源,只提取能回答子问题的事实。
|
|
8
|
-
4. 把笔记写入 `/workspace/research/<主题>.md`,包含简短摘要和来源列表。
|
|
9
|
-
5. 返回摘要和文件路径。
|
|
10
|
-
|
|
11
|
-
## 规则
|
|
12
|
-
|
|
13
|
-
- 每个事实性结论都必须附 URL。无法验证的来源要明确说明。
|
|
14
|
-
- 时间敏感的信息要记录发布日期,并标注可能过时的内容。
|
|
15
|
-
- 控制引用篇幅,不要大段复制原文。
|
|
16
|
-
- 搜索工具不可用时明确说明,并标注所给信息为“未经验证”。
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { webSearchTool } from "../../tools/search/index.js";
|
|
2
|
-
import { loadPrompt } from "../prompts/index.js";
|
|
3
|
-
export const createResearcherSubagent = () => {
|
|
4
|
-
return {
|
|
5
|
-
name: "researcher",
|
|
6
|
-
description:
|
|
7
|
-
"从网络收集可验证的信息,阅读来源,并把带引用的研究笔记写入 /workspace/research/。",
|
|
8
|
-
systemPrompt: loadPrompt("subagents/researcher"),
|
|
9
|
-
tools: [webSearchTool],
|
|
10
|
-
skills: ["/skills/research/"],
|
|
11
|
-
};
|
|
12
|
-
};
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import { ChatAnthropic } from "@langchain/anthropic";
|
|
2
|
-
import { ChatOpenAI } from "@langchain/openai";
|
|
3
|
-
export const DEFAULT_MODELS = {
|
|
4
|
-
openai: "gpt-4.1-mini",
|
|
5
|
-
anthropic: "claude-sonnet-4-5",
|
|
6
|
-
};
|
|
7
|
-
export const resolveModelConfig = (env) => {
|
|
8
|
-
return {
|
|
9
|
-
provider: env.MODEL_PROVIDER,
|
|
10
|
-
name: env.MODEL_NAME ?? DEFAULT_MODELS[env.MODEL_PROVIDER],
|
|
11
|
-
temperature: env.MODEL_TEMPERATURE,
|
|
12
|
-
maxTokens: env.MODEL_MAX_TOKENS,
|
|
13
|
-
...(env.OPENAI_BASE_URL ? { baseUrl: env.OPENAI_BASE_URL } : {}),
|
|
14
|
-
};
|
|
15
|
-
};
|
|
16
|
-
/**
|
|
17
|
-
* 构建主 Agent 和所有子 Agent 共用的聊天模型。
|
|
18
|
-
* 要接入其他提供商(Bedrock、Vertex、Ollama 等),替换此函数即可。
|
|
19
|
-
*/
|
|
20
|
-
export const createChatModel = (config) => {
|
|
21
|
-
if (config.provider === "anthropic") {
|
|
22
|
-
return new ChatAnthropic({
|
|
23
|
-
model: config.name,
|
|
24
|
-
temperature: config.temperature,
|
|
25
|
-
maxTokens: config.maxTokens,
|
|
26
|
-
});
|
|
27
|
-
}
|
|
28
|
-
return new ChatOpenAI({
|
|
29
|
-
model: config.name,
|
|
30
|
-
temperature: config.temperature,
|
|
31
|
-
maxTokens: config.maxTokens,
|
|
32
|
-
...(config.baseUrl ? { configuration: { baseURL: config.baseUrl } } : {}),
|
|
33
|
-
});
|
|
34
|
-
};
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
import { performance } from "node:perf_hooks";
|
|
2
|
-
import { Pool } from "pg";
|
|
3
|
-
import { ConfigurationError } from "../../utils/errors.js";
|
|
4
|
-
let pool;
|
|
5
|
-
/** 懒加载共享的 PostgreSQL 连接池。 */
|
|
6
|
-
export const getPool = (connectionString = process.env.DATABASE_URL) => {
|
|
7
|
-
if (!connectionString) {
|
|
8
|
-
throw new ConfigurationError("未配置 DATABASE_URL。请先在 .env 中设置后再使用数据库功能。");
|
|
9
|
-
}
|
|
10
|
-
pool ??= new Pool({
|
|
11
|
-
connectionString,
|
|
12
|
-
max: 10,
|
|
13
|
-
idleTimeoutMillis: 30_000,
|
|
14
|
-
connectionTimeoutMillis: 5_000,
|
|
15
|
-
});
|
|
16
|
-
return pool;
|
|
17
|
-
};
|
|
18
|
-
export const checkDatabase = async () => {
|
|
19
|
-
if (!process.env.DATABASE_URL) {
|
|
20
|
-
return { ok: false, error: "未配置 DATABASE_URL" };
|
|
21
|
-
}
|
|
22
|
-
const startedAt = performance.now();
|
|
23
|
-
try {
|
|
24
|
-
const client = await getPool().connect();
|
|
25
|
-
try {
|
|
26
|
-
await client.query("select 1");
|
|
27
|
-
} finally {
|
|
28
|
-
client.release();
|
|
29
|
-
}
|
|
30
|
-
return { ok: true, latencyMs: Math.round(performance.now() - startedAt) };
|
|
31
|
-
} catch (error) {
|
|
32
|
-
return {
|
|
33
|
-
ok: false,
|
|
34
|
-
error: error instanceof Error ? error.message : String(error),
|
|
35
|
-
};
|
|
36
|
-
}
|
|
37
|
-
};
|
|
38
|
-
export const closeDatabase = async () => {
|
|
39
|
-
if (!pool) return;
|
|
40
|
-
const current = pool;
|
|
41
|
-
pool = undefined;
|
|
42
|
-
await current.end();
|
|
43
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { createWebSearchTool, webSearchTool } from "./web-search.js";
|
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
import { tool } from "@langchain/core/tools";
|
|
2
|
-
import { z } from "zod";
|
|
3
|
-
const TAVILY_ENDPOINT = "https://api.tavily.com/search";
|
|
4
|
-
const webSearchSchema = z.object({
|
|
5
|
-
query: z.string().min(2).describe("搜索关键词。"),
|
|
6
|
-
maxResults: z.number().int().min(1).max(10).default(5).describe("返回结果数量(1-10)。"),
|
|
7
|
-
});
|
|
8
|
-
/**
|
|
9
|
-
* 基于 Tavily 的 Web 搜索。API Key 延迟读取,因此即使未配置搜索也能注册
|
|
10
|
-
* 该工具;真正调用时会返回清晰错误,供模型报告。
|
|
11
|
-
*/
|
|
12
|
-
export const createWebSearchTool = ({ apiKey, maxResults: defaultMaxResults = 5 } = {}) => {
|
|
13
|
-
return tool(
|
|
14
|
-
async ({ query, maxResults }) => {
|
|
15
|
-
const key = apiKey ?? process.env.TAVILY_API_KEY;
|
|
16
|
-
if (!key) {
|
|
17
|
-
throw new Error("未设置 TAVILY_API_KEY。请在 .env 中添加后启用 Web 搜索。");
|
|
18
|
-
}
|
|
19
|
-
const response = await fetch(TAVILY_ENDPOINT, {
|
|
20
|
-
method: "POST",
|
|
21
|
-
headers: { "content-type": "application/json" },
|
|
22
|
-
body: JSON.stringify({
|
|
23
|
-
api_key: key,
|
|
24
|
-
query,
|
|
25
|
-
max_results: Math.min(maxResults ?? defaultMaxResults, 10),
|
|
26
|
-
search_depth: "basic",
|
|
27
|
-
include_answer: false,
|
|
28
|
-
include_raw_content: false,
|
|
29
|
-
}),
|
|
30
|
-
signal: AbortSignal.timeout(20_000),
|
|
31
|
-
});
|
|
32
|
-
if (!response.ok) {
|
|
33
|
-
const detail = await response.text().catch(() => "");
|
|
34
|
-
throw new Error(
|
|
35
|
-
`Web 搜索失败,HTTP ${response.status}${detail ? `:${detail.slice(0, 300)}` : ""}`,
|
|
36
|
-
);
|
|
37
|
-
}
|
|
38
|
-
const data = await response.json();
|
|
39
|
-
const results = (data.results ?? []).map((result) => ({
|
|
40
|
-
title: result.title ?? "",
|
|
41
|
-
url: result.url ?? "",
|
|
42
|
-
snippet: result.content ?? "",
|
|
43
|
-
score: result.score ?? 0,
|
|
44
|
-
}));
|
|
45
|
-
return JSON.stringify({ query, results }, null, 2);
|
|
46
|
-
},
|
|
47
|
-
{
|
|
48
|
-
name: "web_search",
|
|
49
|
-
description: "搜索公开网络,返回标题、URL 和摘要。用于获取最新信息,并引用实际使用的来源。",
|
|
50
|
-
schema: webSearchSchema,
|
|
51
|
-
},
|
|
52
|
-
);
|
|
53
|
-
};
|
|
54
|
-
export const webSearchTool = createWebSearchTool();
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
name: research
|
|
3
|
-
description: 当问题需要最新的外部事实、多来源对比,或需要把带引用的研究笔记写入工作区时使用。
|
|
4
|
-
---
|
|
5
|
-
|
|
6
|
-
# 研究(Research)
|
|
7
|
-
|
|
8
|
-
## 适用场景
|
|
9
|
-
|
|
10
|
-
- 答案依赖训练截止日期之后的信息。
|
|
11
|
-
- 用户要求来源、对比、市场/竞品数据或官方文档。
|
|
12
|
-
- 某个结论在复述前需要先核实。
|
|
13
|
-
|
|
14
|
-
## 工作流程
|
|
15
|
-
|
|
16
|
-
1. 复述子问题,以及这些信息要支撑的决策。
|
|
17
|
-
2. 使用 `web_search` 做 2-4 次聚焦搜索,而不是一次宽泛搜索。
|
|
18
|
-
3. 优先选择一手来源:官方文档、变更日志、论文、源码、财报。
|
|
19
|
-
4. 打开最有价值的链接,只摘取与子问题相关的事实。
|
|
20
|
-
5. 写入 `/workspace/research/<主题>.md`,包含:
|
|
21
|
-
- 5 条以内的摘要;
|
|
22
|
-
- 按子问题分组的发现;
|
|
23
|
-
- 带 URL 和日期的来源列表。
|
|
24
|
-
6. 把摘要和文件路径返回给主 Agent。
|
|
25
|
-
|
|
26
|
-
## 质量标准
|
|
27
|
-
|
|
28
|
-
- 每个事实旁边都要有 URL。
|
|
29
|
-
- 来源冲突时如实报告,不要取平均值掩盖矛盾。
|
|
30
|
-
- 无日期或无法验证的结论标注为 `unverified`。
|
|
31
|
-
- 没有来源就不下结论:说明哪些内容无法核实。
|