@yaklabs-ai/plugin-sdk 0.10.0 → 0.12.2
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 +1 -1
- package/THIRD-PARTY-INVENTORY.json +13 -20
- package/THIRD-PARTY-NOTICES.md +12 -36
- package/dist/disclosure.d.ts +511 -27
- package/dist/disclosure.js +30 -0
- package/dist/jev.d.ts +145 -18
- package/dist/jev.js +14 -0
- package/dist/kay-agent-testing.d.ts +563 -43
- package/dist/kay-agent-testing.js +124 -1
- package/dist/kay-agent.d.ts +644 -42
- package/dist/kay-agent.js +126 -0
- package/dist/kay-app.d.ts +686 -73
- package/dist/kay-app.js +126 -0
- package/dist/signals.d.ts +113 -18
- package/dist/signals.js +4 -0
- package/package.json +2 -3
|
@@ -1,3 +1,102 @@
|
|
|
1
|
+
// packages/herd-agent/dist/core/tools/tool-parameters.js
|
|
2
|
+
import { z } from "zod";
|
|
3
|
+
var URI_PAYLOAD_MARKER = "x-kay-uri-payload";
|
|
4
|
+
var uriPayloadSchema = z.union([
|
|
5
|
+
z.string(),
|
|
6
|
+
z.record(z.string(), z.unknown()),
|
|
7
|
+
z.array(z.unknown()),
|
|
8
|
+
z.number(),
|
|
9
|
+
z.boolean(),
|
|
10
|
+
z.null()
|
|
11
|
+
]).meta({ [URI_PAYLOAD_MARKER]: true });
|
|
12
|
+
|
|
13
|
+
// packages/herd-uri/dist/produced-resources.js
|
|
14
|
+
var PRODUCED_RESOURCES_DETAILS_KEY = "producedResources";
|
|
15
|
+
var ABSENT = { kind: "absent" };
|
|
16
|
+
var MALFORMED = { kind: "malformed" };
|
|
17
|
+
var SCHEME_URI = /^[a-z][a-z0-9+.-]*:\/\/./;
|
|
18
|
+
var WINDOWS_ABSOLUTE_PATH = /^[A-Za-z]:[\\/]./;
|
|
19
|
+
function isProducedResourceUri(value) {
|
|
20
|
+
if (typeof value !== "string" || value.trim() !== value)
|
|
21
|
+
return false;
|
|
22
|
+
return SCHEME_URI.test(value) || value.startsWith("/") && value.length > 1 || WINDOWS_ABSOLUTE_PATH.test(value);
|
|
23
|
+
}
|
|
24
|
+
function isProducedResourceDeclaration(value) {
|
|
25
|
+
if (typeof value !== "object" || value === null || Array.isArray(value)) {
|
|
26
|
+
return false;
|
|
27
|
+
}
|
|
28
|
+
const keys = Object.keys(value);
|
|
29
|
+
if (keys.length !== 2 || !keys.includes("uri") || !keys.includes("action")) {
|
|
30
|
+
return false;
|
|
31
|
+
}
|
|
32
|
+
const record = value;
|
|
33
|
+
return isProducedResourceUri(record.uri) && (record.action === "created" || record.action === "updated");
|
|
34
|
+
}
|
|
35
|
+
function readProducedResourceDeclarations(details) {
|
|
36
|
+
if (typeof details !== "object" || details === null || Array.isArray(details) || !Object.hasOwn(details, PRODUCED_RESOURCES_DETAILS_KEY)) {
|
|
37
|
+
return ABSENT;
|
|
38
|
+
}
|
|
39
|
+
const claimed = details[PRODUCED_RESOURCES_DETAILS_KEY];
|
|
40
|
+
if (!Array.isArray(claimed))
|
|
41
|
+
return MALFORMED;
|
|
42
|
+
if (claimed.length === 0)
|
|
43
|
+
return ABSENT;
|
|
44
|
+
if (!claimed.every(isProducedResourceDeclaration))
|
|
45
|
+
return MALFORMED;
|
|
46
|
+
return { kind: "declared", resources: claimed };
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
// packages/herd-agent/dist/core/is-object.js
|
|
50
|
+
function isObject(value) {
|
|
51
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
// packages/herd-agent/dist/core/tools/produced-resources.js
|
|
55
|
+
var DECLARATIONS = Symbol.for("herd.producedResources.declarations");
|
|
56
|
+
function recordProducedResources(details) {
|
|
57
|
+
if (!isObject(details))
|
|
58
|
+
return unchanged(details);
|
|
59
|
+
const channel = channelOf(details);
|
|
60
|
+
const droppedPayloadValue = Object.hasOwn(details, PRODUCED_RESOURCES_DETAILS_KEY);
|
|
61
|
+
if (channel === void 0 && !droppedPayloadValue)
|
|
62
|
+
return unchanged(details);
|
|
63
|
+
const recorded = Object.fromEntries(Object.entries(details).filter(([key]) => key !== PRODUCED_RESOURCES_DETAILS_KEY));
|
|
64
|
+
let malformedClaim = false;
|
|
65
|
+
if (channel !== void 0) {
|
|
66
|
+
const claims = claimsFrom(channel);
|
|
67
|
+
if (claims.length > 0) {
|
|
68
|
+
recorded[PRODUCED_RESOURCES_DETAILS_KEY] = claims;
|
|
69
|
+
malformedClaim = !claims.every(isProducedResourceDeclaration);
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
return { details: recorded, droppedPayloadValue, malformedClaim };
|
|
73
|
+
}
|
|
74
|
+
function unchanged(details) {
|
|
75
|
+
return { details, droppedPayloadValue: false, malformedClaim: false };
|
|
76
|
+
}
|
|
77
|
+
function channelOf(details) {
|
|
78
|
+
return Object.hasOwn(details, DECLARATIONS) ? details[DECLARATIONS] : void 0;
|
|
79
|
+
}
|
|
80
|
+
function claimsFrom(claimed) {
|
|
81
|
+
try {
|
|
82
|
+
return Array.isArray(claimed) ? Array.from(claimed, snapshotClaim) : [snapshotClaim(claimed)];
|
|
83
|
+
} catch (error) {
|
|
84
|
+
return [`<unreadable claim: ${typeof error}>`];
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
function snapshotClaim(value) {
|
|
88
|
+
if (!isObject(value))
|
|
89
|
+
return jsonValue(value);
|
|
90
|
+
const copy = Object.fromEntries(Object.entries(value).map(([key, field]) => [key, jsonValue(field)]));
|
|
91
|
+
return isProducedResourceDeclaration(copy) ? Object.freeze({ uri: copy.uri, action: copy.action }) : Object.freeze(copy);
|
|
92
|
+
}
|
|
93
|
+
function jsonValue(value) {
|
|
94
|
+
if (value === null || typeof value === "string" || typeof value === "boolean" || typeof value === "number" && Number.isFinite(value)) {
|
|
95
|
+
return value;
|
|
96
|
+
}
|
|
97
|
+
return `<${Array.isArray(value) ? "array" : typeof value}>`;
|
|
98
|
+
}
|
|
99
|
+
|
|
1
100
|
// packages/herd-agent/dist/testing.js
|
|
2
101
|
function fauxAuthContext(overrides = {}) {
|
|
3
102
|
return {
|
|
@@ -27,11 +126,22 @@ function unwired(name) {
|
|
|
27
126
|
throw new Error(`${name} is not wired in this test double; pass your own handle to exercise it`);
|
|
28
127
|
};
|
|
29
128
|
}
|
|
129
|
+
var NOT_WIRED = async () => ({ ok: false, reason: "unavailable", message: "not wired" });
|
|
130
|
+
var UNWIRED_SURFACE = {
|
|
131
|
+
isAvailable: async () => false,
|
|
132
|
+
targets: NOT_WIRED,
|
|
133
|
+
observe: NOT_WIRED,
|
|
134
|
+
act: NOT_WIRED,
|
|
135
|
+
screenshot: NOT_WIRED,
|
|
136
|
+
open: NOT_WIRED
|
|
137
|
+
};
|
|
30
138
|
function fauxKayAgentCapabilities() {
|
|
31
139
|
return {
|
|
32
140
|
filesystem: {
|
|
33
141
|
readText: unwired("filesystem.readText"),
|
|
34
142
|
writeText: unwired("filesystem.writeText"),
|
|
143
|
+
readBytes: unwired("filesystem.readBytes"),
|
|
144
|
+
writeBytes: unwired("filesystem.writeBytes"),
|
|
35
145
|
mkdir: unwired("filesystem.mkdir"),
|
|
36
146
|
readDir: unwired("filesystem.readDir"),
|
|
37
147
|
stat: unwired("filesystem.stat"),
|
|
@@ -62,6 +172,9 @@ function fauxKayAgentCapabilities() {
|
|
|
62
172
|
remove: unwired("whiteboard.remove")
|
|
63
173
|
})
|
|
64
174
|
},
|
|
175
|
+
// Answers `unavailable` rather than rejecting: the real surfaces report an unavailable
|
|
176
|
+
// surface as `{ ok: false }`, never a throw. A test driving one overrides this handle.
|
|
177
|
+
interaction: { browserPane: UNWIRED_SURFACE, desktop: UNWIRED_SURFACE },
|
|
65
178
|
interceptToolCall: () => void 0,
|
|
66
179
|
// The one handle that does NOT refuse on use. `withJev`'s contract is that it always produces
|
|
67
180
|
// the baseline, so a rejecting double would make a plugin's Jev path untestable and teach the
|
|
@@ -81,8 +194,18 @@ function defaultTestToolContext() {
|
|
|
81
194
|
async function invokeToolForTest(tool, params, ctx = defaultTestToolContext()) {
|
|
82
195
|
return tool.execute("test-call", params, void 0, void 0, ctx);
|
|
83
196
|
}
|
|
197
|
+
function producedResourcesForTest(result) {
|
|
198
|
+
const recorded = recordProducedResources(result.details).details;
|
|
199
|
+
const read = readProducedResourceDeclarations(recorded);
|
|
200
|
+
if (read.kind === "malformed") {
|
|
201
|
+
const claim = recorded[PRODUCED_RESOURCES_DETAILS_KEY];
|
|
202
|
+
throw new TypeError(`The tool declared produced resources the contract refuses, so a run would report a gap for this call: ${JSON.stringify(claim)}. Each declaration must be exactly { uri, action }, where uri is a scheme:// URI or an absolute local path with no surrounding whitespace and action is "created" or "updated".`);
|
|
203
|
+
}
|
|
204
|
+
return read;
|
|
205
|
+
}
|
|
84
206
|
export {
|
|
85
207
|
fauxAuthContext,
|
|
86
208
|
fauxKayAgentCapabilities,
|
|
87
|
-
invokeToolForTest
|
|
209
|
+
invokeToolForTest,
|
|
210
|
+
producedResourcesForTest
|
|
88
211
|
};
|