@yaklabs-ai/plugin-sdk 0.8.4

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.
@@ -0,0 +1,88 @@
1
+ // packages/herd-agent/dist/testing.js
2
+ function fauxAuthContext(overrides = {}) {
3
+ return {
4
+ async resolveToken() {
5
+ return { ok: false, reason: "no-connection", message: "not connected" };
6
+ },
7
+ async getActiveAccount() {
8
+ return void 0;
9
+ },
10
+ async listAccounts() {
11
+ return [];
12
+ },
13
+ async resolveExternalCli({ serviceId, schemeId }) {
14
+ return {
15
+ ok: false,
16
+ reason: "not-external-cli",
17
+ message: `${serviceId}/${schemeId} is not an external CLI scheme.`
18
+ };
19
+ },
20
+ ...overrides
21
+ };
22
+ }
23
+
24
+ // packages/plugin-sdk/dist/kay-agent/testing.js
25
+ function unwired(name) {
26
+ return async () => {
27
+ throw new Error(`${name} is not wired in this test double; pass your own handle to exercise it`);
28
+ };
29
+ }
30
+ function fauxKayAgentCapabilities() {
31
+ return {
32
+ filesystem: {
33
+ readText: unwired("filesystem.readText"),
34
+ writeText: unwired("filesystem.writeText"),
35
+ mkdir: unwired("filesystem.mkdir"),
36
+ readDir: unwired("filesystem.readDir"),
37
+ stat: unwired("filesystem.stat"),
38
+ rename: unwired("filesystem.rename"),
39
+ realpath: unwired("filesystem.realpath")
40
+ },
41
+ network: { fetch: unwired("network.fetch") },
42
+ webSession: {
43
+ request: unwired("webSession.request"),
44
+ download: unwired("webSession.download")
45
+ },
46
+ process: { run: unwired("process.run") },
47
+ whiteboard: {
48
+ listTypes: unwired("whiteboard.listTypes"),
49
+ forType: () => ({
50
+ payload: {
51
+ read: unwired("whiteboard.payload.read"),
52
+ create: unwired("whiteboard.payload.create"),
53
+ replace: unwired("whiteboard.payload.replace")
54
+ },
55
+ inventory: unwired("whiteboard.inventory"),
56
+ inspect: unwired("whiteboard.inspect"),
57
+ list: unwired("whiteboard.list"),
58
+ read: unwired("whiteboard.read"),
59
+ create: unwired("whiteboard.create"),
60
+ update: unwired("whiteboard.update"),
61
+ mutate: unwired("whiteboard.mutate"),
62
+ remove: unwired("whiteboard.remove")
63
+ })
64
+ },
65
+ interceptToolCall: () => void 0,
66
+ // The one handle that does NOT refuse on use. `withJev`'s contract is that it always produces
67
+ // the baseline, so a rejecting double would make a plugin's Jev path untestable and teach the
68
+ // wrong lesson besides: the fallback is the normal outcome, not an error. It reaches no
69
+ // client, no key, and no network, which is all a double here has to guarantee. A test that
70
+ // wants a real Jev answer overrides this handle after the spread, like any other.
71
+ withJev: async (_use, fallback) => fallback(),
72
+ // Accepts and drops, like the registrations above: the real `publish` never throws, so a
73
+ // rejecting double would fail tests for a reason production never has. A test asserting what
74
+ // its plugin publishes overrides this handle after the spread.
75
+ events: { publish: () => void 0 }
76
+ };
77
+ }
78
+ function defaultTestToolContext() {
79
+ return { cwd: "/tmp", model: void 0 };
80
+ }
81
+ async function invokeToolForTest(tool, params, ctx = defaultTestToolContext()) {
82
+ return tool.execute("test-call", params, void 0, void 0, ctx);
83
+ }
84
+ export {
85
+ fauxAuthContext,
86
+ fauxKayAgentCapabilities,
87
+ invokeToolForTest
88
+ };