@capybara-hq/plugin-sdk 0.1.0-rc.51 → 0.1.0-rc.53

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.
@@ -43,6 +43,9 @@ Fields of `template`:
43
43
  tenant id). List only what really differs per org.
44
44
  - `auth`: the auth method without credentials: `none`, `bearer`, `basic`, `api_key`, `headers`,
45
45
  `oauth_code` or `oauth_client`, plus `ownership` (`org` or per member).
46
+ `oauth_code` may add `authorizationParams`, extra query parameters of the authorize request
47
+ (e.g. `{ "access_type": "offline", "prompt": "consent" }` for Google): at most 10, lowercase
48
+ names, plain values, never a secret, none of `OAUTH_RESERVED_AUTHORIZATION_PARAMS`.
46
49
  - `defaultToolPolicies`: tool name to `allow`, `ask` or `deny`. When unsure, do not write `allow`.
47
50
 
48
51
  Credentials and secret config are entered by the person on the `Platform` confirmation card (name
@@ -1,4 +1,11 @@
1
1
  import { z } from "zod";
2
+ /**
3
+ * Authorization request parameters the kernel sets itself, or that would change what the callback
4
+ * or the token exchange relies on, or that never belong on a URL. `oauth_code`
5
+ * `authorizationParams` cannot use them, nor can the query of a manual `authorizationUrl`; the kernel
6
+ * checks the list again before it builds an authorize URL.
7
+ */
8
+ export declare const OAUTH_RESERVED_AUTHORIZATION_PARAMS: readonly ["response_type", "client_id", "redirect_uri", "state", "code_challenge", "code_challenge_method", "scope", "resource", "response_mode", "request", "request_uri", "nonce", "dpop_jkt", "authorization_details", "client_secret", "client_assertion", "client_assertion_type", "code", "code_verifier", "grant_type", "refresh_token"];
2
9
  /**
3
10
  * Authentication method: only the type and non-secret fields; credential values go through the
4
11
  * kernel's `credential` / credentials API.
@@ -54,6 +61,7 @@ export declare const ConnectorAuthSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
54
61
  client_secret_post: "client_secret_post";
55
62
  }>>;
56
63
  tokenTypes: z.ZodOptional<z.ZodArray<z.ZodString>>;
64
+ authorizationParams: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
57
65
  }, z.core.$strict>, z.ZodObject<{
58
66
  type: z.ZodLiteral<"oauth_client">;
59
67
  ownership: z.ZodLiteral<"org">;
@@ -39,6 +39,54 @@ const TokenTypes = z
39
39
  .regex(/^[A-Za-z][A-Za-z0-9_.-]*$/, "Invalid token type")
40
40
  .refine((t) => t.toLowerCase() !== "dpop", "DPoP tokens are not bearer tokens"))
41
41
  .max(5);
42
+ /**
43
+ * Authorization request parameters the kernel sets itself, or that would change what the callback
44
+ * or the token exchange relies on, or that never belong on a URL. `oauth_code`
45
+ * `authorizationParams` cannot use them, nor can the query of a manual `authorizationUrl`; the kernel
46
+ * checks the list again before it builds an authorize URL.
47
+ */
48
+ export const OAUTH_RESERVED_AUTHORIZATION_PARAMS = [
49
+ // set by the kernel's authorize request
50
+ "response_type",
51
+ "client_id",
52
+ "redirect_uri",
53
+ "state",
54
+ "code_challenge",
55
+ "code_challenge_method",
56
+ "scope",
57
+ "resource",
58
+ // would change what the callback or the token exchange relies on
59
+ "response_mode",
60
+ "request",
61
+ "request_uri",
62
+ "nonce",
63
+ "dpop_jkt",
64
+ "authorization_details",
65
+ // credentials and token-endpoint names
66
+ "client_secret",
67
+ "client_assertion",
68
+ "client_assertion_type",
69
+ "code",
70
+ "code_verifier",
71
+ "grant_type",
72
+ "refresh_token",
73
+ ];
74
+ const RESERVED_PARAMS = new Set(OAUTH_RESERVED_AUTHORIZATION_PARAMS);
75
+ const reservedParamMessage = (name) => `"${name}" is set by the kernel and cannot be an authorization parameter`;
76
+ const MAX_AUTHORIZATION_PARAMS = 10;
77
+ /**
78
+ * Extra query parameters of the authorize request (e.g. Google's `access_type: "offline"`,
79
+ * `prompt: "consent"`): names `[a-z][a-z0-9_]` up to 40 characters, values 1-200 printable ASCII
80
+ * characters, at most 10, none of {@link OAUTH_RESERVED_AUTHORIZATION_PARAMS}. Not secrets: they
81
+ * are stored in plain JSON and shown in the browser's address bar.
82
+ */
83
+ const AuthorizationParams = z
84
+ .record(z.string().regex(/^[a-z][a-z0-9_]{0,39}$/, "Invalid authorization parameter name"), z.string().regex(/^[\x20-\x7E]{1,200}$/, "Invalid authorization parameter value"))
85
+ .refine((p) => Object.keys(p).length <= MAX_AUTHORIZATION_PARAMS, {
86
+ message: `At most ${MAX_AUTHORIZATION_PARAMS} authorization parameters`,
87
+ })
88
+ .describe("Extra query parameters of the OAuth authorize request (e.g. access_type, prompt). " +
89
+ "Never put a secret here.");
42
90
  /**
43
91
  * Authentication method: only the type and non-secret fields; credential values go through the
44
92
  * kernel's `credential` / credentials API.
@@ -77,9 +125,29 @@ export const ConnectorAuthSchema = z.discriminatedUnion("type", [
77
125
  client: z.enum(["dcr", "manual"]),
78
126
  tokenAuthMethod: TokenAuthMethod.optional(),
79
127
  tokenTypes: TokenTypes.optional(),
128
+ authorizationParams: AuthorizationParams.optional(),
80
129
  })
81
130
  .strict()
82
131
  .superRefine((a, ctx) => {
132
+ for (const name of Object.keys(a.authorizationParams ?? {})) {
133
+ if (RESERVED_PARAMS.has(name))
134
+ ctx.addIssue({
135
+ code: "custom",
136
+ path: ["authorizationParams", name],
137
+ message: reservedParamMessage(name),
138
+ });
139
+ }
140
+ // A query in a manual endpoint stays (RFC 6749 §3.1), but never with a name the kernel owns
141
+ if (a.authorizationUrl !== undefined && URL.canParse(a.authorizationUrl)) {
142
+ for (const name of new Set(new URL(a.authorizationUrl).searchParams.keys())) {
143
+ if (RESERVED_PARAMS.has(name.toLowerCase()))
144
+ ctx.addIssue({
145
+ code: "custom",
146
+ path: ["authorizationUrl"],
147
+ message: reservedParamMessage(name),
148
+ });
149
+ }
150
+ }
83
151
  if (a.discovery === "manual") {
84
152
  for (const k of ["authorizationUrl", "tokenUrl"]) {
85
153
  if (a[k] === undefined)
package/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- export declare const SDK_VERSION = "0.1.0-rc.51";
1
+ export declare const SDK_VERSION = "0.1.0-rc.53";
2
2
  export * from "./agent-template.js";
3
3
  export * from "./avatar-presets.js";
4
4
  export * from "./bootstrap.js";
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- export const SDK_VERSION = "0.1.0-rc.51";
1
+ export const SDK_VERSION = "0.1.0-rc.53";
2
2
  export * from "./agent-template.js";
3
3
  export * from "./avatar-presets.js";
4
4
  export * from "./bootstrap.js";
@@ -166,15 +166,21 @@ export declare const MOBILE_SHELL_LIMITS: {
166
166
  readonly shareTitle: 256;
167
167
  readonly shareText: 4000;
168
168
  readonly url: 2048;
169
- /** `nav@1`: a section or menu label is 1..32 characters. */
169
+ /** `nav@1`: an item or action label is 1..32 characters. */
170
170
  readonly navLabel: 32;
171
171
  /** `nav@1`: a badge count is an integer 0..9999 (`countMore` says there are more). */
172
172
  readonly navCount: 9999;
173
+ /** `nav@1`: the account's name is 1..64 characters (its initial 1..2). */
174
+ readonly navAccountName: 64;
173
175
  };
