@capybara-hq/plugin-sdk 0.1.0-rc.8 → 0.1.0-rc.81

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 (149) hide show
  1. package/README.md +1 -1
  2. package/agent-docs/agent-templates.md +14 -2
  3. package/agent-docs/concepts.md +14 -5
  4. package/agent-docs/connector-templates.md +11 -3
  5. package/agent-docs/extension-points/channel.md +1 -1
  6. package/agent-docs/extension-points/context.md +15 -0
  7. package/agent-docs/extension-points/device-provider.md +15 -0
  8. package/agent-docs/extension-points/file-preview.md +3 -1
  9. package/agent-docs/extension-points/identity-source.md +2 -0
  10. package/agent-docs/extension-points/model-provider.md +3 -1
  11. package/agent-docs/extension-points/object-store.md +2 -0
  12. package/agent-docs/extension-points/push-provider.md +17 -0
  13. package/agent-docs/extensions.md +77 -4
  14. package/agent-docs/plugin-format.md +45 -10
  15. package/agent-docs/setup.md +54 -0
  16. package/dist/agent-template.d.ts +15 -6
  17. package/dist/agent-template.js +32 -13
  18. package/dist/avatar-presets.d.ts +8 -0
  19. package/dist/avatar-presets.js +17 -0
  20. package/dist/bootstrap.d.ts +109 -1
  21. package/dist/bootstrap.js +185 -2
  22. package/dist/cards.d.ts +97 -13
  23. package/dist/cards.js +121 -19
  24. package/dist/channel.d.ts +133 -47
  25. package/dist/channel.js +10 -5
  26. package/dist/client-css.d.ts +36 -0
  27. package/dist/client-css.js +326 -0
  28. package/dist/client-section.d.ts +35 -0
  29. package/dist/client-section.js +133 -0
  30. package/dist/config-ui.d.ts +28 -6
  31. package/dist/config-ui.js +88 -25
  32. package/dist/config-url-fetch.d.ts +19 -0
  33. package/dist/config-url-fetch.js +43 -0
  34. package/dist/connector-auth.d.ts +13 -2
  35. package/dist/connector-auth.js +82 -8
  36. package/dist/connector.d.ts +74 -32
  37. package/dist/context.d.ts +40 -0
  38. package/dist/context.js +2 -0
  39. package/dist/ctx.d.ts +224 -30
  40. package/dist/ctx.js +9 -1
  41. package/dist/define-extension.d.ts +23 -13
  42. package/dist/define-extension.js +19 -5
  43. package/dist/device-denied-paths.d.ts +20 -0
  44. package/dist/device-denied-paths.js +118 -0
  45. package/dist/device-operation.d.ts +339 -0
  46. package/dist/device-operation.js +312 -0
  47. package/dist/device-protocol.d.ts +285 -50
  48. package/dist/device-protocol.js +755 -90
  49. package/dist/device-provider.d.ts +780 -0
  50. package/dist/device-provider.js +409 -0
  51. package/dist/device-service.d.ts +126 -0
  52. package/dist/device-service.js +211 -0
  53. package/dist/dial-in.d.ts +286 -0
  54. package/dist/dial-in.js +213 -0
  55. package/dist/directory.d.ts +15 -12
  56. package/dist/extension-point.d.ts +2 -0
  57. package/dist/extension-point.js +7 -3
  58. package/dist/field-meta.d.ts +19 -0
  59. package/dist/field-meta.js +54 -0
  60. package/dist/file-preview.d.ts +43 -10
  61. package/dist/git-hosts.d.ts +53 -0
  62. package/dist/git-hosts.js +98 -0
  63. package/dist/hooks.d.ts +125 -20
  64. package/dist/hooks.js +5 -0
  65. package/dist/http-access.d.ts +71 -0
  66. package/dist/http-access.js +12 -0
  67. package/dist/identity.d.ts +70 -9
  68. package/dist/identity.js +46 -1
  69. package/dist/index.d.ts +28 -4
  70. package/dist/index.js +28 -4
  71. package/dist/model-params.d.ts +41 -22
  72. package/dist/model-params.js +28 -15
  73. package/dist/model.d.ts +227 -75
  74. package/dist/model.js +152 -19
  75. package/dist/native-failure.d.ts +13 -0
  76. package/dist/native-failure.js +31 -0
  77. package/dist/net.d.ts +52 -0
  78. package/dist/net.js +34 -0
  79. package/dist/network-classes.d.ts +98 -0
  80. package/dist/network-classes.js +291 -0
  81. package/dist/permissions.d.ts +65 -22
  82. package/dist/permissions.js +139 -43
  83. package/dist/platform-only.d.ts +27 -0
  84. package/dist/platform-only.js +35 -0
  85. package/dist/plugin-manifest.d.ts +30 -6
  86. package/dist/plugin-manifest.js +147 -55
  87. package/dist/plugin-package.d.ts +82 -39
  88. package/dist/plugin-package.js +68 -41
  89. package/dist/push.d.ts +75 -0
  90. package/dist/push.js +87 -0
  91. package/dist/sandbox-linux-runtime-source.d.ts +1 -0
  92. package/dist/sandbox-linux-runtime-source.js +2343 -0
  93. package/dist/sandbox-native-runtime-source.d.ts +10 -0
  94. package/dist/sandbox-native-runtime-source.js +480 -0
  95. package/dist/sandbox-runtime-source.d.ts +47 -0
  96. package/dist/sandbox-runtime-source.js +73 -0
  97. package/dist/sandbox-write-denies.d.ts +139 -0
  98. package/dist/sandbox-write-denies.js +869 -0
  99. package/dist/secret.d.ts +8 -2
  100. package/dist/secret.js +11 -4
  101. package/dist/setup-check.d.ts +128 -0
  102. package/dist/setup-check.js +142 -0
  103. package/dist/setup-guide-parse.d.ts +121 -0
  104. package/dist/setup-guide-parse.js +356 -0
  105. package/dist/setup-guide-render.d.ts +45 -0
  106. package/dist/setup-guide-render.js +351 -0
  107. package/dist/setup-guide.d.ts +86 -72
  108. package/dist/setup-guide.js +340 -108
  109. package/dist/shell-capabilities.d.ts +211 -0
  110. package/dist/shell-capabilities.js +44 -0
  111. package/dist/shell-environment.d.ts +57 -0
  112. package/dist/shell-environment.js +21 -0
  113. package/dist/skill-invocation.d.ts +5 -0
  114. package/dist/skill-invocation.js +4 -3
  115. package/dist/skill.d.ts +27 -17
  116. package/dist/skill.js +40 -26
  117. package/dist/storage.d.ts +52 -25
  118. package/dist/svg-viewbox.d.ts +10 -0
  119. package/dist/svg-viewbox.js +24 -0
  120. package/dist/theme-assets.d.ts +25 -9
  121. package/dist/theme-assets.js +87 -47
  122. package/dist/theme-tokens.generated.d.ts +26 -2
  123. package/dist/theme-tokens.generated.js +17 -0
  124. package/dist/theme.d.ts +48 -10
  125. package/dist/theme.js +100 -21
  126. package/dist/tool.d.ts +196 -31
  127. package/dist/tool.js +133 -13
  128. package/dist/ui-parts.d.ts +23 -0
  129. package/dist/ui-parts.js +385 -0
  130. package/dist/ui-resolve.d.ts +35 -0
  131. package/dist/ui-resolve.js +42 -0
  132. package/dist/ui-slots.d.ts +65 -0
  133. package/dist/ui-slots.js +261 -0
  134. package/dist/ui.d.ts +245 -77
  135. package/dist/ui.js +104 -27
  136. package/dist/url.d.ts +4 -1
  137. package/dist/url.js +4 -1
  138. package/dist/web.d.ts +26 -20
  139. package/package.json +12 -1
  140. package/schemas/bootstrap-extra.v1.schema.json +186 -0
  141. package/schemas/bootstrap.v1.schema.json +20 -0
  142. package/schemas/connector-template.v1.schema.json +62 -4
  143. package/schemas/plugin.v1.schema.json +74 -143
  144. package/schemas/theme.v1.schema.json +77 -0
  145. package/agent-docs/extension-points/sandbox.md +0 -15
  146. package/dist/org-access.d.ts +0 -27
  147. package/dist/org-access.js +0 -35
  148. package/dist/sandbox.d.ts +0 -254
  149. package/dist/sandbox.js +0 -153
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@2`,
4
+ the types, extension point contracts (`model-provider@2`, `channel@1`, `connector@1`, `device-provider@1`,
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
@@ -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, preloaded (pinned). |
34
- | `selectedSkills` | array of skill names | no | At most 32 further skills the agent may use. |
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
@@ -5,6 +5,7 @@ Read this first. It explains the vocabulary the other topics use.
5
5
  The other topics are for *authoring*: writing an extension, building a plugin, skills, templates,
6
6
  connector templates, tool naming and extension points. To *use* the platform (install, switch on,
7
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.
8
9
 
9
10
  ## Platform and org
10
11
 
@@ -51,12 +52,20 @@ When a person cannot do something themselves (install a plugin that is not on in
51
52
  approve extension permissions), they file a **request**. Org admins or the super admin decide it
52
53
  on the web. Agents can file requests but never decide them.
53
54
 
54
- ## Sandbox
55
+ ## Devices
55
56
 
56
- Agents run commands and keep files in a **sandbox**, one per conversation. Skills are mounted
57
- read-only under `/skills/<name>/`. Sandbox limits and network egress are set per org by admins.
57
+ Agents run commands and keep files on a **device**: one instance plus a file system that is kept
58
+ until the device is deleted. A device comes from a device provider (a cloud sandbox such as Docker or E2B)
59
+ or is a machine connected with `capybara-device`, and the conversations that use it share its files.
60
+ A device runs in one of two modes: auto (the environment's own capability) or sandbox (an OS
61
+ sandbox with an allowlist network). Skill files are read-only in the device's skills directory;
62
+ each conversation is told the device's directories, mode and network. Sandbox limits and the
63
+ cloud network are set per org by admins.
58
64
 
59
65
  ## What agents may not do
60
66
 
61
- Deciding approvals and requests, confirming extension permissions, managing tokens and secrets,
62
- changing roles. Operations that need credentials refuse and point to the web page.
67
+ Deciding approvals and requests, confirming extension permissions, managing tokens, changing
68
+ roles. A secret an operation writes (an extension's API key in its config, say) is never a param:
69
+ list its field in `askPerson` and the person types it on the confirmation card on the web. Never ask
70
+ for a secret in the conversation; a secret that appeared there counts as leaked, so tell the person
71
+ to rotate it. Operations whose secrets the card cannot take refuse and point to the web page.
@@ -9,7 +9,7 @@ the file's base name.
9
9
  {
10
10
  "$schema": "https://capybarahq.com/schemas/connector-template.v1.schema.json",
11
11
  "displayName": { "zh": "Acme CRM", "en": "Acme CRM" },
12
- "description": "Acme CRM over MCP",
12
+ "description": { "zh": "通过 MCP 访问 Acme CRM", "en": "Acme CRM over MCP" },
13
13
  "template": {
14
14
  "plugin": "connector-mcp",
15
15
  "pluginVersion": "^0.1.0-rc.0",
@@ -28,12 +28,15 @@ The file is strict. Top-level fields:
28
28
  | Field | Type | Required |
29
29
  |---|---|---|
30
30
  | `displayName` | object | yes |
31
- | `description` | string | no |
31
+ | `description` | string or object | no |
32
32
  | `icon` | string | no |
33
33
  | `defaultEnabled` | boolean | no |
34
34
  | `template` | object | yes |
35
35
  <!-- /generated -->
36
36
 
37
+ `description` is a string (shown in every language) or `{ "zh", "en" }`, each text at most 1024
38
+ characters; the UI shows the text for its language.
39
+
37
40
  Fields of `template`:
38
41
 
39
42
  - `plugin`, `connector`: the connector extension and its kind; `pluginVersion` is a semver range.
@@ -43,6 +46,11 @@ Fields of `template`:
43
46
  tenant id). List only what really differs per org.
44
47
  - `auth`: the auth method without credentials: `none`, `bearer`, `basic`, `api_key`, `headers`,
45
48
  `oauth_code` or `oauth_client`, plus `ownership` (`org` or per member).
49
+ `oauth_code` may add `authorizationParams`, extra query parameters of the authorize request
50
+ (e.g. `{ "access_type": "offline", "prompt": "consent" }` for Google): at most 10, lowercase
51
+ names, plain values, never a secret, none of `OAUTH_RESERVED_AUTHORIZATION_PARAMS`.
46
52
  - `defaultToolPolicies`: tool name to `allow`, `ask` or `deny`. When unsure, do not write `allow`.
47
53
 
48
- Credentials and secret config are entered by people on the web page, never through an agent.
54
+ Credentials and secret config are entered by the person on the `Platform` confirmation card (name
55
+ their paths in `askPerson`), never typed by an agent; only what the card cannot take (secret
56
+ records, custom header credentials) is entered on the web page.
@@ -10,6 +10,6 @@
10
10
 
11
11
  Contract: Channel (`channel.ts`)
12
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`).
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`), including the `progress` card: on a channel with `features.edit` the kernel sends one per run and edits that message in place, so render it by capability and never send narration as separate messages. Files: implement the optional `sendFile` and declare `features.files` (the platform's bot limits); the kernel sends each conversation artifact as one message and falls back to a link line without it.
14
14
 
15
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 device-provider
2
+
3
+ <!-- generated:extension-point -->
4
+ - Name: `device-provider` (a ref is `device-provider@<major>`)
5
+ - Provides devices (an instance plus kept files) agents run commands in: containers, microVMs, connected machines.
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: DeviceProvider (`device-provider.ts`)
12
+
13
+ The kernel accepts `device-provider@1`; several providers may be loaded side by side and each device keeps the provider that made it. 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). Declare `networkAllowlist: true` (you enforce `limits.network` allowlists) and implement `report(device, signal)`, which answers a `DeviceReport` (revision, description, home, limits, reset) shown to people; the kernel refuses a provider without them. A `projects` call may throw `ProjectPathRefusedError` with a reason when a directory is not yours to serve. Aborting a command must kill it. Locking, suspension timing and destruction are the kernel's job, not yours.
14
+
15
+ See `extensions` for the rules every extension follows.
@@ -2,7 +2,7 @@
2
2
 
3
3
  <!-- generated:extension-point -->
4
4
  - Name: `file-preview` (a ref is `file-preview@<major>`)
5
- - Renders previews of files of given types in the conversation UI.
5
+ - Renders previews of files of given types: conversation files, shared files and skill files.
6
6
  - Providers: several
7
7
  - Enabled per org: yes
8
8
  - Brokered by the platform: no
@@ -12,4 +12,6 @@ Contract: FilePreviewProvider (`file-preview.ts`)
12
12
 
13
13
  Declare which file types you can preview and render them through schema views or an approved embed. Enabled per org.
14
14
 
15
+ `render` args are a union on `source`: `"conversation"` (org, account, conversation), `"share"` (org and share id; `file.id` is the share id; no account or conversation) or `"skill"` (a skill version's file on the skill page: org, account, `skillId`, `version` and `path`; `file.id` is `<skillId>@<version>/<path>`; no conversation). An embed previewer of a skill file gets an org token whose claims carry `skillFile: { skillId, version, path }` instead of `conversationId` / `fileId`; that token reaches every `embed` route of the extension, so an embed route must not treat an org caller without `conversationId` as entitled to conversation data, and should serve a `caller.skillFile` caller only that file. A previewer that needs the conversation declines any `source` other than `"conversation"` by throwing; the kernel reports the failure and the page (a share page, a skill page) falls to the next previewer. A share token is valid only for the `file.preview` slot, never for `/api`.
16
+
15
17
  See `extensions` for the rules every extension follows.
@@ -12,4 +12,6 @@ Contract: IdentitySource (`identity.ts`)
12
12
 
13
13
  Provide SSO login through an external provider. The kernel owns state, nonce and PKCE checks; identities are keyed `<plugin>:<tenant>`.
14
14
 
15
+ Declare `tenant` so the admin console can label and check trusted tenants; list tenants that must never be trusted in `neverTrusted` (`validateTenantId` applies the same rule). A super admin turns the source on, orders the login page and sets its trusted tenants in the admin console (the login section of the extension's page, or the `login-sources.*` Platform operations); there is no startup config for it.
16
+
15
17
  See `extensions` for the rules every extension follows.
@@ -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`); refs `model-provider@1` and `@2`
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.
@@ -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.
@@ -0,0 +1,17 @@
1
+ # Authoring: extension point push-provider
2
+
3
+ <!-- generated:extension-point -->
4
+ - Name: `push-provider` (a ref is `push-provider@<major>`)
5
+ - Delivers push notifications to people's mobile apps through one channel (APNs, FCM, an aggregator).
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: PushProvider (`push.ts`)
12
+
13
+ `send` answers one `PushResult` per registration (`checkPushResults`); a thrown `PushError` applies to every registration of the call. No retries inside: the kernel's queue retries `transient` and `rate_limited`, deletes an `unregistered` registration and tells the platform about `auth`. `apps()` is synchronous and derived from deployment config.
14
+
15
+ Map the channel-neutral `PushMessage` to the channel's payload: `title` and `body` as the alert, `path` and `origin` as data for the app, `threadId` as the grouping key (APNs `thread-id`), and `collapseId` as the channel's collapse key (APNs `apns-collapse-id`, FCM `collapse_key`): it is the same for every send of one event to one device, so a resend after a crash or a timeout replaces the notification. Never log a token.
16
+
17
+ See `extensions` for the rules every extension follows.
@@ -32,10 +32,81 @@ 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` verifies this.
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
+ ## Config
41
+
42
+ An extension declares one config schema, `config: { deployment: z.object({ ... }) }`. The super
43
+ admin sets it for the platform. Every top-level field is **overridable** by default: an org
44
+ follows the platform's value until an org admin saves the org's own copy. Mark a field the platform
45
+ alone sets, and orgs never see, with `platformOnly(...)`; `platformOnly(z.object({ ... }))` marks
46
+ the whole schema (for a plugin with no work done for an org). The mark goes on the root or on a
47
+ top-level field only; a nested field has its top-level key's level.
48
+
49
+ ```ts
50
+ import { configUrlFetch, platformOnly, secret } from "@capybara-hq/plugin-sdk";
51
+ import { z } from "zod";
52
+
53
+ config: {
54
+ deployment: z.object({
55
+ baseUrl: z.string().url().default("https://api.example.com"), // overridable
56
+ apiKey: secret(z.string()), // overridable secret
57
+ adminKey: platformOnly(secret(z.string()).optional()), // platform only
58
+ }),
59
+ },
60
+
61
+ // In work done for an org (`config` is the call's effective config, `orgId` the org's id):
62
+ const client = new VendorClient({
63
+ baseURL: config.baseUrl,
64
+ apiKey: config.apiKey,
65
+ fetch: configUrlFetch(ctx.net, {
66
+ url: config.baseUrl,
67
+ platform: (ctx.config as { baseUrl: string }).baseUrl, // read at call time
68
+ orgId,
69
+ }),
70
+ });
71
+ ```
72
+
73
+ - Work done for an org reads the call's `config` (the effective config: platform config with the
74
+ org's copy applied to the overridable fields), never `ctx.config` (the platform's values).
75
+ - An org that saves a copy brings its own value for every overridable secret. Platform-only
76
+ secrets stay in the effective config; never send one to an endpoint taken from an overridable
77
+ field, because an org could point that endpoint at a server it controls.
78
+ - Every URL under an overridable field reaches the network through `configUrlFetch(ctx.net, { url,
79
+ platform, orgId })`: the platform's own value (read from `ctx.config` each time) gets the global
80
+ `fetch`, any other value (set by an org) goes through the kernel's guarded `ctx.net.fetch`. Pass
81
+ the result as the vendor SDK's `fetch` and use it. Declare such a field as a URL (`z.url()` or
82
+ `.url()`); a URL that only the platform should set is marked `platformOnly` instead.
83
+ `capybara-plugin check` fails an overridable URL no `configUrlFetch` call reads, and an
84
+ overridable string named like a URL (`…Url`, `…Endpoint`, `…Host`) not declared as one
85
+ (`plugin-org-url-net`).
86
+
87
+ ## Setup checks
88
+
89
+ A setup guide's `::check <id> <label>` line (see `plugin-format`) runs a check of the plugin's
90
+ extension:
91
+
92
+ ```ts
93
+ ctx.setup.check("bot-token", {
94
+ place: "channel-connection",
95
+ run: async ({ target, config, mode, signal }) => {
96
+ // one or two read calls, passing signal; return ok, failing (with reason and fix) or unknown
97
+ return { status: "ok", reason: { en: "The platform accepted the token." } };
98
+ },
99
+ });
100
+ ```
101
+
102
+ - Register in `setup` and list each id in `permissions.setupChecks` (`^[a-z0-9][a-z0-9-]{0,47}$`).
103
+ - A check never writes (at the third party or in the platform), never retries, and never puts a
104
+ secret in its `reason` or `fix` (plain text, `{ en, zh? }`, at most 300 / 500 characters).
105
+ - A channel connection target carries the connection config; a connector target carries ids and a
106
+ manual OAuth client id, never the client secret or a member's token.
107
+ - The platform runs checks only when a person or an agent asks, caches results for five minutes,
108
+ times a run out after 10 seconds and redacts known secrets from results.
109
+
39
110
  ## Extension points
40
111
 
41
112
  An extension *provides* a point (`provides`) or *consumes* one (`requires`, or `optional`). Refs
@@ -44,7 +115,7 @@ look like `channel@1`: name and major version. The registered points:
44
115
  <!-- generated:extension-points -->
45
116
  | Extension point | Providers | Per org | What it is |
46
117
  |---|---|---|---|
47
- | `sandbox` | single | no | Runs an environment's instance and keeps its files for agents' commands (Docker, E2B). |
118
+ | `device-provider` | multi | yes | Provides devices (an instance plus kept files) agents run commands in: containers, microVMs, connected machines. |
48
119
  | `config-source` | single | no | Supplies deployment configuration from an external store such as Nacos. |
49
120
  | `secret-store` | single | no | Stores and resolves secrets (connector credentials, secret config) outside the database. |
50
121
  | `object-store` | single | no | Stores files and artifacts in S3-compatible object storage, with presigned uploads. |
@@ -54,9 +125,11 @@ look like `channel@1`: name and major version. The registered points:
54
125
  | `directory` | multi | yes | Syncs members and departments from an external company directory. |
55
126
  | `counter` | multi | no | Counts usage so quotas and reports can be built on it. |
56
127
  | `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. |
