@yaklabs-ai/plugin-sdk 0.48.0 → 0.48.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/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.48.0"
16
+ "@bonsai/plugin-sdk": "npm:@yaklabs-ai/plugin-sdk@^0.48.1"
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.48.0" },
65
+ "compatibility": { "sdk": "^0.48.1" },
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.48.0",
4
+ "version": "0.48.1",
5
5
  "target": "npm",
6
6
  "firstPartyLicense": "MIT",
7
7
  "bundled": [
@@ -2446,8 +2446,10 @@ declare const KAY_PLUGIN_PROTOCOL_VERSION: "kay.plugin.v1";
2446
2446
  * 0.47.0 adds card layouts and builders; successful card submits now require a summary.
2447
2447
  *
2448
2448
  * 0.48.0 adds the models.complete UI capability.
2449
+ *
2450
+ * 0.48.1 adds app-tool metadata, conditional tool permissions and screen-action declarations.
2449
2451
  */
2450
- declare const KAY_PLUGIN_SDK_VERSION: "0.48.0";
2452
+ declare const KAY_PLUGIN_SDK_VERSION: "0.48.1";
2451
2453
 
2452
2454
  declare const KAY_PLUGIN_TARGET_NAMES: readonly ["kay.agent", "kay.app", "kay.ui"];
2453
2455
 
@@ -2500,8 +2500,10 @@ declare const KAY_PLUGIN_PROTOCOL_VERSION: "kay.plugin.v1";
2500
2500
  * 0.47.0 adds card layouts and builders; successful card submits now require a summary.
2501
2501
  *
2502
2502
  * 0.48.0 adds the models.complete UI capability.
2503
+ *
2504
+ * 0.48.1 adds app-tool metadata, conditional tool permissions and screen-action declarations.
2503
2505
  */
2504
- declare const KAY_PLUGIN_SDK_VERSION: "0.48.0";
2506
+ declare const KAY_PLUGIN_SDK_VERSION: "0.48.1";
2505
2507
 
2506
2508
  declare const KAY_PLUGIN_TARGET_NAMES: readonly ["kay.agent", "kay.app", "kay.ui"];
2507
2509
 
@@ -5364,6 +5366,32 @@ declare const ResolvedPluginContractV1: z.ZodObject<{
5364
5366
  }, z.core.$strict>;
5365
5367
  }, z.core.$strict>>;
