@capybara-hq/plugin-sdk 0.1.0-rc.9 → 0.1.0-rc.90

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 (159) hide show
  1. package/README.md +3 -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 +5 -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/extension-points/trigger-source.md +19 -0
  14. package/agent-docs/extensions.md +98 -4
  15. package/agent-docs/plugin-format.md +45 -10
  16. package/agent-docs/setup.md +54 -0
  17. package/api/plugin-sdk.api.md +5983 -0
  18. package/dist/agent-template.d.ts +15 -6
  19. package/dist/agent-template.js +32 -13
  20. package/dist/agents-ctx.d.ts +116 -0
  21. package/dist/agents-ctx.js +22 -0
  22. package/dist/avatar-presets.d.ts +8 -0
  23. package/dist/avatar-presets.js +17 -0
  24. package/dist/bootstrap.d.ts +109 -1
  25. package/dist/bootstrap.js +185 -2
  26. package/dist/cards.d.ts +121 -13
  27. package/dist/cards.js +161 -19
  28. package/dist/channel.d.ts +133 -47
  29. package/dist/channel.js +10 -5
  30. package/dist/client-css.d.ts +36 -0
  31. package/dist/client-css.js +326 -0
  32. package/dist/client-section.d.ts +35 -0
  33. package/dist/client-section.js +133 -0
  34. package/dist/config-ui.d.ts +28 -6
  35. package/dist/config-ui.js +88 -25
  36. package/dist/config-url-fetch.d.ts +19 -0
  37. package/dist/config-url-fetch.js +43 -0
  38. package/dist/connector-auth.d.ts +13 -2
  39. package/dist/connector-auth.js +82 -8
  40. package/dist/connector.d.ts +74 -32
  41. package/dist/context.d.ts +40 -0
  42. package/dist/context.js +2 -0
  43. package/dist/ctx.d.ts +344 -31
  44. package/dist/ctx.js +9 -1
  45. package/dist/define-extension.d.ts +18 -12
  46. package/dist/define-extension.js +18 -5
  47. package/dist/device-denied-paths.d.ts +20 -0
  48. package/dist/device-denied-paths.js +118 -0
  49. package/dist/device-operation.d.ts +348 -0
  50. package/dist/device-operation.js +312 -0
  51. package/dist/device-protocol.d.ts +286 -49
  52. package/dist/device-protocol.js +766 -89
  53. package/dist/device-provider.d.ts +820 -0
  54. package/dist/device-provider.js +432 -0
  55. package/dist/device-service.d.ts +204 -0
  56. package/dist/device-service.js +291 -0
  57. package/dist/dial-in.d.ts +286 -0
  58. package/dist/dial-in.js +213 -0
  59. package/dist/directory.d.ts +15 -12
  60. package/dist/extension-point.d.ts +2 -0
  61. package/dist/extension-point.js +8 -3
  62. package/dist/field-meta.d.ts +19 -0
  63. package/dist/field-meta.js +54 -0
  64. package/dist/file-preview.d.ts +46 -9
  65. package/dist/git-hosts.d.ts +53 -0
  66. package/dist/git-hosts.js +98 -0
  67. package/dist/hooks.d.ts +185 -22
  68. package/dist/hooks.js +6 -0
  69. package/dist/http-access.d.ts +71 -0
  70. package/dist/http-access.js +12 -0
  71. package/dist/identity.d.ts +70 -9
  72. package/dist/identity.js +46 -1
  73. package/dist/inbox.d.ts +103 -0
  74. package/dist/inbox.js +173 -0
  75. package/dist/index.d.ts +30 -4
  76. package/dist/index.js +30 -4
  77. package/dist/model-params.d.ts +41 -22
  78. package/dist/model-params.js +28 -15
  79. package/dist/model.d.ts +295 -77
  80. package/dist/model.js +249 -21
  81. package/dist/native-failure.d.ts +13 -0
  82. package/dist/native-failure.js +31 -0
  83. package/dist/net.d.ts +52 -0
  84. package/dist/net.js +34 -0
  85. package/dist/network-classes.d.ts +98 -0
  86. package/dist/network-classes.js +291 -0
  87. package/dist/permissions.d.ts +95 -25
  88. package/dist/permissions.js +175 -54
  89. package/dist/platform-only.d.ts +27 -0
  90. package/dist/platform-only.js +35 -0
  91. package/dist/plugin-manifest.d.ts +30 -6
  92. package/dist/plugin-manifest.js +147 -55
  93. package/dist/plugin-package.d.ts +82 -39
  94. package/dist/plugin-package.js +68 -41
  95. package/dist/push.d.ts +75 -0
  96. package/dist/push.js +87 -0
  97. package/dist/sandbox-linux-runtime-source.d.ts +1 -0
  98. package/dist/sandbox-linux-runtime-source.js +2343 -0
  99. package/dist/sandbox-native-runtime-source.d.ts +10 -0
  100. package/dist/sandbox-native-runtime-source.js +480 -0
  101. package/dist/sandbox-runtime-source.d.ts +47 -0
  102. package/dist/sandbox-runtime-source.js +73 -0
  103. package/dist/sandbox-write-denies.d.ts +139 -0
  104. package/dist/sandbox-write-denies.js +869 -0
  105. package/dist/secret.d.ts +8 -2
  106. package/dist/secret.js +11 -4
  107. package/dist/setup-check.d.ts +128 -0
  108. package/dist/setup-check.js +142 -0
  109. package/dist/setup-guide-parse.d.ts +121 -0
  110. package/dist/setup-guide-parse.js +356 -0
  111. package/dist/setup-guide-render.d.ts +45 -0
  112. package/dist/setup-guide-render.js +351 -0
  113. package/dist/setup-guide.d.ts +86 -72
  114. package/dist/setup-guide.js +340 -108
  115. package/dist/shell-capabilities.d.ts +216 -0
  116. package/dist/shell-capabilities.js +44 -0
  117. package/dist/shell-environment.d.ts +57 -0
  118. package/dist/shell-environment.js +21 -0
  119. package/dist/skill-invocation.d.ts +5 -0
  120. package/dist/skill-invocation.js +4 -3
  121. package/dist/skill.d.ts +27 -17
  122. package/dist/skill.js +40 -26
  123. package/dist/storage.d.ts +52 -25
  124. package/dist/svg-viewbox.d.ts +10 -0
  125. package/dist/svg-viewbox.js +24 -0
  126. package/dist/theme-assets.d.ts +25 -9
  127. package/dist/theme-assets.js +87 -47
  128. package/dist/theme-tokens.generated.d.ts +40 -12
  129. package/dist/theme-tokens.generated.js +36 -8
  130. package/dist/theme.d.ts +56 -10
  131. package/dist/theme.js +117 -23
  132. package/dist/tool.d.ts +242 -28
  133. package/dist/tool.js +135 -13
  134. package/dist/trigger-source.d.ts +35 -0
  135. package/dist/trigger-source.js +2 -0
  136. package/dist/triggers.d.ts +88 -0
  137. package/dist/triggers.js +71 -0
  138. package/dist/ui-parts.d.ts +23 -0
  139. package/dist/ui-parts.js +374 -0
  140. package/dist/ui-resolve.d.ts +2 -7
  141. package/dist/ui-resolve.js +7 -19
  142. package/dist/ui-slots.d.ts +27 -5
  143. package/dist/ui-slots.js +112 -19
  144. package/dist/ui.d.ts +203 -64
  145. package/dist/ui.js +117 -23
  146. package/dist/url.d.ts +4 -1
  147. package/dist/url.js +4 -1
  148. package/dist/web.d.ts +26 -20
  149. package/package.json +13 -1
  150. package/schemas/bootstrap-extra.v1.schema.json +186 -0
  151. package/schemas/bootstrap.v1.schema.json +20 -0
  152. package/schemas/connector-template.v1.schema.json +62 -4
  153. package/schemas/plugin.v1.schema.json +74 -143
  154. package/schemas/theme.v1.schema.json +77 -0
  155. package/agent-docs/extension-points/sandbox.md +0 -15
  156. package/dist/org-access.d.ts +0 -27
  157. package/dist/org-access.js +0 -35
  158. package/dist/sandbox.d.ts +0 -254
  159. 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
