@yaklabs-ai/plugin-sdk 0.14.1 → 0.15.0

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.
@@ -128,6 +128,8 @@ export declare interface AgentToolResult<T = JsonValue_2 | undefined> {
128
128
  * error, but `details` and `structuredContent` are kept for the UI and programmatic callers.
129
129
  */
130
130
  isError?: boolean;
131
+ /** Classification for an `isError` result; the host validates it and stamps identity and attribution. */
132
+ failure?: ToolCallFailure;
131
133
  /**
132
134
  * Hint that the agent should stop after the current tool batch.
133
135
  * Early termination only happens when every finalized tool result in the batch sets this to true.
@@ -305,6 +307,12 @@ declare interface BackgroundTaskAdoptOptions {
305
307
  readonly ownerId?: string;
306
308
  readonly inspect?: BackgroundTaskInspector;
307
309
  readonly meta?: Readonly<Record<string, unknown>>;
310
+ /**
311
+ * The task's owner waits for its result: the work was meant to finish and report back (a build,
312
+ * a test run). Absent or false: nothing waits on it (a dev server, a watcher). The kernel only
313
+ * carries this fact on the task's snapshot; what waiting means is the host's to decide.
314
+ */
315
+ readonly awaitsResult?: boolean;
308
316
  /** Scoped settlement hook for the task created by this adoption only. */
309
317
  readonly onSettled?: (completion: BackgroundTaskCompletion) => void;
310
318
  }
@@ -354,6 +362,8 @@ declare interface BackgroundTaskSnapshot {
354
362
  readonly startedAtMs: number;
355
363
  readonly updatedAtMs: number;
356
364
  readonly meta?: Readonly<Record<string, unknown>>;
365
+ /** The owner waits for this task's result; see `BackgroundTaskAdoptOptions.awaitsResult`. */
366
+ readonly awaitsResult?: boolean;
357
367
  }
358
368
 
359
369
  declare type BackgroundTaskStatus = "queued" | "running" | "completed" | "failed" | "cancelled";