5366
5368
  kayAgentUriModules: z.ZodOptional<z.ZodArray<z.ZodObject<{
5369
+ screenActions: z.ZodExactOptional<z.ZodObject<{
5370
+ scheme: z.ZodString;
5371
+ hosts: z.ZodArray<z.ZodString>;
5372
+ paths: z.ZodOptional<z.ZodArray<z.ZodString>>;
5373
+ apps: z.ZodArray<z.ZodString>;
5374
+ options: z.ZodRecord<z.ZodString, z.ZodDiscriminatedUnion<[z.ZodObject<{
5375
+ kind: z.ZodLiteral<"exact">;
5376
+ description: z.ZodString;
5377
+ verb: z.ZodEnum<{
5378
+ read: "read";
5379
+ write: "write";
5380
+ edit: "edit";
5381
+ delete: "delete";
5382
+ }>;
5383
+ uri: z.ZodString;
5384
+ }, z.core.$strict>, z.ZodObject<{
5385
+ kind: z.ZodLiteral<"catch-all">;
5386
+ description: z.ZodString;
5387
+ verb: z.ZodEnum<{
5388
+ read: "read";
5389
+ write: "write";
5390
+ edit: "edit";
5391
+ delete: "delete";
5392
+ }>;
5393
+ }, z.core.$strict>], "kind">>;
5394
+ }, z.core.$strict>>;
5367
5395
  claims: z.ZodExactOptional<z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
5368
5396
  kind: z.ZodLiteral<"scheme">;
5369
5397
  scheme: z.ZodString;
@@ -5400,27 +5428,27 @@ declare const ResolvedPluginContractV1: z.ZodObject<{
5400
5428
  list: "list";
5401
5429
  read: "read";
5402
5430
  write: "write";
5403
- help: "help";
5404
5431
  edit: "edit";
5405
5432
  delete: "delete";
5433
+ help: "help";
5406
5434
  }>>>;
5407
5435
  operationDocs: z.ZodExactOptional<z.ZodRecord<z.ZodEnum<{
5408
5436
  search: "search";
5409
5437
  list: "list";
5410
5438
  read: "read";
5411
5439
  write: "write";
5412
- help: "help";
5413
5440
  edit: "edit";
5414
5441
  delete: "delete";
5442
+ help: "help";
5415
5443
  }> & z.core.$partial, z.ZodString>>;
5416
5444
  operationDefaults: z.ZodExactOptional<z.ZodRecord<z.ZodEnum<{
5417
5445
  search: "search";
5418
5446
  list: "list";
5419
5447
  read: "read";
5420
5448
  write: "write";
5421
- help: "help";
5422
5449
  edit: "edit";
5423
5450
  delete: "delete";
5451
+ help: "help";
5424
5452
  }> & z.core.$partial, z.ZodEnum<{
5425
5453
  never: "never";
5426
5454
  allow: "allow";
@@ -5482,9 +5510,9 @@ declare const ResolvedPluginContractV1: z.ZodObject<{
5482
5510
  list: "list";
5483
5511
  read: "read";
5484
5512
  write: "write";
5485
- help: "help";
5486
5513
  edit: "edit";
5487
5514
  delete: "delete";
5515
+ help: "help";
5488
5516
  }>>>;
5489
5517
  routes: z.ZodExactOptional<z.ZodArray<z.ZodString>>;
5490
5518
  query: z.ZodExactOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
@@ -5495,9 +5523,9 @@ declare const ResolvedPluginContractV1: z.ZodObject<{
5495
5523
  list: "list";
5496
5524
  read: "read";
5497
5525
  write: "write";
5498
- help: "help";
5499
5526
  edit: "edit";
5500
5527
  delete: "delete";
5528
+ help: "help";
5501
5529
  }>>>;
5502
5530
  routes: z.ZodExactOptional<z.ZodArray<z.ZodString>>;
5503
5531
  query: z.ZodExactOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
@@ -5586,15 +5614,80 @@ declare const ResolvedPluginContractV1: z.ZodObject<{
5586
5614
  scheme: z.ZodOptional<z.ZodString>;
5587
5615
  resourcePrefix: z.ZodOptional<z.ZodString>;
5588
5616
  resourceArgs: z.ZodOptional<z.ZodArray<z.ZodString>>;
5617
+ resourceTrim: z.ZodOptional<z.ZodLiteral<true>>;
5618
+ defaultPermission: z.ZodOptional<z.ZodEnum<{
5619
+ never: "never";
5620
+ allow: "allow";
5621
+ ask: "ask";
5622
+ }>>;
5623
+ classificationRules: z.ZodOptional<z.ZodArray<z.ZodObject<{
5624
+ when: z.ZodArray<z.ZodUnion<readonly [z.ZodObject<{
5625
+ arg: z.ZodString;
5626
+ equals: z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean, z.ZodNull]>;
5627
+ }, z.core.$strict>, z.ZodObject<{
5628
+ arg: z.ZodString;
5629
+ present: z.ZodBoolean;
5630
+ }, z.core.$strict>]>>;
5631
+ kind: z.ZodEnum<{
5632
+ read: "read";
5633
+ mutate: "mutate";
5634
+ destructive: "destructive";
5635
+ execute: "execute";
5636
+ }>;
5637
+ ruleKey: z.ZodOptional<z.ZodString>;
5638
+ }, z.core.$strict>>>;
5589
5639
  }, z.core.$strict>>;
5590
5640
  localId: z.ZodString;
5591
5641
  globalId: z.ZodString;
5592
5642
  toolName: z.ZodString;
5593
5643
  }, z.core.$strict>>>;