128
+ | `file-preview` | multi | yes | Renders previews of files of given types: conversation files, shared files and skill files. |
58
129
  | `web-search` | multi | yes | Searches the web for the WebSearch tool; each org picks a default provider. |
130
+ | `context` | multi | yes | Adds text to the model's context at run start in conversations of orgs that enable it. |
59
131
  | `web-fetch` | multi | yes | Fetches and extracts web pages for the WebFetch tool; each org picks a default provider. |
132
+ | `push-provider` | multi | no | Delivers push notifications to people's mobile apps through one channel (APNs, FCM, an aggregator). |
60
133
  <!-- /generated -->
61
134
 
62
135
  Read `extension-points/<name>` for each one. Which points a deployment actually has loaded, and
@@ -40,6 +40,7 @@ file is strict: an unknown key is an error. Fields (agent templates are listed u
40
40
  | `agents` | array of object | no |
41
41
  | `themes` | array of object | no |
42
42
  | `setupGuides` | array of object | no |
43
+ | `suggestedAppearance` | object | no |
43
44
  | `extension` | object | no |
44
45
  <!-- /generated -->
45
46
 
@@ -56,18 +57,52 @@ Rules that the schema cannot show:
56
57
  - `agents`: at most 64 templates (see `agent-templates`).
57
58
  - `themes`: at most 10 `<id>.json` files; the id is the file's base name. A theme file is checked
58
59
  by `parseThemeFile` (schema `https://capybarahq.com/schemas/theme.v1.schema.json`).
59
- - `setupGuides` (at most 8): setup material shown where a person configures what the plugin
60
- brings. Each guide has an `id`, a `place` (`channel-connection`: 新建渠道 and the channel detail;
61
- the plugin's extension must provide `channel@1`), a `title` and `steps` (`{ en, zh? }`, plain
62
- text, a backtick pair shows as inline code) and `files` (`./` paths ending in `.tmpl`, `.yaml`,
63
- `.yml`, `.json` or `.txt`, at most 64 KiB of text, with a `title` and a `language` of `yaml`,
64
- `json` or `text`). A step or file may carry `mode` (`long_connection` or `webhook`) to apply to
65
- that inbound mode only; ship one file per mode instead of conditionals. The kernel fills
66
- `{{publicUrl}}`, `{{webhookUrl}}`, `{{signInCallbackUrl}}`, `{{connectionName}}`, `{{orgName}}`,
67
- `{{pluginName}}`, `{{pluginVersion}}` and `{{mode}}` (never a secret); in YAML and JSON put a
68
- placeholder inside double quotes. `capybara-plugin pack` refuses any other placeholder.
60
+ Besides schemes and `fonts`, it may set `logo` (`mark`, `wordmark`, `favicon`, `illustration`,
61
+ `appIcon`, `appIconMaskable`), `decoration` (`dither` or `none`), `avatars` (at most 12 presets) and
62
+ `hideAvatarPresets`; every file it names is checked and packed, and nothing else is served.
63
+ - `setupGuides` (at most 8): `{ id, place, templates? }`. Each guide is a Markdown document at
64
+ `guides/<id>.md` (English, required) and `guides/<id>.zh.md` (Chinese, optional), shown where a
65
+ person sets up what the plugin brings. `place` is `channel-connection` (New channel and the channel
66
+ detail; the extension must provide `channel@1`; one per plugin), `connector-template`
67
+ (`templates` names one or more of the plugin's `connectors/<id>.json`, so one guide may serve
68
+ several templates; a template has at most one guide) or
69
+ `extension-deployment` (the super admin's page of the extension; its checks get the extension's
70
+ platform deployment config and `orgId: null`, for credentials such as a push provider's key) or
71
+ `device-connection` (how a member connects a machine through a device provider). See "Setup
72
+ guides" below.
69
73
  - `extension` is written by the packer; never write it by hand.
70
74
 
75
+ ## Setup guides
76
+
77
+ A guide is CommonMark + GFM:
78
+
79
+ - It starts with exactly one `# Title` (the guide's title, at most 100 characters); use `##` to
80
+ `####` below it.
81
+ - `{{name}}` variables come from the place, and none is ever a secret: everywhere `publicUrl`,
82
+ `orgName`, `pluginName`, `pluginVersion`, `mode`; `channel-connection` adds `webhookUrl`,
83
+ `signInCallbackUrl`, `connectionName`; `connector-template` adds `oauthCallbackUrl`,
84
+ `signInCallbackUrl`, `templateId`, `templateName` (the template the guide is shown for),
85
+ `connectorName`; `extension-deployment` adds `signInCallbackUrl` (no modes, admin audience
86
+ only); `device-connection` has only `publicUrl`, `orgId`,
87
+ `orgName`, `pluginName` (no modes, member audience only). In `yaml` / `json` code put a
88
+ variable inside double quotes. Directive lines and fence info strings hold no variables.
89
+ - Sections: a line `::: mode webhook` (modes `long_connection`, `webhook`; channel guides) or
90
+ `::: audience member` (audiences `admin`, `member`; connector template guides) opens one, `:::`
91
+ closes it, both in column 0. Only a mode section may sit inside an audience section. Text outside
92
+ every section applies to all.
93
+ - Checks: a line `::check <id> <label>` is a live status row. `<id>` is one of the extension's own
94
+ checks (registered with `ctx.setup.check` and listed in `permissions.setupChecks`; see
95
+ `extensions`) or a platform check `capybara:<id>` (`public-url`, `webhook-public`,
96
+ `webhook-received`, `connection-active`, `oauth-client`, `connector-tools`,
97
+ `connector-connected`, `oauth-token-endpoint`). The label is plain text, at most 80 characters.
98
+ - Code fences: `<language> title="<text>"`; every block gets a copy button. Indented code blocks are
99
+ refused. Raw HTML shows as text, images are never loaded, and only `https:` links stay links.
100
+ - The zh document has the same sections, the same check ids and byte-equal code blocks.
101
+ - Limits: 64 KiB per document, 24 code blocks, 16 checks, 16 sections.
102
+
103
+ `capybara-plugin pack` and `check` validate the documents; `capybara-plugin guide <id> [--locale zh]
104
+ [--mode m] [--audience a] [--var name=value]` prints a guide as an admin will see it.
105
+
71
106
  ## Importing
72
107
 
73
108
  Plugins reach a deployment through a marketplace (npm, archive, git or path sources) or a direct
@@ -0,0 +1,54 @@
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, never by you. A write that stores one (a connector credential or OAuth client secret, a
35
+ channel secret, an extension config secret) takes it as a person field: name its path in
36
+ `askPerson` and the person types the value on the `Platform` confirmation card. What the card
37
+ cannot take (secret records, custom header credentials) the person enters on the `webPath` page.
38
+ Never ask for a secret in the conversation and never repeat one; if the person pastes one
39
+ anyway, it counts as leaked: tell them to rotate it at the third-party platform. The guide and
40
+ the check results never contain secret values, and no setup operation takes one.
41
+ - **Connecting a personal account** (OAuth consent) happens in the person's browser: call
42
+ `connectors.connect`, which shows the person a Connect button in the conversation, then check
43
+ `connectors.get` for the connection state.
44
+ - **Confirming the app was updated** after a guide changed (the drift notice) is the person's
45
+ confirmation: only they know they changed the app at the third party. For a connector,
46
+ `connectors.guide-ack` puts that statement on its confirmation card (the hash `connectors.get`
47
+ shows under `setupGuide`); for a channel connection, `channels.guide-ack` does (the `hash` of
48
+ `setup.read` for the connection, audience admin, its inbound mode). A stale hash is refused
49
+ before the card: read the guide again and walk the person through the change.
50
+ - **Creating the app** at the third-party platform is outside Capybara: explain it, the person
51
+ does it.
52
+
53
+ Switching a channel connection's inbound mode is an ordinary confirmed operation
54
+ (`channels.update`); the person approves the card.
@@ -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 preloaded (pinned) in the sub-agent. */
22
+ /** Skill names the sub-agent is told to load with `Skill` before it starts (Claude Code's field). */
23
23
  skills?: string[];
24
- /** Further skill names the agent uses (not preloaded; P4-1). */
25
- selectedSkills?: string[];
24
+ /**
25
+ * Skills turned off for the agent (every skill on in the org is on otherwise):
26
+ * `<plugin>:<name>`, `<plugin>:*` (the whole plugin, skills it gains later included) or a bare
27
+ * `<name>` (an org skill without a plugin).
28
+ */
29
+ disallowedSkills?: string[];
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
- /** Preloaded skills. */
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 `selectedSkills`. */
93
- readonly selectedSkills: 32;
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
  /**
@@ -13,12 +13,12 @@ export const AGENT_TEMPLATE_LIMITS = {
13
13
  descriptionChars: 4096,
14
14
  /** Templates in one plugin. */
15
15
  perPlugin: 64,
16
- /** Preloaded skills. */
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 `selectedSkills`. */
21
- selectedSkills: 32,
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, preloaded (pinned).",
92
+ description: "At most 3; the sub-agent is told to load them with `Skill` before it starts.",
93
93
  },
94
94
  {
95
- name: "selectedSkills",
96
- type: "array of skill names",
95
+ name: "disallowedSkills",
96
+ type: "array of skill references",
97
97
  required: false,
98
- description: "At most 32 further skills the agent may use.",
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.selectedSkills !== undefined) {
237
- const s = fm.selectedSkills;
238
- if (Array.isArray(s) && s.length <= L.selectedSkills && s.every(isSkillName) && distinct(s)) {
239
- out.selectedSkills = s;
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);
@@ -0,0 +1,8 @@
1
+ /**
2
+ * The ten built-in pixel-animal agent avatars (drawn by `@capybara-hq/design`), in the picker's
3
+ * order. A theme may hide them (`hideAvatarPresets`) and may not reuse their ids for its own
4
+ * presets (`avatars`). The kernel's preset ids are this list; the design package keeps a copy.
5
+ */
6
+ export declare const BUILTIN_AVATAR_PRESET_IDS: readonly ["capybara", "black-bear", "panda", "elephant", "fox", "owl", "penguin", "rabbit", "turtle", "whale"];
7
+ /** One of {@link BUILTIN_AVATAR_PRESET_IDS}. */
8
+ export type BuiltinAvatarPresetId = (typeof BUILTIN_AVATAR_PRESET_IDS)[number];
@@ -0,0 +1,17 @@
1
+ /**
2
+ * The ten built-in pixel-animal agent avatars (drawn by `@capybara-hq/design`), in the picker's
3
+ * order. A theme may hide them (`hideAvatarPresets`) and may not reuse their ids for its own
4
+ * presets (`avatars`). The kernel's preset ids are this list; the design package keeps a copy.
5
+ */
6
+ export const BUILTIN_AVATAR_PRESET_IDS = [
7
+ "capybara",
8
+ "black-bear",
9
+ "panda",
10
+ "elephant",
11
+ "fox",
12
+ "owl",
13
+ "penguin",
14
+ "rabbit",
15
+ "turtle",
16
+ "whale",
17
+ ];