Repository navigation
Expand file tree
/
Copy path_probe.ts
More file actions
50 lines (47 loc) · 1.58 KB
/
Copy path_probe.ts
File metadata and controls
50 lines (47 loc) · 1.58 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
import { MockLanguageModelV4 } from "ai/test";
import { createSubagentRunner } from "./src/agent/subagent";
import { AuditStore } from "./src/agent/audit";
import { openDb } from "./src/storage/db";
import { defaultCapabilitiesFor } from "./src/agent/surface";
import { mkdtempSync } from "node:fs";
import { tmpdir } from "node:os";
import { join } from "node:path";
let turn = 0;
const model = new MockLanguageModelV4({
doGenerate: async () => {
turn++;
if (turn === 1) {
return {
content: [
{ type: "tool-call", toolCallId: "tc1", toolName: "report_findings",
input: JSON.stringify({ summary: "found three tables", artifacts: [{ label: "q", sql: "SELECT 1" }], confidence: "high" }) },
],
finishReason: "tool-calls",
usage: { inputTokens: 1, outputTokens: 1, totalTokens: 2 },
warnings: [],
};
}
return {
content: [{ type: "text", text: "done" }],
finishReason: "stop",
usage: { inputTokens: 1, outputTokens: 1, totalTokens: 2 },
warnings: [],
};
},
});
const dir = mkdtempSync(join(tmpdir(), "probe-"));
const audit = new AuditStore(openDb(join(dir, "app.db")));
const runner = createSubagentRunner({
model: model as never,
capabilities: defaultCapabilitiesFor("mssql"),
toolDeps: {
getAdapter: () => { throw new Error("no adapter"); },
connectionId: () => "c",
database: () => "d",
audit,
},
timeoutMs: 10_000,
concurrency: 1,
});
const res = await runner("probe goal", [{ name: "t1", instructions: "say hello" }]);
console.log(JSON.stringify(res, null, 2));