@capybara-hq/plugin-sdk 0.1.0-rc.6 → 0.1.0-rc.60
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/README.md +1 -1
- package/agent-docs/agent-templates.md +14 -2
- package/agent-docs/concepts.md +14 -5
- package/agent-docs/connector-templates.md +7 -1
- package/agent-docs/extension-points/channel.md +1 -1
- package/agent-docs/extension-points/context.md +15 -0
- package/agent-docs/extension-points/device-provider.md +15 -0
- package/agent-docs/extension-points/file-preview.md +2 -0
- package/agent-docs/extension-points/model-provider.md +3 -1
- package/agent-docs/extension-points/object-store.md +2 -0
- package/agent-docs/extension-points/push-provider.md +17 -0
- package/agent-docs/extensions.md +29 -3
- package/agent-docs/plugin-format.md +52 -2
- package/agent-docs/setup.md +54 -0
- package/dist/agent-template.d.ts +15 -6
- package/dist/agent-template.js +32 -13
- package/dist/avatar-presets.d.ts +8 -0
- package/dist/avatar-presets.js +17 -0
- package/dist/bootstrap.d.ts +109 -1
- package/dist/bootstrap.js +185 -2
- package/dist/cards.d.ts +67 -13
- package/dist/cards.js +91 -21
- package/dist/channel.d.ts +148 -48
- package/dist/channel.js +10 -5
- package/dist/client-css.d.ts +36 -0
- package/dist/client-css.js +326 -0
- package/dist/client-section.d.ts +35 -0
- package/dist/client-section.js +133 -0
- package/dist/config-ui.d.ts +22 -0
- package/dist/config-ui.js +64 -4
- package/dist/connector-auth.d.ts +15 -2
- package/dist/connector-auth.js +97 -8
- package/dist/connector.d.ts +74 -32
- package/dist/context.d.ts +40 -0
- package/dist/context.js +2 -0
- package/dist/ctx.d.ts +132 -29
- package/dist/define-extension.d.ts +26 -12
- package/dist/define-extension.js +12 -5
- package/dist/device-denied-paths.d.ts +18 -0
- package/dist/device-denied-paths.js +84 -0
- package/dist/device-operation.d.ts +333 -0
- package/dist/device-operation.js +312 -0
- package/dist/device-protocol.d.ts +285 -50
- package/dist/device-protocol.js +755 -90
- package/dist/device-provider.d.ts +500 -0
- package/dist/device-provider.js +302 -0
- package/dist/dial-in.d.ts +176 -0
- package/dist/dial-in.js +115 -0
- package/dist/extension-point.d.ts +2 -0
- package/dist/extension-point.js +6 -2
- package/dist/file-preview.d.ts +23 -6
- package/dist/git-hosts.d.ts +53 -0
- package/dist/git-hosts.js +98 -0
- package/dist/hooks.d.ts +125 -20
- package/dist/hooks.js +5 -0
- package/dist/http-access.d.ts +62 -0
- package/dist/http-access.js +12 -0
- package/dist/identity.d.ts +38 -9
- package/dist/identity.js +21 -1
- package/dist/index.d.ts +29 -3
- package/dist/index.js +29 -3
- package/dist/marketplace.d.ts +26 -0
- package/dist/marketplace.js +43 -1
- package/dist/model-params.d.ts +41 -22
- package/dist/model-params.js +28 -15
- package/dist/model.d.ts +206 -71
- package/dist/model.js +152 -19
- package/dist/net.d.ts +52 -0
- package/dist/net.js +34 -0
- package/dist/network-classes.d.ts +98 -0
- package/dist/network-classes.js +291 -0
- package/dist/permissions.d.ts +54 -22
- package/dist/permissions.js +119 -43
- package/dist/plugin-manifest.d.ts +45 -5
- package/dist/plugin-manifest.js +174 -6
- package/dist/plugin-package.d.ts +82 -38
- package/dist/plugin-package.js +61 -29
- package/dist/push.d.ts +75 -0
- package/dist/push.js +87 -0
- package/dist/sandbox-linux-runtime-source.d.ts +1 -0
- package/dist/sandbox-linux-runtime-source.js +2318 -0
- package/dist/sandbox-native-runtime-source.d.ts +10 -0
- package/dist/sandbox-native-runtime-source.js +476 -0
- package/dist/sandbox-runtime-source.d.ts +19 -0
- package/dist/sandbox-runtime-source.js +28 -0
- package/dist/sandbox-write-denies.d.ts +139 -0
- package/dist/sandbox-write-denies.js +869 -0
- package/dist/secret.d.ts +4 -1
- package/dist/secret.js +4 -1
- package/dist/setup-check.d.ts +128 -0
- package/dist/setup-check.js +142 -0
- package/dist/setup-guide-parse.d.ts +121 -0
- package/dist/setup-guide-parse.js +356 -0
- package/dist/setup-guide-render.d.ts +45 -0
- package/dist/setup-guide-render.js +351 -0
- package/dist/setup-guide.d.ts +108 -0
- package/dist/setup-guide.js +367 -0
- package/dist/shell-capabilities.d.ts +211 -0
- package/dist/shell-capabilities.js +44 -0
- package/dist/shell-environment.d.ts +57 -0
- package/dist/shell-environment.js +21 -0
- package/dist/skill.d.ts +27 -17
- package/dist/skill.js +40 -26
- package/dist/storage.d.ts +52 -25
- package/dist/svg-viewbox.d.ts +10 -0
- package/dist/svg-viewbox.js +24 -0
- package/dist/theme-assets.d.ts +55 -0
- package/dist/theme-assets.js +489 -0
- package/dist/theme-readability.d.ts +37 -0
- package/dist/theme-readability.js +145 -0
- package/dist/theme-tokens.generated.d.ts +299 -0
- package/dist/theme-tokens.generated.js +184 -0
- package/dist/theme.d.ts +190 -0
- package/dist/theme.js +471 -0
- package/dist/tool.d.ts +99 -26
- package/dist/tool.js +29 -9
- package/dist/ui-parts.d.ts +23 -0
- package/dist/ui-parts.js +385 -0
- package/dist/ui-resolve.d.ts +35 -0
- package/dist/ui-resolve.js +42 -0
- package/dist/ui-slots.d.ts +65 -0
- package/dist/ui-slots.js +261 -0
- package/dist/ui.d.ts +212 -76
- package/dist/ui.js +101 -27
- package/dist/url.d.ts +4 -1
- package/dist/url.js +4 -1
- package/package.json +13 -1
- package/schemas/bootstrap-extra.v1.schema.json +186 -0
- package/schemas/bootstrap.v1.schema.json +20 -0
- package/schemas/connector-template.v1.schema.json +35 -0
- package/schemas/marketplace.v1.schema.json +14 -0
- package/schemas/plugin.v1.schema.json +122 -3
- package/schemas/theme.v1.schema.json +302 -0
- package/agent-docs/extension-points/sandbox.md +0 -15
- package/dist/sandbox.d.ts +0 -254
- package/dist/sandbox.js +0 -153
package/dist/ctx.d.ts
CHANGED
|
@@ -1,25 +1,32 @@
|
|
|
1
1
|
import type { Kysely } from "kysely";
|
|
2
|
+
import type { DevicesCtx, DialInChannel } from "./dial-in.js";
|
|
2
3
|
import type { ExtensionPointRef } from "./extension-point.js";
|
|
3
4
|
import type { AvailableHook, HookHandler, HookOptions } from "./hooks.js";
|
|
4
|
-
import type {
|
|
5
|
+
import type { RouteCaller } from "./http-access.js";
|
|
6
|
+
import type { ImageAspectRatio, ImageMediaType, ImageSize, ModelEmbeddingInfo, ModelImageGenerationInfo, ModelKind } from "./model.js";
|
|
7
|
+
import type { ExtensionNet } from "./net.js";
|
|
8
|
+
import type { SetupCheckDefinition } from "./setup-check.js";
|
|
5
9
|
import type { ObjectHead, PresignedUpload, PresignGetOptions } from "./storage.js";
|
|
6
10
|
import type { ToolHandler, ToolSpec } from "./tool.js";
|
|
7
11
|
import type { EmbedClaims, UiActionArgs, UiActionResult, UiRenderArgs, UiView } from "./ui.js";
|
|
8
|
-
/**
|
|
12
|
+
/** Logger interface. */
|
|
9
13
|
export interface Logger {
|
|
10
14
|
info(msg: string, fields?: Record<string, unknown>): void;
|
|
11
15
|
warn(msg: string, fields?: Record<string, unknown>): void;
|
|
12
16
|
error(msg: string, fields?: Record<string, unknown>): void;
|
|
13
17
|
}
|
|
14
|
-
/**
|
|
18
|
+
/** Distributed lock lease. */
|
|
15
19
|
export interface Lease {
|
|
16
20
|
renew(): Promise<boolean>;
|
|
17
21
|
release(): Promise<void>;
|
|
18
22
|
}
|
|
19
23
|
/**
|
|
20
|
-
*
|
|
21
|
-
* `
|
|
22
|
-
*
|
|
24
|
+
* The plugin's object storage (`ctx.storage`, needs `permissions.storage`): the same shape as
|
|
25
|
+
* `ObjectStore`, but the first parameter of every method is
|
|
26
|
+
* `orgId`, and the kernel adds `plugins/<plugin name>/<orgId>/` to keys and prefixes automatically:
|
|
27
|
+
* a plugin sees only its own objects under that org.
|
|
28
|
+
* The backing store is the deployment-configured `object-store@1` provider; every method throws
|
|
29
|
+
* when there is no provider.
|
|
23
30
|
*/
|
|
24
31
|
export interface ExtensionStorage {
|
|
25
32
|
put(orgId: string, key: string, body: Uint8Array | ReadableStream<Uint8Array>, opts: {
|
|
@@ -28,8 +35,10 @@ export interface ExtensionStorage {
|
|
|
28
35
|
signal?: AbortSignal;
|
|
29
36
|
}): Promise<ObjectHead>;
|
|
30
37
|
/**
|
|
31
|
-
*
|
|
32
|
-
*
|
|
38
|
+
* Returns null when missing. `range` is a closed byte range; an omitted `end` means read to the
|
|
39
|
+
* end.
|
|
40
|
+
* With `range`, `head.size` is still the size of the whole object; when the store ignores Range,
|
|
41
|
+
* body may be the whole object.
|
|
33
42
|
*/
|
|
34
43
|
get(orgId: string, key: string, opts?: {
|
|
35
44
|
signal?: AbortSignal;
|
|
@@ -42,7 +51,7 @@ export interface ExtensionStorage {
|
|
|
42
51
|
body: ReadableStream<Uint8Array>;
|
|
43
52
|
} | null>;
|
|
44
53
|
head(orgId: string, key: string): Promise<ObjectHead | null>;
|
|
45
|
-
/**
|
|
54
|
+
/** A missing key also counts as success. */
|
|
46
55
|
delete(orgId: string, key: string): Promise<void>;
|
|
47
56
|
deletePrefix(orgId: string, prefix: string): Promise<number>;
|
|
48
57
|
list(orgId: string, prefix: string, opts?: {
|
|
@@ -86,6 +95,39 @@ export interface ExtensionEmbedResult {
|
|
|
86
95
|
};
|
|
87
96
|
dimensions: number;
|
|
88
97
|
}
|
|
98
|
+
/** A `ctx.models.generateImage` request: images generated for one org with the model of a purpose. */
|
|
99
|
+
export interface ExtensionImageGenerateRequest {
|
|
100
|
+
orgId: string;
|
|
101
|
+
/** A purpose this extension declared in `permissions.models` with `kind: "image_generation"`. */
|
|
102
|
+
purpose: string;
|
|
103
|
+
prompt: string;
|
|
104
|
+
/** An exact size the model offers; rejected otherwise. Wins over `aspectRatio`. */
|
|
105
|
+
size?: ImageSize;
|
|
106
|
+
/** The closest size the model offers; the model's default size when neither is given. */
|
|
107
|
+
aspectRatio?: ImageAspectRatio;
|
|
108
|
+
/** Images to produce (default 1, at most the model's `maxImages`). */
|
|
109
|
+
n?: number;
|
|
110
|
+
/** Base64 reference images, at most the model's `maxReferenceImages`. */
|
|
111
|
+
referenceImages?: {
|
|
112
|
+
mediaType: ImageMediaType;
|
|
113
|
+
data: string;
|
|
114
|
+
}[];
|
|
115
|
+
/** Aborts this call; combined with `ctx.signal`. */
|
|
116
|
+
signal?: AbortSignal;
|
|
117
|
+
}
|
|
118
|
+
/** A `ctx.models.generateImage` result. */
|
|
119
|
+
export interface ExtensionImageGenerateResult {
|
|
120
|
+
images: {
|
|
121
|
+
mediaType: ImageMediaType;
|
|
122
|
+
data: string;
|
|
123
|
+
}[];
|
|
124
|
+
revisedPrompt?: string;
|
|
125
|
+
model: {
|
|
126
|
+
provider: string;
|
|
127
|
+
id: string;
|
|
128
|
+
};
|
|
129
|
+
size: ImageSize;
|
|
130
|
+
}
|
|
89
131
|
/** The model a purpose maps to in an org (`ctx.models.describe`). */
|
|
90
132
|
export interface ExtensionModelTarget {
|
|
91
133
|
provider: string;
|
|
@@ -93,13 +135,16 @@ export interface ExtensionModelTarget {
|
|
|
93
135
|
kind: ModelKind;
|
|
94
136
|
/** Present for an embedding model. */
|
|
95
137
|
embedding?: ModelEmbeddingInfo;
|
|
138
|
+
/** Present for an image generation model. */
|
|
139
|
+
imageGeneration?: ModelImageGenerationInfo;
|
|
96
140
|
}
|
|
97
141
|
/**
|
|
98
142
|
* Models by purpose (`permissions.models`): the purpose → model mapping is chosen by org admins
|
|
99
143
|
* (and the deployment default by the super admin), never by the extension. Only purposes this
|
|
100
|
-
* extension declared with `kind
|
|
144
|
+
* extension declared with a matching `kind` (`embedding` for `embed`, `image_generation` for
|
|
145
|
+
* `generateImage`) are accepted (`model.purpose_unknown` otherwise), and
|
|
101
146
|
* only for an org that enabled the extension (`extension.not_enabled`). Usage is recorded by the
|
|
102
|
-
* kernel and reported through `usage.report` (purpose `embedding`).
|
|
147
|
+
* kernel and reported through `usage.report` (purpose `embedding`, or `image` for `generateImage`).
|
|
103
148
|
*/
|
|
104
149
|
export interface ExtensionModels {
|
|
105
150
|
/**
|
|
@@ -112,13 +157,24 @@ export interface ExtensionModels {
|
|
|
112
157
|
* extension route), and nothing is sent or billed.
|
|
113
158
|
*/
|
|
114
159
|
embed(req: ExtensionEmbedRequest): Promise<ExtensionEmbedResult>;
|
|
160
|
+
/**
|
|
161
|
+
* Generates images with the org's effective model for `purpose`. Rejects with
|
|
162
|
+
* `model.unconfigured` when the purpose maps to no usable model, `validation_failed` for a size,
|
|
163
|
+
* count or reference count the model does not offer, and a `ModelError` when the provider fails
|
|
164
|
+
* (kind `refusal` when it declines the prompt). Not retried. Fires `model.request` first
|
|
165
|
+
* (`purpose: "image"`); a policy denial rejects with `model.hook_denied`.
|
|
166
|
+
*/
|
|
167
|
+
generateImage(req: ExtensionImageGenerateRequest): Promise<ExtensionImageGenerateResult>;
|
|
115
168
|
/** The org's effective model for `purpose`, or null when it maps to no model the org can use. */
|
|
116
169
|
describe(req: {
|
|
117
170
|
orgId: string;
|
|
118
171
|
purpose: string;
|
|
119
172
|
}): Promise<ExtensionModelTarget | null>;
|
|
120
173
|
}
|
|
121
|
-
/**
|
|
174
|
+
/**
|
|
175
|
+
* The context passed to a plugin's `setup`. It provides no timers or in-process shared state; kv
|
|
176
|
+
* writes must carry a TTL.
|
|
177
|
+
*/
|
|
122
178
|
export interface ExtensionContext {
|
|
123
179
|
kv: {
|
|
124
180
|
get(key: string): Promise<string | null>;
|
|
@@ -152,18 +208,27 @@ export interface ExtensionContext {
|
|
|
152
208
|
get(orgId: string, key: string): Promise<string | null>;
|
|
153
209
|
set(orgId: string, key: string, value: string): Promise<void>;
|
|
154
210
|
};
|
|
155
|
-
/**
|
|
211
|
+
/** Object storage (needs `permissions.storage`, see {@link ExtensionStorage}). */
|
|
156
212
|
storage: ExtensionStorage;
|
|
157
213
|
/** Models by purpose (requires `permissions.models`, see {@link ExtensionModels}). */
|
|
158
214
|
models: ExtensionModels;
|
|
159
|
-
/**
|
|
215
|
+
/**
|
|
216
|
+
* Guarded HTTP for URLs a person supplied (see {@link ExtensionNet}): a connector endpoint or an
|
|
217
|
+
* org-overridable base URL goes through `ctx.net.fetch`, never the global `fetch`.
|
|
218
|
+
*/
|
|
219
|
+
net: ExtensionNet;
|
|
220
|
+
/** A Kysely instance already switched to this plugin's schema (withSchema). */
|
|
160
221
|
db: Kysely<any>;
|
|
161
222
|
http: {
|
|
162
|
-
/**
|
|
163
|
-
|
|
223
|
+
/**
|
|
224
|
+
* Mounted at `/plugins/<name><path>` (`public`, `embed`) or `/plugins/<name>/orgs/:orgId<path>`
|
|
225
|
+
* (`member`, `admin`), as `permissions.http` declares. The kernel enforces the access before
|
|
226
|
+
* the handler runs and passes the resolved caller; trust only `caller`.
|
|
227
|
+
*/
|
|
228
|
+
route(method: "GET" | "POST" | "PUT" | "DELETE", path: string, handler: (req: Request, caller: RouteCaller) => Promise<Response>): void;
|
|
164
229
|
};
|
|
165
230
|
tools: {
|
|
166
|
-
/**
|
|
231
|
+
/** Registers a tool; callable only during `setup`, names must not repeat. */
|
|
167
232
|
register(spec: ToolSpec, handler: ToolHandler): void;
|
|
168
233
|
};
|
|
169
234
|
/**
|
|
@@ -195,23 +260,45 @@ export interface ExtensionContext {
|
|
|
195
260
|
}[]>;
|
|
196
261
|
};
|
|
197
262
|
/**
|
|
198
|
-
*
|
|
199
|
-
* - `view` / `action
|
|
200
|
-
*
|
|
201
|
-
*
|
|
202
|
-
*
|
|
203
|
-
*
|
|
263
|
+
* Runtime of UI contributions (manifest `ui` + `permissions.ui`):
|
|
264
|
+
* - `view` / `action`: can be registered only during `setup`; the id is the contribution id of
|
|
265
|
+
* the kind-view entry in the manifest;
|
|
266
|
+
* `action` receives a button click or form submission from the view (`args.actionId` tells
|
|
267
|
+
* which one);
|
|
268
|
+
* - `invalidate`: tells the kernel "this contribution changed", and the web pages that have it
|
|
269
|
+
* open fetch the view again (via the bus, across replicas); a
|
|
270
|
+
* `platform.page` contribution takes no `orgId` (it refreshes the admin console), every other
|
|
271
|
+
* contribution requires one;
|
|
272
|
+
* - `verifyEmbedToken`: validates the embed token an embed page received; it accepts only
|
|
273
|
+
* tokens signed for this plugin and not expired, while the plugin is still enabled in that org,
|
|
274
|
+
* the caller is still an active member and the role still satisfies the slot's minRole,
|
|
275
|
+
* otherwise it returns null; the returned `role` is the role at this moment. A
|
|
276
|
+
* platform-scope token (`scope: "platform"`, no `orgId`) verifies only for a `platform.page`
|
|
277
|
+
* contribution while the account is still an active super admin.
|
|
204
278
|
*/
|
|
205
279
|
ui: {
|
|
206
280
|
view(id: string, render: (args: UiRenderArgs) => Promise<UiView>): void;
|
|
207
281
|
action(id: string, handler: (args: UiActionArgs) => Promise<UiActionResult>): void;
|
|
208
282
|
invalidate(target: {
|
|
209
|
-
|
|
283
|
+
/** Required, except for a `platform.page` contribution, where it must be omitted. */
|
|
284
|
+
orgId?: string;
|
|
210
285
|
conversationId?: string;
|
|
211
286
|
contribution: string;
|
|
212
287
|
}): Promise<void>;
|
|
213
288
|
verifyEmbedToken(token: string): Promise<EmbedClaims | null>;
|
|
214
289
|
};
|
|
290
|
+
/**
|
|
291
|
+
* Setup checks (`permissions.setupChecks`): the live rows of the plugin's setup guides.
|
|
292
|
+
* `check` is only allowed during `setup`; `id` must be listed in `permissions.setupChecks`
|
|
293
|
+
* (else `ExtensionPermissionError`); registering an id twice throws. The kernel runs a check only
|
|
294
|
+
* when a person or an agent asks, only for targets of this plugin and of `def.place`, aborts
|
|
295
|
+
* `signal` after `SETUP_CHECK_LIMITS.timeoutMs`, and redacts and bounds the result. A check never
|
|
296
|
+
* writes, passes `signal` to every request, does not retry and never puts a secret in `reason`
|
|
297
|
+
* or `fix`. It never receives an OAuth client secret or a member's token.
|
|
298
|
+
*/
|
|
299
|
+
setup: {
|
|
300
|
+
check(id: string, def: SetupCheckDefinition): void;
|
|
301
|
+
};
|
|
215
302
|
/**
|
|
216
303
|
* Hooks (`permissions.hooks`): observe model and tool calls, or deny them with a policy hook.
|
|
217
304
|
* `on` is only allowed during `setup`; the mount point must be declared in `permissions.hooks` and be
|
|
@@ -224,16 +311,32 @@ export interface ExtensionContext {
|
|
|
224
311
|
hooks: {
|
|
225
312
|
on<K extends AvailableHook>(mount: K, handler: HookHandler<K>, opts: HookOptions): void;
|
|
226
313
|
};
|
|
314
|
+
/**
|
|
315
|
+
* The dial-in channel to the machines serving this extension's devices (requires
|
|
316
|
+
* `permissions.dialIn`, see {@link DialInChannel}): every call is refused for a device another
|
|
317
|
+
* extension serves.
|
|
318
|
+
*/
|
|
319
|
+
dialIn: DialInChannel;
|
|
320
|
+
/**
|
|
321
|
+
* Tells the kernel about this extension's devices (requires `provides` to include
|
|
322
|
+
* `device-provider@1`, see {@link DevicesCtx}).
|
|
323
|
+
*/
|
|
324
|
+
devices: DevicesCtx;
|
|
227
325
|
provide(extensionPoint: ExtensionPointRef, impl: unknown): void;
|
|
228
326
|
/**
|
|
229
|
-
*
|
|
230
|
-
*
|
|
327
|
+
* The lifecycle signal of this plugin instance: aborted when the instance is revoked (disabled,
|
|
328
|
+
* uninstalled, upgraded), after in-flight calls have drained.
|
|
329
|
+
* Long-running tasks the plugin started itself (polling loops, long connections, etc.) wind down
|
|
330
|
+
* on it.
|
|
231
331
|
*/
|
|
232
332
|
signal: AbortSignal;
|
|
233
333
|
/**
|
|
234
|
-
*
|
|
235
|
-
*
|
|
236
|
-
*
|
|
334
|
+
* Deployment-level config, validated against the plugin schema (the startup config merged with
|
|
335
|
+
* values the super admin saved in the console). This is a getter:
|
|
336
|
+
* when a field marked `hot` (`.meta({ hot: true })`) changes, the kernel replaces it in place, so
|
|
337
|
+
* the plugin must read `ctx.config` **at the time of use** to get the new value;
|
|
338
|
+
* do not copy hot fields into a closure in setup; when a non-hot field changes the kernel reloads
|
|
339
|
+
* the plugin instance (a new setup).
|
|
237
340
|
*/
|
|
238
341
|
readonly config: unknown;
|
|
239
342
|
log: Logger;
|
|
@@ -3,18 +3,25 @@ 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
|
+
/**
|
|
21
|
+
* UI contributions, each in a slot of `UI_SLOTS`; every id is also listed in `permissions.ui`.
|
|
22
|
+
* Kept exactly as written: structural problems fail the extension, while a contribution to an
|
|
23
|
+
* unknown slot or version is only dropped when the host resolves the slots (`resolveUiSlots`).
|
|
24
|
+
*/
|
|
18
25
|
ui?: UiContribution[];
|
|
19
26
|
config?: {
|
|
20
27
|
deployment?: z.ZodTypeAny;
|
|
@@ -23,19 +30,26 @@ export interface ExtensionManifest {
|
|
|
23
30
|
migrations?: string;
|
|
24
31
|
setup(ctx: ExtensionContext): void | Promise<void>;
|
|
25
32
|
/**
|
|
26
|
-
*
|
|
27
|
-
*
|
|
28
|
-
*
|
|
29
|
-
*
|
|
30
|
-
*
|
|
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).
|
|
31
42
|
*/
|
|
32
43
|
dispose?(ctx: ExtensionContext): void | Promise<void>;
|
|
33
44
|
}
|
|
34
|
-
/**
|
|
45
|
+
/** The plugin manifest is invalid. */
|
|
35
46
|
export declare class ExtensionManifestError extends Error {
|
|
36
47
|
constructor(plugin: string, message: string);
|
|
37
48
|
}
|
|
38
|
-
/**
|
|
49
|
+
/** Plugin name rule (manifest `name`; a connector template's `plugin` is validated by it too). */
|
|
39
50
|
export declare const EXTENSION_NAME_RE: RegExp;
|
|
40
|
-
/**
|
|
51
|
+
/**
|
|
52
|
+
* Validates the plugin manifest and returns it unchanged; throws ExtensionManifestError when
|
|
53
|
+
* invalid.
|
|
54
|
+
*/
|
|
41
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) => {
|
|
@@ -74,10 +80,11 @@ export function defineExtension(m) {
|
|
|
74
80
|
}
|
|
75
81
|
}
|
|
76
82
|
if (m.permissions !== undefined) {
|
|
77
|
-
const errs = validatePermissions(plugin, m.permissions);
|
|
83
|
+
const errs = validatePermissions(plugin, m.permissions, m.provides);
|
|
78
84
|
if (errs.length > 0)
|
|
79
85
|
fail(`invalid permissions: ${errs.join("; ")}`);
|
|
80
86
|
}
|
|
87
|
+
// structural ui problems only; slot resolution never fails the extension (UI slots spec §3.2)
|
|
81
88
|
const uiErrs = validateUiContributions(m.ui, m.permissions);
|
|
82
89
|
if (uiErrs.length > 0)
|
|
83
90
|
fail(`invalid ui: ${uiErrs.join("; ")}`);
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Paths a local device never opens to restricted work (Request approval, Approve for me), relative
|
|
3
|
+
* to `~` (spec §13.6, extended by ruling R19): SSH keys, cloud CLI credentials, container and
|
|
4
|
+
* Kubernetes credentials, netrc, GnuPG, git / npm / PyPI tokens, the macOS keychains, the
|
|
5
|
+
* browser profile directories, other tool credential stores (cargo, 1Password, Vault, Terraform,
|
|
6
|
+
* Claude, Codex, keyrings, pass, rclone, s3cmd), mise's config directory and the config files it
|
|
7
|
+
* loads from the home (an `[env]` section may hold tokens; globbed names like `~/mise.<env>.toml`
|
|
8
|
+
* are not listed), Maven and Gradle credential files, and shell histories. One source for
|
|
9
|
+
* the device, which denies them (and its own state directory), and the kernel, which never proposes
|
|
10
|
+
* an approval for a path under one. Full access and auto mode run as the owner and do not apply
|
|
11
|
+
* them: the command review does.
|
|
12
|
+
*/
|
|
13
|
+
export declare const DEVICE_DENIED_SECRET_PATHS: readonly string[];
|
|
14
|
+
/**
|
|
15
|
+
* The device program's default state directory (`$XDG_CONFIG_HOME/capybara-device` when that is
|
|
16
|
+
* set), relative to `~`: denied to restricted work like the secret paths.
|
|
17
|
+
*/
|
|
18
|
+
export declare const DEVICE_DEFAULT_STATE_PATH = "~/.config/capybara-device";
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Paths a local device never opens to restricted work (Request approval, Approve for me), relative
|
|
3
|
+
* to `~` (spec §13.6, extended by ruling R19): SSH keys, cloud CLI credentials, container and
|
|
4
|
+
* Kubernetes credentials, netrc, GnuPG, git / npm / PyPI tokens, the macOS keychains, the
|
|
5
|
+
* browser profile directories, other tool credential stores (cargo, 1Password, Vault, Terraform,
|
|
6
|
+
* Claude, Codex, keyrings, pass, rclone, s3cmd), mise's config directory and the config files it
|
|
7
|
+
* loads from the home (an `[env]` section may hold tokens; globbed names like `~/mise.<env>.toml`
|
|
8
|
+
* are not listed), Maven and Gradle credential files, and shell histories. One source for
|
|
9
|
+
* the device, which denies them (and its own state directory), and the kernel, which never proposes
|
|
10
|
+
* an approval for a path under one. Full access and auto mode run as the owner and do not apply
|
|
11
|
+
* them: the command review does.
|
|
12
|
+
*/
|
|
13
|
+
export const DEVICE_DENIED_SECRET_PATHS = Object.freeze([
|
|
14
|
+
"~/.ssh",
|
|
15
|
+
"~/.aws",
|
|
16
|
+
"~/.config/gcloud",
|
|
17
|
+
"~/.azure",
|
|
18
|
+
"~/.kube",
|
|
19
|
+
"~/.docker/config.json",
|
|
20
|
+
"~/.netrc",
|
|
21
|
+
"~/.gnupg",
|
|
22
|
+
"~/Library/Application Support/Google/Chrome",
|
|
23
|
+
"~/Library/Application Support/Firefox",
|
|
24
|
+
"~/.mozilla",
|
|
25
|
+
"~/.config/google-chrome",
|
|
26
|
+
"~/.config/chromium",
|
|
27
|
+
// Ruling R19: more credential stores and browser data.
|
|
28
|
+
"~/.config/gh",
|
|
29
|
+
"~/.git-credentials",
|
|
30
|
+
"~/.npmrc",
|
|
31
|
+
"~/.pypirc",
|
|
32
|
+
"~/Library/Keychains",
|
|
33
|
+
"~/Library/Cookies",
|
|
34
|
+
"~/Library/Safari",
|
|
35
|
+
"~/Library/Application Support/BraveSoftware",
|
|
36
|
+
"~/Library/Application Support/Microsoft Edge",
|
|
37
|
+
"~/Library/Application Support/Arc",
|
|
38
|
+
"~/.config/BraveSoftware",
|
|
39
|
+
"~/.config/microsoft-edge",
|
|
40
|
+
// Machine reach reads the whole home, so more tool credential stores and shell histories.
|
|
41
|
+
"~/.cargo/credentials",
|
|
42
|
+
"~/.cargo/credentials.toml",
|
|
43
|
+
"~/.config/op",
|
|
44
|
+
"~/.vault-token",
|
|
45
|
+
"~/.terraform.d/credentials.tfrc.json",
|
|
46
|
+
"~/.claude/.credentials.json",
|
|
47
|
+
"~/.codex/auth.json",
|
|
48
|
+
"~/.local/share/keyrings",
|
|
49
|
+
"~/.password-store",
|
|
50
|
+
"~/.config/rclone",
|
|
51
|
+
"~/.s3cfg",
|
|
52
|
+
// mise: its whole config directory (config files with [env] sections, the sops age key; its
|
|
53
|
+
// data lives in ~/.local/share/mise) and the config files it walks up to in the home. Globbed
|
|
54
|
+
// spellings such as ~/mise.<env>.toml cannot be listed here and stay readable.
|
|
55
|
+
"~/.config/mise",
|
|
56
|
+
"~/.config/mise.toml",
|
|
57
|
+
"~/.config/mise.local.toml",
|
|
58
|
+
"~/.mise.toml",
|
|
59
|
+
"~/.mise.local.toml",
|
|
60
|
+
"~/.mise",
|
|
61
|
+
"~/mise.toml",
|
|
62
|
+
"~/mise.local.toml",
|
|
63
|
+
"~/mise/config.toml",
|
|
64
|
+
"~/mise/config.local.toml",
|
|
65
|
+
"~/mise/conf.d",
|
|
66
|
+
// mise's legacy (rtx) names
|
|
67
|
+
"~/.rtx.toml",
|
|
68
|
+
"~/.rtx.local.toml",
|
|
69
|
+
// Maven server passwords (and their master keys), Gradle repository credentials and Develocity
|
|
70
|
+
// (Gradle Enterprise) access keys
|
|
71
|
+
"~/.m2/settings.xml",
|
|
72
|
+
"~/.m2/settings-security.xml",
|
|
73
|
+
"~/.m2/settings-security4.xml",
|
|
74
|
+
"~/.gradle/gradle.properties",
|
|
75
|
+
"~/.gradle/develocity/keys.properties",
|
|
76
|
+
"~/.gradle/enterprise/keys.properties",
|
|
77
|
+
"~/.bash_history",
|
|
78
|
+
"~/.zsh_history",
|
|
79
|
+
]);
|
|
80
|
+
/**
|
|
81
|
+
* The device program's default state directory (`$XDG_CONFIG_HOME/capybara-device` when that is
|
|
82
|
+
* set), relative to `~`: denied to restricted work like the secret paths.
|
|
83
|
+
*/
|
|
84
|
+
export const DEVICE_DEFAULT_STATE_PATH = "~/.config/capybara-device";
|