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

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 (108) hide show
  1. package/README.md +1 -1
  2. package/agent-docs/agent-templates.md +59 -0
  3. package/agent-docs/concepts.md +63 -0
  4. package/agent-docs/connector-templates.md +48 -0
  5. package/agent-docs/extension-points/channel.md +15 -0
  6. package/agent-docs/extension-points/config-source.md +15 -0
  7. package/agent-docs/extension-points/connector.md +15 -0
  8. package/agent-docs/extension-points/context.md +15 -0
  9. package/agent-docs/extension-points/counter.md +15 -0
  10. package/agent-docs/extension-points/directory.md +15 -0
  11. package/agent-docs/extension-points/file-preview.md +15 -0
  12. package/agent-docs/extension-points/identity-source.md +15 -0
  13. package/agent-docs/extension-points/model-provider.md +15 -0
  14. package/agent-docs/extension-points/object-store.md +15 -0
  15. package/agent-docs/extension-points/sandbox.md +15 -0
  16. package/agent-docs/extension-points/secret-store.md +15 -0
  17. package/agent-docs/extension-points/web-fetch.md +15 -0
  18. package/agent-docs/extension-points/web-search.md +15 -0
  19. package/agent-docs/extensions.md +88 -0
  20. package/agent-docs/plugin-format.md +100 -0
  21. package/agent-docs/setup.md +46 -0
  22. package/agent-docs/skills.md +44 -0
  23. package/agent-docs/tool-naming.md +21 -0
  24. package/dist/agent-template.d.ts +96 -2
  25. package/dist/agent-template.js +381 -3
  26. package/dist/bootstrap.d.ts +15 -1
  27. package/dist/bootstrap.js +17 -1
  28. package/dist/cards.d.ts +39 -5
  29. package/dist/cards.js +70 -11
  30. package/dist/channel.d.ts +20 -1
  31. package/dist/client-css.d.ts +36 -0
  32. package/dist/client-css.js +326 -0
  33. package/dist/client-section.d.ts +35 -0
  34. package/dist/client-section.js +133 -0
  35. package/dist/config-ui.d.ts +24 -1
  36. package/dist/config-ui.js +89 -11
  37. package/dist/connector-auth.d.ts +2 -0
  38. package/dist/connector-auth.js +15 -0
  39. package/dist/context.d.ts +40 -0
  40. package/dist/context.js +2 -0
  41. package/dist/ctx.d.ts +86 -4
  42. package/dist/define-extension.d.ts +5 -1
  43. package/dist/define-extension.js +1 -0
  44. package/dist/dev-hosts.d.ts +6 -0
  45. package/dist/dev-hosts.js +48 -0
  46. package/dist/device-protocol.d.ts +260 -0
  47. package/dist/device-protocol.js +496 -0
  48. package/dist/directory.d.ts +11 -2
  49. package/dist/extension-point.d.ts +6 -0
  50. package/dist/extension-point.js +19 -14
  51. package/dist/file-preview.d.ts +9 -1
  52. package/dist/git-hosts.d.ts +44 -0
  53. package/dist/git-hosts.js +81 -0
  54. package/dist/hooks.d.ts +111 -15
  55. package/dist/hooks.js +5 -0
  56. package/dist/index.d.ts +19 -1
  57. package/dist/index.js +19 -1
  58. package/dist/marketplace.d.ts +55 -2
  59. package/dist/marketplace.js +73 -3
  60. package/dist/model.d.ts +60 -2
  61. package/dist/model.js +22 -0
  62. package/dist/org-access.d.ts +27 -0
  63. package/dist/org-access.js +35 -0
  64. package/dist/permissions.d.ts +33 -8
  65. package/dist/permissions.js +89 -22
  66. package/dist/plugin-manifest.d.ts +60 -7
  67. package/dist/plugin-manifest.js +180 -7
  68. package/dist/plugin-package.d.ts +3 -0
  69. package/dist/plugin-package.js +4 -0
  70. package/dist/sandbox.d.ts +239 -62
  71. package/dist/sandbox.js +99 -14
  72. package/dist/setup-check.d.ts +115 -0
  73. package/dist/setup-check.js +142 -0
  74. package/dist/setup-guide-parse.d.ts +121 -0
  75. package/dist/setup-guide-parse.js +350 -0
  76. package/dist/setup-guide-render.d.ts +45 -0
  77. package/dist/setup-guide-render.js +351 -0
  78. package/dist/setup-guide.d.ts +94 -0
  79. package/dist/setup-guide.js +336 -0
  80. package/dist/skill-invocation.d.ts +9 -5
  81. package/dist/skill-invocation.js +18 -8
  82. package/dist/skill.d.ts +23 -3
  83. package/dist/skill.js +31 -6
  84. package/dist/theme-assets.d.ts +39 -0
  85. package/dist/theme-assets.js +449 -0
  86. package/dist/theme-readability.d.ts +37 -0
  87. package/dist/theme-readability.js +145 -0
  88. package/dist/theme-tokens.generated.d.ts +275 -0
  89. package/dist/theme-tokens.generated.js +172 -0
  90. package/dist/theme.d.ts +152 -0
  91. package/dist/theme.js +392 -0
  92. package/dist/tool.d.ts +26 -3
  93. package/dist/tool.js +8 -0
  94. package/dist/ui-parts.d.ts +23 -0
  95. package/dist/ui-parts.js +337 -0
  96. package/dist/ui-resolve.d.ts +40 -0
  97. package/dist/ui-resolve.js +54 -0
  98. package/dist/ui-slots.d.ts +55 -0
  99. package/dist/ui-slots.js +247 -0
  100. package/dist/ui.d.ts +143 -37
  101. package/dist/ui.js +65 -5
  102. package/dist/web.d.ts +30 -5
  103. package/package.json +10 -2
  104. package/schemas/bootstrap.v1.schema.json +6 -0
  105. package/schemas/connector-template.v1.schema.json +35 -0
  106. package/schemas/marketplace.v1.schema.json +50 -0
  107. package/schemas/plugin.v1.schema.json +144 -7
  108. package/schemas/theme.v1.schema.json +225 -0