@@ -768,7 +778,7 @@ declare interface DecideChoiceQuestion<L extends string = string> {
768
778
  /** What a question asks: text, or a JSON object the client sends as its JSON text. */
769
779
  declare type DecideInstructions = string | object;
770
780
 
771
- declare type DecideModelId = "jev" | "clef" | "clef-flash";
781
+ declare type DecideModelId = "jev" | "clef" | "clef-flash" | "gpt-6-luna";
772
782
 
773
783
  declare type DecideQuestion = DecideBoolQuestion | DecideChoiceQuestion | DecideScoreQuestion;
774
784
 
@@ -776,10 +786,10 @@ declare type DecideQuestion = DecideBoolQuestion | DecideChoiceQuestion | Decide
776
786
  declare type DecideQuestions = Readonly<Record<string, DecideQuestion>>;
777
787
 
778
788
  declare interface DecideRequest<Q extends DecideQuestions = DecideQuestions> {
779
- /** Defaults to `jev`. */
780
- readonly model?: DecideModelId;
789
+ readonly model: DecideModelId;
781
790
  readonly state: DecideState;
782
791
  readonly questions: Q;
792
+ readonly image?: SystemOneImage;
783
793
  }
784
794
 
785
795
  declare interface DecideScoreAnswer {
@@ -1179,7 +1189,10 @@ export declare interface ExtensionAuthContext {
1179
1189
 
1180
1190
  /** Optional extension-facing APIs for background task orchestration. */
1181
1191
  declare interface ExtensionBackgroundTasksApi {
1182
- adopt(taskKind: BackgroundTaskKind, label: string, run: BackgroundTaskRun, options?: BackgroundTaskAdoptOptions): string;
1192
+ adopt(taskKind: BackgroundTaskKind, label: string, run: BackgroundTaskRun, options?: BackgroundTaskAdoptOptions & {
1193
+ readonly awaitsResult?: false;
1194
+ }): string;
1195
+ adopt(taskKind: BackgroundTaskKind, label: string, run: BackgroundTaskRun, options: BackgroundTaskAdoptOptions): string | Promise<string>;
1183
1196
  list(): readonly BackgroundTaskSnapshot[];
1184
1197
  get(taskId: string): BackgroundTaskSnapshot | undefined;
1185
1198
  }
@@ -2022,8 +2035,8 @@ export declare class KayAgentCapabilityError extends Error {
2022
2035
  */
2023
2036
  export declare interface KayAgentEvents {
2024
2037
  /**
2025
- * Publish one event the plugin declares in its `kay.app` `eventDefinitions`, with a payload that
2026
- * matches that definition's `payloadSchema`.
2038
+ * Publish one event the plugin declares in its `kay.app` `eventDefinitions`, with its resource URI and optional
2039
+ * payload matching that definition's `payloadSchema` when declared.
2027
2040
  *
2028
2041
  * The host stamps the publisher (this plugin) and the session this activation belongs to; the
2029
2042
  * plugin names neither. Fire-and-forget: it returns nothing and never throws. A publish the host
@@ -2031,7 +2044,7 @@ export declare interface KayAgentEvents {
2031
2044
  * is reported to the host's diagnostics and dropped, so the work that raised the event never
2032
2045
  * fails because the event did not go out.
2033
2046
  */
2034
- publish(localId: string, payload: unknown): void;
2047
+ publish(localId: string, input: PluginEventPublishInput): void;
2035
2048
  }
2036
2049
 
2037
2050
  /** This plugin's folder in the session family's shared Whiteboard. */
@@ -2856,16 +2869,16 @@ declare const KayPluginManifestV1: z.ZodObject<{
2856
2869
  responseSchema: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodType<JsonValue_3, unknown, z.core.$ZodTypeInternals<JsonValue_3, unknown>>>>;
2857
2870
  }, z.core.$strict>>>;
2858
2871
  uriModules: z.ZodOptional<z.ZodArray<z.ZodObject<{
2872
+ localId: z.ZodString;
2859
2873
  displayName: z.ZodOptional<z.ZodString>;
2860
2874
  schemes: z.ZodArray<z.ZodString>;
2861
- localId: z.ZodString;
2862
2875
  }, z.core.$strict>>>;
2863
2876
  dataSources: z.ZodOptional<z.ZodArray<z.ZodObject<{
2864
2877
  localId: z.ZodString;
2865
2878
  scope: z.ZodEnum<{
2866
2879
  session: "session";
2867
- account: "account";
2868
2880
  runtime: "runtime";
2881
+ account: "account";
2869
2882
  }>;
2870
2883
  snapshot: z.ZodObject<{
2871
2884
  version: z.ZodNumber;
@@ -2915,7 +2928,9 @@ declare const KayPluginManifestV1: z.ZodObject<{
2915
2928
  displayName: z.ZodOptional<z.ZodString>;
2916
2929
  description: z.ZodOptional<z.ZodString>;
2917
2930
  version: z.ZodDefault<z.ZodNumber>;
2918
- payloadSchema: z.ZodRecord<z.ZodString, z.ZodType<JsonValue_3, unknown, z.core.$ZodTypeInternals<JsonValue_3, unknown>>>;
2931
+ uriScheme: z.ZodString;
2932
+ relatedKeys: z.ZodOptional<z.ZodReadonly<z.ZodArray<z.ZodString>>>;
2933
+ payloadSchema: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodType<JsonValue_3, unknown, z.core.$ZodTypeInternals<JsonValue_3, unknown>>>>;
2919
2934
  }, z.core.$strict>>>;
2920
2935
  notificationRules: z.ZodOptional<z.ZodArray<z.ZodObject<{
2921
2936
  localId: z.ZodString;
@@ -2954,6 +2969,7 @@ declare const KayPluginManifestV1: z.ZodObject<{
2954
2969
  url: z.ZodString;
2955
2970
  auth: z.ZodOptional<z.ZodEnum<{
2956
2971
  oauth: "oauth";
2972
+ "api-key": "api-key";
2957
2973
  none: "none";
2958
2974
  }>>;
2959
2975
  authService: z.ZodOptional<z.ZodString>;
@@ -3060,6 +3076,8 @@ declare const KayPluginManifestV1: z.ZodObject<{
3060
3076
  "skills.read": "skills.read";
3061
3077
  "automations.run": "automations.run";
3062
3078
  "navigation.open-session": "navigation.open-session";
3079
+ "artifacts.read": "artifacts.read";
3080
+ "artifacts.preview": "artifacts.preview";
3063
3081
  "cost.read": "cost.read";
3064
3082
  "billing.read": "billing.read";
3065
3083
  "context.read": "context.read";
@@ -3072,6 +3090,16 @@ declare const KayPluginManifestV1: z.ZodObject<{
3072
3090
  "workspace.arrange": "workspace.arrange";
3073
3091
  }>>>;
3074
3092
  }, z.core.$strict>>;
3093
+ activityRail: z.ZodOptional<z.ZodObject<{
3094
+ section: z.ZodOptional<z.ZodEnum<{
3095
+ primary: "primary";
3096
+ plugins: "plugins";
3097
+ }>>;
3098
+ order: z.ZodOptional<z.ZodNumber>;
3099
+ icon: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
3100
+ svg: z.ZodString;
3101
+ }, z.core.$strict>]>>;
3102
+ }, z.core.$strict>>;
3075
3103
  }, z.core.$strict>>>;
3076
3104
  themes: z.ZodOptional<z.ZodArray<z.ZodObject<{
3077
3105
  localId: z.ZodString;
@@ -5174,6 +5202,42 @@ export declare interface PluginDelegatedServiceEntry {
5174
5202
  readonly scheme: PluginDelegatedScheme;
5175
5203
  }
5176
5204
 
5205
+ export declare const PluginEventEnvelope: z.ZodObject<{
5206
+ id: z.ZodString;
5207
+ localId: z.ZodString;
5208
+ type: z.ZodString;
5209
+ version: z.ZodNumber;
5210
+ uri: z.ZodString;
5211
+ related: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodString, z.ZodArray<z.ZodString>]>>>;
5212
+ key: z.ZodOptional<z.ZodString>;
5213
+ occurredAt: z.ZodISODateTime;
5214
+ publishedAt: z.ZodISODateTime;
5215
+ source: z.ZodObject<{
5216
+ poller: z.ZodOptional<z.ZodString>;
5217
+ runId: z.ZodOptional<z.ZodString>;
5218
+ layer: z.ZodLiteral<"runtime">;
5219
+ pluginId: z.ZodString;
5220
+ sessionId: z.ZodOptional<z.ZodString>;
5221
+ }, z.core.$strict>;
5222
+ payload: z.ZodOptional<z.ZodType<JsonValue_3, unknown, z.core.$ZodTypeInternals<JsonValue_3, unknown>>>;
5223
+ }, z.core.$strict>;
5224
+
5225
+ export declare type PluginEventEnvelope = z.infer<typeof PluginEventEnvelope>;
5226
+
5227
+ export declare const PluginEventPublishInput: z.ZodObject<{
5228
+ uri: z.ZodString;
5229
+ related: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodString, z.ZodArray<z.ZodString>]>>>;
5230
+ key: z.ZodOptional<z.ZodString>;
5231
+ occurredAt: z.ZodOptional<z.ZodISODateTime>;
5232
+ source: z.ZodOptional<z.ZodObject<{
5233
+ poller: z.ZodOptional<z.ZodString>;
5234
+ runId: z.ZodOptional<z.ZodString>;
5235
+ }, z.core.$strict>>;
5236
+ payload: z.ZodOptional<z.ZodType<JsonValue_3, unknown, z.core.$ZodTypeInternals<JsonValue_3, unknown>>>;
5237
+ }, z.core.$strict>;
5238
+
5239
+ export declare type PluginEventPublishInput = z.infer<typeof PluginEventPublishInput>;
5240
+
5177
5241
  /**
5178
5242
  * An external-CLI readiness scheme the plugin declares: a non-injectable marker for a
5179
5243
  * host-probed local binary (e.g. `osascript`, `gh`). Connecting runs `binary probeArgs`
@@ -6388,7 +6452,7 @@ declare interface SystemOneClient {
6388
6452
  decide<const Q extends DecideQuestions>(request: DecideRequest<Q>, options?: SystemOneCallOptions): Promise<Decision<Q>>;
6389
6453
  extract<const F extends ExtractFields>(request: ExtractRequest<F>, options?: SystemOneCallOptions): Promise<Extraction<F>>;
6390
6454
  /** Whether some provider in the current order can serve `(kind, model)`. Never rejects. */
6391
- availability(kind: SystemOneKind, model?: SystemOneModelId): Promise<Availability>;
6455
+ availability(kind: SystemOneKind, model: SystemOneModelId): Promise<Availability>;
6392
6456
  }
6393
6457
 
6394
6458
  /**
@@ -6423,6 +6487,12 @@ declare type SystemOneFailureCause = {
6423
6487
  readonly kind: "invalid-answer";
6424
6488
  };
6425
6489
 
6490
+ /** One PNG attachment. `data` is padded base64, without a data-URL prefix. */
6491
+ declare interface SystemOneImage {
6492
+ readonly mimeType: "image/png";
6493
+ readonly data: string;
6494
+ }
6495
+
6426
6496
  /**
6427
6497
  * ---
6428
6498
  * responsibility: The data shapes of the System One surface: models, the decide and extract
@@ -8614,6 +8684,14 @@ declare type TOmitDeferred<Type extends TSchema, Indexer extends TSchema> = (TDe
8614
8684
 
8615
8685
  declare type TOmitInstantiate<Context extends TProperties, State extends TState, Type extends TSchema, Indexer extends TSchema, InstantiatedType extends TSchema = TInstantiateType<Context, State, Type>, InstantiatedIndexer extends TSchema = TInstantiateType<Context, State, Indexer>> = TOmitAction<InstantiatedType, InstantiatedIndexer>;
8616
8686
 
8687
+ /**
8688
+ * The closed vocabulary of tool call failure codes. The engine and the tools
8689
+ * mint only these; a returned failure with a code outside it is not a
8690
+ * classification (the engine records the rejection on an unexplained failure),
8691
+ * and a stored record with one reads as none.
8692
+ */
8693
+ 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"];
8694
+
8617
8695
  /**
8618
8696
  * ---
8619
8697
  * responsibility: The declarative permission classification a tool carries on its definition
@@ -8643,6 +8721,56 @@ export declare interface ToolAvailability {
8643
8721
  description: string;
8644
8722
  }
8645
8723
 
8724
+ /**
8725
+ * The lane's classification of why one tool invocation failed: a searchable
8726
+ * machine code and the cause the tool or engine classified at execution.
8727
+ */
8728
+ export declare interface ToolCallFailure extends ToolCallFailureCause {
8729
+ readonly code: ToolCallFailureCode;
8730
+ }
8731
+
8732
+ declare type ToolCallFailureCause = z.infer<typeof toolCallFailureCauseSchema>;
8733
+
8734
+ declare const toolCallFailureCauseSchema: z.ZodObject<{
8735
+ category: z.ZodEnum<{
8736
+ cancelled: "cancelled";
8737
+ timeout: "timeout";
8738
+ unknown: "unknown";
8739
+ provider: "provider";
8740
+ "invalid-input": "invalid-input";
8741
+ "not-connected": "not-connected";
8742
+ "unsupported-operation": "unsupported-operation";
8743
+ "not-found": "not-found";
8744
+ permission: "permission";
8745
+ unavailable: "unavailable";
8746
+ }>;
8747
+ retryable: z.ZodBoolean;
8748
+ action: z.ZodEnum<{
8749
+ unknown: "unknown";
8750
+ none: "none";
8751
+ retry: "retry";
8752
+ "correct-input": "correct-input";
8753
+ connect: "connect";
8754
+ }>;
8755
+ details: z.ZodOptional<z.ZodObject<{
8756
+ moduleId: z.ZodOptional<z.ZodString>;
8757
+ toolOwnerId: z.ZodOptional<z.ZodString>;
8758
+ operation: z.ZodOptional<z.ZodString>;
8759
+ uri: z.ZodOptional<z.ZodString>;
8760
+ path: z.ZodOptional<z.ZodString>;
8761
+ validationField: z.ZodOptional<z.ZodString>;
8762
+ errorName: z.ZodOptional<z.ZodString>;
8763
+ errorCode: z.ZodOptional<z.ZodString>;
8764
+ providerCode: z.ZodOptional<z.ZodString>;
8765
+ status: z.ZodOptional<z.ZodNumber>;
8766
+ editIndex: z.ZodOptional<z.ZodNumber>;
8767
+ occurrences: z.ZodOptional<z.ZodNumber>;
8768
+ retryAfterMs: z.ZodOptional<z.ZodNumber>;
8769
+ }, z.core.$strict>>;
8770
+ }, z.core.$strict>;
8771
+
8772
+ declare type ToolCallFailureCode = (typeof TOOL_CALL_FAILURE_CODES)[number];
8773
+
8646
8774
  /**
8647
8775
  * The neutral around-execution hook: return `next()`'s result (possibly transformed) to run the
8648
8776
  * real tool, or return a result without calling `next()` to substitute one — the tool then never
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
  }
@@ -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
  }
@@ -3878,11 +3900,11 @@ export declare interface KayAppPluginApi {
3878
3900
  */
3879
3901
  readonly sessionEvents: KayAppSessionEvents;
3880
3902
  /**
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.
3903
+ * Grant-gated time-triggered workflow registration. Present for a plugin the host has a workflow
3904
+ * namespace for; `undefined` otherwise. The first `define` asks for the `workflows.define` claim
3905
+ * in the user's grant ledger — no manifest request and no source-class gate — and it is decided
3906
+ * once `activate()` resolves: an ungranted plugin does not start until the user allows it. A
3907
+ * plugin that defines no workflow is never asked.
3886
3908
  */
3887
3909
  readonly workflows?: KayAppWorkflows;
3888
3910
  /**
@@ -3988,12 +4010,7 @@ export declare interface KayAppPluginApi {
3988
4010
  }
3989
4011
 
3990
4012
  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;
4013
+ publish(localId: string, input: PluginEventPublishInput): void;
3997
4014
  }
3998
4015
 
3999
4016
  export declare type KayAppProcessingSpeed = "standard" | "fast";
@@ -4126,12 +4143,12 @@ export declare interface KayAppRepos {
4126
4143
 
4127
4144
  /** What the plugin is asking for, and what it intends to do with it. */
4128
4145
  export declare interface KayAppResolveCredentialRequest {
4129
- /** An auth service this plugin's own manifest declares, by its LOCAL id. */
4146
+ /** A granted service: local ID when owned, globally qualified ID when consumed. */
4130
4147
  readonly serviceId: string;
4131
- /** Exact scheme to require; omit to resolve the service's sole connected scheme. */
4148
+ /** Local scheme ID when owned, globally qualified when consumed; omit for the sole connected scheme. */
4132
4149
  readonly schemeId?: string;
4133
4150
  /**
4134
- * One of the `purposes` the declared service lists. The host pins the resolved grant to it, so a
4151
+ * One of the service's `purposes` admitted by the manifest grant. The host pins the grant to it, so a
4135
4152
  * credential taken for `"transcription"` cannot be replayed for anything else.
4136
4153
  */
4137
4154
  readonly purpose: string;
@@ -4140,8 +4157,8 @@ export declare interface KayAppResolveCredentialRequest {
4140
4157
  /**
4141
4158
  * ---
4142
4159
  * 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.
4160
+ * plugin lists account metadata or resolves credentials for an owned or consumed auth service
4161
+ * under explicit grants. Credential material is read where the work happens.
4145
4162
  * owns:
4146
4163
  * - {@link KayAppAuth}, {@link KayAppResolvedCredential}.
4147
4164
  * does_not_own:
@@ -4152,8 +4169,8 @@ export declare interface KayAppResolveCredentialRequest {
4152
4169
  * ## Deny-by-default
4153
4170
  *
4154
4171
  * `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.
4172
+ * containing `"list"` or `"resolve"` in `permissions.byTarget["kay.app"]`, against an owned or consumed
4173
+ * service) and `undefined` otherwise — an ungranted plugin cannot even reference the capability.
4157
4174
  * This mirrors `KayAppPluginApi.corpus`, and it is the rule for every capability behind a grant:
4158
4175
  * never hand a plugin an object whose grant is decorative.
4159
4176
  *
@@ -5967,6 +5984,8 @@ export declare interface KayAppWhiteboardTypes {
5967
5984
  * different process. Anything you need later belongs in a step's return value.
5968
5985
  */
5969
5986
  export declare interface KayAppWorkflowContext {
5987
+ /** State from the last successful run; undefined until a run saves it. */
5988
+ readonly state: JsonValue | undefined;
5970
5989
  readonly automationId: string;
5971
5990
  readonly runId: string;
5972
5991
  readonly match: Extract<KayAppAutomationMatch, {
@@ -6039,6 +6058,8 @@ export declare interface KayAppWorkflowDefinition {
6039
6058
  readonly kind: "time";
6040
6059
  }>;
6041
6060
  readonly run: (context: KayAppWorkflowContext) => Promise<{
6061
+ /** Replacement JSON state, at most 64 KiB; omission keeps the previous value. */
6062
+ readonly state?: JsonValue | undefined;
6042
6063
  readonly summary: KayAppRunSummary;
6043
6064
  readonly produced?: KayAppRunProduced;
6044
6065
  readonly effect?: KayAppRunEffect;
@@ -7149,6 +7170,8 @@ declare function Partial_2<Type extends TSchema>(type: Type, options?: TSchemaOp
7149
7170
  /** Creates a deferred Partial action. */
7150
7171
  declare function PartialDeferred<Type extends TSchema>(type: Type, options?: TSchemaOptions): TPartialDeferred<Type>;
7151
7172
 
7173
+ export { pathToFileURL }
7174
+
7152
7175
  declare const Pattern: (input: string) => [unknown, string] | [];
7153
7176
 
7154
7177
  declare const PatternBase: (input: string) => [unknown, string] | [];
@@ -7309,6 +7332,42 @@ export declare const PluginAgentDefinitionPermissionRule: z.ZodObject<{
7309
7332
 
7310
7333
  export declare type PluginAgentDefinitionPermissionRule = z.infer<typeof PluginAgentDefinitionPermissionRule>;
7311
7334
 
7335
+ export declare const PluginEventEnvelope: z.ZodObject<{
7336
+ id: z.ZodString;
7337
+ localId: z.ZodString;
7338
+ type: z.ZodString;
7339
+ version: z.ZodNumber;
7340
+ uri: z.ZodString;
7341
+ related: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodString, z.ZodArray<z.ZodString>]>>>;
7342
+ key: z.ZodOptional<z.ZodString>;
7343
+ occurredAt: z.ZodISODateTime;
7344
+ publishedAt: z.ZodISODateTime;
7345
+ source: z.ZodObject<{
7346
+ poller: z.ZodOptional<z.ZodString>;
7347
+ runId: z.ZodOptional<z.ZodString>;
7348
+ layer: z.ZodLiteral<"runtime">;
7349
+ pluginId: z.ZodString;
7350
+ sessionId: z.ZodOptional<z.ZodString>;
7351
+ }, z.core.$strict>;
7352
+ payload: z.ZodOptional<z.ZodType<JsonValue, unknown, z.core.$ZodTypeInternals<JsonValue, unknown>>>;
7353
+ }, z.core.$strict>;
7354
+
7355
+ export declare type PluginEventEnvelope = z.infer<typeof PluginEventEnvelope>;
7356
+
7357
+ export declare const PluginEventPublishInput: z.ZodObject<{
7358
+ uri: z.ZodString;
7359
+ related: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodString, z.ZodArray<z.ZodString>]>>>;
7360
+ key: z.ZodOptional<z.ZodString>;
7361
+ occurredAt: z.ZodOptional<z.ZodISODateTime>;
7362
+ source: z.ZodOptional<z.ZodObject<{
7363
+ poller: z.ZodOptional<z.ZodString>;
7364
+ runId: z.ZodOptional<z.ZodString>;
7365
+ }, z.core.$strict>>;
7366
+ payload: z.ZodOptional<z.ZodType<JsonValue, unknown, z.core.$ZodTypeInternals<JsonValue, unknown>>>;
7367
+ }, z.core.$strict>;
7368
+
7369
+ export declare type PluginEventPublishInput = z.infer<typeof PluginEventPublishInput>;
7370
+
7312
7371
  declare const Properties: (input: string) => [unknown, string] | [];
7313
7372
 
7314
7373
  declare function PropertiesMapping(input: [unknown, unknown, unknown]): unknown;
@@ -8605,7 +8664,7 @@ declare interface SystemOneClient {
8605
8664
  decide<const Q extends DecideQuestions>(request: DecideRequest<Q>, options?: SystemOneCallOptions): Promise<Decision<Q>>;
8606
8665
  extract<const F extends ExtractFields>(request: ExtractRequest<F>, options?: SystemOneCallOptions): Promise<Extraction<F>>;
8607
8666
  /** Whether some provider in the current order can serve `(kind, model)`. Never rejects. */
8608
- availability(kind: SystemOneKind, model?: SystemOneModelId): Promise<Availability>;
8667
+ availability(kind: SystemOneKind, model: SystemOneModelId): Promise<Availability>;
8609
8668
  }
8610
8669
 
8611
8670
  /**
@@ -8640,6 +8699,12 @@ declare type SystemOneFailureCause = {
8640
8699
  readonly kind: "invalid-answer";
8641
8700
  };
8642
8701
 
8702
+ /** One PNG attachment. `data` is padded base64, without a data-URL prefix. */
8703
+ declare interface SystemOneImage {
8704
+ readonly mimeType: "image/png";
8705
+ readonly data: string;
8706
+ }
8707
+
8643
8708
  /**
8644
8709
  * ---
8645
8710
  * responsibility: The data shapes of the System One surface: models, the decide and extract
@@ -10833,6 +10898,14 @@ declare interface Tool<TParameters extends TSchema = TSchema> {
10833
10898
  constrainedSampling?: false | ConstrainedSamplingConfig;
10834
10899
  }
10835
10900
 
10901
+ /**
10902
+ * The closed vocabulary of tool call failure codes. The engine and the tools
10903
+ * mint only these; a returned failure with a code outside it is not a
10904
+ * classification (the engine records the rejection on an unexplained failure),
10905
+ * and a stored record with one reads as none.
10906
+ */
10907
+ 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"];
10908
+
10836
10909
  /**
10837
10910
  * ---
10838
10911
  * responsibility: The declarative permission classification a tool carries on its definition
@@ -10877,6 +10950,56 @@ declare interface ToolCall {
10877
10950
  argumentsError?: string;
10878
10951
  }
10879
10952
 
10953
+ /**
10954
+ * The lane's classification of why one tool invocation failed: a searchable
10955
+ * machine code and the cause the tool or engine classified at execution.
10956
+ */
10957
+ declare interface ToolCallFailure extends ToolCallFailureCause {
10958
+ readonly code: ToolCallFailureCode;
10959
+ }
10960
+
10961
+ declare type ToolCallFailureCause = z.infer<typeof toolCallFailureCauseSchema>;
10962
+
10963
+ declare const toolCallFailureCauseSchema: z.ZodObject<{
10964
+ category: z.ZodEnum<{
10965
+ cancelled: "cancelled";
10966
+ timeout: "timeout";
10967
+ unknown: "unknown";
10968
+ provider: "provider";
10969
+ "invalid-input": "invalid-input";
10970
+ "not-connected": "not-connected";
10971
+ "unsupported-operation": "unsupported-operation";
10972
+ "not-found": "not-found";
10973
+ permission: "permission";
10974
+ unavailable: "unavailable";
10975
+ }>;
10976
+ retryable: z.ZodBoolean;
10977
+ action: z.ZodEnum<{
10978
+ unknown: "unknown";
10979
+ none: "none";
10980
+ retry: "retry";
10981
+ "correct-input": "correct-input";
10982
+ connect: "connect";
10983
+ }>;
10984
+ details: z.ZodOptional<z.ZodObject<{
10985
+ moduleId: z.ZodOptional<z.ZodString>;
10986
+ toolOwnerId: z.ZodOptional<z.ZodString>;
10987
+ operation: z.ZodOptional<z.ZodString>;
10988
+ uri: z.ZodOptional<z.ZodString>;
10989
+ path: z.ZodOptional<z.ZodString>;
10990
+ validationField: z.ZodOptional<z.ZodString>;
10991
+ errorName: z.ZodOptional<z.ZodString>;
10992
+ errorCode: z.ZodOptional<z.ZodString>;
10993
+ providerCode: z.ZodOptional<z.ZodString>;
10994
+ status: z.ZodOptional<z.ZodNumber>;
10995
+ editIndex: z.ZodOptional<z.ZodNumber>;
10996
+ occurrences: z.ZodOptional<z.ZodNumber>;
10997
+ retryAfterMs: z.ZodOptional<z.ZodNumber>;
10998
+ }, z.core.$strict>>;
10999
+ }, z.core.$strict>;
11000
+
11001
+ declare type ToolCallFailureCode = (typeof TOOL_CALL_FAILURE_CODES)[number];
11002
+
10880
11003
  /** A call to judge with {@link ToolContext.checkToolCallPermission}. */
10881
11004
  declare interface ToolCallPermissionCheck {
10882
11005
  readonly toolName: string;
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
  };
@@ -537,6 +540,7 @@ export {
537
540
  invalidObservation,
538
541
  isRetryable,
539
542
  parseLineSelector,
543
+ pathToFileURL,
540
544
  payload,
541
545
  transcriptMessageText,
542
546
  transcriptMessageTexts,