@yaklabs-ai/plugin-sdk 0.14.1 → 0.15.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-app.d.ts CHANGED
@@ -1,3 +1,4 @@
1
+ import { pathToFileURL } from 'node:url';
1
2
  import type { StatementSync } from 'node:sqlite';
2
3
  import { z } from 'zod';
3
4
 
@@ -78,6 +79,8 @@ export declare interface AgentToolResult<T = JsonValue_2 | undefined> {
78
79
  * error, but `details` and `structuredContent` are kept for the UI and programmatic callers.
79
80
  */
80
81
  isError?: boolean;
82
+ /** Classification for an `isError` result; the host validates it and stamps identity and attribution. */
83
+ failure?: ToolCallFailure;
81
84
  /**
82
85
  * Hint that the agent should stop after the current tool batch.
83
86
  * Early termination only happens when every finalized tool result in the batch sets this to true.
@@ -296,6 +299,12 @@ declare interface BackgroundTaskAdoptOptions {
296
299
  readonly ownerId?: string;
297
300
  readonly inspect?: BackgroundTaskInspector;
298
301
  readonly meta?: Readonly<Record<string, unknown>>;
302
+ /**
303
+ * The task's owner waits for its result: the work was meant to finish and report back (a build,
304
+ * a test run). Absent or false: nothing waits on it (a dev server, a watcher). The kernel only
305
+ * carries this fact on the task's snapshot; what waiting means is the host's to decide.
306
+ */
307
+ readonly awaitsResult?: boolean;
299
308
  /** Scoped settlement hook for the task created by this adoption only. */
300
309
  readonly onSettled?: (completion: BackgroundTaskCompletion) => void;
301
310
  }
@@ -370,6 +379,8 @@ declare interface BackgroundTaskSnapshot {
370
379
  readonly startedAtMs: number;
371
380
  readonly updatedAtMs: number;
372
381
  readonly meta?: Readonly<Record<string, unknown>>;
382
+ /** The owner waits for this task's result; see `BackgroundTaskAdoptOptions.awaitsResult`. */
383
+ readonly awaitsResult?: boolean;
373
384
  }
374
385
 
375
386
  declare type BackgroundTaskStatus = "queued" | "running" | "completed" | "failed" | "cancelled";
