@capybara-hq/plugin-sdk 0.1.0-rc.32 → 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.
- package/agent-docs/extension-points/channel.md +1 -1
- package/agent-docs/extension-points/file-preview.md +2 -0
- package/dist/cards.d.ts +11 -0
- package/dist/cards.js +1 -1
- package/dist/channel.d.ts +37 -0
- package/dist/file-preview.d.ts +22 -5
- package/dist/http-access.d.ts +10 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/ui-parts.d.ts +1 -1
- package/dist/ui-parts.js +11 -0
- package/dist/ui.d.ts +25 -6
- package/package.json +1 -1
|
@@ -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.
|
|
@@ -12,4 +12,6 @@ Contract: FilePreviewProvider (`file-preview.ts`)
|
|
|
12
12
|
|
|
13
13
|
Declare which file types you can preview and render them through schema views or an approved embed. Enabled per org.
|
|
14
14
|
|
|
15
|
+
`render` args are a union on `source`: `"conversation"` (org, account, conversation) or `"share"` (org and share id; `file.id` is the share id; no account or conversation). A previewer that needs the conversation declines `source: "share"` by throwing; the kernel reports the failure and the share page falls to the next previewer. A share token is valid only for the `file.preview` slot, never for `/api`.
|
|
16
|
+
|
|
15
17
|
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/file-preview.d.ts
CHANGED
|
@@ -34,14 +34,12 @@ export interface FilePreviewer {
|
|
|
34
34
|
export interface FilePreviewProvider {
|
|
35
35
|
previewers: FilePreviewer[];
|
|
36
36
|
}
|
|
37
|
-
/**
|
|
38
|
-
export interface
|
|
39
|
-
orgId: string;
|
|
40
|
-
accountId: string;
|
|
41
|
-
conversationId: string;
|
|
37
|
+
/** What every {@link FilePreviewArgs} variant carries. */
|
|
38
|
+
export interface FilePreviewArgsBase {
|
|
42
39
|
locale: Locale;
|
|
43
40
|
/** Aborted at the kernel's time limit: stop reading and rendering. */
|
|
44
41
|
signal: AbortSignal;
|
|
42
|
+
/** In the share variant `file.id` is the share id. */
|
|
45
43
|
file: {
|
|
46
44
|
id: string;
|
|
47
45
|
name: string;
|
|
@@ -62,6 +60,25 @@ export interface FilePreviewArgs {
|
|
|
62
60
|
*/
|
|
63
61
|
config?: unknown;
|
|
64
62
|
}
|
|
63
|
+
/** A preview inside a conversation; identities come from the kernel after authentication. */
|
|
64
|
+
export interface FilePreviewConversationArgs extends FilePreviewArgsBase {
|
|
65
|
+
source: "conversation";
|
|
66
|
+
orgId: string;
|
|
67
|
+
accountId: string;
|
|
68
|
+
conversationId: string;
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* A preview on a share page: there is no account and no conversation. A previewer that needs the
|
|
72
|
+
* conversation declines this variant by throwing; the kernel reports the failure and the page falls
|
|
73
|
+
* to the next previewer.
|
|
74
|
+
*/
|
|
75
|
+
export interface FilePreviewShareArgs extends FilePreviewArgsBase {
|
|
76
|
+
source: "share";
|
|
77
|
+
orgId: string;
|
|
78
|
+
shareId: string;
|
|
79
|
+
}
|
|
80
|
+
/** Arguments of {@link FilePreviewer.render}: narrow on `source`. */
|
|
81
|
+
export type FilePreviewArgs = FilePreviewConversationArgs | FilePreviewShareArgs;
|
|
65
82
|
/** Checks a `file-preview@1` provider; returns the problems (empty = valid). */
|
|
66
83
|
export declare function validateFilePreviewProvider(p: unknown): string[];
|
|
67
84
|
/** Whether a previewer takes this file: its type or extension is accepted and it is within `maxBytes`. */
|
package/dist/http-access.d.ts
CHANGED
|
@@ -43,6 +43,16 @@ export type RouteCaller = {
|
|
|
43
43
|
contribution: string;
|
|
44
44
|
/** The token's expiry (Unix seconds): a long-lived response (SSE) ends by then. */
|
|
45
45
|
exp: number;
|
|
46
|
+
} | {
|
|
47
|
+
/** A share page's `file.preview` embed: no account, no role. */
|
|
48
|
+
access: "embed";
|
|
49
|
+
scope: "share";
|
|
50
|
+
orgId: string;
|
|
51
|
+
shareId: string;
|
|
52
|
+
contribution: string;
|
|
53
|
+
/** The token's expiry (Unix seconds): a long-lived response (SSE) ends by then. */
|
|
54
|
+
exp: number;
|
|
55
|
+
config: unknown;
|
|
46
56
|
} | {
|
|
47
57
|
access: "member" | "admin";
|
|
48
58
|
orgId: string;
|
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
package/dist/ui-parts.d.ts
CHANGED
|
@@ -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/dist/ui.d.ts
CHANGED
|
@@ -270,10 +270,9 @@ export type UiActionResult = {
|
|
|
270
270
|
} | {
|
|
271
271
|
view: UiView;
|
|
272
272
|
};
|
|
273
|
-
/** The embed claims
|
|
273
|
+
/** The embed claims every scope shares. `exp` is Unix seconds. */
|
|
274
274
|
export interface EmbedClaimsBase {
|
|
275
275
|
plugin: string;
|
|
276
|
-
accountId: string;
|
|
277
276
|
contribution: string;
|
|
278
277
|
exp: number;
|
|
279
278
|
}
|
|
@@ -281,6 +280,7 @@ export interface EmbedClaimsBase {
|
|
|
281
280
|
export interface OrgEmbedClaims extends EmbedClaimsBase {
|
|
282
281
|
scope: "org";
|
|
283
282
|
orgId: string;
|
|
283
|
+
accountId: string;
|
|
284
284
|
/**
|
|
285
285
|
* The caller's role: written at issuance; `ctx.ui.verifyEmbedToken` returns the current role at
|
|
286
286
|
* validation time.
|
|
@@ -295,18 +295,33 @@ export interface OrgEmbedClaims extends EmbedClaimsBase {
|
|
|
295
295
|
/** A `platform.page` embed token's claims: a super admin's, with no org, conversation, agent or file. */
|
|
296
296
|
export interface PlatformEmbedClaims extends EmbedClaimsBase {
|
|
297
297
|
scope: "platform";
|
|
298
|
+
accountId: string;
|
|
298
299
|
orgId?: undefined;
|
|
299
300
|
role: "superAdmin";
|
|
300
301
|
conversationId?: undefined;
|
|
301
302
|
agentId?: undefined;
|
|
302
303
|
fileId?: undefined;
|
|
303
304
|
}
|
|
305
|
+
/**
|
|
306
|
+
* A share page's `file.preview` embed token's claims: no account and no role, only the org, the
|
|
307
|
+
* share and the share's generation. Valid only for the `file.preview` slot, never for `/api`.
|
|
308
|
+
*/
|
|
309
|
+
export interface ShareEmbedClaims extends EmbedClaimsBase {
|
|
310
|
+
scope: "share";
|
|
311
|
+
orgId: string;
|
|
312
|
+
shareId: string;
|
|
313
|
+
generation: number;
|
|
314
|
+
accountId?: undefined;
|
|
315
|
+
role?: undefined;
|
|
316
|
+
conversationId?: undefined;
|
|
317
|
+
agentId?: undefined;
|
|
318
|
+
fileId?: undefined;
|
|
319
|
+
}
|
|
304
320
|
/**
|
|
305
321
|
* Claims in an embed token (trustworthy after validation by `ctx.ui.verifyEmbedToken`): narrow on
|
|
306
|
-
* `scope` (`"platform"` has no
|
|
307
|
-
* `orgId` and `role` `"superAdmin"`).
|
|
322
|
+
* `scope` (`"platform"` has no `orgId` and `role` `"superAdmin"`; `"share"` has no account or role).
|
|
308
323
|
*/
|
|
309
|
-
export type EmbedClaims = OrgEmbedClaims | PlatformEmbedClaims;
|
|
324
|
+
export type EmbedClaims = OrgEmbedClaims | PlatformEmbedClaims | ShareEmbedClaims;
|
|
310
325
|
/**
|
|
311
326
|
* The version marker of the `postMessage` protocol between the outer page and the embedded iframe.
|
|
312
327
|
*/
|
|
@@ -314,7 +329,7 @@ export declare const EMBED_PROTOCOL = "capybara-embed/1";
|
|
|
314
329
|
/**
|
|
315
330
|
* What an embed's `init` says about where it is shown, narrowed on `scope` like {@link EmbedClaims}:
|
|
316
331
|
* an org's page, panel, section or previewer (`orgId`, and the conversation when there is one), or
|
|
317
|
-
* a platform page of the admin console (no org).
|
|
332
|
+
* a platform page of the admin console (no org), or a share page (no org or conversation).
|
|
318
333
|
*/
|
|
319
334
|
export type EmbedInitContext = {
|
|
320
335
|
scope: "org";
|
|
@@ -324,6 +339,10 @@ export type EmbedInitContext = {
|
|
|
324
339
|
scope: "platform";
|
|
325
340
|
orgId?: undefined;
|
|
326
341
|
conversationId?: undefined;
|
|
342
|
+
} | {
|
|
343
|
+
scope: "share";
|
|
344
|
+
orgId?: undefined;
|
|
345
|
+
conversationId?: undefined;
|
|
327
346
|
};
|
|
328
347
|
/** Messages the outer page sends to the iframe. */
|
|
329
348
|
export type EmbedParentMessage = {
|