@yaklabs-ai/plugin-protocol 0.47.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/dist/index.js CHANGED
@@ -260,8 +260,10 @@ var JsonSchema = z4.record(z4.string(), JsonValue);
260
260
  var KAY_PLUGIN_MANIFEST_SIZE_CAP_BYTES = 1024 * 1024;
261
261
  var KAY_PLUGIN_PROTOCOL_VERSION = "kay.plugin.v1";
262
262
  var KAY_PLUGIN_PROTOCOL_PACKAGE_NAME = "@bonsai/plugin-protocol";
263
- var KAY_PLUGIN_SDK_VERSION = "0.47.0";
263
+ var KAY_PLUGIN_SDK_VERSION = "0.48.1";
264
264
  var KAY_PLUGIN_COMPATIBLE_SDK_VERSIONS = [
265
+ "0.48.0",
266
+ "0.47.0",
265
267
  "0.42.0",
266
268
  "0.42.1",
267
269
  "0.43.0",
@@ -3380,7 +3382,7 @@ function createContributionsSchemas(canonical) {
3380
3382
  })).optional()
3381
3383
  }).optional()
3382
3384
  });
3383
- const ToolContribution2 = z12.strictObject({
3385
+ const ToolIdentity = z12.strictObject({
3384
3386
  localId: LocalContributionId2,
3385
3387
  toolName: PluginToolName2,
3386
3388
  displayName: OptionalDisplayName,
@@ -3392,7 +3394,34 @@ function createContributionsSchemas(canonical) {
3392
3394
  scheme: NonEmptyString3.optional(),
3393
3395
  resourcePrefix: z12.string().max(256).optional(),
3394
3396
  // Arguments whose string values name the resources a call touches.
3395
- resourceArgs: z12.array(NonEmptyString3).min(1).optional()
3397
+ resourceArgs: z12.array(NonEmptyString3).min(1).optional(),
3398
+ resourceTrim: z12.literal(true).optional(),
3399
+ defaultPermission: z12.enum(["allow", "ask", "never"]).optional(),
3400
+ /** First matching rule wins; every condition in its when list must hold. */
3401
+ classificationRules: z12.array(z12.strictObject({
3402
+ when: z12.array(z12.union([
3403
+ z12.strictObject({
3404
+ arg: NonEmptyString3,
3405
+ equals: z12.union([
3406
+ z12.string(),
3407
+ z12.number(),
3408
+ z12.boolean(),
3409
+ z12.null()
3410
+ ])
3411
+ }),
3412
+ z12.strictObject({ arg: NonEmptyString3, present: z12.boolean() })
3413
+ ])).min(1).max(32),
3414
+ kind: z12.enum(["read", "mutate", "destructive", "execute"]),
3415
+ ruleKey: NonEmptyString3.optional()
3416
+ })).min(1).max(64).optional()
3417
+ });
3418
+ const ToolContribution2 = z12.strictObject({
3419
+ ...ToolIdentity.shape,
3420
+ parameters: JsonSchema.optional(),
3421
+ executionMode: z12.enum(["sequential", "parallel"]).optional(),
3422
+ promptSnippet: NonEmptyString3.optional(),
3423
+ promptGuidelines: z12.array(NonEmptyString3).optional(),
3424
+ permission: ToolPermission2.optional()
3396
3425
  });
3397
3426
  const AgentToolContribution2 = z12.strictObject({
3398
3427
  ...ToolContribution2.shape,
@@ -3490,7 +3519,49 @@ function createContributionsSchemas(canonical) {
3490
3519
  }).exactOptional(),
3491
3520
  skills: z12.array(NonEmptyString3).exactOptional()
3492
3521
  });
3522
+ const ScreenActionOption = z12.discriminatedUnion("kind", [
3523
+ z12.strictObject({
3524
+ kind: z12.literal("exact"),
3525
+ description: NonEmptyString3,
3526
+ verb: z12.enum(["read", "write", "edit", "delete"]),
3527
+ uri: NonEmptyString3
3528
+ }),
3529
+ z12.strictObject({
3530
+ kind: z12.literal("catch-all"),
3531
+ description: NonEmptyString3,
3532
+ verb: z12.enum(["read", "write", "edit", "delete"])
3533
+ })
3534
+ ]);
3493
3535
  const UriModuleFactsShape = {
3536
+ screenActions: z12.strictObject({
3537
+ scheme: UriScheme2,
3538
+ hosts: z12.array(NonEmptyString3),
3539
+ paths: z12.array(NonEmptyString3).min(1).optional(),
3540
+ apps: z12.array(NonEmptyString3),
3541
+ options: z12.record(NonEmptyString3, ScreenActionOption)
3542
+ }).superRefine((catalog, ctx) => {
3543
+ if (catalog.hosts.length === 0 && catalog.apps.length === 0) {
3544
+ ctx.addIssue({
3545
+ code: "custom",
3546
+ message: "screen actions need a host or app"
3547
+ });
3548
+ }
3549
+ for (const [key, option] of Object.entries(catalog.options)) {
3550
+ if (key === "none")
3551
+ ctx.addIssue({
3552
+ code: "custom",
3553
+ path: ["options", key],
3554
+ message: "none is reserved"
3555
+ });
3556
+ if (option.kind === "exact" && !option.uri.startsWith(`${catalog.scheme}://`)) {
3557
+ ctx.addIssue({
3558
+ code: "custom",
3559
+ path: ["options", key, "uri"],
3560
+ message: "screen action URI must use its catalog scheme"
3561
+ });
3562
+ }
3563
+ }
3564
+ }).exactOptional(),
3494
3565
  /** Addresses the module answers, in match order; see `@herd/uri`'s `UriClaim`. */
3495
3566
  claims: z12.array(UriClaimContribution).min(1).exactOptional(),
3496
3567
  /** The module's routes, as its scheme-root `help` lists them. */
@@ -4164,6 +4235,7 @@ function createContributionsSchemas(canonical) {
4164
4235
  // Lets `navigation.openChat` create a blank chat (no message, no model
4165
4236
  // turn) when no session id is given. It never sends anything.
4166
4237
  "sessions.create",
4238
+ "models.complete",
4167
4239
  "artifacts.read",
4168
4240
  "artifacts.preview",
4169
4241
  // Draws Bonsai's markdown document view in the app's page (`BonsaiMarkdownDocumentView`).
@@ -5417,6 +5489,35 @@ function createManifestSchemas(canonical) {
5417
5489
  for (const target of ["agent", "app"]) {
5418
5490
  const contributes = target === "agent" ? manifest.targets?.kay?.agent?.contributes : manifest.targets?.kay?.app?.contributes;
5419
5491
  for (const tool of contributes?.tools ?? []) {
5492
+ const toolPath = ["targets", "kay", target, "contributes", "tools"];
5493
+ if (tool.parameters === void 0 && tool.permission !== void 0 && target === "app") {
5494
+ ctx.addIssue({
5495
+ code: "custom",
5496
+ path: toolPath,
5497
+ message: `tool ${tool.localId} declares permission without parameters`
5498
+ });
5499
+ }
5500
+ if (tool.parameters !== void 0 && tool.description === void 0 && target === "app") {
5501
+ ctx.addIssue({
5502
+ code: "custom",
5503
+ path: toolPath,
5504
+ message: `tool ${tool.localId} declares parameters without a description`
5505
+ });
5506
+ }
5507
+ const properties = tool.parameters?.["properties"];
5508
+ const argumentsUsed = [
5509
+ ...target === "app" ? tool.permission?.resourceArgs ?? [] : [],
5510
+ ...(tool.permission?.classificationRules ?? []).flatMap((rule) => rule.when.map((condition) => condition.arg))
5511
+ ];
5512
+ for (const arg of argumentsUsed) {
5513
+ if (typeof properties !== "object" || properties === null || !Object.hasOwn(properties, arg)) {
5514
+ ctx.addIssue({
5515
+ code: "custom",
5516
+ path: toolPath,
5517
+ message: `tool ${tool.localId} names permission argument ${arg}, which is not a parameter`
5518
+ });
5519
+ }
5520
+ }
5420
5521
  const existing = toolNames.get(tool.toolName);
5421
5522
  if (existing !== void 0) {
5422
5523
  ctx.addIssue({
@@ -5427,6 +5528,15 @@ function createManifestSchemas(canonical) {
5427
5528
  }
5428
5529
  toolNames.set(tool.toolName, tool.localId);
5429
5530
  }
5531
+ for (const module of contributes?.uriModules ?? []) {
5532
+ if (module.screenActions !== void 0 && !module.schemes.includes(module.screenActions.scheme)) {
5533
+ ctx.addIssue({
5534
+ code: "custom",
5535
+ path: ["targets", "kay", target, "contributes", "uriModules"],
5536
+ message: `screen actions must use a scheme owned by module ${module.localId}`
5537
+ });
5538
+ }
5539
+ }
5430
5540
  }
5431
5541
  const converterMimeTypes = /* @__PURE__ */ new Map();
5432
5542
  for (const converter of manifest.targets?.kay?.agent?.contributes?.converters ?? []) {
@@ -6062,7 +6172,7 @@ function createResolvedContractSchemas(canonical) {
6062
6172
  }).optional(),
6063
6173
  permission: canonical ? canonicalContributionSchemas.ToolPermission.optional() : ToolPermission.optional()
6064
6174
  });
6065
- const ResolvedKayAppTool2 = ResolvedKayToolId;
6175
+ const ResolvedKayAppTool2 = ResolvedKayAgentTool2.omit({ requiresAuth: true });
6066
6176
  const ResolvedKayAppDataSource2 = z14.strictObject({
6067
6177
  localId: LocalContributionId2,
6068
6178
  globalId: GlobalContributionId2,
@@ -6748,6 +6858,7 @@ function resolveKayPluginContractV1(manifest) {
6748
6858
  ...tool.permission === void 0 ? {} : { permission: tool.permission }
6749
6859
  }));
6750
6860
  const kayAppTools = manifest.targets?.kay?.app?.contributes?.tools?.map((tool) => ({
6861
+ ...tool,
6751
6862
  localId: tool.localId,
6752
6863
  globalId: resolveGlobalContributionId(namespace, tool.localId),
6753
6864
  toolName: tool.toolName
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@yaklabs-ai/plugin-protocol",
3
- "version": "0.47.0",
3
+ "version": "0.48.1",
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",