@yaklabs-ai/plugin-sdk 0.53.0 → 0.54.1

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/dist/kay-agent.js CHANGED
@@ -1,3 +1,20 @@
1
+ // packages/plugin-sdk/dist/workers.js
2
+ var PluginWorkerError = class extends Error {
3
+ code;
4
+ constructor(code, message = `Plugin worker request failed: ${code}`) {
5
+ super(message);
6
+ this.code = code;
7
+ this.name = "PluginWorkerError";
8
+ }
9
+ };
10
+ function createUnavailablePluginWorkers() {
11
+ return {
12
+ async run() {
13
+ throw new PluginWorkerError("spawn_failed", "Plugin workers are not available on this host.");
14
+ }
15
+ };
16
+ }
17
+
1
18
  // packages/herd-uri/dist/claims.js
2
19
  var SCHEME_RE = /^([a-z][a-z0-9+.-]*):\/\//i;
3
20
  var CAPTURE_RE = /^[A-Za-z_][A-Za-z0-9_]*$/;
@@ -999,6 +1016,31 @@ function createUnavailableUriCaller(message) {
999
1016
  };
1000
1017
  }
1001
1018
 
1019
+ // packages/plugin-protocol/dist/project-directories.js
1020
+ import { z as z5 } from "zod";
1021
+ var PluginProjectDirectories = z5.strictObject({
1022
+ /** An endpoint this plugin's app target declares; called with a {@link ProjectDirectoryRequest}. */
1023
+ endpoint: z5.string().min(1),
1024
+ /** A scheme this plugin's URI modules serve; a project is addressed as `<scheme>://<id>`. */
1025
+ scheme: z5.string().min(1)
1026
+ });
1027
+ var ProjectDirectoryRequest = z5.strictObject({
1028
+ /** The project's stable id. */
1029
+ id: z5.string().min(1)
1030
+ });
1031
+ var ProjectDirectory = z5.strictObject({
1032
+ id: z5.string().min(1),
1033
+ /** Absolute path of the project's folder. */
1034
+ path: z5.string().min(1),
1035
+ /** Absolute path a new session in this project starts in. */
1036
+ defaultCwd: z5.string().min(1),
1037
+ /** Ancestor project ids, root first. */
1038
+ ancestorIds: z5.array(z5.string().min(1))
1039
+ });
1040
+ var ProjectDirectoryResponse = z5.strictObject({
1041
+ project: ProjectDirectory.nullable()
1042
+ });
1043
+
1002
1044
  // packages/plugin-sdk/dist/endpoints.js
