@capybara-hq/plugin-sdk 0.1.0-rc.2 → 0.1.0-rc.21
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/agent-docs/agent-templates.md +59 -0
- package/agent-docs/concepts.md +63 -0
- package/agent-docs/connector-templates.md +48 -0
- package/agent-docs/extension-points/channel.md +15 -0
- package/agent-docs/extension-points/config-source.md +15 -0
- package/agent-docs/extension-points/connector.md +15 -0
- package/agent-docs/extension-points/context.md +15 -0
- package/agent-docs/extension-points/counter.md +15 -0
- package/agent-docs/extension-points/directory.md +15 -0
- package/agent-docs/extension-points/file-preview.md +15 -0
- package/agent-docs/extension-points/identity-source.md +15 -0
- package/agent-docs/extension-points/model-provider.md +15 -0
- package/agent-docs/extension-points/object-store.md +15 -0
- package/agent-docs/extension-points/sandbox.md +15 -0
- package/agent-docs/extension-points/secret-store.md +15 -0
- package/agent-docs/extension-points/web-fetch.md +15 -0
- package/agent-docs/extension-points/web-search.md +15 -0
- package/agent-docs/extensions.md +88 -0
- package/agent-docs/plugin-format.md +100 -0
- package/agent-docs/setup.md +46 -0
- package/agent-docs/skills.md +44 -0
- package/agent-docs/tool-naming.md +21 -0
- package/dist/agent-template.d.ts +96 -2
- package/dist/agent-template.js +381 -3
- package/dist/bootstrap.d.ts +15 -1
- package/dist/bootstrap.js +17 -1
- package/dist/cards.d.ts +39 -5
- package/dist/cards.js +70 -11
- package/dist/channel.d.ts +20 -1
- 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 +24 -1
- package/dist/config-ui.js +89 -11
- package/dist/connector-auth.d.ts +2 -0
- package/dist/connector-auth.js +15 -0
- package/dist/context.d.ts +40 -0
- package/dist/context.js +2 -0
- package/dist/ctx.d.ts +86 -4
- package/dist/define-extension.d.ts +5 -1
- package/dist/define-extension.js +1 -0
- package/dist/dev-hosts.d.ts +6 -0
- package/dist/dev-hosts.js +48 -0
- package/dist/device-protocol.d.ts +260 -0
- package/dist/device-protocol.js +496 -0
- package/dist/directory.d.ts +11 -2
- package/dist/extension-point.d.ts +6 -0
- package/dist/extension-point.js +19 -14
- package/dist/file-preview.d.ts +9 -1
- package/dist/git-hosts.d.ts +44 -0
- package/dist/git-hosts.js +81 -0
- package/dist/hooks.d.ts +111 -15
- package/dist/hooks.js +5 -0
- package/dist/index.d.ts +19 -1
- package/dist/index.js +19 -1
- package/dist/marketplace.d.ts +55 -2
- package/dist/marketplace.js +73 -3
- package/dist/model.d.ts +60 -2
- package/dist/model.js +22 -0
- package/dist/org-access.d.ts +27 -0
- package/dist/org-access.js +35 -0
- package/dist/permissions.d.ts +33 -8
- package/dist/permissions.js +89 -22
- package/dist/plugin-manifest.d.ts +60 -7
- package/dist/plugin-manifest.js +180 -7
- package/dist/plugin-package.d.ts +3 -0
- package/dist/plugin-package.js +4 -0
- package/dist/sandbox.d.ts +239 -62
- package/dist/sandbox.js +99 -14
- 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 +9 -5
- package/dist/skill-invocation.js +18 -8
- package/dist/skill.d.ts +23 -3
- package/dist/skill.js +31 -6
- 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 +275 -0
- package/dist/theme-tokens.generated.js +172 -0
- package/dist/theme.d.ts +152 -0
- package/dist/theme.js +392 -0
- package/dist/tool.d.ts +26 -3
- package/dist/tool.js +8 -0
- package/dist/ui-parts.d.ts +23 -0
- package/dist/ui-parts.js +337 -0
- package/dist/ui-resolve.d.ts +40 -0
- package/dist/ui-resolve.js +54 -0
- package/dist/ui-slots.d.ts +55 -0
- package/dist/ui-slots.js +247 -0
- package/dist/ui.d.ts +143 -37
- package/dist/ui.js +65 -5
- package/dist/web.d.ts +30 -5
- package/package.json +10 -2
- package/schemas/bootstrap.v1.schema.json +6 -0
- package/schemas/connector-template.v1.schema.json +35 -0
- package/schemas/marketplace.v1.schema.json +50 -0
- package/schemas/plugin.v1.schema.json +144 -7
- package/schemas/theme.v1.schema.json +225 -0
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
# Authoring: skills
|
|
2
|
+
|
|
3
|
+
A skill is a folder with a `SKILL.md` (the Agent Skills format) and any files it needs. The agent
|
|
4
|
+
sees only the skill's `name` and `description` until it loads the skill, so the description is
|
|
5
|
+
what decides when it is used.
|
|
6
|
+
|
|
7
|
+
```markdown
|
|
8
|
+
---
|
|
9
|
+
name: weekly-report
|
|
10
|
+
description: Write the weekly status report from the team's tracker. Use when asked for a weekly report or status summary.
|
|
11
|
+
---
|
|
12
|
+
|
|
13
|
+
# Weekly report
|
|
14
|
+
|
|
15
|
+
1. Read ...
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
## Frontmatter
|
|
19
|
+
|
|
20
|
+
- `name` (required): 1 to 64 characters, lowercase letters, digits and single hyphens. The skill
|
|
21
|
+
is always known by this name; its sandbox directory is `/skills/<name>/`.
|
|
22
|
+
- `description` (required): 1 to 1024 characters. Say what it does and when to use it. No XML tags.
|
|
23
|
+
- Optional: `license`, `compatibility` (at most 500 characters), `metadata`.
|
|
24
|
+
- Invocation keys (Claude Code's names):
|
|
25
|
+
- `disable-model-invocation: true`: only a person runs it, with `/name args`.
|
|
26
|
+
- `user-invocable: false`: hide it from the `/` menu (not together with the one above).
|
|
27
|
+
- `context: fork`: run it in a sub-agent.
|
|
28
|
+
- `argument-hint`, `arguments`: describe the arguments a person passes.
|
|
29
|
+
|
|
30
|
+
Other keys are ignored.
|
|
31
|
+
|
|
32
|
+
## Where skills live
|
|
33
|
+
|
|
34
|
+
- In a plugin: `skills/<name>/SKILL.md`, listed or scanned (see `plugin-format`). It becomes a
|
|
35
|
+
platform component, named `<plugin>:<name>`.
|
|
36
|
+
- In an org: created or uploaded by an org admin, or proposed by an agent and approved by a
|
|
37
|
+
person. Org skills are private to the org unless shared.
|
|
38
|
+
|
|
39
|
+
## Writing tips
|
|
40
|
+
|
|
41
|
+
- Keep `SKILL.md` short and procedural; put long reference material in separate files the skill
|
|
42
|
+
tells the agent to read.
|
|
43
|
+
- Put scripts next to the skill and tell the agent how to run them in the sandbox.
|
|
44
|
+
- Limits: 1000 files, 10 MB per file, 50 MB in total.
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
# Authoring: tool naming
|
|
2
|
+
|
|
3
|
+
The model-visible tool key grammar:
|
|
4
|
+
|
|
5
|
+
| Kind | Key | Example |
|
|
6
|
+
|---|---|---|
|
|
7
|
+
| Builtin | PascalCase, 2 to 32 letters | `Bash`, `Read`, `Skill`, `Platform` |
|
|
8
|
+
| Connector | `mcp__<slug>__<tool>` | `mcp__crm__search_accounts` |
|
|
9
|
+
| Extension | `plugin__<plugin>__<tool>` | `plugin__todo__write` |
|
|
10
|
+
|
|
11
|
+
Use these keys in `tools`, `disallowedTools` and `toolPolicies` of an agent template, and in
|
|
12
|
+
policies. Keys never contain dots.
|
|
13
|
+
|
|
14
|
+
## Writing a tool
|
|
15
|
+
|
|
16
|
+
- Describe it in English, in one or two sentences saying what it does and when to use it.
|
|
17
|
+
- Make errors actionable: say what was wrong and what to do next, not just "failed".
|
|
18
|
+
- An extension registers tools with `ctx.tools.register` and declares the permission in its
|
|
19
|
+
manifest; the kernel adds the `plugin__<plugin>__` prefix.
|
|
20
|
+
- Connector tools get their `mcp__<slug>__` prefix from the connector's slug.
|
|
21
|
+
- Tool policies are `allow`, `ask` or `deny`; a template or agent may only tighten them.
|
package/dist/agent-template.d.ts
CHANGED
|
@@ -19,8 +19,68 @@ export interface AgentTemplate {
|
|
|
19
19
|
effort?: "low" | "medium" | "high" | "xhigh" | "max";
|
|
20
20
|
/** Step limit (the kernel caps it at `runtime.maxSteps`). */
|
|
21
21
|
maxSteps?: number;
|
|
22
|
-
/** Skill names
|
|
22
|
+
/** Skill names the sub-agent is told to load with `Skill` before it starts (Claude Code's field). */
|
|
23
23
|
skills?: string[];
|
|
24
|
+
/**
|
|
25
|
+
* Skills turned off for the agent (every skill on in the org is on otherwise):
|
|
26
|
+
* `<plugin>:<name>`, `<plugin>:*` (the whole plugin, skills it gains later included) or a bare
|
|
27
|
+
* `<name>` (an org skill without a plugin).
|
|
28
|
+
*/
|
|
29
|
+
disallowedSkills?: string[];
|
|
30
|
+
/** Connectors the agent needs: a connector template of the plugin, or a described need. */
|
|
31
|
+
connectors?: AgentTemplateConnector[];
|
|
32
|
+
/** The sub-agents the agent gets in its roster. */
|
|
33
|
+
subagents?: AgentTemplateSubagents;
|
|
34
|
+
/** `provider/model`: the concrete model an org template was saved with. */
|
|
35
|
+
modelRef?: string;
|
|
36
|
+
/** The agent profile's quick actions (same shape and limits). */
|
|
37
|
+
quickActions?: AgentTemplateQuickAction[];
|
|
38
|
+
/** The agent's instruction files. */
|
|
39
|
+
instructionFiles?: AgentTemplateInstructionFile[];
|
|
40
|
+
}
|
|
41
|
+
/** A quick action of the agent profile. */
|
|
42
|
+
export interface AgentTemplateQuickAction {
|
|
43
|
+
title: string;
|
|
44
|
+
body: string;
|
|
45
|
+
}
|
|
46
|
+
/** An instruction file of the agent. */
|
|
47
|
+
export interface AgentTemplateInstructionFile {
|
|
48
|
+
name: string;
|
|
49
|
+
content: string;
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* A connector entry of a template: a connector template id (`<id>` or `<plugin>:<id>`) or a need.
|
|
53
|
+
* `policies` tighten the connector's tools by tool name (`ask` / `deny`), applied once it is bound.
|
|
54
|
+
*/
|
|
55
|
+
export type AgentTemplateConnector = {
|
|
56
|
+
template: string;
|
|
57
|
+
tools?: string[];
|
|
58
|
+
policies?: Record<string, "ask" | "deny">;
|
|
59
|
+
} | {
|
|
60
|
+
needs: {
|
|
61
|
+
protocol: "mcp" | "openapi";
|
|
62
|
+
endpoint: string;
|
|
63
|
+
tools: string[];
|
|
64
|
+
label: string;
|
|
65
|
+
};
|
|
66
|
+
policies?: Record<string, "ask" | "deny">;
|
|
67
|
+
};
|
|
68
|
+
/** A sub-agent type described inside a template. */
|
|
69
|
+
export interface AgentTemplateInlineSubagent {
|
|
70
|
+
name: string;
|
|
71
|
+
description: string;
|
|
72
|
+
instructions: string;
|
|
73
|
+
/** Tool keys allowed (an allowlist; `[]` = no tools); absent = all of the agent's tools. */
|
|
74
|
+
tools?: string[];
|
|
75
|
+
/** Skill names. */
|
|
76
|
+
skills: string[];
|
|
77
|
+
model: AgentTemplateTier;
|
|
78
|
+
}
|
|
79
|
+
export interface AgentTemplateSubagents {
|
|
80
|
+
general?: boolean;
|
|
81
|
+
/** Template types as the roster writes them (`<plugin>:<name>` or `<name>`). */
|
|
82
|
+
types?: string[];
|
|
83
|
+
inline?: AgentTemplateInlineSubagent[];
|
|
24
84
|
}
|
|
25
85
|
/** Limits of agent templates. */
|
|
26
86
|
export declare const AGENT_TEMPLATE_LIMITS: {
|
|
@@ -29,13 +89,47 @@ export declare const AGENT_TEMPLATE_LIMITS: {
|
|
|
29
89
|
readonly descriptionChars: 4096;
|
|
30
90
|
/** Templates in one plugin. */
|
|
31
91
|
readonly perPlugin: 64;
|
|
32
|
-
/**
|
|
92
|
+
/** Skills the sub-agent loads first. */
|
|
33
93
|
readonly skills: 3;
|
|
34
94
|
/** Entries of `tools` and of `disallowedTools`. */
|
|
35
95
|
readonly tools: 200;
|
|
96
|
+
/** Entries of `disallowedSkills`. */
|
|
97
|
+
readonly disallowedSkills: 64;
|
|
98
|
+
/** Entries of `connectors`. */
|
|
99
|
+
readonly connectors: 16;
|
|
100
|
+
/** `subagents.types` plus `subagents.inline`. */
|
|
101
|
+
readonly subagentTypes: 16;
|
|
102
|
+
/** Characters of one inline sub-agent's instructions. */
|
|
103
|
+
readonly inlineInstructionsChars: 100000;
|
|
104
|
+
/** Tools named by a connector entry (its `tools`, and the keys of its `policies`). */
|
|
105
|
+
readonly connectorTools: 200;
|
|
106
|
+
/** Quick actions, as the agent profile limits them. */
|
|
107
|
+
readonly quickActions: 9;
|
|
108
|
+
readonly quickActionTitleChars: 40;
|
|
109
|
+
readonly quickActionBodyChars: 20000;
|
|
110
|
+
/** Instruction files and their joined size, as the agent limits them. */
|
|
111
|
+
readonly instructionFiles: 20;
|
|
112
|
+
readonly instructionFilesChars: 100000;
|
|
36
113
|
};
|
|
114
|
+
/** One frontmatter key of an agent template, for documentation (served to agents by `Platform`). */
|
|
115
|
+
export interface AgentTemplateField {
|
|
116
|
+
name: string;
|
|
117
|
+
type: string;
|
|
118
|
+
required: boolean;
|
|
119
|
+
/** What it does, with its limit. */
|
|
120
|
+
description: string;
|
|
121
|
+
}
|
|
122
|
+
/** The frontmatter keys `parseAgentTemplate` reads (the body is the instructions). */
|
|
123
|
+
export declare const AGENT_TEMPLATE_FIELDS: readonly AgentTemplateField[];
|
|
37
124
|
/** The name rule of a template (the catalog item name rule). */
|
|
38
125
|
export declare const AGENT_TEMPLATE_NAME_RE: RegExp;
|
|
126
|
+
/**
|
|
127
|
+
* A `disallowedSkills` entry: `<plugin>:<name>`, `<plugin>:*` (the whole plugin) or a bare skill
|
|
128
|
+
* `<name>` (an org skill without a plugin).
|
|
129
|
+
*/
|
|
130
|
+
export declare function isDisallowedSkillRef(v: unknown): v is string;
|
|
131
|
+
/** The name rule of an instruction file (the agent's rule, mirrored). */
|
|
132
|
+
export declare const AGENT_TEMPLATE_INSTRUCTION_FILE_NAME_RE: RegExp;
|
|
39
133
|
/**
|
|
40
134
|
* Parses an agent template file. Returns the template, or every problem found (English, for the
|
|
41
135
|
* plugin author or an admin). Keys the format does not define are ignored. Never throws.
|
package/dist/agent-template.js
CHANGED
|
@@ -13,18 +13,149 @@ export const AGENT_TEMPLATE_LIMITS = {
|
|
|
13
13
|
descriptionChars: 4096,
|
|
14
14
|
/** Templates in one plugin. */
|
|
15
15
|
perPlugin: 64,
|
|
16
|
-
/**
|
|
16
|
+
/** Skills the sub-agent loads first. */
|
|
17
17
|
skills: 3,
|
|
18
18
|
/** Entries of `tools` and of `disallowedTools`. */
|
|
19
19
|
tools: 200,
|
|
20
|
+
/** Entries of `disallowedSkills`. */
|
|
21
|
+
disallowedSkills: 64,
|
|
22
|
+
/** Entries of `connectors`. */
|
|
23
|
+
connectors: 16,
|
|
24
|
+
/** `subagents.types` plus `subagents.inline`. */
|
|
25
|
+
subagentTypes: 16,
|
|
26
|
+
/** Characters of one inline sub-agent's instructions. */
|
|
27
|
+
inlineInstructionsChars: 100_000,
|
|
28
|
+
/** Tools named by a connector entry (its `tools`, and the keys of its `policies`). */
|
|
29
|
+
connectorTools: 200,
|
|
30
|
+
/** Quick actions, as the agent profile limits them. */
|
|
31
|
+
quickActions: 9,
|
|
32
|
+
quickActionTitleChars: 40,
|
|
33
|
+
quickActionBodyChars: 20_000,
|
|
34
|
+
/** Instruction files and their joined size, as the agent limits them. */
|
|
35
|
+
instructionFiles: 20,
|
|
36
|
+
instructionFilesChars: 100_000,
|
|
20
37
|
};
|
|
38
|
+
/** The frontmatter keys `parseAgentTemplate` reads (the body is the instructions). */
|
|
39
|
+
export const AGENT_TEMPLATE_FIELDS = [
|
|
40
|
+
{
|
|
41
|
+
name: "name",
|
|
42
|
+
type: "string",
|
|
43
|
+
required: true,
|
|
44
|
+
description: "`^[a-z0-9][a-z0-9-]{0,63}$`; the type name is `<plugin>:<name>`.",
|
|
45
|
+
},
|
|
46
|
+
{
|
|
47
|
+
name: "description",
|
|
48
|
+
type: "string",
|
|
49
|
+
required: true,
|
|
50
|
+
description: "When to use it; at most 4096 characters.",
|
|
51
|
+
},
|
|
52
|
+
{
|
|
53
|
+
name: "tools",
|
|
54
|
+
type: "array of tool keys",
|
|
55
|
+
required: false,
|
|
56
|
+
description: "Allowlist (at most 200); omitted = the parent's tools, `[]` = none.",
|
|
57
|
+
},
|
|
58
|
+
{
|
|
59
|
+
name: "disallowedTools",
|
|
60
|
+
type: "array of tool keys",
|
|
61
|
+
required: false,
|
|
62
|
+
description: "Tool keys removed (at most 200).",
|
|
63
|
+
},
|
|
64
|
+
{
|
|
65
|
+
name: "toolPolicies",
|
|
66
|
+
type: "object",
|
|
67
|
+
required: false,
|
|
68
|
+
description: "Tool key to `ask` or `deny`; can only tighten.",
|
|
69
|
+
},
|
|
70
|
+
{
|
|
71
|
+
name: "model",
|
|
72
|
+
type: "`inherit` \\| `fast` \\| `standard` \\| `capable`",
|
|
73
|
+
required: false,
|
|
74
|
+
description: "A purpose tier, never a model id; default `inherit`.",
|
|
75
|
+
},
|
|
76
|
+
{
|
|
77
|
+
name: "effort",
|
|
78
|
+
type: "`low` \\| `medium` \\| `high` \\| `xhigh` \\| `max`",
|
|
79
|
+
required: false,
|
|
80
|
+
description: "Reasoning effort.",
|
|
81
|
+
},
|
|
82
|
+
{
|
|
83
|
+
name: "maxSteps",
|
|
84
|
+
type: "integer",
|
|
85
|
+
required: false,
|
|
86
|
+
description: "Step limit; the kernel caps it.",
|
|
87
|
+
},
|
|
88
|
+
{
|
|
89
|
+
name: "skills",
|
|
90
|
+
type: "array of skill names",
|
|
91
|
+
required: false,
|
|
92
|
+
description: "At most 3; the sub-agent is told to load them with `Skill` before it starts.",
|
|
93
|
+
},
|
|
94
|
+
{
|
|
95
|
+
name: "disallowedSkills",
|
|
96
|
+
type: "array of skill references",
|
|
97
|
+
required: false,
|
|
98
|
+
description: "At most 64 skills turned off (all others on in the org are on): `<plugin>:<name>`, `<plugin>:*` (the whole plugin, later skills included) or a bare `<name>` (an org skill without a plugin).",
|
|
99
|
+
},
|
|
100
|
+
{
|
|
101
|
+
name: "connectors",
|
|
102
|
+
type: "array of objects",
|
|
103
|
+
required: false,
|
|
104
|
+
description: "At most 16: `{ template, tools?, policies? }` for a connector template (`<id>` or `<plugin>:<id>`), or `{ needs: { protocol, endpoint, tools, label }, policies? }` for a described need.",
|
|
105
|
+
},
|
|
106
|
+
{
|
|
107
|
+
name: "subagents",
|
|
108
|
+
type: "object",
|
|
109
|
+
required: false,
|
|
110
|
+
description: "`{ general?, types?, inline? }`: the sub-agents in its roster (at most 16 types plus inline).",
|
|
111
|
+
},
|
|
112
|
+
{
|
|
113
|
+
name: "modelRef",
|
|
114
|
+
type: "string",
|
|
115
|
+
required: false,
|
|
116
|
+
description: "`provider/model`; set on org templates saved from an agent.",
|
|
117
|
+
},
|
|
118
|
+
{
|
|
119
|
+
name: "quickActions",
|
|
120
|
+
type: "array of objects",
|
|
121
|
+
required: false,
|
|
122
|
+
description: "At most 9 `{ title, body }` shortcuts.",
|
|
123
|
+
},
|
|
124
|
+
{
|
|
125
|
+
name: "instructionFiles",
|
|
126
|
+
type: "array of objects",
|
|
127
|
+
required: false,
|
|
128
|
+
description: "At most 20 `{ name, content }` files.",
|
|
129
|
+
},
|
|
130
|
+
];
|
|
21
131
|
/** The name rule of a template (the catalog item name rule). */
|
|
22
132
|
export const AGENT_TEMPLATE_NAME_RE = /^[a-z0-9][a-z0-9-]{0,63}$/;
|
|
23
133
|
const TIERS = ["inherit", "fast", "standard", "capable"];
|
|
24
134
|
const EFFORTS = ["low", "medium", "high", "xhigh", "max"];
|
|
25
|
-
|
|
135
|
+
/** Room for sub-agents described inline (up to 16 x 100 000 characters of instructions, P4-1). */
|
|
136
|
+
const FRONTMATTER_MAX_CHARS = 2 * 1024 * 1024;
|
|
26
137
|
/** The kernel's tool key rule (model-visible keys): no dots, no whitespace, at most 64 chars. */
|
|
27
138
|
const TOOL_KEY_RE = /^[a-zA-Z0-9_-]{1,64}$/;
|
|
139
|
+
const distinct = (v) => new Set(v).size === v.length;
|
|
140
|
+
const NAME_REF_RE = /^[a-z0-9][a-z0-9-]{0,63}(:[a-z0-9][a-z0-9-]{0,63})?$/;
|
|
141
|
+
const MODEL_REF_RE = /^[^/\s]+\/\S+$/;
|
|
142
|
+
const PLUGIN_REF_RE = /^[a-z0-9][a-z0-9-]{0,63}$/;
|
|
143
|
+
/**
|
|
144
|
+
* A `disallowedSkills` entry: `<plugin>:<name>`, `<plugin>:*` (the whole plugin) or a bare skill
|
|
145
|
+
* `<name>` (an org skill without a plugin).
|
|
146
|
+
*/
|
|
147
|
+
export function isDisallowedSkillRef(v) {
|
|
148
|
+
if (typeof v !== "string")
|
|
149
|
+
return false;
|
|
150
|
+
const i = v.indexOf(":");
|
|
151
|
+
if (i < 0)
|
|
152
|
+
return isSkillName(v);
|
|
153
|
+
const plugin = v.slice(0, i);
|
|
154
|
+
const name = v.slice(i + 1);
|
|
155
|
+
return PLUGIN_REF_RE.test(plugin) && (name === "*" || isSkillName(name));
|
|
156
|
+
}
|
|
157
|
+
/** The name rule of an instruction file (the agent's rule, mirrored). */
|
|
158
|
+
export const AGENT_TEMPLATE_INSTRUCTION_FILE_NAME_RE = /^[^/\\]{1,64}\.md$/;
|
|
28
159
|
const chars = (s) => [...s].length;
|
|
29
160
|
const isToolKey = (v) => typeof v === "string" && TOOL_KEY_RE.test(v);
|
|
30
161
|
const toolList = (v) => Array.isArray(v) &&
|
|
@@ -112,12 +243,259 @@ export function parseAgentTemplate(text) {
|
|
|
112
243
|
}
|
|
113
244
|
if (fm.skills !== undefined) {
|
|
114
245
|
const s = fm.skills;
|
|
115
|
-
if (Array.isArray(s) && s.length <= L.skills && s.every(isSkillName))
|
|
246
|
+
if (Array.isArray(s) && s.length <= L.skills && s.every(isSkillName) && distinct(s))
|
|
116
247
|
out.skills = s;
|
|
117
248
|
else
|
|
118
249
|
errors.push(`skills must list at most ${L.skills} skill names`);
|
|
119
250
|
}
|
|
251
|
+
if (fm.disallowedSkills !== undefined) {
|
|
252
|
+
const s = fm.disallowedSkills;
|
|
253
|
+
if (Array.isArray(s) &&
|
|
254
|
+
s.length <= L.disallowedSkills &&
|
|
255
|
+
s.every(isDisallowedSkillRef) &&
|
|
256
|
+
distinct(s)) {
|
|
257
|
+
out.disallowedSkills = s;
|
|
258
|
+
}
|
|
259
|
+
else {
|
|
260
|
+
errors.push(`disallowedSkills must list at most ${L.disallowedSkills} distinct entries, each <plugin>:<name>, <plugin>:* or <name>`);
|
|
261
|
+
}
|
|
262
|
+
}
|
|
263
|
+
if (fm.connectors !== undefined) {
|
|
264
|
+
const c = readConnectors(fm.connectors, errors);
|
|
265
|
+
if (c)
|
|
266
|
+
out.connectors = c;
|
|
267
|
+
}
|
|
268
|
+
if (fm.subagents !== undefined) {
|
|
269
|
+
const s = readSubagents(fm.subagents, errors);
|
|
270
|
+
if (s)
|
|
271
|
+
out.subagents = s;
|
|
272
|
+
}
|
|
273
|
+
if (fm.modelRef !== undefined) {
|
|
274
|
+
if (typeof fm.modelRef === "string" &&
|
|
275
|
+
fm.modelRef.length <= 200 &&
|
|
276
|
+
MODEL_REF_RE.test(fm.modelRef)) {
|
|
277
|
+
out.modelRef = fm.modelRef;
|
|
278
|
+
}
|
|
279
|
+
else
|
|
280
|
+
errors.push("modelRef must be <provider>/<model>");
|
|
281
|
+
}
|
|
282
|
+
if (fm.quickActions !== undefined) {
|
|
283
|
+
const q = readQuickActions(fm.quickActions, errors);
|
|
284
|
+
if (q)
|
|
285
|
+
out.quickActions = q;
|
|
286
|
+
}
|
|
287
|
+
if (fm.instructionFiles !== undefined) {
|
|
288
|
+
const f = readInstructionFiles(fm.instructionFiles, errors);
|
|
289
|
+
if (f)
|
|
290
|
+
out.instructionFiles = f;
|
|
291
|
+
}
|
|
120
292
|
if (errors.length > 0)
|
|
121
293
|
return { errors };
|
|
122
294
|
return { template: out };
|
|
123
295
|
}
|
|
296
|
+
const isObj = (v) => v !== null && typeof v === "object" && !Array.isArray(v);
|
|
297
|
+
const isStr = (v, max) => typeof v === "string" && v.trim() !== "" && chars(v) <= max;
|
|
298
|
+
const strList = (v, max, itemMax) => Array.isArray(v) && v.length <= max && v.every((x) => isStr(x, itemMax));
|
|
299
|
+
const connectorPolicies = (v) => isObj(v) &&
|
|
300
|
+
Object.keys(v).length <= AGENT_TEMPLATE_LIMITS.connectorTools &&
|
|
301
|
+
Object.entries(v).every(([k, p]) => isStr(k, 128) && (p === "ask" || p === "deny"));
|
|
302
|
+
const connectorPoliciesRule = `must map at most ${AGENT_TEMPLATE_LIMITS.connectorTools} tool names to ask or deny`;
|
|
303
|
+
function readConnectors(v, errors) {
|
|
304
|
+
const L = AGENT_TEMPLATE_LIMITS;
|
|
305
|
+
if (!Array.isArray(v) || v.length > L.connectors) {
|
|
306
|
+
errors.push(`connectors must be a list of at most ${L.connectors} entries`);
|
|
307
|
+
return undefined;
|
|
308
|
+
}
|
|
309
|
+
const out = [];
|
|
310
|
+
let ok = true;
|
|
311
|
+
v.forEach((e, i) => {
|
|
312
|
+
const at = `connectors[${i}]`;
|
|
313
|
+
if (!isObj(e)) {
|
|
314
|
+
errors.push(`${at} must be { template } or { needs }`);
|
|
315
|
+
ok = false;
|
|
316
|
+
}
|
|
317
|
+
else if ("template" in e) {
|
|
318
|
+
if (typeof e.template !== "string" || !NAME_REF_RE.test(e.template)) {
|
|
319
|
+
errors.push(`${at}.template must be a connector template id (<id> or <plugin>:<id>)`);
|
|
320
|
+
ok = false;
|
|
321
|
+
}
|
|
322
|
+
else if (e.tools !== undefined && !strList(e.tools, L.connectorTools, 128)) {
|
|
323
|
+
errors.push(`${at}.tools must list at most ${L.connectorTools} tool names`);
|
|
324
|
+
ok = false;
|
|
325
|
+
}
|
|
326
|
+
else if (e.policies !== undefined && !connectorPolicies(e.policies)) {
|
|
327
|
+
errors.push(`${at}.policies ${connectorPoliciesRule}`);
|
|
328
|
+
ok = false;
|
|
329
|
+
}
|
|
330
|
+
else {
|
|
331
|
+
out.push({
|
|
332
|
+
template: e.template,
|
|
333
|
+
...(e.tools !== undefined && { tools: e.tools }),
|
|
334
|
+
...(e.policies !== undefined && {
|
|
335
|
+
policies: { ...e.policies },
|
|
336
|
+
}),
|
|
337
|
+
});
|
|
338
|
+
}
|
|
339
|
+
}
|
|
340
|
+
else if ("needs" in e) {
|
|
341
|
+
const n = e.needs;
|
|
342
|
+
if (!isObj(n)) {
|
|
343
|
+
errors.push(`${at}.needs must be an object`);
|
|
344
|
+
ok = false;
|
|
345
|
+
}
|
|
346
|
+
else if (n.protocol !== "mcp" && n.protocol !== "openapi") {
|
|
347
|
+
errors.push(`${at}.needs.protocol must be mcp or openapi`);
|
|
348
|
+
ok = false;
|
|
349
|
+
}
|
|
350
|
+
else if (!isStr(n.endpoint, 2048)) {
|
|
351
|
+
errors.push(`${at}.needs.endpoint must be a non-empty string of at most 2048 characters`);
|
|
352
|
+
ok = false;
|
|
353
|
+
}
|
|
354
|
+
else if (!strList(n.tools, L.connectorTools, 128)) {
|
|
355
|
+
errors.push(`${at}.needs.tools must list at most ${L.connectorTools} tool names`);
|
|
356
|
+
ok = false;
|
|
357
|
+
}
|
|
358
|
+
else if (!isStr(n.label, 80)) {
|
|
359
|
+
errors.push(`${at}.needs.label must be a non-empty string of at most 80 characters`);
|
|
360
|
+
ok = false;
|
|
361
|
+
}
|
|
362
|
+
else if (e.policies !== undefined && !connectorPolicies(e.policies)) {
|
|
363
|
+
errors.push(`${at}.policies ${connectorPoliciesRule}`);
|
|
364
|
+
ok = false;
|
|
365
|
+
}
|
|
366
|
+
else {
|
|
367
|
+
out.push({
|
|
368
|
+
needs: {
|
|
369
|
+
protocol: n.protocol,
|
|
370
|
+
endpoint: n.endpoint,
|
|
371
|
+
tools: n.tools,
|
|
372
|
+
label: n.label,
|
|
373
|
+
},
|
|
374
|
+
...(e.policies !== undefined && {
|
|
375
|
+
policies: { ...e.policies },
|
|
376
|
+
}),
|
|
377
|
+
});
|
|
378
|
+
}
|
|
379
|
+
}
|
|
380
|
+
else {
|
|
381
|
+
errors.push(`${at} must have template or needs`);
|
|
382
|
+
ok = false;
|
|
383
|
+
}
|
|
384
|
+
});
|
|
385
|
+
return ok ? out : undefined;
|
|
386
|
+
}
|
|
387
|
+
function readSubagents(v, errors) {
|
|
388
|
+
const L = AGENT_TEMPLATE_LIMITS;
|
|
389
|
+
if (!isObj(v)) {
|
|
390
|
+
errors.push("subagents must be an object");
|
|
391
|
+
return undefined;
|
|
392
|
+
}
|
|
393
|
+
const out = {};
|
|
394
|
+
const n0 = errors.length;
|
|
395
|
+
if (v.general !== undefined) {
|
|
396
|
+
if (typeof v.general === "boolean")
|
|
397
|
+
out.general = v.general;
|
|
398
|
+
else
|
|
399
|
+
errors.push("subagents.general must be true or false");
|
|
400
|
+
}
|
|
401
|
+
if (v.types !== undefined) {
|
|
402
|
+
if (Array.isArray(v.types) &&
|
|
403
|
+
v.types.every((t) => typeof t === "string" && NAME_REF_RE.test(t)) &&
|
|
404
|
+
distinct(v.types)) {
|
|
405
|
+
out.types = v.types;
|
|
406
|
+
}
|
|
407
|
+
else
|
|
408
|
+
errors.push("subagents.types must list sub-agent type names");
|
|
409
|
+
}
|
|
410
|
+
if (v.inline !== undefined) {
|
|
411
|
+
if (!Array.isArray(v.inline))
|
|
412
|
+
errors.push("subagents.inline must be a list");
|
|
413
|
+
else {
|
|
414
|
+
const inline = [];
|
|
415
|
+
v.inline.forEach((e, i) => {
|
|
416
|
+
const at = `subagents.inline[${i}]`;
|
|
417
|
+
if (!isObj(e)) {
|
|
418
|
+
errors.push(`${at} must be an object`);
|
|
419
|
+
return;
|
|
420
|
+
}
|
|
421
|
+
const before = errors.length;
|
|
422
|
+
if (typeof e.name !== "string" || !AGENT_TEMPLATE_NAME_RE.test(e.name)) {
|
|
423
|
+
errors.push(`${at}.name must match ^[a-z0-9][a-z0-9-]{0,63}$`);
|
|
424
|
+
}
|
|
425
|
+
if (!isStr(e.description, L.descriptionChars)) {
|
|
426
|
+
errors.push(`${at}.description must be a non-empty string of at most ${L.descriptionChars} characters`);
|
|
427
|
+
}
|
|
428
|
+
if (typeof e.instructions !== "string" ||
|
|
429
|
+
e.instructions.trim() === "" ||
|
|
430
|
+
chars(e.instructions) > L.inlineInstructionsChars) {
|
|
431
|
+
errors.push(`${at}.instructions must be a non-empty string of at most ${L.inlineInstructionsChars} characters`);
|
|
432
|
+
}
|
|
433
|
+
if (e.tools !== undefined && !toolList(e.tools)) {
|
|
434
|
+
errors.push(`${at}.tools must be ${toolListRule}`);
|
|
435
|
+
}
|
|
436
|
+
if (!(Array.isArray(e.skills) &&
|
|
437
|
+
e.skills.length <= L.skills &&
|
|
438
|
+
e.skills.every(isSkillName) &&
|
|
439
|
+
distinct(e.skills))) {
|
|
440
|
+
errors.push(`${at}.skills must list at most ${L.skills} skill names`);
|
|
441
|
+
}
|
|
442
|
+
if (!TIERS.includes(e.model)) {
|
|
443
|
+
errors.push(`${at}.model must be one of ${TIERS.join(", ")}`);
|
|
444
|
+
}
|
|
445
|
+
if (errors.length === before)
|
|
446
|
+
inline.push(e);
|
|
447
|
+
});
|
|
448
|
+
out.inline = inline;
|
|
449
|
+
}
|
|
450
|
+
}
|
|
451
|
+
if ((out.types?.length ?? 0) + (out.inline?.length ?? 0) > L.subagentTypes) {
|
|
452
|
+
errors.push(`subagents.types and subagents.inline together must be at most ${L.subagentTypes}`);
|
|
453
|
+
}
|
|
454
|
+
return errors.length === n0 ? out : undefined;
|
|
455
|
+
}
|
|
456
|
+
function readQuickActions(v, errors) {
|
|
457
|
+
const L = AGENT_TEMPLATE_LIMITS;
|
|
458
|
+
if (!Array.isArray(v) || v.length > L.quickActions) {
|
|
459
|
+
errors.push(`quickActions must be a list of at most ${L.quickActions} entries`);
|
|
460
|
+
return undefined;
|
|
461
|
+
}
|
|
462
|
+
const n0 = errors.length;
|
|
463
|
+
const out = [];
|
|
464
|
+
v.forEach((e, i) => {
|
|
465
|
+
if (isObj(e) &&
|
|
466
|
+
isStr(e.title, L.quickActionTitleChars) &&
|
|
467
|
+
isStr(e.body, L.quickActionBodyChars)) {
|
|
468
|
+
out.push({ title: e.title, body: e.body });
|
|
469
|
+
}
|
|
470
|
+
else {
|
|
471
|
+
errors.push(`quickActions[${i}] must have a title (at most ${L.quickActionTitleChars} characters) and a body (at most ${L.quickActionBodyChars})`);
|
|
472
|
+
}
|
|
473
|
+
});
|
|
474
|
+
return errors.length === n0 ? out : undefined;
|
|
475
|
+
}
|
|
476
|
+
function readInstructionFiles(v, errors) {
|
|
477
|
+
const L = AGENT_TEMPLATE_LIMITS;
|
|
478
|
+
if (!Array.isArray(v) || v.length > L.instructionFiles) {
|
|
479
|
+
errors.push(`instructionFiles must be a list of at most ${L.instructionFiles} entries`);
|
|
480
|
+
return undefined;
|
|
481
|
+
}
|
|
482
|
+
const n0 = errors.length;
|
|
483
|
+
const out = [];
|
|
484
|
+
let total = 0;
|
|
485
|
+
v.forEach((e, i) => {
|
|
486
|
+
if (isObj(e) &&
|
|
487
|
+
typeof e.name === "string" &&
|
|
488
|
+
AGENT_TEMPLATE_INSTRUCTION_FILE_NAME_RE.test(e.name) &&
|
|
489
|
+
typeof e.content === "string") {
|
|
490
|
+
total += chars(e.content);
|
|
491
|
+
out.push({ name: e.name, content: e.content });
|
|
492
|
+
}
|
|
493
|
+
else {
|
|
494
|
+
errors.push(`instructionFiles[${i}] must have a name (<name>.md) and a content string`);
|
|
495
|
+
}
|
|
496
|
+
});
|
|
497
|
+
if (errors.length === n0 && total > L.instructionFilesChars) {
|
|
498
|
+
errors.push(`instructionFiles must total at most ${L.instructionFilesChars} characters`);
|
|
499
|
+
}
|
|
500
|
+
return errors.length === n0 ? out : undefined;
|
|
501
|
+
}
|
package/dist/bootstrap.d.ts
CHANGED
|
@@ -9,11 +9,19 @@ import { z } from "zod";
|
|
|
9
9
|
* the official plugins are published: `path` is packed with `packages/plugin-tools`, which is
|
|
10
10
|
* byte-reproducible, and `integrity` is that pack's sha512).
|
|
11
11
|
*
|
|
12
|
+
* `required` and `builtin` are two different promises. A required entry is imported in the first
|
|
13
|
+
* pass, before the extensions load, and the start fails without it (so it can ship no skills or
|
|
14
|
+
* templates: those need object storage, which is not running then). A `builtin` entry is imported
|
|
15
|
+
* once the extensions have loaded (object storage available), so it may ship skills; its failure
|
|
16
|
+
* is logged and retried on the next start. Both give the plugin a builtin catalog item (scope
|
|
17
|
+
* `all`, on in every org, not switchable) and are imported again when missing. An entry is never
|
|
18
|
+
* both.
|
|
19
|
+
*
|
|
12
20
|
* Objects are strict (unknown keys rejected, `$schema` allowed): the manifest ships with core, so
|
|
13
21
|
* there is no older reader to stay compatible with and a misspelt key is a mistake. The committed
|
|
14
22
|
* JSON Schema (`schemas/bootstrap.v1.schema.json`) is generated from {@link BootstrapManifestSchema}
|
|
15
23
|
* by `pnpm gen:package-schemas`; the cross-field rules (unique names, `marketplace` required with an
|
|
16
|
-
* npm entry) are decided only by {@link parseBootstrapManifest}.
|
|
24
|
+
* npm entry, not both `required` and `builtin`) are decided only by {@link parseBootstrapManifest}.
|
|
17
25
|
*/
|
|
18
26
|
/** Manifest format version. */
|
|
19
27
|
export declare const BOOTSTRAP_MANIFEST_SCHEMA_VERSION = 1;
|
|
@@ -30,6 +38,11 @@ export type BootstrapEntry = {
|
|
|
30
38
|
integrity: string;
|
|
31
39
|
/** Enabled in every org and neither disableable nor uninstallable. */
|
|
32
40
|
required: boolean;
|
|
41
|
+
/**
|
|
42
|
+
* Builtin but not required: imported after the extensions loaded (it may ship skills), its
|
|
43
|
+
* catalog item builtin; a failure does not stop the start. Never together with `required`.
|
|
44
|
+
*/
|
|
45
|
+
builtin?: boolean;
|
|
33
46
|
} | {
|
|
34
47
|
name: string;
|
|
35
48
|
source: "workspace";
|
|
@@ -38,6 +51,7 @@ export type BootstrapEntry = {
|
|
|
38
51
|
version: string;
|
|
39
52
|
integrity: string;
|
|
40
53
|
required: boolean;
|
|
54
|
+
builtin?: boolean;
|
|
41
55
|
};
|
|
42
56
|
/** `bootstrap.json`. */
|
|
43
57
|
export interface BootstrapManifest {
|
package/dist/bootstrap.js
CHANGED
|
@@ -10,11 +10,19 @@ import { CATALOG_ITEM_NAME_RE, NPM_PACKAGE_NAME_RE, SEMVER_VERSION_RE, SHA512_IN
|
|
|
10
10
|
* the official plugins are published: `path` is packed with `packages/plugin-tools`, which is
|
|
11
11
|
* byte-reproducible, and `integrity` is that pack's sha512).
|
|
12
12
|
*
|
|
13
|
+
* `required` and `builtin` are two different promises. A required entry is imported in the first
|
|
14
|
+
* pass, before the extensions load, and the start fails without it (so it can ship no skills or
|
|
15
|
+
* templates: those need object storage, which is not running then). A `builtin` entry is imported
|
|
16
|
+
* once the extensions have loaded (object storage available), so it may ship skills; its failure
|
|
17
|
+
* is logged and retried on the next start. Both give the plugin a builtin catalog item (scope
|
|
18
|
+
* `all`, on in every org, not switchable) and are imported again when missing. An entry is never
|
|
19
|
+
* both.
|
|
20
|
+
*
|
|
13
21
|
* Objects are strict (unknown keys rejected, `$schema` allowed): the manifest ships with core, so
|
|
14
22
|
* there is no older reader to stay compatible with and a misspelt key is a mistake. The committed
|
|
15
23
|
* JSON Schema (`schemas/bootstrap.v1.schema.json`) is generated from {@link BootstrapManifestSchema}
|
|
16
24
|
* by `pnpm gen:package-schemas`; the cross-field rules (unique names, `marketplace` required with an
|
|
17
|
-
* npm entry) are decided only by {@link parseBootstrapManifest}.
|
|
25
|
+
* npm entry, not both `required` and `builtin`) are decided only by {@link parseBootstrapManifest}.
|
|
18
26
|
*/
|
|
19
27
|
/** Manifest format version. */
|
|
20
28
|
export const BOOTSTRAP_MANIFEST_SCHEMA_VERSION = 1;
|
|
@@ -35,6 +43,7 @@ const common = {
|
|
|
35
43
|
.string()
|
|
36
44
|
.regex(SHA512_INTEGRITY_RE, { message: "integrity must be sha512-<86 base64 chars>==" }),
|
|
37
45
|
required: z.boolean(),
|
|
46
|
+
builtin: z.boolean().optional(),
|
|
38
47
|
};
|
|
39
48
|
const entry = z.discriminatedUnion("source", [
|
|
40
49
|
z.strictObject({
|
|
@@ -74,6 +83,13 @@ const schema = z
|
|
|
74
83
|
});
|
|
75
84
|
}
|
|
76
85
|
seen.add(e.name);
|
|
86
|
+
if (e.required && e.builtin === true) {
|
|
87
|
+
ctx.addIssue({
|
|
88
|
+
code: "custom",
|
|
89
|
+
path: ["plugins", i, "builtin"],
|
|
90
|
+
message: "an entry is either required or builtin, not both",
|
|
91
|
+
});
|
|
92
|
+
}
|
|
77
93
|
});
|
|
78
94
|
if (m.marketplace === undefined && m.plugins.some((e) => e.source === "npm")) {
|
|
79
95
|
ctx.addIssue({
|