@capybara-hq/plugin-sdk 0.1.0-rc.5 → 0.1.0-rc.51

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 (134) 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 +4 -1
  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 +2 -0
  9. package/agent-docs/extension-points/model-provider.md +3 -1
  10. package/agent-docs/extension-points/object-store.md +2 -0
  11. package/agent-docs/extension-points/push-provider.md +17 -0
  12. package/agent-docs/extensions.md +29 -3
  13. package/agent-docs/plugin-format.md +53 -2
  14. package/agent-docs/setup.md +54 -0
  15. package/dist/agent-template.d.ts +15 -6
  16. package/dist/agent-template.js +32 -13
  17. package/dist/avatar-presets.d.ts +8 -0
  18. package/dist/avatar-presets.js +17 -0
  19. package/dist/bootstrap.d.ts +86 -1
  20. package/dist/bootstrap.js +161 -2
  21. package/dist/cards.d.ts +67 -13
  22. package/dist/cards.js +91 -21
  23. package/dist/channel.d.ts +148 -48
  24. package/dist/channel.js +10 -5
  25. package/dist/client-css.d.ts +36 -0
  26. package/dist/client-css.js +326 -0
  27. package/dist/client-section.d.ts +35 -0
  28. package/dist/client-section.js +133 -0
  29. package/dist/config-ui.d.ts +22 -0
  30. package/dist/config-ui.js +64 -4
  31. package/dist/connector-auth.d.ts +7 -2
  32. package/dist/connector-auth.js +29 -8
  33. package/dist/connector.d.ts +74 -32
  34. package/dist/context.d.ts +40 -0
  35. package/dist/context.js +2 -0
  36. package/dist/ctx.d.ts +120 -29
  37. package/dist/define-extension.d.ts +26 -12
  38. package/dist/define-extension.js +11 -4
  39. package/dist/device-denied-paths.d.ts +14 -0
  40. package/dist/device-denied-paths.js +41 -0
  41. package/dist/device-operation.d.ts +302 -0
  42. package/dist/device-operation.js +292 -0
  43. package/dist/device-protocol.d.ts +490 -0
  44. package/dist/device-protocol.js +1117 -0
  45. package/dist/device-provider.d.ts +472 -0
  46. package/dist/device-provider.js +283 -0
  47. package/dist/extension-point.d.ts +2 -0
  48. package/dist/extension-point.js +6 -2
  49. package/dist/file-preview.d.ts +23 -6
  50. package/dist/git-hosts.d.ts +53 -0
  51. package/dist/git-hosts.js +98 -0
  52. package/dist/hooks.d.ts +125 -20
  53. package/dist/hooks.js +5 -0
  54. package/dist/http-access.d.ts +62 -0
  55. package/dist/http-access.js +12 -0
  56. package/dist/identity.d.ts +38 -9
  57. package/dist/identity.js +21 -1
  58. package/dist/index.d.ts +29 -2
  59. package/dist/index.js +29 -2
  60. package/dist/marketplace.d.ts +26 -0
  61. package/dist/marketplace.js +43 -1
  62. package/dist/model-params.d.ts +41 -22
  63. package/dist/model-params.js +28 -15
  64. package/dist/model.d.ts +206 -71
  65. package/dist/model.js +152 -19
  66. package/dist/net.d.ts +52 -0
  67. package/dist/net.js +34 -0
  68. package/dist/network-classes.d.ts +98 -0
  69. package/dist/network-classes.js +291 -0
  70. package/dist/permissions.d.ts +41 -21
  71. package/dist/permissions.js +101 -42
  72. package/dist/plugin-manifest.d.ts +45 -5
  73. package/dist/plugin-manifest.js +169 -6
  74. package/dist/plugin-package.d.ts +82 -38
  75. package/dist/plugin-package.js +61 -29
  76. package/dist/push.d.ts +75 -0
  77. package/dist/push.js +87 -0
  78. package/dist/sandbox-linux-runtime-source.d.ts +1 -0
  79. package/dist/sandbox-linux-runtime-source.js +2318 -0
  80. package/dist/sandbox-native-runtime-source.d.ts +10 -0
  81. package/dist/sandbox-native-runtime-source.js +476 -0
  82. package/dist/sandbox-runtime-source.d.ts +19 -0
  83. package/dist/sandbox-runtime-source.js +28 -0
  84. package/dist/sandbox-write-denies.d.ts +139 -0
  85. package/dist/sandbox-write-denies.js +869 -0
  86. package/dist/secret.d.ts +4 -1
  87. package/dist/secret.js +4 -1
  88. package/dist/setup-check.d.ts +128 -0
  89. package/dist/setup-check.js +142 -0
  90. package/dist/setup-guide-parse.d.ts +135 -0
  91. package/dist/setup-guide-parse.js +413 -0
  92. package/dist/setup-guide-render.d.ts +50 -0
  93. package/dist/setup-guide-render.js +367 -0
  94. package/dist/setup-guide.d.ts +109 -0
  95. package/dist/setup-guide.js +377 -0
  96. package/dist/shell-capabilities.d.ts +231 -0
  97. package/dist/shell-capabilities.js +37 -0
  98. package/dist/shell-environment.d.ts +57 -0
  99. package/dist/shell-environment.js +22 -0
  100. package/dist/skill-invocation.d.ts +4 -3
  101. package/dist/skill-invocation.js +5 -4
  102. package/dist/skill.d.ts +34 -21
  103. package/dist/skill.js +49 -32
  104. package/dist/storage.d.ts +52 -25
  105. package/dist/theme-assets.d.ts +55 -0
  106. package/dist/theme-assets.js +507 -0
  107. package/dist/theme-readability.d.ts +37 -0
  108. package/dist/theme-readability.js +145 -0
  109. package/dist/theme-tokens.generated.d.ts +299 -0
  110. package/dist/theme-tokens.generated.js +184 -0
  111. package/dist/theme.d.ts +190 -0
  112. package/dist/theme.js +471 -0
  113. package/dist/tool.d.ts +69 -26
  114. package/dist/tool.js +29 -9
  115. package/dist/ui-parts.d.ts +23 -0
  116. package/dist/ui-parts.js +348 -0
  117. package/dist/ui-resolve.d.ts +35 -0
  118. package/dist/ui-resolve.js +42 -0
  119. package/dist/ui-slots.d.ts +65 -0
  120. package/dist/ui-slots.js +261 -0
  121. package/dist/ui.d.ts +212 -76
  122. package/dist/ui.js +101 -27
  123. package/dist/url.d.ts +4 -1
  124. package/dist/url.js +4 -1
  125. package/package.json +8 -1
  126. package/schemas/bootstrap-extra.v1.schema.json +172 -0
  127. package/schemas/bootstrap.v1.schema.json +6 -0
  128. package/schemas/connector-template.v1.schema.json +35 -0
  129. package/schemas/marketplace.v1.schema.json +14 -0
  130. package/schemas/plugin.v1.schema.json +117 -3
  131. package/schemas/theme.v1.schema.json +302 -0
  132. package/agent-docs/extension-points/sandbox.md +0 -15
  133. package/dist/sandbox.d.ts +0 -232
  134. package/dist/sandbox.js +0 -120
