@yaklabs-ai/plugin-sdk 0.29.0 → 0.30.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.
package/README.md CHANGED
@@ -13,7 +13,7 @@ it under the name your plugin code actually imports:
13
13
  ```json
14
14
  {
15
15
  "dependencies": {
16
- "@bonsai/plugin-sdk": "npm:@yaklabs-ai/plugin-sdk@^0.29.0"
16
+ "@bonsai/plugin-sdk": "npm:@yaklabs-ai/plugin-sdk@^0.30.0"
17
17
  }
18
18
  }
19
19
  ```
@@ -62,7 +62,7 @@ Every tool the entrypoint registers is declared in the manifest too:
62
62
  "description": "Greets people by name.",
63
63
  "version": "0.1.0",
64
64
  "namespace": "widgets",
65
- "compatibility": { "sdk": "^0.29.0" },
65
+ "compatibility": { "sdk": "^0.30.0" },
66
66
  "targets": {
67
67
  "kay": {
68
68
  "agent": {
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "schemaVersion": 1,
3
3
  "package": "@yaklabs-ai/plugin-sdk",
4
- "version": "0.29.0",
4
+ "version": "0.30.0",
5
5
  "target": "npm",
6
6
  "firstPartyLicense": "MIT",
7
7
  "bundled": [
@@ -249,6 +249,7 @@ declare namespace authoringCommonSchemas {
249
249
  hostWithinDomain,
250
250
  urlHostWithinDomain,
251
251
  refineWebSessionScopeConfined,
252
+ KAY_PLUGIN_MANIFEST_SIZE_CAP_BYTES,
252
253
  KAY_PLUGIN_PROTOCOL_VERSION,
253
254
  KAY_PLUGIN_PROTOCOL_PACKAGE_NAME,
254
255
  KAY_PLUGIN_SDK_VERSION,
@@ -1771,6 +1772,9 @@ declare const KAY_EVENT_PUBLISHER_ID: "kay";
1771
1772
  /** Released SDK contracts still implemented by the host, alongside its current SDK. */
1772
1773
  declare const KAY_PLUGIN_COMPATIBLE_SDK_VERSIONS: readonly string[];
1773
1774
 
1775
+ /** Manifest byte cap, including declared app-data schemas; larger files are refused unread. */
1776
+ declare const KAY_PLUGIN_MANIFEST_SIZE_CAP_BYTES: number;
1777
+
1774
1778
  declare const KAY_PLUGIN_PROTOCOL_PACKAGE_NAME: "@bonsai/plugin-protocol";
1775
1779
 
1776
1780
  declare const KAY_PLUGIN_PROTOCOL_VERSION: "kay.plugin.v1";
@@ -2347,8 +2351,14 @@ declare const KAY_PLUGIN_PROTOCOL_VERSION: "kay.plugin.v1";
2347
2351
  * whichever process runs the plugin. A plugin's simulator file exports `createPluginSimulator`
2348
2352
  * (`KayPluginSimulatorFactory`). A clean break: only this repo's plugins read the old member, and
2349
2353
  * a plugin with no simulator is unaffected, so 0.28.0 stays served.
2354
+ *
2355
+ * 0.30.0 lets a scheduled workflow be described as data (#15722). `contributes.workflows` under
2356
+ * `kay.app` declares its name, schedule and sign-in, and `app.implementWorkflow(localId, run)`
2357
+ * supplies what a run does: each run is handed the workflow's accounts and tokens, so the code
2358
+ * runs the same in the daemon and in the plugin host. Additive: `app.workflows.define` stays, and
2359
+ * a plugin that declares a workflow declares ^0.30.0.
2350
2360
  */
2351
- declare const KAY_PLUGIN_SDK_VERSION: "0.29.0";
2361
+ declare const KAY_PLUGIN_SDK_VERSION: "0.30.0";
2352
2362
 
2353
2363
  declare const KAY_PLUGIN_TARGET_NAMES: readonly ["kay.agent", "kay.app", "kay.ui"];
2354
2364
 
@@ -224,6 +224,7 @@ declare namespace authoringCommonSchemas {
224
224
  hostWithinDomain,
225
225
  urlHostWithinDomain,
226
226
  refineWebSessionScopeConfined,
227
+ KAY_PLUGIN_MANIFEST_SIZE_CAP_BYTES,
227
228
  KAY_PLUGIN_PROTOCOL_VERSION,
228
229
  KAY_PLUGIN_PROTOCOL_PACKAGE_NAME,
229
230
  KAY_PLUGIN_SDK_VERSION,
@@ -1825,6 +1826,9 @@ declare const KAY_EVENT_PUBLISHER_ID: "kay";
1825
1826
  /** Released SDK contracts still implemented by the host, alongside its current SDK. */
1826
1827
  declare const KAY_PLUGIN_COMPATIBLE_SDK_VERSIONS: readonly string[];
1827
1828
 
1829
+ /** Manifest byte cap, including declared app-data schemas; larger files are refused unread. */
1830
+ declare const KAY_PLUGIN_MANIFEST_SIZE_CAP_BYTES: number;
1831
+
1828
1832
  declare const KAY_PLUGIN_PROTOCOL_PACKAGE_NAME: "@bonsai/plugin-protocol";
1829
1833
 
1830
1834
  declare const KAY_PLUGIN_PROTOCOL_VERSION: "kay.plugin.v1";
@@ -2401,8 +2405,14 @@ declare const KAY_PLUGIN_PROTOCOL_VERSION: "kay.plugin.v1";
2401
2405
  * whichever process runs the plugin. A plugin's simulator file exports `createPluginSimulator`
2402
2406
  * (`KayPluginSimulatorFactory`). A clean break: only this repo's plugins read the old member, and
2403
2407
  * a plugin with no simulator is unaffected, so 0.28.0 stays served.
2408
+ *
2409
+ * 0.30.0 lets a scheduled workflow be described as data (#15722). `contributes.workflows` under
2410
+ * `kay.app` declares its name, schedule and sign-in, and `app.implementWorkflow(localId, run)`
2411
+ * supplies what a run does: each run is handed the workflow's accounts and tokens, so the code
2412
+ * runs the same in the daemon and in the plugin host. Additive: `app.workflows.define` stays, and
2413
+ * a plugin that declares a workflow declares ^0.30.0.
2404
2414
  */
2405
- declare const KAY_PLUGIN_SDK_VERSION: "0.29.0";
2415
+ declare const KAY_PLUGIN_SDK_VERSION: "0.30.0";
2406
2416
 
2407
2417
  declare const KAY_PLUGIN_TARGET_NAMES: readonly ["kay.agent", "kay.app", "kay.ui"];
2408
2418
 
@@ -4745,6 +4755,7 @@ declare const ResolvedPluginContractV1: z.ZodObject<{
4745
4755
  appDataSource: "appDataSource";
4746
4756
  whiteboardType: "whiteboardType";
4747
4757
  approvalType: "approvalType";
4758
+ workflow: "workflow";
4748
4759
  contextContributor: "contextContributor";
4749
4760
  transcriptionProvider: "transcriptionProvider";
4750
4761
  deviceDelegation: "deviceDelegation";
@@ -5516,6 +5527,18 @@ declare const ResolvedPluginContractV1: z.ZodObject<{
5516
5527
  moduleId: z.ZodString;
5517
5528
  authService: z.ZodOptional<z.ZodString>;
5518
5529
  }, z.core.$strict>>>;
5530
+ kayAppWorkflows: z.ZodOptional<z.ZodArray<z.ZodObject<{
5531
+ localId: z.ZodString;
5532
+ globalId: z.ZodString;
5533
+ name: z.ZodString;
5534
+ description: z.ZodString;
5535
+ everyMs: z.ZodNumber;
5536
+ auth: z.ZodOptional<z.ZodObject<{
5537
+ serviceId: z.ZodString;
5538
+ schemeId: z.ZodString;
5539
+ scopes: z.ZodOptional<z.ZodArray<z.ZodString>>;
5540
+ }, z.core.$strict>>;
5541
+ }, z.core.$strict>>>;
5519
5542
  kayAppDataSources: z.ZodOptional<z.ZodArray<z.ZodObject<{
5520
5543
  localId: z.ZodString;
5521
5544
  globalId: z.ZodString;
@@ -317,6 +317,7 @@ declare namespace authoringCommonSchemas {
317
317
  hostWithinDomain,
318
318
  urlHostWithinDomain,
319
319
  refineWebSessionScopeConfined,
320
+ KAY_PLUGIN_MANIFEST_SIZE_CAP_BYTES,
320
321
  KAY_PLUGIN_PROTOCOL_VERSION,
321
322
  KAY_PLUGIN_PROTOCOL_PACKAGE_NAME,
322
323
  KAY_PLUGIN_SDK_VERSION,
@@ -2100,6 +2101,9 @@ declare const KAY_EVENT_PUBLISHER_ID: "kay";
2100
2101
  /** Released SDK contracts still implemented by the host, alongside its current SDK. */
2101
2102
  declare const KAY_PLUGIN_COMPATIBLE_SDK_VERSIONS: readonly string[];
2102
2103
 
2104
+ /** Manifest byte cap, including declared app-data schemas; larger files are refused unread. */
2105
+ declare const KAY_PLUGIN_MANIFEST_SIZE_CAP_BYTES: number;
2106
+
2103
2107
  declare const KAY_PLUGIN_PROTOCOL_PACKAGE_NAME: "@bonsai/plugin-protocol";
2104
2108
 
2105
2109
  declare const KAY_PLUGIN_PROTOCOL_VERSION: "kay.plugin.v1";
@@ -2676,8 +2680,14 @@ declare const KAY_PLUGIN_PROTOCOL_VERSION: "kay.plugin.v1";
2676
2680
  * whichever process runs the plugin. A plugin's simulator file exports `createPluginSimulator`
2677
2681
  * (`KayPluginSimulatorFactory`). A clean break: only this repo's plugins read the old member, and
2678
2682
  * a plugin with no simulator is unaffected, so 0.28.0 stays served.
2683
+ *
2684
+ * 0.30.0 lets a scheduled workflow be described as data (#15722). `contributes.workflows` under
2685
+ * `kay.app` declares its name, schedule and sign-in, and `app.implementWorkflow(localId, run)`
2686
+ * supplies what a run does: each run is handed the workflow's accounts and tokens, so the code
2687
+ * runs the same in the daemon and in the plugin host. Additive: `app.workflows.define` stays, and
2688
+ * a plugin that declares a workflow declares ^0.30.0.
2679
2689
  */
2680
- declare const KAY_PLUGIN_SDK_VERSION: "0.29.0";
2690
+ declare const KAY_PLUGIN_SDK_VERSION: "0.30.0";
2681
2691
 
2682
2692
  declare const KAY_PLUGIN_TARGET_NAMES: readonly ["kay.agent", "kay.app", "kay.ui"];
2683
2693
 
@@ -4348,8 +4358,8 @@ export declare interface OsascriptFailureAdvice {
4348
4358
  }
4349
4359
 
4350
4360
  /**
4351
- * The activation options every osascript plugin's agent factory accepted, so the daemon's
4352
- * simulator roster set each the same way. Absent `simulator`, the plugin is exactly the shipped one.
4361
+ * The activation options every osascript plugin's agent factory accepted, each with the same
4362
+ * `simulator` option. Absent `simulator`, the plugin is exactly the shipped one.
4353
4363
  *
4354
4364
  * @deprecated See {@link OsascriptSimulatorOptions}.
4355
4365
  */
@@ -4388,10 +4398,6 @@ export declare interface OsascriptRunner {
4388
4398
  /**
4389
4399
  * The runners a module's verbs use: the host's exactly when `simulator` is absent, or the
4390
4400
  * simulator's in its place, per dispatch, after the host's connection gate.
4391
- *
4392
- * @deprecated A Bonsai daemon substitutes the runner itself, so a module uses
4393
- * {@link requireExternalCli} and `ctx.auth?.externalCli` directly. Kept so a plugin built against
4394
- * an earlier SDK keeps compiling.
4395
4401
  */
4396
4402
  readonly dispatch: (simulator: OsascriptSimulatedRunner | undefined) => OsascriptDispatch;
4397
4403
  /**
@@ -4438,25 +4444,22 @@ export declare interface OsascriptRunnerOptions {
4438
4444
  }
4439
4445
 
4440
4446
  /**
4441
- * A simulated runner, as a module sees it: the runner one dispatch uses in the host's place. A
4442
- * Bonsai daemon that simulates an osascript plugin hands `runnerFor(ctx)` to the module as
4443
- * `ctx.auth.externalCli`; `@bonsai/uri-simulator-kit/osascript` builds one.
4447
+ * A simulated runner, as a module sees it: the runner one dispatch uses in the host's place. An
4448
+ * osascript plugin's simulator holds one (`@bonsai/uri-simulator-kit/osascript` builds it), and the
4449
+ * module passes it to {@link OsascriptRunner.dispatch}.
4444
4450
  */
4445
4451
  export declare interface OsascriptSimulatedRunner {
4446
4452
  readonly runnerFor: (ctx: UriResolveContext) => UriExternalCliRunner;
4447
4453
  }
4448
4454
 
4449
4455
  /**
4450
- * How a plugin is told to serve its module from its simulator instead of osascript: the one
4451
- * option shape every osascript plugin's agent factory accepts as `simulator`. Only the daemon's
4452
- * URI simulator roster sets it, for evals and dev; an ordinary install never does.
4456
+ * How a plugin was once told to serve its module from its simulator instead of osascript.
4453
4457
  *
4454
- * @deprecated A Bonsai daemon now hands the module a simulated runner as `ctx.auth.externalCli`,
4455
- * so a plugin needs no simulator option; no Bonsai plugin sets this. Kept so a plugin built against
4456
- * an earlier SDK keeps compiling.
4458
+ * @deprecated A plugin gets its simulator as `api.simulator`; no Bonsai plugin sets this. Kept so a
4459
+ * plugin built against an earlier SDK keeps compiling.
4457
4460
  */
4458
4461
  export declare interface OsascriptSimulatorOptions {
4459
- /** The directory holding the simulator's world; the daemon's process config names it. */
4462
+ /** The directory holding the simulator's world. */
4460
4463
  readonly stateDir: string;
4461
4464
  }
4462
4465
 
package/dist/kay-app.d.ts CHANGED
@@ -266,6 +266,7 @@ declare namespace authoringCommonSchemas {
266
266
  hostWithinDomain,
267
267
  urlHostWithinDomain,
268
268
  refineWebSessionScopeConfined,
269
+ KAY_PLUGIN_MANIFEST_SIZE_CAP_BYTES,
269
270
  KAY_PLUGIN_PROTOCOL_VERSION,
270
271
  KAY_PLUGIN_PROTOCOL_PACKAGE_NAME,
271
272
  KAY_PLUGIN_SDK_VERSION,
@@ -2057,6 +2058,9 @@ declare const KAY_EVENT_PUBLISHER_ID: "kay";
2057
2058
  /** Released SDK contracts still implemented by the host, alongside its current SDK. */
2058
2059
  declare const KAY_PLUGIN_COMPATIBLE_SDK_VERSIONS: readonly string[];
2059
2060
 
2061
+ /** Manifest byte cap, including declared app-data schemas; larger files are refused unread. */
2062
+ declare const KAY_PLUGIN_MANIFEST_SIZE_CAP_BYTES: number;
2063
+
2060
2064
  declare const KAY_PLUGIN_PROTOCOL_PACKAGE_NAME: "@bonsai/plugin-protocol";
2061
2065
 
2062
2066
  declare const KAY_PLUGIN_PROTOCOL_VERSION: "kay.plugin.v1";
@@ -2633,8 +2637,14 @@ declare const KAY_PLUGIN_PROTOCOL_VERSION: "kay.plugin.v1";
2633
2637
  * whichever process runs the plugin. A plugin's simulator file exports `createPluginSimulator`
2634
2638
  * (`KayPluginSimulatorFactory`). A clean break: only this repo's plugins read the old member, and
2635
2639
  * a plugin with no simulator is unaffected, so 0.28.0 stays served.
2640
+ *
2641
+ * 0.30.0 lets a scheduled workflow be described as data (#15722). `contributes.workflows` under
2642
+ * `kay.app` declares its name, schedule and sign-in, and `app.implementWorkflow(localId, run)`
2643
+ * supplies what a run does: each run is handed the workflow's accounts and tokens, so the code
2644
+ * runs the same in the daemon and in the plugin host. Additive: `app.workflows.define` stays, and
2645
+ * a plugin that declares a workflow declares ^0.30.0.
2636
2646
  */
2637
- declare const KAY_PLUGIN_SDK_VERSION: "0.29.0";
2647
+ declare const KAY_PLUGIN_SDK_VERSION: "0.30.0";
2638
2648
 
2639
2649
  declare const KAY_PLUGIN_TARGET_NAMES: readonly ["kay.agent", "kay.app", "kay.ui"];
2640
2650
 
@@ -5276,6 +5286,14 @@ export declare interface KayAppPluginApi {
5276
5286
  * fail-closed at activation, exactly like {@link registerUriModule}.
5277
5287
  */
5278
5288
  registerTool(localId: string, definition: KayAppToolDefinition): void;
5289
+ /**
5290
+ * Supply the code of a workflow this plugin's manifest declares under
5291
+ * `targets.kay.app.contributes.workflows` (SDK 0.30.0). The manifest says its name, schedule and
5292
+ * sign-in, so Bonsai schedules it without this code running; each run is handed its accounts and
5293
+ * tokens, so it runs the same wherever the plugin runs. Implementing an undeclared `localId`, or
5294
+ * declaring one this activation does not implement, fails the plugin.
5295
+ */
5296
+ implementWorkflow(localId: string, run: KayAppWorkflowImplementation): void;
5279
5297
  }
5280
5298
 
5281
5299
  export declare interface KayAppPluginEvents {
@@ -8032,6 +8050,16 @@ export declare interface KayAppWhiteboardTypes {
8032
8050
  registerType(localId: string, behavior: KayAppWhiteboardTypeBehavior): void;
8033
8051
  }
8034
8052
 
8053
+ /**
8054
+ * One connected account of a declared workflow's service, and its credential for this run. An
8055
+ * account that needs signing in again, or holds none of the declared scopes, arrives with that
8056
+ * status instead of a token.
8057
+ */
8058
+ export declare interface KayAppWorkflowAccount {
8059
+ readonly account: KayAppAccountSummary;
8060
+ readonly credential: KayAppBackgroundCredentialResult;
8061
+ }
8062
+
8035
8063
  /**
8036
8064
  * What your `run` callback is handed when the trigger fires.
8037
8065
  *
@@ -8145,16 +8173,7 @@ export declare interface KayAppWorkflowDefinition<Trigger extends KayAppWorkflow
8145
8173
  * suits an event trigger whose runs each handle their own event; it cannot return `state`.
8146
8174
  */
8147
8175
  readonly concurrency?: KayAppAutomationConcurrency;
8148
- readonly run: (context: KayAppWorkflowContext<Trigger>) => Promise<{
8149
- /**
8150
- * Replacement JSON state, at most 64 KiB; omission keeps the previous value. Only a
8151
- * sequential workflow may return it: a `parallel` run that does fails.
8152
- */
8153
- readonly state?: JsonValue | undefined;
8154
- readonly summary: KayAppRunSummary;
8155
- readonly produced?: KayAppRunProduced;
8156
- readonly effect?: KayAppRunEffect;
8157
- }>;
8176
+ readonly run: (context: KayAppWorkflowContext<Trigger>) => Promise<KayAppWorkflowResult>;
8158
8177
  }
8159
8178
 
8160
8179
  /**
@@ -8173,6 +8192,9 @@ export declare class KayAppWorkflowFailure extends Error {
8173
8192
  constructor(summary: Omit<KayAppRunSummary, "author">, options?: ErrorOptions);
8174
8193
  }
8175
8194
 
8195
+ /** The code of a workflow the manifest declares under `contributes.workflows`. */
8196
+ export declare type KayAppWorkflowImplementation = (run: KayAppWorkflowRun) => Promise<KayAppWorkflowResult>;
8197
+
8176
8198
  export declare interface KayAppWorkflowInspection {
8177
8199
  readonly binding: KayAppManagedAutomation | null;
8178
8200
  readonly runs: readonly KayAppAutomationRun[];
@@ -8214,6 +8236,42 @@ export declare type KayAppWorkflowMatch<Trigger extends KayAppWorkflowTrigger =
8214
8236
  readonly kind: "time";
8215
8237
  }>);
8216
8238
 
8239
+ /** What a workflow run returns. */
8240
+ export declare interface KayAppWorkflowResult {
8241
+ /**
8242
+ * Replacement JSON state, at most 64 KiB; omission keeps the previous value. Only a
8243
+ * sequential workflow may return it: a `parallel` run that does fails.
8244
+ */
8245
+ readonly state?: JsonValue | undefined;
8246
+ readonly summary: KayAppRunSummary;
8247
+ readonly produced?: KayAppRunProduced;
8248
+ readonly effect?: KayAppRunEffect;
8249
+ }
8250
+
8251
+ /**
8252
+ * What a declared workflow's code is handed each run (`app.implementWorkflow`).
8253
+ *
8254
+ * The whole run is one recorded step, so an interrupted run starts again from the last saved
8255
+ * `state`: it may repeat provider reads and published events, so key events at their source.
8256
+ */
8257
+ export declare interface KayAppWorkflowRun {
8258
+ /** State from the last successful run; undefined until a run saves it. */
8259
+ readonly state: JsonValue | undefined;
8260
+ readonly runId: string;
8261
+ /**
8262
+ * Every connected account of the service and scheme the manifest's `auth` names, in a stable
8263
+ * order. Empty when it names none.
8264
+ */
8265
+ readonly accounts: readonly KayAppWorkflowAccount[];
8266
+ /**
8267
+ * Just runs `fn`, and returns once every event it published has reached Bonsai. Nothing is
8268
+ * recorded for now, so a repeated run runs it again. What it returns must be plain data.
8269
+ */
8270
+ readonly runStep: <T>(fn: () => Promise<T>, options?: {
8271
+ readonly name?: string;
8272
+ }) => Promise<T>;
8273
+ }
8274
+
8217
8275
  export declare interface KayAppWorkflows {
8218
8276
  define<Trigger extends KayAppWorkflowTrigger>(localId: string, definition: KayAppWorkflowDefinition<Trigger>): void;
8219
8277
  inspect(localId: string, options?: KayAppWorkflowInspectOptions): Promise<KayAppWorkflowInspection>;
@@ -26,6 +26,7 @@ var JsonObject = z2.record(z2.string(), JsonValue);
26
26
  var JsonSchema = z2.record(z2.string(), JsonValue);
27
27
 
28
28
  // packages/plugin-protocol/dist/common.js
29
+ var KAY_PLUGIN_MANIFEST_SIZE_CAP_BYTES = 1024 * 1024;
29
30
  var KAY_PLUGIN_PROTOCOL_VERSION = "kay.plugin.v1";
30
31
  var KAY_PLUGIN_TARGET_NAMES = [
31
32
  "kay.agent",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@yaklabs-ai/plugin-sdk",
3
- "version": "0.29.0",
3
+ "version": "0.30.0",
4
4
  "description": "The Kay plugin SDK — types and helpers for authoring a Kay directory plugin.",
5
5
  "author": "YakLabs",
6
6
  "type": "module",