@frockbot/kernel-contracts 0.1.3 → 0.2.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/package.json +1 -1
- package/src/authoring.ts +64 -0
- package/src/catalog-change.test.ts +56 -0
- package/src/iframe-ui.test.ts +99 -0
- package/src/iframe-ui.ts +400 -0
- package/src/index.ts +3 -0
- package/src/isolate-context-catalog.generated.ts +25 -0
- package/src/isolate.test.ts +154 -43
- package/src/isolate.ts +689 -101
- package/src/loop-events.test.ts +80 -0
- package/src/loop-events.ts +711 -0
- package/src/send-to-user.ts +7 -56
- package/src/session.test.ts +16 -0
- package/src/tool-execution.ts +16 -0
- package/src/types.ts +229 -0
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import { describe, expect, test } from "bun:test";
|
|
2
|
+
import {
|
|
3
|
+
BOT_ISOLATE_HOOK_EVENTS_V1,
|
|
4
|
+
decodeBotIsolateHookReplacementV1,
|
|
5
|
+
LOOP_EVENTS_V1,
|
|
6
|
+
} from "./loop-events.js";
|
|
7
|
+
|
|
8
|
+
const call = { id: "call-1", name: "write", input: { value: 1 } };
|
|
9
|
+
|
|
10
|
+
describe("the public loop event declaration", () => {
|
|
11
|
+
test("marks every isolate event as a waterfall", () => {
|
|
12
|
+
expect(
|
|
13
|
+
BOT_ISOLATE_HOOK_EVENTS_V1.every(
|
|
14
|
+
(event) =>
|
|
15
|
+
LOOP_EVENTS_V1[event].mode === "waterfall" &&
|
|
16
|
+
LOOP_EVENTS_V1[event].isolateHook,
|
|
17
|
+
),
|
|
18
|
+
).toBe(true);
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
test("decodes an exact tool exposure replacement", () => {
|
|
22
|
+
expect(
|
|
23
|
+
decodeBotIsolateHookReplacementV1(
|
|
24
|
+
"agent/tool-exposure",
|
|
25
|
+
[
|
|
26
|
+
{
|
|
27
|
+
name: "read_only",
|
|
28
|
+
description: "Reads without effects.",
|
|
29
|
+
inputSchema: { type: "object" },
|
|
30
|
+
},
|
|
31
|
+
],
|
|
32
|
+
[],
|
|
33
|
+
),
|
|
34
|
+
).toEqual([
|
|
35
|
+
{
|
|
36
|
+
name: "read_only",
|
|
37
|
+
description: "Reads without effects.",
|
|
38
|
+
inputSchema: { type: "object" },
|
|
39
|
+
},
|
|
40
|
+
]);
|
|
41
|
+
expect(() =>
|
|
42
|
+
decodeBotIsolateHookReplacementV1(
|
|
43
|
+
"agent/tool-exposure",
|
|
44
|
+
[
|
|
45
|
+
{
|
|
46
|
+
name: "read_only",
|
|
47
|
+
description: "Reads without effects.",
|
|
48
|
+
inputSchema: {},
|
|
49
|
+
execute: "not part of a schema",
|
|
50
|
+
},
|
|
51
|
+
],
|
|
52
|
+
[],
|
|
53
|
+
),
|
|
54
|
+
).toThrow(/invalid fields/);
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
test("a pre-execute hook may add a denial but cannot lift one", () => {
|
|
58
|
+
const ready = { kind: "ready" as const, call, idempotent: false };
|
|
59
|
+
expect(
|
|
60
|
+
decodeBotIsolateHookReplacementV1(
|
|
61
|
+
"tools/pre-execute",
|
|
62
|
+
{
|
|
63
|
+
kind: "denied",
|
|
64
|
+
call,
|
|
65
|
+
result: { content: "Bot policy denied this call", isError: true },
|
|
66
|
+
},
|
|
67
|
+
ready,
|
|
68
|
+
),
|
|
69
|
+
).toMatchObject({ kind: "denied" });
|
|
70
|
+
|
|
71
|
+
const denied = {
|
|
72
|
+
kind: "denied" as const,
|
|
73
|
+
call,
|
|
74
|
+
result: { content: "Core denied this call", isError: true },
|
|
75
|
+
};
|
|
76
|
+
expect(() =>
|
|
77
|
+
decodeBotIsolateHookReplacementV1("tools/pre-execute", ready, denied),
|
|
78
|
+
).toThrow(/cannot lift/);
|
|
79
|
+
});
|
|
80
|
+
});
|