@@ -0,0 +1,81 @@
1
+ import { z } from "zod";
2
+ import { validateAllowHost } from "./sandbox.js";
3
+ /**
4
+ * The git source of a connector: the git hosts a connector's credential may be used for, and the
5
+ * HTTP basic username to present for each (spec 2026-11-12-sandbox-git-credentials §6.1). Pure
6
+ * validation; the kernel reuses {@link GitSourceSchema} for its connector create body.
7
+ */
8
+ /** Limits of {@link GitSourceSchema}. */
9
+ export const GIT_HOSTS_LIMITS = {
10
+ /** Hosts per connector. */
11
+ hosts: 8,
12
+ /** Characters of a username. */
13
+ usernameChars: 64,
14
+ };
15
+ /**
16
+ * The basic-auth usernames of well-known git hosts: a GitHub token (a PAT or an app installation
17
+ * token) is presented with the fixed username `x-access-token`. Documentation for template authors;
18
+ * a connector still states its username explicitly.
19
+ */
20
+ export const GIT_HOST_USERNAMES = {
21
+ "github.com": "x-access-token",
22
+ "*.ghe.com": "x-access-token",
23
+ };
24
+ const USERNAME_RE = /^[A-Za-z0-9._-]{1,64}$/;
25
+ /** Why a host is refused; never echoes the value (it may be a pasted credential or URL). */
26
+ function hostProblems(h) {
27
+ if (/[@:/?#\s]/.test(h))
28
+ return ["host must be a bare hostname (no userinfo, port or path)"];
29
+ if (h.includes("*"))
30
+ return ["host must not contain a wildcard"];
31
+ if (h !== h.toLowerCase())
32
+ return ["host must be lower-case"];
33
+ return validateAllowHost(h);
34
+ }
35
+ const GitHostEntrySchema = z.strictObject({
36
+ host: z
37
+ .string()
38
+ .max(253, "host must be at most 253 characters")
39
+ .superRefine((h, ctx) => {
40
+ for (const message of hostProblems(h))
41
+ ctx.addIssue({ code: "custom", message });
42
+ }),
43
+ username: z
44
+ .string()
45
+ .regex(USERNAME_RE, "username must match ^[A-Za-z0-9._-]{1,64}$ (letters, digits, '.', '_', '-')"),
46
+ });
47
+ /**
48
+ * The zod schema of {@link GitSource} (strict objects, 1 to {@link GIT_HOSTS_LIMITS}`.hosts` hosts,
49
+ * no duplicate host). Error messages never echo the offending value.
50
+ */
51
+ export const GitSourceSchema = z
52
+ .strictObject({
53
+ hosts: z
54
+ .array(GitHostEntrySchema)
55
+ .min(1, "hosts must not be empty")
56
+ .max(GIT_HOSTS_LIMITS.hosts),
57
+ })
58
+ .superRefine((g, ctx) => {
59
+ const seen = new Set();
60
+ g.hosts.forEach((e, i) => {
61
+ if (seen.has(e.host)) {
62
+ ctx.addIssue({ code: "custom", path: ["hosts", i, "host"], message: "duplicate host" });
63
+ }
64
+ seen.add(e.host);
65
+ });
66
+ });
67
+ /** Validates a `git` value; returns problems as `<path>: <message>` (empty means valid). */
68
+ export function validateGitSource(git, at = "git") {
69
+ const r = GitSourceSchema.safeParse(git);
70
+ if (r.success)
71
+ return [];
72
+ return r.error.issues.map((i) => {
73
+ const path = i.path.map(String).join(".");
74
+ return `${path === "" ? at : `${at}.${path}`}: ${i.message}`;
75
+ });
76
+ }
77
+ /** Parses a `git` value: the value, or `{ errors }`. */
78
+ export function parseGitSource(git) {
79
+ const errors = validateGitSource(git);
80
+ return errors.length > 0 ? { errors } : GitSourceSchema.parse(git);
81
+ }
package/dist/hooks.d.ts CHANGED
@@ -4,7 +4,9 @@ import type { ContentBlock, ModelRequest, ModelUsage } from "./model.js";
4
4
  * `HOOK_MOUNT_POINTS` (`session.*`, `agent.preStep`) stay reserved: they validate in a manifest but
5
5
  * cannot be registered yet.
6
6
  */
7
- export declare const HOOKS_AVAILABLE: readonly ["model.request", "model.response", "tool.preExecute", "tool.postExecute", "usage.report"];
7
+ export declare const HOOKS_AVAILABLE: readonly ["model.request", "model.response", "tool.preExecute", "tool.postExecute", "usage.report", "org.member_removed", "agent.deleted", "org.deleted"];
8
+ /** Lifecycle mount points: observe-only notices that something was removed. */
9
+ export declare const LIFECYCLE_HOOKS: readonly ["org.member_removed", "agent.deleted", "org.deleted"];
8
10
  /** A mount point that `ctx.hooks.on` accepts. */
9
11
  export type AvailableHook = (typeof HOOKS_AVAILABLE)[number];
10
12
  /** Where a sub-agent was dispatched from: the parent conversation, its run and the `Agent` call. */
@@ -39,8 +41,12 @@ export interface HookScope {
39
41
  * `WebFetch` tool.
40
42
  */
41
43
  export type ModelCallPurpose = "step" | "compaction" | "title" | "web_fetch";
42
- /** What a reported model call was for (the same values as {@link ModelCallPurpose}). */
43
- export type UsagePurpose = ModelCallPurpose;
44
+ /**
45
+ * What a reported or requested model call was for: the {@link ModelCallPurpose} values, or
46
+ * `embedding` for an embedding call an extension made through `ctx.models` (`usage.report`, and
47
+ * `model.request` with {@link EmbeddingRequestHookPayload}; never `model.response`).
48
+ */
49
+ export type UsagePurpose = ModelCallPurpose | "embedding";
44
50
  /**
45
51
  * An image or document of a `model.request` payload. Hook payloads never carry media bytes or
46
52
  * attachment ids: each image or document block is replaced by this placeholder.
@@ -74,14 +80,15 @@ export type HookModelRequest = Omit<ModelRequest, "messages"> & {
74
80
  messages: HookModelMessage[];
75
81
  };
76
82
  /**
77
- * `model.request`: before a model call is sent. A policy hook may deny it. Fires once per attempt of a
78
- * step (`purpose: "step"`), once for each compaction call (`purpose: "compaction"`, `attempt` 1) and
83
+ * `model.request` of a chat model call (see {@link ModelRequestHookPayload}): once per attempt of a
84
+ * step (`purpose: "step"`), once for each compaction call (`purpose: "compaction"`, `attempt` 1),
79
85
  * once for each conversation title call (`purpose: "title"`, `runId` "", `step` 0, `attempt` 1; a
80
- * denial skips the title and is recorded only in the audit log).
86
+ * denial skips the title and is recorded only in the audit log) and once for each `WebFetch`
87
+ * extraction call (`purpose: "web_fetch"`).
81
88
  * `request` is the request as sent, except that images and documents are placeholders
82
89
  * ({@link HookMediaPlaceholder}): no media bytes, no attachment ids.
83
90
  */
84
- export interface ModelRequestHookPayload extends HookScope {
91
+ export interface ModelCallRequestHookPayload extends HookScope {
85
92
  purpose: ModelCallPurpose;
86
93
  step: number;
87
94
  attempt: number;
@@ -89,6 +96,45 @@ export interface ModelRequestHookPayload extends HookScope {
89
96
  model: string;
90
97
  request: Readonly<HookModelRequest>;
91
98
  }
99
+ /**
100
+ * `model.request` of an embedding call an extension made through `ctx.models.embed`
101
+ * (`purpose: "embedding"`): fired once per `embed` call, before the first batch is sent, with every
102
+ * text of the call (the kernel splits them into batches afterwards). A call with no input sends
103
+ * nothing and fires nothing. There is no conversation: the conversation fields of a chat model call
104
+ * (`accountId`, `agentId`, `agentVersion`, `conversationId`, `runId`, `parent`, `step`, `attempt`,
105
+ * `request`) are absent. A policy denial makes `embed` reject (`model.hook_denied`); nothing is sent
106
+ * to the provider and no usage is recorded.
107
+ */
108
+ export interface EmbeddingRequestHookPayload {
109
+ purpose: "embedding";
110
+ orgId: string;
111
+ /** The extension that called `ctx.models.embed`. */
112
+ extension: string;
113
+ /** The embedding purpose the extension called with (one it declared in `permissions.models`). */
114
+ embeddingPurpose: string;
115
+ provider: string;
116
+ model: string;
117
+ /** The texts of the call, in order (text only). */
118
+ input: readonly string[];
119
+ /** The dimensions the extension asked for, when it asked. */
120
+ dimensions?: number;
121
+ /** The input type the extension gave, when it gave one. */
122
+ inputType?: "query" | "document";
123
+ accountId?: undefined;
124
+ agentId?: undefined;
125
+ agentVersion?: undefined;
126
+ conversationId?: undefined;
127
+ runId?: undefined;
128
+ parent?: undefined;
129
+ }
130
+ /**
131
+ * `model.request`: before a model call is sent. A policy hook may deny it. Either a chat model call
132
+ * ({@link ModelCallRequestHookPayload}: steps, compaction, titles, `WebFetch`) or an extension's
133
+ * embedding call ({@link EmbeddingRequestHookPayload}, `purpose: "embedding"`); tell them apart by
134
+ * `purpose`. Handlers must accept the absent conversation fields of an embedding call (a policy
135
+ * hook that throws on one denies the call). Payloads carry no media bytes.
136
+ */
137
+ export type ModelRequestHookPayload = ModelCallRequestHookPayload | EmbeddingRequestHookPayload;
92
138
  /**
93
139
  * `model.response`: after a sent model call finished or failed, with its usage when known (step
94
140
  * attempts, compaction and title calls, see `purpose`). Not fired for a call the user aborted (the run was
@@ -138,12 +184,18 @@ export interface UsageReportPayload {
138
184
  */
139
185
  purpose: UsagePurpose;
140
186
  orgId: string;
141
- accountId: string;
142
- agentId: string;
143
- conversationId: string;
144
- /** A sub-agent's calls report `chat`; `parent` tells them apart. */
145
- conversationKind: "chat" | "eval";
146
- runId: string;
187
+ /** Absent for `embedding`. */
188
+ accountId?: string;
189
+ /** Absent for `embedding`. */
190
+ agentId?: string;
191
+ /** Absent for `embedding`. */
192
+ conversationId?: string;
193
+ /** A sub-agent's calls report `chat`; `parent` tells them apart. Absent for `embedding`. */
194
+ conversationKind?: "chat" | "eval";
195
+ /** Absent for `embedding`. */
196
+ runId?: string;
197
+ /** The calling extension; set for `embedding`. */
198
+ extension?: string;
147
199
  /** Set when the call belongs to a sub-agent: where it was dispatched from. */
148
200
  parent?: HookParentScope;
149
201
  provider: string;
@@ -151,6 +203,34 @@ export interface UsageReportPayload {
151
203
  usage: ModelUsage;
152
204
  occurredAt: string;
153
205
  }
206
+ /**
207
+ * `org.member_removed`: an account left the org (offboarding: removed by an admin, left on its own,
208
+ * or offboarded by a directory sync). Lifecycle hooks are delivered durably, after the removal
209
+ * committed, through a queue, at least once per plugin that declares the mount in
210
+ * `permissions.hooks`, whether or not the org has the plugin enabled and whether or not the org's
211
+ * effective config of the plugin is valid (`call.config` is the platform deployment config): they
212
+ * exist so a plugin can delete the data it holds. Handlers must be idempotent. The payload carries
213
+ * ids only.
214
+ */
215
+ export interface OrgMemberRemovedPayload {
216
+ orgId: string;
217
+ accountId: string;
218
+ }
219
+ /**
220
+ * `agent.deleted`: an agent was deleted. Delivered like {@link OrgMemberRemovedPayload} (durably, at
221
+ * least once, regardless of org enablement or config validity; ids only).
222
+ */
223
+ export interface AgentDeletedPayload {
224
+ orgId: string;
225
+ agentId: string;
226
+ }
227
+ /**
228
+ * `org.deleted`: an org was deleted. Delivered like {@link OrgMemberRemovedPayload} (durably, at
229
+ * least once, regardless of org enablement or config validity; ids only).
230
+ */
231
+ export interface OrgDeletedPayload {
232
+ orgId: string;
233
+ }
154
234
  /** Payload type of each mount point. */
155
235
  export interface HookPayloads {
156
236
  "model.request": ModelRequestHookPayload;
@@ -158,6 +238,9 @@ export interface HookPayloads {
158
238
  "tool.preExecute": ToolPreHookPayload;
159
239
  "tool.postExecute": ToolPostHookPayload;
160
240
  "usage.report": UsageReportPayload;
241
+ "org.member_removed": OrgMemberRemovedPayload;
242
+ "agent.deleted": AgentDeletedPayload;
243
+ "org.deleted": OrgDeletedPayload;
161
244
  }
162
245
  /**
163
246
  * What a hook returns: nothing, or `{ deny: reason }`. A deny only takes effect for a `policy` hook
@@ -169,9 +252,22 @@ export type HookVerdict = void | {
169
252
  };
170
253
  /**
171
254
  * A hook handler. The payload is a deep-frozen copy (mutating it throws). `signal` aborts when the
172
- * hook runs past `hooks.timeoutMs` or the call it observes is aborted.
255
+ * hook runs past `hooks.timeoutMs` or the call it observes is aborted. `call.config` is the
256
+ * extension's effective deployment config for the payload's org (the platform's config with the
257
+ * org's copy applied to the overridable fields, or `ctx.config` while the org follows it); the
258
+ * kernel always passes it, and never calls a hook for an org where that config is not valid
259
+ * (observe hooks are skipped, policy hooks deny). Lifecycle hooks ({@link LIFECYCLE_HOOKS}) are the
260
+ * exception: they get the platform deployment config and are always called.
173
261
  */
174
- export type HookHandler<K extends AvailableHook> = (payload: HookPayloads[K], signal: AbortSignal) => Promise<HookVerdict> | HookVerdict;
262
+ export type HookHandler<K extends AvailableHook> = (payload: HookPayloads[K], signal: AbortSignal, call?: HookCall) => Promise<HookVerdict> | HookVerdict;
263
+ /** The per-call context of a hook handler (see {@link HookHandler}). */
264
+ export interface HookCall {
265
+ /**
266
+ * The extension's effective deployment config for the payload's org (lifecycle hooks: the
267
+ * platform deployment config).
268
+ */
269
+ config: unknown;
270
+ }
175
271
  /**
176
272
  * - `policy` (only on {@link POLICY_HOOKS}): policy hooks run serially by plugin name (registration
177
273
  * order within a plugin) before the call; the first `{ deny }`, error or timeout blocks the call and
package/dist/hooks.js CHANGED
@@ -9,6 +9,11 @@ export const HOOKS_AVAILABLE = [
9
9
  "tool.preExecute",
10
10
  "tool.postExecute",
11
11
  "usage.report",
12
+ "org.member_removed",
13
+ "agent.deleted",
14
+ "org.deleted",
12
15
  ];
16
+ /** Lifecycle mount points: observe-only notices that something was removed. */
17
+ export const LIFECYCLE_HOOKS = ["org.member_removed", "agent.deleted", "org.deleted"];
13
18
  /** Mount points where a `policy` hook may deny the call. */
14
19
  export const POLICY_HOOKS = ["model.request", "tool.preExecute"];
package/dist/index.d.ts CHANGED
@@ -1,30 +1,48 @@
1
- export declare const SDK_VERSION = "0.1.0-rc.2";
1
+ export declare const SDK_VERSION = "0.1.0-rc.21";
2
2
  export * from "./agent-template.js";
3
3
  export * from "./bootstrap.js";
4
4
  export * from "./cards.js";
5
5
  export * from "./channel.js";
6
+ export * from "./client-css.js";
7
+ export * from "./client-section.js";
6
8
  export * from "./config-ui.js";
7
9
  export * from "./connector.js";
8
10
  export * from "./connector-auth.js";
11
+ export * from "./context.js";
9
12
  export * from "./ctx.js";
10
13
  export * from "./define-extension.js";
14
+ export * from "./dev-hosts.js";
15
+ export * from "./device-protocol.js";
11
16
  export * from "./directory.js";
12
17
  export * from "./extension-point.js";
13
18
  export * from "./file-preview.js";
19
+ export * from "./git-hosts.js";
14
20
  export * from "./hooks.js";
15
21
  export * from "./identity.js";
16
22
  export * from "./marketplace.js";
17
23
  export * from "./model.js";
18
24
  export * from "./model-params.js";
25
+ export * from "./org-access.js";
19
26
  export * from "./permissions.js";
20
27
  export * from "./plugin-manifest.js";
21
28
  export * from "./plugin-package.js";
22
29
  export * from "./sandbox.js";
23
30
  export * from "./secret.js";
31
+ export * from "./setup-check.js";
32
+ export * from "./setup-guide.js";
33
+ export { type ParsedSetupGuide, parseSetupGuide, type SetupGuideCheckLine, type SetupGuideCodeBlock, type SetupGuideParseIssue, type SetupGuideSection, } from "./setup-guide-parse.js";
34
+ export * from "./setup-guide-render.js";
24
35
  export * from "./skill.js";
25
36
  export * from "./skill-invocation.js";
26
37
  export * from "./storage.js";
38
+ export * from "./theme.js";
39
+ export * from "./theme-assets.js";
40
+ export * from "./theme-readability.js";
41
+ export * from "./theme-tokens.generated.js";
27
42
  export * from "./tool.js";
28
43
  export * from "./tool-key.js";
29
44
  export * from "./ui.js";
45
+ export * from "./ui-parts.js";
46
+ export * from "./ui-resolve.js";
47
+ export * from "./ui-slots.js";
30
48
  export * from "./web.js";
package/dist/index.js CHANGED
@@ -1,30 +1,48 @@
1
- export const SDK_VERSION = "0.1.0-rc.2";
1
+ export const SDK_VERSION = "0.1.0-rc.21";
2
2
  export * from "./agent-template.js";
3
3
  export * from "./bootstrap.js";
4
4
  export * from "./cards.js";
5
5
  export * from "./channel.js";
6
+ export * from "./client-css.js";
7
+ export * from "./client-section.js";
6
8
  export * from "./config-ui.js";
7
9
  export * from "./connector.js";
8
10
  export * from "./connector-auth.js";
11
+ export * from "./context.js";
9
12
  export * from "./ctx.js";
10
13
  export * from "./define-extension.js";
14
+ export * from "./dev-hosts.js";
15
+ export * from "./device-protocol.js";
11
16
  export * from "./directory.js";
12
17
  export * from "./extension-point.js";
13
18
  export * from "./file-preview.js";
19
+ export * from "./git-hosts.js";
14
20
  export * from "./hooks.js";
15
21
  export * from "./identity.js";
16
22
  export * from "./marketplace.js";
17
23
  export * from "./model.js";
18
24
  export * from "./model-params.js";
25
+ export * from "./org-access.js";
19
26
  export * from "./permissions.js";
20
27
  export * from "./plugin-manifest.js";
21
28
  export * from "./plugin-package.js";
22
29
  export * from "./sandbox.js";
23
30
  export * from "./secret.js";
31
+ export * from "./setup-check.js";
32
+ export * from "./setup-guide.js";
33
+ export { parseSetupGuide, } from "./setup-guide-parse.js";
34
+ export * from "./setup-guide-render.js";
24
35
  export * from "./skill.js";
25
36
  export * from "./skill-invocation.js";
26
37
  export * from "./storage.js";
38
+ export * from "./theme.js";
39
+ export * from "./theme-assets.js";
40
+ export * from "./theme-readability.js";
41
+ export * from "./theme-tokens.generated.js";
27
42
  export * from "./tool.js";
28
43
  export * from "./tool-key.js";
29
44
  export * from "./ui.js";
45
+ export * from "./ui-parts.js";
46
+ export * from "./ui-resolve.js";
47
+ export * from "./ui-slots.js";
30
48
  export * from "./web.js";
@@ -1,8 +1,10 @@
1
1
  import { z } from "zod";
2
2
  /**
3
3
  * The marketplace manifest `marketplace.json` (package ecosystem spec §5.2): a list of plugins,
4
- * each with one source. One entry is one version: a marketplace that offers several versions lists
5
- * the plugin once per version, so `(name, marketplaceEntryVersion)` is unique in a manifest.
4
+ * each with one source. One entry is one version. `capybara-plugin marketplace --write` lists one
5
+ * entry per plugin, its current version (plugin component management spec §13.2); readers still
6
+ * accept several versions of a plugin (marketplaces written in the older form), so
7
+ * `(name, marketplaceEntryVersion)` is unique in a manifest.
6
8
  *
7
9
  * Sources: a same-repo `path`, a `git` repo, an `npm` package (exact version + sha512, downloads
8
10
  * are verified against it, never npm metadata) or an `archive` URL (sha512 or sha256 SRI).
@@ -19,9 +21,15 @@ export declare const MARKETPLACE_MANIFEST_SCHEMA_VERSION = 1;
19
21
  export declare const MARKETPLACE_LIMITS: {
20
22
  readonly nameChars: 100;
21
23
  readonly summaryChars: 280;
24
+ /** Characters of each `displayName` language (as `plugin.json`'s). */
25
+ readonly displayNameChars: 100;
26
+ /** Characters of a `deprecated.reason`. */
27
+ readonly deprecationReasonChars: 280;
22
28
  readonly plugins: 5000;
23
29
  readonly permissionKeys: 500;
24
30
  readonly urlChars: 2000;
31
+ /** Bytes of an entry icon (the plugin icon limit, {@link CONNECTOR_TEMPLATE_LIMITS}). */
32
+ readonly iconBytes: number;
25
33
  };
26
34
  /** Where a marketplace entry's plugin comes from. */
27
35
  export type MarketplaceSource = {
@@ -53,6 +61,11 @@ export interface MarketplaceEntry {
53
61
  en: string;
54
62
  zh?: string;
55
63
  };
64
+ /** Display name (the plugin's `plugin.json` `displayName`); lists show it, else the name. */
65
+ displayName?: {
66
+ zh: string;
67
+ en: string;
68
+ };
56
69
  /** Exact semver; defaults to the npm source's version, otherwise the plugin's own. */
57
70
  version?: string;
58
71
  /** Exact semver. */
@@ -64,6 +77,27 @@ export interface MarketplaceEntry {
64
77
  };
65
78
  /** https URL. */
66
79
  homepage?: string;
80
+ /**
81
+ * The plugin's icon for marketplace lists, before the plugin is imported (display only; an
82
+ * imported plugin shows its own icon). Either an absolute `https://` URL whose path ends in
83
+ * `.svg` / `.png`, or `./<path>.svg|png` inside the marketplace's repository, read at the commit
84
+ * the marketplace was refreshed at (git marketplaces only; ignored in a marketplace fetched over
85
+ * http). The kernel downloads it on refresh (network rules of the marketplace downloads, never
86
+ * with the marketplace token), keeps it when it really is an svg / png of at most
87
+ * {@link MARKETPLACE_LIMITS}`.iconBytes`, and treats a URL's content as fixed: a new icon needs a
88
+ * new URL. A missing or invalid icon never fails the refresh. `capybara-plugin marketplace
89
+ * --write` fills it with the repository path of the plugin's `plugin.json` `icon`.
90
+ */
91
+ icon?: string;
92
+ /**
93
+ * This version is deprecated (`true`, or with a reason shown to admins): browsing lists it under
94
+ * the plugin's other versions, never as the one to import, and the kernel refuses importing it
95
+ * (`marketplace.entry_deprecated`). Set by hand on the entry by the marketplace maintainer;
96
+ * `capybara-plugin marketplace --write` keeps it. `false` is the same as absent.
97
+ */
98
+ deprecated?: boolean | {
99
+ reason?: string;
100
+ };
67
101
  source: MarketplaceSource;
68
102
  }
69
103
  /** `marketplace.json`. */
@@ -83,6 +117,8 @@ export interface MarketplaceParseOptions {
83
117
  /** Tests only: allow http on loopback addresses for `git` / `archive` URLs. */
84
118
  allowInsecureLoopback?: boolean;
85
119
  }
120
+ /** An entry icon's file extension (of the URL's path, or of the repository path). */
121
+ export declare const MARKETPLACE_ICON_RE: RegExp;
86
122
  /**
87
123
  * The zod schema of `marketplace.json` (https only; non-strict: unknown fields dropped). The JSON
88
124
  * Schema is generated with `z.toJSONSchema(MarketplaceManifestSchema, { io: "input" })`.
@@ -97,3 +133,20 @@ export declare function parseMarketplaceManifest(json: unknown, opts?: Marketpla
97
133
  };
98
134
  /** The entry's version: `version`, else the npm source's version, else `null` (the plugin's own). */
99
135
  export declare function marketplaceEntryVersion(e: MarketplaceEntry): string | null;
136
+ /**
137
+ * The entry's icon (see {@link MarketplaceEntry.icon}): `{ url }` for an absolute URL, `{ path }`
138
+ * (normalized, without the leading `./`) for a path inside the marketplace's repository, `null`
139
+ * without one.
140
+ */
141
+ export declare function marketplaceEntryIcon(e: Pick<MarketplaceEntry, "icon">): {
142
+ url: string;
143
+ } | {
144
+ path: string;
145
+ } | null;
146
+ /**
147
+ * The entry's deprecation (see {@link MarketplaceEntry.deprecated}): `null` when it is not
148
+ * deprecated (absent or `false`), else its reason (`null` without one).
149
+ */
150
+ export declare function marketplaceEntryDeprecation(e: MarketplaceEntry): {
151
+ reason: string | null;
152
+ } | null;
@@ -1,9 +1,11 @@
1
1
  import { z } from "zod";
2
- import { CATALOG_ITEM_NAME_RE, isSafePackagePath, NPM_PACKAGE_NAME_RE, SEMVER_VERSION_RE, SHA512_INTEGRITY_RE, } from "./plugin-package.js";
2
+ import { CATALOG_ITEM_NAME_RE, CONNECTOR_TEMPLATE_LIMITS, isSafePackagePath, NPM_PACKAGE_NAME_RE, SEMVER_VERSION_RE, SHA512_INTEGRITY_RE, } from "./plugin-package.js";
3
3
  /**
4
4
  * The marketplace manifest `marketplace.json` (package ecosystem spec §5.2): a list of plugins,
5
- * each with one source. One entry is one version: a marketplace that offers several versions lists
6
- * the plugin once per version, so `(name, marketplaceEntryVersion)` is unique in a manifest.
5
+ * each with one source. One entry is one version. `capybara-plugin marketplace --write` lists one
6
+ * entry per plugin, its current version (plugin component management spec §13.2); readers still
7
+ * accept several versions of a plugin (marketplaces written in the older form), so
8
+ * `(name, marketplaceEntryVersion)` is unique in a manifest.
7
9
  *
8
10
  * Sources: a same-repo `path`, a `git` repo, an `npm` package (exact version + sha512, downloads
9
11
  * are verified against it, never npm metadata) or an `archive` URL (sha512 or sha256 SRI).
@@ -20,9 +22,15 @@ export const MARKETPLACE_MANIFEST_SCHEMA_VERSION = 1;
20
22
  export const MARKETPLACE_LIMITS = {
21
23
  nameChars: 100,
22
24
  summaryChars: 280,
25
+ /** Characters of each `displayName` language (as `plugin.json`'s). */
26
+ displayNameChars: 100,
27
+ /** Characters of a `deprecated.reason`. */
28
+ deprecationReasonChars: 280,
23
29
  plugins: 5000,
24
30
  permissionKeys: 500,
25
31
  urlChars: 2000,
32
+ /** Bytes of an entry icon (the plugin icon limit, {@link CONNECTOR_TEMPLATE_LIMITS}). */
33
+ iconBytes: CONNECTOR_TEMPLATE_LIMITS.iconBytes,
26
34
  };
27
35
  const M = MARKETPLACE_LIMITS;
28
36
  const MAX_ERRORS = 50;
@@ -31,6 +39,13 @@ const PERMISSION_KEY_RE = /^[a-z][a-z.]{0,62}(?::[^\r\n]{1,256})?$/;
31
39
  const SHA256_INTEGRITY_RE = /^sha256-[A-Za-z0-9+/]{43}=$/;
32
40
  const COMMIT_RE = /^[0-9a-f]{40}$/;
33
41
  const HTTPS_URL_RE = /^https:\/\/\S+$/;
42
+ /** An entry icon's file extension (of the URL's path, or of the repository path). */
43
+ export const MARKETPLACE_ICON_RE = /\.(?:svg|png)$/i;
44
+ // Spelled without the `i` flag so the generated JSON Schema keeps the rule
45
+ const ICON_EXT = "\\.(?:[sS][vV][gG]|[pP][nN][gG])";
46
+ const ICON_URL_RE = new RegExp(`^https://[^\\s?#]+${ICON_EXT}(?:\\?[^\\s#]*)?$`);
47
+ const ICON_URL_OR_LOOPBACK_RE = new RegExp(`^(?:https://[^\\s?#]+|http://(?:127\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}|localhost|\\[::1\\])(?::\\d{1,5})?/[^\\s?#]*)${ICON_EXT}(?:\\?[^\\s#]*)?$`);
48
+ const ICON_PATH_RE = new RegExp(`^\\./[^\\s?#]+${ICON_EXT}$`);
34
49
  const HTTPS_OR_LOOPBACK_RE = /^(?:https:\/\/\S+|http:\/\/(?:127\.\d{1,3}\.\d{1,3}\.\d{1,3}|localhost|\[::1\])(?::\d{1,5})?(?:\/\S*)?)$/;
35
50
  const urlString = (re) => z
36
51
  .string()
@@ -49,6 +64,15 @@ const exactVersion = (what) => z
49
64
  .string()
50
65
  .max(256)
51
66
  .regex(SEMVER_VERSION_RE, { message: `${what} must be an exact semver version` });
67
+ /** The path of a URL (empty when it does not parse). */
68
+ const urlPathname = (s) => {
69
+ try {
70
+ return new URL(s).pathname;
71
+ }
72
+ catch {
73
+ return "";
74
+ }
75
+ };
52
76
  /** `./<safe path>` inside the marketplace repo. */
53
77
  const repoPath = z
54
78
  .string()
@@ -123,6 +147,12 @@ function buildSchema(opts) {
123
147
  en: z.string().min(1).max(M.summaryChars),
124
148
  zh: z.string().min(1).max(M.summaryChars).optional(),
125
149
  }),
150
+ displayName: z
151
+ .object({
152
+ zh: z.string().min(1).max(M.displayNameChars),
153
+ en: z.string().min(1).max(M.displayNameChars),
154
+ })
155
+ .optional(),
126
156
  version: exactVersion("version").optional(),
127
157
  minKernel: exactVersion("minKernel").optional(),
128
158
  permissions: z
@@ -132,6 +162,18 @@ function buildSchema(opts) {
132
162
  })
133
163
  .optional(),
134
164
  homepage: urlString(HTTPS_URL_RE).optional(),
165
+ icon: z
166
+ .union([
167
+ urlString(opts.allowInsecureLoopback ? ICON_URL_OR_LOOPBACK_RE : ICON_URL_RE).refine((s) => MARKETPLACE_ICON_RE.test(urlPathname(s)), { message: "an icon URL's path must end in .svg or .png" }),
168
+ repoPath.regex(ICON_PATH_RE, { message: "icon must be a .svg or .png file" }),
169
+ ])
170
+ .optional(),
171
+ deprecated: z
172
+ .union([
173
+ z.boolean(),
174
+ z.object({ reason: z.string().min(1).max(M.deprecationReasonChars).optional() }),
175
+ ])
176
+ .optional(),
135
177
  source,
136
178
  });
