@yaklabs-ai/plugin-sdk 0.41.0 → 0.42.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.41.0"
16
+ "@bonsai/plugin-sdk": "npm:@yaklabs-ai/plugin-sdk@^0.42.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.41.0" },
65
+ "compatibility": { "sdk": "^0.42.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.41.0",
4
+ "version": "0.42.0",
5
5
  "target": "npm",
6
6
  "firstPartyLicense": "MIT",
7
7
  "bundled": [
@@ -2417,8 +2417,12 @@ declare const KAY_PLUGIN_PROTOCOL_VERSION: "kay.plugin.v1";
2417
2417
  *
2418
2418
  * 0.41.0 adds app.mcp.callTool for background calls to a plugin's own manifest-declared MCP
2419
2419
  * servers, using Bonsai's managed connection without a session or working directory (#16172).
2420
+ *
2421
+ * 0.42.0 hands background work the shared ResolvedCredential in auth.credential. Workflow
2422
+ * accounts carry auth resolution outcomes, and Poller callbacks receive only the credential.
2423
+ * Older SDK ranges are refused because their background success shape is no longer served.
2420
2424
  */
2421
- declare const KAY_PLUGIN_SDK_VERSION: "0.41.0";
2425
+ declare const KAY_PLUGIN_SDK_VERSION: "0.42.0";
2422
2426
 
2423
2427
  declare const KAY_PLUGIN_TARGET_NAMES: readonly ["kay.agent", "kay.app", "kay.ui"];
2424
2428
 
@@ -2471,8 +2471,12 @@ declare const KAY_PLUGIN_PROTOCOL_VERSION: "kay.plugin.v1";
2471
2471
  *
2472
2472
  * 0.41.0 adds app.mcp.callTool for background calls to a plugin's own manifest-declared MCP
2473
2473
  * servers, using Bonsai's managed connection without a session or working directory (#16172).
2474
+ *
2475
+ * 0.42.0 hands background work the shared ResolvedCredential in auth.credential. Workflow
2476
+ * accounts carry auth resolution outcomes, and Poller callbacks receive only the credential.
2477
+ * Older SDK ranges are refused because their background success shape is no longer served.
2474
2478
  */
2475
- declare const KAY_PLUGIN_SDK_VERSION: "0.41.0";
2479
+ declare const KAY_PLUGIN_SDK_VERSION: "0.42.0";
2476
2480
 
2477
2481
  declare const KAY_PLUGIN_TARGET_NAMES: readonly ["kay.agent", "kay.app", "kay.ui"];
2478
2482
 
@@ -5796,6 +5800,7 @@ declare const ResolvedPluginContractV1: z.ZodObject<{
5796
5800
  "artifacts.read": "artifacts.read";
5797
5801
  "artifacts.preview": "artifacts.preview";
5798
5802
  "markdown.document-view": "markdown.document-view";
5803
+ "references.open": "references.open";
5799
5804
  "billing.read": "billing.read";
5800
5805
  "automations.read": "automations.read";
5801
5806
  "automations.run": "automations.run";
@@ -2746,8 +2746,12 @@ declare const KAY_PLUGIN_PROTOCOL_VERSION: "kay.plugin.v1";
2746
2746
  *
2747
2747
  * 0.41.0 adds app.mcp.callTool for background calls to a plugin's own manifest-declared MCP
2748
2748
  * servers, using Bonsai's managed connection without a session or working directory (#16172).
2749
+ *
2750
+ * 0.42.0 hands background work the shared ResolvedCredential in auth.credential. Workflow
2751
+ * accounts carry auth resolution outcomes, and Poller callbacks receive only the credential.
2752
+ * Older SDK ranges are refused because their background success shape is no longer served.
2749
2753
  */
2750
- declare const KAY_PLUGIN_SDK_VERSION: "0.41.0";
2754
+ declare const KAY_PLUGIN_SDK_VERSION: "0.42.0";
2751
2755
 
2752
2756
  declare const KAY_PLUGIN_TARGET_NAMES: readonly ["kay.agent", "kay.app", "kay.ui"];
2753
2757
 
package/dist/kay-app.d.ts CHANGED
@@ -2722,8 +2722,12 @@ declare const KAY_PLUGIN_PROTOCOL_VERSION: "kay.plugin.v1";
2722
2722
  *
2723
2723
  * 0.41.0 adds app.mcp.callTool for background calls to a plugin's own manifest-declared MCP
2724
2724
  * servers, using Bonsai's managed connection without a session or working directory (#16172).
2725
+ *
2726
+ * 0.42.0 hands background work the shared ResolvedCredential in auth.credential. Workflow
2727
+ * accounts carry auth resolution outcomes, and Poller callbacks receive only the credential.
2728
+ * Older SDK ranges are refused because their background success shape is no longer served.
2725
2729
  */
2726
- declare const KAY_PLUGIN_SDK_VERSION: "0.41.0";
2730
+ declare const KAY_PLUGIN_SDK_VERSION: "0.42.0";
2727
2731
 
2728
2732
  declare const KAY_PLUGIN_TARGET_NAMES: readonly ["kay.agent", "kay.app", "kay.ui"];
2729
2733
 
@@ -3932,7 +3936,7 @@ export declare interface KayAppAutomationUriChangeCondition {
3932
3936
 
3933
3937
  /** Exact-account credential resolution for a plugin's durable background jobs. */
3934
3938
  export declare interface KayAppBackgroundAuth {
3935
- resolveCredential(request: KayAppBackgroundCredentialRequest): Promise<KayAppBackgroundCredentialResult>;
3939
+ resolveCredential(request: KayAppBackgroundCredentialRequest): Promise<KayAppCredentialResolution>;
3936
3940
  }
3937
3941
 
3938
3942
  /** A credential request for durable background work bound to one known account. */
@@ -3948,21 +3952,6 @@ export declare interface KayAppBackgroundCredentialRequest {
3948
3952
  readonly jobId: string;
3949
3953
  }
3950
3954
 
3951
- /** The non-secret outcome of a durable background credential lookup. */
3952
- export declare type KayAppBackgroundCredentialResult = {
3953
- readonly status: "resolved";
3954
- readonly accessToken: string;
3955
- readonly accountId: string;
3956
- readonly scopes: readonly string[];
3957
- } | {
3958
- readonly status: "missing";
3959
- readonly reason: string;
3960
- } | {
3961
- readonly status: "requires-auth";
3962
- readonly reason: string;
3963
- readonly requiredScopes?: readonly string[];
3964
- };
3965
-
3966
3955
  /**
3967
3956
  * The `kay.app` system-prompt contract (`app.systemPrompt`): text a plugin adds to every chat's
3968
3957
  * system prompt, rendered by the daemon from a few facts about the chat and reused across chats.
@@ -4114,6 +4103,19 @@ export declare class KayAppCredentialRejectedError extends Error {
4114
4103
  readonly name = "KayAppCredentialRejectedError";
4115
4104
  }
4116
4105
 
4106
+ /** A credential for this call, or an account failure with no secret material. Never persist it. */
4107
+ export declare type KayAppCredentialResolution = {
4108
+ readonly status: "resolved";
4109
+ readonly credential: ResolvedCredential;
4110
+ } | {
4111
+ readonly status: "missing";
4112
+ readonly reason: string;
4113
+ } | {
4114
+ readonly status: "requires-auth";
4115
+ readonly reason: string;
4116
+ readonly requiredScopes?: readonly string[];
4117
+ };
4118
+
4117
4119
  export declare interface KayAppData {
4118
4120
  /**
4119
4121
  * Register the live definition behind one declared source. At most one registration per source
@@ -4359,18 +4361,17 @@ export declare interface KayAppDynamicContextSearchOptions {
4359
4361
  } | undefined;
4360
4362
  }
4361
4363
 
4362
- /**
4363
- * The app-wide endpoint bus. A plugin registers named handlers a consuming surface can invoke; the
4364
- * host routes invocations (e.g. Bonsai Desktop forwards the renderer's frame-gated call to the daemon,
4365
- * where the endpoint is single-homed). The corpus is NEVER reachable here - only what the plugin
4366
- * explicitly exposes. Both `payload` and the handler's return ride strict JSON on the wire.
4367
- */
4364
+ /** Per-invocation authority prepared from the endpoint's manifest declaration. */
4365
+ export declare interface KayAppEndpointContext {
4366
+ readonly credentials: readonly KayAppResolvedCredential[];
4367
+ readonly signal: AbortSignal;
4368
+ /** Record only a scheme from this call's credentials after its provider operation succeeds. */
4369
+ reportWorked(schemeId: string): void;
4370
+ }
4371
+
4372
+ /** The app-wide endpoint bus; payloads and returned values must be JSON. */
4368
4373
  export declare interface KayAppEndpoints {
4369
- /**
4370
- * Register a handler under `name`. Names are app-wide (open bus); a duplicate name is rejected by
4371
- * the host registry.
4372
- */
4373
- register(name: string, handler: (payload: unknown) => unknown | Promise<unknown>): void;
4374
+ register(name: string, handler: (payload: unknown, context: KayAppEndpointContext) => unknown | Promise<unknown>): void;
4374
4375
  }
4375
4376
 
4376
4377
  /**
@@ -5407,9 +5408,7 @@ export declare interface KayAppPollerOptions<Cursor extends JsonValue> {
5407
5408
  readonly poll: (input: {
5408
5409
  readonly account: KayAppAccountSummary;
5409
5410
  readonly cursor: Cursor | undefined;
5410
- readonly credential: Extract<KayAppBackgroundCredentialResult, {
5411
- readonly status: "resolved";
5412
- }>;
5411
+ readonly credential: ResolvedCredential;
5413
5412
  readonly runId: string;
5414
5413
  }) => Promise<KayAppPollResult<Cursor>>;
5415
5414
  }
@@ -5564,50 +5563,7 @@ export declare interface KayAppResolveCredentialRequest {
5564
5563
  readonly purpose: string;
5565
5564
  }
5566
5565
 
5567
- /**
5568
- * ---
5569
- * responsibility: The plugin-facing credential surface of the `kay.app` target SDK. A daemon-hosted
5570
- * plugin lists account metadata or resolves credentials for an owned or consumed auth service
5571
- * under explicit grants. Credential material is read where the work happens.
5572
- * owns:
5573
- * - {@link KayAppAuth}, {@link KayAppResolvedCredential}.
5574
- * does_not_own:
5575
- * - Acquisition, storage, refresh, or revocation. Those are the credential authority's, reached
5576
- * through the host. A plugin can only ask for material it is granted, for a purpose it declared.
5577
- * ---
5578
- *
5579
- * ## Deny-by-default
5580
- *
5581
- * `KayAppPluginApi.auth` is **present only for plugins the host grants** (`auth.operations`
5582
- * containing `"list"` or `"resolve"` in `permissions.byTarget["kay.app"]`, against an owned or consumed
5583
- * service) and `undefined` otherwise - an ungranted plugin cannot even reference the capability.
5584
- * This mirrors `KayAppPluginApi.sessions`, and it is the rule for every capability behind a grant:
5585
- * never hand a plugin an object whose grant is decorative.
5586
- *
5587
- * ## Secrets do not leave this object
5588
- *
5589
- * A resolved credential is live secret material. Never log it, never echo it into an error message,
5590
- * never put it in an event payload, never return it from an endpoint handler, and never accept it
5591
- * as a URI or config value. Read it, use it in the outbound request, drop it.
5592
- */
5593
- /**
5594
- * Live credential material for one account of one auth scheme.
5595
- *
5596
- * Shaped to match the kernel's `ResolvedCredential` so a plugin that already reads
5597
- * `ctx.auth.credential` in a URI verb reads the same thing here.
5598
- */
5599
- export declare interface KayAppResolvedCredential {
5600
- /** Bearer for OAuth schemes, the api key for api-key schemes. Host-resolved and refreshed. */
5601
- readonly accessToken: string;
5602
- readonly accountId: string;
5603
- readonly schemeId: string;
5604
- readonly scopes?: readonly string[];
5605
- /**
5606
- * Every value of a multi-field api-key credential, keyed by the scheme's declared field id
5607
- * (`accessToken` mirrors the primary field). Absent for single-secret schemes.
5608
- */
5609
- readonly fields?: Readonly<Record<string, string>>;
5610
- }
5566
+ export declare type KayAppResolvedCredential = ResolvedCredential;
5611
5567
 
5612
5568
  /** Hard limits on the routes a `tier` or `model` selection may use. */
5613
5569
  export declare interface KayAppRouteConstraints {
@@ -8145,7 +8101,7 @@ export declare interface KayAppWhiteboardTypes {
8145
8101
  */
8146
8102
  export declare interface KayAppWorkflowAccount {
8147
8103
  readonly account: KayAppAccountSummary;
8148
- readonly credential: KayAppBackgroundCredentialResult;
8104
+ readonly auth: KayAppCredentialResolution;
8149
8105
  }
8150
8106
 
8151
8107
  /**
@@ -10314,7 +10270,7 @@ export declare function requireWriteContent(payload: UriPayload | Uint8Array | u
10314
10270
  * verb (`ctx.auth.credential`), a tool (`ctx.credential`) or a search provider (`ctx.credential`).
10315
10271
  * Plain data, so it crosses a process boundary with the call; plugin code never asks for one.
10316
10272
  */
10317
- declare interface ResolvedCredential {
10273
+ export declare interface ResolvedCredential {
10318
10274
  /** Bearer for OAuth schemes, apiKey for api-key schemes. Host-resolved and refreshed. */
10319
10275
  readonly accessToken: string;
10320
10276
  readonly accountId: string;
@@ -16963,6 +16919,9 @@ declare const WithElementList_0: (input: string, result?: unknown[]) => [unknown
16963
16919
 
16964
16920
  declare function WithElementListMapping(input: [unknown, unknown, unknown] | []): unknown;
16965
16921
 
16922
+ /** Try the call's credentials in order; only credential rejection advances to the next. */
16923
+ export declare function withEndpointCredential<T>(context: KayAppEndpointContext, use: (credential: KayAppResolvedCredential) => Promise<T>): Promise<T>;
16924
+
16966
16925
  declare function WithMapping(input: [unknown, unknown] | []): unknown;
16967
16926
 
16968
16927
  declare const WithNull: (input: string) => [unknown, string] | [];
package/dist/kay-app.js CHANGED
@@ -599,11 +599,6 @@ function payload(name, schema, options = {}) {
599
599
  };
600
600
  }
601
601
 
602
- // packages/plugin-sdk/dist/kay-app/account.js
603
- function isRetryable(result) {
604
- return result.status === "not-ready";
605
- }
606
-
607
602
  // packages/plugin-sdk/dist/kay-app/auth.js
608
603
  var KayAppCredentialRejectedError = class extends Error {
609
604
  name = "KayAppCredentialRejectedError";
@@ -626,6 +621,32 @@ async function withCredential(auth, request, use) {
626
621
  throw rejection ?? new Error(`No credential is resolvable for '${request.serviceId}'.`);
627
622
  }
628
623
 
624
+ // packages/plugin-sdk/dist/kay-app/endpoints.js
625
+ async function withEndpointCredential(context, use) {
626
+ let rejection;
627
+ for (const credential of context.credentials) {
628
+ context.signal.throwIfAborted();
629
+ try {
630
+ const result = await use(credential);
631
+ try {
632
+ context.reportWorked(credential.schemeId);
633
+ } catch {
634
+ }
635
+ return result;
636
+ } catch (error) {
637
+ if (!(error instanceof KayAppCredentialRejectedError))
638
+ throw error;
639
+ rejection = error;
640
+ }
641
+ }
642
+ throw rejection ?? new Error("No credential is resolvable for this endpoint.");
643
+ }
644
+
645
+ // packages/plugin-sdk/dist/kay-app/account.js
646
+ function isRetryable(result) {
647
+ return result.status === "not-ready";
648
+ }
649
+
629
650
  // packages/plugin-sdk/dist/kay-app/automations.js
630
651
  var KAY_APP_AUTOMATION_CONDITION_KINDS = [
631
652
  "time",
@@ -715,7 +736,7 @@ function definePoller(app, localId, options) {
715
736
  let skipped = 0;
716
737
  let failed = 0;
717
738
  let refused = 0;
718
- for (const { account, credential } of accounts) {
739
+ for (const { account, auth } of accounts) {
719
740
  const saved = previous.find((entry) => entry.schemeId === account.schemeId && entry.accountId === account.accountId);
720
741
  const name = `${account.schemeId}/${account.accountId}`;
721
742
  const keepSaved = (summary) => {
@@ -723,9 +744,9 @@ function definePoller(app, localId, options) {
723
744
  next.push(saved);
724
745
  details.push(`${name}: ${summary}`);
725
746
  };
726
- if (credential.status !== "resolved") {
747
+ if (auth.status !== "resolved") {
727
748
  skipped++;
728
- keepSaved(credential.status === "requires-auth" ? "Sign-in or required scope missing" : "Credential missing");
749
+ keepSaved(auth.status === "requires-auth" ? "Sign-in or required scope missing" : "Credential missing");
729
750
  continue;
730
751
  }
731
752
  let result;
@@ -733,7 +754,7 @@ function definePoller(app, localId, options) {
733
754
  result = await options.poll({
734
755
  account,
735
756
  cursor: structuredClone(saved?.cursor),
736
- credential,
757
+ credential: auth.credential,
737
758
  runId
738
759
  });
739
760
  } catch {
@@ -964,5 +985,6 @@ export {
964
985
  transcriptMessageText,
965
986
  transcriptMessageTexts,
966
987
  transcriptRoleLabel,
967
- withCredential
988
+ withCredential,
989
+ withEndpointCredential
968
990
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@yaklabs-ai/plugin-sdk",
3
- "version": "0.41.0",
3
+ "version": "0.42.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",