@@ -843,7 +854,7 @@ declare interface DecideChoiceQuestion<L extends string = string> {
843
854
  /** What a question asks: text, or a JSON object the client sends as its JSON text. */
844
855
  declare type DecideInstructions = string | object;
845
856
 
846
- declare type DecideModelId = "jev" | "clef" | "clef-flash";
857
+ declare type DecideModelId = "jev" | "clef" | "clef-flash" | "gpt-6-luna";
847
858
 
848
859
  declare type DecideQuestion = DecideBoolQuestion | DecideChoiceQuestion | DecideScoreQuestion;
849
860
 
@@ -851,10 +862,10 @@ declare type DecideQuestion = DecideBoolQuestion | DecideChoiceQuestion | Decide
851
862
  declare type DecideQuestions = Readonly<Record<string, DecideQuestion>>;
852
863
 
853
864
  declare interface DecideRequest<Q extends DecideQuestions = DecideQuestions> {
854
- /** Defaults to `jev`. */
855
- readonly model?: DecideModelId;
865
+ readonly model: DecideModelId;
856
866
  readonly state: DecideState;
857
867
  readonly questions: Q;
868
+ readonly image?: SystemOneImage;
858
869
  }
859
870
 
860
871
  declare interface DecideScoreAnswer {
@@ -1235,7 +1246,10 @@ declare interface ExtensionAuthContext {
1235
1246
 
1236
1247
  /** Optional extension-facing APIs for background task orchestration. */
1237
1248
  declare interface ExtensionBackgroundTasksApi {
1238
- adopt(taskKind: BackgroundTaskKind, label: string, run: BackgroundTaskRun, options?: BackgroundTaskAdoptOptions): string;
1249
+ adopt(taskKind: BackgroundTaskKind, label: string, run: BackgroundTaskRun, options?: BackgroundTaskAdoptOptions & {
1250
+ readonly awaitsResult?: false;
1251
+ }): string;
1252
+ adopt(taskKind: BackgroundTaskKind, label: string, run: BackgroundTaskRun, options: BackgroundTaskAdoptOptions): string | Promise<string>;
1239
1253
  list(): readonly BackgroundTaskSnapshot[];
1240
1254
  get(taskId: string): BackgroundTaskSnapshot | undefined;
1241
1255
  }
@@ -1836,7 +1850,7 @@ declare type JsonValue_4 = null | boolean | number | string | readonly JsonValue
1836
1850
  * the union and not to this list, so the next kind cannot repeat that bug
1837
1851
  * quietly.
1838
1852
  */
1839
- export declare const KAY_APP_AUTOMATION_CONDITION_KINDS: readonly ["time", "uri-change", "occurrence", "delayed-occurrence"];
1853
+ export declare const KAY_APP_AUTOMATION_CONDITION_KINDS: readonly ["time", "uri-change", "plugin-event", "occurrence", "delayed-occurrence"];
1840
1854
 
1841
1855
  /** Maximum UTF-8 JSON size of one plugin app-data live change. */
1842
1856
  export declare const KAY_APP_DATA_CHANGE_MAX_BYTES: number;
@@ -2093,7 +2107,10 @@ export declare interface KayAppAccountProfileUpdate {
2093
2107
  readonly displayName: string;
2094
2108
  }
2095
2109
 
2096
- /** Owned services use local IDs; omitted scheme searches all admitted schemes. */
2110
+ /**
2111
+ * Service/scheme IDs are local when owned, globally qualified when consumed.
2112
+ * Omitting scheme searches all admitted schemes.
2113
+ */
2097
2114
  export declare interface KayAppAccountRequest {
2098
2115
  readonly serviceId: string;
2099
2116
  readonly schemeId?: string;
@@ -2363,15 +2380,20 @@ export declare interface KayAppAuth {
2363
2380
  /** Resolve a granted credential for a declared purpose. */
2364
2381
  resolve(request: KayAppResolveCredentialRequest): Promise<KayAppResolvedCredential>;
2365
2382
  /**
2366
- * Enumerate an owned service under an explicit list grant. Includes accounts needing repair.
2383
+ * Enumerate an owned or consumed service under an explicit list grant in
2384
+ * permissions.byTarget["kay.app"].auth. Consumption or resolve alone does not allow listing;
2385
+ * shared-identity services also require auth.shared-identity authorization.
2386
+ * Includes accounts needing repair within admitted schemes, without broadening resolve grants.
2367
2387
  * Never resolves, decrypts secret material, refreshes, or calls a provider. Invalid or
2368
2388
  * unauthorized requests reject; an authorized service with no accounts returns an empty list.
2369
2389
  */
2370
2390
  listAccounts(request: KayAppAccountRequest): Promise<readonly KayAppAccountSummary[]>;
2371
2391
  /**
2372
2392
  * Stored availability, not proof that a provider request will authenticate. False for no
2373
- * matching account or only revoked/needs-reauth accounts. Accepts list permission or existing
2374
- * resolve permission within its account bounds. Storage and authorization failures reject.
2393
+ * matching account or only revoked/needs-reauth accounts. Uses explicit list permission for
2394
+ * owned or consumed services when present, otherwise resolve permission within its account
2395
+ * bounds. Never resolves, decrypts secrets, refreshes, or calls a provider.
2396
+ * Storage and authorization failures reject.
2375
2397
  */
2376
2398
  has(request: KayAppAccountRequest): Promise<boolean>;
2377
2399
  }
@@ -2451,7 +2473,7 @@ export declare interface KayAppAutomationBinding {
2451
2473
  readonly scriptLastError?: string;
2452
2474
  }
2453
2475
 
2454
- export declare type KayAppAutomationCondition = Extract<KayAppAutomationConditionInput, {
2476
+ export declare type KayAppAutomationCondition = KayAppAutomationPluginEventCondition | Extract<KayAppAutomationConditionInput, {
2455
2477
  readonly kind: "time";
2456
2478
  }> | KayAppAutomationUriChangeCondition | {
2457
2479
  readonly kind: "occurrence";
@@ -2473,7 +2495,7 @@ export declare type KayAppAutomationCondition = Extract<KayAppAutomationConditio
2473
2495
  readonly guard?: "session-idle";
2474
2496
  };
2475
2497
 
2476
- export declare type KayAppAutomationConditionInput = {
2498
+ export declare type KayAppAutomationConditionInput = KayAppAutomationPluginEventCondition | {
2477
2499
  readonly kind: "time";
2478
2500
  readonly schedule: {
2479
2501
  readonly kind: "every";
@@ -2585,6 +2607,22 @@ export declare interface KayAppAutomationExternalResourceItem {
2585
2607
  export declare type KayAppAutomationFactSource = "run-settled" | "tool-used" | "tool-failed";
2586
2608
 
2587
2609
  export declare type KayAppAutomationMatch = {
2610
+ readonly kind: "plugin-event";
2611
+ readonly event: {
2612
+ readonly id: string;
2613
+ readonly type: string;
2614
+ readonly version: number;
2615
+ readonly uri: string;
2616
+ readonly occurredAt: string;
2617
+ readonly publishedAt: string;
2618
+ readonly source: {
2619
+ readonly layer: "runtime";
2620
+ readonly pluginId: string;
2621
+ readonly poller?: string | undefined;
2622
+ readonly runId?: string | undefined;
2623
+ };
2624
+ };
2625
+ } | {
2588
2626
  readonly kind: "time";
2589
2627
  readonly scheduledAtMs: number;
2590
2628
  } | {
@@ -2626,6 +2664,16 @@ export declare type KayAppAutomationMatch = {
2626
2664
  readonly requestedBy?: "user" | "agent" | undefined;
2627
2665
  };
2628
2666
 
2667
+ /** Match any listed type; filters use strict equality or scalar-list containment. */
2668
+ export declare interface KayAppAutomationPluginEventCondition {
2669
+ readonly kind: "plugin-event";
2670
+ readonly events: readonly string[];
2671
+ readonly where?: readonly {
2672
+ readonly path: string;
2673
+ readonly equals: string | number | boolean;
2674
+ }[];
2675
+ }
2676
+
2629
2677
  /**
2630
2678
  * One URI a run produced: every URI its successful `write` and `edit` calls
2631
2679
  * changed, every URI a tool declared it created or updated, and every row
@@ -3878,11 +3926,11 @@ export declare interface KayAppPluginApi {
3878
3926
  */
3879
3927
  readonly sessionEvents: KayAppSessionEvents;
3880
3928
  /**
3881
- * Grant-gated time-triggered workflow registration. PRESENT ONLY for a plugin holding the
3882
- * `workflows.define` claim in the user's grant ledger — no manifest request and no source-class
3883
- * gate; `undefined` otherwise. Same deny-by-default rule as {@link corpus}: an ungranted plugin
3884
- * cannot even reference the capability, so guard with `if (app.workflows === undefined) return;`
3885
- * rather than assuming it is there.
3929
+ * Grant-gated time-triggered workflow registration. Present for a plugin the host has a workflow
3930
+ * namespace for; `undefined` otherwise. The first `define` asks for the `workflows.define` claim
3931
+ * in the user's grant ledger — no manifest request and no source-class gate — and it is decided
3932
+ * once `activate()` resolves: an ungranted plugin does not start until the user allows it. A
3933
+ * plugin that defines no workflow is never asked.
3886
3934
  */
3887
3935
  readonly workflows?: KayAppWorkflows;
3888
3936
  /**
@@ -3988,12 +4036,7 @@ export declare interface KayAppPluginApi {
3988
4036
  }
3989
4037
 
3990
4038
  export declare interface KayAppPluginEvents {
3991
- publish(localId: string, payload: unknown, options?: {
3992
- readonly subject?: {
3993
- readonly kind: string;
3994
- readonly id?: string;
3995
- };
3996
- }): void;
4039
+ publish(localId: string, input: PluginEventPublishInput): void;
3997
4040
  }
3998
4041
 
3999
4042
  export declare type KayAppProcessingSpeed = "standard" | "fast";
@@ -4126,12 +4169,12 @@ export declare interface KayAppRepos {
4126
4169
 
4127
4170
  /** What the plugin is asking for, and what it intends to do with it. */
4128
4171
  export declare interface KayAppResolveCredentialRequest {
4129
- /** An auth service this plugin's own manifest declares, by its LOCAL id. */
4172
+ /** A granted service: local ID when owned, globally qualified ID when consumed. */
4130
4173
  readonly serviceId: string;
4131
- /** Exact scheme to require; omit to resolve the service's sole connected scheme. */
4174
+ /** Local scheme ID when owned, globally qualified when consumed; omit for the sole connected scheme. */
4132
4175
  readonly schemeId?: string;
4133
4176
  /**
4134
- * One of the `purposes` the declared service lists. The host pins the resolved grant to it, so a
4177
+ * One of the service's `purposes` admitted by the manifest grant. The host pins the grant to it, so a
4135
4178
  * credential taken for `"transcription"` cannot be replayed for anything else.
4136
4179
  */
4137
4180
  readonly purpose: string;
@@ -4140,8 +4183,8 @@ export declare interface KayAppResolveCredentialRequest {
4140
4183
  /**
4141
4184
  * ---
4142
4185
  * responsibility: The plugin-facing credential surface of the `kay.app` target SDK. A daemon-hosted
4143
- * plugin resolves the credential for an auth service **it declared in its own manifest**, so a
4144
- * cloud adapter's secret is read where the work happens and never crosses a process boundary.
4186
+ * plugin lists account metadata or resolves credentials for an owned or consumed auth service
4187
+ * under explicit grants. Credential material is read where the work happens.
4145
4188
  * owns:
4146
4189
  * - {@link KayAppAuth}, {@link KayAppResolvedCredential}.
4147
4190
  * does_not_own:
@@ -4152,8 +4195,8 @@ export declare interface KayAppResolveCredentialRequest {
4152
4195
  * ## Deny-by-default
4153
4196
  *
4154
4197
  * `KayAppPluginApi.auth` is **present only for plugins the host grants** (`auth.operations`
4155
- * containing `"list"` or `"resolve"` in `permissions.byTarget["kay.app"]`, against a service the manifest
4156
- * declares) and `undefined` otherwise — an ungranted plugin cannot even reference the capability.
4198
+ * containing `"list"` or `"resolve"` in `permissions.byTarget["kay.app"]`, against an owned or consumed
4199
+ * service) and `undefined` otherwise — an ungranted plugin cannot even reference the capability.
4157
4200
  * This mirrors `KayAppPluginApi.corpus`, and it is the rule for every capability behind a grant:
4158
4201
  * never hand a plugin an object whose grant is decorative.
4159
4202
  *
@@ -5967,6 +6010,8 @@ export declare interface KayAppWhiteboardTypes {
5967
6010
  * different process. Anything you need later belongs in a step's return value.
5968
6011
  */
5969
6012
  export declare interface KayAppWorkflowContext {
6013
+ /** State from the last successful run; undefined until a run saves it. */
6014
+ readonly state: JsonValue | undefined;
5970
6015
  readonly automationId: string;
5971
6016
  readonly runId: string;
5972
6017
  readonly match: Extract<KayAppAutomationMatch, {
@@ -6039,6 +6084,8 @@ export declare interface KayAppWorkflowDefinition {
6039
6084
  readonly kind: "time";
6040
6085
  }>;
6041
6086
  readonly run: (context: KayAppWorkflowContext) => Promise<{
6087
+ /** Replacement JSON state, at most 64 KiB; omission keeps the previous value. */
6088
+ readonly state?: JsonValue | undefined;
6042
6089
  readonly summary: KayAppRunSummary;
6043
6090
  readonly produced?: KayAppRunProduced;
6044
6091
  readonly effect?: KayAppRunEffect;
@@ -7149,6 +7196,8 @@ declare function Partial_2<Type extends TSchema>(type: Type, options?: TSchemaOp
7149
7196
  /** Creates a deferred Partial action. */
7150
7197
  declare function PartialDeferred<Type extends TSchema>(type: Type, options?: TSchemaOptions): TPartialDeferred<Type>;
7151
7198
 
7199
+ export { pathToFileURL }
7200
+
7152
7201
  declare const Pattern: (input: string) => [unknown, string] | [];
7153
7202
 
7154
7203
  declare const PatternBase: (input: string) => [unknown, string] | [];
@@ -7309,6 +7358,42 @@ export declare const PluginAgentDefinitionPermissionRule: z.ZodObject<{
7309
7358
 
7310
7359
  export declare type PluginAgentDefinitionPermissionRule = z.infer<typeof PluginAgentDefinitionPermissionRule>;
7311
7360
 
7361
+ export declare const PluginEventEnvelope: z.ZodObject<{
7362
+ id: z.ZodString;
7363
+ localId: z.ZodString;
7364
+ type: z.ZodString;
7365
+ version: z.ZodNumber;
7366
+ uri: z.ZodString;
7367
+ related: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodString, z.ZodArray<z.ZodString>]>>>;
7368
+ key: z.ZodOptional<z.ZodString>;
7369
+ occurredAt: z.ZodISODateTime;
7370
+ publishedAt: z.ZodISODateTime;
7371
+ source: z.ZodObject<{
7372
+ poller: z.ZodOptional<z.ZodString>;
7373
+ runId: z.ZodOptional<z.ZodString>;
7374
+ layer: z.ZodLiteral<"runtime">;
7375
+ pluginId: z.ZodString;
7376
+ sessionId: z.ZodOptional<z.ZodString>;
7377
+ }, z.core.$strict>;
7378
+ payload: z.ZodOptional<z.ZodType<JsonValue, unknown, z.core.$ZodTypeInternals<JsonValue, unknown>>>;
7379
+ }, z.core.$strict>;
7380
+
7381
+ export declare type PluginEventEnvelope = z.infer<typeof PluginEventEnvelope>;
7382
+
7383
+ export declare const PluginEventPublishInput: z.ZodObject<{
7384
+ uri: z.ZodString;
7385
+ related: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodString, z.ZodArray<z.ZodString>]>>>;
7386
+ key: z.ZodOptional<z.ZodString>;
7387
+ occurredAt: z.ZodOptional<z.ZodISODateTime>;
7388
+ source: z.ZodOptional<z.ZodObject<{
7389
+ poller: z.ZodOptional<z.ZodString>;
7390
+ runId: z.ZodOptional<z.ZodString>;
7391
+ }, z.core.$strict>>;
7392
+ payload: z.ZodOptional<z.ZodType<JsonValue, unknown, z.core.$ZodTypeInternals<JsonValue, unknown>>>;
7393
+ }, z.core.$strict>;
7394
+
7395
+ export declare type PluginEventPublishInput = z.infer<typeof PluginEventPublishInput>;
7396
+
7312
7397
  declare const Properties: (input: string) => [unknown, string] | [];
7313
7398
 
7314
7399
  declare function PropertiesMapping(input: [unknown, unknown, unknown]): unknown;
@@ -8201,6 +8286,7 @@ declare const SessionCreator: z.ZodDiscriminatedUnion<[z.ZodObject<{
8201
8286
  cron: "cron";
8202
8287
  occurrence: "occurrence";
8203
8288
  "uri-change": "uri-change";
8289
+ "plugin-event": "plugin-event";
8204
8290
  manual: "manual";
8205
8291
  }>;
8206
8292
  }, z.core.$strict>, z.ZodObject<{
@@ -8292,6 +8378,7 @@ declare const SessionProvenanceRecord: z.ZodObject<{
8292
8378
  cron: "cron";
8293
8379
  occurrence: "occurrence";
8294
8380
  "uri-change": "uri-change";
8381
+ "plugin-event": "plugin-event";
8295
8382
  manual: "manual";
8296
8383
  }>;
8297
8384
  }, z.core.$strict>, z.ZodObject<{
@@ -8605,7 +8692,7 @@ declare interface SystemOneClient {
8605
8692
  decide<const Q extends DecideQuestions>(request: DecideRequest<Q>, options?: SystemOneCallOptions): Promise<Decision<Q>>;
8606
8693
  extract<const F extends ExtractFields>(request: ExtractRequest<F>, options?: SystemOneCallOptions): Promise<Extraction<F>>;
8607
8694
  /** Whether some provider in the current order can serve `(kind, model)`. Never rejects. */
8608
- availability(kind: SystemOneKind, model?: SystemOneModelId): Promise<Availability>;
8695
+ availability(kind: SystemOneKind, model: SystemOneModelId): Promise<Availability>;
8609
8696
  }
8610
8697
 
8611
8698
  /**
@@ -8640,6 +8727,12 @@ declare type SystemOneFailureCause = {
8640
8727
  readonly kind: "invalid-answer";
8641
8728
  };
8642
8729
 
8730
+ /** One PNG attachment. `data` is padded base64, without a data-URL prefix. */
8731
+ declare interface SystemOneImage {
8732
+ readonly mimeType: "image/png";
8733
+ readonly data: string;
8734
+ }
8735
+
8643
8736
  /**
8644
8737
  * ---
8645
8738
  * responsibility: The data shapes of the System One surface: models, the decide and extract
@@ -10833,6 +10926,14 @@ declare interface Tool<TParameters extends TSchema = TSchema> {
10833
10926
  constrainedSampling?: false | ConstrainedSamplingConfig;
10834
10927
  }
10835
10928
 
10929
+ /**
10930
+ * The closed vocabulary of tool call failure codes. The engine and the tools
10931
+ * mint only these; a returned failure with a code outside it is not a
10932
+ * classification (the engine records the rejection on an unexplained failure),
10933
+ * and a stored record with one reads as none.
10934
+ */
10935
+ declare const TOOL_CALL_FAILURE_CODES: readonly ["tool.invalid_input", "tool.blocked", "tool.cancelled", "tool.timeout", "tool.not_found", "tool.unavailable", "tool.execution_failed", "provider.http", "provider.api", "provider.transport", "uri.not_found", "uri.unsupported_operation", "uri.not_connected", "uri.auth_unavailable", "permission.denied", "edit.empty_edits", "edit.text_not_found", "edit.text_not_unique", "edit.empty_old_text", "edit.overlapping_edits", "edit.no_change"];
10936
+
10836
10937
  /**
10837
10938
  * ---
10838
10939
  * responsibility: The declarative permission classification a tool carries on its definition
@@ -10877,6 +10978,56 @@ declare interface ToolCall {
10877
10978
  argumentsError?: string;
10878
10979
  }
10879
10980
 
10981
+ /**
10982
+ * The lane's classification of why one tool invocation failed: a searchable
10983
+ * machine code and the cause the tool or engine classified at execution.
10984
+ */
10985
+ declare interface ToolCallFailure extends ToolCallFailureCause {
10986
+ readonly code: ToolCallFailureCode;
10987
+ }
10988
+
10989
+ declare type ToolCallFailureCause = z.infer<typeof toolCallFailureCauseSchema>;
10990
+
10991
+ declare const toolCallFailureCauseSchema: z.ZodObject<{
10992
+ category: z.ZodEnum<{
10993
+ cancelled: "cancelled";
10994
+ timeout: "timeout";
10995
+ unknown: "unknown";
10996
+ provider: "provider";
10997
+ "invalid-input": "invalid-input";
10998
+ "not-connected": "not-connected";
10999
+ "unsupported-operation": "unsupported-operation";
11000
+ "not-found": "not-found";
11001
+ permission: "permission";
11002
+ unavailable: "unavailable";
11003
+ }>;
11004
+ retryable: z.ZodBoolean;
11005
+ action: z.ZodEnum<{
11006
+ unknown: "unknown";
11007
+ none: "none";
11008
+ retry: "retry";
11009
+ "correct-input": "correct-input";
11010
+ connect: "connect";
11011
+ }>;
11012
+ details: z.ZodOptional<z.ZodObject<{
11013
+ moduleId: z.ZodOptional<z.ZodString>;
11014
+ toolOwnerId: z.ZodOptional<z.ZodString>;
11015
+ operation: z.ZodOptional<z.ZodString>;
11016
+ uri: z.ZodOptional<z.ZodString>;
11017
+ path: z.ZodOptional<z.ZodString>;
11018
+ validationField: z.ZodOptional<z.ZodString>;
11019
+ errorName: z.ZodOptional<z.ZodString>;
11020
+ errorCode: z.ZodOptional<z.ZodString>;
11021
+ providerCode: z.ZodOptional<z.ZodString>;
11022
+ status: z.ZodOptional<z.ZodNumber>;
11023
+ editIndex: z.ZodOptional<z.ZodNumber>;
11024
+ occurrences: z.ZodOptional<z.ZodNumber>;
11025
+ retryAfterMs: z.ZodOptional<z.ZodNumber>;
11026
+ }, z.core.$strict>>;
11027
+ }, z.core.$strict>;
11028
+
11029
+ declare type ToolCallFailureCode = (typeof TOOL_CALL_FAILURE_CODES)[number];
11030
+
10880
11031
  /** A call to judge with {@link ToolContext.checkToolCallPermission}. */
10881
11032
  declare interface ToolCallPermissionCheck {
10882
11033
  readonly toolName: string;
@@ -11078,6 +11229,14 @@ export declare type ToolParametersWire = unknown;
11078
11229
  * declares {@link ToolPermissionHint.quiet} and keeps its honest `kind`.
11079
11230
  */
11080
11231
  export declare interface ToolPermissionHint {
11232
+ /**
11233
+ * Names this exact call for the approval card, from its validated input: a title and optional
11234
+ * labelled facts. Render-only: never matched against a rule, never one-tap approval grounds.
11235
+ * The tool says what its input claims, so the gate shows it as the tool's claim, not as the
11236
+ * daemon's attestation. The host admits only display-safe text; a throw, a blank title or an
11237
+ * unsafe string costs the description and the call is asked about as before.
11238
+ */
11239
+ readonly describePreview?: (input: Record<string, unknown>) => ToolPreviewDescription | undefined;
11081
11240
  readonly kind?: ToolActionKind;
11082
11241
  readonly scheme?: string;
11083
11242
  readonly ruleKey?: string;
@@ -11204,6 +11363,16 @@ export declare interface ToolPermissionHint {
11204
11363
  readonly defaultPermission?: "allow" | "ask" | "never";
11205
11364
  }
11206
11365
 
11366
+ /** What {@link ToolPermissionHint.describePreview} answers. */
11367
+ declare interface ToolPreviewDescription {
11368
+ readonly title: string;
11369
+ readonly description?: string;
11370
+ readonly fields?: readonly {
11371
+ readonly label: string;
11372
+ readonly value: string;
11373
+ }[];
11374
+ }
11375
+
11207
11376
  declare interface ToolReference {
11208
11377
  name: string;
11209
11378
  }
package/dist/kay-app.js CHANGED
@@ -163,6 +163,9 @@ function invalidObservation(input) {
163
163
  };
164
164
  }
165
165
 
166
+ // packages/plugin-sdk/dist/kay-app/index.js
167
+ import { pathToFileURL } from "node:url";
168
+
166
169
  // packages/herd-uri/dist/errors.js
167
170
  var UriError = class extends Error {
168
171
  };
@@ -441,6 +444,7 @@ function isRetryable(result) {
441
444
  var KAY_APP_AUTOMATION_CONDITION_KINDS = [
442
445
  "time",
443
446
  "uri-change",
447
+ "plugin-event",
444
448
  "occurrence",
445
449
  "delayed-occurrence"
446
450
  ];
@@ -537,6 +541,7 @@ export {
537
541
  invalidObservation,
538
542
  isRetryable,
539
543
  parseLineSelector,
544
+ pathToFileURL,
540
545
  payload,
541
546
  transcriptMessageText,
542
547
  transcriptMessageTexts,
@@ -42,7 +42,7 @@ export declare interface DecideChoiceQuestion<L extends string = string> {
42
42
  /** What a question asks: text, or a JSON object the client sends as its JSON text. */
43
43
  export declare type DecideInstructions = string | object;
44
44
 
45
- export declare type DecideModelId = "jev" | "clef" | "clef-flash";
45
+ export declare type DecideModelId = "jev" | "clef" | "clef-flash" | "gpt-6-luna";
46
46
 
47
47
  export declare type DecideQuestion = DecideBoolQuestion | DecideChoiceQuestion | DecideScoreQuestion;
48
48
 
@@ -50,10 +50,10 @@ export declare type DecideQuestion = DecideBoolQuestion | DecideChoiceQuestion |
50
50
  export declare type DecideQuestions = Readonly<Record<string, DecideQuestion>>;
51
51
 
52
52
  export declare interface DecideRequest<Q extends DecideQuestions = DecideQuestions> {
53
- /** Defaults to `jev`. */
54
- readonly model?: DecideModelId;
53
+ readonly model: DecideModelId;
55
54
  readonly state: DecideState;
56
55
  readonly questions: Q;
56
+ readonly image?: SystemOneImage;
57
57
  }
58
58
 
59
59
  export declare interface DecideScoreAnswer {
@@ -243,7 +243,7 @@ export declare interface SystemOneClient {
243
243
  decide<const Q extends DecideQuestions>(request: DecideRequest<Q>, options?: SystemOneCallOptions): Promise<Decision<Q>>;
244
244
  extract<const F extends ExtractFields>(request: ExtractRequest<F>, options?: SystemOneCallOptions): Promise<Extraction<F>>;
245
245
  /** Whether some provider in the current order can serve `(kind, model)`. Never rejects. */
246
- availability(kind: SystemOneKind, model?: SystemOneModelId): Promise<SystemOneAvailability>;
246
+ availability(kind: SystemOneKind, model: SystemOneModelId): Promise<SystemOneAvailability>;
247
247
  }
248
248
 
249
249
  /**
@@ -297,6 +297,12 @@ export declare type SystemOneFailureCause = {
297
297
  readonly kind: "invalid-answer";
298
298
  };
299
299
 
300
+ /** One PNG attachment. `data` is padded base64, without a data-URL prefix. */
301
+ export declare interface SystemOneImage {
302
+ readonly mimeType: "image/png";
303
+ readonly data: string;
304
+ }
305
+
300
306
  /**
301
307
  * ---
302
308
  * responsibility: The data shapes of the System One surface: models, the decide and extract
@@ -23,20 +23,6 @@ function isSystemOneError(error) {
23
23
  return error instanceof SystemOneError;
24
24
  }
25
25
 
26
- // packages/system-one/dist/models.js
27
- var DEFAULT_DECIDE_MODEL = "jev";
28
- var SYSTEM_ONE_LIMITS = {
29
- /** The serialized request body, in bytes. */
30
- maxBodyBytes: 64 * 1024,
31
- maxQuestions: 64,
32
- maxFields: 32,
33
- minChoiceOptions: 2,
34
- maxChoiceOptions: 255,
35
- minScoreLevels: 2,
36
- maxScoreLevels: 10,
37
- maxForecastHorizon: 64
38
- };
39
-
40
26
  // packages/system-one/dist/unavailable.js
41
27
  var NOT_SERVED = {
42
28
  available: false,
@@ -48,7 +34,7 @@ function createUnavailableSystemOneClient() {
48
34
  decide(request) {
49
35
  return Promise.reject(new SystemOneError({
50
36
  kind: "decide",
51
- model: request.model ?? DEFAULT_DECIDE_MODEL,
37
+ model: request.model,
52
38
  cause: { kind: "not-served" }
53
39
  }));
54
40
  },
@@ -62,6 +48,22 @@ function createUnavailableSystemOneClient() {
62
48
  availability: () => Promise.resolve(NOT_SERVED)
63
49
  };
64
50
  }
51
+
52
+ // packages/system-one/dist/models.js
53
+ var SYSTEM_ONE_LIMITS = {
54
+ /** The serialized state and questions, in bytes; images have a separate budget. */
55
+ maxBodyBytes: 64 * 1024,
56
+ maxImageBytes: 4 * 1024 * 1024,
57
+ maxImagePixels: 16e6,
58
+ maxImageBodyBytes: 6 * 1024 * 1024,
59
+ maxQuestions: 64,
60
+ maxFields: 32,
61
+ minChoiceOptions: 2,
62
+ maxChoiceOptions: 255,
63
+ minScoreLevels: 2,
64
+ maxScoreLevels: 10,
65
+ maxForecastHorizon: 64
66
+ };
65
67
  export {
66
68
  SystemOneError,
67
69
  createUnavailableSystemOneClient,
@@ -1,5 +1,7 @@
1
1
  import { z } from 'zod';
2
2
 
3
+ export declare const ATTACHMENTS_CUSTOM_TYPE = "attachments";
4
+
3
5
  /**
4
6
  * The ids on a session's active branch: the leaf chain walked parent-ward from
5
7
  * the tip, which a trailing `leaf` marker moves. Empty for an empty log.
@@ -43,6 +45,36 @@ export declare function matchesWorkBlock(coverage: WorkBlockCoverage, toolResult
43
45
  */
44
46
  export declare const NON_ACTIVITY_TOOL_NAMES: readonly string[];
45
47
 
48
+ /**
49
+ * What a run did to a URI. The words match the automation run wire's artifact actions. When one
50
+ * run both creates and updates a URI, the reader reports `created`.
51
+ */
52
+ declare type ProducedResourceAction = "created" | "updated";
53
+
54
+ /** One URI a tool call created or updated as a side effect. */
55
+ declare interface ProducedResourceDeclaration {
56
+ /** A `scheme://…` URI or an absolute local file path, compared as an exact string. */
57
+ readonly uri: string;
58
+ readonly action: ProducedResourceAction;
59
+ }
60
+
61
+ /**
62
+ * One tool result's declarations. `absent` covers every result that makes no claim, including a
63
+ * non-object `details` and an empty list. `malformed` means a claim was made that cannot be
64
+ * trusted; the reader reports a gap for it instead of keeping the parts that look valid.
65
+ */
66
+ declare type ProducedResourceDeclarationsRead = {
67
+ readonly kind: "absent";
68
+ } | {
69
+ readonly kind: "malformed";
70
+ } | {
71
+ readonly kind: "declared";
72
+ readonly resources: readonly ProducedResourceDeclaration[];
73
+ };
74
+
75
+ /** Read the declarations that one persisted tool result's `details` carries. */
76
+ export declare function readProducedResourceDeclarations(details: unknown): ProducedResourceDeclarationsRead;
77
+
46
78
  /**
47
79
  * The daemon's own run-start record. A run's entries begin here, before the
48
80
  * user message that opened it.
@@ -94,7 +94,47 @@ var NON_ACTIVITY_TOOL_NAMES = [
94
94
  ];
95
95
  var WORK_HEADLINE_MIN_CHARS = 12;
96
96
  var WORK_HEADLINE_MAX_CHARS = 90;
97
+
98
+ // packages/herd-transcript/dist/context-messages.js
99
+ var ATTACHMENTS_CUSTOM_TYPE = "attachments";
100
+
101
+ // packages/herd-uri/dist/produced-resources.js
102
+ var PRODUCED_RESOURCES_DETAILS_KEY = "producedResources";
103
+ var ABSENT = { kind: "absent" };
104
+ var MALFORMED = { kind: "malformed" };
105
+ var SCHEME_URI = /^[a-z][a-z0-9+.-]*:\/\/./;
106
+ var WINDOWS_ABSOLUTE_PATH = /^[A-Za-z]:[\\/]./;
107
+ function isProducedResourceUri(value) {
108
+ if (typeof value !== "string" || value.trim() !== value)
109
+ return false;
110
+ return SCHEME_URI.test(value) || value.startsWith("/") && value.length > 1 || WINDOWS_ABSOLUTE_PATH.test(value);
111
+ }
112
+ function isProducedResourceDeclaration(value) {
113
+ if (typeof value !== "object" || value === null || Array.isArray(value)) {
114
+ return false;
115
+ }
116
+ const keys = Object.keys(value);
117
+ if (keys.length !== 2 || !keys.includes("uri") || !keys.includes("action")) {
118
+ return false;
119
+ }
120
+ const record = value;
121
+ return isProducedResourceUri(record.uri) && (record.action === "created" || record.action === "updated");
122
+ }
123
+ function readProducedResourceDeclarations(details) {
124
+ if (typeof details !== "object" || details === null || Array.isArray(details) || !Object.hasOwn(details, PRODUCED_RESOURCES_DETAILS_KEY)) {
125
+ return ABSENT;
126
+ }
127
+ const claimed = details[PRODUCED_RESOURCES_DETAILS_KEY];
128
+ if (!Array.isArray(claimed))
129
+ return MALFORMED;
130
+ if (claimed.length === 0)
131
+ return ABSENT;
132
+ if (!claimed.every(isProducedResourceDeclaration))
133
+ return MALFORMED;
134
+ return { kind: "declared", resources: claimed };
135
+ }
97
136
  export {
137
+ ATTACHMENTS_CUSTOM_TYPE,
98
138
  NON_ACTIVITY_TOOL_NAMES,
99
139
  RUN_STARTED_CUSTOM_TYPE,
100
140
  RUN_TERMINAL_CUSTOM_TYPE,
@@ -105,6 +145,7 @@ export {
105
145
  branchEntryIds,
106
146
  customEntriesFromEntries,
107
147
  matchesWorkBlock,
148
+ readProducedResourceDeclarations,
108
149
  turnSegments,
109
150
  workBlockCoverage,
110
151
  workBlockKey