@@ -0,0 +1,283 @@
1
+ /**
2
+ * Device provider contract `device-provider@1`: a multi, brokered, org-scoped extension point
3
+ * (extensions may not `requires` it; the kernel's `SandboxService` consumes it). The provider implements only the
4
+ * primitives below; the kernel builds `glob` / `grep` / `edit` from `exec` plus `readFile` /
5
+ * `writeFile`.
6
+ *
7
+ * A device separates its **file system** from its **instance**: the file system
8
+ * (`createFileSystem`) lives until the device is deleted (`destroyFileSystem`); instances
9
+ * (`create`) attach to it and come and go (`destroy` drops the instance and keeps the files).
10
+ */
11
+ /** Device provider extension point ref. */
12
+ export const DEVICE_PROVIDER_EXTENSION_POINT = "device-provider@1";
13
+ /** The roots inside the sandbox the model may access. */
14
+ export const SANDBOX_ROOTS = ["/workspace", "/skills", "/tmp"];
15
+ const MAX_PATH_LENGTH = 4096;
16
+ /** The roots every container-like provider uses; the same paths as {@link SANDBOX_ROOTS}. */
17
+ export const DEFAULT_SANDBOX_ROOTS = Object.freeze({
18
+ workspace: "/workspace",
19
+ skills: "/skills",
20
+ tmp: "/tmp",
21
+ });
22
+ /** The roots of an instance, falling back to {@link DEFAULT_SANDBOX_ROOTS}. */
23
+ export function rootsOf(h) {
24
+ return h.roots ?? DEFAULT_SANDBOX_ROOTS;
25
+ }
26
+ /**
27
+ * The instance is definitely gone on the provider's side (container removed, E2B sandbox expired).
28
+ * `exec` / `readFile` / `writeFile` / `stat` must throw it (not a plain Error) when they find the
29
+ * instance gone; the kernel then rebuilds the instance and retries once. A transient connection
30
+ * failure throws a plain error.
31
+ */
32
+ export class SandboxGoneError extends Error {
33
+ sandboxGone = true;
34
+ constructor(message, opts) {
35
+ super(message, opts && "cause" in opts ? { cause: opts.cause } : undefined);
36
+ this.name = "SandboxGoneError";
37
+ }
38
+ }
39
+ /** Duck-typed check (not instanceof), so a plugin bundling another plugin-sdk copy still matches. */
40
+ export function isSandboxGoneError(e) {
41
+ return (e instanceof Error &&
42
+ e.name === "SandboxGoneError" &&
43
+ e.sandboxGone === true);
44
+ }
45
+ /**
46
+ * The file system is definitely gone on the provider's side (volume removed, E2B sandbox killed).
47
+ * `create` throws it instead of attaching the instance to a new, empty file system; the kernel then
48
+ * reports the device's files as lost rather than handing out a silently empty workspace.
49
+ */
50
+ export class FileSystemGoneError extends Error {
51
+ fileSystemGone = true;
52
+ constructor(message, opts) {
53
+ super(message, opts && "cause" in opts ? { cause: opts.cause } : undefined);
54
+ this.name = "FileSystemGoneError";
55
+ }
56
+ }
57
+ /** Duck-typed check (not instanceof), so a plugin bundling another plugin-sdk copy still matches. */
58
+ export function isFileSystemGoneError(e) {
59
+ return (e instanceof Error &&
60
+ e.name === "FileSystemGoneError" &&
61
+ e.fileSystemGone === true);
62
+ }
63
+ /**
64
+ * A holder tag (`exec` argument `tag`, {@link DeviceProvider.killTagged}): the kernel passes its
65
+ * lease tokens (UUIDs). Providers check tags against it before putting them in a command line or a
66
+ * kill pattern.
67
+ */
68
+ export const SANDBOX_TAG_RE = /^[a-z0-9-]{1,64}$/;
69
+ /** Size limits {@link parseDeviceReport} enforces. */
70
+ export const DEVICE_REPORT_LIMITS = Object.freeze({
71
+ revisionChars: 128,
72
+ descriptionChars: 300,
73
+ limits: 8,
74
+ limitLabelChars: 60,
75
+ limitValueChars: 60,
76
+ homeChars: 4096,
77
+ });
78
+ const isRecord = (v) => typeof v === "object" && v !== null && !Array.isArray(v);
79
+ function exactKeys(v, keys, what) {
80
+ for (const k of Object.keys(v)) {
81
+ if (!keys.includes(k))
82
+ throw new TypeError(`${what}: unknown key ${k}`);
83
+ }
84
+ }
85
+ function parseText(v, max, what) {
86
+ if (!isRecord(v))
87
+ throw new TypeError(`${what} must be an object`);
88
+ exactKeys(v, ["en", "zh"], what);
89
+ const { en, zh } = v;
90
+ if (typeof en !== "string" || en === "" || en.length > max) {
91
+ throw new TypeError(`${what}.en must be a non-empty string of at most ${max} characters`);
92
+ }
93
+ if (zh === undefined)
94
+ return { en };
95
+ if (typeof zh !== "string" || zh === "" || zh.length > max) {
96
+ throw new TypeError(`${what}.zh must be a non-empty string of at most ${max} characters`);
97
+ }
98
+ return { en, zh };
99
+ }
100
+ /** Checks a provider's report; throws `TypeError` on any other shape, returns a clean copy. */
101
+ export function parseDeviceReport(value) {
102
+ const L = DEVICE_REPORT_LIMITS;
103
+ if (!isRecord(value))
104
+ throw new TypeError("device report must be an object");
105
+ exactKeys(value, ["revision", "description", "home", "limits", "reset"], "device report");
106
+ const { revision, home, limits, reset } = value;
107
+ if (typeof revision !== "string" || revision === "" || revision.length > L.revisionChars) {
108
+ throw new TypeError(`device report revision must be a non-empty string of at most ${L.revisionChars} characters`);
109
+ }
110
+ const description = parseText(value.description, L.descriptionChars, "device report description");
111
+ if (home !== null) {
112
+ if (typeof home !== "string" || home.length > L.homeChars) {
113
+ throw new TypeError("device report home must be an absolute path or null");
114
+ }
115
+ const errors = validateSandboxPathShape(home);
116
+ if (errors.length > 0)
117
+ throw new TypeError(`device report home: ${errors.join("; ")}`);
118
+ }
119
+ if (!Array.isArray(limits) || limits.length > L.limits) {
120
+ throw new TypeError(`device report limits must be an array of at most ${L.limits} entries`);
121
+ }
122
+ const parsedLimits = limits.map((raw, i) => {
123
+ const what = `device report limits[${i}]`;
124
+ if (!isRecord(raw))
125
+ throw new TypeError(`${what} must be an object`);
126
+ exactKeys(raw, ["label", "value"], what);
127
+ if (typeof raw.value !== "string" || raw.value === "" || raw.value.length > L.limitValueChars) {
128
+ throw new TypeError(`${what}.value must be a non-empty string of at most ${L.limitValueChars} characters`);
129
+ }
130
+ return { label: parseText(raw.label, L.limitLabelChars, `${what}.label`), value: raw.value };
131
+ });
132
+ if (typeof reset !== "boolean")
133
+ throw new TypeError("device report reset must be a boolean");
134
+ return { revision, description, home, limits: parsedLimits, reset };
135
+ }
136
+ /**
137
+ * The provider refuses a project directory (`projects` operations: it lies where the provider
138
+ * will not serve, for example another connection's directory). `reason` is shown to the person.
139
+ * The kernel answers it as `device.project_refused` (422).
140
+ */
141
+ export class ProjectPathRefusedError extends Error {
142
+ projectPathRefused = true;
143
+ reason;
144
+ constructor(reason, opts) {
145
+ super(reason.en, opts && "cause" in opts ? { cause: opts.cause } : undefined);
146
+ this.name = "ProjectPathRefusedError";
147
+ this.reason = reason;
148
+ }
149
+ }
150
+ /** Duck-typed check (not instanceof), so a plugin bundling another plugin-sdk copy still matches. */
151
+ export function isProjectPathRefusedError(e) {
152
+ return (e instanceof Error &&
153
+ e.name === "ProjectPathRefusedError" &&
154
+ e.projectPathRefused === true &&
155
+ isRecord(e.reason));
156
+ }
157
+ // biome-ignore lint/suspicious/noControlCharactersInRegex: control characters are exactly what must be blocked
158
+ const CONTROL = /[\u0000-\u001f\u007f]/;
159
+ /** The longest project name, in UTF-16 code units. */
160
+ export const MAX_DEVICE_PROJECT_NAME_LENGTH = 64;
161
+ /** The most candidates a `scan` answers ({@link DeviceProvider.scan}). */
162
+ export const MAX_DEVICE_SCAN_RESULTS = 50;
163
+ /**
164
+ * Directory names a `scan` never enters, at any depth ({@link DeviceProvider.scan}): dependency
165
+ * trees, not projects. Every provider skips exactly these.
166
+ */
167
+ export const DEVICE_SCAN_SKIPPED_DIRS = Object.freeze(["node_modules"]);
168
+ /**
169
+ * Directory names a `scan` does not enter directly under its `base` ({@link DeviceProvider.scan}):
170
+ * the owner's macOS `Library` (app data, huge, partly privacy-protected) is not where projects
171
+ * live. Every provider skips exactly these.
172
+ */
173
+ export const DEVICE_SCAN_SKIPPED_BASE_DIRS = Object.freeze(["Library"]);
174
+ /** How far below its base a `scan` looks: the base's children and their children. */
175
+ export const MAX_DEVICE_SCAN_DEPTH = 2;
176
+ /**
177
+ * The most directories one `scan` visits (reads the entries of), its `base` included
178
+ * ({@link DeviceProvider.scan}): breadth-first, each level in code-unit order of path.
179
+ */
180
+ export const MAX_DEVICE_SCAN_DIRS = 500;
181
+ /**
182
+ * Whether `v` is a valid project name (a project's identity on its device, and a `scan`
183
+ * candidate's `suggestedName`): non-empty, at most {@link MAX_DEVICE_PROJECT_NAME_LENGTH} UTF-16
184
+ * code units, not `.` or `..`, no `/`, no control characters, and no leading or trailing
185
+ * whitespace.
186
+ */
187
+ export function isDeviceProjectName(v) {
188
+ return (typeof v === "string" &&
189
+ v !== "" &&
190
+ v !== "." &&
191
+ v !== ".." &&
192
+ v.length <= MAX_DEVICE_PROJECT_NAME_LENGTH &&
193
+ !CONTROL.test(v) &&
194
+ !v.includes("/") &&
195
+ !/^\s|\s$/.test(v));
196
+ }
197
+ /**
198
+ * The root-independent checks of a path inside an instance (non-empty, at most 4096 characters, no
199
+ * control characters or backslashes, absolute, no empty or `..` segments); returns the errors,
200
+ * empty when valid. {@link validateSandboxPath} adds root membership.
201
+ */
202
+ export function validateSandboxPathShape(p) {
203
+ if (typeof p !== "string" || p.length === 0)
204
+ return ["path must be a non-empty string"];
205
+ if (p.length > MAX_PATH_LENGTH)
206
+ return [`path must be at most ${MAX_PATH_LENGTH} characters`];
207
+ if (CONTROL.test(p))
208
+ return ["path must not contain control characters"];
209
+ if (p.includes("\\"))
210
+ return ["path must not contain backslashes"];
211
+ if (!p.startsWith("/"))
212
+ return ["path must be absolute"];
213
+ if (p.includes("//"))
214
+ return ["path must not contain empty segments"];
215
+ for (const seg of p.split("/")) {
216
+ let decoded = seg;
217
+ try {
218
+ decoded = decodeURIComponent(seg);
219
+ }
220
+ catch {
221
+ // invalid percent-encoding is taken literally
222
+ }
223
+ if (seg === ".." || decoded === ".." || decoded.includes("/") || decoded.includes("\\")) {
224
+ return ["path must not contain '..' segments"];
225
+ }
226
+ }
227
+ return [];
228
+ }
229
+ /** A structural error after which {@link validateSandboxPath} stops (before the root check). */
230
+ const STOPS = new Set([
231
+ "path must be a non-empty string",
232
+ `path must be at most ${MAX_PATH_LENGTH} characters`,
233
+ "path must not contain control characters",
234
+ "path must not contain backslashes",
235
+ "path must be absolute",
236
+ "path must not contain empty segments",
237
+ ]);
238
+ /**
239
+ * Checks a path inside an instance; returns the errors, empty when valid: the
240
+ * {@link validateSandboxPathShape} checks, then root membership. `roots`: the instance's roots
241
+ * ({@link rootsOf}); absent means {@link SANDBOX_ROOTS}. The path must be one of them or under one.
242
+ */
243
+ export function validateSandboxPath(p, roots) {
244
+ const errors = validateSandboxPathShape(p);
245
+ if (errors.some((e) => STOPS.has(e)))
246
+ return errors;
247
+ const allowed = roots === undefined ? SANDBOX_ROOTS : [roots.workspace, roots.skills, roots.tmp];
248
+ if (!allowed.some((r) => p === r || p.startsWith(`${r}/`))) {
249
+ errors.push(`path must be under ${allowed.join(", ")}`);
250
+ }
251
+ return errors;
252
+ }
253
+ const LABEL = /^[a-z0-9]([a-z0-9-]{0,61}[a-z0-9])?$/;
254
+ /**
255
+ * Validates an outbound allowlist host name: lowercase, no protocol or port, optional leading `*.`,
256
+ * IDN accepted only as punycode.
257
+ */
258
+ export function validateAllowHost(h) {
259
+ if (typeof h !== "string" || h.length === 0)
260
+ return ["host must be a non-empty string"];
261
+ if (h.length > 253)
262
+ return ["host must be at most 253 characters"];
263
+ const name = h.startsWith("*.") ? h.slice(2) : h;
264
+ if (name.length === 0)
265
+ return ["wildcard must be followed by a domain"];
266
+ const labels = name.split(".");
267
+ if (labels.every((l) => LABEL.test(l))) {
268
+ const tld = labels[labels.length - 1];
269
+ if (labels.length < 2)
270
+ return ["host must have at least two labels (no single-label names)"];
271
+ // The last label must start with a letter: this blocks the decimal / octal / hexadecimal
272
+ // spellings of IPv4
273
+ if (!/^[a-z]/.test(tld))
274
+ return ["host must not be an IP address literal"];
275
+ if (["local", "internal", "localhost"].includes(tld)) {
276
+ return ["host must not be in an internal-only domain (.local, .internal, .localhost)"];
277
+ }
278
+ return [];
279
+ }
280
+ return [
281
+ "host must be a lowercase hostname without scheme, port or path (optional leading '*.'; IDN as punycode)",
282
+ ];
283
+ }
@@ -31,6 +31,8 @@ export declare const CHANNEL_EXTENSION_POINT = "channel@1";
31
31
  export declare const IDENTITY_SOURCE_EXTENSION_POINT = "identity-source@1";