174
176
  /** The menu item id pattern, checked on `menu@1.show` (the shell validates every input). */
175
177
  export declare const MENU_ITEM_ID: RegExp;
176
- export type NavSectionId = "chats" | "inbox" | "agents" | "schedules";
177
- /** The strip's sections in display order. */
178
+ /**
179
+ * The strip's items: the four sections and, last, `search` (opens the web's command palette; never
180
+ * `current`).
181
+ */
182
+ export type NavSectionId = "chats" | "inbox" | "agents" | "schedules" | "search";
183
+ /** The strip's items in display order. */
178
184
  export declare const NAV_SECTION_ORDER: readonly NavSectionId[];
179
185
  export interface NavBadgeV1 {
180
186
  count?: number;
@@ -184,21 +190,53 @@ export interface NavItemV1 extends NavBadgeV1 {
184
190
  id: NavSectionId;
185
191
  label: string;
186
192
  }
187
- export interface NavMenuV1 extends NavBadgeV1 {
193
+ /**
194
+ * The pill's top item, accent-filled: the page's primary action, else the new conversation
195
+ * (`id` matches MENU_ITEM_ID, `label` 1..navLabel; the shell draws its own glyph per `icon`).
196
+ */
197
+ export interface NavActionV1 {
198
+ id: string;
188
199
  label: string;
200
+ icon: "plus" | "square-pen";
201
+ }
202
+ /**
203
+ * The account avatar under the strip's status: the image at `avatarUrl` (an absolute https URL
204
+ * or one on the profile's origin), else `initial` in a circle; `badge` a count 0..navCount.
205
+ */
206
+ export interface NavAccountV1 {
207
+ name: string;
208
+ avatarUrl?: string | null;
209
+ initial: string;
210
+ badge?: number;
189
211
  }
190
212
  export interface NavStateV1 {
191
- /** The sections the person sees, in NAV_SECTION_ORDER (a guest has no `schedules`). */
213
+ /** The items the person sees, in NAV_SECTION_ORDER (a guest has no `schedules`). */
192
214
  items: NavItemV1[];
215
+ /**
216
+ * The section of the page on screen; `null`: no section is selected and the shell clears its
217
+ * highlight (the new-conversation home, a page outside the sections). Never `search`.
218
+ */
193
219
  current: NavSectionId | null;
194
- /** The strip's menu button, or null for none (non-null while the web's class is compact). */
195
- menu: NavMenuV1 | null;
220
+ /** The pill's top item: the page's primary, else the new conversation (no menu button, D12). */
221
+ action: NavActionV1;
222
+ /** The avatar under the status (absent: the shell shows none). */
223
+ account?: NavAccountV1;
196
224
  }
197
- /** `nav@1`: offered only while the window has a strip (mobile app spec §6.1): presence is visibility. */
225
+ /**
226
+ * `nav@1`: offered only while the window has a strip (mobile app spec §6.1): presence is
227
+ * visibility. `side` is the edge the strip is on (right unless the app is the left one of a
228
+ * split), reported with the capability and updated with the envelope's `change`. The shell and
229
+ * the web ship this shape in lockstep (no older-shell path before 0.1.0): the shell's nav@1
230
+ * minor version of 2026-11-22 ships with or before the web that sends it.
231
+ */
198
232
  export interface NavCapabilityV1 {
199
233
  set(state: NavStateV1): Promise<void>;
200
234
  onSelect(listener: (id: NavSectionId) => void): () => void;
201
- onMenu(listener: () => void): () => void;
235
+ /** The pill's top item was tapped: the web runs the action. */
236
+ onAction(listener: () => void): () => void;
237
+ /** The account avatar was tapped: the web opens its account sheet. */
238
+ onAccount(listener: () => void): () => void;
239
+ readonly side?: "left" | "right";
202
240
  }
203
241
  /** `profiles@1`: the native profile switcher. */
204
242
  export interface ProfilesCapabilityV1 {
@@ -26,12 +26,20 @@ export const MOBILE_SHELL_LIMITS = {
26
26
  shareTitle: 256,
27
27
  shareText: 4000,
28
28
  url: 2048,
29
- /** `nav@1`: a section or menu label is 1..32 characters. */
29
+ /** `nav@1`: an item or action label is 1..32 characters. */
30
30
  navLabel: 32,
31
31
  /** `nav@1`: a badge count is an integer 0..9999 (`countMore` says there are more). */
32
32
  navCount: 9999,
33
+ /** `nav@1`: the account's name is 1..64 characters (its initial 1..2). */
34
+ navAccountName: 64,
33
35
  };
34
36
  /** The menu item id pattern, checked on `menu@1.show` (the shell validates every input). */
35
37
  export const MENU_ITEM_ID = /^[A-Za-z0-9_.-]{1,64}$/;
36
- /** The strip's sections in display order. */
37
- export const NAV_SECTION_ORDER = ["chats", "inbox", "agents", "schedules"];
38
+ /** The strip's items in display order. */
39
+ export const NAV_SECTION_ORDER = [
40
+ "chats",
41
+ "inbox",
42
+ "agents",
43
+ "schedules",
44
+ "search",
45
+ ];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@capybara-hq/plugin-sdk",
3
- "version": "0.1.0-rc.51",
3
+ "version": "0.1.0-rc.53",
4
4
  "description": "Capybara plugin SDK: the types and pure functions plugins are written against",
5
5
  "license": "Apache-2.0",
6
6
  "repository": {