@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
package/dist/config-ui.js
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
|
+
/** Every channel inbound mode, in the order forms list them. */
|
|
3
|
+
export const CHANNEL_INBOUND_MODES = ["long_connection", "webhook"];
|
|
2
4
|
/** Limits of config UI hints and of the JSON Schemas a plugin package carries. */
|
|
3
5
|
export const CONFIG_UI_LIMITS = {
|
|
4
6
|
/** Characters per language of a `label` (also `unit`, `item.addLabel`). */
|
|
@@ -163,9 +165,18 @@ const HINT_KEYS = new Set([
|
|
|
163
165
|
"secrets",
|
|
164
166
|
"sections",
|
|
165
167
|
"messages",
|
|
168
|
+
"inboundModes",
|
|
166
169
|
]);
|
|
167
170
|
/** The only hints a secret node may carry. */
|
|
168
|
-
const SECRET_HINT_KEYS = new Set([
|
|
171
|
+
const SECRET_HINT_KEYS = new Set([
|
|
172
|
+
"label",
|
|
173
|
+
"help",
|
|
174
|
+
"placeholder",
|
|
175
|
+
"order",
|
|
176
|
+
"section",
|
|
177
|
+
"advanced",
|
|
178
|
+
"inboundModes",
|
|
179
|
+
]);
|
|
169
180
|
const ITEM_KEYS = new Set(["title", "subtitle", "addLabel", "reorder"]);
|
|
170
181
|
const utf8Bytes = (s) => new TextEncoder().encode(s).length;
|
|
171
182
|
/** The JSON types a node accepts (`type`, a type list, or the branches of a nullable `anyOf`). */
|
|
@@ -326,7 +337,7 @@ export function validateConfigUi(schema, level) {
|
|
|
326
337
|
if (!isObj(raw))
|
|
327
338
|
report("x-ui must be an object");
|
|
328
339
|
else
|
|
329
|
-
checkHints(raw, node, isRoot, report, text);
|
|
340
|
+
checkHints(raw, node, isRoot, depth, report, text);
|
|
330
341
|
}
|
|
331
342
|
const shape = shapeOf(node);
|
|
332
343
|
const props = shape.properties;
|
|
@@ -343,7 +354,7 @@ export function validateConfigUi(schema, level) {
|
|
|
343
354
|
visit(shape.additionalProperties, path === "" ? "additionalProperties" : `${path}.additionalProperties`, false, depth + 1);
|
|
344
355
|
}
|
|
345
356
|
};
|
|
346
|
-
const checkHints = (h, node, isRoot, report, text) => {
|
|
357
|
+
const checkHints = (h, node, isRoot, depth, report, text) => {
|
|
347
358
|
const shape = shapeOf(node);
|
|
348
359
|
const types = typesOf(node);
|
|
349
360
|
const isArray = types.has("array");
|
|
@@ -356,7 +367,7 @@ export function validateConfigUi(schema, level) {
|
|
|
356
367
|
if (node["x-secret"] === true) {
|
|
357
368
|
const bad = Object.keys(h).filter((k) => HINT_KEYS.has(k) && !SECRET_HINT_KEYS.has(k));
|
|
358
369
|
if (bad.length > 0) {
|
|
359
|
-
report(`a secret field allows only label, help, placeholder, order, section and
|
|
370
|
+
report(`a secret field allows only label, help, placeholder, order, section, advanced and inboundModes hints, not ${bad.join(", ")}`);
|
|
360
371
|
}
|
|
361
372
|
}
|
|
362
373
|
text(h.label, "label", L.labelChars);
|
|
@@ -369,6 +380,28 @@ export function validateConfigUi(schema, level) {
|
|
|
369
380
|
if (h.advanced !== undefined && typeof h.advanced !== "boolean") {
|
|
370
381
|
report("advanced must be a boolean");
|
|
371
382
|
}
|
|
383
|
+
if (h.inboundModes !== undefined) {
|
|
384
|
+
const modes = h.inboundModes;
|
|
385
|
+
if (level !== "connection") {
|
|
386
|
+
report(`inboundModes is only allowed at the connection level, not ${level}`);
|
|
387
|
+
}
|
|
388
|
+
else if (depth !== 1) {
|
|
389
|
+
report("inboundModes is only allowed on a top-level field of the config");
|
|
390
|
+
}
|
|
391
|
+
else if (!Array.isArray(modes) || modes.length === 0) {
|
|
392
|
+
report("inboundModes must be a non-empty array");
|
|
393
|
+
}
|
|
394
|
+
else {
|
|
395
|
+
modes.forEach((m, i) => {
|
|
396
|
+
if (!CHANNEL_INBOUND_MODES.includes(m)) {
|
|
397
|
+
report(`inboundModes[${i}] must be one of ${CHANNEL_INBOUND_MODES.join(", ")}`);
|
|
398
|
+
}
|
|
399
|
+
else if (modes.indexOf(m) !== i) {
|
|
400
|
+
report(`inboundModes[${i}] "${String(m)}" is listed twice`);
|
|
401
|
+
}
|
|
402
|
+
});
|
|
403
|
+
}
|
|
404
|
+
}
|
|
372
405
|
if (h.section !== undefined) {
|
|
373
406
|
if (typeof h.section !== "string" || !sectionIds.has(h.section)) {
|
|
374
407
|
report(`section "${String(h.section)}" is not an id of the root's sections`);
|
|
@@ -600,3 +633,30 @@ export function validateConfigUi(schema, level) {
|
|
|
600
633
|
}
|
|
601
634
|
return problems;
|
|
602
635
|
}
|
|
636
|
+
/**
|
|
637
|
+
* The top-level fields of a connection config's JSON Schema ({@link configJsonSchema}) that carry
|
|
638
|
+
* an `inboundModes` hint, with their modes (unknown modes dropped). Pure; fields without the hint
|
|
639
|
+
* belong to every mode and are not listed.
|
|
640
|
+
*/
|
|
641
|
+
export function inboundModeFields(schema) {
|
|
642
|
+
const out = {};
|
|
643
|
+
for (const [key, node] of Object.entries(properties(schema))) {
|
|
644
|
+
const hints = isObj(node) ? node["x-ui"] : undefined;
|
|
645
|
+
const modes = isObj(hints) ? hints.inboundModes : undefined;
|
|
646
|
+
if (!Array.isArray(modes))
|
|
647
|
+
continue;
|
|
648
|
+
const known = CHANNEL_INBOUND_MODES.filter((m) => modes.includes(m));
|
|
649
|
+
if (known.length > 0)
|
|
650
|
+
out[key] = known;
|
|
651
|
+
}
|
|
652
|
+
return out;
|
|
653
|
+
}
|
|
654
|
+
/**
|
|
655
|
+
* The fields `mode` requires ({@link inboundModeFields}) for which `has(field)` is false, in schema
|
|
656
|
+
* order: what the kernel refuses on a channel connection create or config / mode change.
|
|
657
|
+
*/
|
|
658
|
+
export function missingInboundModeFields(schema, mode, has) {
|
|
659
|
+
return Object.entries(inboundModeFields(schema))
|
|
660
|
+
.filter(([key, modes]) => modes.includes(mode) && !has(key))
|
|
661
|
+
.map(([key]) => key);
|
|
662
|
+
}
|
package/dist/connector-auth.d.ts
CHANGED
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
|
-
/**
|
|
2
|
+
/**
|
|
3
|
+
* Authentication method: only the type and non-secret fields; credential values go through the
|
|
4
|
+
* kernel's `credential` / credentials API.
|
|
5
|
+
*/
|
|
3
6
|
export declare const ConnectorAuthSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
4
7
|
type: z.ZodLiteral<"none">;
|
|
5
8
|
}, z.core.$strict>, z.ZodObject<{
|
|
@@ -50,6 +53,7 @@ export declare const ConnectorAuthSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
|
50
53
|
client_secret_basic: "client_secret_basic";
|
|
51
54
|
client_secret_post: "client_secret_post";
|
|
52
55
|
}>>;
|
|
56
|
+
tokenTypes: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
53
57
|
}, z.core.$strict>, z.ZodObject<{
|
|
54
58
|
type: z.ZodLiteral<"oauth_client">;
|
|
55
59
|
ownership: z.ZodLiteral<"org">;
|
|
@@ -59,6 +63,7 @@ export declare const ConnectorAuthSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
|
59
63
|
client_secret_basic: "client_secret_basic";
|
|
60
64
|
client_secret_post: "client_secret_post";
|
|
61
65
|
}>>;
|
|
66
|
+
tokenTypes: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
62
67
|
}, z.core.$strict>], "type">;
|
|
63
|
-
/**
|
|
68
|
+
/** Auth preset (the output of {@link ConnectorAuthSchema}). */
|
|
64
69
|
export type ConnectorAuthPreset = z.infer<typeof ConnectorAuthSchema>;
|
package/dist/connector-auth.js
CHANGED
|
@@ -1,21 +1,24 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
2
|
/*
|
|
3
|
-
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
3
|
+
* A connector's authentication method (only the type and non-secret fields; credential values are
|
|
4
|
+
* not here): the kernel's connector install API and the connector templates in the catalog
|
|
5
|
+
* (`ConnectorTemplateSpec.auth`) share this one schema. Every branch is strict: extra fields (such
|
|
6
|
+
* as `token`) are always rejected,
|
|
7
|
+
* so a valid auth preset cannot smuggle in a credential. Whether OAuth endpoints must be https is
|
|
8
|
+
* checked again by the kernel per deployment config.
|
|
6
9
|
*/
|
|
7
|
-
/** HTTP
|
|
10
|
+
/** HTTP header name (RFC 9110 token). */
|
|
8
11
|
const HeaderName = z
|
|
9
12
|
.string()
|
|
10
13
|
.min(1)
|
|
11
14
|
.max(100)
|
|
12
15
|
.regex(/^[A-Za-z0-9!#$%&'*+.^_`|~-]+$/, "Invalid header name");
|
|
13
16
|
const Ownership = z.enum(["org", "personal"]);
|
|
14
|
-
/** OAuth
|
|
17
|
+
/** OAuth endpoint (https etc. is checked again by the kernel per deployment config). */
|
|
15
18
|
const OAuthUrl = z.url().max(2000);
|
|
16
|
-
/**
|
|
19
|
+
/** Client authentication method at the token endpoint (when there is a client secret). */
|
|
17
20
|
const TokenAuthMethod = z.enum(["client_secret_basic", "client_secret_post"]);
|
|
18
|
-
/** OAuth scope
|
|
21
|
+
/** OAuth scope (RFC 6749 §3.3 scope-token). */
|
|
19
22
|
const Scopes = z
|
|
20
23
|
.array(z
|
|
21
24
|
.string()
|
|
@@ -23,7 +26,23 @@ const Scopes = z
|
|
|
23
26
|
.max(200)
|
|
24
27
|
.regex(/^[\x21\x23-\x5B\x5D-\x7E]+$/, "Invalid scope"))
|
|
25
28
|
.max(50);
|
|
26
|
-
/**
|
|
29
|
+
/**
|
|
30
|
+
* More `token_type` values the token endpoint may return for a bearer token (case-insensitive;
|
|
31
|
+
* `Bearer` and Slack's `user` are always accepted). The token is still sent as
|
|
32
|
+
* `Authorization: Bearer`. Never `DPoP`: such a token is bound to a key the kernel does not hold.
|
|
33
|
+
*/
|
|
34
|
+
const TokenTypes = z
|
|
35
|
+
.array(z
|
|
36
|
+
.string()
|
|
37
|
+
.min(1)
|
|
38
|
+
.max(32)
|
|
39
|
+
.regex(/^[A-Za-z][A-Za-z0-9_.-]*$/, "Invalid token type")
|
|
40
|
+
.refine((t) => t.toLowerCase() !== "dpop", "DPoP tokens are not bearer tokens"))
|
|
41
|
+
.max(5);
|
|
42
|
+
/**
|
|
43
|
+
* Authentication method: only the type and non-secret fields; credential values go through the
|
|
44
|
+
* kernel's `credential` / credentials API.
|
|
45
|
+
*/
|
|
27
46
|
export const ConnectorAuthSchema = z.discriminatedUnion("type", [
|
|
28
47
|
z.object({ type: z.literal("none") }).strict(),
|
|
29
48
|
z.object({ type: z.literal("bearer"), ownership: Ownership }).strict(),
|
|
@@ -57,6 +76,7 @@ export const ConnectorAuthSchema = z.discriminatedUnion("type", [
|
|
|
57
76
|
scopes: Scopes.optional(),
|
|
58
77
|
client: z.enum(["dcr", "manual"]),
|
|
59
78
|
tokenAuthMethod: TokenAuthMethod.optional(),
|
|
79
|
+
tokenTypes: TokenTypes.optional(),
|
|
60
80
|
})
|
|
61
81
|
.strict()
|
|
62
82
|
.superRefine((a, ctx) => {
|
|
@@ -91,6 +111,7 @@ export const ConnectorAuthSchema = z.discriminatedUnion("type", [
|
|
|
91
111
|
tokenUrl: OAuthUrl,
|
|
92
112
|
scopes: Scopes.optional(),
|
|
93
113
|
tokenAuthMethod: TokenAuthMethod.optional(),
|
|
114
|
+
tokenTypes: TokenTypes.optional(),
|
|
94
115
|
})
|
|
95
116
|
.strict(),
|
|
96
117
|
]);
|
package/dist/connector.d.ts
CHANGED
|
@@ -1,16 +1,19 @@
|
|
|
1
1
|
import type { ZodTypeAny } from "zod";
|
|
2
2
|
import type { FormAnswer, ToolContent, ToolResult, ToolSpec } from "./tool.js";
|
|
3
|
-
/**
|
|
3
|
+
/** Authentication information injected into outbound requests. */
|
|
4
4
|
export interface AuthInjection {
|
|
5
5
|
headers: Record<string, string>;
|
|
6
6
|
query?: Record<string, string>;
|
|
7
7
|
}
|
|
8
|
-
/**
|
|
8
|
+
/** One session between the connector and the remote service. */
|
|
9
9
|
export interface ConnectorSession {
|
|
10
10
|
listTools(): Promise<ToolSpec[]>;
|
|
11
11
|
/**
|
|
12
|
-
* `ctx.spec
|
|
13
|
-
* `connectorData
|
|
12
|
+
* `ctx.spec`: the already-reviewed definition of this tool in the kernel snapshot
|
|
13
|
+
* (`connector_tools.spec`, never a new definition awaiting review), including the `connectorData`
|
|
14
|
+
* given at listTools.
|
|
15
|
+
* The connector should route the call by it rather than re-reading the remote description (remote
|
|
16
|
+
* changes must pass drift review first). Old kernels do not pass it; check for absence.
|
|
14
17
|
*/
|
|
15
18
|
callTool(name: string, input: unknown, signal: AbortSignal, ctx?: {
|
|
16
19
|
spec: ToolSpec;
|
|
@@ -22,13 +25,19 @@ export interface ConnectorSession {
|
|
|
22
25
|
mimeType?: string;
|
|
23
26
|
}[]>;
|
|
24
27
|
readResource?(uri: string): Promise<ToolResult>;
|
|
25
|
-
/**
|
|
28
|
+
/**
|
|
29
|
+
* Optional: prompt templates the remote provides (e.g. MCP prompts). Do not implement when
|
|
30
|
+
* unsupported; the kernel must check for absence.
|
|
31
|
+
*/
|
|
26
32
|
listPrompts?(): Promise<PromptInfo[]>;
|
|
27
|
-
/**
|
|
33
|
+
/**
|
|
34
|
+
* Optional: renders a prompt template with arguments and returns messages (e.g. MCP
|
|
35
|
+
* `prompts/get`). On failure throw ToolError (English, no credentials).
|
|
36
|
+
*/
|
|
28
37
|
getPrompt?(name: string, args: Record<string, string>): Promise<RenderedPrompt>;
|
|
29
38
|
close(): Promise<void>;
|
|
30
39
|
}
|
|
31
|
-
/**
|
|
40
|
+
/** A remote prompt template (the `/connector:promptName` slash command). */
|
|
32
41
|
export interface PromptInfo {
|
|
33
42
|
name: string;
|
|
34
43
|
title?: string;
|
|
@@ -39,7 +48,10 @@ export interface PromptInfo {
|
|
|
39
48
|
required?: boolean;
|
|
40
49
|
}[];
|
|
41
50
|
}
|
|
42
|
-
/**
|
|
51
|
+
/**
|
|
52
|
+
* A rendered prompt: messages in order, content blocks the same as tool results (non-text gets a
|
|
53
|
+
* type description).
|
|
54
|
+
*/
|
|
43
55
|
export interface RenderedPrompt {
|
|
44
56
|
description?: string;
|
|
45
57
|
messages: {
|
|
@@ -48,9 +60,11 @@ export interface RenderedPrompt {
|
|
|
48
60
|
}[];
|
|
49
61
|
}
|
|
50
62
|
/**
|
|
51
|
-
*
|
|
52
|
-
* - `form
|
|
53
|
-
*
|
|
63
|
+
* The remote asks the user for input in the middle of a call (MCP `elicitation/create`):
|
|
64
|
+
* - `form`: `requestedSchema` is the flat JSON Schema the remote gives (object + primitive-typed
|
|
65
|
+
* properties), which the kernel maps to an interactive form;
|
|
66
|
+
* - `url`: asks the user to open `url` in a browser to complete a step (authorization, payment,
|
|
67
|
+
* entering sensitive information); the user confirms whether it was completed.
|
|
54
68
|
*/
|
|
55
69
|
export type ElicitationRequest = {
|
|
56
70
|
mode: "form";
|
|
@@ -62,7 +76,10 @@ export type ElicitationRequest = {
|
|
|
62
76
|
url: string;
|
|
63
77
|
elicitationId: string;
|
|
64
78
|
};
|
|
65
|
-
/**
|
|
79
|
+
/**
|
|
80
|
+
* The reply to an elicitation (corresponds to MCP `ElicitResult`): accept (with form content) /
|
|
81
|
+
* decline / cancel.
|
|
82
|
+
*/
|
|
66
83
|
export type ElicitationResponse = {
|
|
67
84
|
action: "accept";
|
|
68
85
|
content?: FormAnswer;
|
|
@@ -71,18 +88,26 @@ export type ElicitationResponse = {
|
|
|
71
88
|
} | {
|
|
72
89
|
action: "cancel";
|
|
73
90
|
};
|
|
74
|
-
/**
|
|
91
|
+
/** Parameters the kernel passes to the connector when it opens a session. */
|
|
75
92
|
export interface ConnectorOpenArgs {
|
|
76
|
-
/**
|
|
93
|
+
/** Already validated against endpointSchema. */
|
|
77
94
|
endpoint: unknown;
|
|
78
|
-
/**
|
|
95
|
+
/** Called before every request; refreshing credentials is the kernel's job. */
|
|
79
96
|
auth: () => Promise<AuthInjection>;
|
|
80
|
-
/**
|
|
97
|
+
/** Called once on a 401; after the kernel refreshes credentials the plugin retries once. */
|
|
81
98
|
onUnauthorized: () => Promise<void>;
|
|
82
99
|
signal: AbortSignal;
|
|
83
100
|
/**
|
|
84
|
-
*
|
|
85
|
-
*
|
|
101
|
+
* The org this session serves. Pass it to `ctx.net.fetch` as `opts.orgId` for every request to
|
|
102
|
+
* the endpoint, so the org's allowed internal endpoints apply (and no other org's).
|
|
103
|
+
*/
|
|
104
|
+
orgId: string;
|
|
105
|
+
/**
|
|
106
|
+
* Called when the remote reports during the session that its tool list changed (e.g. MCP
|
|
107
|
+
* `notifications/tools/list_changed`), possibly several times; the kernel schedules one
|
|
108
|
+
* drift check from it (new / changed tools are unavailable until an admin reviews them).
|
|
109
|
+
* Optional: old kernels do not provide it, so the connector must check for absence. Do not wait
|
|
110
|
+
* for it and do not throw because of it.
|
|
86
111
|
*/
|
|
87
112
|
onToolsChanged?: () => void;
|
|
88
113
|
/**
|
|
@@ -91,17 +116,26 @@ export interface ConnectorOpenArgs {
|
|
|
91
116
|
* when the kernel does not provide it, the connector does not declare the MCP elicitation
|
|
92
117
|
* capability (so the remote never starts one).
|
|
93
118
|
*
|
|
94
|
-
*
|
|
95
|
-
*
|
|
96
|
-
*
|
|
97
|
-
*
|
|
119
|
+
* The kernel cannot hold a remote call while waiting for the user to answer (the run pauses, the
|
|
120
|
+
* worker is released, the session closes): when the user must be asked, the kernel **aborts this
|
|
121
|
+
* call**
|
|
122
|
+
* (via the `callTool` signal) and puts the run into waiting; after the user answers the kernel
|
|
123
|
+
* issues the same call again, and when the remote raises the same elicitation again
|
|
124
|
+
* this callback replies at once with the user's answer. So the connector only needs "call it when
|
|
125
|
+
* received, return what it gets"; do not cache or retry yourself; when the user must be asked
|
|
126
|
+
* this callback
|
|
127
|
+
* rejects with an error (the call has already been aborted), and the connector simply lets that
|
|
128
|
+
* error end this call unchanged.
|
|
98
129
|
*/
|
|
99
130
|
onElicit?: (request: ElicitationRequest) => Promise<ElicitationResponse>;
|
|
100
131
|
}
|
|
101
132
|
/**
|
|
102
|
-
*
|
|
103
|
-
*
|
|
104
|
-
*
|
|
133
|
+
* An authentication method declared in the remote description, mapped to the shape of the kernel's
|
|
134
|
+
* connector auth (ConnectorAuth), to prefill the install wizard.
|
|
135
|
+
* `scheme` is the name in the remote description (e.g. the key of OpenAPI `securitySchemes`),
|
|
136
|
+
* `description` is given as is (may be absent).
|
|
137
|
+
* Only methods the kernel supports are listed; the rest (API keys in cookies, OpenID Connect,
|
|
138
|
+
* implicit / password flows, etc.) do not appear.
|
|
105
139
|
*/
|
|
106
140
|
export type AuthHint = {
|
|
107
141
|
scheme: string;
|
|
@@ -124,31 +158,39 @@ export type AuthHint = {
|
|
|
124
158
|
tokenUrl: string;
|
|
125
159
|
scopes: string[];
|
|
126
160
|
});
|
|
127
|
-
/**
|
|
161
|
+
/**
|
|
162
|
+
* An operation in the remote description (e.g. an OpenAPI operation), for the install wizard to
|
|
163
|
+
* tick.
|
|
164
|
+
*/
|
|
128
165
|
export interface ConnectorOperation {
|
|
129
|
-
/**
|
|
166
|
+
/** The id used for ticking in the endpoint config (e.g. OpenAPI's operationId). */
|
|
130
167
|
id: string;
|
|
131
|
-
/**
|
|
168
|
+
/** Uppercase HTTP method. */
|
|
132
169
|
method: string;
|
|
133
170
|
path: string;
|
|
134
171
|
summary?: string;
|
|
135
172
|
}
|
|
136
|
-
/** `Connector.inspect
|
|
173
|
+
/** The result of `Connector.inspect`. */
|
|
137
174
|
export interface ConnectorInspection {
|
|
138
175
|
authHints: AuthHint[];
|
|
139
176
|
operations?: ConnectorOperation[];
|
|
140
177
|
}
|
|
141
|
-
/** `connector@1
|
|
178
|
+
/** `connector@1`: implemented by the plugin, called by the kernel. */
|
|
142
179
|
export interface Connector {
|
|
143
180
|
kind: string;
|
|
144
181
|
endpointSchema: ZodTypeAny;
|
|
145
182
|
open(args: ConnectorOpenArgs): Promise<ConnectorSession>;
|
|
146
183
|
/**
|
|
147
|
-
*
|
|
148
|
-
*
|
|
184
|
+
* Optional: reads the endpoint's description without credentials (for the install wizard
|
|
185
|
+
* preview), returning the declared auth methods and an optional operation list.
|
|
186
|
+
* `endpoint` is already validated against endpointSchema. On failure throw ToolError (message in
|
|
187
|
+
* English, no credentials). Old connectors do not implement it; the kernel must check for
|
|
188
|
+
* absence. `orgId` is the org the preview runs for: pass it to `ctx.net.fetch` as `opts.orgId`
|
|
189
|
+
* for every request to the endpoint, as with `ConnectorOpenArgs.orgId`.
|
|
149
190
|
*/
|
|
150
191
|
inspect?(args: {
|
|
151
192
|
endpoint: unknown;
|
|
152
193
|
signal: AbortSignal;
|
|
194
|
+
orgId: string;
|
|
153
195
|
}): Promise<ConnectorInspection>;
|
|
154
196
|
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import type { ConversationSource } from "./tool.js";
|
|
2
|
+
/**
|
|
3
|
+
* What the kernel passes to a `context@1` provider at the start of a run. The provider returns the
|
|
4
|
+
* text it wants the model to see, or null.
|
|
5
|
+
*/
|
|
6
|
+
export interface ContextRequest {
|
|
7
|
+
orgId: string;
|
|
8
|
+
/** The run's trigger account (the person whose message started the run). */
|
|
9
|
+
accountId: string;
|
|
10
|
+
agentId: string;
|
|
11
|
+
agentName: string;
|
|
12
|
+
conversationId: string;
|
|
13
|
+
runId: string;
|
|
14
|
+
/** Where the conversation comes from. */
|
|
15
|
+
source: ConversationSource;
|
|
16
|
+
/** The trigger account's role in the org. */
|
|
17
|
+
role: "owner" | "admin" | "member" | "guest";
|
|
18
|
+
/** The conversation's owner (`conversations.account_id`); `accountId` is the run's trigger account. */
|
|
19
|
+
ownerAccountId: string;
|
|
20
|
+
ownerName: string;
|
|
21
|
+
/** Keys of the tools the agent has in this run. */
|
|
22
|
+
tools: string[];
|
|
23
|
+
/** The provider's effective config for the org. */
|
|
24
|
+
config: unknown;
|
|
25
|
+
/** Aborts when the call runs past {@link CONTEXT_LIMITS}.timeoutMs or the run is aborted. */
|
|
26
|
+
signal: AbortSignal;
|
|
27
|
+
}
|
|
28
|
+
/** The text a provider adds to the model's context, or null for nothing. */
|
|
29
|
+
export type ContextResult = {
|
|
30
|
+
text: string;
|
|
31
|
+
} | null;
|
|
32
|
+
/** The `context@1` contract: an extension that adds text to the model's context at run start. */
|
|
33
|
+
export interface ContextProvider {
|
|
34
|
+
provide(req: ContextRequest): Promise<ContextResult>;
|
|
35
|
+
}
|
|
36
|
+
/** Limits on one `provide` call: the time it may take and the bytes of text the kernel keeps. */
|
|
37
|
+
export declare const CONTEXT_LIMITS: {
|
|
38
|
+
readonly timeoutMs: 2000;
|
|
39
|
+
readonly maxBytes: 32768;
|
|
40
|
+
};
|
package/dist/context.js
ADDED