137
179
  return z
@@ -230,6 +272,14 @@ const SOURCE_FORMS = ["path", "git", "npm", "archive"];
230
272
  * form the source uses instead, or that it must use exactly one form.
231
273
  */
232
274
  function explainSource(json, issue) {
275
+ if (issue.code === "invalid_union" && issue.path[issue.path.length - 1] === "icon") {
276
+ return [
277
+ {
278
+ path: issue.path,
279
+ message: 'icon must be an https URL whose path ends in .svg or .png, or a "./" path inside the repository ending in .svg or .png',
280
+ },
281
+ ];
282
+ }
233
283
  if (issue.code !== "invalid_union" || issue.path[issue.path.length - 1] !== "source") {
234
284
  return [issue];
235
285
  }
@@ -254,3 +304,23 @@ export function marketplaceEntryVersion(e) {
254
304
  return e.source.npm.version;
255
305
  return null;
256
306
  }
307
+ /**
308
+ * The entry's icon (see {@link MarketplaceEntry.icon}): `{ url }` for an absolute URL, `{ path }`
309
+ * (normalized, without the leading `./`) for a path inside the marketplace's repository, `null`
310
+ * without one.
311
+ */
312
+ export function marketplaceEntryIcon(e) {
313
+ if (e.icon === undefined)
314
+ return null;
315
+ return e.icon.startsWith("./") ? { path: e.icon.slice(2) } : { url: e.icon };
316
+ }
317
+ /**
318
+ * The entry's deprecation (see {@link MarketplaceEntry.deprecated}): `null` when it is not
319
+ * deprecated (absent or `false`), else its reason (`null` without one).
320
+ */
321
+ export function marketplaceEntryDeprecation(e) {
322
+ const d = e.deprecated;
323
+ if (d === undefined || d === false)
324
+ return null;
325
+ return { reason: d === true ? null : (d.reason ?? null) };
326
+ }