@capybara-hq/plugin-sdk 0.1.0-rc.25 → 0.1.0-rc.27
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/model-provider.md +3 -1
- package/agent-docs/extension-points/object-store.md +2 -0
- package/dist/cards.d.ts +17 -8
- package/dist/cards.js +21 -10
- package/dist/channel.d.ts +91 -47
- package/dist/channel.js +10 -5
- package/dist/connector-auth.d.ts +5 -2
- package/dist/connector-auth.js +14 -8
- package/dist/connector.d.ts +67 -32
- package/dist/ctx.d.ts +41 -23
- package/dist/define-extension.d.ts +21 -11
- package/dist/define-extension.js +10 -4
- package/dist/device-protocol.d.ts +2 -1
- package/dist/extension-point.js +1 -1
- package/dist/hooks.d.ts +6 -4
- package/dist/identity.d.ts +22 -9
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/model-params.d.ts +41 -22
- package/dist/model-params.js +28 -15
- package/dist/model.d.ts +121 -70
- package/dist/model.js +49 -19
- package/dist/permissions.d.ts +6 -6
- package/dist/permissions.js +8 -32
- package/dist/plugin-package.d.ts +79 -38
- package/dist/plugin-package.js +57 -29
- package/dist/sandbox-linux-runtime-source.d.ts +15 -0
- package/dist/sandbox-linux-runtime-source.js +1412 -0
- package/dist/sandbox-runtime-source.d.ts +9 -3
- package/dist/sandbox-runtime-source.js +16 -4
- package/dist/sandbox.d.ts +4 -1
- package/dist/sandbox.js +7 -3
- package/dist/secret.d.ts +4 -1
- package/dist/secret.js +4 -1
- package/dist/setup-guide.d.ts +1 -1
- package/dist/setup-guide.js +1 -1
- package/dist/skill.d.ts +27 -17
- package/dist/skill.js +39 -25
- package/dist/storage.d.ts +52 -25
- package/dist/tool.d.ts +51 -23
- package/dist/tool.js +21 -9
- package/dist/ui-resolve.d.ts +2 -7
- package/dist/ui-resolve.js +7 -19
- package/dist/ui-slots.d.ts +1 -3
- package/dist/ui-slots.js +0 -9
- package/dist/ui.d.ts +63 -49
- package/dist/ui.js +36 -22
- package/dist/url.d.ts +4 -1
- package/dist/url.js +4 -1
- package/package.json +1 -1
package/dist/connector.d.ts
CHANGED
|
@@ -1,16 +1,19 @@
|
|
|
1
1
|
import type { ZodTypeAny } from "zod";
|
|
2
2
|
import type { FormAnswer, ToolContent, ToolResult, ToolSpec } from "./tool.js";
|
|
3
|
-
/**
|
|
3
|
+
/** Authentication information injected into outbound requests. */
|
|
4
4
|
export interface AuthInjection {
|
|
5
5
|
headers: Record<string, string>;
|
|
6
6
|
query?: Record<string, string>;
|
|
7
7
|
}
|
|
8
|
-
/**
|
|
8
|
+
/** One session between the connector and the remote service. */
|
|
9
9
|
export interface ConnectorSession {
|
|
10
10
|
listTools(): Promise<ToolSpec[]>;
|
|
11
11
|
/**
|
|
12
|
-
* `ctx.spec
|
|
13
|
-
* `connectorData
|
|
12
|
+
* `ctx.spec`: the already-reviewed definition of this tool in the kernel snapshot
|
|
13
|
+
* (`connector_tools.spec`, never a new definition awaiting review), including the `connectorData`
|
|
14
|
+
* given at listTools.
|
|
15
|
+
* The connector should route the call by it rather than re-reading the remote description (remote
|
|
16
|
+
* changes must pass drift review first). Old kernels do not pass it; check for absence.
|
|
14
17
|
*/
|
|
15
18
|
callTool(name: string, input: unknown, signal: AbortSignal, ctx?: {
|
|
16
19
|
spec: ToolSpec;
|
|
@@ -22,13 +25,19 @@ export interface ConnectorSession {
|
|
|
22
25
|
mimeType?: string;
|
|
23
26
|
}[]>;
|
|
24
27
|
readResource?(uri: string): Promise<ToolResult>;
|
|
25
|
-
/**
|
|
28
|
+
/**
|
|
29
|
+
* Optional: prompt templates the remote provides (e.g. MCP prompts). Do not implement when
|
|
30
|
+
* unsupported; the kernel must check for absence.
|
|
31
|
+
*/
|
|
26
32
|
listPrompts?(): Promise<PromptInfo[]>;
|
|
27
|
-
/**
|
|
33
|
+
/**
|
|
34
|
+
* Optional: renders a prompt template with arguments and returns messages (e.g. MCP
|
|
35
|
+
* `prompts/get`). On failure throw ToolError (English, no credentials).
|
|
36
|
+
*/
|
|
28
37
|
getPrompt?(name: string, args: Record<string, string>): Promise<RenderedPrompt>;
|
|
29
38
|
close(): Promise<void>;
|
|
30
39
|
}
|
|
31
|
-
/**
|
|
40
|
+
/** A remote prompt template (the `/connector:promptName` slash command). */
|
|
32
41
|
export interface PromptInfo {
|
|
33
42
|
name: string;
|
|
34
43
|
title?: string;
|
|
@@ -39,7 +48,10 @@ export interface PromptInfo {
|
|
|
39
48
|
required?: boolean;
|
|
40
49
|
}[];
|
|
41
50
|
}
|
|
42
|
-
/**
|
|
51
|
+
/**
|
|
52
|
+
* A rendered prompt: messages in order, content blocks the same as tool results (non-text gets a
|
|
53
|
+
* type description).
|
|
54
|
+
*/
|
|
43
55
|
export interface RenderedPrompt {
|
|
44
56
|
description?: string;
|
|
45
57
|
messages: {
|
|
@@ -48,9 +60,11 @@ export interface RenderedPrompt {
|
|
|
48
60
|
}[];
|
|
49
61
|
}
|
|
50
62
|
/**
|
|
51
|
-
*
|
|
52
|
-
* - `form
|
|
53
|
-
*
|
|
63
|
+
* The remote asks the user for input in the middle of a call (MCP `elicitation/create`):
|
|
64
|
+
* - `form`: `requestedSchema` is the flat JSON Schema the remote gives (object + primitive-typed
|
|
65
|
+
* properties), which the kernel maps to an interactive form;
|
|
66
|
+
* - `url`: asks the user to open `url` in a browser to complete a step (authorization, payment,
|
|
67
|
+
* entering sensitive information); the user confirms whether it was completed.
|
|
54
68
|
*/
|
|
55
69
|
export type ElicitationRequest = {
|
|
56
70
|
mode: "form";
|
|
@@ -62,7 +76,10 @@ export type ElicitationRequest = {
|
|
|
62
76
|
url: string;
|
|
63
77
|
elicitationId: string;
|
|
64
78
|
};
|
|
65
|
-
/**
|
|
79
|
+
/**
|
|
80
|
+
* The reply to an elicitation (corresponds to MCP `ElicitResult`): accept (with form content) /
|
|
81
|
+
* decline / cancel.
|
|
82
|
+
*/
|
|
66
83
|
export type ElicitationResponse = {
|
|
67
84
|
action: "accept";
|
|
68
85
|
content?: FormAnswer;
|
|
@@ -71,18 +88,21 @@ export type ElicitationResponse = {
|
|
|
71
88
|
} | {
|
|
72
89
|
action: "cancel";
|
|
73
90
|
};
|
|
74
|
-
/**
|
|
91
|
+
/** Parameters the kernel passes to the connector when it opens a session. */
|
|
75
92
|
export interface ConnectorOpenArgs {
|
|
76
|
-
/**
|
|
93
|
+
/** Already validated against endpointSchema. */
|
|
77
94
|
endpoint: unknown;
|
|
78
|
-
/**
|
|
95
|
+
/** Called before every request; refreshing credentials is the kernel's job. */
|
|
79
96
|
auth: () => Promise<AuthInjection>;
|
|
80
|
-
/**
|
|
97
|
+
/** Called once on a 401; after the kernel refreshes credentials the plugin retries once. */
|
|
81
98
|
onUnauthorized: () => Promise<void>;
|
|
82
99
|
signal: AbortSignal;
|
|
83
100
|
/**
|
|
84
|
-
*
|
|
85
|
-
*
|
|
101
|
+
* Called when the remote reports during the session that its tool list changed (e.g. MCP
|
|
102
|
+
* `notifications/tools/list_changed`), possibly several times; the kernel schedules one
|
|
103
|
+
* drift check from it (new / changed tools are unavailable until an admin reviews them).
|
|
104
|
+
* Optional: old kernels do not provide it, so the connector must check for absence. Do not wait
|
|
105
|
+
* for it and do not throw because of it.
|
|
86
106
|
*/
|
|
87
107
|
onToolsChanged?: () => void;
|
|
88
108
|
/**
|
|
@@ -91,17 +111,26 @@ export interface ConnectorOpenArgs {
|
|
|
91
111
|
* when the kernel does not provide it, the connector does not declare the MCP elicitation
|
|
92
112
|
* capability (so the remote never starts one).
|
|
93
113
|
*
|
|
94
|
-
*
|
|
95
|
-
*
|
|
96
|
-
*
|
|
97
|
-
*
|
|
114
|
+
* The kernel cannot hold a remote call while waiting for the user to answer (the run pauses, the
|
|
115
|
+
* worker is released, the session closes): when the user must be asked, the kernel **aborts this
|
|
116
|
+
* call**
|
|
117
|
+
* (via the `callTool` signal) and puts the run into waiting; after the user answers the kernel
|
|
118
|
+
* issues the same call again, and when the remote raises the same elicitation again
|
|
119
|
+
* this callback replies at once with the user's answer. So the connector only needs "call it when
|
|
120
|
+
* received, return what it gets"; do not cache or retry yourself; when the user must be asked
|
|
121
|
+
* this callback
|
|
122
|
+
* rejects with an error (the call has already been aborted), and the connector simply lets that
|
|
123
|
+
* error end this call unchanged.
|
|
98
124
|
*/
|
|
99
125
|
onElicit?: (request: ElicitationRequest) => Promise<ElicitationResponse>;
|
|
100
126
|
}
|
|
101
127
|
/**
|
|
102
|
-
*
|
|
103
|
-
*
|
|
104
|
-
*
|
|
128
|
+
* An authentication method declared in the remote description, mapped to the shape of the kernel's
|
|
129
|
+
* connector auth (ConnectorAuth), to prefill the install wizard.
|
|
130
|
+
* `scheme` is the name in the remote description (e.g. the key of OpenAPI `securitySchemes`),
|
|
131
|
+
* `description` is given as is (may be absent).
|
|
132
|
+
* Only methods the kernel supports are listed; the rest (API keys in cookies, OpenID Connect,
|
|
133
|
+
* implicit / password flows, etc.) do not appear.
|
|
105
134
|
*/
|
|
106
135
|
export type AuthHint = {
|
|
107
136
|
scheme: string;
|
|
@@ -124,28 +153,34 @@ export type AuthHint = {
|
|
|
124
153
|
tokenUrl: string;
|
|
125
154
|
scopes: string[];
|
|
126
155
|
});
|
|
127
|
-
/**
|
|
156
|
+
/**
|
|
157
|
+
* An operation in the remote description (e.g. an OpenAPI operation), for the install wizard to
|
|
158
|
+
* tick.
|
|
159
|
+
*/
|
|
128
160
|
export interface ConnectorOperation {
|
|
129
|
-
/**
|
|
161
|
+
/** The id used for ticking in the endpoint config (e.g. OpenAPI's operationId). */
|
|
130
162
|
id: string;
|
|
131
|
-
/**
|
|
163
|
+
/** Uppercase HTTP method. */
|
|
132
164
|
method: string;
|
|
133
165
|
path: string;
|
|
134
166
|
summary?: string;
|
|
135
167
|
}
|
|
136
|
-
/** `Connector.inspect
|
|
168
|
+
/** The result of `Connector.inspect`. */
|
|
137
169
|
export interface ConnectorInspection {
|
|
138
170
|
authHints: AuthHint[];
|
|
139
171
|
operations?: ConnectorOperation[];
|
|
140
172
|
}
|
|
141
|
-
/** `connector@1
|
|
173
|
+
/** `connector@1`: implemented by the plugin, called by the kernel. */
|
|
142
174
|
export interface Connector {
|
|
143
175
|
kind: string;
|
|
144
176
|
endpointSchema: ZodTypeAny;
|
|
145
177
|
open(args: ConnectorOpenArgs): Promise<ConnectorSession>;
|
|
146
178
|
/**
|
|
147
|
-
*
|
|
148
|
-
*
|
|
179
|
+
* Optional: reads the endpoint's description without credentials (for the install wizard
|
|
180
|
+
* preview), returning the declared auth methods and an optional operation list.
|
|
181
|
+
* `endpoint` is already validated against endpointSchema. On failure throw ToolError (message in
|
|
182
|
+
* English, no credentials). Old connectors do not implement it; the kernel must check for
|
|
183
|
+
* absence.
|
|
149
184
|
*/
|
|
150
185
|
inspect?(args: {
|
|
151
186
|
endpoint: unknown;
|
package/dist/ctx.d.ts
CHANGED
|
@@ -7,21 +7,24 @@ import type { SetupCheckDefinition } from "./setup-check.js";
|
|
|
7
7
|
import type { ObjectHead, PresignedUpload, PresignGetOptions } from "./storage.js";
|
|
8
8
|
import type { ToolHandler, ToolSpec } from "./tool.js";
|
|
9
9
|
import type { EmbedClaims, UiActionArgs, UiActionResult, UiRenderArgs, UiView } from "./ui.js";
|
|
10
|
-
/**
|
|
10
|
+
/** Logger interface. */
|
|
11
11
|
export interface Logger {
|
|
12
12
|
info(msg: string, fields?: Record<string, unknown>): void;
|
|
13
13
|
warn(msg: string, fields?: Record<string, unknown>): void;
|
|
14
14
|
error(msg: string, fields?: Record<string, unknown>): void;
|
|
15
15
|
}
|
|
16
|
-
/**
|
|
16
|
+
/** Distributed lock lease. */
|
|
17
17
|
export interface Lease {
|
|
18
18
|
renew(): Promise<boolean>;
|
|
19
19
|
release(): Promise<void>;
|
|
20
20
|
}
|
|
21
21
|
/**
|
|
22
|
-
*
|
|
23
|
-
* `
|
|
24
|
-
*
|
|
22
|
+
* The plugin's object storage (`ctx.storage`, needs `permissions.storage`): the same shape as
|
|
23
|
+
* `ObjectStore`, but the first parameter of every method is
|
|
24
|
+
* `orgId`, and the kernel adds `plugins/<plugin name>/<orgId>/` to keys and prefixes automatically:
|
|
25
|
+
* a plugin sees only its own objects under that org.
|
|
26
|
+
* The backing store is the deployment-configured `object-store@1` provider; every method throws
|
|
27
|
+
* when there is no provider.
|
|
25
28
|
*/
|
|
26
29
|
export interface ExtensionStorage {
|
|
27
30
|
put(orgId: string, key: string, body: Uint8Array | ReadableStream<Uint8Array>, opts: {
|
|
@@ -30,8 +33,10 @@ export interface ExtensionStorage {
|
|
|
30
33
|
signal?: AbortSignal;
|
|
31
34
|
}): Promise<ObjectHead>;
|
|
32
35
|
/**
|
|
33
|
-
*
|
|
34
|
-
*
|
|
36
|
+
* Returns null when missing. `range` is a closed byte range; an omitted `end` means read to the
|
|
37
|
+
* end.
|
|
38
|
+
* With `range`, `head.size` is still the size of the whole object; when the store ignores Range,
|
|
39
|
+
* body may be the whole object.
|
|
35
40
|
*/
|
|
36
41
|
get(orgId: string, key: string, opts?: {
|
|
37
42
|
signal?: AbortSignal;
|
|
@@ -44,7 +49,7 @@ export interface ExtensionStorage {
|
|
|
44
49
|
body: ReadableStream<Uint8Array>;
|
|
45
50
|
} | null>;
|
|
46
51
|
head(orgId: string, key: string): Promise<ObjectHead | null>;
|
|
47
|
-
/**
|
|
52
|
+
/** A missing key also counts as success. */
|
|
48
53
|
delete(orgId: string, key: string): Promise<void>;
|
|
49
54
|
deletePrefix(orgId: string, prefix: string): Promise<number>;
|
|
50
55
|
list(orgId: string, prefix: string, opts?: {
|
|
@@ -120,7 +125,10 @@ export interface ExtensionModels {
|
|
|
120
125
|
purpose: string;
|
|
121
126
|
}): Promise<ExtensionModelTarget | null>;
|
|
122
127
|
}
|
|
123
|
-
/**
|
|
128
|
+
/**
|
|
129
|
+
* The context passed to a plugin's `setup`. It provides no timers or in-process shared state; kv
|
|
130
|
+
* writes must carry a TTL.
|
|
131
|
+
*/
|
|
124
132
|
export interface ExtensionContext {
|
|
125
133
|
kv: {
|
|
126
134
|
get(key: string): Promise<string | null>;
|
|
@@ -154,11 +162,11 @@ export interface ExtensionContext {
|
|
|
154
162
|
get(orgId: string, key: string): Promise<string | null>;
|
|
155
163
|
set(orgId: string, key: string, value: string): Promise<void>;
|
|
156
164
|
};
|
|
157
|
-
/**
|
|
165
|
+
/** Object storage (needs `permissions.storage`, see {@link ExtensionStorage}). */
|
|
158
166
|
storage: ExtensionStorage;
|
|
159
167
|
/** Models by purpose (requires `permissions.models`, see {@link ExtensionModels}). */
|
|
160
168
|
models: ExtensionModels;
|
|
161
|
-
/**
|
|
169
|
+
/** A Kysely instance already switched to this plugin's schema (withSchema). */
|
|
162
170
|
db: Kysely<any>;
|
|
163
171
|
http: {
|
|
164
172
|
/**
|
|
@@ -169,7 +177,7 @@ export interface ExtensionContext {
|
|
|
169
177
|
route(method: "GET" | "POST" | "PUT" | "DELETE", path: string, handler: (req: Request, caller: RouteCaller) => Promise<Response>): void;
|
|
170
178
|
};
|
|
171
179
|
tools: {
|
|
172
|
-
/**
|
|
180
|
+
/** Registers a tool; callable only during `setup`, names must not repeat. */
|
|
173
181
|
register(spec: ToolSpec, handler: ToolHandler): void;
|
|
174
182
|
};
|
|
175
183
|
/**
|
|
@@ -201,14 +209,19 @@ export interface ExtensionContext {
|
|
|
201
209
|
}[]>;
|
|
202
210
|
};
|
|
203
211
|
/**
|
|
204
|
-
*
|
|
205
|
-
* - `view` / `action
|
|
206
|
-
*
|
|
207
|
-
*
|
|
212
|
+
* Runtime of UI contributions (manifest `ui` + `permissions.ui`):
|
|
213
|
+
* - `view` / `action`: can be registered only during `setup`; the id is the contribution id of
|
|
214
|
+
* the kind-view entry in the manifest;
|
|
215
|
+
* `action` receives a button click or form submission from the view (`args.actionId` tells
|
|
216
|
+
* which one);
|
|
217
|
+
* - `invalidate`: tells the kernel "this contribution changed", and the web pages that have it
|
|
218
|
+
* open fetch the view again (via the bus, across replicas); a
|
|
208
219
|
* `platform.page` contribution takes no `orgId` (it refreshes the admin console), every other
|
|
209
220
|
* contribution requires one;
|
|
210
|
-
* - `verifyEmbedToken
|
|
211
|
-
*
|
|
221
|
+
* - `verifyEmbedToken`: validates the embed token an embed page received; it accepts only
|
|
222
|
+
* tokens signed for this plugin and not expired, while the plugin is still enabled in that org,
|
|
223
|
+
* the caller is still an active member and the role still satisfies the slot's minRole,
|
|
224
|
+
* otherwise it returns null; the returned `role` is the role at this moment. A
|
|
212
225
|
* platform-scope token (`scope: "platform"`, no `orgId`) verifies only for a `platform.page`
|
|
213
226
|
* contribution while the account is still an active super admin.
|
|
214
227
|
*/
|
|
@@ -249,14 +262,19 @@ export interface ExtensionContext {
|
|
|
249
262
|
};
|
|
250
263
|
provide(extensionPoint: ExtensionPointRef, impl: unknown): void;
|
|
251
264
|
/**
|
|
252
|
-
*
|
|
253
|
-
*
|
|
265
|
+
* The lifecycle signal of this plugin instance: aborted when the instance is revoked (disabled,
|
|
266
|
+
* uninstalled, upgraded), after in-flight calls have drained.
|
|
267
|
+
* Long-running tasks the plugin started itself (polling loops, long connections, etc.) wind down
|
|
268
|
+
* on it.
|
|
254
269
|
*/
|
|
255
270
|
signal: AbortSignal;
|
|
256
271
|
/**
|
|
257
|
-
*
|
|
258
|
-
*
|
|
259
|
-
*
|
|
272
|
+
* Deployment-level config, validated against the plugin schema (the startup config merged with
|
|
273
|
+
* values the super admin saved in the console). This is a getter:
|
|
274
|
+
* when a field marked `hot` (`.meta({ hot: true })`) changes, the kernel replaces it in place, so
|
|
275
|
+
* the plugin must read `ctx.config` **at the time of use** to get the new value;
|
|
276
|
+
* do not copy hot fields into a closure in setup; when a non-hot field changes the kernel reloads
|
|
277
|
+
* the plugin instance (a new setup).
|
|
260
278
|
*/
|
|
261
279
|
readonly config: unknown;
|
|
262
280
|
log: Logger;
|
|
@@ -3,16 +3,19 @@ import type { ExtensionContext } from "./ctx.js";
|
|
|
3
3
|
import { type ExtensionPointRef } from "./extension-point.js";
|
|
4
4
|
import { type ExtensionPermissions } from "./permissions.js";
|
|
5
5
|
import type { UiContribution } from "./ui.js";
|
|
6
|
-
/**
|
|
6
|
+
/** The plugin manifest. */
|
|
7
7
|
export interface ExtensionManifest {
|
|
8
8
|
name: string;
|
|
9
9
|
version: string;
|
|
10
10
|
sdk: string;
|
|
11
11
|
provides: ExtensionPointRef[];
|
|
12
12
|
requires?: ExtensionPointRef[];
|
|
13
|
-
/**
|
|
13
|
+
/**
|
|
14
|
+
* Optional dependencies: when missing the plugin still loads, and decides at runtime through
|
|
15
|
+
* ctx.extensionPoints.
|
|
16
|
+
*/
|
|
14
17
|
optional?: ExtensionPointRef[];
|
|
15
|
-
/**
|
|
18
|
+
/** Permission manifest (governance, not a sandbox). */
|
|
16
19
|
permissions?: ExtensionPermissions;
|
|
17
20
|
/**
|
|
18
21
|
* UI contributions, each in a slot of `UI_SLOTS`; every id is also listed in `permissions.ui`.
|
|
@@ -27,19 +30,26 @@ export interface ExtensionManifest {
|
|
|
27
30
|
migrations?: string;
|
|
28
31
|
setup(ctx: ExtensionContext): void | Promise<void>;
|
|
29
32
|
/**
|
|
30
|
-
*
|
|
31
|
-
*
|
|
32
|
-
*
|
|
33
|
-
*
|
|
34
|
-
*
|
|
33
|
+
* Optional: called when the plugin instance is revoked (disabled, uninstalled, replaced by a new
|
|
34
|
+
* instance on upgrade, a dependent reloaded together with its provider).
|
|
35
|
+
* By then the kernel has already: stopped accepting new calls, waited for in-flight calls to
|
|
36
|
+
* finish (at most `extensionHost.drainSeconds`), aborted `ctx.signal`,
|
|
37
|
+
* and revoked every registration this instance made through ctx (tools, routes, queue workers,
|
|
38
|
+
* bus subscriptions, lock leases, UI, provide).
|
|
39
|
+
* Clean up here only what the plugin opened outside ctx (e.g. its own connections); do not
|
|
40
|
+
* register anything through ctx again.
|
|
41
|
+
* Not called when setup throws (the kernel revokes what was already registered).
|
|
35
42
|
*/
|
|
36
43
|
dispose?(ctx: ExtensionContext): void | Promise<void>;
|
|
37
44
|
}
|
|
38
|
-
/**
|
|
45
|
+
/** The plugin manifest is invalid. */
|
|
39
46
|
export declare class ExtensionManifestError extends Error {
|
|
40
47
|
constructor(plugin: string, message: string);
|
|
41
48
|
}
|
|
42
|
-
/**
|
|
49
|
+
/** Plugin name rule (manifest `name`; a connector template's `plugin` is validated by it too). */
|
|
43
50
|
export declare const EXTENSION_NAME_RE: RegExp;
|
|
44
|
-
/**
|
|
51
|
+
/**
|
|
52
|
+
* Validates the plugin manifest and returns it unchanged; throws ExtensionManifestError when
|
|
53
|
+
* invalid.
|
|
54
|
+
*/
|
|
45
55
|
export declare function defineExtension(m: ExtensionManifest): ExtensionManifest;
|
package/dist/define-extension.js
CHANGED
|
@@ -1,17 +1,20 @@
|
|
|
1
1
|
import semver from "semver";
|
|
2
2
|
import { EXTENSION_POINTS, parseExtensionPoint, } from "./extension-point.js";
|
|
3
3
|
import { validatePermissions, validateUiContributions, } from "./permissions.js";
|
|
4
|
-
/**
|
|
4
|
+
/** The plugin manifest is invalid. */
|
|
5
5
|
export class ExtensionManifestError extends Error {
|
|
6
6
|
constructor(plugin, message) {
|
|
7
7
|
super(`extension ${plugin}: ${message}`);
|
|
8
8
|
this.name = "ExtensionManifestError";
|
|
9
9
|
}
|
|
10
10
|
}
|
|
11
|
-
/**
|
|
11
|
+
/** Plugin name rule (manifest `name`; a connector template's `plugin` is validated by it too). */
|
|
12
12
|
export const EXTENSION_NAME_RE = /^[a-z][a-z0-9-]{1,40}$/;
|
|
13
13
|
const NAME_RE = EXTENSION_NAME_RE;
|
|
14
|
-
/**
|
|
14
|
+
/**
|
|
15
|
+
* Reserved plugin name: the kernel uses `kernel` as its own secrets namespace, so a plugin cannot
|
|
16
|
+
* take it.
|
|
17
|
+
*/
|
|
15
18
|
const RESERVED_NAMES = new Set(["kernel"]);
|
|
16
19
|
function checkRefs(label, refs, fail, forbidBrokered = false) {
|
|
17
20
|
for (const ref of refs) {
|
|
@@ -30,7 +33,10 @@ function checkRefs(label, refs, fail, forbidBrokered = false) {
|
|
|
30
33
|
}
|
|
31
34
|
}
|
|
32
35
|
}
|
|
33
|
-
/**
|
|
36
|
+
/**
|
|
37
|
+
* Validates the plugin manifest and returns it unchanged; throws ExtensionManifestError when
|
|
38
|
+
* invalid.
|
|
39
|
+
*/
|
|
34
40
|
export function defineExtension(m) {
|
|
35
41
|
const plugin = typeof m?.name === "string" && m.name !== "" ? m.name : "<unnamed>";
|
|
36
42
|
const fail = (msg) => {
|
|
@@ -143,7 +143,8 @@ export interface DeviceExecArgs {
|
|
|
143
143
|
actor: SandboxActor;
|
|
144
144
|
limits: SandboxLimits;
|
|
145
145
|
/**
|
|
146
|
-
* Hosts the kernel allows for this command beyond the local policy (a run's
|
|
146
|
+
* Hosts the kernel allows for this command beyond the local policy (a run's "Allow this time" or
|
|
147
|
+
* a
|
|
147
148
|
* scheduled task's grants). A device applies them only in sandbox mode, within `limits`; a
|
|
148
149
|
* device without the feature ignores the field.
|
|
149
150
|
*/
|
package/dist/extension-point.js
CHANGED
|
@@ -13,7 +13,7 @@ export const EXTENSION_POINTS = {
|
|
|
13
13
|
"secret-store": info([1], "Stores and resolves secrets (connector credentials, secret config) outside the database.", "single", true),
|
|
14
14
|
"object-store": info([1], "Stores files and artifacts in S3-compatible object storage, with presigned uploads.", "single", true),
|
|
15
15
|
channel: info([1], "Connects an instant-messaging platform (Slack, Lark): inbound events, replies and cards.", "multi", false, true),
|
|
16
|
-
"model-provider": info([
|
|
16
|
+
"model-provider": info([2], "Calls a model vendor's API and streams the result back to the runtime.", "multi", true),
|
|
17
17
|
"identity-source": info([1], "Signs people in through an external identity provider (SSO).", "multi"),
|
|
18
18
|
directory: info([1], "Syncs members and departments from an external company directory.", "multi", false, true),
|
|
19
19
|
counter: info([1], "Counts usage so quotas and reports can be built on it.", "multi"),
|
package/dist/hooks.d.ts
CHANGED
|
@@ -49,21 +49,23 @@ export type ModelCallPurpose = "step" | "compaction" | "title" | "web_fetch" | "
|
|
|
49
49
|
*/
|
|
50
50
|
export type UsagePurpose = ModelCallPurpose | "embedding";
|
|
51
51
|
/**
|
|
52
|
-
* An image or
|
|
53
|
-
* attachment ids: each image
|
|
52
|
+
* An image, document or file of a `model.request` payload. Hook payloads never carry media bytes or
|
|
53
|
+
* attachment ids: each image / document / file block is replaced by this placeholder.
|
|
54
54
|
* `size` is the size of the bytes sent to the provider, in bytes (0 when unknown).
|
|
55
55
|
*/
|
|
56
56
|
export interface HookMediaPlaceholder {
|
|
57
57
|
type: "media_omitted";
|
|
58
|
-
kind: "image" | "document";
|
|
58
|
+
kind: "image" | "document" | "file";
|
|
59
59
|
mediaType: string;
|
|
60
60
|
size: number;
|
|
61
61
|
}
|
|
62
|
-
/** A content block of a `model.request` payload: image and
|
|
62
|
+
/** A content block of a `model.request` payload: image, document and file blocks become placeholders. */
|
|
63
63
|
export type HookContentBlock = Exclude<ContentBlock, {
|
|
64
64
|
type: "image";
|
|
65
65
|
} | {
|
|
66
66
|
type: "document";
|
|
67
|
+
} | {
|
|
68
|
+
type: "file";
|
|
67
69
|
}> | HookMediaPlaceholder;
|
|
68
70
|
/** A message of a `model.request` payload (see {@link HookContentBlock}). */
|
|
69
71
|
export type HookModelMessage = {
|
package/dist/identity.d.ts
CHANGED
|
@@ -1,8 +1,12 @@
|
|
|
1
|
-
/**
|
|
1
|
+
/**
|
|
2
|
+
* An external identity; login, channel inbound and directory all use the same (source, externalId)
|
|
3
|
+
* key.
|
|
4
|
+
*/
|
|
2
5
|
export interface ExternalIdentity {
|
|
3
6
|
/**
|
|
4
|
-
* `"
|
|
5
|
-
* `source === \`${
|
|
7
|
+
* `"<plugin name>:<tenant id>"`, must equal `tenantId`. On third-party login the kernel checks
|
|
8
|
+
* `source === \`${plugin name}:${tenantId}\``, and rejects a mismatch as an identity source
|
|
9
|
+
* error.
|
|
6
10
|
*/
|
|
7
11
|
source: string;
|
|
8
12
|
externalId: string;
|
|
@@ -13,9 +17,12 @@ export interface ExternalIdentity {
|
|
|
13
17
|
avatarUrl?: string;
|
|
14
18
|
}
|
|
15
19
|
/**
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
*
|
|
20
|
+
* Third-party login (`identity-source@1`). State, nonce and PKCE are all generated by the kernel
|
|
21
|
+
* and kept server-side:
|
|
22
|
+
* the plugin puts `codeChallenge` / `codeChallengeMethod` into the authorization URL
|
|
23
|
+
* (`code_challenge` / `code_challenge_method`),
|
|
24
|
+
* and passes `codeVerifier` (`code_verifier`) when exchanging the token at the callback. If the
|
|
25
|
+
* platform does not support PKCE, just ignore these fields.
|
|
19
26
|
*/
|
|
20
27
|
export interface IdentitySource {
|
|
21
28
|
label: {
|
|
@@ -27,9 +34,12 @@ export interface IdentitySource {
|
|
|
27
34
|
redirectUri: string;
|
|
28
35
|
state: string;
|
|
29
36
|
nonce: string;
|
|
30
|
-
/**
|
|
37
|
+
/**
|
|
38
|
+
* PKCE challenge (base64url(SHA-256(codeVerifier))); the kernel always provides it, old kernels
|
|
39
|
+
* do not.
|
|
40
|
+
*/
|
|
31
41
|
codeChallenge?: string;
|
|
32
|
-
/** PKCE challenge
|
|
42
|
+
/** The PKCE challenge algorithm; the kernel uses only `"S256"`. */
|
|
33
43
|
codeChallengeMethod?: "S256";
|
|
34
44
|
}): string;
|
|
35
45
|
callback(args: {
|
|
@@ -38,7 +48,10 @@ export interface IdentitySource {
|
|
|
38
48
|
query: Record<string, string>;
|
|
39
49
|
nonce: string;
|
|
40
50
|
signal: AbortSignal;
|
|
41
|
-
/**
|
|
51
|
+
/**
|
|
52
|
+
* The PKCE verifier matching this flow's `codeChallenge`; the kernel always provides it, old
|
|
53
|
+
* kernels do not.
|
|
54
|
+
*/
|
|
42
55
|
codeVerifier?: string;
|
|
43
56
|
}): Promise<ExternalIdentity>;
|
|
44
57
|
}
|
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED