@yaklabs-ai/plugin-protocol 0.31.0 → 0.33.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
@@ -11,7 +11,7 @@ flow.
11
11
  ```json
12
12
  {
13
13
  "dependencies": {
14
- "@bonsai/plugin-protocol": "npm:@yaklabs-ai/plugin-protocol@^0.31.0"
14
+ "@bonsai/plugin-protocol": "npm:@yaklabs-ai/plugin-protocol@^0.33.0"
15
15
  }
16
16
  }
17
17
  ```
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "schemaVersion": 1,
3
3
  "package": "@yaklabs-ai/plugin-protocol",
4
- "version": "0.31.0",
4
+ "version": "0.33.0",
5
5
  "target": "npm",
6
6
  "firstPartyLicense": "MIT",
7
7
  "bundled": [],
package/dist/index.d.ts CHANGED
@@ -106,6 +106,13 @@ export declare const AppDataSourceContribution: z.ZodObject<{
106
106
  schema: z.ZodRecord<z.ZodString, z.ZodType<authoringCommonSchemas.JsonValue, unknown, z.core.$ZodTypeInternals<authoringCommonSchemas.JsonValue, unknown>>>;
107
107
  }, z.core.$strict>;
108
108
  }, z.core.$strict>>;
109
+ store: z.ZodOptional<z.ZodDiscriminatedUnion<[z.ZodObject<{
110
+ shape: z.ZodLiteral<"rows">;
111
+ rowsField: z.ZodString;
112
+ key: z.ZodArray<z.ZodString>;
113
+ }, z.core.$strict>, z.ZodObject<{
114
+ shape: z.ZodLiteral<"value">;
115
+ }, z.core.$strict>], "shape">>;
109
116
  }, z.core.$strict>;
110
117
 
111
118
  export declare type AppDataSourceContribution = z.infer<typeof AppDataSourceContribution>;
@@ -2365,6 +2372,13 @@ declare const canonicalContributionSchemas: {
2365
2372
  schema: z.ZodRecord<z.ZodString, z.ZodType<authoringCommonSchemas.JsonValue, unknown, z.core.$ZodTypeInternals<authoringCommonSchemas.JsonValue, unknown>>>;
2366
2373
  }, z.core.$strict>;
2367
2374
  }, z.core.$strict>>;
2375
+ store: z.ZodOptional<z.ZodDiscriminatedUnion<[z.ZodObject<{
2376
+ shape: z.ZodLiteral<"rows">;
2377
+ rowsField: z.ZodString;
2378
+ key: z.ZodArray<z.ZodString>;
2379
+ }, z.core.$strict>, z.ZodObject<{
2380
+ shape: z.ZodLiteral<"value">;
2381
+ }, z.core.$strict>], "shape">>;
2368
2382
  }, z.core.$strict>;