32
32
  /** Directory sync extension point ref (see `directory.ts`). */
33
33
  export declare const DIRECTORY_EXTENSION_POINT = "directory@1";
34
+ /** Context provider extension point ref (see `context.ts`). */
35
+ export declare const CONTEXT_EXTENSION_POINT = "context@1";
34
36
  /** Parses an extension point ref; throws when the format is invalid. */
35
37
  export declare function parseExtensionPoint(ref: string): {
36
38
  name: string;
@@ -8,19 +8,21 @@ const info = (majors, description, cardinality, brokered = false, orgScoped = fa
8
8
  });
9
9
  /** The registered extension points. */
10
10
  export const EXTENSION_POINTS = {
11
- sandbox: info([2], "Runs an environment's instance and keeps its files for agents' commands (Docker, E2B).", "single", true),
11
+ "device-provider": info([1], "Provides devices (an instance plus kept files) agents run commands in: containers, microVMs, connected machines.", "multi", true, true),
12
12
  "config-source": info([1], "Supplies deployment configuration from an external store such as Nacos.", "single"),
13
13
  "secret-store": info([1], "Stores and resolves secrets (connector credentials, secret config) outside the database.", "single", true),
14
14
  "object-store": info([1], "Stores files and artifacts in S3-compatible object storage, with presigned uploads.", "single", true),
15
15
  channel: info([1], "Connects an instant-messaging platform (Slack, Lark): inbound events, replies and cards.", "multi", false, true),
16
- "model-provider": info([1, 2], "Calls a model vendor's API and streams the result back to the runtime.", "multi", true),
16
+ "model-provider": info([2], "Calls a model vendor's API and streams the result back to the runtime.", "multi", true),
17
17
  "identity-source": info([1], "Signs people in through an external identity provider (SSO).", "multi"),
18
18
  directory: info([1], "Syncs members and departments from an external company directory.", "multi", false, true),
19
19
  counter: info([1], "Counts usage so quotas and reports can be built on it.", "multi"),
20
20
  connector: info([1], "Speaks one protocol (MCP, OpenAPI) to external systems and exposes their tools to agents.", "multi", true),
21
21
  "file-preview": info([1], "Renders previews of files of given types in the conversation UI.", "multi", false, true),
22
22
  "web-search": info([1], "Searches the web for the WebSearch tool; each org picks a default provider.", "multi", true, true, "org-default"),
23
+ context: info([1], "Adds text to the model's context at run start in conversations of orgs that enable it.", "multi", true, true),
23
24
  "web-fetch": info([1], "Fetches and extracts web pages for the WebFetch tool; each org picks a default provider.", "multi", true, true, "org-default"),
25
+ "push-provider": info([1], "Delivers push notifications to people's mobile apps through one channel (APNs, FCM, an aggregator).", "multi", true),
24
26
  };