5594
5644
  kayAppTools: z.ZodOptional<z.ZodArray<z.ZodObject<{
5645
+ description: z.ZodOptional<z.ZodString>;
5595
5646
  localId: z.ZodString;
5596
- globalId: z.ZodString;
5647
+ displayName: z.ZodOptional<z.ZodString>;
5597
5648
  toolName: z.ZodString;
5649
+ parameters: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodType<authoringCommonSchemas.JsonValue, unknown, z.core.$ZodTypeInternals<authoringCommonSchemas.JsonValue, unknown>>>>;
5650
+ executionMode: z.ZodOptional<z.ZodEnum<{
5651
+ sequential: "sequential";
5652
+ parallel: "parallel";
5653
+ }>>;
5654
+ promptSnippet: z.ZodOptional<z.ZodString>;
5655
+ promptGuidelines: z.ZodOptional<z.ZodArray<z.ZodString>>;
5656
+ permission: z.ZodOptional<z.ZodObject<{
5657
+ kind: z.ZodEnum<{
5658
+ read: "read";
5659
+ mutate: "mutate";
5660
+ destructive: "destructive";
5661
+ execute: "execute";
5662
+ }>;
5663
+ ruleKey: z.ZodOptional<z.ZodString>;
5664
+ scheme: z.ZodOptional<z.ZodString>;
5665
+ resourcePrefix: z.ZodOptional<z.ZodString>;
5666
+ resourceArgs: z.ZodOptional<z.ZodArray<z.ZodString>>;
5667
+ resourceTrim: z.ZodOptional<z.ZodLiteral<true>>;
5668
+ defaultPermission: z.ZodOptional<z.ZodEnum<{
5669
+ never: "never";
5670
+ allow: "allow";
5671
+ ask: "ask";
5672
+ }>>;
5673
+ classificationRules: z.ZodOptional<z.ZodArray<z.ZodObject<{
5674
+ when: z.ZodArray<z.ZodUnion<readonly [z.ZodObject<{
5675
+ arg: z.ZodString;
5676
+ equals: z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean, z.ZodNull]>;
5677
+ }, z.core.$strict>, z.ZodObject<{
5678
+ arg: z.ZodString;
5679
+ present: z.ZodBoolean;
5680
+ }, z.core.$strict>]>>;
5681
+ kind: z.ZodEnum<{
5682
+ read: "read";
5683
+ mutate: "mutate";
5684
+ destructive: "destructive";
5685
+ execute: "execute";
5686
+ }>;
5687
+ ruleKey: z.ZodOptional<z.ZodString>;
5688
+ }, z.core.$strict>>>;
5689
+ }, z.core.$strict>>;
5690
+ globalId: z.ZodString;
5598
5691
  }, z.core.$strict>>>;