2369
2383
  WhiteboardTypeStorage: z.ZodDiscriminatedUnion<[z.ZodObject<{
2370
2384
  kind: z.ZodLiteral<"json">;
@@ -2566,7 +2580,13 @@ declare const canonicalContributionSchemas: {
2566
2580
  localId: z.ZodString;
2567
2581
  title: z.ZodString;
2568
2582
  icon: z.ZodOptional<z.ZodString>;
2569
- placement: z.ZodOptional<z.ZodString>;
2583
+ button: z.ZodOptional<z.ZodEnum<{
2584
+ tabStrip: "tabStrip";
2585
+ }>>;
2586
+ menu: z.ZodOptional<z.ZodEnum<{
2587
+ help: "help";
2588
+ }>>;
2589
+ where: z.ZodOptional<z.ZodString>;
2570
2590
  }, z.core.$strict>;
2571
2591
  UiSlotContribution: z.ZodObject<{
2572
2592
  localId: z.ZodString;
@@ -2680,8 +2700,6 @@ declare const canonicalContributionSchemas: {
2680
2700
  "artifacts.preview": "artifacts.preview";
2681
2701
  "cost.read": "cost.read";
2682
2702
  "billing.read": "billing.read";
2683
- "context.read": "context.read";
2684
- "usage.read": "usage.read";
2685
2703
  "self-improvement.read": "self-improvement.read";
2686
2704
  "automations.read": "automations.read";
2687
2705
  "shared-artifacts.read": "shared-artifacts.read";
@@ -2701,8 +2719,6 @@ declare const canonicalContributionSchemas: {
2701
2719
  "artifacts.preview": "artifacts.preview";
2702
2720
  "cost.read": "cost.read";
2703
2721
  "billing.read": "billing.read";
2704
- "context.read": "context.read";
2705
- "usage.read": "usage.read";
2706
2722
  "self-improvement.read": "self-improvement.read";
2707
2723
  "automations.read": "automations.read";
2708
2724
  "shared-artifacts.read": "shared-artifacts.read";
@@ -2752,8 +2768,6 @@ declare const canonicalContributionSchemas: {
2752
2768
  "artifacts.preview": "artifacts.preview";
2753
2769
  "cost.read": "cost.read";
2754
2770
  "billing.read": "billing.read";
2755
- "context.read": "context.read";
2756
- "usage.read": "usage.read";
2757
2771
  "self-improvement.read": "self-improvement.read";
2758
2772
  "automations.read": "automations.read";
2759
2773
  "shared-artifacts.read": "shared-artifacts.read";
@@ -2790,8 +2804,6 @@ declare const canonicalContributionSchemas: {
2790
2804
  "artifacts.preview": "artifacts.preview";
2791
2805
  "cost.read": "cost.read";
2792
2806
  "billing.read": "billing.read";
2793
- "context.read": "context.read";
2794
- "usage.read": "usage.read";
2795
2807
  "self-improvement.read": "self-improvement.read";
2796
2808
  "automations.read": "automations.read";
2797
2809
  "shared-artifacts.read": "shared-artifacts.read";
@@ -2985,6 +2997,41 @@ export declare const CommandHandler: z.ZodDiscriminatedUnion<[z.ZodObject<{
2985
2997
 
2986
2998
  export declare type CommandHandler = z.infer<typeof CommandHandler>;
2987
2999
 
3000
+ export declare type CommandWhere = {
3001
+ readonly kind: "literal";
3002
+ readonly value: boolean;
3003
+ } | {
3004
+ readonly kind: "key";
3005
+ readonly key: CommandWhereKey;
3006
+ } | {
3007
+ readonly kind: "equals";
3008
+ readonly key: CommandWhereKey;
3009
+ readonly value: boolean | string;
3010
+ readonly negated: boolean;
3011
+ } | {
3012
+ readonly kind: "not";
3013
+ readonly operand: CommandWhere;
3014
+ } | {
3015
+ readonly kind: "and" | "or";
3016
+ readonly left: CommandWhere;
3017
+ readonly right: CommandWhere;
3018
+ };
3019
+
3020
+ export declare type CommandWhereKey = keyof typeof WHERE_KEY_TYPES;
3021
+
3022
+ export declare type CommandWhereParseResult = {
3023
+ readonly ok: true;
3024
+ readonly where: CommandWhere;
3025
+ } | {
3026
+ readonly ok: false;
3027
+ readonly message: string;
3028
+ };
3029
+
3030
+ /** The values a `where` reads. A key left out isn't known yet, for example while it loads. */
3031
+ export declare type CommandWhereValues = {
3032
+ readonly [K in CommandWhereKey]?: (typeof WHERE_KEY_TYPES)[K] extends "boolean" ? boolean : string;
3033
+ };
3034
+
2988
3035
  /**
2989
3036
  * Total order over claims, for deterministic projection and diffs. Compares the same fields
2990
3037
  * {@link sameClaim} compares, in a fixed order, so two claims that compare equal here are the same
@@ -3114,6 +3161,25 @@ export declare const CorpusResourceKind: z.ZodEnum<{
3114
3161
 
3115
3162
  export declare type CorpusResourceKind = z.infer<typeof CorpusResourceKind>;
3116
3163
 
3164
+ /**
3165
+ * Every plugin's declarations of one kind, each with the plugin that made it. Main and the window
3166
+ * each hold the plugins' `kay.ui` facts, and both read them through here. `contributes` crosses the
3167
+ * daemon, the protocol and main unread, so this is where it gets its type back.
3168
+ */
3169
+ export declare function declarationsOfKind<TPlugin extends {
3170
+ readonly contributes: Readonly<Record<string, unknown>>;
3171
+ }, K extends keyof UiContributes>(plugins: readonly TPlugin[], kind: K): readonly {
3172
+ readonly plugin: TPlugin;
3173
+ readonly declaration: NonNullable<UiContributes[K]>[number];
3174
+ }[];
3175
+
3176
+ /**
3177
+ * A declared command's full id. Neither part can contain `/`, so two plugins can't produce the same
3178
+ * one, and none can name an app command such as `session.interrupt`, which a plugin called `session`
3179
+ * could otherwise put a button on without implementing it.
3180
+ */
3181
+ export declare function declaredCommandId(pluginId: string, localId: string): string;
3182
+
3117
3183
  /**
3118
3184
  * The `compatibility` block as the check reads it. Structural rather than the parsed
3119
3185
  * `PluginCompatibilityManifest`, so a host can judge the block of a manifest whose other fields
@@ -3213,6 +3279,13 @@ export declare const EntityResolverContribution: z.ZodObject<{
3213
3279
 
3214
3280
  export declare type EntityResolverContribution = z.infer<typeof EntityResolverContribution>;
3215
3281
 
3282
+ /**
3283
+ * Whether a `where` holds. When the answer depends on a value not known yet the result is false,
3284
+ * so a button stays hidden while a value loads rather than flashing on: `true || app.channel == 'x'`
3285
+ * holds whatever the channel is, and `!(app.channel == 'x')` waits for it.
3286
+ */
3287
+ export declare function evaluateCommandWhere(where: CommandWhere, values: CommandWhereValues): boolean;
3288
+
3216
3289
  export declare const EventGrantRequest: z.ZodObject<{
3217
3290
  event: z.ZodString;
3218
3291
  operations: z.ZodArray<z.ZodEnum<{
@@ -3991,8 +4064,17 @@ export declare const KAY_PLUGIN_PROTOCOL_VERSION: "kay.plugin.v1";
3991
4064
  * `contributes` names each entry's title, page, shortcut and icon file. It replaces `activityRail` on a
3992
4065
  * UI app, which is stripped from a manifest that still carries it, so that manifest loses only the
3993
4066
  * rail button. A plugin that declares a rail entry declares ^0.31.0.
4067
+ *
4068
+ * 0.32.0 lets an app-data source declare its window store as data (#15891). `store` under
4069
+ * `contributes.dataSources` replaces a `kay.ui` data materializer, and a change too big for a live
4070
+ * update becomes a re-read of the snapshot. A plugin that declares a store declares ^0.32.0.
4071
+ *
4072
+ * 0.33.0 lets a plugin declare a window command with its button and menu item (#15903). `commands`
4073
+ * under `kay.ui` `contributes` names each command's title, icon file, `button`, `menu` and `where`,
4074
+ * and `api.implementCommand(localId, handler)` supplies what it does. `placement` is gone and `icon`
4075
+ * is now a file path: nothing ever read either. A plugin that declares a command declares ^0.33.0.
3994
4076
  */
3995
- export declare const KAY_PLUGIN_SDK_VERSION: "0.31.0";
4077
+ export declare const KAY_PLUGIN_SDK_VERSION: "0.33.0";
3996
4078
 
3997
4079
  export declare const KAY_PLUGIN_TARGET_NAMES: readonly ["kay.agent", "kay.app", "kay.ui"];
3998
4080
 
@@ -4491,6 +4573,13 @@ export declare const KayAppTargetManifest: z.ZodObject<{
4491
4573
  schema: z.ZodRecord<z.ZodString, z.ZodType<authoringCommonSchemas.JsonValue, unknown, z.core.$ZodTypeInternals<authoringCommonSchemas.JsonValue, unknown>>>;
4492
4574
  }, z.core.$strict>;
4493
4575
  }, z.core.$strict>>;
4576
+ store: z.ZodOptional<z.ZodDiscriminatedUnion<[z.ZodObject<{
4577
+ shape: z.ZodLiteral<"rows">;
4578
+ rowsField: z.ZodString;
4579
+ key: z.ZodArray<z.ZodString>;
4580
+ }, z.core.$strict>, z.ZodObject<{
4581
+ shape: z.ZodLiteral<"value">;
4582
+ }, z.core.$strict>], "shape">>;
4494
4583
  }, z.core.$strict>>>;
4495
4584
  whiteboardTypes: z.ZodOptional<z.ZodArray<z.ZodObject<{
4496
4585
  localId: z.ZodString;
@@ -5255,6 +5344,13 @@ export declare const KayPluginManifestV1: z.ZodObject<{
5255
5344
  schema: z.ZodRecord<z.ZodString, z.ZodType<authoringCommonSchemas.JsonValue, unknown, z.core.$ZodTypeInternals<authoringCommonSchemas.JsonValue, unknown>>>;
5256
5345
  }, z.core.$strict>;
5257
5346
  }, z.core.$strict>>;
5347
+ store: z.ZodOptional<z.ZodDiscriminatedUnion<[z.ZodObject<{
5348
+ shape: z.ZodLiteral<"rows">;
5349
+ rowsField: z.ZodString;
5350
+ key: z.ZodArray<z.ZodString>;
5351
+ }, z.core.$strict>, z.ZodObject<{
5352
+ shape: z.ZodLiteral<"value">;
5353
+ }, z.core.$strict>], "shape">>;
5258
5354
  }, z.core.$strict>>>;
5259
5355
  whiteboardTypes: z.ZodOptional<z.ZodArray<z.ZodObject<{
5260
5356
  localId: z.ZodString;
@@ -5442,7 +5538,13 @@ export declare const KayPluginManifestV1: z.ZodObject<{
5442
5538
  localId: z.ZodString;
5443
5539
  title: z.ZodString;
5444
5540
  icon: z.ZodOptional<z.ZodString>;
5445
- placement: z.ZodOptional<z.ZodString>;
5541
+ button: z.ZodOptional<z.ZodEnum<{
5542
+ tabStrip: "tabStrip";
5543
+ }>>;
5544
+ menu: z.ZodOptional<z.ZodEnum<{
5545
+ help: "help";
5546
+ }>>;
5547
+ where: z.ZodOptional<z.ZodString>;
5446
5548
  }, z.core.$strict>>>;
5447
5549
  slots: z.ZodOptional<z.ZodArray<z.ZodObject<{
5448
5550
  localId: z.ZodString;
@@ -5530,8 +5632,6 @@ export declare const KayPluginManifestV1: z.ZodObject<{
5530
5632
  "artifacts.preview": "artifacts.preview";
5531
5633
  "cost.read": "cost.read";
5532
5634
  "billing.read": "billing.read";
5533
- "context.read": "context.read";
5534
- "usage.read": "usage.read";
5535
5635
  "self-improvement.read": "self-improvement.read";
5536
5636
  "automations.read": "automations.read";
5537
5637
  "shared-artifacts.read": "shared-artifacts.read";
@@ -5568,8 +5668,6 @@ export declare const KayPluginManifestV1: z.ZodObject<{
5568
5668
  "artifacts.preview": "artifacts.preview";
5569
5669
  "cost.read": "cost.read";
5570
5670
  "billing.read": "billing.read";
5571
- "context.read": "context.read";
5572
- "usage.read": "usage.read";
5573
5671
  "self-improvement.read": "self-improvement.read";
5574
5672
  "automations.read": "automations.read";
5575
5673
  "shared-artifacts.read": "shared-artifacts.read";
@@ -6417,8 +6515,6 @@ export declare const KayUiAppHostCapability: z.ZodEnum<{
6417
6515
  "artifacts.preview": "artifacts.preview";
6418
6516
  "cost.read": "cost.read";
6419
6517
  "billing.read": "billing.read";
6420
- "context.read": "context.read";
6421
- "usage.read": "usage.read";
6422
6518
  "self-improvement.read": "self-improvement.read";
6423
6519
  "automations.read": "automations.read";
6424
6520
  "shared-artifacts.read": "shared-artifacts.read";
@@ -6536,7 +6632,13 @@ export declare const KayUiTargetManifest: z.ZodObject<{
6536
6632
  localId: z.ZodString;
6537
6633
  title: z.ZodString;
6538
6634
  icon: z.ZodOptional<z.ZodString>;
6539
- placement: z.ZodOptional<z.ZodString>;
6635
+ button: z.ZodOptional<z.ZodEnum<{
6636
+ tabStrip: "tabStrip";
6637
+ }>>;
6638
+ menu: z.ZodOptional<z.ZodEnum<{
6639
+ help: "help";
6640
+ }>>;
6641
+ where: z.ZodOptional<z.ZodString>;
6540
6642
  }, z.core.$strict>>>;
6541
6643
  slots: z.ZodOptional<z.ZodArray<z.ZodObject<{
6542
6644
  localId: z.ZodString;
@@ -6624,8 +6726,6 @@ export declare const KayUiTargetManifest: z.ZodObject<{
6624
6726
  "artifacts.preview": "artifacts.preview";
6625
6727
  "cost.read": "cost.read";
6626
6728
  "billing.read": "billing.read";
6627
- "context.read": "context.read";
6628
- "usage.read": "usage.read";
6629
6729
  "self-improvement.read": "self-improvement.read";
6630
6730
  "automations.read": "automations.read";
6631
6731
  "shared-artifacts.read": "shared-artifacts.read";
@@ -6662,8 +6762,6 @@ export declare const KayUiTargetManifest: z.ZodObject<{
6662
6762
  "artifacts.preview": "artifacts.preview";
6663
6763
  "cost.read": "cost.read";
6664
6764
  "billing.read": "billing.read";
6665
- "context.read": "context.read";
6666
- "usage.read": "usage.read";
6667
6765
  "self-improvement.read": "self-improvement.read";
6668
6766
  "automations.read": "automations.read";
6669
6767
  "shared-artifacts.read": "shared-artifacts.read";
@@ -6854,6 +6952,12 @@ export declare function parseArtifactProvenanceCaptureContext(input: unknown): A
6854
6952
  /** Returns an owned value snapshot; callers must not attach live session references. */
6855
6953
  export declare function parseArtifactProvenanceEnvelope(input: unknown): ArtifactProvenanceEnvelopeV1;
6856
6954
 
6955
+ /**
6956
+ * Parses a declared command's `where`: `||`, `&&`, `!`, parentheses, `==`, `!=`, strings, `true`,
6957
+ * `false` and dotted keys, for example `account.signedIn || app.channel != 'production'`.
6958
+ */
6959
+ export declare function parseCommandWhere(source: string): CommandWhereParseResult;
6960
+
6857
6961
  /** A `MAJOR.MINOR.PATCH` version broken into its comparable parts. */
6858
6962
  export declare interface ParsedSemver {
6859
6963
  readonly major: number;
@@ -10639,6 +10743,13 @@ export declare const ResolvedKayAppDataSource: z.ZodObject<{
10639
10743
  schema: z.ZodRecord<z.ZodString, z.ZodType<authoringCommonSchemas.JsonValue, unknown, z.core.$ZodTypeInternals<authoringCommonSchemas.JsonValue, unknown>>>;
10640
10744
  }, z.core.$strict>;
10641
10745
  }, z.core.$strict>>;
10746
+ store: z.ZodOptional<z.ZodDiscriminatedUnion<[z.ZodObject<{
10747
+ shape: z.ZodLiteral<"rows">;
10748
+ rowsField: z.ZodString;
10749
+ key: z.ZodArray<z.ZodString>;
10750
+ }, z.core.$strict>, z.ZodObject<{
10751
+ shape: z.ZodLiteral<"value">;
10752
+ }, z.core.$strict>], "shape">>;
10642
10753
  }, z.core.$strict>;
10643
10754
 
10644
10755
  export declare type ResolvedKayAppDataSource = z.infer<typeof ResolvedKayAppDataSource>;
@@ -10733,8 +10844,6 @@ export declare const ResolvedKayUiApp: z.ZodObject<{
10733
10844
  "artifacts.preview": "artifacts.preview";
10734
10845
  "cost.read": "cost.read";
10735
10846
  "billing.read": "billing.read";
10736
- "context.read": "context.read";
10737
- "usage.read": "usage.read";
10738
10847
  "self-improvement.read": "self-improvement.read";
10739
10848
  "automations.read": "automations.read";
10740
10849
  "shared-artifacts.read": "shared-artifacts.read";
@@ -11911,6 +12020,13 @@ export declare const ResolvedPluginContractV1: z.ZodObject<{
11911
12020
  schema: z.ZodRecord<z.ZodString, z.ZodType<authoringCommonSchemas.JsonValue, unknown, z.core.$ZodTypeInternals<authoringCommonSchemas.JsonValue, unknown>>>;
11912
12021
  }, z.core.$strict>;
11913
12022
  }, z.core.$strict>>;
12023
+ store: z.ZodOptional<z.ZodDiscriminatedUnion<[z.ZodObject<{
12024
+ shape: z.ZodLiteral<"rows">;
12025
+ rowsField: z.ZodString;
12026
+ key: z.ZodArray<z.ZodString>;
12027
+ }, z.core.$strict>, z.ZodObject<{
12028
+ shape: z.ZodLiteral<"value">;
12029
+ }, z.core.$strict>], "shape">>;
11914
12030
  }, z.core.$strict>>>;
11915
12031
  kayAppWhiteboardTypes: z.ZodOptional<z.ZodArray<z.ZodObject<{
11916
12032
  localId: z.ZodString;
@@ -12020,8 +12136,6 @@ export declare const ResolvedPluginContractV1: z.ZodObject<{
12020
12136
  "artifacts.preview": "artifacts.preview";
12021
12137
  "cost.read": "cost.read";
12022
12138
  "billing.read": "billing.read";
12023
- "context.read": "context.read";
12024
- "usage.read": "usage.read";
12025
12139
  "self-improvement.read": "self-improvement.read";
12026
12140
  "automations.read": "automations.read";
12027
12141
  "shared-artifacts.read": "shared-artifacts.read";
@@ -13606,8 +13720,6 @@ export declare const UiAppCapabilities: z.ZodObject<{
13606
13720
  "artifacts.preview": "artifacts.preview";
13607
13721
  "cost.read": "cost.read";
13608
13722
  "billing.read": "billing.read";
13609
- "context.read": "context.read";
13610
- "usage.read": "usage.read";
13611
13723
  "self-improvement.read": "self-improvement.read";
13612
13724
  "automations.read": "automations.read";
13613
13725
  "shared-artifacts.read": "shared-artifacts.read";
@@ -13647,8 +13759,6 @@ export declare const UiAppContribution: z.ZodObject<{
13647
13759
  "artifacts.preview": "artifacts.preview";
13648
13760
  "cost.read": "cost.read";
13649
13761
  "billing.read": "billing.read";
13650
- "context.read": "context.read";
13651
- "usage.read": "usage.read";
13652
13762
  "self-improvement.read": "self-improvement.read";
13653
13763
  "automations.read": "automations.read";
13654
13764
  "shared-artifacts.read": "shared-artifacts.read";
@@ -13685,8 +13795,6 @@ export declare const UiAppContribution: z.ZodObject<{
13685
13795
  "artifacts.preview": "artifacts.preview";
13686
13796
  "cost.read": "cost.read";
13687
13797
  "billing.read": "billing.read";
13688
- "context.read": "context.read";
13689
- "usage.read": "usage.read";
13690
13798
  "self-improvement.read": "self-improvement.read";
13691
13799
  "automations.read": "automations.read";
13692
13800
  "shared-artifacts.read": "shared-artifacts.read";
@@ -13703,11 +13811,19 @@ export declare const UiCommandContribution: z.ZodObject<{
13703
13811
  localId: z.ZodString;
13704
13812
  title: z.ZodString;
13705
13813
  icon: z.ZodOptional<z.ZodString>;
13706
- placement: z.ZodOptional<z.ZodString>;
13814
+ button: z.ZodOptional<z.ZodEnum<{
13815
+ tabStrip: "tabStrip";
13816
+ }>>;
13817
+ menu: z.ZodOptional<z.ZodEnum<{
13818
+ help: "help";
13819
+ }>>;
13820
+ where: z.ZodOptional<z.ZodString>;
13707
13821
  }, z.core.$strict>;
13708
13822
 
13709
13823
  export declare type UiCommandContribution = z.infer<typeof UiCommandContribution>;
13710
13824
 
13825
+ declare type UiContributes = NonNullable<KayUiTargetManifest["contributes"]>;
13826
+
13711
13827
  export declare const UiEventSubscriptionContribution: z.ZodObject<{
13712
13828
  localId: z.ZodString;
13713
13829
  event: z.ZodString;
@@ -14128,6 +14244,12 @@ export declare type WebSessionGrantRequest = z.infer<typeof WebSessionGrantReque
14128
14244
  */
14129
14245
  export declare function webSessionPathWithinPrefix(pathname: string, pathPrefix: string): boolean;
14130
14246
 
14247
+ /** What a `where` expression can read, and the type of each. */
14248
+ declare const WHERE_KEY_TYPES: {
14249
+ readonly "account.signedIn": "boolean";
14250
+ readonly "app.channel": "string";
14251
+ };
14252
+
14131
14253
  /** Construct the exact claim row for one Whiteboard scope and operation. */
14132
14254
  export declare function whiteboardCapabilityClaim(operation: WhiteboardCapabilityOperation, scope: WhiteboardCapabilityScope, target?: "kay.agent"): WhiteboardCapabilityClaimV1;
14133
14255
 
package/dist/index.js CHANGED
@@ -13,7 +13,15 @@ var KAY_APP_DATA_READ_RESULT_MAX_BYTES = 16 * 1024 * 1024;
13
13
  // packages/plugin-protocol/dist/ui-icon-paths.js
14
14
  function declaredUiIconPaths(manifest) {
15
15
  const contributes = manifest.targets?.kay?.ui?.contributes;
16
- return (contributes?.railEntries ?? []).flatMap((entry) => entry.icon === void 0 ? [] : [{ label: `kay.ui rail entry '${entry.id}' icon`, path: entry.icon }]);
16
+ return [
17
+ ...(contributes?.railEntries ?? []).flatMap((entry) => entry.icon === void 0 ? [] : [{ label: `kay.ui rail entry '${entry.id}' icon`, path: entry.icon }]),
18
+ ...(contributes?.commands ?? []).flatMap((command) => command.icon === void 0 ? [] : [
19
+ {
20
+ label: `kay.ui command '${command.localId}' icon`,
21
+ path: command.icon
22
+ }
23
+ ])
24
+ ];
17
25
  }
18
26
 
19
27
  // packages/plugin-protocol/dist/approval-types.js
@@ -230,13 +238,15 @@ var JsonSchema = z4.record(z4.string(), JsonValue);
230
238
  var KAY_PLUGIN_MANIFEST_SIZE_CAP_BYTES = 1024 * 1024;
231
239
  var KAY_PLUGIN_PROTOCOL_VERSION = "kay.plugin.v1";
232
240
  var KAY_PLUGIN_PROTOCOL_PACKAGE_NAME = "@bonsai/plugin-protocol";
233
- var KAY_PLUGIN_SDK_VERSION = "0.31.0";
241
+ var KAY_PLUGIN_SDK_VERSION = "0.33.0";
234
242
  var KAY_PLUGIN_COMPATIBLE_SDK_VERSIONS = [
235
243
  "0.26.3",
236
244
  "0.27.1",
237
245
  "0.28.0",
238
246
  "0.29.0",
239
- "0.30.0"
247
+ "0.30.0",
248
+ "0.31.0",
249
+ "0.32.0"
240
250
  ];
241
251
  var KAY_PLUGIN_TARGET_NAMES = [
242
252
  "kay.agent",
@@ -2822,6 +2832,165 @@ function createPluginEventsSchemas(canonical) {
2822
2832
  var { PluginEventLocalId, PluginEventUri, PluginEventTimestamp, PluginEventRelated, PluginEventPublishSource, PluginEventSource, PluginEventId, PluginEventPublishInput, PluginEventEnvelope } = createPluginEventsSchemas(false);
2823
2833
  var canonicalPluginEventSchemas = createPluginEventsSchemas(true);
2824
2834
 
2835
+ // packages/plugin-protocol/dist/declared-commands.js
2836
+ function declarationsOfKind(plugins, kind) {
2837
+ return plugins.flatMap((plugin) => (plugin.contributes[kind] ?? []).map((declaration) => ({
2838
+ plugin,
2839
+ declaration
2840
+ })));
2841
+ }
2842
+ function declaredCommandId(pluginId, localId) {
2843
+ return `${pluginId}/${localId}`;
2844
+ }
2845
+ var WHERE_KEY_TYPES = {
2846
+ "account.signedIn": "boolean",
2847
+ "app.channel": "string"
2848
+ };
2849
+ var TOKEN = /\s*(?:(\|\||&&|==|!=|!|\(|\))|'([^']*)'|"([^"]*)"|([A-Za-z][A-Za-z0-9]*(?:\.[A-Za-z][A-Za-z0-9]*)*))/y;
2850
+ function tokenize(source) {
2851
+ const tokens = [];
2852
+ TOKEN.lastIndex = 0;
2853
+ while (source.slice(TOKEN.lastIndex).trim() !== "") {
2854
+ const start = TOKEN.lastIndex;
2855
+ const match = TOKEN.exec(source);
2856
+ if (match === null) {
2857
+ throw new Error(`unexpected text at '${source.slice(start).trim()}'`);
2858
+ }
2859
+ const [, operator, single, double, word] = match;
2860
+ if (operator !== void 0)
2861
+ tokens.push({ kind: "operator", text: operator });
2862
+ else if (word !== void 0)
2863
+ tokens.push({ kind: "word", text: word });
2864
+ else
2865
+ tokens.push({ kind: "string", text: single ?? double ?? "" });
2866
+ }
2867
+ return tokens;
2868
+ }
2869
+ function isKey(text) {
2870
+ return Object.hasOwn(WHERE_KEY_TYPES, text);
2871
+ }
2872
+ function parseTokens(tokens) {
2873
+ let position = 0;
2874
+ const takeOperator = (text) => {
2875
+ const token = tokens[position];
2876
+ if (token?.kind !== "operator" || token.text !== text)
2877
+ return false;
2878
+ position += 1;
2879
+ return true;
2880
+ };
2881
+ const parseOr = () => {
2882
+ let left = parseAnd();
2883
+ while (takeOperator("||"))
2884
+ left = { kind: "or", left, right: parseAnd() };
2885
+ return left;
2886
+ };
2887
+ const parseAnd = () => {
2888
+ let left = parseNot();
2889
+ while (takeOperator("&&"))
2890
+ left = { kind: "and", left, right: parseNot() };
2891
+ return left;
2892
+ };
2893
+ const parseNot = () => takeOperator("!") ? { kind: "not", operand: parseNot() } : parseAtom();
2894
+ const parseAtom = () => {
2895
+ if (takeOperator("(")) {
2896
+ const inner = parseOr();
2897
+ if (!takeOperator(")"))
2898
+ throw new Error("missing ')'");
2899
+ return inner;
2900
+ }
2901
+ const token = tokens[position];
2902
+ if (token === void 0)
2903
+ throw new Error("the expression ends too soon");
2904
+ position += 1;
2905
+ if (token.kind === "word" && token.text === "true") {
2906
+ return { kind: "literal", value: true };
2907
+ }
2908
+ if (token.kind === "word" && token.text === "false") {
2909
+ return { kind: "literal", value: false };
2910
+ }
2911
+ if (token.kind !== "word")
2912
+ throw new Error(`unexpected '${token.text}'`);
2913
+ if (!isKey(token.text)) {
2914
+ throw new Error(`unknown key '${token.text}'; the keys are ${Object.keys(WHERE_KEY_TYPES).join(", ")}`);
2915
+ }
2916
+ return parseKeyAtom(token.text);
2917
+ };
2918
+ const parseKeyAtom = (key) => {
2919
+ const negated = takeOperator("!=");
2920
+ if (!negated && !takeOperator("==")) {
2921
+ if (WHERE_KEY_TYPES[key] !== "boolean") {
2922
+ throw new Error(`'${key}' must be compared, with == or !=`);
2923
+ }
2924
+ return { kind: "key", key };
2925
+ }
2926
+ const value = parseLiteral();
2927
+ if (typeof value !== WHERE_KEY_TYPES[key]) {
2928
+ throw new Error(`'${key}' compares to a ${WHERE_KEY_TYPES[key]}`);
2929
+ }
2930
+ return { kind: "equals", key, value, negated };
2931
+ };
2932
+ const parseLiteral = () => {
2933
+ const token = tokens[position];
2934
+ position += 1;
2935
+ if (token?.kind === "string")
2936
+ return token.text;
2937
+ if (token?.kind === "word" && token.text === "true")
2938
+ return true;
2939
+ if (token?.kind === "word" && token.text === "false")
2940
+ return false;
2941
+ throw new Error("expected a string, true or false after == or !=");
2942
+ };
2943
+ const where = parseOr();
2944
+ const extra = tokens[position];
2945
+ if (extra !== void 0)
2946
+ throw new Error(`unexpected '${extra.text}'`);
2947
+ return where;
2948
+ }
2949
+ function parseCommandWhere(source) {
2950
+ try {
2951
+ return { ok: true, where: parseTokens(tokenize(source)) };
2952
+ } catch (error) {
2953
+ return { ok: false, message: error.message };
2954
+ }
2955
+ }
2956
+ function resolve(where, values) {
2957
+ switch (where.kind) {
2958
+ case "literal":
2959
+ return where.value;
2960
+ case "key": {
2961
+ const value = values[where.key];
2962
+ return value === void 0 ? void 0 : value === true;
2963
+ }
2964
+ case "equals": {
2965
+ const value = values[where.key];
2966
+ if (value === void 0)
2967
+ return void 0;
2968
+ return value === where.value !== where.negated;
2969
+ }
2970
+ case "not": {
2971
+ const operand = resolve(where.operand, values);
2972
+ return operand === void 0 ? void 0 : !operand;
2973
+ }
2974
+ case "and": {
2975
+ const left = resolve(where.left, values);
2976
+ const right = resolve(where.right, values);
2977
+ if (left === false || right === false)
2978
+ return false;
2979
+ return left === void 0 || right === void 0 ? void 0 : true;
2980
+ }
2981
+ case "or": {
2982
+ const left = resolve(where.left, values);
2983
+ const right = resolve(where.right, values);
2984
+ if (left === true || right === true)
2985
+ return true;
2986
+ return left === void 0 || right === void 0 ? void 0 : false;
2987
+ }
2988
+ }
2989
+ }
2990
+ function evaluateCommandWhere(where, values) {
2991
+ return resolve(where, values) === true;
2992
+ }
2993
+
2825
2994
  // packages/plugin-protocol/dist/contributions.js
2826
2995
  var MCP_SERVER_LOCAL_HTTP_HOSTNAMES = /* @__PURE__ */ new Set(["localhost", "127.0.0.1"]);
2827
2996
  var MCP_SIGN_IN_SCHEME_KIND = {
@@ -3095,6 +3264,14 @@ function createContributionsSchemas(canonical) {
3095
3264
  knownResources: true,
3096
3265
  describesOperations: true
3097
3266
  });
3267
+ const AppDataSourceStore = z12.discriminatedUnion("shape", [
3268
+ z12.strictObject({
3269
+ shape: z12.literal("rows"),
3270
+ rowsField: NonEmptyString3,
3271
+ key: z12.array(NonEmptyString3).min(1)
3272
+ }),
3273
+ z12.strictObject({ shape: z12.literal("value") })
3274
+ ]);
3098
3275
  const AppDataSourceContribution2 = z12.strictObject({
3099
3276
  localId: LocalContributionId2,
3100
3277
  scope: z12.enum(["runtime", "account", "session"]),
@@ -3115,7 +3292,8 @@ function createContributionsSchemas(canonical) {
3115
3292
  })
3116
3293
  ]).optional()
3117
3294
  }),
3118
- read: AppDataSourceRead.optional()
3295
+ read: AppDataSourceRead.optional(),
3296
+ store: AppDataSourceStore.optional()
3119
3297
  }).superRefine((source, ctx) => {
3120
3298
  if (source.read !== void 0 && source.scope !== "session") {
3121
3299
  ctx.addIssue({
@@ -3124,6 +3302,23 @@ function createContributionsSchemas(canonical) {
3124
3302
  message: "App-data read operations require session scope."
3125
3303
  });
3126
3304
  }
3305
+ if (source.store === void 0)
3306
+ return;
3307
+ if (source.scope === "session") {
3308
+ ctx.addIssue({
3309
+ code: "custom",
3310
+ path: ["store"],
3311
+ message: "A declared app-data store requires runtime or account scope."
3312
+ });
3313
+ }
3314
+ const replaces = source.change.semantics?.kind === "snapshot-replacement";
3315
+ if (replaces !== (source.store.shape === "value")) {
3316
+ ctx.addIssue({
3317
+ code: "custom",
3318
+ path: ["store"],
3319
+ message: "A value store requires snapshot-replacement changes, and a rows store forbids them."
3320
+ });
3321
+ }
3127
3322
  });
3128
3323
  const WhiteboardTypeStorage2 = z12.discriminatedUnion("kind", [
3129
3324
  z12.strictObject({ kind: z12.literal("json") }),
@@ -3376,8 +3571,28 @@ function createContributionsSchemas(canonical) {
3376
3571
  const UiCommandContribution2 = z12.strictObject({
3377
3572
  localId: LocalContributionId2,
3378
3573
  title: NonEmptyString3,
3379
- icon: NonEmptyString3.optional(),
3380
- placement: NonEmptyString3.optional()
3574
+ icon: PackageAssetPath2.optional(),
3575
+ button: z12.enum(["tabStrip"]).optional(),
3576
+ menu: z12.enum(["help"]).optional(),
3577
+ where: NonEmptyString3.optional()
3578
+ }).superRefine((command, ctx) => {
3579
+ if (command.where === void 0)
3580
+ return;
3581
+ if (command.button === void 0) {
3582
+ ctx.addIssue({
3583
+ code: "custom",
3584
+ path: ["where"],
3585
+ message: `command ${command.localId} declares where without a button: where only decides when a button shows`
3586
+ });
3587
+ }
3588
+ const parsed = parseCommandWhere(command.where);
3589
+ if (!parsed.ok) {
3590
+ ctx.addIssue({
3591
+ code: "custom",
3592
+ path: ["where"],
3593
+ message: `command ${command.localId} has an invalid where: ${parsed.message}`
3594
+ });
3595
+ }
3381
3596
  });
3382
3597
  const UiSlotContribution2 = z12.strictObject({
3383
3598
  localId: LocalContributionId2,
@@ -3462,16 +3677,9 @@ function createContributionsSchemas(canonical) {
3462
3677
  "cost.read",
3463
3678
  // Server-rated organization billing, distinct from local/provider cost.
3464
3679
  "billing.read",
3465
- // Context, Skills, and Memory analytics reads (full snapshots via the capability broker).
3466
- "context.read",
3680
+ // Skills and Memory analytics reads (full snapshots via the capability broker).
3467
3681
  "skills.read",
3468
3682
  "memory.read",
3469
- // The "session trees" lens: root-session USD/token roll-ups from the
3470
- // typed usage-query surface (telemetry-unification RFC Phase 3, PR 3
3471
- // contract `docs/telemetry-lane-pr3-contracts.md`, amendment A7). Follows
3472
- // the `cost.read`/`context.read`/`skills.read`/`memory.read` convention -
3473
- // names the data (`usage`), not the tab that happens to render it.
3474
- "usage.read",
3475
3683
  // The self-improvement lens: reads the telemetry lane's self-improvement rollup
3476
3684
  // (memory/skill/notebook activity). Follows the same "names the data" convention.
3477
3685
  "self-improvement.read",
@@ -4190,9 +4398,7 @@ function createManifestSchemas(canonical) {
4190
4398
  */
4191
4399
  description: NonEmptyString3,
4192
4400
  // Display icons resolved relative to the package root and traversal-guarded
4193
- // by `PackageAssetPath`. This is a *raster/asset* icon - distinct from the
4194
- // *symbolic* `UiCommandContribution.icon` (an icon-set name), see LEXICON
4195
- // `icon`. By default the host treats the SVG as a mark and frames it, inset
4401
+ // by `PackageAssetPath`. By default the host treats the SVG as a mark and frames it, inset
4196
4402
  // on a white tile. An SVG whose artwork is already a complete tile (its own
4197
4403
  // background, edge to edge) says so with `data-icon-shape="tile"` on its
4198
4404
  // root `<svg>` element, and the host then draws it full-bleed in its tile
@@ -4291,6 +4497,7 @@ function createManifestSchemas(canonical) {
4291
4497
  }
4292
4498
  reportDuplicateLocalIds(ctx, ["targets", "kay", "app", "contributes", "notificationRules"], manifest.targets?.kay?.app?.contributes?.notificationRules, "notification rule");
4293
4499
  const declaredAppDataSources = new Set(manifest.targets?.kay?.app?.contributes?.dataSources?.map((source) => source.localId) ?? []);
4500
+ const declaredAppDataStores = new Set(manifest.targets?.kay?.app?.contributes?.dataSources?.filter((source) => source.store !== void 0).map((source) => source.localId) ?? []);
4294
4501
  const materializedAppDataSources = /* @__PURE__ */ new Set();
4295
4502
  for (const [index, materializer] of (manifest.targets?.kay?.ui?.contributes?.dataMaterializers ?? []).entries()) {
4296
4503
  if (!declaredAppDataSources.has(materializer.source)) {
@@ -4323,15 +4530,30 @@ function createManifestSchemas(canonical) {
4323
4530
  message: `app-data source ${materializer.source} has more than one materializer`
4324
4531
  });
4325
4532
  }
4533
+ if (declaredAppDataStores.has(materializer.source)) {
4534
+ ctx.addIssue({
4535
+ code: "custom",
4536
+ path: [
4537
+ "targets",
4538
+ "kay",
4539
+ "ui",
4540
+ "contributes",
4541
+ "dataMaterializers",
4542
+ index,
4543
+ "source"
4544
+ ],
4545
+ message: `app-data source ${materializer.source} declares a store and a materializer`
4546
+ });
4547
+ }
4326
4548
  materializedAppDataSources.add(materializer.source);
4327
4549
  }
4328
4550
  for (const source of declaredAppDataSources) {
4329
- if (materializedAppDataSources.has(source))
4551
+ if (materializedAppDataSources.has(source) || declaredAppDataStores.has(source))
4330
4552
  continue;
4331
4553
  ctx.addIssue({
4332
4554
  code: "custom",
4333
4555
  path: ["targets", "kay", "app", "contributes", "dataSources"],
4334
- message: `app-data source ${source} has no same-plugin UI materializer`
4556
+ message: `app-data source ${source} has no declared store and no same-plugin UI materializer`
4335
4557
  });
4336
4558
  }
4337
4559
  reportDuplicateLocalIds(ctx, ["targets", "kay", "app", "contributes", "whiteboardTypes"], manifest.targets?.kay?.app?.contributes?.whiteboardTypes, "Whiteboard type");
@@ -4395,6 +4617,7 @@ function createManifestSchemas(canonical) {
4395
4617
  presentationByUriModule.set(presentation.uriModule, presentation.localId);
4396
4618
  }
4397
4619
  }
4620
+ reportDuplicateLocalIds(ctx, ["targets", "kay", "ui", "contributes", "commands"], manifest.targets?.kay?.ui?.contributes?.commands, "ui command");
4398
4621
  reportDuplicateLocalIds(ctx, ["targets", "kay", "ui", "contributes", "referencePresentations"], manifest.targets?.kay?.ui?.contributes?.referencePresentations, "reference presentation");
4399
4622
  reportDuplicateLocalIds(ctx, ["targets", "kay", "app", "contributes", "eventDefinitions"], manifest.targets?.kay?.app?.contributes?.eventDefinitions, "plugin event definition");
4400
4623
  reportDuplicateLocalIds(ctx, ["targets", "kay", "app", "contributes", "contextContributors"], manifest.targets?.kay?.app?.contributes?.contextContributors, "context contributor");
@@ -5128,7 +5351,15 @@ function createResolvedContractSchemas(canonical) {
5128
5351
  })
5129
5352
  ]).optional()
5130
5353
  }),
5131
- read: AppDataSourceRead.optional()
5354
+ read: AppDataSourceRead.optional(),
5355
+ store: z14.discriminatedUnion("shape", [
5356
+ z14.strictObject({
5357
+ shape: z14.literal("rows"),
5358
+ rowsField: z14.string().min(1),
5359
+ key: z14.array(z14.string().min(1)).min(1)
5360
+ }),
5361
+ z14.strictObject({ shape: z14.literal("value") })
5362
+ ]).optional()
5132
5363
  }).superRefine((source, ctx) => {
5133
5364
  if (source.read !== void 0 && source.scope !== "session") {
5134
5365
  ctx.addIssue({
@@ -5769,7 +6000,8 @@ function resolveKayPluginContractV1(manifest) {
5769
6000
  scope: source.scope,
5770
6001
  snapshot: source.snapshot,
5771
6002
  change: source.change,
5772
- ...source.read === void 0 ? {} : { read: source.read }
6003
+ ...source.read === void 0 ? {} : { read: source.read },
6004
+ ...source.store === void 0 ? {} : { store: source.store }
5773
6005
  }));
5774
6006
  const kayAppApprovalTypes = manifest.targets?.kay?.app?.contributes?.approvalTypes?.map(({ uriModule, ...type }) => {
5775
6007
  const authService = manifest.targets?.kay?.agent?.contributes?.uriModules?.find((candidate) => candidate.localId === uriModule)?.authService;
@@ -6875,9 +7107,12 @@ export {
6875
7107
  compareClaims,
6876
7108
  compareSemver,
6877
7109
  configSectionKeysForManifest,
7110
+ declarationsOfKind,
7111
+ declaredCommandId,
6878
7112
  declaredUiIconPaths,
6879
7113
  dedupeClaims,
6880
7114
  deriveDirectoryPluginToolName,
7115
+ evaluateCommandWhere,
6881
7116
  finalizeArtifactProvenanceEnvelope,
6882
7117
  findSkillSuggestionCitations,
6883
7118
  hasClaim,
@@ -6899,6 +7134,7 @@ export {
6899
7134
  parseArtifactOutputUri,
6900
7135
  parseArtifactProvenanceCaptureContext,
6901
7136
  parseArtifactProvenanceEnvelope,
7137
+ parseCommandWhere,
6902
7138
  parseKayPluginManifestV1,
6903
7139
  parseKayUiAppPackageV1,
6904
7140
  parseKayUiBundleIndexV1,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@yaklabs-ai/plugin-protocol",
3
- "version": "0.31.0",
3
+ "version": "0.33.0",
4
4
  "description": "The Kay plugin manifest schema (`kay.plugin.v1`) — parse and validate a kay-plugin.json.",
5
5
  "author": "YakLabs",
6
6
  "type": "module",