@capybara-hq/plugin-sdk 0.1.0-rc.3 → 0.1.0-rc.31
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/agent-templates.md +15 -3
- package/agent-docs/concepts.md +5 -0
- package/agent-docs/connector-templates.md +2 -1
- package/agent-docs/extension-points/channel.md +1 -1
- package/agent-docs/extension-points/config-source.md +1 -1
- package/agent-docs/extension-points/connector.md +1 -1
- package/agent-docs/extension-points/context.md +15 -0
- package/agent-docs/extension-points/counter.md +1 -1
- package/agent-docs/extension-points/directory.md +1 -1
- package/agent-docs/extension-points/file-preview.md +1 -1
- package/agent-docs/extension-points/identity-source.md +1 -1
- package/agent-docs/extension-points/model-provider.md +4 -2
- package/agent-docs/extension-points/object-store.md +3 -1
- package/agent-docs/extension-points/sandbox.md +3 -3
- package/agent-docs/extension-points/secret-store.md +1 -1
- package/agent-docs/extension-points/web-fetch.md +1 -1
- package/agent-docs/extension-points/web-search.md +1 -1
- package/agent-docs/extensions.md +29 -4
- package/agent-docs/plugin-format.md +43 -3
- package/agent-docs/setup.md +46 -0
- package/agent-docs/skills.md +1 -1
- package/agent-docs/tool-naming.md +1 -1
- package/dist/agent-template.d.ts +15 -6
- package/dist/agent-template.js +32 -13
- package/dist/bootstrap.d.ts +15 -1
- package/dist/bootstrap.js +17 -1
- package/dist/cards.d.ts +56 -13
- package/dist/cards.js +90 -20
- package/dist/channel.d.ts +111 -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 +7 -2
- package/dist/connector-auth.js +29 -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 +135 -26
- package/dist/define-extension.d.ts +26 -12
- package/dist/define-extension.js +11 -4
- package/dist/device-protocol-v3.d.ts +117 -0
- package/dist/device-protocol-v3.js +409 -0
- package/dist/device-protocol.d.ts +330 -0
- package/dist/device-protocol.js +567 -0
- package/dist/extension-point.d.ts +2 -0
- package/dist/extension-point.js +5 -2
- package/dist/file-preview.d.ts +1 -1
- package/dist/git-hosts.d.ts +44 -0
- package/dist/git-hosts.js +81 -0
- package/dist/hooks.d.ts +111 -21
- package/dist/hooks.js +5 -0
- package/dist/http-access.d.ts +52 -0
- package/dist/http-access.js +12 -0
- package/dist/identity.d.ts +22 -9
- package/dist/index.d.ts +23 -1
- package/dist/index.js +24 -1
- 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 +180 -71
- package/dist/model.js +71 -19
- package/dist/net.d.ts +52 -0
- package/dist/net.js +34 -0
- package/dist/permissions.d.ts +42 -20
- package/dist/permissions.js +97 -40
- package/dist/plugin-manifest.d.ts +45 -5
- package/dist/plugin-manifest.js +169 -6
- package/dist/plugin-package.d.ts +82 -38
- package/dist/plugin-package.js +61 -29
- package/dist/sandbox-linux-runtime-source.d.ts +1 -0
- package/dist/sandbox-linux-runtime-source.js +1886 -0
- package/dist/sandbox-native-runtime-source.d.ts +8 -0
- package/dist/sandbox-native-runtime-source.js +325 -0
- package/dist/sandbox-operation.d.ts +248 -0
- package/dist/sandbox-operation.js +245 -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 +60 -0
- package/dist/sandbox-write-denies.js +630 -0
- package/dist/sandbox.d.ts +201 -16
- package/dist/sandbox.js +89 -14
- package/dist/secret.d.ts +4 -1
- package/dist/secret.js +4 -1
- package/dist/setup-check.d.ts +115 -0
- package/dist/setup-check.js +142 -0
- package/dist/setup-guide-parse.d.ts +121 -0
- package/dist/setup-guide-parse.js +350 -0
- package/dist/setup-guide-render.d.ts +45 -0
- package/dist/setup-guide-render.js +351 -0
- package/dist/setup-guide.d.ts +94 -0
- package/dist/setup-guide.js +336 -0
- package/dist/skill-invocation.d.ts +4 -3
- package/dist/skill-invocation.js +5 -4
- package/dist/skill.d.ts +34 -21
- package/dist/skill.js +48 -31
- package/dist/storage.d.ts +52 -25
- package/dist/theme-assets.d.ts +39 -0
- package/dist/theme-assets.js +449 -0
- package/dist/theme-readability.d.ts +37 -0
- package/dist/theme-readability.js +145 -0
- package/dist/theme-tokens.generated.d.ts +279 -0
- package/dist/theme-tokens.generated.js +174 -0
- package/dist/theme.d.ts +152 -0
- package/dist/theme.js +392 -0
- package/dist/tool.d.ts +69 -26
- package/dist/tool.js +29 -9
- package/dist/ui-parts.d.ts +23 -0
- package/dist/ui-parts.js +337 -0
- package/dist/ui-resolve.d.ts +35 -0
- package/dist/ui-resolve.js +42 -0
- package/dist/ui-slots.d.ts +53 -0
- package/dist/ui-slots.js +238 -0
- package/dist/ui.d.ts +191 -79
- package/dist/ui.js +101 -27
- package/dist/url.d.ts +4 -1
- package/dist/url.js +4 -1
- package/package.json +7 -1
- package/schemas/bootstrap.v1.schema.json +6 -0
- package/schemas/connector-template.v1.schema.json +35 -0
- package/schemas/marketplace.v1.schema.json +14 -0
- package/schemas/plugin.v1.schema.json +115 -3
- package/schemas/theme.v1.schema.json +225 -0
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { validateAllowHost } from "./sandbox.js";
|
|
3
|
+
/**
|
|
4
|
+
* The git source of a connector: the git hosts a connector's credential may be used for, and the
|
|
5
|
+
* HTTP basic username to present for each (spec 2026-11-12-sandbox-git-credentials §6.1). Pure
|
|
6
|
+
* validation; the kernel reuses {@link GitSourceSchema} for its connector create body.
|
|
7
|
+
*/
|
|
8
|
+
/** Limits of {@link GitSourceSchema}. */
|
|
9
|
+
export const GIT_HOSTS_LIMITS = {
|
|
10
|
+
/** Hosts per connector. */
|
|
11
|
+
hosts: 8,
|
|
12
|
+
/** Characters of a username. */
|
|
13
|
+
usernameChars: 64,
|
|
14
|
+
};
|
|
15
|
+
/**
|
|
16
|
+
* The basic-auth usernames of well-known git hosts: a GitHub token (a PAT or an app installation
|
|
17
|
+
* token) is presented with the fixed username `x-access-token`. Documentation for template authors;
|
|
18
|
+
* a connector still states its username explicitly.
|
|
19
|
+
*/
|
|
20
|
+
export const GIT_HOST_USERNAMES = {
|
|
21
|
+
"github.com": "x-access-token",
|
|
22
|
+
"*.ghe.com": "x-access-token",
|
|
23
|
+
};
|
|
24
|
+
const USERNAME_RE = /^[A-Za-z0-9._-]{1,64}$/;
|
|
25
|
+
/** Why a host is refused; never echoes the value (it may be a pasted credential or URL). */
|
|
26
|
+
function hostProblems(h) {
|
|
27
|
+
if (/[@:/?#\s]/.test(h))
|
|
28
|
+
return ["host must be a bare hostname (no userinfo, port or path)"];
|
|
29
|
+
if (h.includes("*"))
|
|
30
|
+
return ["host must not contain a wildcard"];
|
|
31
|
+
if (h !== h.toLowerCase())
|
|
32
|
+
return ["host must be lower-case"];
|
|
33
|
+
return validateAllowHost(h);
|
|
34
|
+
}
|
|
35
|
+
const GitHostEntrySchema = z.strictObject({
|
|
36
|
+
host: z
|
|
37
|
+
.string()
|
|
38
|
+
.max(253, "host must be at most 253 characters")
|
|
39
|
+
.superRefine((h, ctx) => {
|
|
40
|
+
for (const message of hostProblems(h))
|
|
41
|
+
ctx.addIssue({ code: "custom", message });
|
|
42
|
+
}),
|
|
43
|
+
username: z
|
|
44
|
+
.string()
|
|
45
|
+
.regex(USERNAME_RE, "username must match ^[A-Za-z0-9._-]{1,64}$ (letters, digits, '.', '_', '-')"),
|
|
46
|
+
});
|
|
47
|
+
/**
|
|
48
|
+
* The zod schema of {@link GitSource} (strict objects, 1 to {@link GIT_HOSTS_LIMITS}`.hosts` hosts,
|
|
49
|
+
* no duplicate host). Error messages never echo the offending value.
|
|
50
|
+
*/
|
|
51
|
+
export const GitSourceSchema = z
|
|
52
|
+
.strictObject({
|
|
53
|
+
hosts: z
|
|
54
|
+
.array(GitHostEntrySchema)
|
|
55
|
+
.min(1, "hosts must not be empty")
|
|
56
|
+
.max(GIT_HOSTS_LIMITS.hosts),
|
|
57
|
+
})
|
|
58
|
+
.superRefine((g, ctx) => {
|
|
59
|
+
const seen = new Set();
|
|
60
|
+
g.hosts.forEach((e, i) => {
|
|
61
|
+
if (seen.has(e.host)) {
|
|
62
|
+
ctx.addIssue({ code: "custom", path: ["hosts", i, "host"], message: "duplicate host" });
|
|
63
|
+
}
|
|
64
|
+
seen.add(e.host);
|
|
65
|
+
});
|
|
66
|
+
});
|
|
67
|
+
/** Validates a `git` value; returns problems as `<path>: <message>` (empty means valid). */
|
|
68
|
+
export function validateGitSource(git, at = "git") {
|
|
69
|
+
const r = GitSourceSchema.safeParse(git);
|
|
70
|
+
if (r.success)
|
|
71
|
+
return [];
|
|
72
|
+
return r.error.issues.map((i) => {
|
|
73
|
+
const path = i.path.map(String).join(".");
|
|
74
|
+
return `${path === "" ? at : `${at}.${path}`}: ${i.message}`;
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
/** Parses a `git` value: the value, or `{ errors }`. */
|
|
78
|
+
export function parseGitSource(git) {
|
|
79
|
+
const errors = validateGitSource(git);
|
|
80
|
+
return errors.length > 0 ? { errors } : GitSourceSchema.parse(git);
|
|
81
|
+
}
|
package/dist/hooks.d.ts
CHANGED
|
@@ -4,7 +4,9 @@ import type { ContentBlock, ModelRequest, ModelUsage } from "./model.js";
|
|
|
4
4
|
* `HOOK_MOUNT_POINTS` (`session.*`, `agent.preStep`) stay reserved: they validate in a manifest but
|
|
5
5
|
* cannot be registered yet.
|
|
6
6
|
*/
|
|
7
|
-
export declare const HOOKS_AVAILABLE: readonly ["model.request", "model.response", "tool.preExecute", "tool.postExecute", "usage.report"];
|
|
7
|
+
export declare const HOOKS_AVAILABLE: readonly ["model.request", "model.response", "tool.preExecute", "tool.postExecute", "usage.report", "org.member_removed", "agent.deleted", "org.deleted"];
|
|
8
|
+
/** Lifecycle mount points: observe-only notices that something was removed. */
|
|
9
|
+
export declare const LIFECYCLE_HOOKS: readonly ["org.member_removed", "agent.deleted", "org.deleted"];
|
|
8
10
|
/** A mount point that `ctx.hooks.on` accepts. */
|
|
9
11
|
export type AvailableHook = (typeof HOOKS_AVAILABLE)[number];
|
|
10
12
|
/** Where a sub-agent was dispatched from: the parent conversation, its run and the `Agent` call. */
|
|
@@ -36,27 +38,34 @@ export interface HookScope {
|
|
|
36
38
|
* that summarizes earlier history before a step when the context grows too large, `title` is the call
|
|
37
39
|
* that writes a conversation's title after its first completed run (no run: `runId` is "", `step` 0,
|
|
38
40
|
* `attempt` 1), `web_fetch` is the call that extracts an answer from a fetched web page for the
|
|
39
|
-
* `WebFetch` tool
|
|
41
|
+
* `WebFetch` tool, `review` is the command-review classifier's call (`review` purpose, no run
|
|
42
|
+
* step; absent = no classifier).
|
|
40
43
|
*/
|
|
41
|
-
export type ModelCallPurpose = "step" | "compaction" | "title" | "web_fetch";
|
|
42
|
-
/** What a reported model call was for (the same values as {@link ModelCallPurpose}). */
|
|
43
|
-
export type UsagePurpose = ModelCallPurpose;
|
|
44
|
+
export type ModelCallPurpose = "step" | "compaction" | "title" | "web_fetch" | "review";
|
|
44
45
|
/**
|
|
45
|
-
*
|
|
46
|
-
*
|
|
46
|
+
* What a reported or requested model call was for: the {@link ModelCallPurpose} values, or
|
|
47
|
+
* `embedding` for an embedding call an extension made through `ctx.models` (`usage.report`, and
|
|
48
|
+
* `model.request` with {@link EmbeddingRequestHookPayload}; never `model.response`).
|
|
49
|
+
*/
|
|
50
|
+
export type UsagePurpose = ModelCallPurpose | "embedding";
|
|
51
|
+
/**
|
|
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.
|
|
47
54
|
* `size` is the size of the bytes sent to the provider, in bytes (0 when unknown).
|
|
48
55
|
*/
|
|
49
56
|
export interface HookMediaPlaceholder {
|
|
50
57
|
type: "media_omitted";
|
|
51
|
-
kind: "image" | "document";
|
|
58
|
+
kind: "image" | "document" | "file";
|
|
52
59
|
mediaType: string;
|
|
53
60
|
size: number;
|
|
54
61
|
}
|
|
55
|
-
/** 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. */
|
|
56
63
|
export type HookContentBlock = Exclude<ContentBlock, {
|
|
57
64
|
type: "image";
|
|
58
65
|
} | {
|
|
59
66
|
type: "document";
|
|
67
|
+
} | {
|
|
68
|
+
type: "file";
|
|
60
69
|
}> | HookMediaPlaceholder;
|
|
61
70
|
/** A message of a `model.request` payload (see {@link HookContentBlock}). */
|
|
62
71
|
export type HookModelMessage = {
|
|
@@ -74,14 +83,15 @@ export type HookModelRequest = Omit<ModelRequest, "messages"> & {
|
|
|
74
83
|
messages: HookModelMessage[];
|
|
75
84
|
};
|
|
76
85
|
/**
|
|
77
|
-
* `model.request
|
|
78
|
-
* step (`purpose: "step"`), once for each compaction call (`purpose: "compaction"`, `attempt` 1)
|
|
86
|
+
* `model.request` of a chat model call (see {@link ModelRequestHookPayload}): once per attempt of a
|
|
87
|
+
* step (`purpose: "step"`), once for each compaction call (`purpose: "compaction"`, `attempt` 1),
|
|
79
88
|
* once for each conversation title call (`purpose: "title"`, `runId` "", `step` 0, `attempt` 1; a
|
|
80
|
-
* denial skips the title and is recorded only in the audit log)
|
|
89
|
+
* denial skips the title and is recorded only in the audit log) and once for each `WebFetch`
|
|
90
|
+
* extraction call (`purpose: "web_fetch"`).
|
|
81
91
|
* `request` is the request as sent, except that images and documents are placeholders
|
|
82
92
|
* ({@link HookMediaPlaceholder}): no media bytes, no attachment ids.
|
|
83
93
|
*/
|
|
84
|
-
export interface
|
|
94
|
+
export interface ModelCallRequestHookPayload extends HookScope {
|
|
85
95
|
purpose: ModelCallPurpose;
|
|
86
96
|
step: number;
|
|
87
97
|
attempt: number;
|
|
@@ -89,6 +99,45 @@ export interface ModelRequestHookPayload extends HookScope {
|
|
|
89
99
|
model: string;
|
|
90
100
|
request: Readonly<HookModelRequest>;
|
|
91
101
|
}
|
|
102
|
+
/**
|
|
103
|
+
* `model.request` of an embedding call an extension made through `ctx.models.embed`
|
|
104
|
+
* (`purpose: "embedding"`): fired once per `embed` call, before the first batch is sent, with every
|
|
105
|
+
* text of the call (the kernel splits them into batches afterwards). A call with no input sends
|
|
106
|
+
* nothing and fires nothing. There is no conversation: the conversation fields of a chat model call
|
|
107
|
+
* (`accountId`, `agentId`, `agentVersion`, `conversationId`, `runId`, `parent`, `step`, `attempt`,
|
|
108
|
+
* `request`) are absent. A policy denial makes `embed` reject (`model.hook_denied`); nothing is sent
|
|
109
|
+
* to the provider and no usage is recorded.
|
|
110
|
+
*/
|
|
111
|
+
export interface EmbeddingRequestHookPayload {
|
|
112
|
+
purpose: "embedding";
|
|
113
|
+
orgId: string;
|
|
114
|
+
/** The extension that called `ctx.models.embed`. */
|
|
115
|
+
extension: string;
|
|
116
|
+
/** The embedding purpose the extension called with (one it declared in `permissions.models`). */
|
|
117
|
+
embeddingPurpose: string;
|
|
118
|
+
provider: string;
|
|
119
|
+
model: string;
|
|
120
|
+
/** The texts of the call, in order (text only). */
|
|
121
|
+
input: readonly string[];
|
|
122
|
+
/** The dimensions the extension asked for, when it asked. */
|
|
123
|
+
dimensions?: number;
|
|
124
|
+
/** The input type the extension gave, when it gave one. */
|
|
125
|
+
inputType?: "query" | "document";
|
|
126
|
+
accountId?: undefined;
|
|
127
|
+
agentId?: undefined;
|
|
128
|
+
agentVersion?: undefined;
|
|
129
|
+
conversationId?: undefined;
|
|
130
|
+
runId?: undefined;
|
|
131
|
+
parent?: undefined;
|
|
132
|
+
}
|
|
133
|
+
/**
|
|
134
|
+
* `model.request`: before a model call is sent. A policy hook may deny it. Either a chat model call
|
|
135
|
+
* ({@link ModelCallRequestHookPayload}: steps, compaction, titles, `WebFetch`) or an extension's
|
|
136
|
+
* embedding call ({@link EmbeddingRequestHookPayload}, `purpose: "embedding"`); tell them apart by
|
|
137
|
+
* `purpose`. Handlers must accept the absent conversation fields of an embedding call (a policy
|
|
138
|
+
* hook that throws on one denies the call). Payloads carry no media bytes.
|
|
139
|
+
*/
|
|
140
|
+
export type ModelRequestHookPayload = ModelCallRequestHookPayload | EmbeddingRequestHookPayload;
|
|
92
141
|
/**
|
|
93
142
|
* `model.response`: after a sent model call finished or failed, with its usage when known (step
|
|
94
143
|
* attempts, compaction and title calls, see `purpose`). Not fired for a call the user aborted (the run was
|
|
@@ -138,12 +187,18 @@ export interface UsageReportPayload {
|
|
|
138
187
|
*/
|
|
139
188
|
purpose: UsagePurpose;
|
|
140
189
|
orgId: string;
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
190
|
+
/** Absent for `embedding`. */
|
|
191
|
+
accountId?: string;
|
|
192
|
+
/** Absent for `embedding`. */
|
|
193
|
+
agentId?: string;
|
|
194
|
+
/** Absent for `embedding`. */
|
|
195
|
+
conversationId?: string;
|
|
196
|
+
/** A sub-agent's calls report `chat`; `parent` tells them apart. Absent for `embedding`. */
|
|
197
|
+
conversationKind?: "chat" | "eval";
|
|
198
|
+
/** Absent for `embedding`. */
|
|
199
|
+
runId?: string;
|
|
200
|
+
/** The calling extension; set for `embedding`. */
|
|
201
|
+
extension?: string;
|
|
147
202
|
/** Set when the call belongs to a sub-agent: where it was dispatched from. */
|
|
148
203
|
parent?: HookParentScope;
|
|
149
204
|
provider: string;
|
|
@@ -151,6 +206,34 @@ export interface UsageReportPayload {
|
|
|
151
206
|
usage: ModelUsage;
|
|
152
207
|
occurredAt: string;
|
|
153
208
|
}
|
|
209
|
+
/**
|
|
210
|
+
* `org.member_removed`: an account left the org (offboarding: removed by an admin, left on its own,
|
|
211
|
+
* or offboarded by a directory sync). Lifecycle hooks are delivered durably, after the removal
|
|
212
|
+
* committed, through a queue, at least once per plugin that declares the mount in
|
|
213
|
+
* `permissions.hooks`, whether or not the org has the plugin enabled and whether or not the org's
|
|
214
|
+
* effective config of the plugin is valid (`call.config` is the platform deployment config): they
|
|
215
|
+
* exist so a plugin can delete the data it holds. Handlers must be idempotent. The payload carries
|
|
216
|
+
* ids only.
|
|
217
|
+
*/
|
|
218
|
+
export interface OrgMemberRemovedPayload {
|
|
219
|
+
orgId: string;
|
|
220
|
+
accountId: string;
|
|
221
|
+
}
|
|
222
|
+
/**
|
|
223
|
+
* `agent.deleted`: an agent was deleted. Delivered like {@link OrgMemberRemovedPayload} (durably, at
|
|
224
|
+
* least once, regardless of org enablement or config validity; ids only).
|
|
225
|
+
*/
|
|
226
|
+
export interface AgentDeletedPayload {
|
|
227
|
+
orgId: string;
|
|
228
|
+
agentId: string;
|
|
229
|
+
}
|
|
230
|
+
/**
|
|
231
|
+
* `org.deleted`: an org was deleted. Delivered like {@link OrgMemberRemovedPayload} (durably, at
|
|
232
|
+
* least once, regardless of org enablement or config validity; ids only).
|
|
233
|
+
*/
|
|
234
|
+
export interface OrgDeletedPayload {
|
|
235
|
+
orgId: string;
|
|
236
|
+
}
|
|
154
237
|
/** Payload type of each mount point. */
|
|
155
238
|
export interface HookPayloads {
|
|
156
239
|
"model.request": ModelRequestHookPayload;
|
|
@@ -158,6 +241,9 @@ export interface HookPayloads {
|
|
|
158
241
|
"tool.preExecute": ToolPreHookPayload;
|
|
159
242
|
"tool.postExecute": ToolPostHookPayload;
|
|
160
243
|
"usage.report": UsageReportPayload;
|
|
244
|
+
"org.member_removed": OrgMemberRemovedPayload;
|
|
245
|
+
"agent.deleted": AgentDeletedPayload;
|
|
246
|
+
"org.deleted": OrgDeletedPayload;
|
|
161
247
|
}
|
|
162
248
|
/**
|
|
163
249
|
* What a hook returns: nothing, or `{ deny: reason }`. A deny only takes effect for a `policy` hook
|
|
@@ -173,12 +259,16 @@ export type HookVerdict = void | {
|
|
|
173
259
|
* extension's effective deployment config for the payload's org (the platform's config with the
|
|
174
260
|
* org's copy applied to the overridable fields, or `ctx.config` while the org follows it); the
|
|
175
261
|
* kernel always passes it, and never calls a hook for an org where that config is not valid
|
|
176
|
-
* (observe hooks are skipped, policy hooks deny).
|
|
262
|
+
* (observe hooks are skipped, policy hooks deny). Lifecycle hooks ({@link LIFECYCLE_HOOKS}) are the
|
|
263
|
+
* exception: they get the platform deployment config and are always called.
|
|
177
264
|
*/
|
|
178
265
|
export type HookHandler<K extends AvailableHook> = (payload: HookPayloads[K], signal: AbortSignal, call?: HookCall) => Promise<HookVerdict> | HookVerdict;
|
|
179
266
|
/** The per-call context of a hook handler (see {@link HookHandler}). */
|
|
180
267
|
export interface HookCall {
|
|
181
|
-
/**
|
|
268
|
+
/**
|
|
269
|
+
* The extension's effective deployment config for the payload's org (lifecycle hooks: the
|
|
270
|
+
* platform deployment config).
|
|
271
|
+
*/
|
|
182
272
|
config: unknown;
|
|
183
273
|
}
|
|
184
274
|
/**
|
package/dist/hooks.js
CHANGED
|
@@ -9,6 +9,11 @@ export const HOOKS_AVAILABLE = [
|
|
|
9
9
|
"tool.preExecute",
|
|
10
10
|
"tool.postExecute",
|
|
11
11
|
"usage.report",
|
|
12
|
+
"org.member_removed",
|
|
13
|
+
"agent.deleted",
|
|
14
|
+
"org.deleted",
|
|
12
15
|
];
|
|
16
|
+
/** Lifecycle mount points: observe-only notices that something was removed. */
|
|
17
|
+
export const LIFECYCLE_HOOKS = ["org.member_removed", "agent.deleted", "org.deleted"];
|
|
13
18
|
/** Mount points where a `policy` hook may deny the call. */
|
|
14
19
|
export const POLICY_HOOKS = ["model.request", "tool.preExecute"];
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import type { UiRole } from "./ui.js";
|
|
2
|
+
/**
|
|
3
|
+
* Who may call an extension route (declared per route in `permissions.http`, enforced by the
|
|
4
|
+
* kernel before the handler runs and before the body is read):
|
|
5
|
+
*
|
|
6
|
+
* - `public`: anyone; unsafe methods are rate-limited per client IP. Mounted at
|
|
7
|
+
* `/plugins/<name><path>`.
|
|
8
|
+
* - `embed`: the holder of an embed token (see `ctx.ui`); path under `/ui/`. Mounted at
|
|
9
|
+
* `/plugins/<name><path>`.
|
|
10
|
+
* - `member` / `admin`: an org member (admin: org admin and up) with a personal access token.
|
|
11
|
+
* Mounted at `/plugins/<name>/orgs/:orgId<path>`.
|
|
12
|
+
*/
|
|
13
|
+
export declare const HTTP_ACCESS: readonly ["public", "embed", "member", "admin"];
|
|
14
|
+
export type HttpAccess = (typeof HTTP_ACCESS)[number];
|
|
15
|
+
/** One entry of `permissions.http`. */
|
|
16
|
+
export interface HttpPermission {
|
|
17
|
+
method: "GET" | "POST" | "PUT" | "DELETE";
|
|
18
|
+
path: string;
|
|
19
|
+
access: HttpAccess;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* The caller the kernel resolved for a route, passed to the handler as its second argument.
|
|
23
|
+
* Trust only this (`caller.orgId`, never an org id in the body or query).
|
|
24
|
+
*/
|
|
25
|
+
export type RouteCaller = {
|
|
26
|
+
access: "public";
|
|
27
|
+
} | {
|
|
28
|
+
access: "embed";
|
|
29
|
+
scope: "org";
|
|
30
|
+
orgId: string;
|
|
31
|
+
accountId: string;
|
|
32
|
+
role: UiRole;
|
|
33
|
+
contribution: string;
|
|
34
|
+
conversationId?: string;
|
|
35
|
+
/** The token's expiry (Unix seconds): a long-lived response (SSE) ends by then. */
|
|
36
|
+
exp: number;
|
|
37
|
+
config: unknown;
|
|
38
|
+
} | {
|
|
39
|
+
access: "embed";
|
|
40
|
+
scope: "platform";
|
|
41
|
+
accountId: string;
|
|
42
|
+
role: "superAdmin";
|
|
43
|
+
contribution: string;
|
|
44
|
+
/** The token's expiry (Unix seconds): a long-lived response (SSE) ends by then. */
|
|
45
|
+
exp: number;
|
|
46
|
+
} | {
|
|
47
|
+
access: "member" | "admin";
|
|
48
|
+
orgId: string;
|
|
49
|
+
accountId: string;
|
|
50
|
+
role: UiRole;
|
|
51
|
+
config: unknown;
|
|
52
|
+
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Who may call an extension route (declared per route in `permissions.http`, enforced by the
|
|
3
|
+
* kernel before the handler runs and before the body is read):
|
|
4
|
+
*
|
|
5
|
+
* - `public`: anyone; unsafe methods are rate-limited per client IP. Mounted at
|
|
6
|
+
* `/plugins/<name><path>`.
|
|
7
|
+
* - `embed`: the holder of an embed token (see `ctx.ui`); path under `/ui/`. Mounted at
|
|
8
|
+
* `/plugins/<name><path>`.
|
|
9
|
+
* - `member` / `admin`: an org member (admin: org admin and up) with a personal access token.
|
|
10
|
+
* Mounted at `/plugins/<name>/orgs/:orgId<path>`.
|
|
11
|
+
*/
|
|
12
|
+
export const HTTP_ACCESS = ["public", "embed", "member", "admin"];
|
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
|
@@ -1,31 +1,53 @@
|
|
|
1
|
-
export declare const SDK_VERSION = "0.1.0-rc.
|
|
1
|
+
export declare const SDK_VERSION = "0.1.0-rc.31";
|
|
2
2
|
export * from "./agent-template.js";
|
|
3
3
|
export * from "./bootstrap.js";
|
|
4
4
|
export * from "./cards.js";
|
|
5
5
|
export * from "./channel.js";
|
|
6
|
+
export * from "./client-css.js";
|
|
7
|
+
export * from "./client-section.js";
|
|
6
8
|
export * from "./config-ui.js";
|
|
7
9
|
export * from "./connector.js";
|
|
8
10
|
export * from "./connector-auth.js";
|
|
11
|
+
export * from "./context.js";
|
|
9
12
|
export * from "./ctx.js";
|
|
10
13
|
export * from "./define-extension.js";
|
|
14
|
+
export * from "./device-protocol.js";
|
|
15
|
+
export { type BackgroundReadOutputRequestV3, type BackgroundReadOutputResultV3, type BindInstanceRequestV3, type BindInstanceResultV3, type DeviceFrameV3, type DeviceHelloV3, type DeviceOperationV3, type DeviceOwnerCeilingNarrowingV3, type DeviceOwnerCeilingV3, type DevicePolicyArgsV3, type DevicePolicyChangedV3, type DevicePolicyResultV3, type DevicePolicyStatusV3, type DeviceResponseV3, type DeviceRuntimeIdentityV3, type KernelReadyV3, type KernelRequestV3, parseDeviceFrameV3, parseOperationResultV3, parseOwnerCeilingReportV3, STAGED_DEVICE_PROTOCOL_VERSION, } from "./device-protocol-v3.js";
|
|
11
16
|
export * from "./directory.js";
|
|
12
17
|
export * from "./extension-point.js";
|
|
13
18
|
export * from "./file-preview.js";
|
|
19
|
+
export * from "./git-hosts.js";
|
|
14
20
|
export * from "./hooks.js";
|
|
21
|
+
export * from "./http-access.js";
|
|
15
22
|
export * from "./identity.js";
|
|
16
23
|
export * from "./marketplace.js";
|
|
17
24
|
export * from "./model.js";
|
|
18
25
|
export * from "./model-params.js";
|
|
26
|
+
export * from "./net.js";
|
|
19
27
|
export * from "./org-access.js";
|
|
20
28
|
export * from "./permissions.js";
|
|
21
29
|
export * from "./plugin-manifest.js";
|
|
22
30
|
export * from "./plugin-package.js";
|
|
23
31
|
export * from "./sandbox.js";
|
|
32
|
+
export * from "./sandbox-operation.js";
|
|
33
|
+
export { SANDBOX_RUNTIME_SOURCE } from "./sandbox-runtime-source.js";
|
|
34
|
+
export { isSandboxMoveDenied, isSandboxWriteDenied, SANDBOX_GIT_ALLOWED_DIRECTORIES, SANDBOX_GIT_ALLOWED_FILES, SANDBOX_GIT_DENIED_INTERNALS, SANDBOX_MANDATORY_WRITE_DENIES, SANDBOX_PROTECTED_PATH_NAMES, } from "./sandbox-write-denies.js";
|
|
24
35
|
export * from "./secret.js";
|
|
36
|
+
export * from "./setup-check.js";
|
|
37
|
+
export * from "./setup-guide.js";
|
|
38
|
+
export { type ParsedSetupGuide, parseSetupGuide, type SetupGuideCheckLine, type SetupGuideCodeBlock, type SetupGuideParseIssue, type SetupGuideSection, } from "./setup-guide-parse.js";
|
|
39
|
+
export * from "./setup-guide-render.js";
|
|
25
40
|
export * from "./skill.js";
|
|
26
41
|
export * from "./skill-invocation.js";
|
|
27
42
|
export * from "./storage.js";
|
|
43
|
+
export * from "./theme.js";
|
|
44
|
+
export * from "./theme-assets.js";
|
|
45
|
+
export * from "./theme-readability.js";
|
|
46
|
+
export * from "./theme-tokens.generated.js";
|
|
28
47
|
export * from "./tool.js";
|
|
29
48
|
export * from "./tool-key.js";
|
|
30
49
|
export * from "./ui.js";
|
|
50
|
+
export * from "./ui-parts.js";
|
|
51
|
+
export * from "./ui-resolve.js";
|
|
52
|
+
export * from "./ui-slots.js";
|
|
31
53
|
export * from "./web.js";
|
package/dist/index.js
CHANGED
|
@@ -1,31 +1,54 @@
|
|
|
1
|
-
export const SDK_VERSION = "0.1.0-rc.
|
|
1
|
+
export const SDK_VERSION = "0.1.0-rc.31";
|
|
2
2
|
export * from "./agent-template.js";
|
|
3
3
|
export * from "./bootstrap.js";
|
|
4
4
|
export * from "./cards.js";
|
|
5
5
|
export * from "./channel.js";
|
|
6
|
+
export * from "./client-css.js";
|
|
7
|
+
export * from "./client-section.js";
|
|
6
8
|
export * from "./config-ui.js";
|
|
7
9
|
export * from "./connector.js";
|
|
8
10
|
export * from "./connector-auth.js";
|
|
11
|
+
export * from "./context.js";
|
|
9
12
|
export * from "./ctx.js";
|
|
10
13
|
export * from "./define-extension.js";
|
|
14
|
+
export * from "./device-protocol.js";
|
|
15
|
+
// Development staging: removed with the coordinated device protocol v3 activation.
|
|
16
|
+
export { parseDeviceFrameV3, parseOperationResultV3, parseOwnerCeilingReportV3, STAGED_DEVICE_PROTOCOL_VERSION, } from "./device-protocol-v3.js";
|
|
11
17
|
export * from "./directory.js";
|
|
12
18
|
export * from "./extension-point.js";
|
|
13
19
|
export * from "./file-preview.js";
|
|
20
|
+
export * from "./git-hosts.js";
|
|
14
21
|
export * from "./hooks.js";
|
|
22
|
+
export * from "./http-access.js";
|
|
15
23
|
export * from "./identity.js";
|
|
16
24
|
export * from "./marketplace.js";
|
|
17
25
|
export * from "./model.js";
|
|
18
26
|
export * from "./model-params.js";
|
|
27
|
+
export * from "./net.js";
|
|
19
28
|
export * from "./org-access.js";
|
|
20
29
|
export * from "./permissions.js";
|
|
21
30
|
export * from "./plugin-manifest.js";
|
|
22
31
|
export * from "./plugin-package.js";
|
|
23
32
|
export * from "./sandbox.js";
|
|
33
|
+
export * from "./sandbox-operation.js";
|
|
34
|
+
export { SANDBOX_RUNTIME_SOURCE } from "./sandbox-runtime-source.js";
|
|
35
|
+
export { isSandboxMoveDenied, isSandboxWriteDenied, SANDBOX_GIT_ALLOWED_DIRECTORIES, SANDBOX_GIT_ALLOWED_FILES, SANDBOX_GIT_DENIED_INTERNALS, SANDBOX_MANDATORY_WRITE_DENIES, SANDBOX_PROTECTED_PATH_NAMES, } from "./sandbox-write-denies.js";
|
|
24
36
|
export * from "./secret.js";
|
|
37
|
+
export * from "./setup-check.js";
|
|
38
|
+
export * from "./setup-guide.js";
|
|
39
|
+
export { parseSetupGuide, } from "./setup-guide-parse.js";
|
|
40
|
+
export * from "./setup-guide-render.js";
|
|
25
41
|
export * from "./skill.js";
|
|
26
42
|
export * from "./skill-invocation.js";
|
|
27
43
|
export * from "./storage.js";
|
|
44
|
+
export * from "./theme.js";
|
|
45
|
+
export * from "./theme-assets.js";
|
|
46
|
+
export * from "./theme-readability.js";
|
|
47
|
+
export * from "./theme-tokens.generated.js";
|
|
28
48
|
export * from "./tool.js";
|
|
29
49
|
export * from "./tool-key.js";
|
|
30
50
|
export * from "./ui.js";
|
|
51
|
+
export * from "./ui-parts.js";
|
|
52
|
+
export * from "./ui-resolve.js";
|
|
53
|
+
export * from "./ui-slots.js";
|
|
31
54
|
export * from "./web.js";
|
package/dist/marketplace.d.ts
CHANGED
|
@@ -28,6 +28,8 @@ export declare const MARKETPLACE_LIMITS: {
|
|
|
28
28
|
readonly plugins: 5000;
|
|
29
29
|
readonly permissionKeys: 500;
|
|
30
30
|
readonly urlChars: 2000;
|
|
31
|
+
/** Bytes of an entry icon (the plugin icon limit, {@link CONNECTOR_TEMPLATE_LIMITS}). */
|
|
32
|
+
readonly iconBytes: number;
|
|
31
33
|
};
|
|
32
34
|
/** Where a marketplace entry's plugin comes from. */
|
|
33
35
|
export type MarketplaceSource = {
|
|
@@ -75,6 +77,18 @@ export interface MarketplaceEntry {
|
|
|
75
77
|
};
|
|
76
78
|
/** https URL. */
|
|
77
79
|
homepage?: string;
|
|
80
|
+
/**
|
|
81
|
+
* The plugin's icon for marketplace lists, before the plugin is imported (display only; an
|
|
82
|
+
* imported plugin shows its own icon). Either an absolute `https://` URL whose path ends in
|
|
83
|
+
* `.svg` / `.png`, or `./<path>.svg|png` inside the marketplace's repository, read at the commit
|
|
84
|
+
* the marketplace was refreshed at (git marketplaces only; ignored in a marketplace fetched over
|
|
85
|
+
* http). The kernel downloads it on refresh (network rules of the marketplace downloads, never
|
|
86
|
+
* with the marketplace token), keeps it when it really is an svg / png of at most
|
|
87
|
+
* {@link MARKETPLACE_LIMITS}`.iconBytes`, and treats a URL's content as fixed: a new icon needs a
|
|
88
|
+
* new URL. A missing or invalid icon never fails the refresh. `capybara-plugin marketplace
|
|
89
|
+
* --write` fills it with the repository path of the plugin's `plugin.json` `icon`.
|
|
90
|
+
*/
|
|
91
|
+
icon?: string;
|
|
78
92
|
/**
|
|
79
93
|
* This version is deprecated (`true`, or with a reason shown to admins): browsing lists it under
|
|
80
94
|
* the plugin's other versions, never as the one to import, and the kernel refuses importing it
|
|
@@ -103,6 +117,8 @@ export interface MarketplaceParseOptions {
|
|
|
103
117
|
/** Tests only: allow http on loopback addresses for `git` / `archive` URLs. */
|
|
104
118
|
allowInsecureLoopback?: boolean;
|
|
105
119
|
}
|
|
120
|
+
/** An entry icon's file extension (of the URL's path, or of the repository path). */
|
|
121
|
+
export declare const MARKETPLACE_ICON_RE: RegExp;
|
|
106
122
|
/**
|
|
107
123
|
* The zod schema of `marketplace.json` (https only; non-strict: unknown fields dropped). The JSON
|
|
108
124
|
* Schema is generated with `z.toJSONSchema(MarketplaceManifestSchema, { io: "input" })`.
|
|
@@ -117,6 +133,16 @@ export declare function parseMarketplaceManifest(json: unknown, opts?: Marketpla
|
|
|
117
133
|
};
|
|
118
134
|
/** The entry's version: `version`, else the npm source's version, else `null` (the plugin's own). */
|
|
119
135
|
export declare function marketplaceEntryVersion(e: MarketplaceEntry): string | null;
|
|
136
|
+
/**
|
|
137
|
+
* The entry's icon (see {@link MarketplaceEntry.icon}): `{ url }` for an absolute URL, `{ path }`
|
|
138
|
+
* (normalized, without the leading `./`) for a path inside the marketplace's repository, `null`
|
|
139
|
+
* without one.
|
|
140
|
+
*/
|
|
141
|
+
export declare function marketplaceEntryIcon(e: Pick<MarketplaceEntry, "icon">): {
|
|
142
|
+
url: string;
|
|
143
|
+
} | {
|
|
144
|
+
path: string;
|
|
145
|
+
} | null;
|
|
120
146
|
/**
|
|
121
147
|
* The entry's deprecation (see {@link MarketplaceEntry.deprecated}): `null` when it is not
|
|
122
148
|
* deprecated (absent or `false`), else its reason (`null` without one).
|