5599
5692
  kayAppApprovalTypes: z.ZodOptional<z.ZodArray<z.ZodObject<{
5600
5693
  kind: z.ZodLiteral<"message">;
@@ -123,16 +123,31 @@ function createKayPluginLog(write, bound = {}) {
123
123
  }
124
124
 
125
125
  // packages/plugin-sdk/dist/kay-agent/declared-tool.js
126
- function permissionHint(permission) {
127
- const { kind, ruleKey, resourceArgs, scheme, resourcePrefix } = permission;
126
+ function declaredToolPermission(permission) {
127
+ const { kind, ruleKey, resourceArgs, scheme, resourcePrefix, resourceTrim, defaultPermission, classificationRules } = permission;
128
128
  return {
129
129
  kind,
130
130
  ...scheme === void 0 ? {} : { scheme },
131
131
  ...ruleKey === void 0 ? {} : { ruleKey },
132
+ ...defaultPermission === void 0 ? {} : { defaultPermission },
133
+ ...classificationRules === void 0 ? {} : {
134
+ deriveClassification: (input) => {
135
+ const rule = classificationRules.find((candidate) => candidate.when.every((condition) => {
136
+ const value = Object.hasOwn(input, condition.arg) ? input[condition.arg] : void 0;
137
+ return "equals" in condition ? value === condition.equals : value !== void 0 === condition.present;
138
+ }));
139
+ return rule === void 0 ? void 0 : {
140
+ kind: rule.kind,
141
+ ...rule.ruleKey === void 0 ? {} : { ruleKey: rule.ruleKey }
142
+ };
143
+ }
144
+ },
132
145
  ...resourceArgs === void 0 ? {} : {
133
146
  deriveResources: (input) => resourceArgs.flatMap((arg) => {
134
147
  const value = input[arg];
135
- return typeof value === "string" ? [`${resourcePrefix ?? ""}${value}`] : [];
148
+ return typeof value === "string" ? [
149
+ `${resourcePrefix ?? ""}${resourceTrim === true ? value.trim() : value}`
150
+ ] : [];
136
151
  })
137
152
  }
138
153
  };
@@ -156,7 +171,7 @@ function declaredToolDefinition(tool, execute) {
156
171
  ...requiresAuth.schemeId === void 0 ? {} : { schemeId: requiresAuth.schemeId }
157
172
  }
158
173
  },
159
- ...permission === void 0 ? {} : { permission: permissionHint(permission) },
174
+ ...permission === void 0 ? {} : { permission: declaredToolPermission(permission) },
160
175
  execute
161
176
  };
162
177
  }
@@ -2775,8 +2775,10 @@ declare const KAY_PLUGIN_PROTOCOL_VERSION: "kay.plugin.v1";
2775
2775
  * 0.47.0 adds card layouts and builders; successful card submits now require a summary.
2776
2776
  *
2777
2777
  * 0.48.0 adds the models.complete UI capability.
2778
+ *
2779
+ * 0.48.1 adds app-tool metadata, conditional tool permissions and screen-action declarations.
2778
2780
  */
2779
- declare const KAY_PLUGIN_SDK_VERSION: "0.48.0";
2781
+ declare const KAY_PLUGIN_SDK_VERSION: "0.48.1";
2780
2782
 
2781
2783
  declare const KAY_PLUGIN_TARGET_NAMES: readonly ["kay.agent", "kay.app", "kay.ui"];
2782
2784
 
package/dist/kay-app.d.ts CHANGED
@@ -1139,6 +1139,9 @@ declare interface Decision<Q extends DecideQuestions = DecideQuestions> {
1139
1139
  readonly usage?: SystemOneTokenUsage;
1140
1140
  }
1141
1141
 
1142
+ /** Builds an app tool from manifest facts, retaining its execution, availability and preview callbacks. */
1143
+ export declare function declaredAppToolDefinition(tool: ToolContribution, implementation: KayAppToolImplementation): KayAppToolDefinition;
1144
+
1142
1145
  /** Createsa uni-directional Codec with Decode only. The Decode function is called on Value.Decode */
1143
1146
  declare function Decode<Type extends TSchema, Callback extends TDecodeCallback<StaticDecode<Type>, unknown>>(type: Type, callback: Callback): TCodec<Type, ReturnType<Callback>>;
1144
1147
 
@@ -2882,8 +2885,10 @@ declare const KAY_PLUGIN_PROTOCOL_VERSION: "kay.plugin.v1";
2882
2885
  * 0.47.0 adds card layouts and builders; successful card submits now require a summary.
2883
2886
  *
2884
2887
  * 0.48.0 adds the models.complete UI capability.
2888
+ *
2889
+ * 0.48.1 adds app-tool metadata, conditional tool permissions and screen-action declarations.
2885
2890
  */
2886
- declare const KAY_PLUGIN_SDK_VERSION: "0.48.0";
2891
+ declare const KAY_PLUGIN_SDK_VERSION: "0.48.1";
2887
2892
 
2888
2893
  declare const KAY_PLUGIN_TARGET_NAMES: readonly ["kay.agent", "kay.app", "kay.ui"];
