@capybara-hq/plugin-sdk 0.1.0-rc.58 → 0.1.0-rc.59
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/plugin-format.md +6 -4
- package/dist/device-operation.d.ts +6 -0
- package/dist/device-operation.js +6 -0
- package/dist/device-provider.d.ts +4 -1
- package/dist/device-provider.js +4 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/plugin-manifest.js +19 -14
- package/dist/setup-guide.d.ts +9 -2
- package/dist/setup-guide.js +3 -1
- package/dist/tool.d.ts +30 -0
- package/package.json +1 -1
- package/schemas/plugin.v1.schema.json +8 -3
|
@@ -60,11 +60,12 @@ Rules that the schema cannot show:
|
|
|
60
60
|
Besides schemes and `fonts`, it may set `logo` (`mark`, `wordmark`, `favicon`, `illustration`,
|
|
61
61
|
`appIcon`, `appIconMaskable`), `decoration` (`dither` or `none`), `avatars` (at most 12 presets) and
|
|
62
62
|
`hideAvatarPresets`; every file it names is checked and packed, and nothing else is served.
|
|
63
|
-
- `setupGuides` (at most 8): `{ id, place,
|
|
63
|
+
- `setupGuides` (at most 8): `{ id, place, templates? }`. Each guide is a Markdown document at
|
|
64
64
|
`guides/<id>.md` (English, required) and `guides/<id>.zh.md` (Chinese, optional), shown where a
|
|
65
65
|
person sets up what the plugin brings. `place` is `channel-connection` (New channel and the channel
|
|
66
66
|
detail; the extension must provide `channel@1`; one per plugin), `connector-template`
|
|
67
|
-
(`
|
|
67
|
+
(`templates` names one or more of the plugin's `connectors/<id>.json`, so one guide may serve
|
|
68
|
+
several templates; a template has at most one guide) or
|
|
68
69
|
`extension-deployment` (the super admin's page of the extension; its checks get the extension's
|
|
69
70
|
platform deployment config and `orgId: null`, for credentials such as a push provider's key) or
|
|
70
71
|
`device-connection` (how a member connects a machine through a device provider). See "Setup
|
|
@@ -80,8 +81,9 @@ A guide is CommonMark + GFM:
|
|
|
80
81
|
- `{{name}}` variables come from the place, and none is ever a secret: everywhere `publicUrl`,
|
|
81
82
|
`orgName`, `pluginName`, `pluginVersion`, `mode`; `channel-connection` adds `webhookUrl`,
|
|
82
83
|
`signInCallbackUrl`, `connectionName`; `connector-template` adds `oauthCallbackUrl`,
|
|
83
|
-
`signInCallbackUrl`, `templateId`, `templateName
|
|
84
|
-
|
|
84
|
+
`signInCallbackUrl`, `templateId`, `templateName` (the template the guide is shown for),
|
|
85
|
+
`connectorName`; `extension-deployment` adds `signInCallbackUrl` (no modes, admin audience
|
|
86
|
+
only); `device-connection` has only `publicUrl`, `orgId`,
|
|
85
87
|
`orgName`, `pluginName` (no modes, member audience only). In `yaml` / `json` code put a
|
|
86
88
|
variable inside double quotes. Directive lines and fence info strings hold no variables.
|
|
87
89
|
- Sections: a line `::: mode webhook` (modes `long_connection`, `webhook`; channel guides) or
|
|
@@ -37,6 +37,12 @@ export declare function isSandboxScopeDeniedError(e: unknown): e is SandboxScope
|
|
|
37
37
|
* every scope check treats it as the definite pre-effect failure it is) that the operation path
|
|
38
38
|
* records as `not_sent`, never as an unknown outcome. It says nothing about an earlier request of
|
|
39
39
|
* the same operation, so a recovery tells it apart ({@link isDeviceRequestNotSent}).
|
|
40
|
+
*
|
|
41
|
+
* A provider throws it too when it finds the instance gone before contacting the machine (for
|
|
42
|
+
* example the machine's runtime changed since the instance was created), with a
|
|
43
|
+
* `SandboxGoneError` as its `cause`: nothing ran, and the kernel also rebuilds the instance so a
|
|
44
|
+
* retry of the call runs on the new one. A gone instance found after the request was sent is a
|
|
45
|
+
* bare `SandboxGoneError` (its outcome is unknown).
|
|
40
46
|
*/
|
|
41
47
|
export declare class DeviceRequestNotSentError extends SandboxScopeDeniedError {
|
|
42
48
|
readonly notSent: true;
|
package/dist/device-operation.js
CHANGED
|
@@ -57,6 +57,12 @@ export function isSandboxScopeDeniedError(e) {
|
|
|
57
57
|
* every scope check treats it as the definite pre-effect failure it is) that the operation path
|
|
58
58
|
* records as `not_sent`, never as an unknown outcome. It says nothing about an earlier request of
|
|
59
59
|
* the same operation, so a recovery tells it apart ({@link isDeviceRequestNotSent}).
|
|
60
|
+
*
|
|
61
|
+
* A provider throws it too when it finds the instance gone before contacting the machine (for
|
|
62
|
+
* example the machine's runtime changed since the instance was created), with a
|
|
63
|
+
* `SandboxGoneError` as its `cause`: nothing ran, and the kernel also rebuilds the instance so a
|
|
64
|
+
* retry of the call runs on the new one. A gone instance found after the request was sent is a
|
|
65
|
+
* bare `SandboxGoneError` (its outcome is unknown).
|
|
60
66
|
*/
|
|
61
67
|
export class DeviceRequestNotSentError extends SandboxScopeDeniedError {
|
|
62
68
|
notSent = true;
|
|
@@ -99,7 +99,10 @@ export interface ExecResult {
|
|
|
99
99
|
* The instance is definitely gone on the provider's side (container removed, E2B sandbox expired).
|
|
100
100
|
* `exec` / `readFile` / `writeFile` / `stat` must throw it (not a plain Error) when they find the
|
|
101
101
|
* instance gone; the kernel then rebuilds the instance and retries once. A transient connection
|
|
102
|
-
* failure throws a plain error.
|
|
102
|
+
* failure throws a plain error. In a managed operation (`operation()`), a gone instance found
|
|
103
|
+
* **before** the request reached the machine throws a `DeviceRequestNotSentError` with this error
|
|
104
|
+
* as its `cause`: the operation is then recorded as not started rather than as an unknown outcome,
|
|
105
|
+
* and the instance is still rebuilt, so the call can be retried on it.
|
|
103
106
|
*/
|
|
104
107
|
export declare class SandboxGoneError extends Error {
|
|
105
108
|
readonly sandboxGone: true;
|
package/dist/device-provider.js
CHANGED
|
@@ -27,7 +27,10 @@ export function rootsOf(h) {
|
|
|
27
27
|
* The instance is definitely gone on the provider's side (container removed, E2B sandbox expired).
|
|
28
28
|
* `exec` / `readFile` / `writeFile` / `stat` must throw it (not a plain Error) when they find the
|
|
29
29
|
* instance gone; the kernel then rebuilds the instance and retries once. A transient connection
|
|
30
|
-
* failure throws a plain error.
|
|
30
|
+
* failure throws a plain error. In a managed operation (`operation()`), a gone instance found
|
|
31
|
+
* **before** the request reached the machine throws a `DeviceRequestNotSentError` with this error
|
|
32
|
+
* as its `cause`: the operation is then recorded as not started rather than as an unknown outcome,
|
|
33
|
+
* and the instance is still rebuilt, so the call can be retried on it.
|
|
31
34
|
*/
|
|
32
35
|
export class SandboxGoneError extends Error {
|
|
33
36
|
sandboxGone = true;
|
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
package/dist/plugin-manifest.js
CHANGED
|
@@ -114,9 +114,12 @@ const setupGuide = z.strictObject({
|
|
|
114
114
|
message: "id must match ^[a-z0-9][a-z0-9-]{0,63}$",
|
|
115
115
|
}),
|
|
116
116
|
place: z.enum(SETUP_GUIDE_PLACES),
|
|
117
|
-
|
|
118
|
-
.string()
|
|
119
|
-
|
|
117
|
+
templates: z
|
|
118
|
+
.array(z.string().regex(CATALOG_ITEM_NAME_RE, {
|
|
119
|
+
message: "a template must match ^[a-z0-9][a-z0-9-]{0,63}$",
|
|
120
|
+
}))
|
|
121
|
+
.min(1)
|
|
122
|
+
.max(SETUP_GUIDE_LIMITS.templatesPerGuide)
|
|
120
123
|
.optional(),
|
|
121
124
|
});
|
|
122
125
|
const clientSection = z
|
|
@@ -271,21 +274,23 @@ const schema = z
|
|
|
271
274
|
issue(["setupGuides", i, "id"], `duplicate setup guide id ${g.id}`);
|
|
272
275
|
guideIds.add(g.id);
|
|
273
276
|
if (g.place === "connector-template") {
|
|
274
|
-
if (g.
|
|
275
|
-
issue(["setupGuides", i, "
|
|
277
|
+
if (g.templates === undefined) {
|
|
278
|
+
issue(["setupGuides", i, "templates"], "templates is required for a connector-template guide");
|
|
276
279
|
}
|
|
277
280
|
else {
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
281
|
+
g.templates.forEach((t, j) => {
|
|
282
|
+
if (m.connectorTemplates !== undefined && !ids.has(t)) {
|
|
283
|
+
issue(["setupGuides", i, "templates", j], `template ${t} is not one of the plugin's connector templates`);
|
|
284
|
+
}
|
|
285
|
+
if (guideTemplates.has(t)) {
|
|
286
|
+
issue(["setupGuides", i, "templates", j], `at most one setup guide per connector template (${t} is named twice)`);
|
|
287
|
+
}
|
|
288
|
+
guideTemplates.add(t);
|
|
289
|
+
});
|
|
285
290
|
}
|
|
286
291
|
}
|
|
287
|
-
else if (g.
|
|
288
|
-
issue(["setupGuides", i, "
|
|
292
|
+
else if (g.templates !== undefined) {
|
|
293
|
+
issue(["setupGuides", i, "templates"], "templates is only for connector-template guides");
|
|
289
294
|
}
|
|
290
295
|
if (g.place === "channel-connection") {
|
|
291
296
|
channelGuides++;
|
package/dist/setup-guide.d.ts
CHANGED
|
@@ -37,6 +37,8 @@ export declare const SETUP_GUIDE_PLACE_INFO: Readonly<Record<SetupGuidePlace, Se
|
|
|
37
37
|
export declare const SETUP_GUIDE_LIMITS: {
|
|
38
38
|
/** Guides per plugin. */
|
|
39
39
|
readonly guides: 8;
|
|
40
|
+
/** Connector templates one `connector-template` guide covers. */
|
|
41
|
+
readonly templatesPerGuide: 64;
|
|
40
42
|
/** Bytes per document (each language). */
|
|
41
43
|
readonly docBytes: 65536;
|
|
42
44
|
/** Fenced code blocks per document. */
|
|
@@ -61,8 +63,13 @@ export interface PluginSetupGuide {
|
|
|
61
63
|
/** `^[a-z0-9][a-z0-9-]{0,63}$`, unique in the plugin; the documents are `guides/<id>.md`. */
|
|
62
64
|
id: string;
|
|
63
65
|
place: SetupGuidePlace;
|
|
64
|
-
/**
|
|
65
|
-
|
|
66
|
+
/**
|
|
67
|
+
* Only and required for `connector-template`: the plugin's connector template ids the guide is
|
|
68
|
+
* for (one or more, at most {@link SETUP_GUIDE_LIMITS}`.templatesPerGuide`). A template has at
|
|
69
|
+
* most one guide; `{{templateId}}` / `{{templateName}}` render the template the guide is shown
|
|
70
|
+
* for.
|
|
71
|
+
*/
|
|
72
|
+
templates?: string[];
|
|
66
73
|
}
|
|
67
74
|
/** The package path of a guide's document: `guides/<id>.md` (en) or `guides/<id>.zh.md` (zh). */
|
|
68
75
|
export declare function setupGuideDocPath(id: string, locale: "en" | "zh"): string;
|
package/dist/setup-guide.js
CHANGED
|
@@ -62,7 +62,7 @@ export const SETUP_GUIDE_PLACE_INFO = {
|
|
|
62
62
|
"extension-deployment": {
|
|
63
63
|
modes: [],
|
|
64
64
|
audiences: ["admin"],
|
|
65
|
-
variables: { ...COMMON_VARIABLES, pluginName: "text" },
|
|
65
|
+
variables: { ...COMMON_VARIABLES, pluginName: "text", signInCallbackUrl: "url" },
|
|
66
66
|
drift: false,
|
|
67
67
|
shellActions: [],
|
|
68
68
|
},
|
|
@@ -78,6 +78,8 @@ export const SETUP_GUIDE_PLACE_INFO = {
|
|
|
78
78
|
export const SETUP_GUIDE_LIMITS = {
|
|
79
79
|
/** Guides per plugin. */
|
|
80
80
|
guides: 8,
|
|
81
|
+
/** Connector templates one `connector-template` guide covers. */
|
|
82
|
+
templatesPerGuide: 64,
|
|
81
83
|
/** Bytes per document (each language). */
|
|
82
84
|
docBytes: 65536,
|
|
83
85
|
/** Fenced code blocks per document. */
|
package/dist/tool.d.ts
CHANGED
|
@@ -146,12 +146,42 @@ export interface InputRequired {
|
|
|
146
146
|
state?: unknown;
|
|
147
147
|
}
|
|
148
148
|
export type FormAnswer = Record<string, string | number | boolean | string[]>;
|
|
149
|
+
/**
|
|
150
|
+
* What a tool handler gets with each invocation.
|
|
151
|
+
*
|
|
152
|
+
* **Side effects and idempotency.** The kernel runs a call's effect at most once: it records
|
|
153
|
+
* that the call started before invoking the handler, and when a run dies after that and before
|
|
154
|
+
* the result is recorded, the result is written as unknown (an error result the model sees:
|
|
155
|
+
* `Result unknown: the call was interrupted before a result was recorded. Verify the outcome
|
|
156
|
+
* before retrying.`) and **the handler is never called again** for that call. The model, or a
|
|
157
|
+
* person, may then decide to call the tool again: that is a new call with a new `callId`.
|
|
158
|
+
*
|
|
159
|
+
* One logical call may still invoke the handler more than once: each `InputRequired` round
|
|
160
|
+
* resumes it with `resume`. `callId` and `idempotencyKey` stay the same across those
|
|
161
|
+
* invocations. A tool with an external side effect passes `idempotencyKey` downstream (for
|
|
162
|
+
* example as an `Idempotency-Key` header, or stored with the record it creates) so the effect
|
|
163
|
+
* applies once per logical call and an unknown outcome can be checked against the external
|
|
164
|
+
* system before retrying.
|
|
165
|
+
*/
|
|
149
166
|
export interface ToolCallContext {
|
|
150
167
|
orgId: string;
|
|
151
168
|
accountId: string;
|
|
152
169
|
agentId: string;
|
|
153
170
|
conversationId: string;
|
|
171
|
+
/**
|
|
172
|
+
* The model's id for this call. Stable across every invocation of one logical call (the
|
|
173
|
+
* `InputRequired` rounds), but unique only within its run: two runs of one conversation may
|
|
174
|
+
* reuse an id, so `conversationId` + `callId` is not a key. Use `idempotencyKey`.
|
|
175
|
+
*/
|
|
154
176
|
callId: string;
|
|
177
|
+
/**
|
|
178
|
+
* The key of this logical call for idempotent side effects: 64 lowercase hex characters derived
|
|
179
|
+
* from the conversation, the run and `callId`. The same for every invocation of the call
|
|
180
|
+
* (each `InputRequired` round), different for every other call, including a later call the
|
|
181
|
+
* model makes to retry it. Optional in the type so older extensions compile; the kernel always
|
|
182
|
+
* passes it.
|
|
183
|
+
*/
|
|
184
|
+
idempotencyKey?: string;
|
|
155
185
|
signal: AbortSignal;
|
|
156
186
|
/** null = the user cancelled or it timed out. */
|
|
157
187
|
resume?: {
|
package/package.json
CHANGED
|
@@ -229,9 +229,14 @@
|
|
|
229
229
|
"device-connection"
|
|
230
230
|
]
|
|
231
231
|
},
|
|
232
|
-
"
|
|
233
|
-
"
|
|
234
|
-
"
|
|
232
|
+
"templates": {
|
|
233
|
+
"minItems": 1,
|
|
234
|
+
"maxItems": 64,
|
|
235
|
+
"type": "array",
|
|
236
|
+
"items": {
|
|
237
|
+
"type": "string",
|
|
238
|
+
"pattern": "^[a-z0-9][a-z0-9-]{0,63}$"
|
|
239
|
+
}
|
|
235
240
|
}
|
|
236
241
|
},
|
|
237
242
|
"required": [
|