forked from Lilly-Protocol/agentlily-runtime
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtask-runner.test.ts
More file actions
79 lines (74 loc) · 2.24 KB
/
Copy pathtask-runner.test.ts
File metadata and controls
79 lines (74 loc) · 2.24 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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
import { describe, it, expect } from "vitest";
import { TaskRunner } from "../../src/tasks/task-runner.js";
import { RuntimeError } from "../../src/errors/runtime-errors.js";
import { InMemoryMemoryStore } from "../../src/memory/memory-store.js";
describe("TaskRunner INVALID_TASK rejection paths", () => {
const stubExecutor = { execute: async () => ({}) };
const memoryStore = new InMemoryMemoryStore();
const runner = new TaskRunner(stubExecutor as any, memoryStore);
const ctx = {} as any;
it("rejects with INVALID_TASK when taskId is empty", async () => {
try {
await runner.run(
{ taskId: "", agentId: "a", toolName: "t", input: "i", payload: {} },
ctx
);
expect.fail("should have thrown");
} catch (e) {
const err = e as RuntimeError;
expect(err.code).toBe("INVALID_TASK");
expect(err.details?.fieldName).toBe("taskId");
}
});
it("rejects with INVALID_TASK when agentId is whitespace-only", async () => {
try {
await runner.run(
{
taskId: "t1",
agentId: " ",
toolName: "t",
input: "i",
payload: {}
},
ctx
);
expect.fail("should have thrown");
} catch (e) {
const err = e as RuntimeError;
expect(err.code).toBe("INVALID_TASK");
expect(err.details?.fieldName).toBe("agentId");
}
});
it("rejects with INVALID_TASK when toolName is empty", async () => {
try {
await runner.run(
{ taskId: "t1", agentId: "a1", toolName: "", input: "i", payload: {} },
ctx
);
expect.fail("should have thrown");
} catch (e) {
const err = e as RuntimeError;
expect(err.code).toBe("INVALID_TASK");
expect(err.details?.fieldName).toBe("toolName");
}
});
it("rejects with INVALID_TASK when input is missing or blank", async () => {
try {
await runner.run(
{
taskId: "t1",
agentId: "a1",
toolName: "t",
input: "\n\t",
payload: {}
},
ctx
);
expect.fail("should have thrown");
} catch (e) {
const err = e as RuntimeError;
expect(err.code).toBe("INVALID_TASK");
expect(err.details?.fieldName).toBe("input");
}
});
});