@capybara-hq/plugin-sdk 0.1.0-rc.1 → 0.1.0-rc.3
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 +47 -0
- package/agent-docs/concepts.md +58 -0
- package/agent-docs/connector-templates.md +47 -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/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 +63 -0
- package/agent-docs/plugin-format.md +60 -0
- package/agent-docs/skills.md +44 -0
- package/agent-docs/tool-naming.md +21 -0
- package/dist/agent-template.d.ts +85 -0
- package/dist/agent-template.js +361 -2
- package/dist/config-ui.d.ts +131 -0
- package/dist/config-ui.js +602 -0
- package/dist/ctx.d.ts +3 -1
- package/dist/directory.d.ts +11 -2
- package/dist/extension-point.d.ts +9 -0
- package/dist/extension-point.js +17 -12
- package/dist/file-preview.d.ts +8 -0
- package/dist/hooks.d.ts +14 -4
- package/dist/index.d.ts +4 -1
- package/dist/index.js +4 -1
- package/dist/marketplace.d.ts +29 -2
- package/dist/marketplace.js +30 -2
- package/dist/org-access.d.ts +27 -0
- package/dist/org-access.js +35 -0
- package/dist/plugin-manifest.d.ts +25 -2
- package/dist/plugin-manifest.js +20 -1
- package/dist/sandbox.d.ts +140 -60
- package/dist/sandbox.js +30 -6
- package/dist/secret.d.ts +4 -1
- package/dist/secret.js +5 -2
- package/dist/skill-invocation.d.ts +8 -5
- package/dist/skill-invocation.js +17 -8
- package/dist/skill.d.ts +20 -3
- package/dist/skill.js +28 -6
- package/dist/tool.d.ts +8 -0
- package/dist/ui.d.ts +8 -0
- package/dist/web.d.ts +105 -0
- package/dist/web.js +135 -0
- package/package.json +4 -2
- package/schemas/marketplace.v1.schema.json +36 -0
- package/schemas/plugin.v1.schema.json +49 -4
package/README.md
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
# @capybara-hq/plugin-sdk
|
|
2
2
|
|
|
3
3
|
The SDK for writing plugins for [Capybara](https://github.com/capybara-hq/core), an open-source enterprise agent platform. It holds
|
|
4
|
-
the types, extension point contracts (`model-provider@2`, `channel@1`, `connector@1`, `sandbox@
|
|
4
|
+
the types, extension point contracts (`model-provider@2`, `channel@1`, `connector@1`, `sandbox@2`,
|
|
5
5
|
`object-store@1` and others) and pure functions that a plugin's extension is written against, and the
|
|
6
6
|
package formats: the plugin manifest `.capybara-plugin/plugin.json` (`parsePluginManifest`),
|
|
7
7
|
connector template files `connectors/<id>.json` (`parseConnectorTemplateFile`) and the marketplace
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
# Agent templates
|
|
2
|
+
|
|
3
|
+
An agent template describes a whole agent: instructions, tools, skills, connectors and the
|
|
4
|
+
sub-agents it may dispatch. A member creates a private agent from a template; org admins can also
|
|
5
|
+
save an agent as an org template. A plugin ships templates as `agents/<name>.md`: Markdown with
|
|
6
|
+
YAML frontmatter, the body being the instructions.
|
|
7
|
+
|
|
8
|
+
```markdown
|
|
9
|
+
---
|
|
10
|
+
name: researcher
|
|
11
|
+
description: Finds and summarizes sources on a topic. Use for open-ended research.
|
|
12
|
+
model: standard
|
|
13
|
+
tools: [WebSearch, WebFetch, Read]
|
|
14
|
+
skills: [citation-style]
|
|
15
|
+
---
|
|
16
|
+
|
|
17
|
+
You are a careful researcher. ...
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
## Frontmatter
|
|
21
|
+
|
|
22
|
+
<!-- generated:agent-template -->
|
|
23
|
+
| Field | Type | Required | Meaning |
|
|
24
|
+
|---|---|---|---|
|
|
25
|
+
| `name` | string | yes | `^[a-z0-9][a-z0-9-]{0,63}$`; the type name is `<plugin>:<name>`. |
|
|
26
|
+
| `description` | string | yes | When to use it; at most 4096 characters. |
|
|
27
|
+
| `tools` | array of tool keys | no | Allowlist (at most 200); omitted = the parent's tools, `[]` = none. |
|
|
28
|
+
| `disallowedTools` | array of tool keys | no | Tool keys removed (at most 200). |
|
|
29
|
+
| `toolPolicies` | object | no | Tool key to `ask` or `deny`; can only tighten. |
|
|
30
|
+
| `model` | `inherit` \| `fast` \| `standard` \| `capable` | no | A purpose tier, never a model id; default `inherit`. |
|
|
31
|
+
| `effort` | `low` \| `medium` \| `high` \| `xhigh` \| `max` | no | Reasoning effort. |
|
|
32
|
+
| `maxSteps` | integer | no | Step limit; the kernel caps it. |
|
|
33
|
+
| `skills` | array of skill names | no | At most 3, preloaded (pinned). |
|
|
34
|
+
| `selectedSkills` | array of skill names | no | At most 32 further skills the agent may use. |
|
|
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
|
+
| `subagents` | object | no | `{ general?, types?, inline? }`: the sub-agents in its roster (at most 16 types plus inline). |
|
|
37
|
+
| `modelRef` | string | no | `provider/model`; set on org templates saved from an agent. |
|
|
38
|
+
| `quickActions` | array of objects | no | At most 9 `{ title, body }` shortcuts. |
|
|
39
|
+
| `instructionFiles` | array of objects | no | At most 20 `{ name, content }` files. |
|
|
40
|
+
<!-- /generated -->
|
|
41
|
+
|
|
42
|
+
Unknown keys are ignored. The body is at most 100,000 characters.
|
|
43
|
+
|
|
44
|
+
## Creating an agent from a template
|
|
45
|
+
|
|
46
|
+
A connector the org does not have becomes a pending entry, and a setup request goes to the org
|
|
47
|
+
admins. Tool keys follow `tool-naming`.
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
# Platform concepts
|
|
2
|
+
|
|
3
|
+
Read this first. It explains the vocabulary the other topics use.
|
|
4
|
+
|
|
5
|
+
## Platform and org
|
|
6
|
+
|
|
7
|
+
- The **platform** is one deployment. The **super admin** runs it: imports plugins into the
|
|
8
|
+
**catalog**, decides where each item is on, and configures deployment-wide extensions.
|
|
9
|
+
- An **org** is a tenant of the platform. An org sees the platform items that are on in it, plus
|
|
10
|
+
the items it owns. **Org admins** manage their org; **members** use it.
|
|
11
|
+
- Everything you do through the `Platform` tool acts as the person who started the run. You never
|
|
12
|
+
have more rights than that person, and role, membership and super admin status are re-read on
|
|
13
|
+
every call.
|
|
14
|
+
|
|
15
|
+
## Plugins, extensions, skills, templates
|
|
16
|
+
|
|
17
|
+
- A **plugin** is the install and distribution unit: an optional extension, skills, connector
|
|
18
|
+
templates and agent templates (see `plugin-format`).
|
|
19
|
+
- An **extension** is the in-process code inside a plugin (see `extensions`). Most
|
|
20
|
+
contributions need no code: a plugin with only skills or templates is *declarative*.
|
|
21
|
+
- A **skill** is instructions the agent loads on demand (`skills`). An **agent template**
|
|
22
|
+
describes a whole agent (`agent-templates`). A **connector template** is a ready-made
|
|
23
|
+
connection to an external system (`connector-templates`).
|
|
24
|
+
- An **extension point** is a versioned contract (`channel@1`) an extension provides or consumes.
|
|
25
|
+
|
|
26
|
+
## Scope
|
|
27
|
+
|
|
28
|
+
Every platform item (plugin, and its skills and templates) has a scope:
|
|
29
|
+
|
|
30
|
+
| Scope | Meaning |
|
|
31
|
+
|---|---|
|
|
32
|
+
| `all` | On in every org. Org admins cannot switch it. |
|
|
33
|
+
| `optional` | Off until an org admin switches it on. The default for new imports. |
|
|
34
|
+
| `named` | On in the listed orgs only; invisible to other orgs unless shown to them. |
|
|
35
|
+
|
|
36
|
+
Skills, agent templates and connector templates of a platform plugin are platform components: one
|
|
37
|
+
version per deployment, never copied into orgs.
|
|
38
|
+
|
|
39
|
+
## Owner and shareable
|
|
40
|
+
|
|
41
|
+
An item has an owner: the platform (no owner org) or one org. An org-owned item reaches another org
|
|
42
|
+
only if its owner marked it `shareable` and the platform then shows or scopes it there.
|
|
43
|
+
|
|
44
|
+
## Requests
|
|
45
|
+
|
|
46
|
+
When a person cannot do something themselves (install a plugin that is not on in their org,
|
|
47
|
+
approve extension permissions), they file a **request**. Org admins or the super admin decide it
|
|
48
|
+
on the web. Agents can file requests but never decide them.
|
|
49
|
+
|
|
50
|
+
## Sandbox
|
|
51
|
+
|
|
52
|
+
Agents run commands and keep files in a **sandbox**, one per conversation. Skills are mounted
|
|
53
|
+
read-only under `/skills/<name>/`. Sandbox limits and network egress are set per org by admins.
|
|
54
|
+
|
|
55
|
+
## What agents may not do
|
|
56
|
+
|
|
57
|
+
Deciding approvals and requests, confirming extension permissions, managing tokens and secrets,
|
|
58
|
+
changing roles. Operations that need credentials refuse and point to the web page.
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
# Connector templates
|
|
2
|
+
|
|
3
|
+
A connector template is a ready-made connection to an external system: a protocol connector
|
|
4
|
+
(`connector-mcp`, `connector-openapi`), a preset endpoint and the auth shape. An org installs it
|
|
5
|
+
and fills in only the credential. Templates live in a plugin as `connectors/<id>.json`; the id is
|
|
6
|
+
the file's base name.
|
|
7
|
+
|
|
8
|
+
```json
|
|
9
|
+
{
|
|
10
|
+
"$schema": "https://capybarahq.com/schemas/connector-template.v1.schema.json",
|
|
11
|
+
"displayName": { "zh": "Acme CRM", "en": "Acme CRM" },
|
|
12
|
+
"description": "Acme CRM over MCP",
|
|
13
|
+
"template": {
|
|
14
|
+
"plugin": "connector-mcp",
|
|
15
|
+
"pluginVersion": "^0.1.0-rc.0",
|
|
16
|
+
"connector": "mcp",
|
|
17
|
+
"endpoint": { "url": "https://mcp.acme.example/mcp" },
|
|
18
|
+
"editableEndpoint": ["url"],
|
|
19
|
+
"auth": { "type": "bearer", "ownership": "org" },
|
|
20
|
+
"defaultToolPolicies": { "search": "allow", "delete_record": "deny" }
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
The file is strict. Top-level fields:
|
|
26
|
+
|
|
27
|
+
<!-- generated:connector-template -->
|
|
28
|
+
| Field | Type | Required |
|
|
29
|
+
|---|---|---|
|
|
30
|
+
| `displayName` | object | yes |
|
|
31
|
+
| `description` | string | no |
|
|
32
|
+
| `icon` | string | no |
|
|
33
|
+
| `template` | object | yes |
|
|
34
|
+
<!-- /generated -->
|
|
35
|
+
|
|
36
|
+
Fields of `template`:
|
|
37
|
+
|
|
38
|
+
- `plugin`, `connector`: the connector extension and its kind; `pluginVersion` is a semver range.
|
|
39
|
+
- `endpoint`: the preset every org sees. **Never put credentials in it** (no `token`, `apiKey`,
|
|
40
|
+
`secret`, `password`, `authorization`, `cookie`).
|
|
41
|
+
- `editableEndpoint`: dotted endpoint paths an org may change at install (a self-hosted URL, a
|
|
42
|
+
tenant id). List only what really differs per org.
|
|
43
|
+
- `auth`: the auth method without credentials: `none`, `bearer`, `basic`, `api_key`, `headers`,
|
|
44
|
+
`oauth_code` or `oauth_client`, plus `ownership` (`org` or per member).
|
|
45
|
+
- `defaultToolPolicies`: tool name to `allow`, `ask` or `deny`. When unsure, do not write `allow`.
|
|
46
|
+
|
|
47
|
+
Credentials and secret config are entered by people on the web page, never through an agent.
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
# Extension point: channel
|
|
2
|
+
|
|
3
|
+
<!-- generated:extension-point -->
|
|
4
|
+
- Name: `channel` (a ref is `channel@<major>`)
|
|
5
|
+
- Connects an instant-messaging platform (Slack, Lark): inbound events, replies and cards.
|
|
6
|
+
- Providers: several
|
|
7
|
+
- Enabled per org: yes
|
|
8
|
+
- Brokered by the platform: no
|
|
9
|
+
<!-- /generated -->
|
|
10
|
+
|
|
11
|
+
Contract: Channel (`channel.ts`)
|
|
12
|
+
|
|
13
|
+
Normalize inbound events (messageId, threadId, tenantId, the bot mention stripped) and acknowledge only after the kernel's `onEvent` resolves. Long connections are held only by the gateway role. Replies use the card spec (`validateChannelCard`).
|
|
14
|
+
|
|
15
|
+
See `extensions` for the rules every extension follows.
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
# Extension point: config-source
|
|
2
|
+
|
|
3
|
+
<!-- generated:extension-point -->
|
|
4
|
+
- Name: `config-source` (a ref is `config-source@<major>`)
|
|
5
|
+
- Supplies deployment configuration from an external store such as Nacos.
|
|
6
|
+
- Providers: one at a time
|
|
7
|
+
- Enabled per org: no
|
|
8
|
+
- Brokered by the platform: no
|
|
9
|
+
<!-- /generated -->
|
|
10
|
+
|
|
11
|
+
Contract: (kernel-defined; no public SDK contract yet)
|
|
12
|
+
|
|
13
|
+
Deployment config precedence is env, then file or this source, then the database, then defaults. A source must never fail startup when its content is invalid.
|
|
14
|
+
|
|
15
|
+
See `extensions` for the rules every extension follows.
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
# Extension point: connector
|
|
2
|
+
|
|
3
|
+
<!-- generated:extension-point -->
|
|
4
|
+
- Name: `connector` (a ref is `connector@<major>`)
|
|
5
|
+
- Speaks one protocol (MCP, OpenAPI) to external systems and exposes their tools to agents.
|
|
6
|
+
- Providers: several
|
|
7
|
+
- Enabled per org: no
|
|
8
|
+
- Brokered by the platform: yes (extensions use it only through `ctx`)
|
|
9
|
+
<!-- /generated -->
|
|
10
|
+
|
|
11
|
+
Contract: Connector (`connector.ts`)
|
|
12
|
+
|
|
13
|
+
Implement one protocol (`kind`): an endpoint schema, `open` and `close` per call, `auth()` before every request, and tool listing and calls. Surface failures as `ToolError` with a kind. Tools reach agents as `mcp__<slug>__<tool>`. Templates for it: see `connector-templates`. No stdio MCP.
|
|
14
|
+
|
|
15
|
+
See `extensions` for the rules every extension follows.
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
# Extension point: counter
|
|
2
|
+
|
|
3
|
+
<!-- generated:extension-point -->
|
|
4
|
+
- Name: `counter` (a ref is `counter@<major>`)
|
|
5
|
+
- Counts usage so quotas and reports can be built on it.
|
|
6
|
+
- Providers: several
|
|
7
|
+
- Enabled per org: no
|
|
8
|
+
- Brokered by the platform: no
|
|
9
|
+
<!-- /generated -->
|
|
10
|
+
|
|
11
|
+
Contract: (kernel-defined; no public SDK contract yet)
|
|
12
|
+
|
|
13
|
+
Counts usage events. Check the SDK exports before relying on it.
|
|
14
|
+
|
|
15
|
+
See `extensions` for the rules every extension follows.
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
# Extension point: directory
|
|
2
|
+
|
|
3
|
+
<!-- generated:extension-point -->
|
|
4
|
+
- Name: `directory` (a ref is `directory@<major>`)
|
|
5
|
+
- Syncs members and departments from an external company directory.
|
|
6
|
+
- Providers: several
|
|
7
|
+
- Enabled per org: yes
|
|
8
|
+
- Brokered by the platform: no
|
|
9
|
+
<!-- /generated -->
|
|
10
|
+
|
|
11
|
+
Contract: Directory (`directory.ts`)
|
|
12
|
+
|
|
13
|
+
List members and departments from a company directory so the kernel can sync them into orgs. Enabled per org.
|
|
14
|
+
|
|
15
|
+
See `extensions` for the rules every extension follows.
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
# Extension point: file-preview
|
|
2
|
+
|
|
3
|
+
<!-- generated:extension-point -->
|
|
4
|
+
- Name: `file-preview` (a ref is `file-preview@<major>`)
|
|
5
|
+
- Renders previews of files of given types in the conversation UI.
|
|
6
|
+
- Providers: several
|
|
7
|
+
- Enabled per org: yes
|
|
8
|
+
- Brokered by the platform: no
|
|
9
|
+
<!-- /generated -->
|
|
10
|
+
|
|
11
|
+
Contract: FilePreviewProvider (`file-preview.ts`)
|
|
12
|
+
|
|
13
|
+
Declare which file types you can preview and render them through schema views or an approved embed. Enabled per org.
|
|
14
|
+
|
|
15
|
+
See `extensions` for the rules every extension follows.
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
# Extension point: identity-source
|
|
2
|
+
|
|
3
|
+
<!-- generated:extension-point -->
|
|
4
|
+
- Name: `identity-source` (a ref is `identity-source@<major>`)
|
|
5
|
+
- Signs people in through an external identity provider (SSO).
|
|
6
|
+
- Providers: several
|
|
7
|
+
- Enabled per org: no
|
|
8
|
+
- Brokered by the platform: no
|
|
9
|
+
<!-- /generated -->
|
|
10
|
+
|
|
11
|
+
Contract: IdentitySource (`identity.ts`)
|
|
12
|
+
|
|
13
|
+
Provide SSO login through an external provider. The kernel owns state, nonce and PKCE checks; identities are keyed `<plugin>:<tenant>`.
|
|
14
|
+
|
|
15
|
+
See `extensions` for the rules every extension follows.
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
# Extension point: model-provider
|
|
2
|
+
|
|
3
|
+
<!-- generated:extension-point -->
|
|
4
|
+
- Name: `model-provider` (a ref is `model-provider@<major>`)
|
|
5
|
+
- Calls a model vendor's API and streams the result back to the runtime.
|
|
6
|
+
- Providers: several
|
|
7
|
+
- Enabled per org: no
|
|
8
|
+
- Brokered by the platform: yes (extensions use it only through `ctx`)
|
|
9
|
+
<!-- /generated -->
|
|
10
|
+
|
|
11
|
+
Contract: ModelProvider (`model.ts`); refs `model-provider@1` and `@2`
|
|
12
|
+
|
|
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
|
+
|
|
15
|
+
See `extensions` for the rules every extension follows.
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
# Extension point: object-store
|
|
2
|
+
|
|
3
|
+
<!-- generated:extension-point -->
|
|
4
|
+
- Name: `object-store` (a ref is `object-store@<major>`)
|
|
5
|
+
- Stores files and artifacts in S3-compatible object storage, with presigned uploads.
|
|
6
|
+
- Providers: one at a time
|
|
7
|
+
- Enabled per org: no
|
|
8
|
+
- Brokered by the platform: yes (extensions use it only through `ctx`)
|
|
9
|
+
<!-- /generated -->
|
|
10
|
+
|
|
11
|
+
Contract: ObjectStore (`storage.ts`)
|
|
12
|
+
|
|
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
|
+
|
|
15
|
+
See `extensions` for the rules every extension follows.
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
# Extension point: sandbox
|
|
2
|
+
|
|
3
|
+
<!-- generated:extension-point -->
|
|
4
|
+
- Name: `sandbox` (a ref is `sandbox@<major>`)
|
|
5
|
+
- Runs an environment's instance and keeps its files for agents' commands (Docker, E2B).
|
|
6
|
+
- Providers: one at a time
|
|
7
|
+
- Enabled per org: no
|
|
8
|
+
- Brokered by the platform: yes (extensions use it only through `ctx`)
|
|
9
|
+
<!-- /generated -->
|
|
10
|
+
|
|
11
|
+
Contract: SandboxProvider (`sandbox.ts`)
|
|
12
|
+
|
|
13
|
+
The kernel accepts only `sandbox@2`. An environment 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
|
+
|
|
15
|
+
See `extensions` for the rules every extension follows.
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
# Extension point: secret-store
|
|
2
|
+
|
|
3
|
+
<!-- generated:extension-point -->
|
|
4
|
+
- Name: `secret-store` (a ref is `secret-store@<major>`)
|
|
5
|
+
- Stores and resolves secrets (connector credentials, secret config) outside the database.
|
|
6
|
+
- Providers: one at a time
|
|
7
|
+
- Enabled per org: no
|
|
8
|
+
- Brokered by the platform: yes (extensions use it only through `ctx`)
|
|
9
|
+
<!-- /generated -->
|
|
10
|
+
|
|
11
|
+
Contract: (kernel-defined; no public SDK contract yet)
|
|
12
|
+
|
|
13
|
+
Brokered: extensions never call it directly. They use `ctx.secrets` and `secret()` config fields, and results never contain secret values.
|
|
14
|
+
|
|
15
|
+
See `extensions` for the rules every extension follows.
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
# Extension point: web-fetch
|
|
2
|
+
|
|
3
|
+
<!-- generated:extension-point -->
|
|
4
|
+
- Name: `web-fetch` (a ref is `web-fetch@<major>`)
|
|
5
|
+
- Fetches and extracts web pages for the WebFetch tool; each org picks a default provider.
|
|
6
|
+
- Providers: several; each org chooses its default
|
|
7
|
+
- Enabled per org: yes
|
|
8
|
+
- Brokered by the platform: yes (extensions use it only through `ctx`)
|
|
9
|
+
<!-- /generated -->
|
|
10
|
+
|
|
11
|
+
Contract: WebFetchProvider (`web.ts`)
|
|
12
|
+
|
|
13
|
+
Fetch a URL and return extracted page content. Admin-supplied URLs go through the kernel's network rules. Each org chooses its default provider.
|
|
14
|
+
|
|
15
|
+
See `extensions` for the rules every extension follows.
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
# Extension point: web-search
|
|
2
|
+
|
|
3
|
+
<!-- generated:extension-point -->
|
|
4
|
+
- Name: `web-search` (a ref is `web-search@<major>`)
|
|
5
|
+
- Searches the web for the WebSearch tool; each org picks a default provider.
|
|
6
|
+
- Providers: several; each org chooses its default
|
|
7
|
+
- Enabled per org: yes
|
|
8
|
+
- Brokered by the platform: yes (extensions use it only through `ctx`)
|
|
9
|
+
<!-- /generated -->
|
|
10
|
+
|
|
11
|
+
Contract: WebSearchProvider (`web.ts`)
|
|
12
|
+
|
|
13
|
+
Return ranked results for a query. Each org chooses its default provider; the kernel's WebSearch tool calls it.
|
|
14
|
+
|
|
15
|
+
See `extensions` for the rules every extension follows.
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
# Writing an extension
|
|
2
|
+
|
|
3
|
+
An extension is TypeScript code a plugin ships. It runs in the platform's process with full
|
|
4
|
+
trust: approval by the super admin is governance, not a sandbox. It sees only the SDK's `ctx`
|
|
5
|
+
(never kernel internals). Use an extension only when skills, templates and connectors cannot do
|
|
6
|
+
the job.
|
|
7
|
+
|
|
8
|
+
```ts
|
|
9
|
+
import { defineExtension } from "@capybara-hq/plugin-sdk";
|
|
10
|
+
|
|
11
|
+
export default defineExtension({
|
|
12
|
+
name: "my-plugin",
|
|
13
|
+
version: "0.1.0",
|
|
14
|
+
sdk: "^0.1.0-rc.0",
|
|
15
|
+
provides: [], // extension points it implements
|
|
16
|
+
permissions: { tools: true },
|
|
17
|
+
setup(ctx) {
|
|
18
|
+
ctx.tools.register(/* ... */);
|
|
19
|
+
},
|
|
20
|
+
});
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
The plugin's `name` equals the extension's `name`. Put code in `src/index.ts`; `capybara-plugin
|
|
24
|
+
pack` bundles it. Depend only on `@capybara-hq/plugin-sdk`, `zod` and third-party packages.
|
|
25
|
+
|
|
26
|
+
## Rules for multiple replicas
|
|
27
|
+
|
|
28
|
+
The platform runs several replicas, so:
|
|
29
|
+
|
|
30
|
+
- No timers (`setTimeout`, `setInterval`) and no module-level state (top-level `let`, `Map`,
|
|
31
|
+
`Set`, arrays). Use `ctx.db` (durable), `ctx.kv` (every write has a TTL), `ctx.queue` (delayed
|
|
32
|
+
and periodic work) and `ctx.bus`.
|
|
33
|
+
- Queue names and job ids contain no `:`.
|
|
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` verifies this.
|
|
37
|
+
- Hooks observe or deny; they never rewrite.
|
|
38
|
+
|
|
39
|
+
## Extension points
|
|
40
|
+
|
|
41
|
+
An extension *provides* a point (`provides`) or *consumes* one (`requires`, or `optional`). Refs
|
|
42
|
+
look like `channel@1`: name and major version. The registered points:
|
|
43
|
+
|
|
44
|
+
<!-- generated:extension-points -->
|
|
45
|
+
| Extension point | Providers | Per org | What it is |
|
|
46
|
+
|---|---|---|---|
|
|
47
|
+
| `sandbox` | single | no | Runs an environment's instance and keeps its files for agents' commands (Docker, E2B). |
|
|
48
|
+
| `config-source` | single | no | Supplies deployment configuration from an external store such as Nacos. |
|
|
49
|
+
| `secret-store` | single | no | Stores and resolves secrets (connector credentials, secret config) outside the database. |
|
|
50
|
+
| `object-store` | single | no | Stores files and artifacts in S3-compatible object storage, with presigned uploads. |
|
|
51
|
+
| `channel` | multi | yes | Connects an instant-messaging platform (Slack, Lark): inbound events, replies and cards. |
|
|
52
|
+
| `model-provider` | multi | no | Calls a model vendor's API and streams the result back to the runtime. |
|
|
53
|
+
| `identity-source` | multi | no | Signs people in through an external identity provider (SSO). |
|
|
54
|
+
| `directory` | multi | yes | Syncs members and departments from an external company directory. |
|
|
55
|
+
| `counter` | multi | no | Counts usage so quotas and reports can be built on it. |
|
|
56
|
+
| `connector` | multi | no | Speaks one protocol (MCP, OpenAPI) to external systems and exposes their tools to agents. |
|
|
57
|
+
| `file-preview` | multi | yes | Renders previews of files of given types in the conversation UI. |
|
|
58
|
+
| `web-search` | multi | yes | Searches the web for the WebSearch tool; each org picks a default provider. |
|
|
59
|
+
| `web-fetch` | multi | yes | Fetches and extracts web pages for the WebFetch tool; each org picks a default provider. |
|
|
60
|
+
<!-- /generated -->
|
|
61
|
+
|
|
62
|
+
Read `extension-points/<name>` for each one. Which points a deployment actually has loaded, and
|
|
63
|
+
which plugins are installed, come from `Platform` operations, not from these docs.
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
# Plugin format
|
|
2
|
+
|
|
3
|
+
A plugin is a directory, packed into a `.tgz` with `capybara-plugin pack` (the published
|
|
4
|
+
`@capybara-hq/plugin-tools`; `npx capybara-plugin check` runs the checks).
|
|
5
|
+
|
|
6
|
+
```
|
|
7
|
+
<plugin>/
|
|
8
|
+
.capybara-plugin/plugin.json the manifest (required)
|
|
9
|
+
package.json npm metadata; `version` equals plugin.json `version`
|
|
10
|
+
skills/<name>/SKILL.md skills (scanned unless plugin.json lists them)
|
|
11
|
+
connectors/<id>.json connector templates (scanned unless listed)
|
|
12
|
+
agents/<name>.md agent templates (scanned unless listed)
|
|
13
|
+
src/index.ts the extension (optional; bundled by the packer)
|
|
14
|
+
migrations/*.sql, ui/** extension migrations and UI files (optional)
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
A plugin without `src/index.ts` is declarative: skills and templates only, no code runs.
|
|
18
|
+
|
|
19
|
+
## plugin.json
|
|
20
|
+
|
|
21
|
+
Add `"$schema": "https://capybarahq.com/schemas/plugin.v1.schema.json"` for editor support. The
|
|
22
|
+
file is strict: an unknown key is an error. Fields (agent templates are listed under `agents`):
|
|
23
|
+
|
|
24
|
+
<!-- generated:plugin-manifest -->
|
|
25
|
+
| Field | Type | Required |
|
|
26
|
+
|---|---|---|
|
|
27
|
+
| `schemaVersion` | `1` | yes |
|
|
28
|
+
| `name` | string | yes |
|
|
29
|
+
| `version` | string | yes |
|
|
30
|
+
| `publisher` | string | yes |
|
|
31
|
+
| `description` | string or object | yes |
|
|
32
|
+
| `displayName` | object | no |
|
|
33
|
+
| `icon` | string | no |
|
|
34
|
+
| `license` | string | no |
|
|
35
|
+
| `homepage` | string | no |
|
|
36
|
+
| `dependencies` | array of object | no |
|
|
37
|
+
| `skills` | array of object | no |
|
|
38
|
+
| `connectorTemplates` | array of object | no |
|
|
39
|
+
| `agents` | array of object | no |
|
|
40
|
+
| `extension` | object | no |
|
|
41
|
+
<!-- /generated -->
|
|
42
|
+
|
|
43
|
+
Rules that the schema cannot show:
|
|
44
|
+
|
|
45
|
+
- `name`: `^[a-z0-9][a-z0-9-]{0,63}$`. With an extension it must equal the extension's name.
|
|
46
|
+
- `version`: an exact semver version, equal to `package.json` `version`. While the platform is in
|
|
47
|
+
release candidates, ranges on official packages are written `^0.1.0-rc.0`.
|
|
48
|
+
- `description` is a string or `{ en, zh? }`; `displayName` is `{ zh, en }`.
|
|
49
|
+
- `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.
|
|
51
|
+
Omit them to scan the default folders. Names and ids are unique within the plugin.
|
|
52
|
+
- `dependencies`: plugin name plus semver range; no self-dependency.
|
|
53
|
+
- `agents`: at most 64 templates (see `agent-templates`).
|
|
54
|
+
- `extension` is written by the packer; never write it by hand.
|
|
55
|
+
|
|
56
|
+
## Importing
|
|
57
|
+
|
|
58
|
+
Plugins reach a deployment through a marketplace (npm, archive, git or path sources) or a direct
|
|
59
|
+
import. The super admin reviews one import screen (permissions, components, scope) and confirms
|
|
60
|
+
it; an org can upload its own plugin, which the super admin approves if it carries an extension.
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
# 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
|
+
# 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.
|