@@ -18,6 +18,8 @@ npm install @capybara-hq/plugin-sdk
18
18
  in capybara-hq/plugins and its reference plugin [plugins/example-counter](https://github.com/capybara-hq/plugins/tree/main/plugins/example-counter).
19
19
  - Writing a plugin (manifest, skills, connector templates, dependencies, marketplaces):
20
20
  [.agents/skills/writing-plugins](https://github.com/capybara-hq/core/tree/main/.agents/skills/writing-plugins).
21
+ - The public API report: `api/plugin-sdk.api.md` in this package (generated by API Extractor),
22
+ every exported name and its exact type in one file.
21
23
  - The repository: [capybara-hq/core](https://github.com/capybara-hq/core).
22
24
 
23
25
  Capybara is on 0.x: the SDK may change in breaking ways between minor versions, and each release's
@@ -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,12 @@
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
+
17
+ Declare each model's prompt cache in `ModelInfo.cache` (absent = mechanism `none`; it must pass `validateModelCache`): the `mechanism` (`explicit` breakpoints, `implicit` service caching, `none`), the lifetimes a request can choose in seconds (`ttlOptions`, ascending; empty when the service decides alone), `defaultTtl` (required and one of `ttlOptions` when `ttlOptions` is non-empty), `ttlIsMinimum`, `refreshOnHit` (true only if a hit refreshes the lifetime of every tier the kernel may select; the kernel selects only `defaultTtl` or the smallest option of at least 1800 s, so OpenAI GPT-5.6+ declares true: its 30m tier refreshes, its 12h tier does not and is never selected; when unconfirmed, declare false), `ttlClock`, `minTokens` and `guaranteed` (a hit on an unchanged prefix within the lifetime is expected, not best-effort). `ModelRequest.cacheTtl` is one of the model's `ttlOptions` (the kernel sends no other value): map it to the vendor's field (`cache_control.ttl`, `prompt_cache_options.ttl`), and ignore it for a model without options. When the vendor reports writes per lifetime tier, report them in `ModelUsage.cacheWriteByTtl` (`{ ttl, tokens }[]`, summing to `cacheWriteTokens`; `validateCacheWriteByTtl`).
18
+
15
19
  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.
@@ -0,0 +1,19 @@
1
+ # Authoring: extension point trigger-source
2
+
3
+ <!-- generated:extension-point -->
4
+ - Name: `trigger-source` (a ref is `trigger-source@<major>`)
5
+ - Declares the events an extension emits and which people may see their subjects.
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: TriggerSource (`trigger-source.ts`), with `ctx.triggers` (`triggers.ts`)
12
+
13
+ Declare the event types the extension emits in `permissions.triggers.emit` (lower-case dotted names such as `item.created`, at most 64) and implement `TriggerSource.events()` with one `TriggerEventDeclaration` per type: a name, whether the event is directed at one agent, and its facts (a type, a name and whether automations may filter on it). Emit with `ctx.triggers.emit(event)`; the result says whether the `dedupeKey` was already seen (`duplicate`). An event carries the org, the subject (kind, id, title, optional url), scalar or string-list facts, a summary of at most 4096 UTF-8 bytes for the agent, and optionally the cause (the tool call, a handle made from one, or the account) and an audience for directed events. `emit` throws `TriggerError`: `type_not_declared`, `invalid_event` or `org_disabled`. An event that must not be lost is emitted from a `ctx.queue` job, where no tool call context exists: in the tool call, get `await ctx.triggers.causeOf(call)` (a handle valid for 24 hours, bound to the call's org and run and to this extension), put it in the job's payload, and emit with `cause: { handle }`, so the event keeps the call's chain depth and self-trigger check.
14
+
15
+ `visible` answers which of the given accounts may see a subject; the kernel only wakes agents of accounts it lists, and a throw or a missing answer means nobody. `subjectLink` optionally gives people a link to the subject. Automation filters are conjunctions over facts: `eq` compares scalars, `in` matches a scalar fact against a list, `contains` matches a list fact against a scalar, and a missing fact never matches.
16
+
17
+ A directed event (its declaration says so, and `audience` names a person and an agent) never reaches automations people made: it runs only through the audience person's acceptance rule for the source (`auto`, `confirm` or `off`; the person sets it on their own page and the org sets the default), so an assignment may be offered, accepted at once, or not accepted; the `run.lifecycle` hook reports the outcome (see `extensions`).
18
+
19
+ See `extensions` for the rules every extension follows.
@@ -32,10 +32,101 @@ 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
+
110
+ ## Inbox, people and run notices
111
+
112
+ - `ctx.inbox` (`permissions.inbox: true`) posts a personal item for one active member of an org that
113
+ enabled the extension: a title, a short body, a link under `/p/<extension name>/` and up to three
114
+ actions, each naming a UI action of the extension that the kernel calls as the person who clicked
115
+ (actions must be idempotent). Pass a `dedupeKey` to keep one open item per subject; items expire
116
+ (30 days by default, 90 at most) and the person's push settings apply. `ctx.inbox.resolve` closes
117
+ an item the extension posted. Errors are `InboxError` (`invalid_item`, `org_disabled`, `not_found`).
118
+ - `ctx.agents.usableBy`, `ctx.conversations.bySubject` and `ctx.people.get` / `search` read org
119
+ facts for pages (`permissions.agents`, `conversations`, `people`; each call names an `orgId`, and
120
+ the extension must be enabled there). They return ids, names and avatars, never emails or
121
+ conversation content.
122
+ - The `run.lifecycle` hook (`permissions.hooks`) tells the extension each phase of a run of a
123
+ conversation about its subject: `started`, `waiting` (on a person), `resumed` (that wait
124
+ cleared), `finished`, `failed` or `aborted`; and that directed work was not run
125
+ (`offer_declined`, `reason` `off`, `declined`, `paused`, `expired` or `undelivered`, with the
126
+ event's `eventId` and your `dedupeKey`, so you can tell a stale decline from one for your latest
127
+ event). It is delivered at least once: make the handler idempotent and treat it as a hint. For events about
128
+ your subjects see `trigger-source`.
129
+
39
130
  ## Extension points
40
131
 
41
132
  An extension *provides* a point (`provides`) or *consumes* one (`requires`, or `optional`). Refs
@@ -44,7 +135,7 @@ look like `channel@1`: name and major version. The registered points:
44
135
  <!-- generated:extension-points -->
45
136
  | Extension point | Providers | Per org | What it is |
46
137
  |---|---|---|---|
47
- | `sandbox` | single | no | Runs a device's instance and keeps its files for agents' commands (Docker, E2B). |
138
+ | `device-provider` | multi | yes | Provides devices (an instance plus kept files) agents run commands in: containers, microVMs, connected machines. |
48
139
  | `config-source` | single | no | Supplies deployment configuration from an external store such as Nacos. |
49
140
  | `secret-store` | single | no | Stores and resolves secrets (connector credentials, secret config) outside the database. |
50
141
  | `object-store` | single | no | Stores files and artifacts in S3-compatible object storage, with presigned uploads. |
@@ -54,9 +145,12 @@ look like `channel@1`: name and major version. The registered points:
54
145
  | `directory` | multi | yes | Syncs members and departments from an external company directory. |
55
146
  | `counter` | multi | no | Counts usage so quotas and reports can be built on it. |
56
147
  | `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. |
148
+ | `file-preview` | multi | yes | Renders previews of files of given types: conversation files, shared files and skill files. |
58
149
  | `web-search` | multi | yes | Searches the web for the WebSearch tool; each org picks a default provider. |
150
+ | `context` | multi | yes | Adds text to the model's context at run start in conversations of orgs that enable it. |
151
+ | `trigger-source` | multi | yes | Declares the events an extension emits and which people may see their subjects. |
59
152
  | `web-fetch` | multi | yes | Fetches and extracts web pages for the WebFetch tool; each org picks a default provider. |
153
+ | `push-provider` | multi | no | Delivers push notifications to people's mobile apps through one channel (APNs, FCM, an aggregator). |
60
154
  <!-- /generated -->
61
155
 
62
156
  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.