@capybara-hq/plugin-sdk 0.1.0-rc.3 → 0.1.0-rc.30
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.d.ts +319 -0
- package/dist/device-protocol.js +559 -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 +21 -1
- package/dist/index.js +21 -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 +15 -0
- package/dist/sandbox-linux-runtime-source.js +1421 -0
- package/dist/sandbox-native-runtime-source.d.ts +8 -0
- package/dist/sandbox-native-runtime-source.js +307 -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.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
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
#
|
|
1
|
+
# Authoring: agent templates
|
|
2
2
|
|
|
3
3
|
An agent template describes a whole agent: instructions, tools, skills, connectors and the
|
|
4
4
|
sub-agents it may dispatch. A member creates a private agent from a template; org admins can also
|
|
@@ -30,8 +30,8 @@ You are a careful researcher. ...
|
|
|
30
30
|
| `model` | `inherit` \| `fast` \| `standard` \| `capable` | no | A purpose tier, never a model id; default `inherit`. |
|
|
31
31
|
| `effort` | `low` \| `medium` \| `high` \| `xhigh` \| `max` | no | Reasoning effort. |
|
|
32
32
|
| `maxSteps` | integer | no | Step limit; the kernel caps it. |
|
|
33
|
-
| `skills` | array of skill names | no | At most 3
|
|
34
|
-
| `
|
|
33
|
+
| `skills` | array of skill names | no | At most 3; the sub-agent is told to load them with `Skill` before it starts. |
|
|
34
|
+
| `disallowedSkills` | array of skill references | no | 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). |
|
|
35
35
|
| `connectors` | array of objects | no | 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. |
|
|
36
36
|
| `subagents` | object | no | `{ general?, types?, inline? }`: the sub-agents in its roster (at most 16 types plus inline). |
|
|
37
37
|
| `modelRef` | string | no | `provider/model`; set on org templates saved from an agent. |
|
|
@@ -41,6 +41,18 @@ You are a careful researcher. ...
|
|
|
41
41
|
|
|
42
42
|
Unknown keys are ignored. The body is at most 100,000 characters.
|
|
43
43
|
|
|
44
|
+
## Skills
|
|
45
|
+
|
|
46
|
+
An agent has every skill that is on in its org; nothing is pinned into its context. A template
|
|
47
|
+
only turns skills off, with `disallowedSkills`: `<plugin>:<name>` for one skill of a plugin,
|
|
48
|
+
`<plugin>:*` for the whole plugin (skills it gains later included) or a bare `<name>` for an org
|
|
49
|
+
skill without a plugin. Saving an agent as an org template writes its off-list here.
|
|
50
|
+
|
|
51
|
+
`skills` keeps Claude Code's meaning for sub-agent use: when the template runs as a sub-agent, the
|
|
52
|
+
child is told to load these skills with `Skill` before it starts. When a member creates an agent
|
|
53
|
+
from the template, each name in `skills` (and in its sub-agents' `skills`) is reported as carried
|
|
54
|
+
or as unavailable in the org; it narrows nothing.
|
|
55
|
+
|
|
44
56
|
## Creating an agent from a template
|
|
45
57
|
|
|
46
58
|
A connector the org does not have becomes a pending entry, and a setup request goes to the org
|
package/agent-docs/concepts.md
CHANGED
|
@@ -2,6 +2,11 @@
|
|
|
2
2
|
|
|
3
3
|
Read this first. It explains the vocabulary the other topics use.
|
|
4
4
|
|
|
5
|
+
The other topics are for *authoring*: writing an extension, building a plugin, skills, templates,
|
|
6
|
+
connector templates, tool naming and extension points. To *use* the platform (install, switch on,
|
|
7
|
+
configure, manage), use the operations: `browse`, `search`, `describe` and `call`.
|
|
8
|
+
To help a person through a plugin's setup guide, read `setup` first.
|
|
9
|
+
|
|
5
10
|
## Platform and org
|
|
6
11
|
|
|
7
12
|
- The **platform** is one deployment. The **super admin** runs it: imports plugins into the
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
#
|
|
1
|
+
# Authoring: connector templates
|
|
2
2
|
|
|
3
3
|
A connector template is a ready-made connection to an external system: a protocol connector
|
|
4
4
|
(`connector-mcp`, `connector-openapi`), a preset endpoint and the auth shape. An org installs it
|
|
@@ -30,6 +30,7 @@ The file is strict. Top-level fields:
|
|
|
30
30
|
| `displayName` | object | yes |
|
|
31
31
|
| `description` | string | no |
|
|
32
32
|
| `icon` | string | no |
|
|
33
|
+
| `defaultEnabled` | boolean | no |
|
|
33
34
|
| `template` | object | yes |
|
|
34
35
|
<!-- /generated -->
|
|
35
36
|
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
# Authoring: extension point context
|
|
2
|
+
|
|
3
|
+
<!-- generated:extension-point -->
|
|
4
|
+
- Name: `context` (a ref is `context@<major>`)
|
|
5
|
+
- Adds text to the model's context at run start in conversations of orgs that enable it.
|
|
6
|
+
- Providers: several
|
|
7
|
+
- Enabled per org: yes
|
|
8
|
+
- Brokered by the platform: yes (extensions use it only through `ctx`)
|
|
9
|
+
<!-- /generated -->
|
|
10
|
+
|
|
11
|
+
Contract: ContextProvider (`context.ts`)
|
|
12
|
+
|
|
13
|
+
Return the text the model should see at the start of a run, or null. The kernel calls every provider enabled in the org once per run, only in `chat` conversations (not evals or sub-agents), with the run's source, the trigger account and its org role, the conversation owner and the tool keys. A call is limited to 2 seconds and 32 KB of text and fails open: a timeout or error adds nothing and the run goes on. The text is recorded in the conversation log only when its hash changes.
|
|
14
|
+
|
|
15
|
+
See `extensions` for the rules every extension follows.
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
#
|
|
1
|
+
# Authoring: extension point model-provider
|
|
2
2
|
|
|
3
3
|
<!-- generated:extension-point -->
|
|
4
4
|
- Name: `model-provider` (a ref is `model-provider@<major>`)
|
|
@@ -8,8 +8,10 @@
|
|
|
8
8
|
- Brokered by the platform: yes (extensions use it only through `ctx`)
|
|
9
9
|
<!-- /generated -->
|
|
10
10
|
|
|
11
|
-
Contract: ModelProvider (`model.ts`);
|
|
11
|
+
Contract: ModelProvider (`model.ts`); ref `model-provider@2`
|
|
12
12
|
|
|
13
13
|
Map the kernel's messages and tools to the vendor API and stream the result. Do not retry inside the extension; return a `ModelError` with the right kind and let the kernel degrade. History sent to the model is append-only. Declare parameters and media support.
|
|
14
14
|
|
|
15
|
+
Messages may carry an `image` or a `document` block, gated by `capabilities.vision` and `capabilities.documents`; the kernel replaces a block the model cannot take with an English placeholder and never sends the bytes. A `file` block is an attachment the model can only reference (an xlsx, say): the kernel resolves it to text before the request, so a provider never receives one. Resolve any block you do not recognize by skipping it. The `size` on an attachment block is display metadata (the UI chip, the reference line) and is never sent to a provider.
|
|
16
|
+
|
|
15
17
|
See `extensions` for the rules every extension follows.
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
#
|
|
1
|
+
# Authoring: extension point object-store
|
|
2
2
|
|
|
3
3
|
<!-- generated:extension-point -->
|
|
4
4
|
- Name: `object-store` (a ref is `object-store@<major>`)
|
|
@@ -12,4 +12,6 @@ Contract: ObjectStore (`storage.ts`)
|
|
|
12
12
|
|
|
13
13
|
Return `null` for a missing key, reject keys containing `${`, and enforce the size of presigned uploads in the store itself. The kernel adds key prefixes; extensions consume it as `ctx.storage`.
|
|
14
14
|
|
|
15
|
+
Optionally implement `uri(key)`: the store's canonical identifier for a key, such as `s3://bucket/key`. It is unsigned, stable and carries no credentials, and is never a presigned URL — the kernel may record it in an event log and show it to a model. A store with no notion of URIs simply leaves it out.
|
|
16
|
+
|
|
15
17
|
See `extensions` for the rules every extension follows.
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
#
|
|
1
|
+
# Authoring: extension point sandbox
|
|
2
2
|
|
|
3
3
|
<!-- generated:extension-point -->
|
|
4
4
|
- Name: `sandbox` (a ref is `sandbox@<major>`)
|
|
5
|
-
- Runs
|
|
5
|
+
- Runs a device's instance and keeps its files for agents' commands (Docker, E2B).
|
|
6
6
|
- Providers: one at a time
|
|
7
7
|
- Enabled per org: no
|
|
8
8
|
- Brokered by the platform: yes (extensions use it only through `ctx`)
|
|
@@ -10,6 +10,6 @@
|
|
|
10
10
|
|
|
11
11
|
Contract: SandboxProvider (`sandbox.ts`)
|
|
12
12
|
|
|
13
|
-
The kernel accepts only `sandbox@2`.
|
|
13
|
+
The kernel accepts only `sandbox@2`. A device is one instance plus a file system that outlives it. Implement the file system (`createFileSystem`, `destroyFileSystem`, `destroyFileSystemByName`), the instance on it (`create`, which throws `FileSystemGoneError` when the file system is gone instead of making an empty one; `resume`, `suspend`; `destroy` and `destroyByName`, which drop the instance and keep the files), and the instance's `exec`, `readFile`, `writeFile`, `stat`, `killAll` and `killTagged` (`concurrentExec` is required: several conversations share one instance). Aborting a command must kill it. Locking, suspension timing and destruction are the kernel's job, not yours. Never publish a docker socket proxy on a host address.
|
|
14
14
|
|
|
15
15
|
See `extensions` for the rules every extension follows.
|
package/agent-docs/extensions.md
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
#
|
|
1
|
+
# Authoring: writing an extension
|
|
2
2
|
|
|
3
3
|
An extension is TypeScript code a plugin ships. It runs in the platform's process with full
|
|
4
4
|
trust: approval by the super admin is governance, not a sandbox. It sees only the SDK's `ctx`
|
|
@@ -32,10 +32,34 @@ The platform runs several replicas, so:
|
|
|
32
32
|
and periodic work) and `ctx.bus`.
|
|
33
33
|
- Queue names and job ids contain no `:`.
|
|
34
34
|
- Migrations are plain SQL under `migrations/`, in the schema `plugin_<name>`, expand-only.
|
|
35
|
-
- Declare every capability you use (`ctx.secrets`, `ctx.storage`, `ctx.tools`, `ctx.ui`, hooks
|
|
36
|
-
in `permissions`. `capybara-plugin check`
|
|
35
|
+
- Declare every capability you use (`ctx.secrets`, `ctx.storage`, `ctx.tools`, `ctx.ui`, hooks,
|
|
36
|
+
`ctx.setup.check` ids in `permissions.setupChecks`) in `permissions`. `capybara-plugin check`
|
|
37
|
+
verifies this.
|
|
37
38
|
- Hooks observe or deny; they never rewrite.
|
|
38
39
|
|
|
40
|
+
## Setup checks
|
|
41
|
+
|
|
42
|
+
A setup guide's `::check <id> <label>` line (see `plugin-format`) runs a check of the plugin's
|
|
43
|
+
extension:
|
|
44
|
+
|
|
45
|
+
```ts
|
|
46
|
+
ctx.setup.check("bot-token", {
|
|
47
|
+
place: "channel-connection",
|
|
48
|
+
run: async ({ target, config, mode, signal }) => {
|
|
49
|
+
// one or two read calls, passing signal; return ok, failing (with reason and fix) or unknown
|
|
50
|
+
return { status: "ok", reason: { en: "The platform accepted the token." } };
|
|
51
|
+
},
|
|
52
|
+
});
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
- Register in `setup` and list each id in `permissions.setupChecks` (`^[a-z0-9][a-z0-9-]{0,47}$`).
|
|
56
|
+
- A check never writes (at the third party or in the platform), never retries, and never puts a
|
|
57
|
+
secret in its `reason` or `fix` (plain text, `{ en, zh? }`, at most 300 / 500 characters).
|
|
58
|
+
- A channel connection target carries the connection config; a connector target carries ids and a
|
|
59
|
+
manual OAuth client id, never the client secret or a member's token.
|
|
60
|
+
- The platform runs checks only when a person or an agent asks, caches results for five minutes,
|
|
61
|
+
times a run out after 10 seconds and redacts known secrets from results.
|
|
62
|
+
|
|
39
63
|
## Extension points
|
|
40
64
|
|
|
41
65
|
An extension *provides* a point (`provides`) or *consumes* one (`requires`, or `optional`). Refs
|
|
@@ -44,7 +68,7 @@ look like `channel@1`: name and major version. The registered points:
|
|
|
44
68
|
<!-- generated:extension-points -->
|
|
45
69
|
| Extension point | Providers | Per org | What it is |
|
|
46
70
|
|---|---|---|---|
|
|
47
|
-
| `sandbox` | single | no | Runs
|
|
71
|
+
| `sandbox` | single | no | Runs a device's instance and keeps its files for agents' commands (Docker, E2B). |
|
|
48
72
|
| `config-source` | single | no | Supplies deployment configuration from an external store such as Nacos. |
|
|
49
73
|
| `secret-store` | single | no | Stores and resolves secrets (connector credentials, secret config) outside the database. |
|
|
50
74
|
| `object-store` | single | no | Stores files and artifacts in S3-compatible object storage, with presigned uploads. |
|
|
@@ -56,6 +80,7 @@ look like `channel@1`: name and major version. The registered points:
|
|
|
56
80
|
| `connector` | multi | no | Speaks one protocol (MCP, OpenAPI) to external systems and exposes their tools to agents. |
|
|
57
81
|
| `file-preview` | multi | yes | Renders previews of files of given types in the conversation UI. |
|
|
58
82
|
| `web-search` | multi | yes | Searches the web for the WebSearch tool; each org picks a default provider. |
|
|
83
|
+
| `context` | multi | yes | Adds text to the model's context at run start in conversations of orgs that enable it. |
|
|
59
84
|
| `web-fetch` | multi | yes | Fetches and extracts web pages for the WebFetch tool; each org picks a default provider. |
|
|
60
85
|
<!-- /generated -->
|
|
61
86
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
#
|
|
1
|
+
# Authoring: the plugin format
|
|
2
2
|
|
|
3
3
|
A plugin is a directory, packed into a `.tgz` with `capybara-plugin pack` (the published
|
|
4
4
|
`@capybara-hq/plugin-tools`; `npx capybara-plugin check` runs the checks).
|
|
@@ -10,11 +10,12 @@ A plugin is a directory, packed into a `.tgz` with `capybara-plugin pack` (the p
|
|
|
10
10
|
skills/<name>/SKILL.md skills (scanned unless plugin.json lists them)
|
|
11
11
|
connectors/<id>.json connector templates (scanned unless listed)
|
|
12
12
|
agents/<name>.md agent templates (scanned unless listed)
|
|
13
|
+
themes/<id>.json themes (scanned unless listed)
|
|
13
14
|
src/index.ts the extension (optional; bundled by the packer)
|
|
14
15
|
migrations/*.sql, ui/** extension migrations and UI files (optional)
|
|
15
16
|
```
|
|
16
17
|
|
|
17
|
-
A plugin without `src/index.ts` is declarative: skills and
|
|
18
|
+
A plugin without `src/index.ts` is declarative: skills, templates and themes only, no code runs.
|
|
18
19
|
|
|
19
20
|
## plugin.json
|
|
20
21
|
|
|
@@ -37,6 +38,9 @@ file is strict: an unknown key is an error. Fields (agent templates are listed u
|
|
|
37
38
|
| `skills` | array of object | no |
|
|
38
39
|
| `connectorTemplates` | array of object | no |
|
|
39
40
|
| `agents` | array of object | no |
|
|
41
|
+
| `themes` | array of object | no |
|
|
42
|
+
| `setupGuides` | array of object | no |
|
|
43
|
+
| `suggestedAppearance` | object | no |
|
|
40
44
|
| `extension` | object | no |
|
|
41
45
|
<!-- /generated -->
|
|
42
46
|
|
|
@@ -47,12 +51,48 @@ Rules that the schema cannot show:
|
|
|
47
51
|
release candidates, ranges on official packages are written `^0.1.0-rc.0`.
|
|
48
52
|
- `description` is a string or `{ en, zh? }`; `displayName` is `{ zh, en }`.
|
|
49
53
|
- `icon` is a `./` path to an `.svg` or `.png` inside the plugin.
|
|
50
|
-
- `skills`, `connectorTemplates`, `agents` list paths starting with `./` that stay inside the plugin.
|
|
54
|
+
- `skills`, `connectorTemplates`, `agents`, `themes` list paths starting with `./` that stay inside the plugin.
|
|
51
55
|
Omit them to scan the default folders. Names and ids are unique within the plugin.
|
|
52
56
|
- `dependencies`: plugin name plus semver range; no self-dependency.
|
|
53
57
|
- `agents`: at most 64 templates (see `agent-templates`).
|
|
58
|
+
- `themes`: at most 10 `<id>.json` files; the id is the file's base name. A theme file is checked
|
|
59
|
+
by `parseThemeFile` (schema `https://capybarahq.com/schemas/theme.v1.schema.json`).
|
|
60
|
+
- `setupGuides` (at most 8): `{ id, place, template? }`. Each guide is a Markdown document at
|
|
61
|
+
`guides/<id>.md` (English, required) and `guides/<id>.zh.md` (Chinese, optional), shown where a
|
|
62
|
+
person sets up what the plugin brings. `place` is `channel-connection` (新建渠道 and the channel
|
|
63
|
+
detail; the extension must provide `channel@1`; one per plugin) or `connector-template`
|
|
64
|
+
(`template` names one of the plugin's `connectors/<id>.json`; one per template). See "Setup
|
|
65
|
+
guides" below.
|
|
54
66
|
- `extension` is written by the packer; never write it by hand.
|
|
55
67
|
|
|
68
|
+
## Setup guides
|
|
69
|
+
|
|
70
|
+
A guide is CommonMark + GFM:
|
|
71
|
+
|
|
72
|
+
- It starts with exactly one `# Title` (the guide's title, at most 100 characters); use `##` to
|
|
73
|
+
`####` below it.
|
|
74
|
+
- `{{name}}` variables come from the place, and none is ever a secret: everywhere `publicUrl`,
|
|
75
|
+
`orgName`, `pluginName`, `pluginVersion`, `mode`; `channel-connection` adds `webhookUrl`,
|
|
76
|
+
`signInCallbackUrl`, `connectionName`; `connector-template` adds `oauthCallbackUrl`,
|
|
77
|
+
`signInCallbackUrl`, `templateId`, `templateName`, `connectorName`. In `yaml` / `json` code put a
|
|
78
|
+
variable inside double quotes. Directive lines and fence info strings hold no variables.
|
|
79
|
+
- Sections: a line `::: mode webhook` (modes `long_connection`, `webhook`; channel guides) or
|
|
80
|
+
`::: audience member` (audiences `admin`, `member`; connector template guides) opens one, `:::`
|
|
81
|
+
closes it, both in column 0. Only a mode section may sit inside an audience section. Text outside
|
|
82
|
+
every section applies to all.
|
|
83
|
+
- Checks: a line `::check <id> <label>` is a live status row. `<id>` is one of the extension's own
|
|
84
|
+
checks (registered with `ctx.setup.check` and listed in `permissions.setupChecks`; see
|
|
85
|
+
`extensions`) or a platform check `capybara:<id>` (`public-url`, `webhook-public`,
|
|
86
|
+
`webhook-received`, `connection-active`, `oauth-client`, `connector-tools`,
|
|
87
|
+
`connector-connected`, `oauth-token-endpoint`). The label is plain text, at most 80 characters.
|
|
88
|
+
- Code fences: `<language> title="<text>"`; every block gets a copy button. Indented code blocks are
|
|
89
|
+
refused. Raw HTML shows as text, images are never loaded, and only `https:` links stay links.
|
|
90
|
+
- The zh document has the same sections, the same check ids and byte-equal code blocks.
|
|
91
|
+
- Limits: 64 KiB per document, 24 code blocks, 16 checks, 16 sections.
|
|
92
|
+
|
|
93
|
+
`capybara-plugin pack` and `check` validate the documents; `capybara-plugin guide <id> [--locale zh]
|
|
94
|
+
[--mode m] [--audience a] [--var name=value]` prints a guide as an admin will see it.
|
|
95
|
+
|
|
56
96
|
## Importing
|
|
57
97
|
|
|
58
98
|
Plugins reach a deployment through a marketplace (npm, archive, git or path sources) or a direct
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
# Helping with plugin setup
|
|
2
|
+
|
|
3
|
+
Read this before helping a person set up a channel connection or a connector from a plugin's
|
|
4
|
+
setup guide. The `setup` operations do the reading and checking; everything that needs a secret or
|
|
5
|
+
the person's own decision stays with the person on the web.
|
|
6
|
+
|
|
7
|
+
## The flow
|
|
8
|
+
|
|
9
|
+
1. **List** the guides you may help with: `call setup.guides`. Each guide has its targets (a
|
|
10
|
+
channel connection, a connector made from a template, or a template switched on without a
|
|
11
|
+
connector yet), a drift entry when the plugin changed the guide since the target was set up, a
|
|
12
|
+
count of the cached check states, and the `webPath` of the page where the person does the
|
|
13
|
+
setup. Org admins get the admin guides; members get the guides for connecting their own
|
|
14
|
+
account (audience `member`).
|
|
15
|
+
2. **Read** the guide for the target: `call setup.read` with `itemId`, `guideId` and the target
|
|
16
|
+
(`connectionId` for a channel guide, `connectorId` for a connector template guide; `audience`
|
|
17
|
+
`member` for a member guide). It returns the guide as Markdown, with each check as a
|
|
18
|
+
`- [check <id>] <label>` line, the modes (for example `long_connection` or `webhook`), the
|
|
19
|
+
variables that have no value yet with the reason, and the `webPath`.
|
|
20
|
+
3. **Explain the step the person is on**, in their language: what to open at the third-party
|
|
21
|
+
platform, what to paste there (the app manifest and URLs come from the guide), what to copy
|
|
22
|
+
back.
|
|
23
|
+
4. **Run a check after the person says they did a step**: `call setup.check` with the check id
|
|
24
|
+
from the guide. A fresh cached result comes back as is; `force: true` reruns it, at most once
|
|
25
|
+
every 10 seconds per check and target. `call setup.status` reads every check's cached state
|
|
26
|
+
without running anything.
|
|
27
|
+
5. **Explain a failing check** with its `reason` and `fix`, then wait for the person to fix it and
|
|
28
|
+
say so before running it again. `running` means another run is in progress: read the state
|
|
29
|
+
again in a moment. `unknown` means the check could not answer; its reason says why.
|
|
30
|
+
|
|
31
|
+
## What stays with the person
|
|
32
|
+
|
|
33
|
+
- **Secrets.** Bot tokens, app tokens, signing secrets and OAuth client secrets are typed by the
|
|
34
|
+
person into their fields on the `webPath` page. Never ask for a secret in the conversation and
|
|
35
|
+
never repeat one; if the person pastes one anyway, tell them to rotate it at the third-party
|
|
36
|
+
platform. The guide and the check results never contain secret values, and no setup operation
|
|
37
|
+
takes one.
|
|
38
|
+
- **Connecting a personal account** (OAuth consent) happens in the browser on the `webPath` page
|
|
39
|
+
(for a member, their connections page).
|
|
40
|
+
- **Confirming the app was updated** after a guide changed (the drift notice) is the person's
|
|
41
|
+
click on the target's page: only they know they changed the app at the third party.
|
|
42
|
+
- **Creating the app** at the third-party platform is outside Capybara: explain it, the person
|
|
43
|
+
does it.
|
|
44
|
+
|
|
45
|
+
Switching a channel connection's inbound mode is an ordinary confirmed operation
|
|
46
|
+
(`channels.update`); the person approves the card.
|
package/agent-docs/skills.md
CHANGED
package/dist/agent-template.d.ts
CHANGED
|
@@ -19,10 +19,14 @@ 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
|
-
|
|
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[];
|
|
26
30
|
/** Connectors the agent needs: a connector template of the plugin, or a described need. */
|
|
27
31
|
connectors?: AgentTemplateConnector[];
|
|
28
32
|
/** The sub-agents the agent gets in its roster. */
|
|
@@ -85,12 +89,12 @@ export declare const AGENT_TEMPLATE_LIMITS: {
|
|
|
85
89
|
readonly descriptionChars: 4096;
|
|
86
90
|
/** Templates in one plugin. */
|
|
87
91
|
readonly perPlugin: 64;
|
|
88
|
-
/**
|
|
92
|
+
/** Skills the sub-agent loads first. */
|
|
89
93
|
readonly skills: 3;
|
|
90
94
|
/** Entries of `tools` and of `disallowedTools`. */
|
|
91
95
|
readonly tools: 200;
|
|
92
|
-
/** Entries of `
|
|
93
|
-
readonly
|
|
96
|
+
/** Entries of `disallowedSkills`. */
|
|
97
|
+
readonly disallowedSkills: 64;
|
|
94
98
|
/** Entries of `connectors`. */
|
|
95
99
|
readonly connectors: 16;
|
|
96
100
|
/** `subagents.types` plus `subagents.inline`. */
|
|
@@ -119,6 +123,11 @@ export interface AgentTemplateField {
|
|
|
119
123
|
export declare const AGENT_TEMPLATE_FIELDS: readonly AgentTemplateField[];
|
|
120
124
|
/** The name rule of a template (the catalog item name rule). */
|
|
121
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;
|
|
122
131
|
/** The name rule of an instruction file (the agent's rule, mirrored). */
|
|
123
132
|
export declare const AGENT_TEMPLATE_INSTRUCTION_FILE_NAME_RE: RegExp;
|
|
124
133
|
/**
|
package/dist/agent-template.js
CHANGED
|
@@ -13,12 +13,12 @@ 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 `
|
|
21
|
-
|
|
20
|
+
/** Entries of `disallowedSkills`. */
|
|
21
|
+
disallowedSkills: 64,
|
|
22
22
|
/** Entries of `connectors`. */
|
|
23
23
|
connectors: 16,
|
|
24
24
|
/** `subagents.types` plus `subagents.inline`. */
|
|
@@ -89,13 +89,13 @@ export const AGENT_TEMPLATE_FIELDS = [
|
|
|
89
89
|
name: "skills",
|
|
90
90
|
type: "array of skill names",
|
|
91
91
|
required: false,
|
|
92
|
-
description: "At most 3
|
|
92
|
+
description: "At most 3; the sub-agent is told to load them with `Skill` before it starts.",
|
|
93
93
|
},
|
|
94
94
|
{
|
|
95
|
-
name: "
|
|
96
|
-
type: "array of skill
|
|
95
|
+
name: "disallowedSkills",
|
|
96
|
+
type: "array of skill references",
|
|
97
97
|
required: false,
|
|
98
|
-
description: "At most
|
|
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
99
|
},
|
|
100
100
|
{
|
|
101
101
|
name: "connectors",
|
|
@@ -139,6 +139,21 @@ const TOOL_KEY_RE = /^[a-zA-Z0-9_-]{1,64}$/;
|
|
|
139
139
|
const distinct = (v) => new Set(v).size === v.length;
|
|
140
140
|
const NAME_REF_RE = /^[a-z0-9][a-z0-9-]{0,63}(:[a-z0-9][a-z0-9-]{0,63})?$/;
|
|
141
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
|
+
}
|
|
142
157
|
/** The name rule of an instruction file (the agent's rule, mirrored). */
|
|
143
158
|
export const AGENT_TEMPLATE_INSTRUCTION_FILE_NAME_RE = /^[^/\\]{1,64}\.md$/;
|
|
144
159
|
const chars = (s) => [...s].length;
|
|
@@ -233,13 +248,17 @@ export function parseAgentTemplate(text) {
|
|
|
233
248
|
else
|
|
234
249
|
errors.push(`skills must list at most ${L.skills} skill names`);
|
|
235
250
|
}
|
|
236
|
-
if (fm.
|
|
237
|
-
const s = fm.
|
|
238
|
-
if (Array.isArray(s) &&
|
|
239
|
-
|
|
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>`);
|
|
240
261
|
}
|
|
241
|
-
else
|
|
242
|
-
errors.push(`selectedSkills must list at most ${L.selectedSkills} skill names`);
|
|
243
262
|
}
|
|
244
263
|
if (fm.connectors !== undefined) {
|
|
245
264
|
const c = readConnectors(fm.connectors, errors);
|
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({
|