1003
1045
  function createUnavailablePluginEndpointCaller(message) {
1004
1046
  return {
@@ -1171,7 +1213,7 @@ async function readBodyWithByteCap(response, maxBytes) {
1171
1213
  }
1172
1214
 
1173
1215
  // packages/plugin-primitives/dist/tool-parameters.js
1174
- import { z as z5 } from "zod";
1216
+ import { z as z6 } from "zod";
1175
1217
  var URI_PAYLOAD_MARKER = "x-kay-uri-payload";
1176
1218
  var URI_PAYLOAD_WIRE_TYPES = [
1177
1219
  "string",
@@ -1181,16 +1223,16 @@ var URI_PAYLOAD_WIRE_TYPES = [
1181
1223
  "boolean",
1182
1224
  "null"
1183
1225
  ];
1184
- var uriPayloadSchema = z5.union([
1185
- z5.string(),
1186
- z5.record(z5.string(), z5.unknown()),
1187
- z5.array(z5.unknown()),
1188
- z5.number(),
1189
- z5.boolean(),
1190
- z5.null()
1226
+ var uriPayloadSchema = z6.union([
1227
+ z6.string(),
1228
+ z6.record(z6.string(), z6.unknown()),
1229
+ z6.array(z6.unknown()),
1230
+ z6.number(),
1231
+ z6.boolean(),
1232
+ z6.null()
1191
1233
  ]).meta({ [URI_PAYLOAD_MARKER]: true });
1192
1234
  function toToolParameters(schema) {
1193
- const jsonSchema = z5.toJSONSchema(schema, {
1235
+ const jsonSchema = z6.toJSONSchema(schema, {
1194
1236
  io: "input",
1195
1237
  override(ctx) {
1196
1238
  const node = ctx.jsonSchema;
@@ -1331,7 +1373,7 @@ function jsonValue(value) {
1331
1373
  }
1332
1374
 
1333
1375
  // packages/plugin-sdk/dist/kay-agent/index.js
1334
- import { z as z7 } from "zod";
1376
+ import { z as z8 } from "zod";
1335
1377
 
1336
1378
  // packages/plugin-sdk/dist/kay-agent/http-client.js
1337
1379
  var PluginApiError = class extends Error {
@@ -1507,7 +1549,7 @@ function createUnavailableEndpoints(message) {
1507
1549
  }
1508
1550
 
1509
1551
  // packages/plugin-sdk/dist/kay-agent/osascript.js
1510
- import { z as z6 } from "zod";
1552
+ import { z as z7 } from "zod";
1511
1553
  var OSASCRIPT_TIMEOUT_MS = 3e4;
1512
1554
  var OSASCRIPT_ENVELOPE_JXA = `
1513
1555
  function jsonOk(data) {
@@ -1517,11 +1559,11 @@ function jsonFail(code, message) {
1517
1559
  return JSON.stringify({ ok: false, error: { code: String(code), message: String(message) } });
1518
1560
  }
1519
1561
  `;
1520
- var envelopeSchema = z6.discriminatedUnion("ok", [
1521
- z6.object({ ok: z6.literal(true), data: z6.unknown() }),
1522
- z6.object({
1523
- ok: z6.literal(false),
1524
- error: z6.object({ code: z6.string(), message: z6.string() })
1562
+ var envelopeSchema = z7.discriminatedUnion("ok", [
1563
+ z7.object({ ok: z7.literal(true), data: z7.unknown() }),
1564
+ z7.object({
1565
+ ok: z7.literal(false),
1566
+ error: z7.object({ code: z7.string(), message: z7.string() })
1525
1567
  })
1526
1568
  ]);
1527
1569
  function readOsascriptOutput(stdout) {
@@ -1717,6 +1759,10 @@ export {
1717
1759
  OSASCRIPT_ENVELOPE_JXA,
1718
1760
  OSASCRIPT_TIMEOUT_MS,
1719
1761
  PluginApiError,
1762
+ PluginWorkerError,
1763
+ ProjectDirectory,
1764
+ ProjectDirectoryRequest,
1765
+ ProjectDirectoryResponse,
1720
1766
  SearchProviderError,
1721
1767
  SecureTransportError,
1722
1768
  URI_TEXT_EDIT_SHAPE_SUMMARY,
@@ -1742,6 +1788,7 @@ export {
1742
1788
  createUnavailableCompiler,
1743
1789
  createUnavailableEndpoints,
1744
1790
  createUnavailablePluginEndpointCaller,
1791
+ createUnavailablePluginWorkers,
1745
1792
  createUnavailableUriCaller,
1746
1793
  declareProducedResources,
1747
1794
  defineAuthedTool,
@@ -1787,5 +1834,5 @@ export {
1787
1834
  uriTextEditPayloadSchema,
1788
1835
  withResolvedAuth,
1789
1836
  withResolvedSearchProvider,
1790
- z7 as z
1837
+ z8 as z
1791
1838
  };
@@ -25,6 +25,254 @@ declare function AddReadonlyDeferred<Type extends TSchema>(type: Type, options?:
25
25
  */
26
26
  declare type AgentMessage = Message | CustomAgentMessages[keyof CustomAgentMessages];
27
27
 
28
+ /**
29
+ * The optional schema-validated terminal output contract a session may declare
30
+ * (issue #2234). `schema` is a bounded JSON object (a JSON Schema); `required`
31
+ * (default off) decides whether a text-only completion settles the turn -
32
+ * `true` holds every run to a submission, while the `"per-run"` literal defers
33
+ * the decision to each run's driver (a reused subagent session's assignment
34
+ * runs are stamped; its internal wake turns are not);
35
+ * `sessionTitle` (default off) adds the reserved `submit_final` field a turn
36
+ * uses to rename its own session; `whenToSubmit` is the one sentence telling the
37
+ * model when an OPTIONAL submission is worth making (ignored when `required`
38
+ * is `true` or `"per-run"`).
39
+ * The wire enforces the size caps and the credential-key tripwire; the herd
40
+ * kernel enforces the full acceptance policy (JSON-only, depth, non-local
41
+ * `$ref`).
42
+ *
43
+ * STRICT on purpose, which makes this schema a required stop for every new
44
+ * contract field: an unmirrored one is not merely absent on the wire, it fails
45
+ * the whole contract's parse, and the consumer that reads a stored session drops
46
+ * the contract entirely rather than reporting anything.
47
+ */
48
+ declare const AgentRuntimeFinalOutputContract: z.ZodObject<{
49
+ schema: z.ZodType<{
50
+ [key: string]: JsonValue_4;
51
+ }, unknown, z.core.$ZodTypeInternals<{
52
+ [key: string]: JsonValue_4;
53
+ }, unknown>>;
54
+ required: z.ZodOptional<z.ZodUnion<readonly [z.ZodBoolean, z.ZodLiteral<"per-run">]>>;
55
+ sessionTitle: z.ZodOptional<z.ZodBoolean>;
56
+ whenToSubmit: z.ZodOptional<z.ZodString>;
57
+ }, z.core.$strict>;
58
+
59
+ declare type AgentRuntimeFinalOutputContract = z.infer<typeof AgentRuntimeFinalOutputContract>;
60
+
61
+ /** Model pricing in USD per one million tokens. */
62
+ declare const AgentRuntimeModelCost: z.ZodObject<{
63
+ input: z.ZodNumber;
64
+ output: z.ZodNumber;
65
+ cacheRead: z.ZodNumber;
66
+ cacheWrite: z.ZodNumber;
67
+ }, z.core.$strict>;
68
+
69
+ declare type AgentRuntimeModelCost = z.infer<typeof AgentRuntimeModelCost>;
70
+
71
+ declare const AgentRuntimeModelFeatures: z.ZodObject<{
72
+ thinking: z.ZodBoolean;
73
+ vision: z.ZodBoolean;
74
+ toolUse: z.ZodBoolean;
75
+ streaming: z.ZodBoolean;
76
+ reasoning: z.ZodOptional<z.ZodBoolean>;
77
+ inputModalities: z.ZodArray<z.ZodEnum<{
78
+ text: "text";
79
+ image: "image";
80
+ audio: "audio";
81
+ video: "video";
82
+ pdf: "pdf";
83
+ embedding: "embedding";
84
+ }>>;
85
+ outputModalities: z.ZodArray<z.ZodEnum<{
86
+ text: "text";
87
+ image: "image";
88
+ audio: "audio";
89
+ video: "video";
90
+ pdf: "pdf";
91
+ embedding: "embedding";
92
+ }>>;
93
+ structuredOutput: z.ZodOptional<z.ZodBoolean>;
94
+ promptCaching: z.ZodOptional<z.ZodBoolean>;
95
+ contextWindow: z.ZodOptional<z.ZodNumber>;
96
+ maxOutputTokens: z.ZodOptional<z.ZodNumber>;
97
+ }, z.core.$strict>;
98
+
99
+ declare type AgentRuntimeModelFeatures = z.infer<typeof AgentRuntimeModelFeatures>;
100
+
101
+ declare const AgentRuntimeModelScores: z.ZodObject<{
102
+ intelligence: z.ZodOptional<z.ZodObject<{
103
+ value: z.ZodNumber;
104
+ }, z.core.$strict>>;
105
+ coding: z.ZodOptional<z.ZodObject<{
106
+ value: z.ZodNumber;
107
+ }, z.core.$strict>>;
108
+ speedTps: z.ZodOptional<z.ZodObject<{
109
+ value: z.ZodNumber;
110
+ }, z.core.$strict>>;
111
+ categories: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodObject<{
112
+ value: z.ZodNumber;
113
+ }, z.core.$strict>>>;
114
+ source: z.ZodOptional<z.ZodString>;
115
+ asOf: z.ZodOptional<z.ZodString>;
116
+ }, z.core.$strict>;
117
+
118
+ declare type AgentRuntimeModelScores = z.infer<typeof AgentRuntimeModelScores>;
119
+
120
+ declare const AgentRuntimeModelTierId: z.ZodEnum<{
121
+ small: "small";
122
+ medium: "medium";
123
+ large: "large";
124
+ ultra: "ultra";
125
+ }>;
126
+
127
+ declare type AgentRuntimeModelTierId = z.infer<typeof AgentRuntimeModelTierId>;
128
+
129
+ /**
130
+ * One product model tier (resolved through the provider tier tables), projected with the
131
+ * model the tier RESOLVES TO for this runtime right now. `resolved` is absent
132
+ * when nothing - pin or floor - is currently eligible; the preview is
133
+ * point-in-time (checked-strength, never minting), so surfaces re-fetch rather
134
+ * than cache it across auth changes.
135
+ */
136
+ declare const AgentRuntimeModelTierInfo: z.ZodObject<{
137
+ id: z.ZodEnum<{
138
+ small: "small";
139
+ medium: "medium";
140
+ large: "large";
141
+ ultra: "ultra";
142
+ }>;
143
+ displayName: z.ZodString;
144
+ description: z.ZodString;
145
+ resolved: z.ZodOptional<z.ZodObject<{
146
+ provider: z.ZodString;
147
+ modelId: z.ZodString;
148
+ modelReference: z.ZodString;
149
+ displayName: z.ZodOptional<z.ZodString>;
150
+ }, z.core.$strict>>;
151
+ }, z.core.$strict>;
152
+
153
+ declare type AgentRuntimeModelTierInfo = z.infer<typeof AgentRuntimeModelTierInfo>;
154
+
155
+ /**
156
+ * One session-steward observation (hindsight): structured FACTS, never
157
+ * actions - appended to the session's log as a `session_steward` custom entry,
158
+ * from which summary state derives (`stewardTitle` / `stewardCommentary` /
159
+ * `stewardNextSteps` / `stewardCompactionSuggested`). Derivation is
160
+ * side-effect-free by contract. The compaction flag has two consumers:
161
+ * auto-compaction taken once at append time behind the
162
+ * `kayLoop.hindsight.stewardAutoCompact` flag, and - when auto-compact is
163
+ * off - the standing `stewardCompactionSuggested` summary field that backs
164
+ * the UI's "compact now" affordance. NOT itself a wire payload - it
165
+ * lives here as the ONE shared source of the summary's steward fields (the
166
+ * entry on disk, the backend fold, and the stored-state reader all validate
167
+ * against it); only the derived summary fields ever cross the wire.
168
+ */
169
+ declare const AgentRuntimeSessionStewardEntry: z.ZodObject<{
170
+ titleChange: z.ZodNullable<z.ZodString>;
171
+ summaryAddition: z.ZodNullable<z.ZodString>;
172
+ nextSteps: z.ZodOptional<z.ZodArray<z.ZodString>>;
173
+ workHeadline: z.ZodOptional<z.ZodString>;
174
+ workHeadlineReview: z.ZodOptional<z.ZodArray<z.ZodUnion<readonly [z.ZodObject<{
175
+ labelKind: z.ZodEnum<{
176
+ purpose: "purpose";
177
+ result: "result";
178
+ }>;
179
+ text: z.ZodString;
180
+ faultProbability: z.ZodNullable<z.ZodNumber>;
181
+ accepted: z.ZodBoolean;
182
+ reason: z.ZodOptional<z.ZodString>;
183
+ }, z.core.$strict>, z.ZodObject<{
184
+ attempt: z.ZodObject<{
185
+ outcome: z.ZodEnum<{
186
+ error: "error";
187
+ none: "none";
188
+ rejected: "rejected";
189
+ }>;
190
+ }, z.core.$strict>;
191
+ }, z.core.$strict>]>>>;
192
+ workBlock: z.ZodOptional<z.ZodObject<{
193
+ firstToolResultEntryId: z.ZodString;
194
+ lastToolResultEntryId: z.ZodString;
195
+ toolResultEntryIds: z.ZodArray<z.ZodString>;
196
+ }, z.core.$strict>>;
197
+ goodCompactionOpportunity: z.ZodOptional<z.ZodBoolean>;
198
+ suggestedModelTier: z.ZodOptional<z.ZodNullable<z.ZodEnum<{
199
+ small: "small";
200
+ medium: "medium";
201
+ large: "large";
202
+ ultra: "ultra";
203
+ }>>>;
204
+ reviewedThroughEntryId: z.ZodOptional<z.ZodString>;
205
+ outcomeVerdict: z.ZodOptional<z.ZodNullable<z.ZodObject<{
206
+ verdict: z.ZodEnum<{
207
+ bad: "bad";
208
+ good: "good";
209
+ mixed: "mixed";
210
+ unclear: "unclear";
211
+ }>;
212
+ confidence: z.ZodEnum<{
213
+ low: "low";
214
+ medium: "medium";
215
+ high: "high";
216
+ }>;
217
+ basis: z.ZodString;
218
+ correctionsObserved: z.ZodNumber;
219
+ retriesObserved: z.ZodNumber;
220
+ rubricVersion: z.ZodNumber;
221
+ }, z.core.$strict>>>;
222
+ deferredVerdicts: z.ZodOptional<z.ZodArray<z.ZodObject<{
223
+ subjectSessionId: z.ZodString;
224
+ verdict: z.ZodEnum<{
225
+ bad: "bad";
226
+ good: "good";
227
+ mixed: "mixed";
228
+ unclear: "unclear";
229
+ }>;
230
+ confidence: z.ZodEnum<{
231
+ low: "low";
232
+ medium: "medium";
233
+ high: "high";
234
+ }>;
235
+ basis: z.ZodString;
236
+ rubricVersion: z.ZodNumber;
237
+ }, z.core.$strict>>>;
238
+ }, z.core.$strict>;
239
+
240
+ declare type AgentRuntimeSessionStewardEntry = z.infer<typeof AgentRuntimeSessionStewardEntry>;
241
+
242
+ /** One trailing-window spend view (mirrors `SpendWindowView`). */
243
+ declare const AgentRuntimeSpendWindow: z.ZodObject<{
244
+ window: z.ZodEnum<{
245
+ trailing24h: "trailing24h";
246
+ trailing7d: "trailing7d";
247
+ trailing30d: "trailing30d";
248
+ trailing90d: "trailing90d";
249
+ }>;
250
+ measuredUsd: z.ZodNumber;
251
+ estimatedUsd: z.ZodNumber;
252
+ unknownTurns: z.ZodNumber;
253
+ tokens: z.ZodObject<{
254
+ input: z.ZodNumber;
255
+ output: z.ZodNumber;
256
+ cacheRead: z.ZodNumber;
257
+ cacheWrite: z.ZodNumber;
258
+ }, z.core.$strict>;
259
+ effectiveUsdPerMTok: z.ZodOptional<z.ZodNumber>;
260
+ }, z.core.$strict>;
261
+
262
+ declare type AgentRuntimeSpendWindow = z.infer<typeof AgentRuntimeSpendWindow>;
263
+
264
+ declare const AgentRuntimeThinkingLevel: z.ZodEnum<{
265
+ max: "max";
266
+ off: "off";
267
+ minimal: "minimal";
268
+ low: "low";
269
+ medium: "medium";
270
+ high: "high";
271
+ xhigh: "xhigh";
272
+ }>;
273
+
274
+ declare type AgentRuntimeThinkingLevel = z.infer<typeof AgentRuntimeThinkingLevel>;
275
+
28
276
  declare const Alpha: TAlpha;
29
277
 
30
278
  /** Creates a Any type. */
@@ -1265,6 +1513,12 @@ declare type JsonValue_3 = string | number | boolean | null | JsonValue_3[] | {
1265
1513
 
1266
1514
  declare const JsonValue_3: z.ZodType<JsonValue_3>;
1267
1515
 
1516
+ declare type JsonValue_4 = string | number | boolean | null | JsonValue_4[] | {
1517
+ [key: string]: JsonValue_4;
1518
+ };
1519
+
1520
+ declare const JsonValue_4: z.ZodType<JsonValue_4>;
1521
+
1268
1522
  /** The inert session-config subset a plugin-authored agent definition may contribute. */
1269
1523
  declare interface KayAppAgentDefinitionConfig {
1270
1524
  /**
@@ -1288,13 +1542,7 @@ declare interface KayAppAgentDefinitionConfig {
1288
1542
  }
1289
1543
 
1290
1544
  /** A plugin-authored definition's structured-output contract (the wire's final-output shape). */
1291
- declare interface KayAppAgentDefinitionFinalOutput {
1292
- /** JSON Schema for the structured value a matching turn submits. */
1293
- readonly schema: JsonSchema;
1294
- readonly required?: boolean | "per-run";
1295
- readonly sessionTitle?: boolean;
1296
- readonly whenToSubmit?: string;
1297
- }
1545
+ declare type KayAppAgentDefinitionFinalOutput = ReadonlyContract<AgentRuntimeFinalOutputContract>;
1298
1546
 
1299
1547
  /**
1300
1548
  * An opaque handle to one definition THIS plugin registered. `define` returns it; `sessions.run`
@@ -1400,27 +1648,10 @@ declare type KayAppModelCompleteOutcome = {
1400
1648
  };
1401
1649
 
1402
1650
  /** Per-million-token model prices projected by the host. */
1403
- declare interface KayAppModelCost {
1404
- readonly input: number;
1405
- readonly output: number;
1406
- readonly cacheRead: number;
1407
- readonly cacheWrite: number;
1408
- }
1651
+ declare type KayAppModelCost = Readonly<AgentRuntimeModelCost>;
1409
1652
 
1410
1653
  /** Model capabilities safe for plugin policy and presentation. */
1411
- declare interface KayAppModelFeatures {
1412
- readonly thinking: boolean;
1413
- readonly vision: boolean;
1414
- readonly toolUse: boolean;
1415
- readonly streaming: boolean;
1416
- readonly reasoning?: boolean;
1417
- readonly inputModalities: readonly KayAppModelModality[];
1418
- readonly outputModalities: readonly KayAppModelModality[];
1419
- readonly structuredOutput?: boolean;
1420
- readonly promptCaching?: boolean;
1421
- readonly contextWindow?: number;
1422
- readonly maxOutputTokens?: number;
1423
- }
1654
+ declare type KayAppModelFeatures = ReadonlyContract<AgentRuntimeModelFeatures>;
1424
1655
 
1425
1656
  /** The plugin-safe projection of one model in Bonsai's live model catalog. */
1426
1657
  declare interface KayAppModelInfo {
@@ -1450,9 +1681,6 @@ declare interface KayAppModelInfo {
1450
1681
  readonly disabledBy?: "privacy-setting" | "subscription-reauth";
1451
1682
  }
1452
1683
 
1453
- /** Input or output modality advertised by a model. */
1454
- declare type KayAppModelModality = "text" | "image" | "audio" | "video" | "pdf" | "embedding";
1455
-
1456
1684
  /** Safe model catalog plus an optional, consented direct-completion broker. */
1457
1685
  declare interface KayAppModels {
1458
1686
  /** Returns the current projection; an empty catalog is an empty array. */
@@ -1477,23 +1705,11 @@ declare interface KayAppModels {
1477
1705
  complete?(input: KayAppModelCompleteInput): Promise<KayAppModelCompleteOutcome>;
1478
1706
  }
1479
1707
 
1480
- /** One normalized model score. */
1481
- declare interface KayAppModelScore {
1482
- readonly value: number;
1483
- }
1484
-
1485
1708
  /** Optional host-curated scores and their provenance. */
1486
- declare interface KayAppModelScores {
1487
- readonly intelligence?: KayAppModelScore;
1488
- readonly coding?: KayAppModelScore;
1489
- readonly speedTps?: KayAppModelScore;
1490
- readonly categories?: Readonly<Record<string, KayAppModelScore>>;
1491
- readonly source?: string;
1492
- readonly asOf?: string;
1493
- }
1709
+ declare type KayAppModelScores = ReadonlyContract<AgentRuntimeModelScores>;
1494
1710
 
1495
1711
  /** Bonsai's canonical task-difficulty tier vocabulary at the plugin boundary. */
1496
- declare type KayAppModelTierId = "small" | "medium" | "large" | "ultra";
1712
+ declare type KayAppModelTierId = AgentRuntimeModelTierId;
1497
1713
 
1498
1714
  /**
1499
1715
  * The plugin-safe projection of one product model tier (small/medium/large/ultra -
@@ -1503,17 +1719,7 @@ declare type KayAppModelTierId = "small" | "medium" | "large" | "ultra";
1503
1719
  * something derivable from the model alone (the same model can be curated onto two
1504
1720
  * different tiers), so `listTiers()` is the only seam a plugin reads it through.
1505
1721
  */
1506
- declare interface KayAppModelTierInfo {
1507
- readonly id: KayAppModelTierId;
1508
- readonly displayName: string;
1509
- readonly description: string;
1510
- readonly resolved?: {
1511
- readonly provider: string;
1512
- readonly modelId: string;
1513
- readonly modelReference: string;
1514
- readonly displayName?: string;
1515
- };
1516
- }
1722
+ declare type KayAppModelTierInfo = ReadonlyContract<AgentRuntimeModelTierInfo>;
1517
1723
 
1518
1724
  /** An ephemeral one-shot agent definition. Identity and permission rules remain host-owned. */
1519
1725
  declare interface KayAppSessionAgentDefinition {
@@ -1529,33 +1735,7 @@ declare interface KayAppSessionAgentDefinition {
1529
1735
  * optional field follows one rule: OMITTED says nothing and leaves the standing value alone, while
1530
1736
  * an explicit value replaces it (`[]` withdraws the next steps, `false` clears a compaction offer).
1531
1737
  */
1532
- declare interface KayAppSessionAnnotation {
1533
- readonly titleChange: string | null;
1534
- readonly summaryAddition: string | null;
1535
- readonly nextSteps?: readonly string[] | undefined;
1536
- /** A one-line label for the closed work block {@link workBlock} names. */
1537
- readonly workHeadline?: string;
1538
- readonly workHeadlineReview?: readonly ({
1539
- readonly labelKind: "result" | "purpose";
1540
- readonly text: string;
1541
- readonly faultProbability: number | null;
1542
- readonly accepted: boolean;
1543
- readonly reason?: string;
1544
- } | {
1545
- readonly attempt: {
1546
- readonly outcome: "none" | "rejected" | "error";
1547
- };
1548
- })[];
1549
- readonly workBlock?: WorkBlockCoverage;
1550
- readonly goodCompactionOpportunity?: boolean;
1551
- /** The last entry the annotation reviewed: the transcript marker's anchor. */
1552
- readonly reviewedThroughEntryId?: string;
1553
- /** A tier the remaining work suits better, or null when the current one still fits. */
1554
- readonly suggestedModelTier?: KayAppModelTierId | null;
1555
- readonly outcomeVerdict?: KayAppSessionOutcomeVerdict | null;
1556
- /** At most three; a verdict naming the annotated session itself is dropped. */
1557
- readonly deferredVerdicts?: readonly KayAppSessionDeferredVerdict[];
1558
- }
1738
+ declare type KayAppSessionAnnotation = ReadonlyContract<AgentRuntimeSessionStewardEntry>;
1559
1739
 
1560
1740
  /** One stored session's spend, including the sessions it started. */
1561
1741
  declare interface KayAppSessionCost {
@@ -1623,21 +1803,7 @@ declare interface KayAppSessionCostModelBreakdown {
1623
1803
  }
1624
1804
 
1625
1805
  /** Token counts across a set of model calls. */
1626
- declare interface KayAppSessionCostTokens {
1627
- readonly input: number;
1628
- readonly output: number;
1629
- readonly cacheRead: number;
1630
- readonly cacheWrite: number;
1631
- }
1632
-
1633
- /** A verdict about an EARLIER session, filed on the annotated one and naming its subject. */
1634
- declare interface KayAppSessionDeferredVerdict {
1635
- readonly subjectSessionId: string;
1636
- readonly verdict: KayAppSessionVerdict;
1637
- readonly confidence: KayAppSessionVerdictConfidence;
1638
- readonly basis: string;
1639
- readonly rubricVersion: number;
1640
- }
1806
+ declare type KayAppSessionCostTokens = Readonly<AgentRuntimeSpendWindow["tokens"]>;
1641
1807
 
1642
1808
  /** One bounded page from the host's stored transcript reader. */
1643
1809
  declare interface KayAppSessionEntryBatch {
@@ -1750,19 +1916,6 @@ declare type KayAppSessionOrigin = {
1750
1916
  readonly forkedAtEntryId?: string | undefined;
1751
1917
  };
1752
1918
 
1753
- /** A judgment of whether the annotated session's own work served the user. */
1754
- declare interface KayAppSessionOutcomeVerdict {
1755
- readonly verdict: KayAppSessionVerdict;
1756
- readonly confidence: KayAppSessionVerdictConfidence;
1757
- /** The stated evidence. The host cuts an over-long basis on a word boundary. */
1758
- readonly basis: string;
1759
- /** User-correction turns counted in the transcript. */
1760
- readonly correctionsObserved: number;
1761
- /** Visible retry loops counted in the transcript. */
1762
- readonly retriesObserved: number;
1763
- readonly rubricVersion: number;
1764
- }
1765
-
1766
1919
  /**
1767
1920
  * One bounded page of a session's stored transcript, oldest first, or why there is none. Pass
1768
1921
  * `cursor` back for the next page. `replace` means the page starts over from the first record: the
@@ -1824,6 +1977,18 @@ declare type KayAppSessionPageItem = (Omit<Extract<TranscriptPageItem, {
1824
1977
  readonly unreadable: unknown;
1825
1978
  }>;
1826
1979
 
1980
+ /** One write for {@link KayAppSessions.assignProject}. */
1981
+ declare interface KayAppSessionProjectAssignment {
1982
+ readonly sessionId: string;
1983
+ /**
1984
+ * The project the session must still hold for the write to land: a project id, `null` for "no
1985
+ * project" chosen on purpose, or absent for a session whose project was never decided.
1986
+ */
1987
+ readonly expectedProjectId?: string | null;
1988
+ /** The project to set; `null` sets "no project". */
1989
+ readonly projectId: string | null;
1990
+ }
1991
+
1827
1992
  /**
1828
1993
  * What one headless system run reports back. The run's spend is read from the
1829
1994
  * ledger after the turn settles; `cost` is absent when no spend rows were
@@ -2158,6 +2323,15 @@ declare interface KayAppSessions {
2158
2323
  } | {
2159
2324
  readonly kind: "unavailable";
2160
2325
  }>;
2326
+ /**
2327
+ * Private API: only plugins Bonsai ships; refused for any other. Set the project of any stored
2328
+ * sessions, each only while it still holds the project the caller last saw (a compare-and-set,
2329
+ * so a person's own choice made meanwhile always wins). Answers one boolean per assignment, in
2330
+ * order: `false` when the session is gone or its project changed. A written session's project
2331
+ * folder and prompt block are refreshed. Checked against `sessions.assign-project`; a refused
2332
+ * call rejects.
2333
+ */
2334
+ assignProject?(assignments: readonly KayAppSessionProjectAssignment[]): Promise<readonly boolean[]>;
2161
2335
  /**
2162
2336
  * Run one hidden headless system session through Bonsai's harness and resolve
2163
2337
  * with its final output - the sole sanctioned way for a `kay.app` plugin to
@@ -2274,12 +2448,6 @@ export declare interface KayAppSessionSummaryResult {
2274
2448
  readonly continuation?: KayAppSessionSummaryContinuation;
2275
2449
  }
2276
2450
 
2277
- /** How a session's work is judged to have served the user. `"unclear"` is a real answer, not a failure. */
2278
- declare type KayAppSessionVerdict = "good" | "mixed" | "bad" | "unclear";
2279
-
2280
- /** The judge's own certainty: a tuning filter, never a weight the reader applies. */
2281
- declare type KayAppSessionVerdictConfidence = "low" | "medium" | "high";
2282
-
2283
2451
  export declare interface KayAppSessionWorkSummary {
2284
2452
  readonly goal: string;
2285
2453
  readonly work: readonly string[];
@@ -2316,7 +2484,7 @@ declare interface KayAppStoredSession {
2316
2484
  }
2317
2485
 
2318
2486
  /** Bonsai's reasoning-effort ladder, in ascending order. */
2319
- declare type KayAppThinkingLevel = "off" | "minimal" | "low" | "medium" | "high" | "xhigh" | "max";
2487
+ declare type KayAppThinkingLevel = AgentRuntimeThinkingLevel;
2320
2488
 
2321
2489
  /**
2322
2490
  * The host-stamped per-call context an app-contributed tool's `execute` receives. The app
@@ -3039,6 +3207,10 @@ declare function Readonly_2<Type extends TSchema>(type: Type): TAddReadonly<Type
3039
3207
 
3040
3208
  declare const Readonly_3: (input: string) => [unknown, string] | [];
3041
3209
 
3210
+ declare type ReadonlyContract<T> = T extends readonly (infer Item)[] ? readonly ReadonlyContract<Item>[] : T extends object ? {
3211
+ readonly [Key in keyof T]: ReadonlyContract<T[Key]>;
3212
+ } : T;
3213
+
3042
3214
  declare type ReadonlyKeys<Properties extends TProperties, Result extends PropertyKey = {
3043
3215
  [Key in keyof Properties]: Properties[Key] extends TReadonly<TSchema> ? (Properties[Key] extends TOptional<Properties[Key]> ? never : Key) : never;
3044
3216
  }[keyof Properties]> = Result;
@@ -7655,18 +7827,6 @@ declare const WithValue: (input: string) => [unknown, string] | [];
7655
7827
 
7656
7828
  declare function WithValueMapping(input: unknown): unknown;
7657
7829
 
7658
- declare type WorkBlockCoverage = z.infer<typeof WorkBlockCoverageSchema>;
7659
-
7660
- /**
7661
- * Exact ordered completed executions, addressed by persisted tool-result entry IDs.
7662
- * Provider call IDs can repeat across retries and turns; they are never ownership keys.
7663
- */
7664
- declare const WorkBlockCoverageSchema: z.ZodObject<{
7665
- firstToolResultEntryId: z.ZodString;
7666
- lastToolResultEntryId: z.ZodString;
7667
- toolResultEntryIds: z.ZodArray<z.ZodString>;
7668
- }, z.core.$strict>;
7669
-
7670
7830
  declare interface XAdditionalItems<AdditionalItems extends XSchema = XSchema> {
7671
7831
  additionalItems: AdditionalItems;
7672
7832
  }