25
27
  /** Cardinality of the registered extension points (derived from EXTENSION_POINTS). */
26
28
  export const EXTENSION_POINT_CARDINALITY = Object.fromEntries(Object.entries(EXTENSION_POINTS).map(([k, v]) => [k, v.cardinality]));
@@ -32,6 +34,8 @@ export const CHANNEL_EXTENSION_POINT = "channel@1";
32
34
  export const IDENTITY_SOURCE_EXTENSION_POINT = "identity-source@1";
33
35
  /** Directory sync extension point ref (see `directory.ts`). */
34
36
  export const DIRECTORY_EXTENSION_POINT = "directory@1";
37
+ /** Context provider extension point ref (see `context.ts`). */
38
+ export const CONTEXT_EXTENSION_POINT = "context@1";
35
39
  /** Parses an extension point ref; throws when the format is invalid. */
36
40
  export function parseExtensionPoint(ref) {
37
41
  const m = /^([a-z][a-z0-9-]*)@(\d+)$/.exec(ref);
@@ -7,7 +7,7 @@ export declare const FILE_PREVIEW_MAX_BYTES: number;
7
7
  /**
8
8
  * One previewer of a `file-preview@1` provider: which files it previews and how. It renders either a
9
9
  * view (`render`, drawn by the web app like any `UiView`) or an embed page (`embed`, the id of a ui
10
- * contribution `{ kind: "embed", place: "file-preview" }` of the same extension, which receives the
10
+ * contribution `{ kind: "embed", slot: "file.preview" }` of the same extension, which receives the
11
11
  * file over the message bridge). Exactly one of the two.
12
12
  */
13
13
  export interface FilePreviewer {
@@ -34,14 +34,12 @@ export interface FilePreviewer {
34
34
  export interface FilePreviewProvider {
35
35
  previewers: FilePreviewer[];
36
36
  }
37
- /** Arguments of {@link FilePreviewer.render}; identities come from the kernel after authentication. */
38
- export interface FilePreviewArgs {
39
- orgId: string;
40
- accountId: string;
41
- conversationId: string;
37
+ /** What every {@link FilePreviewArgs} variant carries. */
38
+ export interface FilePreviewArgsBase {
42
39
  locale: Locale;
43
40
  /** Aborted at the kernel's time limit: stop reading and rendering. */
44
41
  signal: AbortSignal;
42
+ /** In the share variant `file.id` is the share id. */
45
43
  file: {
46
44
  id: string;
47
45
  name: string;
@@ -62,6 +60,25 @@ export interface FilePreviewArgs {
62
60
  */
63
61
  config?: unknown;
64
62
  }
63
+ /** A preview inside a conversation; identities come from the kernel after authentication. */
64
+ export interface FilePreviewConversationArgs extends FilePreviewArgsBase {
65
+ source: "conversation";
66
+ orgId: string;
67
+ accountId: string;
68
+ conversationId: string;
69
+ }
70
+ /**
71
+ * A preview on a share page: there is no account and no conversation. A previewer that needs the
72
+ * conversation declines this variant by throwing; the kernel reports the failure and the page falls
73
+ * to the next previewer.
74
+ */
75
+ export interface FilePreviewShareArgs extends FilePreviewArgsBase {
76
+ source: "share";
77
+ orgId: string;
78
+ shareId: string;
79
+ }
80
+ /** Arguments of {@link FilePreviewer.render}: narrow on `source`. */
81
+ export type FilePreviewArgs = FilePreviewConversationArgs | FilePreviewShareArgs;
65
82
  /** Checks a `file-preview@1` provider; returns the problems (empty = valid). */
66
83
  export declare function validateFilePreviewProvider(p: unknown): string[];
67
84
  /** Whether a previewer takes this file: its type or extension is accepted and it is within `maxBytes`. */
@@ -0,0 +1,53 @@
1
+ import { z } from "zod";
2
+ /**
3
+ * The git source of a connector: the git hosts a connector's credential may be used for, and the
4
+ * HTTP basic username to present for each (spec 2026-11-12-sandbox-git-credentials §6.1). Pure
5
+ * validation; the kernel reuses {@link GitSourceSchema} for its connector create body.
6
+ */
7
+ /** Limits of {@link GitSourceSchema}. */
8
+ export declare const GIT_HOSTS_LIMITS: {
9
+ /** Hosts per connector. */
10
+ readonly hosts: 8;
11
+ /** Characters of a username. */
12
+ readonly usernameChars: 64;
13
+ };
14
+ /**
15
+ * The basic-auth usernames of well-known git hosts: a GitHub token (a PAT or an app installation
16
+ * token) is presented with the fixed username `x-access-token`. Documentation for template authors;
17
+ * a connector still states its username explicitly.
18
+ */
19
+ export declare const GIT_HOST_USERNAMES: {
20
+ readonly "github.com": "x-access-token";
21
+ readonly "*.ghe.com": "x-access-token";
22
+ };
23
+ /** A valid HTTP basic username: `^[A-Za-z0-9._-]{1,64}$`. */
24
+ export declare const GIT_USERNAME_RE: RegExp;
25
+ /** The username a git marketplace credential is presented with when none is stored. */
26
+ export declare const GIT_MARKETPLACE_USERNAME_DEFAULT = "x-access-token";
27
+ /**
28
+ * A hint for forms: the basic username well-known git hosts document for a token. Other hosts
29
+ * return `undefined`; the user enters the username the host's documentation names.
30
+ */
31
+ export declare function suggestGitUsername(host: string): string | undefined;
32
+ /** One git host and the username its credential is presented with. */
33
+ export interface GitHostEntry {
34
+ /** Lower-case hostname with no scheme, port, path, wildcard or userinfo. */
35
+ host: string;
36
+ /** HTTP basic username, `^[A-Za-z0-9._-]{1,64}$`. */
37
+ username: string;
38
+ }
39
+ /** The git source of a connector (`git` on a connector template and on a custom connector). */
40
+ export interface GitSource {
41
+ hosts: GitHostEntry[];
42
+ }
43
+ /**
44
+ * The zod schema of {@link GitSource} (strict objects, 1 to {@link GIT_HOSTS_LIMITS}`.hosts` hosts,
45
+ * no duplicate host). Error messages never echo the offending value.
46
+ */
47
+ export declare const GitSourceSchema: z.ZodType<GitSource>;
48
+ /** Validates a `git` value; returns problems as `<path>: <message>` (empty means valid). */
49
+ export declare function validateGitSource(git: unknown, at?: string): string[];
50
+ /** Parses a `git` value: the value, or `{ errors }`. */
51
+ export declare function parseGitSource(git: unknown): GitSource | {
52
+ errors: string[];
53
+ };
@@ -0,0 +1,98 @@
1
+ import { z } from "zod";
2
+ import { validateAllowHost } from "./device-provider.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
+ /** A valid HTTP basic username: `^[A-Za-z0-9._-]{1,64}$`. */
25
+ export const GIT_USERNAME_RE = /^[A-Za-z0-9._-]{1,64}$/;
26
+ /** The username a git marketplace credential is presented with when none is stored. */
27
+ export const GIT_MARKETPLACE_USERNAME_DEFAULT = "x-access-token";
28
+ /**
29
+ * A hint for forms: the basic username well-known git hosts document for a token. Other hosts
30
+ * return `undefined`; the user enters the username the host's documentation names.
31
+ */
32
+ export function suggestGitUsername(host) {
33
+ const h = host.toLowerCase();
34
+ if (h === "github.com" || h.endsWith(".ghe.com"))
35
+ return GIT_MARKETPLACE_USERNAME_DEFAULT;
36
+ if (h === "bitbucket.org")
37
+ return "x-token-auth";
38
+ if (h === "gitlab.com")
39
+ return "oauth2";
40
+ return undefined;
41
+ }
42
+ /** Why a host is refused; never echoes the value (it may be a pasted credential or URL). */
43
+ function hostProblems(h) {
44
+ if (/[@:/?#\s]/.test(h))
45
+ return ["host must be a bare hostname (no userinfo, port or path)"];
46
+ if (h.includes("*"))
47
+ return ["host must not contain a wildcard"];
48
+ if (h !== h.toLowerCase())
49
+ return ["host must be lower-case"];
50
+ return validateAllowHost(h);
51
+ }
52
+ const GitHostEntrySchema = z.strictObject({
53
+ host: z
54
+ .string()
55
+ .max(253, "host must be at most 253 characters")
56
+ .superRefine((h, ctx) => {
57
+ for (const message of hostProblems(h))
58
+ ctx.addIssue({ code: "custom", message });
59
+ }),
60
+ username: z
61
+ .string()
62
+ .regex(GIT_USERNAME_RE, "username must match ^[A-Za-z0-9._-]{1,64}$ (letters, digits, '.', '_', '-')"),
63
+ });
64
+ /**
65
+ * The zod schema of {@link GitSource} (strict objects, 1 to {@link GIT_HOSTS_LIMITS}`.hosts` hosts,
66
+ * no duplicate host). Error messages never echo the offending value.
67
+ */
68
+ export const GitSourceSchema = z
69
+ .strictObject({
70
+ hosts: z
71
+ .array(GitHostEntrySchema)
72
+ .min(1, "hosts must not be empty")
73
+ .max(GIT_HOSTS_LIMITS.hosts),
74
+ })
75
+ .superRefine((g, ctx) => {
76
+ const seen = new Set();
77
+ g.hosts.forEach((e, i) => {
78
+ if (seen.has(e.host)) {
79
+ ctx.addIssue({ code: "custom", path: ["hosts", i, "host"], message: "duplicate host" });
80
+ }
81
+ seen.add(e.host);
82
+ });
83
+ });
84
+ /** Validates a `git` value; returns problems as `<path>: <message>` (empty means valid). */
85
+ export function validateGitSource(git, at = "git") {
86
+ const r = GitSourceSchema.safeParse(git);
87
+ if (r.success)
88
+ return [];
89
+ return r.error.issues.map((i) => {
90
+ const path = i.path.map(String).join(".");
91
+ return `${path === "" ? at : `${at}.${path}`}: ${i.message}`;
92
+ });
93
+ }
94
+ /** Parses a `git` value: the value, or `{ errors }`. */
95
+ export function parseGitSource(git) {
96
+ const errors = validateGitSource(git);
97
+ return errors.length > 0 ? { errors } : GitSourceSchema.parse(git);
98
+ }