@capybara-hq/plugin-sdk 0.1.0-rc.9 → 0.1.0-rc.90
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 +3 -1
- package/agent-docs/agent-templates.md +14 -2
- package/agent-docs/concepts.md +14 -5
- package/agent-docs/connector-templates.md +11 -3
- 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 +3 -1
- package/agent-docs/extension-points/identity-source.md +2 -0
- package/agent-docs/extension-points/model-provider.md +5 -1
- package/agent-docs/extension-points/object-store.md +2 -0
- package/agent-docs/extension-points/push-provider.md +17 -0
- package/agent-docs/extension-points/trigger-source.md +19 -0
- package/agent-docs/extensions.md +98 -4
- package/agent-docs/plugin-format.md +45 -10
- package/agent-docs/setup.md +54 -0
- package/api/plugin-sdk.api.md +5983 -0
- package/dist/agent-template.d.ts +15 -6
- package/dist/agent-template.js +32 -13
- package/dist/agents-ctx.d.ts +116 -0
- package/dist/agents-ctx.js +22 -0
- 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 +121 -13
- package/dist/cards.js +161 -19
- package/dist/channel.d.ts +133 -47
- 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 +28 -6
- package/dist/config-ui.js +88 -25
- package/dist/config-url-fetch.d.ts +19 -0
- package/dist/config-url-fetch.js +43 -0
- package/dist/connector-auth.d.ts +13 -2
- package/dist/connector-auth.js +82 -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 +344 -31
- package/dist/ctx.js +9 -1
- package/dist/define-extension.d.ts +18 -12
- package/dist/define-extension.js +18 -5
- package/dist/device-denied-paths.d.ts +20 -0
- package/dist/device-denied-paths.js +118 -0
- package/dist/device-operation.d.ts +348 -0
- package/dist/device-operation.js +312 -0
- package/dist/device-protocol.d.ts +286 -49
- package/dist/device-protocol.js +766 -89
- package/dist/device-provider.d.ts +820 -0
- package/dist/device-provider.js +432 -0
- package/dist/device-service.d.ts +204 -0
- package/dist/device-service.js +291 -0
- package/dist/dial-in.d.ts +286 -0
- package/dist/dial-in.js +213 -0
- package/dist/directory.d.ts +15 -12
- package/dist/extension-point.d.ts +2 -0
- package/dist/extension-point.js +8 -3
- package/dist/field-meta.d.ts +19 -0
- package/dist/field-meta.js +54 -0
- package/dist/file-preview.d.ts +46 -9
- package/dist/git-hosts.d.ts +53 -0
- package/dist/git-hosts.js +98 -0
- package/dist/hooks.d.ts +185 -22
- package/dist/hooks.js +6 -0
- package/dist/http-access.d.ts +71 -0
- package/dist/http-access.js +12 -0
- package/dist/identity.d.ts +70 -9
- package/dist/identity.js +46 -1
- package/dist/inbox.d.ts +103 -0
- package/dist/inbox.js +173 -0
- package/dist/index.d.ts +30 -4
- package/dist/index.js +30 -4
- package/dist/model-params.d.ts +41 -22
- package/dist/model-params.js +28 -15
- package/dist/model.d.ts +295 -77
- package/dist/model.js +249 -21
- package/dist/native-failure.d.ts +13 -0
- package/dist/native-failure.js +31 -0
- 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 +95 -25
- package/dist/permissions.js +175 -54
- package/dist/platform-only.d.ts +27 -0
- package/dist/platform-only.js +35 -0
- package/dist/plugin-manifest.d.ts +30 -6
- package/dist/plugin-manifest.js +147 -55
- package/dist/plugin-package.d.ts +82 -39
- package/dist/plugin-package.js +68 -41
- 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 +2343 -0
- package/dist/sandbox-native-runtime-source.d.ts +10 -0
- package/dist/sandbox-native-runtime-source.js +480 -0
- package/dist/sandbox-runtime-source.d.ts +47 -0
- package/dist/sandbox-runtime-source.js +73 -0
- package/dist/sandbox-write-denies.d.ts +139 -0
- package/dist/sandbox-write-denies.js +869 -0
- package/dist/secret.d.ts +8 -2
- package/dist/secret.js +11 -4
- 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 +86 -72
- package/dist/setup-guide.js +340 -108
- package/dist/shell-capabilities.d.ts +216 -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-invocation.d.ts +5 -0
- package/dist/skill-invocation.js +4 -3
- 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 +25 -9
- package/dist/theme-assets.js +87 -47
- package/dist/theme-tokens.generated.d.ts +40 -12
- package/dist/theme-tokens.generated.js +36 -8
- package/dist/theme.d.ts +56 -10
- package/dist/theme.js +117 -23
- package/dist/tool.d.ts +242 -28
- package/dist/tool.js +135 -13
- package/dist/trigger-source.d.ts +35 -0
- package/dist/trigger-source.js +2 -0
- package/dist/triggers.d.ts +88 -0
- package/dist/triggers.js +71 -0
- package/dist/ui-parts.d.ts +23 -0
- package/dist/ui-parts.js +374 -0
- package/dist/ui-resolve.d.ts +2 -7
- package/dist/ui-resolve.js +7 -19
- package/dist/ui-slots.d.ts +27 -5
- package/dist/ui-slots.js +112 -19
- package/dist/ui.d.ts +203 -64
- package/dist/ui.js +117 -23
- package/dist/url.d.ts +4 -1
- package/dist/url.js +4 -1
- package/dist/web.d.ts +26 -20
- 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 +62 -4
- package/schemas/plugin.v1.schema.json +74 -143
- package/schemas/theme.v1.schema.json +77 -0
- package/agent-docs/extension-points/sandbox.md +0 -15
- package/dist/org-access.d.ts +0 -27
- package/dist/org-access.js +0 -35
- package/dist/sandbox.d.ts +0 -254
- package/dist/sandbox.js +0 -153
package/dist/inbox.js
ADDED
|
@@ -0,0 +1,173 @@
|
|
|
1
|
+
import { UI_LIMITS } from "./ui.js";
|
|
2
|
+
/** A {@link InboxCtx} call was refused. */
|
|
3
|
+
export class InboxError extends Error {
|
|
4
|
+
code;
|
|
5
|
+
constructor(code, message, opts) {
|
|
6
|
+
super(message, opts && "cause" in opts ? { cause: opts.cause } : undefined);
|
|
7
|
+
this.name = "InboxError";
|
|
8
|
+
this.code = code;
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
/** The most actions one inbox item carries. */
|
|
12
|
+
export const INBOX_ACTIONS_MAX = 3;
|
|
13
|
+
/** Limits of an inbox item. */
|
|
14
|
+
export const INBOX_LIMITS = {
|
|
15
|
+
titleChars: 200,
|
|
16
|
+
bodyChars: 2000,
|
|
17
|
+
linkChars: 512,
|
|
18
|
+
kindChars: 64,
|
|
19
|
+
labelChars: 40,
|
|
20
|
+
idChars: 64,
|
|
21
|
+
dedupeKeyChars: 200,
|
|
22
|
+
/** UTF-8 bytes of one action's `payload` as JSON (as a UI button's). */
|
|
23
|
+
payloadBytes: UI_LIMITS.payloadBytes,
|
|
24
|
+
defaultExpirySeconds: 30 * 24 * 3600,
|
|
25
|
+
maxExpirySeconds: 90 * 24 * 3600,
|
|
26
|
+
};
|
|
27
|
+
/** The shape of an item's `kind`: dotted lower-case words. */
|
|
28
|
+
export const INBOX_KIND_RE = /^[a-z][a-z0-9_]*(\.[a-z][a-z0-9_]*)*$/;
|
|
29
|
+
/** The shape of an action id, a contribution id and a UI action id. */
|
|
30
|
+
export const INBOX_ID_RE = /^[A-Za-z0-9][A-Za-z0-9_.-]*$/;
|
|
31
|
+
/**
|
|
32
|
+
* Checks a post before it is stored; returns error codes (empty = valid): `missing_<field>`,
|
|
33
|
+
* `<field>_too_long`, `title_invalid` / `body_invalid` (not a string or `{ zh, en }`),
|
|
34
|
+
* `kind_invalid`, `link_invalid` (not a path of the extension's own pages
|
|
35
|
+
* `/p/<plugin>/`), `too_many_actions`, `action_invalid`, `action_duplicate`, `payload_too_large`,
|
|
36
|
+
* `expiry_invalid`. `plugin` is the posting extension's name.
|
|
37
|
+
*/
|
|
38
|
+
export function validateInboxPost(p, plugin) {
|
|
39
|
+
const errs = [];
|
|
40
|
+
const str = (v) => typeof v === "string";
|
|
41
|
+
const blank = (v) => !str(v) || v.trim() === "";
|
|
42
|
+
if (blank(p.orgId))
|
|
43
|
+
errs.push("missing_org_id");
|
|
44
|
+
if (blank(p.accountId))
|
|
45
|
+
errs.push("missing_account_id");
|
|
46
|
+
if (blank(p.kind))
|
|
47
|
+
errs.push("missing_kind");
|
|
48
|
+
else if (p.kind.length > INBOX_LIMITS.kindChars || !INBOX_KIND_RE.test(p.kind))
|
|
49
|
+
errs.push("kind_invalid");
|
|
50
|
+
const title = textProblem(p.title, INBOX_LIMITS.titleChars, true);
|
|
51
|
+
if (title !== null)
|
|
52
|
+
errs.push(`${title === "missing" ? "missing_title" : `title_${title}`}`);
|
|
53
|
+
if (p.body !== undefined) {
|
|
54
|
+
const body = textProblem(p.body, INBOX_LIMITS.bodyChars, false);
|
|
55
|
+
if (body !== null)
|
|
56
|
+
errs.push(body === "missing" ? "body_invalid" : `body_${body}`);
|
|
57
|
+
}
|
|
58
|
+
if (p.link !== undefined) {
|
|
59
|
+
if (!str(p.link) || p.link.length > INBOX_LIMITS.linkChars || !ownPageLink(p.link, plugin))
|
|
60
|
+
errs.push("link_invalid");
|
|
61
|
+
}
|
|
62
|
+
if (p.dedupeKey !== undefined) {
|
|
63
|
+
if (blank(p.dedupeKey) || p.dedupeKey.length > INBOX_LIMITS.dedupeKeyChars)
|
|
64
|
+
errs.push("dedupe_key_invalid");
|
|
65
|
+
}
|
|
66
|
+
if (p.expiresInSeconds !== undefined) {
|
|
67
|
+
const s = p.expiresInSeconds;
|
|
68
|
+
if (typeof s !== "number" || !Number.isInteger(s) || s < 1 || s > INBOX_LIMITS.maxExpirySeconds)
|
|
69
|
+
errs.push("expiry_invalid");
|
|
70
|
+
}
|
|
71
|
+
if (p.actions !== undefined) {
|
|
72
|
+
if (!Array.isArray(p.actions))
|
|
73
|
+
errs.push("action_invalid");
|
|
74
|
+
else {
|
|
75
|
+
if (p.actions.length > INBOX_ACTIONS_MAX)
|
|
76
|
+
errs.push("too_many_actions");
|
|
77
|
+
const ids = new Set();
|
|
78
|
+
for (const a of p.actions) {
|
|
79
|
+
const problem = actionProblem(a);
|
|
80
|
+
if (problem !== null) {
|
|
81
|
+
errs.push(problem);
|
|
82
|
+
continue;
|
|
83
|
+
}
|
|
84
|
+
if (ids.has(a.id))
|
|
85
|
+
errs.push("action_duplicate");
|
|
86
|
+
ids.add(a.id);
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
return [...new Set(errs)];
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* What is wrong with a title or body (a string, or `{ zh, en }` with both strings): `missing` (a
|
|
94
|
+
* required text that is not a string or object, or blank), `invalid` (an object with another
|
|
95
|
+
* shape, or a blank language of a required text), `too_long`; null when it is fine.
|
|
96
|
+
*/
|
|
97
|
+
function textProblem(v, max, required) {
|
|
98
|
+
const blank = (t) => required && t.trim() === "";
|
|
99
|
+
if (typeof v === "string") {
|
|
100
|
+
if (blank(v))
|
|
101
|
+
return "missing";
|
|
102
|
+
return v.length > max ? "too_long" : null;
|
|
103
|
+
}
|
|
104
|
+
if (typeof v !== "object" || v === null || Array.isArray(v))
|
|
105
|
+
return "missing";
|
|
106
|
+
const keys = Object.keys(v);
|
|
107
|
+
const { zh, en } = v;
|
|
108
|
+
if (keys.length !== 2 || typeof zh !== "string" || typeof en !== "string")
|
|
109
|
+
return "invalid";
|
|
110
|
+
if (blank(zh) || blank(en))
|
|
111
|
+
return "invalid";
|
|
112
|
+
return zh.length > max || en.length > max ? "too_long" : null;
|
|
113
|
+
}
|
|
114
|
+
const idOk = (v) => typeof v === "string" && v.length <= INBOX_LIMITS.idChars && INBOX_ID_RE.test(v);
|
|
115
|
+
const labelOk = (v) => typeof v === "string" && v.trim() !== "" && v.length <= INBOX_LIMITS.labelChars;
|
|
116
|
+
function actionProblem(a) {
|
|
117
|
+
if (typeof a !== "object" || a === null)
|
|
118
|
+
return "action_invalid";
|
|
119
|
+
const x = a;
|
|
120
|
+
if (!idOk(x.id))
|
|
121
|
+
return "action_invalid";
|
|
122
|
+
if (typeof x.label !== "object" || x.label === null)
|
|
123
|
+
return "action_invalid";
|
|
124
|
+
if (!labelOk(x.label.zh) || !labelOk(x.label.en))
|
|
125
|
+
return "action_invalid";
|
|
126
|
+
if (x.style !== undefined && x.style !== "primary" && x.style !== "danger")
|
|
127
|
+
return "action_invalid";
|
|
128
|
+
const u = x.uiAction;
|
|
129
|
+
if (typeof u !== "object" || u === null)
|
|
130
|
+
return "action_invalid";
|
|
131
|
+
if (!idOk(u.contribution) || !idOk(u.actionId))
|
|
132
|
+
return "action_invalid";
|
|
133
|
+
if (u.payload !== undefined) {
|
|
134
|
+
let json;
|
|
135
|
+
try {
|
|
136
|
+
json = JSON.stringify(u.payload);
|
|
137
|
+
}
|
|
138
|
+
catch {
|
|
139
|
+
return "action_invalid";
|
|
140
|
+
}
|
|
141
|
+
if (json === undefined)
|
|
142
|
+
return "action_invalid";
|
|
143
|
+
if (new TextEncoder().encode(json).length > INBOX_LIMITS.payloadBytes)
|
|
144
|
+
return "payload_too_large";
|
|
145
|
+
}
|
|
146
|
+
return null;
|
|
147
|
+
}
|
|
148
|
+
/**
|
|
149
|
+
* Whether `link` is a path of the extension's own pages: `/p/<plugin>/` followed by at least one
|
|
150
|
+
* character, with no backslash or control character, no dot segment (`.`, `..`, also spelled with
|
|
151
|
+
* `%2e` in any case), and a path that still starts with `/p/<plugin>/` once a URL parser resolved
|
|
152
|
+
* it.
|
|
153
|
+
*/
|
|
154
|
+
function ownPageLink(link, plugin) {
|
|
155
|
+
const prefix = `/p/${plugin}/`;
|
|
156
|
+
if (!link.startsWith(prefix) || link.length === prefix.length)
|
|
157
|
+
return false;
|
|
158
|
+
if (/[\\\p{Cc}]/u.test(link))
|
|
159
|
+
return false;
|
|
160
|
+
const path = link.split(/[?#]/, 1)[0] ?? "";
|
|
161
|
+
const dot = (s) => {
|
|
162
|
+
const d = s.replace(/%2e/gi, ".");
|
|
163
|
+
return d === "." || d === "..";
|
|
164
|
+
};
|
|
165
|
+
if (path.split("/").some(dot))
|
|
166
|
+
return false;
|
|
167
|
+
try {
|
|
168
|
+
return new URL(link, "http://x").pathname.startsWith(prefix);
|
|
169
|
+
}
|
|
170
|
+
catch {
|
|
171
|
+
return false;
|
|
172
|
+
}
|
|
173
|
+
}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,29 +1,52 @@
|
|
|
1
|
-
export declare const SDK_VERSION = "0.1.0-rc.
|
|
1
|
+
export declare const SDK_VERSION = "0.1.0-rc.90";
|
|
2
2
|
export * from "./agent-template.js";
|
|
3
|
+
export * from "./agents-ctx.js";
|
|
4
|
+
export * from "./avatar-presets.js";
|
|
3
5
|
export * from "./bootstrap.js";
|
|
4
6
|
export * from "./cards.js";
|
|
5
7
|
export * from "./channel.js";
|
|
8
|
+
export * from "./client-css.js";
|
|
9
|
+
export * from "./client-section.js";
|
|
6
10
|
export * from "./config-ui.js";
|
|
11
|
+
export * from "./config-url-fetch.js";
|
|
7
12
|
export * from "./connector.js";
|
|
8
13
|
export * from "./connector-auth.js";
|
|
14
|
+
export * from "./context.js";
|
|
9
15
|
export * from "./ctx.js";
|
|
10
16
|
export * from "./define-extension.js";
|
|
11
|
-
export
|
|
17
|
+
export { DEVICE_DEFAULT_STATE_PATH, DEVICE_DENIED_SECRET_PATHS } from "./device-denied-paths.js";
|
|
18
|
+
export * from "./device-operation.js";
|
|
19
|
+
export * from "./device-provider.js";
|
|
20
|
+
export * from "./device-service.js";
|
|
21
|
+
export * from "./dial-in.js";
|
|
12
22
|
export * from "./directory.js";
|
|
13
23
|
export * from "./extension-point.js";
|
|
14
24
|
export * from "./file-preview.js";
|
|
25
|
+
export * from "./git-hosts.js";
|
|
15
26
|
export * from "./hooks.js";
|
|
27
|
+
export * from "./http-access.js";
|
|
16
28
|
export * from "./identity.js";
|
|
29
|
+
export * from "./inbox.js";
|
|
17
30
|
export * from "./marketplace.js";
|
|
18
31
|
export * from "./model.js";
|
|
19
32
|
export * from "./model-params.js";
|
|
20
|
-
export * from "./
|
|
33
|
+
export * from "./native-failure.js";
|
|
34
|
+
export * from "./net.js";
|
|
35
|
+
export * from "./network-classes.js";
|
|
21
36
|
export * from "./permissions.js";
|
|
37
|
+
export * from "./platform-only.js";
|
|
22
38
|
export * from "./plugin-manifest.js";
|
|
23
39
|
export * from "./plugin-package.js";
|
|
24
|
-
export * from "./
|
|
40
|
+
export * from "./push.js";
|
|
41
|
+
export { SANDBOX_RUNTIME_SOURCE, type SandboxRuntimeFeature, type SandboxRuntimeFile, } from "./sandbox-runtime-source.js";
|
|
42
|
+
export { isSandboxHomeWriteDenied, isSandboxMoveDenied, isSandboxWriteDenied, SANDBOX_GIT_ALLOWED_DIRECTORIES, SANDBOX_GIT_ALLOWED_FILES, SANDBOX_GIT_DENIED_INTERNALS, SANDBOX_HOME_WRITE_DENIES, SANDBOX_MANDATORY_WRITE_DENIES, SANDBOX_PROTECTED_PATH_NAMES, SANDBOX_RESERVED_NAME_PREFIX, SANDBOX_RUNTIME_DIRECTORIES, SANDBOX_SYSTEM_WRITE_DENIES, sandboxRuntimeDirectoryOf, } from "./sandbox-write-denies.js";
|
|
25
43
|
export * from "./secret.js";
|
|
44
|
+
export * from "./setup-check.js";
|
|
26
45
|
export * from "./setup-guide.js";
|
|
46
|
+
export { type ParsedSetupGuide, parseSetupGuide, type SetupGuideCheckLine, type SetupGuideCodeBlock, type SetupGuideParseIssue, type SetupGuideSection, } from "./setup-guide-parse.js";
|
|
47
|
+
export * from "./setup-guide-render.js";
|
|
48
|
+
export * from "./shell-capabilities.js";
|
|
49
|
+
export * from "./shell-environment.js";
|
|
27
50
|
export * from "./skill.js";
|
|
28
51
|
export * from "./skill-invocation.js";
|
|
29
52
|
export * from "./storage.js";
|
|
@@ -33,7 +56,10 @@ export * from "./theme-readability.js";
|
|
|
33
56
|
export * from "./theme-tokens.generated.js";
|
|
34
57
|
export * from "./tool.js";
|
|
35
58
|
export * from "./tool-key.js";
|
|
59
|
+
export * from "./trigger-source.js";
|
|
60
|
+
export * from "./triggers.js";
|
|
36
61
|
export * from "./ui.js";
|
|
62
|
+
export * from "./ui-parts.js";
|
|
37
63
|
export * from "./ui-resolve.js";
|
|
38
64
|
export * from "./ui-slots.js";
|
|
39
65
|
export * from "./web.js";
|
package/dist/index.js
CHANGED
|
@@ -1,29 +1,52 @@
|
|
|
1
|
-
export const SDK_VERSION = "0.1.0-rc.
|
|
1
|
+
export const SDK_VERSION = "0.1.0-rc.90";
|
|
2
2
|
export * from "./agent-template.js";
|
|
3
|
+
export * from "./agents-ctx.js";
|
|
4
|
+
export * from "./avatar-presets.js";
|
|
3
5
|
export * from "./bootstrap.js";
|
|
4
6
|
export * from "./cards.js";
|
|
5
7
|
export * from "./channel.js";
|
|
8
|
+
export * from "./client-css.js";
|
|
9
|
+
export * from "./client-section.js";
|
|
6
10
|
export * from "./config-ui.js";
|
|
11
|
+
export * from "./config-url-fetch.js";
|
|
7
12
|
export * from "./connector.js";
|
|
8
13
|
export * from "./connector-auth.js";
|
|
14
|
+
export * from "./context.js";
|
|
9
15
|
export * from "./ctx.js";
|
|
10
16
|
export * from "./define-extension.js";
|
|
11
|
-
export
|
|
17
|
+
export { DEVICE_DEFAULT_STATE_PATH, DEVICE_DENIED_SECRET_PATHS } from "./device-denied-paths.js";
|
|
18
|
+
export * from "./device-operation.js";
|
|
19
|
+
export * from "./device-provider.js";
|
|
20
|
+
export * from "./device-service.js";
|
|
21
|
+
export * from "./dial-in.js";
|
|
12
22
|
export * from "./directory.js";
|
|
13
23
|
export * from "./extension-point.js";
|
|
14
24
|
export * from "./file-preview.js";
|
|
25
|
+
export * from "./git-hosts.js";
|
|
15
26
|
export * from "./hooks.js";
|
|
27
|
+
export * from "./http-access.js";
|
|
16
28
|
export * from "./identity.js";
|
|
29
|
+
export * from "./inbox.js";
|
|
17
30
|
export * from "./marketplace.js";
|
|
18
31
|
export * from "./model.js";
|
|
19
32
|
export * from "./model-params.js";
|
|
20
|
-
export * from "./
|
|
33
|
+
export * from "./native-failure.js";
|
|
34
|
+
export * from "./net.js";
|
|
35
|
+
export * from "./network-classes.js";
|
|
21
36
|
export * from "./permissions.js";
|
|
37
|
+
export * from "./platform-only.js";
|
|
22
38
|
export * from "./plugin-manifest.js";
|
|
23
39
|
export * from "./plugin-package.js";
|
|
24
|
-
export * from "./
|
|
40
|
+
export * from "./push.js";
|
|
41
|
+
export { SANDBOX_RUNTIME_SOURCE, } from "./sandbox-runtime-source.js";
|
|
42
|
+
export { isSandboxHomeWriteDenied, isSandboxMoveDenied, isSandboxWriteDenied, SANDBOX_GIT_ALLOWED_DIRECTORIES, SANDBOX_GIT_ALLOWED_FILES, SANDBOX_GIT_DENIED_INTERNALS, SANDBOX_HOME_WRITE_DENIES, SANDBOX_MANDATORY_WRITE_DENIES, SANDBOX_PROTECTED_PATH_NAMES, SANDBOX_RESERVED_NAME_PREFIX, SANDBOX_RUNTIME_DIRECTORIES, SANDBOX_SYSTEM_WRITE_DENIES, sandboxRuntimeDirectoryOf, } from "./sandbox-write-denies.js";
|
|
25
43
|
export * from "./secret.js";
|
|
44
|
+
export * from "./setup-check.js";
|
|
26
45
|
export * from "./setup-guide.js";
|
|
46
|
+
export { parseSetupGuide, } from "./setup-guide-parse.js";
|
|
47
|
+
export * from "./setup-guide-render.js";
|
|
48
|
+
export * from "./shell-capabilities.js";
|
|
49
|
+
export * from "./shell-environment.js";
|
|
27
50
|
export * from "./skill.js";
|
|
28
51
|
export * from "./skill-invocation.js";
|
|
29
52
|
export * from "./storage.js";
|
|
@@ -33,7 +56,10 @@ export * from "./theme-readability.js";
|
|
|
33
56
|
export * from "./theme-tokens.generated.js";
|
|
34
57
|
export * from "./tool.js";
|
|
35
58
|
export * from "./tool-key.js";
|
|
59
|
+
export * from "./trigger-source.js";
|
|
60
|
+
export * from "./triggers.js";
|
|
36
61
|
export * from "./ui.js";
|
|
62
|
+
export * from "./ui-parts.js";
|
|
37
63
|
export * from "./ui-resolve.js";
|
|
38
64
|
export * from "./ui-slots.js";
|
|
39
65
|
export * from "./web.js";
|
package/dist/model-params.d.ts
CHANGED
|
@@ -1,22 +1,29 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* `model-provider@2`
|
|
3
|
-
*
|
|
2
|
+
* Parameter declarations and validation for `model-provider@2` (pure functions; issues / error
|
|
3
|
+
* messages are in English, for logs and API responses).
|
|
4
|
+
* Each model declares in `ModelInfo.parameters` the parameters it supports; value constraints are a
|
|
5
|
+
* restricted JSON Schema subset.
|
|
4
6
|
*/
|
|
5
7
|
export type Effort = "low" | "medium" | "high" | "xhigh" | "max";
|
|
6
8
|
/**
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
* - `thinking
|
|
10
|
-
*
|
|
11
|
-
* - `
|
|
9
|
+
* Standard knobs: uniform platform semantics, rendered specially by the UI, with semantics that
|
|
10
|
+
* carry over when switching models or falling back; the plugin maps them to native parameters.
|
|
11
|
+
* - `effort`: thinking depth, `{ type: "string", enum }`, values a subset of
|
|
12
|
+
* `low|medium|high|xhigh|max`;
|
|
13
|
+
* - `thinking`: thinking mode, `{ type: "string", enum }`, values a subset of `off|on|summarized`;
|
|
14
|
+
* - `temperature`: `{ type: "number" }` (may carry a range);
|
|
15
|
+
* - `maxOutputTokens`: maximum output tokens, `{ type: "integer" }` (may carry a range).
|
|
12
16
|
*/
|
|
13
17
|
export type StandardKnob = "effort" | "thinking" | "temperature" | "maxOutputTokens";
|
|
14
18
|
export declare const STANDARD_KNOBS: readonly StandardKnob[];
|
|
15
|
-
/** `effort`
|
|
19
|
+
/** The full set of values the `effort` knob allows. */
|
|
16
20
|
export declare const EFFORT_VALUES: readonly Effort[];
|
|
17
|
-
/** `thinking`
|
|
21
|
+
/** The full set of values the `thinking` knob allows. */
|
|
18
22
|
export declare const THINKING_VALUES: readonly string[];
|
|
19
|
-
/**
|
|
23
|
+
/**
|
|
24
|
+
* Parameter value constraints: a restricted JSON Schema subset (serializable for the UI; the kernel
|
|
25
|
+
* validates it itself, without ajv).
|
|
26
|
+
*/
|
|
20
27
|
export type ParamSchema = {
|
|
21
28
|
type: "string";
|
|
22
29
|
enum: string[];
|
|
@@ -31,14 +38,20 @@ export type ParamSchema = {
|
|
|
31
38
|
maximum?: number;
|
|
32
39
|
};
|
|
33
40
|
export type ParamValue = string | number | boolean;
|
|
34
|
-
/**
|
|
41
|
+
/** One parameter a model declares. */
|
|
35
42
|
export interface ModelParameter {
|
|
36
|
-
/**
|
|
43
|
+
/**
|
|
44
|
+
* A standard knob name (see {@link StandardKnob}), or a vendor-specific parameter `"<plugin
|
|
45
|
+
* name>.<name>"`.
|
|
46
|
+
*/
|
|
37
47
|
key: string;
|
|
38
|
-
/**
|
|
48
|
+
/**
|
|
49
|
+
* Required when key is a standard knob and must equal key; vendor-specific parameters must not
|
|
50
|
+
* set it.
|
|
51
|
+
*/
|
|
39
52
|
standard?: StandardKnob;
|
|
40
53
|
schema: ParamSchema;
|
|
41
|
-
/**
|
|
54
|
+
/** The value used when unset; must satisfy the schema. */
|
|
42
55
|
default?: ParamValue;
|
|
43
56
|
label: {
|
|
44
57
|
zh: string;
|
|
@@ -53,11 +66,13 @@ export interface ParamIssue {
|
|
|
53
66
|
key: string;
|
|
54
67
|
message: string;
|
|
55
68
|
}
|
|
56
|
-
/**
|
|
69
|
+
/** Returns an English reason when the value does not satisfy the schema, undefined when it does. */
|
|
57
70
|
export declare function checkParamValue(schema: ParamSchema, v: unknown): string | undefined;
|
|
58
71
|
/**
|
|
59
|
-
*
|
|
60
|
-
*
|
|
72
|
+
* Strict validation (used when saving an agent): unknown keys, type mismatches, enum violations and
|
|
73
|
+
* out-of-range values are all errors, reported per key.
|
|
74
|
+
* On success `value` is the input parameters, with no defaults filled in; a key whose value is
|
|
75
|
+
* undefined counts as unset.
|
|
61
76
|
*/
|
|
62
77
|
export declare function validateParams(decl: ModelParameter[], params: Record<string, unknown>): {
|
|
63
78
|
ok: true;
|
|
@@ -67,16 +82,20 @@ export declare function validateParams(decl: ModelParameter[], params: Record<st
|
|
|
67
82
|
issues: ParamIssue[];
|
|
68
83
|
};
|
|
69
84
|
/**
|
|
70
|
-
*
|
|
71
|
-
*
|
|
85
|
+
* The lenient variant (used at runtime): drops unknown or invalid entries (their keys go into
|
|
86
|
+
* `dropped`), then fills defaults for declared parameters that are unset.
|
|
87
|
+
* For the case where saved parameters are no longer valid after a plugin upgrade, so that the whole
|
|
88
|
+
* run does not fail.
|
|
72
89
|
*/
|
|
73
90
|
export declare function sanitizeParams(decl: ModelParameter[], params: Record<string, unknown>): {
|
|
74
91
|
value: Record<string, ParamValue>;
|
|
75
92
|
dropped: string[];
|
|
76
93
|
};
|
|
77
94
|
/**
|
|
78
|
-
*
|
|
79
|
-
*
|
|
80
|
-
*
|
|
95
|
+
* Validates the parameters a plugin declares for a model: the key is a standard knob or
|
|
96
|
+
* `<plugin>.<name>`, `standard` agrees with the key,
|
|
97
|
+
* the schema belongs to the supported subset, standard knobs satisfy the value conventions,
|
|
98
|
+
* defaults satisfy the schema, copy is complete, keys do not repeat.
|
|
99
|
+
* Throws when there is a problem, with a message naming the plugin and each key (in English).
|
|
81
100
|
*/
|
|
82
101
|
export declare function assertValidDeclarations(plugin: string, decl: ModelParameter[]): void;
|
package/dist/model-params.js
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* `model-provider@2`
|
|
3
|
-
*
|
|
2
|
+
* Parameter declarations and validation for `model-provider@2` (pure functions; issues / error
|
|
3
|
+
* messages are in English, for logs and API responses).
|
|
4
|
+
* Each model declares in `ModelInfo.parameters` the parameters it supports; value constraints are a
|
|
5
|
+
* restricted JSON Schema subset.
|
|
4
6
|
*/
|
|
5
7
|
export const STANDARD_KNOBS = [
|
|
6
8
|
"effort",
|
|
@@ -8,13 +10,13 @@ export const STANDARD_KNOBS = [
|
|
|
8
10
|
"temperature",
|
|
9
11
|
"maxOutputTokens",
|
|
10
12
|
];
|
|
11
|
-
/** `effort`
|
|
13
|
+
/** The full set of values the `effort` knob allows. */
|
|
12
14
|
export const EFFORT_VALUES = ["low", "medium", "high", "xhigh", "max"];
|
|
13
|
-
/** `thinking`
|
|
15
|
+
/** The full set of values the `thinking` knob allows. */
|
|
14
16
|
export const THINKING_VALUES = ["off", "on", "summarized"];
|
|
15
17
|
const isStandardKnob = (k) => STANDARD_KNOBS.includes(k);
|
|
16
18
|
const VENDOR_NAME = /^[A-Za-z][A-Za-z0-9_-]*$/;
|
|
17
|
-
/**
|
|
19
|
+
/** Returns an English reason when the value does not satisfy the schema, undefined when it does. */
|
|
18
20
|
export function checkParamValue(schema, v) {
|
|
19
21
|
switch (schema.type) {
|
|
20
22
|
case "boolean":
|
|
@@ -45,11 +47,16 @@ export function checkParamValue(schema, v) {
|
|
|
45
47
|
return `has unsupported schema type ${JSON.stringify(schema.type)}`;
|
|
46
48
|
}
|
|
47
49
|
}
|
|
48
|
-
/**
|
|
50
|
+
/**
|
|
51
|
+
* Looks up a declaration by key (uses a Map so that prototype properties such as `constructor` are
|
|
52
|
+
* not mistaken for declared keys).
|
|
53
|
+
*/
|
|
49
54
|
const declMap = (decl) => new Map(decl.map((d) => [d.key, d]));
|
|
50
55
|
/**
|
|
51
|
-
*
|
|
52
|
-
*
|
|
56
|
+
* Strict validation (used when saving an agent): unknown keys, type mismatches, enum violations and
|
|
57
|
+
* out-of-range values are all errors, reported per key.
|
|
58
|
+
* On success `value` is the input parameters, with no defaults filled in; a key whose value is
|
|
59
|
+
* undefined counts as unset.
|
|
53
60
|
*/
|
|
54
61
|
export function validateParams(decl, params) {
|
|
55
62
|
const byKey = declMap(decl);
|
|
@@ -72,8 +79,10 @@ export function validateParams(decl, params) {
|
|
|
72
79
|
return issues.length > 0 ? { ok: false, issues } : { ok: true, value };
|
|
73
80
|
}
|
|
74
81
|
/**
|
|
75
|
-
*
|
|
76
|
-
*
|
|
82
|
+
* The lenient variant (used at runtime): drops unknown or invalid entries (their keys go into
|
|
83
|
+
* `dropped`), then fills defaults for declared parameters that are unset.
|
|
84
|
+
* For the case where saved parameters are no longer valid after a plugin upgrade, so that the whole
|
|
85
|
+
* run does not fail.
|
|
77
86
|
*/
|
|
78
87
|
export function sanitizeParams(decl, params) {
|
|
79
88
|
const byKey = declMap(decl);
|
|
@@ -143,7 +152,9 @@ function schemaProblems(schema) {
|
|
|
143
152
|
return [`unsupported schema type ${JSON.stringify(s.type)}`];
|
|
144
153
|
}
|
|
145
154
|
}
|
|
146
|
-
/**
|
|
155
|
+
/**
|
|
156
|
+
* The value conventions of standard knobs (checked only when the schema itself is already valid).
|
|
157
|
+
*/
|
|
147
158
|
function knobProblems(key, schema) {
|
|
148
159
|
const values = schema.type === "string" && "enum" in schema ? schema.enum : undefined;
|
|
149
160
|
switch (key) {
|
|
@@ -178,7 +189,7 @@ function textProblems(d) {
|
|
|
178
189
|
}
|
|
179
190
|
return out;
|
|
180
191
|
}
|
|
181
|
-
/**
|
|
192
|
+
/** All problems of one parameter declaration; an empty array when there are none. */
|
|
182
193
|
function declarationProblems(plugin, d) {
|
|
183
194
|
if (typeof d !== "object" || d === null)
|
|
184
195
|
return ["declaration must be an object"];
|
|
@@ -198,9 +209,11 @@ function declarationProblems(plugin, d) {
|
|
|
198
209
|
return out;
|
|
199
210
|
}
|
|
200
211
|
/**
|
|
201
|
-
*
|
|
202
|
-
*
|
|
203
|
-
*
|
|
212
|
+
* Validates the parameters a plugin declares for a model: the key is a standard knob or
|
|
213
|
+
* `<plugin>.<name>`, `standard` agrees with the key,
|
|
214
|
+
* the schema belongs to the supported subset, standard knobs satisfy the value conventions,
|
|
215
|
+
* defaults satisfy the schema, copy is complete, keys do not repeat.
|
|
216
|
+
* Throws when there is a problem, with a message naming the plugin and each key (in English).
|
|
204
217
|
*/
|
|
205
218
|
export function assertValidDeclarations(plugin, decl) {
|
|
206
219
|
if (!Array.isArray(decl)) {
|