@capybara-hq/plugin-sdk 0.1.0-rc.33 → 0.1.0-rc.35
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/concepts.md +9 -4
- package/agent-docs/extension-points/channel.md +1 -1
- package/agent-docs/extension-points/sandbox.md +1 -1
- package/agent-docs/plugin-format.md +1 -1
- package/dist/cards.d.ts +11 -0
- package/dist/cards.js +1 -1
- package/dist/channel.d.ts +37 -0
- package/dist/hooks.d.ts +13 -8
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/model.d.ts +4 -3
- package/dist/ui-parts.d.ts +1 -1
- package/dist/ui-parts.js +11 -0
- package/package.json +1 -1
package/agent-docs/concepts.md
CHANGED
|
@@ -52,10 +52,15 @@ When a person cannot do something themselves (install a plugin that is not on in
|
|
|
52
52
|
approve extension permissions), they file a **request**. Org admins or the super admin decide it
|
|
53
53
|
on the web. Agents can file requests but never decide them.
|
|
54
54
|
|
|
55
|
-
##
|
|
56
|
-
|
|
57
|
-
Agents run commands and keep files
|
|
58
|
-
|
|
55
|
+
## Devices
|
|
56
|
+
|
|
57
|
+
Agents run commands and keep files on a **device**: one instance plus a file system that is kept
|
|
58
|
+
until the device is deleted. A device is a cloud sandbox (from the deployment's sandbox provider)
|
|
59
|
+
or a machine connected with `capybara-device`, and the conversations that use it share its files.
|
|
60
|
+
A device runs in one of two modes: auto (the environment's own capability) or sandbox (an OS
|
|
61
|
+
sandbox with an allowlist network). Skill files are read-only in the device's skills directory;
|
|
62
|
+
each conversation is told the device's directories, mode and network. Sandbox limits and the
|
|
63
|
+
cloud network are set per org by admins.
|
|
59
64
|
|
|
60
65
|
## What agents may not do
|
|
61
66
|
|
|
@@ -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.
|
|
@@ -10,6 +10,6 @@
|
|
|
10
10
|
|
|
11
11
|
Contract: SandboxProvider (`sandbox.ts`)
|
|
12
12
|
|
|
13
|
-
The kernel accepts only `sandbox@2`. A device is one instance plus a file system that outlives it. Implement the file system (`createFileSystem`, `destroyFileSystem`, `destroyFileSystemByName`), the instance on it (`create`, which throws `FileSystemGoneError` when the file system is gone instead of making an empty one; `resume`, `suspend`; `destroy` and `destroyByName`, which drop the instance and keep the files), and the instance's `exec`, `readFile`, `writeFile`, `stat`, `killAll` and `killTagged` (`concurrentExec` is required: several conversations share one instance). Aborting a command must kill it. Locking, suspension timing and destruction are the kernel's job, not yours.
|
|
13
|
+
The kernel accepts only `sandbox@2`. A device is one instance plus a file system that outlives it. Implement the file system (`createFileSystem`, `destroyFileSystem`, `destroyFileSystemByName`), the instance on it (`create`, which throws `FileSystemGoneError` when the file system is gone instead of making an empty one; `resume`, `suspend`; `destroy` and `destroyByName`, which drop the instance and keep the files), and the instance's `exec`, `readFile`, `writeFile`, `stat`, `killAll` and `killTagged` (`concurrentExec` is required: several conversations share one instance). Aborting a command must kill it. Locking, suspension timing and destruction are the kernel's job, not yours.
|
|
14
14
|
|
|
15
15
|
See `extensions` for the rules every extension follows.
|
|
@@ -59,7 +59,7 @@ Rules that the schema cannot show:
|
|
|
59
59
|
by `parseThemeFile` (schema `https://capybarahq.com/schemas/theme.v1.schema.json`).
|
|
60
60
|
- `setupGuides` (at most 8): `{ id, place, template? }`. Each guide is a Markdown document at
|
|
61
61
|
`guides/<id>.md` (English, required) and `guides/<id>.zh.md` (Chinese, optional), shown where a
|
|
62
|
-
person sets up what the plugin brings. `place` is `channel-connection` (
|
|
62
|
+
person sets up what the plugin brings. `place` is `channel-connection` (New channel and the channel
|
|
63
63
|
detail; the extension must provide `channel@1`; one per plugin) or `connector-template`
|
|
64
64
|
(`template` names one of the plugin's `connectors/<id>.json`; one per template). See "Setup
|
|
65
65
|
guides" below.
|
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/hooks.d.ts
CHANGED
|
@@ -39,9 +39,11 @@ export interface HookScope {
|
|
|
39
39
|
* that writes a conversation's title after its first completed run (no run: `runId` is "", `step` 0,
|
|
40
40
|
* `attempt` 1), `web_fetch` is the call that extracts an answer from a fetched web page for the
|
|
41
41
|
* `WebFetch` tool, `review` is the command-review classifier's call (`review` purpose, no run
|
|
42
|
-
* step; absent = no classifier)
|
|
42
|
+
* step; absent = no classifier), `suggestion` is the prompt suggestion side request after a
|
|
43
|
+
* completed web run (`runId` the run, `step` 0, `attempt` 1; a denial skips it and is recorded only
|
|
44
|
+
* in the audit log).
|
|
43
45
|
*/
|
|
44
|
-
export type ModelCallPurpose = "step" | "compaction" | "title" | "web_fetch" | "review" | "image";
|
|
46
|
+
export type ModelCallPurpose = "step" | "compaction" | "title" | "web_fetch" | "review" | "image" | "suggestion";
|
|
45
47
|
/**
|
|
46
48
|
* What a reported or requested model call was for: the {@link ModelCallPurpose} values, or
|
|
47
49
|
* `embedding` for an embedding call an extension made through `ctx.models` (`usage.report`, and
|
|
@@ -86,8 +88,10 @@ export type HookModelRequest = Omit<ModelRequest, "messages"> & {
|
|
|
86
88
|
* `model.request` of a chat model call (see {@link ModelRequestHookPayload}): once per attempt of a
|
|
87
89
|
* step (`purpose: "step"`), once for each compaction call (`purpose: "compaction"`, `attempt` 1),
|
|
88
90
|
* once for each conversation title call (`purpose: "title"`, `runId` "", `step` 0, `attempt` 1; a
|
|
89
|
-
* denial skips the title and is recorded only in the audit log)
|
|
90
|
-
* extraction call (`purpose: "web_fetch"`)
|
|
91
|
+
* denial skips the title and is recorded only in the audit log), once for each `WebFetch`
|
|
92
|
+
* extraction call (`purpose: "web_fetch"`) and once for each prompt suggestion call
|
|
93
|
+
* (`purpose: "suggestion"`, `step` 0, `attempt` 1; a denial skips the suggestion and is recorded
|
|
94
|
+
* only in the audit log).
|
|
91
95
|
* `request` is the request as sent, except that images and documents are placeholders
|
|
92
96
|
* ({@link HookMediaPlaceholder}): no media bytes, no attachment ids.
|
|
93
97
|
*/
|
|
@@ -198,10 +202,11 @@ export interface ImageResponseHookPayload {
|
|
|
198
202
|
export type ModelRequestHookPayload = ModelCallRequestHookPayload | EmbeddingRequestHookPayload | ImageRequestHookPayload;
|
|
199
203
|
/**
|
|
200
204
|
* `model.response`: after a sent model call finished or failed, with its usage when known (step
|
|
201
|
-
* attempts, compaction and
|
|
202
|
-
* stopped while the call was in flight), nor for a call that was never sent
|
|
203
|
-
* before sending), so a `model.request` can have no matching `model.response`.
|
|
204
|
-
* is this or, for an image generation call, an
|
|
205
|
+
* attempts, compaction, title and suggestion calls, see `purpose`). Not fired for a call the user
|
|
206
|
+
* aborted (the run was stopped while the call was in flight), nor for a call that was never sent
|
|
207
|
+
* (denied, or failed before sending), so a `model.request` can have no matching `model.response`.
|
|
208
|
+
* The mount's payload is this or, for an image generation call, an
|
|
209
|
+
* {@link ImageResponseHookPayload}.
|
|
205
210
|
*/
|
|
206
211
|
export interface ModelResponseHookPayload extends HookScope {
|
|
207
212
|
purpose: Exclude<ModelCallPurpose, "image">;
|
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
package/dist/model.d.ts
CHANGED
|
@@ -255,9 +255,10 @@ export interface ModelRequest {
|
|
|
255
255
|
*/
|
|
256
256
|
params: Record<string, ParamValue>;
|
|
257
257
|
/**
|
|
258
|
-
* What this call is for, when the kernel says so: `"compaction"` for a conversation summary call
|
|
259
|
-
* Absent on ordinary step calls. Informational (a
|
|
260
|
-
* ignore it and must not forward it to a vendor
|
|
258
|
+
* What this call is for, when the kernel says so: `"compaction"` for a conversation summary call,
|
|
259
|
+
* `"suggestion"` for a prompt suggestion call. Absent on ordinary step calls. Informational (a
|
|
260
|
+
* scripted test model keys on it); real providers ignore it and must not forward it to a vendor
|
|
261
|
+
* API.
|
|
261
262
|
*/
|
|
262
263
|
purpose?: ModelCallPurpose;
|
|
263
264
|
}
|
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);
|