@capybara-hq/plugin-sdk 0.1.0-rc.2 → 0.1.0-rc.20

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.
Files changed (104) hide show
  1. package/README.md +1 -1
  2. package/agent-docs/agent-templates.md +59 -0
  3. package/agent-docs/concepts.md +63 -0
  4. package/agent-docs/connector-templates.md +48 -0
  5. package/agent-docs/extension-points/channel.md +15 -0
  6. package/agent-docs/extension-points/config-source.md +15 -0
  7. package/agent-docs/extension-points/connector.md +15 -0
  8. package/agent-docs/extension-points/context.md +15 -0
  9. package/agent-docs/extension-points/counter.md +15 -0
  10. package/agent-docs/extension-points/directory.md +15 -0
  11. package/agent-docs/extension-points/file-preview.md +15 -0
  12. package/agent-docs/extension-points/identity-source.md +15 -0
  13. package/agent-docs/extension-points/model-provider.md +15 -0
  14. package/agent-docs/extension-points/object-store.md +15 -0
  15. package/agent-docs/extension-points/sandbox.md +15 -0
  16. package/agent-docs/extension-points/secret-store.md +15 -0
  17. package/agent-docs/extension-points/web-fetch.md +15 -0
  18. package/agent-docs/extension-points/web-search.md +15 -0
  19. package/agent-docs/extensions.md +88 -0
  20. package/agent-docs/plugin-format.md +100 -0
  21. package/agent-docs/setup.md +46 -0
  22. package/agent-docs/skills.md +44 -0
  23. package/agent-docs/tool-naming.md +21 -0
  24. package/dist/agent-template.d.ts +96 -2
  25. package/dist/agent-template.js +381 -3
  26. package/dist/bootstrap.d.ts +15 -1
  27. package/dist/bootstrap.js +17 -1
  28. package/dist/cards.d.ts +39 -5
  29. package/dist/cards.js +70 -11
  30. package/dist/channel.d.ts +20 -1
  31. package/dist/client-css.d.ts +36 -0
  32. package/dist/client-css.js +326 -0
  33. package/dist/client-section.d.ts +35 -0
  34. package/dist/client-section.js +133 -0
  35. package/dist/config-ui.d.ts +24 -1
  36. package/dist/config-ui.js +89 -11
  37. package/dist/connector-auth.d.ts +2 -0
  38. package/dist/connector-auth.js +15 -0
  39. package/dist/context.d.ts +40 -0
  40. package/dist/context.js +2 -0
  41. package/dist/ctx.d.ts +86 -4
  42. package/dist/define-extension.d.ts +5 -1
  43. package/dist/define-extension.js +1 -0
  44. package/dist/dev-hosts.d.ts +6 -0
  45. package/dist/dev-hosts.js +48 -0
  46. package/dist/device-protocol.d.ts +260 -0
  47. package/dist/device-protocol.js +496 -0
  48. package/dist/directory.d.ts +11 -2
  49. package/dist/extension-point.d.ts +6 -0
  50. package/dist/extension-point.js +19 -14
  51. package/dist/file-preview.d.ts +9 -1
  52. package/dist/hooks.d.ts +111 -15
  53. package/dist/hooks.js +5 -0
  54. package/dist/index.d.ts +18 -1
  55. package/dist/index.js +18 -1
  56. package/dist/marketplace.d.ts +55 -2
  57. package/dist/marketplace.js +73 -3
  58. package/dist/model.d.ts +60 -2
  59. package/dist/model.js +22 -0
  60. package/dist/org-access.d.ts +27 -0
  61. package/dist/org-access.js +35 -0
  62. package/dist/permissions.d.ts +33 -8
  63. package/dist/permissions.js +89 -22
  64. package/dist/plugin-manifest.d.ts +60 -7
  65. package/dist/plugin-manifest.js +178 -7
  66. package/dist/sandbox.d.ts +239 -62
  67. package/dist/sandbox.js +99 -14
  68. package/dist/setup-check.d.ts +115 -0
  69. package/dist/setup-check.js +142 -0
  70. package/dist/setup-guide-parse.d.ts +121 -0
  71. package/dist/setup-guide-parse.js +350 -0
  72. package/dist/setup-guide-render.d.ts +45 -0
  73. package/dist/setup-guide-render.js +351 -0
  74. package/dist/setup-guide.d.ts +94 -0
  75. package/dist/setup-guide.js +336 -0
  76. package/dist/skill-invocation.d.ts +9 -5
  77. package/dist/skill-invocation.js +18 -8
  78. package/dist/skill.d.ts +23 -3
  79. package/dist/skill.js +31 -6
  80. package/dist/theme-assets.d.ts +39 -0
  81. package/dist/theme-assets.js +449 -0
  82. package/dist/theme-readability.d.ts +37 -0
  83. package/dist/theme-readability.js +145 -0
  84. package/dist/theme-tokens.generated.d.ts +275 -0
  85. package/dist/theme-tokens.generated.js +172 -0
  86. package/dist/theme.d.ts +152 -0
  87. package/dist/theme.js +392 -0
  88. package/dist/tool.d.ts +26 -3
  89. package/dist/tool.js +8 -0
  90. package/dist/ui-parts.d.ts +23 -0
  91. package/dist/ui-parts.js +337 -0
  92. package/dist/ui-resolve.d.ts +40 -0
  93. package/dist/ui-resolve.js +54 -0
  94. package/dist/ui-slots.d.ts +55 -0
  95. package/dist/ui-slots.js +247 -0
  96. package/dist/ui.d.ts +143 -37
  97. package/dist/ui.js +65 -5
  98. package/dist/web.d.ts +30 -5
  99. package/package.json +10 -2
  100. package/schemas/bootstrap.v1.schema.json +6 -0
  101. package/schemas/connector-template.v1.schema.json +3 -0
  102. package/schemas/marketplace.v1.schema.json +50 -0
  103. package/schemas/plugin.v1.schema.json +144 -7
  104. package/schemas/theme.v1.schema.json +225 -0
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@1`,
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,59 @@
1
+ # Authoring: 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; 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
+ | `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
+ ## 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
+
56
+ ## Creating an agent from a template
57
+
58
+ A connector the org does not have becomes a pending entry, and a setup request goes to the org
59
+ admins. Tool keys follow `tool-naming`.
@@ -0,0 +1,63 @@
1
+ # Platform concepts
2
+
3
+ Read this first. It explains the vocabulary the other topics use.
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
+
10
+ ## Platform and org
11
+
12
+ - The **platform** is one deployment. The **super admin** runs it: imports plugins into the
13
+ **catalog**, decides where each item is on, and configures deployment-wide extensions.
14
+ - An **org** is a tenant of the platform. An org sees the platform items that are on in it, plus
15
+ the items it owns. **Org admins** manage their org; **members** use it.
16
+ - Everything you do through the `Platform` tool acts as the person who started the run. You never
17
+ have more rights than that person, and role, membership and super admin status are re-read on
18
+ every call.
19
+
20
+ ## Plugins, extensions, skills, templates
21
+
22
+ - A **plugin** is the install and distribution unit: an optional extension, skills, connector
23
+ templates and agent templates (see `plugin-format`).
24
+ - An **extension** is the in-process code inside a plugin (see `extensions`). Most
25
+ contributions need no code: a plugin with only skills or templates is *declarative*.
26
+ - A **skill** is instructions the agent loads on demand (`skills`). An **agent template**
27
+ describes a whole agent (`agent-templates`). A **connector template** is a ready-made
28
+ connection to an external system (`connector-templates`).
29
+ - An **extension point** is a versioned contract (`channel@1`) an extension provides or consumes.
30
+
31
+ ## Scope
32
+
33
+ Every platform item (plugin, and its skills and templates) has a scope:
34
+
35
+ | Scope | Meaning |
36
+ |---|---|
37
+ | `all` | On in every org. Org admins cannot switch it. |
38
+ | `optional` | Off until an org admin switches it on. The default for new imports. |
39
+ | `named` | On in the listed orgs only; invisible to other orgs unless shown to them. |
40
+
41
+ Skills, agent templates and connector templates of a platform plugin are platform components: one
42
+ version per deployment, never copied into orgs.
43
+
44
+ ## Owner and shareable
45
+
46
+ An item has an owner: the platform (no owner org) or one org. An org-owned item reaches another org
47
+ only if its owner marked it `shareable` and the platform then shows or scopes it there.
48
+
49
+ ## Requests
50
+
51
+ When a person cannot do something themselves (install a plugin that is not on in their org,
52
+ approve extension permissions), they file a **request**. Org admins or the super admin decide it
53
+ on the web. Agents can file requests but never decide them.
54
+
55
+ ## Sandbox
56
+
57
+ Agents run commands and keep files in a **sandbox**, one per conversation. Skills are mounted
58
+ read-only under `/skills/<name>/`. Sandbox limits and network egress are set per org by admins.
59
+
60
+ ## What agents may not do
61
+
62
+ Deciding approvals and requests, confirming extension permissions, managing tokens and secrets,
63
+ changing roles. Operations that need credentials refuse and point to the web page.
@@ -0,0 +1,48 @@
1
+ # Authoring: 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
+ | `defaultEnabled` | boolean | no |
34
+ | `template` | object | yes |
35
+ <!-- /generated -->
36
+
37
+ Fields of `template`:
38
+
39
+ - `plugin`, `connector`: the connector extension and its kind; `pluginVersion` is a semver range.
40
+ - `endpoint`: the preset every org sees. **Never put credentials in it** (no `token`, `apiKey`,
41
+ `secret`, `password`, `authorization`, `cookie`).
42
+ - `editableEndpoint`: dotted endpoint paths an org may change at install (a self-hosted URL, a
43
+ tenant id). List only what really differs per org.
44
+ - `auth`: the auth method without credentials: `none`, `bearer`, `basic`, `api_key`, `headers`,
45
+ `oauth_code` or `oauth_client`, plus `ownership` (`org` or per member).
46
+ - `defaultToolPolicies`: tool name to `allow`, `ask` or `deny`. When unsure, do not write `allow`.
47
+
48
+ Credentials and secret config are entered by people on the web page, never through an agent.
@@ -0,0 +1,15 @@
1
+ # Authoring: 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
+ # Authoring: 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
+ # Authoring: 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
+ # 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.
@@ -0,0 +1,15 @@
1
+ # Authoring: 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
+ # Authoring: 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
+ # Authoring: 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
+ # Authoring: 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
+ # Authoring: 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
+ # Authoring: 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
+ # Authoring: extension point sandbox
2
+
3
+ <!-- generated:extension-point -->
4
+ - Name: `sandbox` (a ref is `sandbox@<major>`)
5
+ - Runs a device'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`. 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
+
15
+ See `extensions` for the rules every extension follows.
@@ -0,0 +1,15 @@
1
+ # Authoring: 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
+ # Authoring: 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
+ # Authoring: 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,88 @@
1
+ # Authoring: 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
+ `ctx.setup.check` ids in `permissions.setupChecks`) in `permissions`. `capybara-plugin check`
37
+ verifies this.
38
+ - Hooks observe or deny; they never rewrite.
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
+
63
+ ## Extension points
64
+
65
+ An extension *provides* a point (`provides`) or *consumes* one (`requires`, or `optional`). Refs
66
+ look like `channel@1`: name and major version. The registered points:
67
+
68
+ <!-- generated:extension-points -->
69
+ | Extension point | Providers | Per org | What it is |
70
+ |---|---|---|---|
71
+ | `sandbox` | single | no | Runs a device's instance and keeps its files for agents' commands (Docker, E2B). |
72
+ | `config-source` | single | no | Supplies deployment configuration from an external store such as Nacos. |
73
+ | `secret-store` | single | no | Stores and resolves secrets (connector credentials, secret config) outside the database. |
74
+ | `object-store` | single | no | Stores files and artifacts in S3-compatible object storage, with presigned uploads. |
75
+ | `channel` | multi | yes | Connects an instant-messaging platform (Slack, Lark): inbound events, replies and cards. |
76
+ | `model-provider` | multi | no | Calls a model vendor's API and streams the result back to the runtime. |
77
+ | `identity-source` | multi | no | Signs people in through an external identity provider (SSO). |
78
+ | `directory` | multi | yes | Syncs members and departments from an external company directory. |
79
+ | `counter` | multi | no | Counts usage so quotas and reports can be built on it. |
80
+ | `connector` | multi | no | Speaks one protocol (MCP, OpenAPI) to external systems and exposes their tools to agents. |
81
+ | `file-preview` | multi | yes | Renders previews of files of given types in the conversation UI. |
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. |
84
+ | `web-fetch` | multi | yes | Fetches and extracts web pages for the WebFetch tool; each org picks a default provider. |
85
+ <!-- /generated -->
86
+
87
+ Read `extension-points/<name>` for each one. Which points a deployment actually has loaded, and
88
+ which plugins are installed, come from `Platform` operations, not from these docs.
@@ -0,0 +1,100 @@
1
+ # Authoring: the 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
+ themes/<id>.json themes (scanned unless listed)
14
+ src/index.ts the extension (optional; bundled by the packer)
15
+ migrations/*.sql, ui/** extension migrations and UI files (optional)
16
+ ```
17
+
18
+ A plugin without `src/index.ts` is declarative: skills, templates and themes only, no code runs.
19
+
20
+ ## plugin.json
21
+
22
+ Add `"$schema": "https://capybarahq.com/schemas/plugin.v1.schema.json"` for editor support. The
23
+ file is strict: an unknown key is an error. Fields (agent templates are listed under `agents`):
24
+
25
+ <!-- generated:plugin-manifest -->
26
+ | Field | Type | Required |
27
+ |---|---|---|
28
+ | `schemaVersion` | `1` | yes |
29
+ | `name` | string | yes |
30
+ | `version` | string | yes |
31
+ | `publisher` | string | yes |
32
+ | `description` | string or object | yes |
33
+ | `displayName` | object | no |
34
+ | `icon` | string | no |
35
+ | `license` | string | no |
36
+ | `homepage` | string | no |
37
+ | `dependencies` | array of object | no |
38
+ | `skills` | array of object | no |
39
+ | `connectorTemplates` | array of object | no |
40
+ | `agents` | array of object | no |
41
+ | `themes` | array of object | no |
42
+ | `setupGuides` | array of object | no |
43
+ | `suggestedAppearance` | object | no |
44
+ | `extension` | object | no |
45
+ <!-- /generated -->
46
+
47
+ Rules that the schema cannot show:
48
+
49
+ - `name`: `^[a-z0-9][a-z0-9-]{0,63}$`. With an extension it must equal the extension's name.
50
+ - `version`: an exact semver version, equal to `package.json` `version`. While the platform is in
51
+ release candidates, ranges on official packages are written `^0.1.0-rc.0`.
52
+ - `description` is a string or `{ en, zh? }`; `displayName` is `{ zh, en }`.
53
+ - `icon` is a `./` path to an `.svg` or `.png` inside the plugin.
54
+ - `skills`, `connectorTemplates`, `agents`, `themes` list paths starting with `./` that stay inside the plugin.
55
+ Omit them to scan the default folders. Names and ids are unique within the plugin.
56
+ - `dependencies`: plugin name plus semver range; no self-dependency.
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.
66
+ - `extension` is written by the packer; never write it by hand.
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
+
96
+ ## Importing
97
+
98
+ Plugins reach a deployment through a marketplace (npm, archive, git or path sources) or a direct
99
+ import. The super admin reviews one import screen (permissions, components, scope) and confirms
100
+ it; an org can upload its own plugin, which the super admin approves if it carries an extension.
@@ -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.