@capybara-hq/plugin-sdk 0.1.0-rc.33 → 0.1.0-rc.34

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.
@@ -10,6 +10,6 @@
10
10
 
11
11
  Contract: Channel (`channel.ts`)
12
12
 
13
- Normalize inbound events (messageId, threadId, tenantId, the bot mention stripped) and acknowledge only after the kernel's `onEvent` resolves. Long connections are held only by the gateway role. Replies use the card spec (`validateChannelCard`).
13
+ Normalize inbound events (messageId, threadId, tenantId, the bot mention stripped) and acknowledge only after the kernel's `onEvent` resolves. Long connections are held only by the gateway role. Replies use the card spec (`validateChannelCard`). Files: implement the optional `sendFile` and declare `features.files` (the platform's bot limits); the kernel sends each conversation artifact as one message and falls back to a link line without it.
14
14
 
15
15
  See `extensions` for the rules every extension follows.
package/dist/cards.d.ts CHANGED
@@ -91,6 +91,17 @@ export declare function questionRenderableInline(form: InputForm, opts?: {
91
91
  export declare function validateChannelCard(card: unknown): string[];
92
92
  /** A UI locale. */
93
93
  export type Locale = "zh" | "en";
94
+ /**
95
+ * Puts model-controllable values (approval title, call summary, question title, answer summary)
96
+ * into code, so that in the fallback text they do not turn into links, emphasis or HTML:
97
+ * single-line values use inline code, multi-line values a fenced code block (starting with a
98
+ * newline); the delimiters are always longer than the longest backtick run in the value (CommonMark
99
+ * 6.1 / 4.5).
100
+ * Code is chosen over backslash-escaping punctuation because code is the only form CommonMark / GFM
101
+ * guarantee to display content verbatim (a backslash does not stop GFM bare-URL
102
+ * autolinks, and channel converters treat backslashes inconsistently).
103
+ */
104
+ export declare function asCode(s: string): string;
94
105
  /** The hint line of a pending question card with `textReply`, as {@link renderCardAsText} writes it. */
95
106
  export declare function questionTextReplyHint(mode: "plain" | "mention", locale: Locale): string;
96
107
  /**
package/dist/cards.js CHANGED
@@ -125,7 +125,7 @@ export function validateChannelCard(card) {
125
125
  * guarantee to display content verbatim (a backslash does not stop GFM bare-URL
126
126
  * autolinks, and channel converters treat backslashes inconsistently).
127
127
  */
128
- function asCode(s) {
128
+ export function asCode(s) {
129
129
  const v = s.replace(/\r\n?/g, "\n");
130
130
  const longest = Math.max(0, ...[...v.matchAll(/`+/g)].map((m) => m[0].length));
131
131
  if (v.includes("\n")) {
package/dist/channel.d.ts CHANGED
@@ -202,6 +202,25 @@ export interface ChannelWebhook {
202
202
  signal: AbortSignal;
203
203
  }): Promise<ChannelWebhookResult>;
204
204
  }
205
+ /** One conversation artifact handed to {@link Channel.sendFile}. */
206
+ export interface ChannelFile {
207
+ /** File name shown to the user. Model-controlled: never interpret it as markup, a path or a mention. */
208
+ name: string;
209
+ contentType: string;
210
+ /** Chosen by the kernel (an image type within the image cap, else a file). */
211
+ kind: "image" | "file";
212
+ data: Uint8Array;
213
+ }
214
+ /** Arguments of {@link Channel.sendFile}: one file for one message; the whole file is in memory. */
215
+ export interface ChannelSendFileArgs {
216
+ config: unknown;
217
+ target: ChannelTarget;
218
+ file: ChannelFile;
219
+ signal: AbortSignal;
220
+ locale: Locale;
221
+ /** Same semantics as {@link ChannelSendArgs.idempotencyKey}. */
222
+ idempotencyKey?: string;
223
+ }
205
224
  /** A channel implementation (the bot uses the channel connection config). */
206
225
  export interface Channel {
207
226
  /** Schema of the channel connection config; secret fields use secret(). */
@@ -210,12 +229,19 @@ export interface Channel {
210
229
  * `minEditIntervalMs`: the minimum interval the platform allows between two edits of the same
211
230
  * message; the kernel's streaming-draft update interval is
212
231
  * `max(1000, minEditIntervalMs)`.
232
+ *
233
+ * `files`: present iff `sendFile` is implemented; the kernel never hands a file larger than
234
+ * `maxBytes`, and sends `kind: "image"` only within `imageMaxBytes ?? maxBytes`.
213
235
  */
214
236
  features: {
215
237
  cards: boolean;
216
238
  edit: boolean;
217
239
  threads: boolean;
218
240
  minEditIntervalMs?: number;
241
+ files?: {
242
+ maxBytes: number;
243
+ imageMaxBytes?: number;
244
+ };
219
245
  };
220
246
  verify(args: {
221
247
  config: unknown;
@@ -247,6 +273,17 @@ export interface Channel {
247
273
  update(args: ChannelSendArgs & {
248
274
  messageId: string;
249
275
  }): Promise<void>;
276
+ /**
277
+ * Optional file delivery: one message per file; the kernel picks `kind`; an extension may send an
278
+ * `image` as a file when the platform refuses it as an image, never the reverse; `messageId`
279
+ * when the platform returns it; failures as {@link ChannelSendError} (`send`); never put an
280
+ * upload URL in an error. Throw a missing upload permission or scope as a non-retryable
281
+ * {@link ChannelSendError} with `reason: "rejected"`, never `auth`: `auth` stops the whole
282
+ * delivery of the conversation, text included, while `rejected` only turns this file into a link.
283
+ */
284
+ sendFile?(args: ChannelSendFileArgs): Promise<{
285
+ messageId?: string;
286
+ }>;
250
287
  /**
251
288
  * Optional webhook inbound (see {@link ChannelWebhook}). Only connections of plugins that
252
289
  * implement it can be switched from the default long connection to webhook mode; a connection in
package/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- export declare const SDK_VERSION = "0.1.0-rc.33";
1
+ export declare const SDK_VERSION = "0.1.0-rc.34";
2
2
  export * from "./agent-template.js";
3
3
  export * from "./bootstrap.js";
4
4
  export * from "./cards.js";
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- export const SDK_VERSION = "0.1.0-rc.33";
1
+ export const SDK_VERSION = "0.1.0-rc.34";
2
2
  export * from "./agent-template.js";
3
3
  export * from "./bootstrap.js";
4
4
  export * from "./cards.js";
@@ -1,7 +1,7 @@
1
1
  /** The ARIA / data states a part promises (client extensions spec §7.1). */
2
2
  export type UiPartState = "aria-current" | "aria-selected" | "aria-expanded" | "aria-busy" | "aria-checked" | "aria-pressed" | "disabled";
3
3
  /** Every part name of the catalog, in catalog order. */
4
- export declare const UI_PART_NAMES: readonly ["shell", "sidebar", "sidebar.brand", "sidebar.item", "title-bar", "page-header", "thread", "message.user", "message.user.bubble", "message.assistant", "tool-row", "composer", "properties-panel", "section", "right-panel", "status-bar", "button", "button.primary", "card", "input", "dialog", "code-block", "menu", "segmented", "stat-card", "switch", "switch.knob", "org-avatar", "agent-chip"];
4
+ export declare const UI_PART_NAMES: readonly ["shell", "sidebar", "sidebar.brand", "sidebar.item", "title-bar", "page-header", "thread", "message.user", "message.user.bubble", "message.assistant", "tool-row", "composer", "properties-panel", "section", "right-panel", "status-bar", "button", "button.primary", "card", "input", "dialog", "code-block", "menu", "segmented", "stat-card", "switch", "switch.knob", "org-avatar", "agent-chip", "image-placeholder"];
5
5
  export type UiPartName = (typeof UI_PART_NAMES)[number];
6
6
  /** One built-in element plugin CSS may select with `[data-cap-part~="<name>"]`. */
7
7
  export interface UiPartSpec {
package/dist/ui-parts.js CHANGED
@@ -29,6 +29,7 @@ export const UI_PART_NAMES = [
29
29
  "switch.knob",
30
30
  "org-avatar",
31
31
  "agent-chip",
32
+ "image-placeholder",
32
33
  ];
33
34
  export const UI_PARTS = [
34
35
  {
@@ -331,6 +332,16 @@ export const UI_PARTS = [
331
332
  zh: "新会话智能体行里的智能体标签;选中的那个带 aria-pressed。",
332
333
  },
333
334
  },
335
+ {
336
+ name: "image-placeholder",
337
+ version: 1,
338
+ owner: ["packages/design/src/conversation/files.tsx"],
339
+ states: ["aria-busy"],
340
+ description: {
341
+ en: "A generating image's placeholder in the conversation.",
342
+ zh: "对话中正在生成的图片的占位框。",
343
+ },
344
+ },
334
345
  ];
335
346
  export function uiPart(name) {
336
347
  return UI_PARTS.find((p) => p.name === name);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@capybara-hq/plugin-sdk",
3
- "version": "0.1.0-rc.33",
3
+ "version": "0.1.0-rc.34",
4
4
  "description": "Capybara plugin SDK: the types and pure functions plugins are written against",
5
5
  "license": "Apache-2.0",
6
6
  "repository": {