@yaklabs-ai/plugin-sdk 0.11.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 +27 -0
- package/dist/jev.d.ts +145 -18
- package/dist/jev.js +14 -0
- package/dist/kay-agent-testing.d.ts +511 -43
- package/dist/kay-agent-testing.js +14 -0
- package/dist/kay-agent.d.ts +605 -42
- package/dist/kay-agent.js +52 -0
- package/dist/kay-app.d.ts +653 -75
- 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
package/dist/disclosure.js
CHANGED
|
@@ -730,12 +730,33 @@ async function auditSkillCodegenPairFile(skill, declaration, packageDir) {
|
|
|
730
730
|
return violations;
|
|
731
731
|
}
|
|
732
732
|
|
|
733
|
+
// packages/plugin-sdk/dist/kay-agent/interaction.js
|
|
734
|
+
function unavailableInteractionSurface(message) {
|
|
735
|
+
const refused = async () => ({ ok: false, reason: "unavailable", message });
|
|
736
|
+
return {
|
|
737
|
+
isAvailable: async () => false,
|
|
738
|
+
targets: refused,
|
|
739
|
+
observe: refused,
|
|
740
|
+
act: refused,
|
|
741
|
+
screenshot: refused,
|
|
742
|
+
open: refused
|
|
743
|
+
};
|
|
744
|
+
}
|
|
745
|
+
function unavailableInteractionSurfaces(message) {
|
|
746
|
+
return {
|
|
747
|
+
browserPane: unavailableInteractionSurface(message),
|
|
748
|
+
desktop: unavailableInteractionSurface(message)
|
|
749
|
+
};
|
|
750
|
+
}
|
|
751
|
+
|
|
733
752
|
// packages/plugin-sdk/dist/disclosure/probe-kay-agent-capabilities.js
|
|
734
753
|
var inertResult = () => new Promise(() => {
|
|
735
754
|
});
|
|
736
755
|
var INERT_FILESYSTEM = {
|
|
737
756
|
readText: inertResult,
|
|
738
757
|
writeText: inertResult,
|
|
758
|
+
readBytes: inertResult,
|
|
759
|
+
writeBytes: inertResult,
|
|
739
760
|
mkdir: inertResult,
|
|
740
761
|
readDir: inertResult,
|
|
741
762
|
stat: inertResult,
|
|
@@ -778,6 +799,8 @@ function createKayAgentProbeCapabilityHandles() {
|
|
|
778
799
|
webSession: INERT_WEB_SESSION,
|
|
779
800
|
process: INERT_PROCESS,
|
|
780
801
|
whiteboard: INERT_WHITEBOARD,
|
|
802
|
+
// Answers `unavailable` at once: a probe must never reach the user's browser or desktop.
|
|
803
|
+
interaction: unavailableInteractionSurfaces("Interaction surfaces are not available while a plugin is being probed."),
|
|
781
804
|
interceptToolCall: () => {
|
|
782
805
|
},
|
|
783
806
|
withJev: INERT_WITH_JEV,
|
|
@@ -801,6 +824,8 @@ function collectUriModulesFromKayAgentActivate(activate) {
|
|
|
801
824
|
},
|
|
802
825
|
registerSearchProvider: () => {
|
|
803
826
|
},
|
|
827
|
+
registerInteractionDriver: () => {
|
|
828
|
+
},
|
|
804
829
|
registerConverter: () => {
|
|
805
830
|
},
|
|
806
831
|
auth: {
|
|
@@ -838,6 +863,8 @@ function collectAuthDeclarationsFromKayAgentActivate(activate) {
|
|
|
838
863
|
},
|
|
839
864
|
registerSearchProvider: () => {
|
|
840
865
|
},
|
|
866
|
+
registerInteractionDriver: () => {
|
|
867
|
+
},
|
|
841
868
|
registerConverter: () => {
|
|
842
869
|
},
|
|
843
870
|
auth: {
|
package/dist/jev.d.ts
CHANGED
|
@@ -1,9 +1,3 @@
|
|
|
1
|
-
import { Questions } from '@typesafe-ai/sdk';
|
|
2
|
-
import { SystemOneRequest } from '@typesafe-ai/sdk';
|
|
3
|
-
import { SystemOneResult } from '@typesafe-ai/sdk';
|
|
4
|
-
import { TypeSafeClient } from '@typesafe-ai/sdk';
|
|
5
|
-
import { Usage } from '@typesafe-ai/sdk';
|
|
6
|
-
|
|
7
1
|
/**
|
|
8
2
|
* The `withJev` a host with no Jev lane binds: `use` is never called, no client is ever built,
|
|
9
3
|
* and no network is ever touched. It keeps the cancellation contract identical to the real
|
|
@@ -15,21 +9,155 @@ import { Usage } from '@typesafe-ai/sdk';
|
|
|
15
9
|
*/
|
|
16
10
|
export declare function createFallbackOnlyWithJev(): WithJev;
|
|
17
11
|
|
|
18
|
-
export
|
|
12
|
+
export declare type JevAnswer = JevBoolAnswer | JevChoiceAnswer | JevScoreAnswer;
|
|
13
|
+
|
|
14
|
+
/** The answer shape one question gets back. */
|
|
15
|
+
export declare type JevAnswerFor<Q> = Q extends JevBoolQuestion ? JevBoolAnswer : Q extends JevChoiceQuestion<infer L> ? JevChoiceAnswer<L> : Q extends JevScoreQuestion ? JevScoreAnswer : never;
|
|
16
|
+
|
|
17
|
+
export declare interface JevBoolAnswer {
|
|
18
|
+
readonly type: "bool";
|
|
19
|
+
/** P(yes), from 0 to 1. */
|
|
20
|
+
readonly probability: number;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
/** A yes/no question. `criteria` says what yes and what no mean; omit it to leave both open. */
|
|
24
|
+
export declare interface JevBoolQuestion {
|
|
25
|
+
readonly type: "bool";
|
|
26
|
+
readonly instructions: string;
|
|
27
|
+
readonly criteria?: {
|
|
28
|
+
readonly true: string;
|
|
29
|
+
readonly false: string;
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* The one error `classify` rejects with. It carries a classification, never the provider's own
|
|
35
|
+
* message or body: those can echo the request state, and this error reaches logs.
|
|
36
|
+
*/
|
|
37
|
+
export declare class JevCallError extends Error {
|
|
38
|
+
readonly transport: JevTransport;
|
|
39
|
+
readonly kind: JevCallErrorKind;
|
|
40
|
+
/** The final attempt's HTTP status, when a response arrived. */
|
|
41
|
+
readonly status: number | undefined;
|
|
42
|
+
constructor(init: {
|
|
43
|
+
readonly transport: JevTransport;
|
|
44
|
+
readonly kind: JevCallErrorKind;
|
|
45
|
+
readonly status?: number | undefined;
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* Why a Jev call failed, as a closed set:
|
|
51
|
+
*
|
|
52
|
+
* - `http`: the route answered with an error status (`status` says which).
|
|
53
|
+
* - `too-large`: the route refused the request's size (413, or a 400 naming the token limit).
|
|
54
|
+
* - `network`: no response arrived.
|
|
55
|
+
* - `aborted`: the call was cancelled.
|
|
56
|
+
* - `invalid-answer`: the route answered, but not with an answer for every asked question.
|
|
57
|
+
*/
|
|
58
|
+
export declare type JevCallErrorKind = "http" | "too-large" | "network" | "aborted" | "invalid-answer";
|
|
19
59
|
|
|
20
|
-
export
|
|
60
|
+
export declare interface JevChoiceAnswer<L extends string = string> {
|
|
61
|
+
readonly type: "choice";
|
|
62
|
+
readonly choice: L;
|
|
63
|
+
readonly confidence: number;
|
|
64
|
+
/** P(label) for every offered label. */
|
|
65
|
+
readonly probabilities: Readonly<Record<L, number>>;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
/** A choice among labels. Each label maps to what it means; an empty string leaves it open. */
|
|
69
|
+
export declare interface JevChoiceQuestion<L extends string = string> {
|
|
70
|
+
readonly type: "choice";
|
|
71
|
+
readonly instructions: string;
|
|
72
|
+
readonly criteria: Readonly<Record<L, string>>;
|
|
73
|
+
}
|
|
21
74
|
|
|
22
|
-
|
|
75
|
+
/** One answered request: every asked question has an answer of its own kind. */
|
|
76
|
+
export declare interface JevClassification<Q extends JevQuestions = JevQuestions> {
|
|
77
|
+
/** The Jev model the host asked. */
|
|
78
|
+
readonly model: string;
|
|
79
|
+
readonly answers: {
|
|
80
|
+
readonly [K in keyof Q]: JevAnswerFor<Q[K]>;
|
|
81
|
+
};
|
|
82
|
+
/** Token counts, when the route reported them. */
|
|
83
|
+
readonly usage?: {
|
|
84
|
+
readonly inputTokens: number;
|
|
85
|
+
readonly outputTokens: number;
|
|
86
|
+
};
|
|
87
|
+
}
|
|
23
88
|
|
|
24
|
-
export
|
|
89
|
+
export declare interface JevClassifyRequest<Q extends JevQuestions = JevQuestions> {
|
|
90
|
+
readonly state: JevState;
|
|
91
|
+
readonly questions: Q;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
/**
|
|
95
|
+
* The Jev client a `use` body receives. `classify` either resolves with an answer for every
|
|
96
|
+
* asked question, each of its question's kind, or rejects with a {@link JevCallError}; it never
|
|
97
|
+
* resolves with a partial or substituted answer.
|
|
98
|
+
*/
|
|
99
|
+
export declare interface JevClient {
|
|
100
|
+
classify<const Q extends JevQuestions>(request: JevClassifyRequest<Q>, options?: {
|
|
101
|
+
readonly signal?: AbortSignal;
|
|
102
|
+
}): Promise<JevClassification<Q>>;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
export declare type JevQuestion = JevBoolQuestion | JevChoiceQuestion | JevScoreQuestion;
|
|
106
|
+
|
|
107
|
+
/** A rubric: questions keyed by the name each answer comes back under. */
|
|
108
|
+
export declare type JevQuestions = Readonly<Record<string, JevQuestion>>;
|
|
109
|
+
|
|
110
|
+
export declare interface JevScoreAnswer {
|
|
111
|
+
readonly type: "score";
|
|
112
|
+
/** The expected score, from 0 to the number of rungs minus one. */
|
|
113
|
+
readonly score: number;
|
|
114
|
+
readonly confidence: number;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
/** A score over ordered rungs: the first criterion scores 0, the next 1, and so on. */
|
|
118
|
+
export declare interface JevScoreQuestion {
|
|
119
|
+
readonly type: "score";
|
|
120
|
+
readonly instructions: string;
|
|
121
|
+
readonly criteria: readonly string[];
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
/**
|
|
125
|
+
* ---
|
|
126
|
+
* responsibility: The plugin-facing CONTRACT for Jev typed-decision inference — the shape of
|
|
127
|
+
* `api.withJev` on both plugin SDK targets, the {@link JevClient} a `use` body receives, the
|
|
128
|
+
* question and answer vocabulary it speaks, and the fallback-only implementation a host
|
|
129
|
+
* without a Jev lane binds.
|
|
130
|
+
* owns:
|
|
131
|
+
* - {@link WithJev}, {@link WithJevOptions}, {@link createFallbackOnlyWithJev}.
|
|
132
|
+
* - {@link JevClient}, the {@link JevQuestion} and {@link JevAnswer} vocabulary, and
|
|
133
|
+
* {@link JevCallError}.
|
|
134
|
+
* does_not_own:
|
|
135
|
+
* - The wire. The host serves `classify` over whichever route the user's Jev provider order
|
|
136
|
+
* picks; a plugin never sees a vendor client, a vendor type, or a route.
|
|
137
|
+
* - Credential resolution, the `jev.use` decision, the Jev-branch budget, or usage accounting.
|
|
138
|
+
* Those are host-side (`@kay/agent-runtime`'s `kay/jev/`).
|
|
139
|
+
* ---
|
|
140
|
+
*
|
|
141
|
+
* The vocabulary is Kay's own (SDK 0.12.0). Before it, `use` received TypeSafe's `TypeSafeClient`
|
|
142
|
+
* and plugins coded against a vendor's types. It follows pi's classifier contract, which the host
|
|
143
|
+
* runs Jev through: a yes/no question is `bool` and answers a `probability`, every instruction and
|
|
144
|
+
* criterion is text, and the state is a JSON object.
|
|
145
|
+
*/
|
|
146
|
+
/**
|
|
147
|
+
* The state a rubric reads: a JSON object, never text or an array. Every value must survive
|
|
148
|
+
* `JSON.stringify` unchanged (no functions or class instances), because it is sent as JSON.
|
|
149
|
+
* Typed as `object` so a state declared as an interface fits without an index signature.
|
|
150
|
+
*/
|
|
151
|
+
export declare type JevState = object;
|
|
25
152
|
|
|
26
|
-
|
|
153
|
+
/** The route a Jev call took: the user's own TypeSafe key, or Bonsai's hosted gateway. */
|
|
154
|
+
export declare type JevTransport = "direct" | "hosted";
|
|
27
155
|
|
|
28
156
|
/**
|
|
29
157
|
* Run `use` against a live Jev client, falling back to `fallback` whenever Jev cannot serve the
|
|
30
158
|
* call. The wrapper exists so a feature can ASK for a typed decision without ever depending on
|
|
31
|
-
* one: `fallback` is required, and it runs whenever no
|
|
32
|
-
* the user has not granted `jev.use`, the branch exceeds its budget, `use` throws, or
|
|
159
|
+
* one: `fallback` is required, and it runs whenever no provider in the user's Jev provider
|
|
160
|
+
* order holds a usable credential, the user has not granted `jev.use`, the branch exceeds its budget, `use` throws, or
|
|
33
161
|
* `use` declines by returning `undefined`. With valid options, this rejects on an explicit
|
|
34
162
|
* `signal` abort, reaching `deadlineAt`, or `fallback` itself throwing.
|
|
35
163
|
*
|
|
@@ -37,10 +165,9 @@ export { Usage }
|
|
|
37
165
|
* {@link createFallbackOnlyWithJev}, so a caller never branches on availability — branching is
|
|
38
166
|
* exactly how a fallback gets skipped.
|
|
39
167
|
*
|
|
40
|
-
* `jev` is
|
|
41
|
-
*
|
|
42
|
-
*
|
|
43
|
-
* refused at the transport, and an in-flight request is aborted when the call stops waiting.
|
|
168
|
+
* `jev` is a {@link JevClient} on the host's Jev model. It is valid only for the duration of
|
|
169
|
+
* the callback: a reference retained past `use`'s scope is refused at the transport, and an
|
|
170
|
+
* in-flight request is aborted when the call stops waiting.
|
|
44
171
|
* The callback itself is ABANDONED, not interrupted — a host cannot stop arbitrary JavaScript
|
|
45
172
|
* that is already running, so `use` must not perform side effects it would mind completing
|
|
46
173
|
* unobserved. The same applies to a running fallback: abort/deadline stops waiting for it but
|
|
@@ -49,7 +176,7 @@ export { Usage }
|
|
|
49
176
|
export declare type WithJev = <T>(
|
|
50
177
|
/** Return `undefined` to decline (the fallback runs). A feature whose real result can itself be
|
|
51
178
|
* `undefined` should return `null` or its own wrapper type instead. */
|
|
52
|
-
use: (jev:
|
|
179
|
+
use: (jev: JevClient) => T | undefined | PromiseLike<T | undefined>,
|
|
53
180
|
/** Required. The behaviour the feature has without Jev. */
|
|
54
181
|
fallback: () => T | PromiseLike<T>, options?: WithJevOptions) => Promise<T>;
|
|
55
182
|
|
package/dist/jev.js
CHANGED
|
@@ -1,4 +1,17 @@
|
|
|
1
1
|
// packages/plugin-sdk/dist/jev.js
|
|
2
|
+
var JevCallError = class extends Error {
|
|
3
|
+
transport;
|
|
4
|
+
kind;
|
|
5
|
+
/** The final attempt's HTTP status, when a response arrived. */
|
|
6
|
+
status;
|
|
7
|
+
constructor(init) {
|
|
8
|
+
super(`Jev call failed on the ${init.transport} route: ${init.kind}${init.status === void 0 ? "" : ` (HTTP ${init.status})`}.`);
|
|
9
|
+
this.name = "JevCallError";
|
|
10
|
+
this.transport = init.transport;
|
|
11
|
+
this.kind = init.kind;
|
|
12
|
+
this.status = init.status;
|
|
13
|
+
}
|
|
14
|
+
};
|
|
2
15
|
function createFallbackOnlyWithJev() {
|
|
3
16
|
return async (_use, fallback, options = {}) => {
|
|
4
17
|
if (typeof fallback !== "function") {
|
|
@@ -59,5 +72,6 @@ function createFallbackOnlyWithJev() {
|
|
|
59
72
|
};
|
|
60
73
|
}
|
|
61
74
|
export {
|
|
75
|
+
JevCallError,
|
|
62
76
|
createFallbackOnlyWithJev
|
|
63
77
|
};
|