2889
2894
 
@@ -7862,6 +7867,10 @@ export declare interface KayAppToolEvents {
7862
7867
  subscribe(handler: (event: unknown) => void): () => void;
7863
7868
  }
7864
7869
 
7870
+ export declare type KayAppToolImplementation = Omit<KayAppToolDefinition, "label" | "description" | "parameters" | "permission" | "executionMode" | "promptSnippet" | "promptGuidelines"> & {
7871
+ readonly permission?: Pick<ToolPermissionHint, "describePreview">;
7872
+ };
7873
+
7865
7874
  /** Where a described tool or address comes from. */
7866
7875
  export declare type KayAppToolOrigin =
7867
7876
  /** The agent kernel's own (`bash`, `read`, `help`, `skill://`). */
@@ -14200,6 +14209,56 @@ declare interface ToolContext {
14200
14209
  readonly paths?: ExtensionPaths;
14201
14210
  }
14202
14211
 
14212
+ export declare const ToolContribution: z.ZodObject<{
14213
+ parameters: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodType<authoringCommonSchemas.JsonValue, unknown, z.core.$ZodTypeInternals<authoringCommonSchemas.JsonValue, unknown>>>>;
14214
+ executionMode: z.ZodOptional<z.ZodEnum<{
14215
+ sequential: "sequential";
14216
+ parallel: "parallel";
14217
+ }>>;
14218
+ promptSnippet: z.ZodOptional<z.ZodString>;
14219
+ promptGuidelines: z.ZodOptional<z.ZodArray<z.ZodString>>;
14220
+ permission: z.ZodOptional<z.ZodObject<{
14221
+ kind: z.ZodEnum<{
14222
+ read: "read";
14223
+ mutate: "mutate";
14224
+ destructive: "destructive";
14225
+ execute: "execute";
14226
+ }>;
14227
+ ruleKey: z.ZodOptional<z.ZodString>;
14228
+ scheme: z.ZodOptional<z.ZodString>;
14229
+ resourcePrefix: z.ZodOptional<z.ZodString>;
14230
+ resourceArgs: z.ZodOptional<z.ZodArray<z.ZodString>>;
14231
+ resourceTrim: z.ZodOptional<z.ZodLiteral<true>>;
14232
+ defaultPermission: z.ZodOptional<z.ZodEnum<{
14233
+ never: "never";
14234
+ allow: "allow";
14235
+ ask: "ask";
14236
+ }>>;
14237
+ classificationRules: z.ZodOptional<z.ZodArray<z.ZodObject<{
14238
+ when: z.ZodArray<z.ZodUnion<readonly [z.ZodObject<{
14239
+ arg: z.ZodString;
14240
+ equals: z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean, z.ZodNull]>;
14241
+ }, z.core.$strict>, z.ZodObject<{
14242
+ arg: z.ZodString;
14243
+ present: z.ZodBoolean;
14244
+ }, z.core.$strict>]>>;
14245
+ kind: z.ZodEnum<{
14246
+ read: "read";
14247
+ mutate: "mutate";
14248
+ destructive: "destructive";
14249
+ execute: "execute";
14250
+ }>;
14251
+ ruleKey: z.ZodOptional<z.ZodString>;
14252
+ }, z.core.$strict>>>;
14253
+ }, z.core.$strict>>;
14254
+ localId: z.ZodString;
14255
+ toolName: z.ZodString;
14256
+ displayName: z.ZodOptional<z.ZodString>;
14257
+ description: z.ZodOptional<z.ZodString>;
14258
+ }, z.core.$strict>;
14259
+
14260
+ export declare type ToolContribution = z.infer<typeof ToolContribution>;
14261
+
14203
14262
  export declare interface ToolDefinition<TParams extends ToolParametersWire = ToolParametersWire, TDetails = unknown> {
14204
14263
  /** Tool name (used in LLM tool calls) */
14205
14264
  name: string;
package/dist/kay-app.js CHANGED
@@ -880,6 +880,60 @@ function refusedCountOf(error) {
880
880
  return typeof count === "number" && Number.isSafeInteger(count) && count > 0 ? count : 1;
881
881
  }
882
882
 
883
+ // packages/plugin-sdk/dist/kay-agent/declared-tool.js
884
+ function declaredToolPermission(permission) {
885
+ const { kind, ruleKey, resourceArgs, scheme, resourcePrefix, resourceTrim, defaultPermission, classificationRules } = permission;
886
+ return {
887
+ kind,
888
+ ...scheme === void 0 ? {} : { scheme },
889
+ ...ruleKey === void 0 ? {} : { ruleKey },
890
+ ...defaultPermission === void 0 ? {} : { defaultPermission },
891
+ ...classificationRules === void 0 ? {} : {
892
+ deriveClassification: (input) => {
893
+ const rule = classificationRules.find((candidate) => candidate.when.every((condition) => {
894
+ const value = Object.hasOwn(input, condition.arg) ? input[condition.arg] : void 0;
895
+ return "equals" in condition ? value === condition.equals : value !== void 0 === condition.present;
896
+ }));
897
+ return rule === void 0 ? void 0 : {
898
+ kind: rule.kind,
899
+ ...rule.ruleKey === void 0 ? {} : { ruleKey: rule.ruleKey }
900
+ };
901
+ }
902
+ },
903
+ ...resourceArgs === void 0 ? {} : {
904
+ deriveResources: (input) => resourceArgs.flatMap((arg) => {
905
+ const value = input[arg];
906
+ return typeof value === "string" ? [
907
+ `${resourcePrefix ?? ""}${resourceTrim === true ? value.trim() : value}`
908
+ ] : [];
909
+ })
910
+ }
911
+ };
912
+ }
913
+
914
+ // packages/plugin-sdk/dist/kay-app/declared-tool.js
915
+ function declaredAppToolDefinition(tool, implementation) {
916
+ if (tool.parameters === void 0 || tool.description === void 0) {
917
+ throw new Error(`Tool '${tool.toolName}' declares no parameters or description.`);
918
+ }
919
+ const { permission: preview, label: _label, description: _description, parameters: _parameters, executionMode: _executionMode, promptSnippet: _promptSnippet, promptGuidelines: _promptGuidelines, ...callbacks } = implementation;
920
+ return {
921
+ ...callbacks,
922
+ label: tool.displayName ?? tool.toolName,
923
+ description: tool.description,
924
+ parameters: tool.parameters,
925
+ ...tool.executionMode === void 0 ? {} : { executionMode: tool.executionMode },
926
+ ...tool.promptSnippet === void 0 ? {} : { promptSnippet: tool.promptSnippet },
927
+ ...tool.promptGuidelines === void 0 ? {} : { promptGuidelines: tool.promptGuidelines },
928
+ ...tool.permission === void 0 ? {} : {
929
+ permission: {
930
+ ...declaredToolPermission(tool.permission),
931
+ ...preview?.describePreview === void 0 ? {} : { describePreview: preview.describePreview }
932
+ }
933
+ }
934
+ };
935
+ }
936
+
883
937
  // packages/plugin-sdk/dist/kay-app/sealing.js
884
938
  var KAY_APP_SEALING_MAX_BYTES = 1048576;
885
939
  function createUnavailableSealing(message) {
@@ -1031,6 +1085,7 @@ export {
1031
1085
  createUnavailableSkills,
1032
1086
  createUnavailableTools,
1033
1087
  createUnavailableUsage,
1088
+ declaredAppToolDefinition,
1034
1089
  definePoller,
1035
1090
  failedRunCause,
1036
1091
  invalidObservation,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@yaklabs-ai/plugin-sdk",
3
- "version": "0.48.0",
3
+ "version": "0.48.1",
4
4
  "description": "The Kay plugin SDK — types and helpers for authoring a Kay directory plugin.",
5
5
  "author": "YakLabs",
6
6
  "type": "module",