@yaklabs-ai/plugin-protocol 0.27.0 → 0.28.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.27.0"
14
+ "@bonsai/plugin-protocol": "npm:@yaklabs-ai/plugin-protocol@^0.28.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.27.0",
4
+ "version": "0.28.0",
5
5
  "target": "npm",
6
6
  "firstPartyLicense": "MIT",
7
7
  "bundled": [],
package/dist/index.d.ts CHANGED
@@ -2039,6 +2039,7 @@ declare const canonicalContributionSchemas: {
2039
2039
  }, z.core.$strict>;
2040
2040
  UriModuleContribution: z.ZodObject<{
2041
2041
  authService: z.ZodOptional<z.ZodString>;
2042
+ authScheme: z.ZodOptional<z.ZodString>;
2042
2043
  knownResources: z.ZodOptional<z.ZodLiteral<true>>;
2043
2044
  describesOperations: z.ZodOptional<z.ZodLiteral<true>>;
2044
2045
  claims: z.ZodExactOptional<z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
@@ -3901,8 +3902,23 @@ export declare const KAY_PLUGIN_PROTOCOL_VERSION: "kay.plugin.v1";
3901
3902
  * `write`. `app.approvals`, its `prepare`, `finalize` and `resolveResource` are gone, and a write can
3902
3903
  * refuse in the person's words with `UriProviderError.refusalMessage`. No plugin outside this repo
3903
3904
  * declared a card, so 0.26.3 stays served. A plugin that declares a card declares ^0.27.0.
3905
+ *
3906
+ * 0.27.1 lets a manifest URI module name the exact sign-in scheme its calls use, as a tool can
3907
+ * (#14928): `authScheme`, a scheme of the module's `authService`, local or another plugin's. A
3908
+ * hosted module's code and manifest must agree on it, and the daemon reads it to find an
3909
+ * external-CLI scheme without running the module. A module that runs in the daemon is unchanged,
3910
+ * so this is additive; a plugin whose manifest sets `authScheme` declares ^0.27.1.
3911
+ *
3912
+ * 0.28.0 makes "whose credential is this?" one call (#15714). `api.auth.registerAccountLookup`
3913
+ * replaces `registerValidator` and `registerAccountResolver`: it takes the credential, its fields and
3914
+ * a cancel signal, and returns every account the credential reaches. A manifest says `account:
3915
+ * "lookup"` on any `oauth2` or `api-key` scheme the plugin answers for, in place of `validates: true`
3916
+ * and the `"resolveAccountId"` and `"resolveAccounts"` values, and a `pkce` scheme on a client the
3917
+ * host holds may name one too. A plugin using a removed member or value stops loading until it is
3918
+ * rebuilt; a code search found none outside this repo. A plugin with a sign-in declares ^0.28.0. 0.26.3 and 0.27.1
3919
+ * stay served for a plugin that uses none of these.
3904
3920
  */
3905
- export declare const KAY_PLUGIN_SDK_VERSION: "0.27.0";
3921
+ export declare const KAY_PLUGIN_SDK_VERSION: "0.28.0";
3906
3922
 
3907
3923
  export declare const KAY_PLUGIN_TARGET_NAMES: readonly ["kay.agent", "kay.app", "kay.ui"];
3908
3924
 
@@ -3954,6 +3970,7 @@ export declare const KayAgentTargetManifest: z.ZodObject<{
3954
3970
  }, z.core.$strict>>>;
3955
3971
  uriModules: z.ZodOptional<z.ZodArray<z.ZodObject<{
3956
3972
  authService: z.ZodOptional<z.ZodString>;
3973
+ authScheme: z.ZodOptional<z.ZodString>;
3957
3974
  knownResources: z.ZodOptional<z.ZodLiteral<true>>;
3958
3975
  describesOperations: z.ZodOptional<z.ZodLiteral<true>>;
3959
3976
  claims: z.ZodExactOptional<z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
@@ -4709,6 +4726,7 @@ export declare const KayPluginManifestV1: z.ZodObject<{
4709
4726
  }, z.core.$strict>>>;
4710
4727
  uriModules: z.ZodOptional<z.ZodArray<z.ZodObject<{
4711
4728
  authService: z.ZodOptional<z.ZodString>;
4729
+ authScheme: z.ZodOptional<z.ZodString>;
4712
4730
  knownResources: z.ZodOptional<z.ZodLiteral<true>>;
4713
4731
  describesOperations: z.ZodOptional<z.ZodLiteral<true>>;
4714
4732
  claims: z.ZodExactOptional<z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
@@ -5489,10 +5507,7 @@ export declare const KayPluginManifestV1: z.ZodObject<{
5489
5507
  exchange: z.ZodLiteral<"pkce">;
5490
5508
  clientId: z.ZodOptional<z.ZodString>;
5491
5509
  clientSecret: z.ZodOptional<z.ZodString>;
5492
- account: z.ZodOptional<z.ZodEnum<{
5493
- resolveAccountId: "resolveAccountId";
5494
- resolveAccounts: "resolveAccounts";
5495
- }>>;
5510
+ account: z.ZodOptional<z.ZodLiteral<"lookup">>;
5496
5511
  clientSuppliers: z.ZodArray<z.ZodEnum<{
5497
5512
  user: "user";
5498
5513
  kay: "kay";
@@ -5524,10 +5539,7 @@ export declare const KayPluginManifestV1: z.ZodObject<{
5524
5539
  exchange: z.ZodLiteral<"confidential">;
5525
5540
  clientSuppliers: z.ZodOptional<z.ZodTuple<[z.ZodLiteral<"kay">], null>>;
5526
5541
  scopes: z.ZodOptional<z.ZodArray<z.ZodString>>;
5527
- account: z.ZodUnion<readonly [z.ZodEnum<{
5528
- resolveAccountId: "resolveAccountId";
5529
- resolveAccounts: "resolveAccounts";
5530
- }>, z.ZodLiteral<"sign-in">]>;
5542
+ account: z.ZodUnion<readonly [z.ZodLiteral<"lookup">, z.ZodLiteral<"sign-in">]>;
5531
5543
  authorizationUrl: z.ZodURL;
5532
5544
  tokenUrl: z.ZodURL;
5533
5545
  extraAuthorizeParams: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
@@ -5561,7 +5573,7 @@ export declare const KayPluginManifestV1: z.ZodObject<{
5561
5573
  instructions: z.ZodString;
5562
5574
  url: z.ZodURL;
5563
5575
  }, z.core.$strict>>;
5564
- validates: z.ZodOptional<z.ZodLiteral<true>>;
5576
+ account: z.ZodOptional<z.ZodLiteral<"lookup">>;
5565
5577
  displayName: z.ZodOptional<z.ZodString>;
5566
5578
  agentHint: z.ZodOptional<z.ZodString>;
5567
5579
  summary: z.ZodOptional<z.ZodString>;
@@ -6599,6 +6611,9 @@ export declare function mintOperation(input: OperationCaptureInput, clock?: Capt
6599
6611
  readonly gaps: readonly ArtifactProvenanceGap[];
6600
6612
  };
6601
6613
 
6614
+ /** The namespace of a qualified auth ref (`google` in `google.oauth`); empty for a local ref. */
6615
+ export declare function namespaceOfQualifiedRef(ref: string): string;
6616
+
6602
6617
  export declare const NonEmptyString: z.ZodString;
6603
6618
 
6604
6619
  /**
@@ -6730,10 +6745,7 @@ export declare const PluginAuthManifest: z.ZodObject<{
6730
6745
  exchange: z.ZodLiteral<"pkce">;
6731
6746
  clientId: z.ZodOptional<z.ZodString>;
6732
6747
  clientSecret: z.ZodOptional<z.ZodString>;
6733
- account: z.ZodOptional<z.ZodEnum<{
6734
- resolveAccountId: "resolveAccountId";
6735
- resolveAccounts: "resolveAccounts";
6736
- }>>;
6748
+ account: z.ZodOptional<z.ZodLiteral<"lookup">>;
6737
6749
  clientSuppliers: z.ZodArray<z.ZodEnum<{
6738
6750
  user: "user";
6739
6751
  kay: "kay";
@@ -6765,10 +6777,7 @@ export declare const PluginAuthManifest: z.ZodObject<{
6765
6777
  exchange: z.ZodLiteral<"confidential">;
6766
6778
  clientSuppliers: z.ZodOptional<z.ZodTuple<[z.ZodLiteral<"kay">], null>>;
6767
6779
  scopes: z.ZodOptional<z.ZodArray<z.ZodString>>;
6768
- account: z.ZodUnion<readonly [z.ZodEnum<{
6769
- resolveAccountId: "resolveAccountId";
6770
- resolveAccounts: "resolveAccounts";
6771
- }>, z.ZodLiteral<"sign-in">]>;
6780
+ account: z.ZodUnion<readonly [z.ZodLiteral<"lookup">, z.ZodLiteral<"sign-in">]>;
6772
6781
  authorizationUrl: z.ZodURL;
6773
6782
  tokenUrl: z.ZodURL;
6774
6783
  extraAuthorizeParams: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
@@ -6802,7 +6811,7 @@ export declare const PluginAuthManifest: z.ZodObject<{
6802
6811
  instructions: z.ZodString;
6803
6812
  url: z.ZodURL;
6804
6813
  }, z.core.$strict>>;
6805
- validates: z.ZodOptional<z.ZodLiteral<true>>;
6814
+ account: z.ZodOptional<z.ZodLiteral<"lookup">>;
6806
6815
  displayName: z.ZodOptional<z.ZodString>;
6807
6816
  agentHint: z.ZodOptional<z.ZodString>;
6808
6817
  summary: z.ZodOptional<z.ZodString>;
@@ -6891,10 +6900,7 @@ export declare const PluginAuthScheme: z.ZodDiscriminatedUnion<[z.ZodDiscriminat
6891
6900
  exchange: z.ZodLiteral<"pkce">;
6892
6901
  clientId: z.ZodOptional<z.ZodString>;
6893
6902
  clientSecret: z.ZodOptional<z.ZodString>;
6894
- account: z.ZodOptional<z.ZodEnum<{
6895
- resolveAccountId: "resolveAccountId";
6896
- resolveAccounts: "resolveAccounts";
6897
- }>>;
6903
+ account: z.ZodOptional<z.ZodLiteral<"lookup">>;
6898
6904
  clientSuppliers: z.ZodArray<z.ZodEnum<{
6899
6905
  user: "user";
6900
6906
  kay: "kay";
@@ -6926,10 +6932,7 @@ export declare const PluginAuthScheme: z.ZodDiscriminatedUnion<[z.ZodDiscriminat
6926
6932
  exchange: z.ZodLiteral<"confidential">;
6927
6933
  clientSuppliers: z.ZodOptional<z.ZodTuple<[z.ZodLiteral<"kay">], null>>;
6928
6934
  scopes: z.ZodOptional<z.ZodArray<z.ZodString>>;
6929
- account: z.ZodUnion<readonly [z.ZodEnum<{
6930
- resolveAccountId: "resolveAccountId";
6931
- resolveAccounts: "resolveAccounts";
6932
- }>, z.ZodLiteral<"sign-in">]>;
6935
+ account: z.ZodUnion<readonly [z.ZodLiteral<"lookup">, z.ZodLiteral<"sign-in">]>;
6933
6936
  authorizationUrl: z.ZodURL;
6934
6937
  tokenUrl: z.ZodURL;
6935
6938
  extraAuthorizeParams: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
@@ -6963,7 +6966,7 @@ export declare const PluginAuthScheme: z.ZodDiscriminatedUnion<[z.ZodDiscriminat
6963
6966
  instructions: z.ZodString;
6964
6967
  url: z.ZodURL;
6965
6968
  }, z.core.$strict>>;
6966
- validates: z.ZodOptional<z.ZodLiteral<true>>;
6969
+ account: z.ZodOptional<z.ZodLiteral<"lookup">>;
6967
6970
  displayName: z.ZodOptional<z.ZodString>;
6968
6971
  agentHint: z.ZodOptional<z.ZodString>;
6969
6972
  summary: z.ZodOptional<z.ZodString>;
@@ -7033,10 +7036,7 @@ export declare const PluginAuthService: z.ZodObject<{
7033
7036
  exchange: z.ZodLiteral<"pkce">;
7034
7037
  clientId: z.ZodOptional<z.ZodString>;
7035
7038
  clientSecret: z.ZodOptional<z.ZodString>;
7036
- account: z.ZodOptional<z.ZodEnum<{
7037
- resolveAccountId: "resolveAccountId";
7038
- resolveAccounts: "resolveAccounts";
7039
- }>>;
7039
+ account: z.ZodOptional<z.ZodLiteral<"lookup">>;
7040
7040
  clientSuppliers: z.ZodArray<z.ZodEnum<{
7041
7041
  user: "user";
7042
7042
  kay: "kay";
@@ -7068,10 +7068,7 @@ export declare const PluginAuthService: z.ZodObject<{
7068
7068
  exchange: z.ZodLiteral<"confidential">;
7069
7069
  clientSuppliers: z.ZodOptional<z.ZodTuple<[z.ZodLiteral<"kay">], null>>;
7070
7070
  scopes: z.ZodOptional<z.ZodArray<z.ZodString>>;
7071
- account: z.ZodUnion<readonly [z.ZodEnum<{
7072
- resolveAccountId: "resolveAccountId";
7073
- resolveAccounts: "resolveAccounts";
7074
- }>, z.ZodLiteral<"sign-in">]>;
7071
+ account: z.ZodUnion<readonly [z.ZodLiteral<"lookup">, z.ZodLiteral<"sign-in">]>;
7075
7072
  authorizationUrl: z.ZodURL;
7076
7073
  tokenUrl: z.ZodURL;
7077
7074
  extraAuthorizeParams: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
@@ -7105,7 +7102,7 @@ export declare const PluginAuthService: z.ZodObject<{
7105
7102
  instructions: z.ZodString;
7106
7103
  url: z.ZodURL;
7107
7104
  }, z.core.$strict>>;
7108
- validates: z.ZodOptional<z.ZodLiteral<true>>;
7105
+ account: z.ZodOptional<z.ZodLiteral<"lookup">>;
7109
7106
  displayName: z.ZodOptional<z.ZodString>;
7110
7107
  agentHint: z.ZodOptional<z.ZodString>;
7111
7108
  summary: z.ZodOptional<z.ZodString>;
@@ -10344,6 +10341,7 @@ export declare const ResolvedKayAgentUriModule: z.ZodObject<{
10344
10341
  schemes: z.ZodArray<z.ZodString>;
10345
10342
  displayName: z.ZodOptional<z.ZodString>;
10346
10343
  authServiceId: z.ZodOptional<z.ZodString>;
10344
+ authSchemeId: z.ZodOptional<z.ZodString>;
10347
10345
  knownResources: z.ZodOptional<z.ZodLiteral<true>>;
10348
10346
  describesOperations: z.ZodOptional<z.ZodLiteral<true>>;
10349
10347
  }, z.core.$strict>;
@@ -10580,10 +10578,7 @@ export declare const ResolvedPluginAuthScheme: z.ZodDiscriminatedUnion<[z.ZodDis
10580
10578
  }>>;
10581
10579
  clientId: z.ZodOptional<z.ZodString>;
10582
10580
  clientSecret: z.ZodOptional<z.ZodString>;
10583
- account: z.ZodOptional<z.ZodEnum<{
10584
- resolveAccountId: "resolveAccountId";
10585
- resolveAccounts: "resolveAccounts";
10586
- }>>;
10581
+ account: z.ZodOptional<z.ZodLiteral<"lookup">>;
10587
10582
  localId: z.ZodString;
10588
10583
  globalId: z.ZodString;
10589
10584
  kind: z.ZodLiteral<"oauth2">;
@@ -10612,8 +10607,7 @@ export declare const ResolvedPluginAuthScheme: z.ZodDiscriminatedUnion<[z.ZodDis
10612
10607
  exchange: z.ZodLiteral<"confidential">;
10613
10608
  clientSuppliers: z.ZodTuple<[z.ZodLiteral<"kay">], null>;
10614
10609
  account: z.ZodEnum<{
10615
- resolveAccountId: "resolveAccountId";
10616
- resolveAccounts: "resolveAccounts";
10610
+ lookup: "lookup";
10617
10611
  "sign-in": "sign-in";
10618
10612
  }>;
10619
10613
  localId: z.ZodString;
@@ -10654,7 +10648,7 @@ export declare const ResolvedPluginAuthScheme: z.ZodDiscriminatedUnion<[z.ZodDis
10654
10648
  instructions: z.ZodString;
10655
10649
  url: z.ZodURL;
10656
10650
  }, z.core.$strict>>;
10657
- validates: z.ZodOptional<z.ZodLiteral<true>>;
10651
+ account: z.ZodOptional<z.ZodLiteral<"lookup">>;
10658
10652
  displayName: z.ZodOptional<z.ZodString>;
10659
10653
  agentHint: z.ZodOptional<z.ZodString>;
10660
10654
  summary: z.ZodOptional<z.ZodString>;
@@ -10729,10 +10723,7 @@ export declare const ResolvedPluginAuthService: z.ZodObject<{
10729
10723
  }>>;
10730
10724
  clientId: z.ZodOptional<z.ZodString>;
10731
10725
  clientSecret: z.ZodOptional<z.ZodString>;
10732
- account: z.ZodOptional<z.ZodEnum<{
10733
- resolveAccountId: "resolveAccountId";
10734
- resolveAccounts: "resolveAccounts";
10735
- }>>;
10726
+ account: z.ZodOptional<z.ZodLiteral<"lookup">>;
10736
10727
  localId: z.ZodString;
10737
10728
  globalId: z.ZodString;
10738
10729
  kind: z.ZodLiteral<"oauth2">;
@@ -10761,8 +10752,7 @@ export declare const ResolvedPluginAuthService: z.ZodObject<{
10761
10752
  exchange: z.ZodLiteral<"confidential">;
10762
10753
  clientSuppliers: z.ZodTuple<[z.ZodLiteral<"kay">], null>;
10763
10754
  account: z.ZodEnum<{
10764
- resolveAccountId: "resolveAccountId";
10765
- resolveAccounts: "resolveAccounts";
10755
+ lookup: "lookup";
10766
10756
  "sign-in": "sign-in";
10767
10757
  }>;
10768
10758
  localId: z.ZodString;
@@ -10803,7 +10793,7 @@ export declare const ResolvedPluginAuthService: z.ZodObject<{
10803
10793
  instructions: z.ZodString;
10804
10794
  url: z.ZodURL;
10805
10795
  }, z.core.$strict>>;
10806
- validates: z.ZodOptional<z.ZodLiteral<true>>;
10796
+ account: z.ZodOptional<z.ZodLiteral<"lookup">>;
10807
10797
  displayName: z.ZodOptional<z.ZodString>;
10808
10798
  agentHint: z.ZodOptional<z.ZodString>;
10809
10799
  summary: z.ZodOptional<z.ZodString>;
@@ -10951,10 +10941,7 @@ export declare const ResolvedPluginContractV1: z.ZodObject<{
10951
10941
  }>>;
10952
10942
  clientId: z.ZodOptional<z.ZodString>;
10953
10943
  clientSecret: z.ZodOptional<z.ZodString>;
10954
- account: z.ZodOptional<z.ZodEnum<{
10955
- resolveAccountId: "resolveAccountId";
10956
- resolveAccounts: "resolveAccounts";
10957
- }>>;
10944
+ account: z.ZodOptional<z.ZodLiteral<"lookup">>;
10958
10945
  localId: z.ZodString;
10959
10946
  globalId: z.ZodString;
10960
10947
  kind: z.ZodLiteral<"oauth2">;
@@ -10983,8 +10970,7 @@ export declare const ResolvedPluginContractV1: z.ZodObject<{
10983
10970
  exchange: z.ZodLiteral<"confidential">;
10984
10971
  clientSuppliers: z.ZodTuple<[z.ZodLiteral<"kay">], null>;
10985
10972
  account: z.ZodEnum<{
10986
- resolveAccountId: "resolveAccountId";
10987
- resolveAccounts: "resolveAccounts";
10973
+ lookup: "lookup";
10988
10974
  "sign-in": "sign-in";
10989
10975
  }>;
10990
10976
  localId: z.ZodString;
@@ -11025,7 +11011,7 @@ export declare const ResolvedPluginContractV1: z.ZodObject<{
11025
11011
  instructions: z.ZodString;
11026
11012
  url: z.ZodURL;
11027
11013
  }, z.core.$strict>>;
11028
- validates: z.ZodOptional<z.ZodLiteral<true>>;
11014
+ account: z.ZodOptional<z.ZodLiteral<"lookup">>;
11029
11015
  displayName: z.ZodOptional<z.ZodString>;
11030
11016
  agentHint: z.ZodOptional<z.ZodString>;
11031
11017
  summary: z.ZodOptional<z.ZodString>;
@@ -11560,6 +11546,7 @@ export declare const ResolvedPluginContractV1: z.ZodObject<{
11560
11546
  schemes: z.ZodArray<z.ZodString>;
11561
11547
  displayName: z.ZodOptional<z.ZodString>;
11562
11548
  authServiceId: z.ZodOptional<z.ZodString>;
11549
+ authSchemeId: z.ZodOptional<z.ZodString>;
11563
11550
  knownResources: z.ZodOptional<z.ZodLiteral<true>>;
11564
11551
  describesOperations: z.ZodOptional<z.ZodLiteral<true>>;
11565
11552
  }, z.core.$strict>>>;
@@ -13535,6 +13522,7 @@ export declare type UiSlotContribution = z.infer<typeof UiSlotContribution>;
13535
13522
 
13536
13523
  export declare const UriModuleContribution: z.ZodObject<{
13537
13524
  authService: z.ZodOptional<z.ZodString>;
13525
+ authScheme: z.ZodOptional<z.ZodString>;
13538
13526
  knownResources: z.ZodOptional<z.ZodLiteral<true>>;
13539
13527
  describesOperations: z.ZodOptional<z.ZodLiteral<true>>;
13540
13528
  claims: z.ZodExactOptional<z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
package/dist/index.js CHANGED
@@ -222,8 +222,11 @@ var JsonSchema = z4.record(z4.string(), JsonValue);
222
222
  // packages/plugin-protocol/dist/common.js
223
223
  var KAY_PLUGIN_PROTOCOL_VERSION = "kay.plugin.v1";
224
224
  var KAY_PLUGIN_PROTOCOL_PACKAGE_NAME = "@bonsai/plugin-protocol";
225
- var KAY_PLUGIN_SDK_VERSION = "0.27.0";
226
- var KAY_PLUGIN_COMPATIBLE_SDK_VERSIONS = ["0.26.3"];
225
+ var KAY_PLUGIN_SDK_VERSION = "0.28.0";
226
+ var KAY_PLUGIN_COMPATIBLE_SDK_VERSIONS = [
227
+ "0.26.3",
228
+ "0.27.1"
229
+ ];
227
230
  var KAY_PLUGIN_TARGET_NAMES = [
228
231
  "kay.agent",
229
232
  "kay.app",
@@ -1235,6 +1238,9 @@ function isQualifiedAuthServiceRef(ref) {
1235
1238
  function isQualifiedAuthSchemeRef(ref) {
1236
1239
  return ref.includes(".");
1237
1240
  }
1241
+ function namespaceOfQualifiedRef(ref) {
1242
+ return ref.slice(0, Math.max(0, ref.lastIndexOf(".")));
1243
+ }
1238
1244
  function resolveAdapterId(globalId, declaredAdapterId) {
1239
1245
  return declaredAdapterId ?? globalId;
1240
1246
  }
@@ -2817,7 +2823,7 @@ var PLUGIN_NOTIFICATION_RULE_HOST_KEYS = [
2817
2823
  ];
2818
2824
  function createContributionsSchemas(canonical) {
2819
2825
  const { PluginEventLocalId: PluginEventLocalId2 } = canonical ? canonicalPluginEventSchemas : plugin_events_exports;
2820
- const { AuthServiceReference: AuthServiceReference2, CliAuthEnvVarName: CliAuthEnvVarName2, CliBinaryName: CliBinaryName2, FileExtensionToken: FileExtensionToken2, GitBasicAuthUser: GitBasicAuthUser2, GitHostName: GitHostName2, LocalContributionId: LocalContributionId2, MimeTypeString: MimeTypeString2, NonEmptyString: NonEmptyString3, PackageAssetPath: PackageAssetPath2, PluginId: PluginId2, PluginToolName: PluginToolName2, TargetEntrypoint: TargetEntrypoint2, UriScheme: UriScheme2 } = canonical ? canonicalCommonSchemas : common_exports;
2826
+ const { AuthSchemeReference: AuthSchemeReference2, AuthServiceReference: AuthServiceReference2, CliAuthEnvVarName: CliAuthEnvVarName2, CliBinaryName: CliBinaryName2, FileExtensionToken: FileExtensionToken2, GitBasicAuthUser: GitBasicAuthUser2, GitHostName: GitHostName2, LocalContributionId: LocalContributionId2, MimeTypeString: MimeTypeString2, NonEmptyString: NonEmptyString3, PackageAssetPath: PackageAssetPath2, PluginId: PluginId2, PluginToolName: PluginToolName2, TargetEntrypoint: TargetEntrypoint2, UriScheme: UriScheme2 } = canonical ? canonicalCommonSchemas : common_exports;
2821
2827
  const { ScopeRequirement: ScopeRequirement2 } = canonical ? canonicalPermissionSchemas : permissions_exports;
2822
2828
  const OptionalDisplayName = NonEmptyString3.optional();
2823
2829
  const ApprovalCardValueName = z12.string().regex(/^[A-Za-z][A-Za-z0-9_]{0,63}$/u, "must be a plain field name");
@@ -3049,6 +3055,12 @@ function createContributionsSchemas(canonical) {
3049
3055
  // plugin's already-minted global id and is recorded, not resolved, here (see
3050
3056
  // `consumesAuthServices` on the resolved contract).
3051
3057
  authService: AuthServiceReference2.optional(),
3058
+ // A scheme of the module's `authService`: every call to this module must use exactly this
3059
+ // scheme. A local ref names a scheme of a service in this manifest; a dotted ref names a scheme
3060
+ // of another plugin's service (`google.oauth`). The daemon reads it here because it may hold
3061
+ // only the manifest (a plugin that runs in the plugin host), and the host refuses a module
3062
+ // whose code names a different one.
3063
+ authScheme: AuthSchemeReference2.optional(),
3052
3064
  // Opt this module's traffic into the daemon's known-resources ledger: the
3053
3065
  // HOST records the canonical URIs (plus title/summary/mime facts) that flow
3054
3066
  // through the module's successful read/list/search resolutions (a read only
@@ -3067,6 +3079,7 @@ function createContributionsSchemas(canonical) {
3067
3079
  const AppUriModuleContribution2 = UriModuleContribution2.omit({
3068
3080
  authActions: true,
3069
3081
  authService: true,
3082
+ authScheme: true,
3070
3083
  knownResources: true,
3071
3084
  describesOperations: true
3072
3085
  });
@@ -3906,10 +3919,7 @@ function createManifestSchemas(canonical) {
3906
3919
  /** Provider-specific query parameters added to the authorize URL. */
3907
3920
  extraAuthorizeParams: z13.record(NonEmptyString3, z13.string()).optional()
3908
3921
  };
3909
- const PluginAuthSchemeAccountLookup = z13.enum([
3910
- "resolveAccountId",
3911
- "resolveAccounts"
3912
- ]);
3922
+ const PluginAuthSchemeAccountLookup = z13.literal("lookup");
3913
3923
  const PluginAuthSchemeOAuthPkce = z13.strictObject({
3914
3924
  ...PluginProvisioningField,
3915
3925
  ...PluginAuthSchemeDescriptionFields,
@@ -3929,7 +3939,8 @@ function createManifestSchemas(canonical) {
3929
3939
  clientSecret: NonEmptyString3.optional(),
3930
3940
  /**
3931
3941
  * Where the account comes from (see {@link PluginAuthSchemeAccountLookup}); required with a
3932
- * `clientId`. A scheme without one is run by Bonsai's own client, which names the account.
3942
+ * `clientId`. A scheme without one runs on a client the host holds and may name a lookup too
3943
+ * (Google, Microsoft); naming none leaves the record under the placeholder account.
3933
3944
  */
3934
3945
  account: PluginAuthSchemeAccountLookup.optional(),
3935
3946
  /**
@@ -3950,8 +3961,8 @@ function createManifestSchemas(canonical) {
3950
3961
  }).refine((scheme) => scheme.clientSecret === void 0 || scheme.clientId !== void 0, {
3951
3962
  message: "clientSecret needs the clientId it belongs to",
3952
3963
  path: ["clientSecret"]
3953
- }).refine((scheme) => scheme.account === void 0 === (scheme.clientId === void 0), {
3954
- message: "a scheme with its own clientId names where its account comes from (`account`), and one without declares none",
3964
+ }).refine((scheme) => scheme.clientId === void 0 || scheme.account !== void 0, {
3965
+ message: "a scheme with its own clientId names where its account comes from (`account`)",
3955
3966
  path: ["account"]
3956
3967
  });
3957
3968
  const PluginAuthSchemeOAuthConfidential = z13.strictObject({
@@ -3991,10 +4002,11 @@ function createManifestSchemas(canonical) {
3991
4002
  /** Where and how the person creates the key outside Bonsai. */
3992
4003
  setup: z13.strictObject({ instructions: NonEmptyString3, url: HttpsUrl2 }).optional(),
3993
4004
  /**
3994
- * The plugin checks a key before it is saved, with the validator it registers for this scheme
3995
- * (`api.auth.registerValidator`).
4005
+ * `"lookup"`: the plugin checks a key before it is saved and names its account, with the function
4006
+ * it registers (`api.auth.registerAccountLookup`). Absent: the key is saved unchecked, under the
4007
+ * caller's account or the placeholder.
3996
4008
  */
3997
- validates: z13.literal(true).optional()
4009
+ account: PluginAuthSchemeAccountLookup.optional()
3998
4010
  });
3999
4011
  const PluginAuthSchemeDelegated = z13.strictObject({
4000
4012
  ...PluginAuthSchemeDescriptionFields,
@@ -4434,6 +4446,13 @@ function createManifestSchemas(canonical) {
4434
4446
  message: `uri module ${module.localId} references unknown auth service ${module.authService}`
4435
4447
  });
4436
4448
  }
4449
+ if (module.authScheme !== void 0 && (module.authService === void 0 || (isQualifiedAuthServiceRef(module.authService) ? namespaceOfQualifiedRef(module.authScheme) !== namespaceOfQualifiedRef(module.authService) : authSchemeIdsByService.get(module.authService)?.has(module.authScheme) !== true))) {
4450
+ ctx.addIssue({
4451
+ code: "custom",
4452
+ path: ["targets", "kay", "agent", "contributes", "uriModules"],
4453
+ message: `uri module ${module.localId} names auth scheme ${module.authScheme}, which is not a scheme of its authService`
4454
+ });
4455
+ }
4437
4456
  }
4438
4457
  for (const [index, tool] of (manifest.targets?.kay?.agent?.contributes?.tools ?? []).entries()) {
4439
4458
  const path = ["targets", "kay", "agent", "contributes", "tools", index];
@@ -5075,6 +5094,8 @@ function createResolvedContractSchemas(canonical) {
5075
5094
  schemes: z14.array(UriScheme2).min(1),
5076
5095
  displayName: NonEmptyString3.optional(),
5077
5096
  authServiceId: GlobalContributionId2.optional(),
5097
+ /** Mirrors `UriModuleContribution.authScheme`; a local ref takes the plugin's namespace. */
5098
+ authSchemeId: GlobalContributionId2.optional(),
5078
5099
  /** Mirrors `UriModuleContribution.knownResources` (host-side recording opt-in). */
5079
5100
  knownResources: z14.literal(true).optional(),
5080
5101
  /** Mirrors `UriModuleContribution.describesOperations`. */
@@ -5171,13 +5192,13 @@ function createResolvedContractSchemas(canonical) {
5171
5192
  clientSuppliers: z14.array(PluginOAuthClientSupplier2).nonempty(),
5172
5193
  clientId: NonEmptyString3.optional(),
5173
5194
  clientSecret: NonEmptyString3.optional(),
5174
- account: z14.enum(["resolveAccountId", "resolveAccounts"]).optional()
5195
+ account: z14.literal("lookup").optional()
5175
5196
  });
5176
5197
  const ResolvedPluginAuthSchemeOAuthConfidential = z14.strictObject({
5177
5198
  ...ResolvedPluginAuthSchemeOAuthBase,
5178
5199
  exchange: z14.literal("confidential"),
5179
5200
  clientSuppliers: z14.tuple([z14.literal("kay")]),
5180
- account: z14.enum(["resolveAccountId", "resolveAccounts", "sign-in"])
5201
+ account: z14.enum(["lookup", "sign-in"])
5181
5202
  });
5182
5203
  const ResolvedPluginAuthSchemeOAuth2 = z14.discriminatedUnion("exchange", [
5183
5204
  ResolvedPluginAuthSchemeOAuthPkce,
@@ -5194,7 +5215,7 @@ function createResolvedContractSchemas(canonical) {
5194
5215
  inputLabel: NonEmptyString3,
5195
5216
  fields: z14.array(z14.strictObject({ id: z14.string(), label: z14.string() })).optional(),
5196
5217
  setup: z14.strictObject({ instructions: z14.string(), url: HttpsUrl2 }).optional(),
5197
- validates: z14.literal(true).optional()
5218
+ account: z14.literal("lookup").optional()
5198
5219
  });
5199
5220
  const ResolvedPluginAuthSchemeDelegated = z14.strictObject({
5200
5221
  ...ResolvedPluginAuthSchemeDescriptionFields,
@@ -5558,7 +5579,7 @@ function resolveAuthServices(namespace, manifest) {
5558
5579
  inputLabel: scheme.inputLabel ?? `${service.displayName} API key`,
5559
5580
  ...scheme.fields === void 0 ? {} : { fields: scheme.fields.map((field) => ({ ...field })) },
5560
5581
  ...scheme.setup === void 0 ? {} : { setup: { ...scheme.setup } },
5561
- ...scheme.validates === void 0 ? {} : { validates: scheme.validates },
5582
+ ...scheme.account === void 0 ? {} : { account: scheme.account },
5562
5583
  ...scopesField,
5563
5584
  ...descriptionFields,
5564
5585
  ...provisioningField
@@ -5689,6 +5710,9 @@ function resolveKayPluginContractV1(manifest) {
5689
5710
  ...module.authService === void 0 ? {} : {
5690
5711
  authServiceId: isQualifiedAuthServiceRef(module.authService) ? module.authService : resolveGlobalContributionId(namespace, module.authService)
5691
5712
  },
5713
+ ...module.authScheme === void 0 ? {} : {
5714
+ authSchemeId: isQualifiedAuthSchemeRef(module.authScheme) ? module.authScheme : resolveGlobalContributionId(namespace, module.authScheme)
5715
+ },
5692
5716
  ...module.knownResources === void 0 ? {} : { knownResources: module.knownResources },
5693
5717
  ...module.describesOperations === void 0 ? {} : { describesOperations: module.describesOperations },
5694
5718
  ...uriModuleFacts(module)
@@ -5808,7 +5832,7 @@ function safeResolveKayPluginContractV1(manifest) {
5808
5832
  throw error;
5809
5833
  }
5810
5834
  }
5811
- function uriModuleFacts({ localId: _localId, schemes: _schemes, displayName: _displayName, authService: _authService, knownResources: _knownResources, describesOperations: _describesOperations, ...facts }) {
5835
+ function uriModuleFacts({ localId: _localId, schemes: _schemes, displayName: _displayName, authService: _authService, authScheme: _authScheme, knownResources: _knownResources, describesOperations: _describesOperations, ...facts }) {
5812
5836
  return facts;
5813
5837
  }
5814
5838
 
@@ -6765,6 +6789,7 @@ export {
6765
6789
  kayPluginHostCompatibility,
6766
6790
  kayUiEventSubscriptionsFromManifest,
6767
6791
  mintOperation,
6792
+ namespaceOfQualifiedRef,
6768
6793
  normalizeNetworkConnectHost,
6769
6794
  parseArtifactOutputUri,
6770
6795
  parseArtifactProvenanceCaptureContext,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@yaklabs-ai/plugin-protocol",
3
- "version": "0.27.0",
3
+ "version": "0.28.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",