@capybara-hq/plugin-sdk 0.1.0-rc.7 → 0.1.0-rc.70

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 (146) hide show
  1. package/README.md +1 -1
  2. package/agent-docs/agent-templates.md +14 -2
  3. package/agent-docs/concepts.md +14 -5
  4. package/agent-docs/connector-templates.md +11 -3
  5. package/agent-docs/extension-points/channel.md +1 -1
  6. package/agent-docs/extension-points/context.md +15 -0
  7. package/agent-docs/extension-points/device-provider.md +15 -0
  8. package/agent-docs/extension-points/file-preview.md +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 +76 -3
  13. package/agent-docs/plugin-format.md +51 -12
  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 +109 -1
  20. package/dist/bootstrap.js +185 -2
  21. package/dist/cards.d.ts +60 -13
  22. package/dist/cards.js +88 -18
  23. package/dist/channel.d.ts +128 -47
  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 +28 -6
  30. package/dist/config-ui.js +88 -25
  31. package/dist/config-url-fetch.d.ts +19 -0
  32. package/dist/config-url-fetch.js +43 -0
  33. package/dist/connector-auth.d.ts +13 -2
  34. package/dist/connector-auth.js +82 -8
  35. package/dist/connector.d.ts +74 -32
  36. package/dist/context.d.ts +40 -0
  37. package/dist/context.js +2 -0
  38. package/dist/ctx.d.ts +210 -30
  39. package/dist/ctx.js +9 -1
  40. package/dist/define-extension.d.ts +23 -13
  41. package/dist/define-extension.js +19 -5
  42. package/dist/device-denied-paths.d.ts +20 -0
  43. package/dist/device-denied-paths.js +118 -0
  44. package/dist/device-operation.d.ts +339 -0
  45. package/dist/device-operation.js +312 -0
  46. package/dist/device-protocol.d.ts +285 -50
  47. package/dist/device-protocol.js +755 -90
  48. package/dist/device-provider.d.ts +708 -0
  49. package/dist/device-provider.js +325 -0
  50. package/dist/device-service.d.ts +52 -0
  51. package/dist/device-service.js +105 -0
  52. package/dist/dial-in.d.ts +239 -0
  53. package/dist/dial-in.js +155 -0
  54. package/dist/directory.d.ts +15 -12
  55. package/dist/extension-point.d.ts +2 -0
  56. package/dist/extension-point.js +6 -2
  57. package/dist/field-meta.d.ts +19 -0
  58. package/dist/field-meta.js +54 -0
  59. package/dist/file-preview.d.ts +26 -10
  60. package/dist/git-hosts.d.ts +53 -0
  61. package/dist/git-hosts.js +98 -0
  62. package/dist/hooks.d.ts +125 -20
  63. package/dist/hooks.js +5 -0
  64. package/dist/http-access.d.ts +62 -0
  65. package/dist/http-access.js +12 -0
  66. package/dist/identity.d.ts +38 -9
  67. package/dist/identity.js +21 -1
  68. package/dist/index.d.ts +31 -4
  69. package/dist/index.js +31 -4
  70. package/dist/model-params.d.ts +41 -22
  71. package/dist/model-params.js +28 -15
  72. package/dist/model.d.ts +210 -75
  73. package/dist/model.js +152 -19
  74. package/dist/net.d.ts +52 -0
  75. package/dist/net.js +34 -0
  76. package/dist/network-classes.d.ts +98 -0
  77. package/dist/network-classes.js +291 -0
  78. package/dist/permissions.d.ts +65 -22
  79. package/dist/permissions.js +139 -43
  80. package/dist/platform-only.d.ts +27 -0
  81. package/dist/platform-only.js +35 -0
  82. package/dist/plugin-manifest.d.ts +40 -9
  83. package/dist/plugin-manifest.js +171 -60
  84. package/dist/plugin-package.d.ts +82 -39
  85. package/dist/plugin-package.js +68 -41
  86. package/dist/push.d.ts +75 -0
  87. package/dist/push.js +87 -0
  88. package/dist/sandbox-linux-runtime-source.d.ts +1 -0
  89. package/dist/sandbox-linux-runtime-source.js +2343 -0
  90. package/dist/sandbox-native-runtime-source.d.ts +10 -0
  91. package/dist/sandbox-native-runtime-source.js +476 -0
  92. package/dist/sandbox-runtime-source.d.ts +47 -0
  93. package/dist/sandbox-runtime-source.js +73 -0
  94. package/dist/sandbox-write-denies.d.ts +139 -0
  95. package/dist/sandbox-write-denies.js +869 -0
  96. package/dist/secret.d.ts +8 -2
  97. package/dist/secret.js +11 -4
  98. package/dist/setup-check.d.ts +128 -0
  99. package/dist/setup-check.js +142 -0
  100. package/dist/setup-guide-parse.d.ts +121 -0
  101. package/dist/setup-guide-parse.js +356 -0
  102. package/dist/setup-guide-render.d.ts +45 -0
  103. package/dist/setup-guide-render.js +351 -0
  104. package/dist/setup-guide.d.ts +86 -72
  105. package/dist/setup-guide.js +340 -108
  106. package/dist/shell-capabilities.d.ts +211 -0
  107. package/dist/shell-capabilities.js +44 -0
  108. package/dist/shell-environment.d.ts +57 -0
  109. package/dist/shell-environment.js +21 -0
  110. package/dist/skill.d.ts +27 -17
  111. package/dist/skill.js +40 -26
  112. package/dist/storage.d.ts +52 -25
  113. package/dist/svg-viewbox.d.ts +10 -0
  114. package/dist/svg-viewbox.js +24 -0
  115. package/dist/theme-assets.d.ts +55 -0
  116. package/dist/theme-assets.js +489 -0
  117. package/dist/theme-readability.d.ts +37 -0
  118. package/dist/theme-readability.js +145 -0
  119. package/dist/theme-tokens.generated.d.ts +299 -0
  120. package/dist/theme-tokens.generated.js +184 -0
  121. package/dist/theme.d.ts +190 -0
  122. package/dist/theme.js +471 -0
  123. package/dist/tool.d.ts +104 -30
  124. package/dist/tool.js +29 -9
  125. package/dist/ui-parts.d.ts +23 -0
  126. package/dist/ui-parts.js +385 -0
  127. package/dist/ui-resolve.d.ts +35 -0
  128. package/dist/ui-resolve.js +42 -0
  129. package/dist/ui-slots.d.ts +65 -0
  130. package/dist/ui-slots.js +261 -0
  131. package/dist/ui.d.ts +221 -77
  132. package/dist/ui.js +104 -27
  133. package/dist/url.d.ts +4 -1
  134. package/dist/url.js +4 -1
  135. package/dist/web.d.ts +26 -20
  136. package/package.json +13 -1
  137. package/schemas/bootstrap-extra.v1.schema.json +186 -0
  138. package/schemas/bootstrap.v1.schema.json +20 -0
  139. package/schemas/connector-template.v1.schema.json +62 -4
  140. package/schemas/plugin.v1.schema.json +93 -143
  141. package/schemas/theme.v1.schema.json +302 -0
  142. package/agent-docs/extension-points/sandbox.md +0 -15
  143. package/dist/org-access.d.ts +0 -27
  144. package/dist/org-access.js +0 -35
  145. package/dist/sandbox.d.ts +0 -254
  146. package/dist/sandbox.js +0 -153
@@ -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
+ }
package/dist/hooks.d.ts CHANGED
@@ -1,10 +1,12 @@
1
- import type { ContentBlock, ModelRequest, ModelUsage } from "./model.js";
1
+ import type { ContentBlock, ImageSize, ModelRequest, ModelUsage } from "./model.js";
2
2
  /**
3
3
  * Hook mount points a plugin can register on through `ctx.hooks.on` (from M7). The other names in
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. */
@@ -36,9 +38,13 @@ export interface HookScope {
36
38
  * that summarizes earlier history before a step when the context grows too large, `title` is the call
37
39
  * that writes a conversation's title after its first completed run (no run: `runId` is "", `step` 0,
38
40
  * `attempt` 1), `web_fetch` is the call that extracts an answer from a fetched web page for the
39
- * `WebFetch` tool.
41
+ * `WebFetch` tool, `review` is the command-review classifier's call (`review` purpose, no run
42
+ * step; absent = no classifier), `suggestion` is the prompt suggestion side request after a
43
+ * completed web run (`runId` the run, `step` 0, `attempt` 1; a denial skips it and is recorded only
44
+ * in the audit log), `vision` is the call that reads an image for a model without vision, made by
45
+ * the `Read` tool (also for a pasted image, read by its `file_id`; the `vision` purpose's model).
40
46
  */
41
- export type ModelCallPurpose = "step" | "compaction" | "title" | "web_fetch";
47
+ export type ModelCallPurpose = "step" | "compaction" | "title" | "web_fetch" | "review" | "image" | "vision" | "suggestion";
42
48
  /**
43
49
  * What a reported or requested model call was for: the {@link ModelCallPurpose} values, or
44
50
  * `embedding` for an embedding call an extension made through `ctx.models` (`usage.report`, and
@@ -46,21 +52,23 @@ export type ModelCallPurpose = "step" | "compaction" | "title" | "web_fetch";
46
52
  */
47
53
  export type UsagePurpose = ModelCallPurpose | "embedding";
48
54
  /**
49
- * An image or document of a `model.request` payload. Hook payloads never carry media bytes or
50
- * attachment ids: each image or document block is replaced by this placeholder.
55
+ * An image, document or file of a `model.request` payload. Hook payloads never carry media bytes or
56
+ * attachment ids: each image / document / file block is replaced by this placeholder.
51
57
  * `size` is the size of the bytes sent to the provider, in bytes (0 when unknown).
52
58
  */
53
59
  export interface HookMediaPlaceholder {
54
60
  type: "media_omitted";
55
- kind: "image" | "document";
61
+ kind: "image" | "document" | "file";
56
62
  mediaType: string;
57
63
  size: number;
58
64
  }
59
- /** A content block of a `model.request` payload: image and document blocks become placeholders. */
65
+ /** A content block of a `model.request` payload: image, document and file blocks become placeholders. */
60
66
  export type HookContentBlock = Exclude<ContentBlock, {
61
67
  type: "image";
62
68
  } | {
63
69
  type: "document";
70
+ } | {
71
+ type: "file";
64
72
  }> | HookMediaPlaceholder;
65
73
  /** A message of a `model.request` payload (see {@link HookContentBlock}). */
66
74
  export type HookModelMessage = {
@@ -81,13 +89,15 @@ export type HookModelRequest = Omit<ModelRequest, "messages"> & {
81
89
  * `model.request` of a chat model call (see {@link ModelRequestHookPayload}): once per attempt of a
82
90
  * step (`purpose: "step"`), once for each compaction call (`purpose: "compaction"`, `attempt` 1),
83
91
  * once for each conversation title call (`purpose: "title"`, `runId` "", `step` 0, `attempt` 1; a
84
- * denial skips the title and is recorded only in the audit log) and once for each `WebFetch`
85
- * extraction call (`purpose: "web_fetch"`).
92
+ * denial skips the title and is recorded only in the audit log), once for each `WebFetch`
93
+ * extraction call (`purpose: "web_fetch"`) and once for each prompt suggestion call
94
+ * (`purpose: "suggestion"`, `step` 0, `attempt` 1; a denial skips the suggestion and is recorded
95
+ * only in the audit log) and once for each vision call (`purpose: "vision"`).
86
96
  * `request` is the request as sent, except that images and documents are placeholders
87
97
  * ({@link HookMediaPlaceholder}): no media bytes, no attachment ids.
88
98
  */
89
99
  export interface ModelCallRequestHookPayload extends HookScope {
90
- purpose: ModelCallPurpose;
100
+ purpose: Exclude<ModelCallPurpose, "image">;
91
101
  step: number;
92
102
  attempt: number;
93
103
  provider: string;
@@ -125,22 +135,82 @@ export interface EmbeddingRequestHookPayload {
125
135
  runId?: undefined;
126
136
  parent?: undefined;
127
137
  }
138
+ /**
139
+ * `model.request` of an image generation call (`purpose: "image"`): once per `GenerateImage` tool
140
+ * call (conversation fields set) or `ctx.models.generateImage` call (`extension` and `imagePurpose`
141
+ * set, conversation fields absent). Reference images are placeholders: no bytes. A policy denial
142
+ * sends nothing and records no usage.
143
+ */
144
+ export interface ImageRequestHookPayload {
145
+ purpose: "image";
146
+ orgId: string;
147
+ provider: string;
148
+ model: string;
149
+ prompt: string;
150
+ size: ImageSize;
151
+ n: number;
152
+ referenceImages: HookMediaPlaceholder[];
153
+ /** Conversation call: */
154
+ accountId?: string;
155
+ agentId?: string;
156
+ agentVersion?: number;
157
+ conversationId?: string;
158
+ runId?: string;
159
+ parent?: HookParentScope;
160
+ step?: number;
161
+ callId?: string;
162
+ /** Extension call: */
163
+ extension?: string;
164
+ imagePurpose?: string;
165
+ }
166
+ /**
167
+ * `model.response` of an image generation call: after it finished or failed. Same identity fields
168
+ * as {@link ImageRequestHookPayload}; images carry only their media type and byte size.
169
+ */
170
+ export interface ImageResponseHookPayload {
171
+ purpose: "image";
172
+ orgId: string;
173
+ provider: string;
174
+ model: string;
175
+ accountId?: string;
176
+ agentId?: string;
177
+ agentVersion?: number;
178
+ conversationId?: string;
179
+ runId?: string;
180
+ parent?: HookParentScope;
181
+ step?: number;
182
+ callId?: string;
183
+ extension?: string;
184
+ imagePurpose?: string;
185
+ outcome: "ok" | "failed";
186
+ images: {
187
+ mediaType: string;
188
+ size: number;
189
+ }[];
190
+ revisedPrompt?: string;
191
+ usage: ModelUsage | null;
192
+ latencyMs: number;
193
+ errorCode?: string;
194
+ }
128
195
  /**
129
196
  * `model.request`: before a model call is sent. A policy hook may deny it. Either a chat model call
130
197
  * ({@link ModelCallRequestHookPayload}: steps, compaction, titles, `WebFetch`) or an extension's
131
- * embedding call ({@link EmbeddingRequestHookPayload}, `purpose: "embedding"`); tell them apart by
198
+ * embedding call ({@link EmbeddingRequestHookPayload}, `purpose: "embedding"`) or an image generation
199
+ * call ({@link ImageRequestHookPayload}, `purpose: "image"`); tell them apart by
132
200
  * `purpose`. Handlers must accept the absent conversation fields of an embedding call (a policy
133
201
  * hook that throws on one denies the call). Payloads carry no media bytes.
134
202
  */
135
- export type ModelRequestHookPayload = ModelCallRequestHookPayload | EmbeddingRequestHookPayload;
203
+ export type ModelRequestHookPayload = ModelCallRequestHookPayload | EmbeddingRequestHookPayload | ImageRequestHookPayload;
136
204
  /**
137
205
  * `model.response`: after a sent model call finished or failed, with its usage when known (step
138
- * attempts, compaction and title calls, see `purpose`). Not fired for a call the user aborted (the run was
139
- * stopped while the call was in flight), nor for a call that was never sent (denied, or failed
140
- * before sending), so a `model.request` can have no matching `model.response`.
206
+ * attempts, compaction, title and suggestion calls, see `purpose`). Not fired for a call the user
207
+ * aborted (the run was stopped while the call was in flight), nor for a call that was never sent
208
+ * (denied, or failed before sending), so a `model.request` can have no matching `model.response`.
209
+ * The mount's payload is this or, for an image generation call, an
210
+ * {@link ImageResponseHookPayload}.
141
211
  */
142
212
  export interface ModelResponseHookPayload extends HookScope {
143
- purpose: ModelCallPurpose;
213
+ purpose: Exclude<ModelCallPurpose, "image">;
144
214
  step: number;
145
215
  attempt: number;
146
216
  provider: string;
@@ -201,13 +271,44 @@ export interface UsageReportPayload {
201
271
  usage: ModelUsage;
202
272
  occurredAt: string;
203
273
  }
274
+ /**
275
+ * `org.member_removed`: an account left the org (offboarding: removed by an admin, left on its own,
276
+ * or offboarded by a directory sync). Lifecycle hooks are delivered durably, after the removal
277
+ * committed, through a queue, at least once per plugin that declares the mount in
278
+ * `permissions.hooks`, whether or not the org has the plugin enabled and whether or not the org's
279
+ * effective config of the plugin is valid (`call.config` is the platform deployment config): they
280
+ * exist so a plugin can delete the data it holds. Handlers must be idempotent. The payload carries
281
+ * ids only.
282
+ */
283
+ export interface OrgMemberRemovedPayload {
284
+ orgId: string;
285
+ accountId: string;
286
+ }
287
+ /**
288
+ * `agent.deleted`: an agent was deleted. Delivered like {@link OrgMemberRemovedPayload} (durably, at
289
+ * least once, regardless of org enablement or config validity; ids only).
290
+ */
291
+ export interface AgentDeletedPayload {
292
+ orgId: string;
293
+ agentId: string;
294
+ }
295
+ /**
296
+ * `org.deleted`: an org was deleted. Delivered like {@link OrgMemberRemovedPayload} (durably, at
297
+ * least once, regardless of org enablement or config validity; ids only).
298
+ */
299
+ export interface OrgDeletedPayload {
300
+ orgId: string;
301
+ }
204
302
  /** Payload type of each mount point. */
205
303
  export interface HookPayloads {
206
304
  "model.request": ModelRequestHookPayload;
207
- "model.response": ModelResponseHookPayload;
305
+ "model.response": ModelResponseHookPayload | ImageResponseHookPayload;
208
306
  "tool.preExecute": ToolPreHookPayload;
209
307
  "tool.postExecute": ToolPostHookPayload;
210
308
  "usage.report": UsageReportPayload;
309
+ "org.member_removed": OrgMemberRemovedPayload;
310
+ "agent.deleted": AgentDeletedPayload;
311
+ "org.deleted": OrgDeletedPayload;
211
312
  }
212
313
  /**
213
314
  * What a hook returns: nothing, or `{ deny: reason }`. A deny only takes effect for a `policy` hook
@@ -223,12 +324,16 @@ export type HookVerdict = void | {
223
324
  * extension's effective deployment config for the payload's org (the platform's config with the
224
325
  * org's copy applied to the overridable fields, or `ctx.config` while the org follows it); the
225
326
  * kernel always passes it, and never calls a hook for an org where that config is not valid
226
- * (observe hooks are skipped, policy hooks deny).
327
+ * (observe hooks are skipped, policy hooks deny). Lifecycle hooks ({@link LIFECYCLE_HOOKS}) are the
328
+ * exception: they get the platform deployment config and are always called.
227
329
  */
228
330
  export type HookHandler<K extends AvailableHook> = (payload: HookPayloads[K], signal: AbortSignal, call?: HookCall) => Promise<HookVerdict> | HookVerdict;
229
331
  /** The per-call context of a hook handler (see {@link HookHandler}). */
230
332
  export interface HookCall {
231
- /** The extension's effective deployment config for the payload's org. */
333
+ /**
334
+ * The extension's effective deployment config for the payload's org (lifecycle hooks: the
335
+ * platform deployment config).
336
+ */
232
337
  config: unknown;
233
338
  }
234
339
  /**
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"];
@@ -0,0 +1,62 @@
1
+ import type { UiRole } from "./ui.js";
2
+ /**
3
+ * Who may call an extension route (declared per route in `permissions.http`, enforced by the
4
+ * kernel before the handler runs and before the body is read):
5
+ *
6
+ * - `public`: anyone; unsafe methods are rate-limited per client IP. Mounted at
7
+ * `/plugins/<name><path>`.
8
+ * - `embed`: the holder of an embed token (see `ctx.ui`); path under `/ui/`. Mounted at
9
+ * `/plugins/<name><path>`.
10
+ * - `member` / `admin`: an org member (admin: org admin and up) with a personal access token.
11
+ * Mounted at `/plugins/<name>/orgs/:orgId<path>`.
12
+ */
13
+ export declare const HTTP_ACCESS: readonly ["public", "embed", "member", "admin"];
14
+ export type HttpAccess = (typeof HTTP_ACCESS)[number];
15
+ /** One entry of `permissions.http`. */
16
+ export interface HttpPermission {
17
+ method: "GET" | "POST" | "PUT" | "DELETE";
18
+ path: string;
19
+ access: HttpAccess;
20
+ }
21
+ /**
22
+ * The caller the kernel resolved for a route, passed to the handler as its second argument.
23
+ * Trust only this (`caller.orgId`, never an org id in the body or query).
24
+ */
25
+ export type RouteCaller = {
26
+ access: "public";
27
+ } | {
28
+ access: "embed";
29
+ scope: "org";
30
+ orgId: string;
31
+ accountId: string;
32
+ role: UiRole;
33
+ contribution: string;
34
+ conversationId?: string;
35
+ /** The token's expiry (Unix seconds): a long-lived response (SSE) ends by then. */
36
+ exp: number;
37
+ config: unknown;
38
+ } | {
39
+ access: "embed";
40
+ scope: "platform";
41
+ accountId: string;
42
+ role: "superAdmin";
43
+ contribution: string;
44
+ /** The token's expiry (Unix seconds): a long-lived response (SSE) ends by then. */
45
+ exp: number;
46
+ } | {
47
+ /** A share page's `file.preview` embed: no account, no role. */
48
+ access: "embed";
49
+ scope: "share";
50
+ orgId: string;
51
+ shareId: string;
52
+ contribution: string;
53
+ /** The token's expiry (Unix seconds): a long-lived response (SSE) ends by then. */
54
+ exp: number;
55
+ config: unknown;
56
+ } | {
57
+ access: "member" | "admin";
58
+ orgId: string;
59
+ accountId: string;
60
+ role: UiRole;
61
+ config: unknown;
62
+ };
@@ -0,0 +1,12 @@
1
+ /**
2
+ * Who may call an extension route (declared per route in `permissions.http`, enforced by the
3
+ * kernel before the handler runs and before the body is read):
4
+ *
5
+ * - `public`: anyone; unsafe methods are rate-limited per client IP. Mounted at
6
+ * `/plugins/<name><path>`.
7
+ * - `embed`: the holder of an embed token (see `ctx.ui`); path under `/ui/`. Mounted at
8
+ * `/plugins/<name><path>`.
9
+ * - `member` / `admin`: an org member (admin: org admin and up) with a personal access token.
10
+ * Mounted at `/plugins/<name>/orgs/:orgId<path>`.
11
+ */
12
+ export const HTTP_ACCESS = ["public", "embed", "member", "admin"];
@@ -1,8 +1,12 @@
1
- /** 外部身份;登录、渠道入站、通讯录三处用同一个 (source, externalId) 键。 */
1
+ /**
2
+ * An external identity; login, channel inbound and directory all use the same (source, externalId)
3
+ * key.
4
+ */
2
5
  export interface ExternalIdentity {
3
6
  /**
4
- * `"<插件名>:<租户 id>"`,必须与 `tenantId` 一致。第三方登录时内核核对
5
- * `source === \`${插件名}:${tenantId}\``,不一致按身份源出错拒绝。
7
+ * `"<plugin name>:<tenant id>"`, must equal `tenantId`. On third-party login the kernel checks
8
+ * `source === \`${plugin name}:${tenantId}\``, and rejects a mismatch as an identity source
9
+ * error.
6
10
  */
7
11
  source: string;
8
12
  externalId: string;
@@ -13,9 +17,12 @@ export interface ExternalIdentity {
13
17
  avatarUrl?: string;
14
18
  }
15
19
  /**
16
- * 第三方登录(`identity-source@1`)。state、nonce 与 PKCE 都由内核生成并保存在服务端:
17
- * 插件把 `codeChallenge` / `codeChallengeMethod` 放进授权地址(`code_challenge` / `code_challenge_method`),
18
- * 回调换 token 时带上 `codeVerifier`(`code_verifier`)。平台不支持 PKCE 时忽略这几个字段即可。
20
+ * Third-party login (`identity-source@1`). State, nonce and PKCE are all generated by the kernel
21
+ * and kept server-side:
22
+ * the plugin puts `codeChallenge` / `codeChallengeMethod` into the authorization URL
23
+ * (`code_challenge` / `code_challenge_method`),
24
+ * and passes `codeVerifier` (`code_verifier`) when exchanging the token at the callback. If the
25
+ * platform does not support PKCE, just ignore these fields.
19
26
  */
20
27
  export interface IdentitySource {
21
28
  label: {
@@ -27,9 +34,12 @@ export interface IdentitySource {
27
34
  redirectUri: string;
28
35
  state: string;
29
36
  nonce: string;
30
- /** PKCE challenge(base64url(SHA-256(codeVerifier)));内核总会提供,旧内核不提供。 */
37
+ /**
38
+ * PKCE challenge (base64url(SHA-256(codeVerifier))); the kernel always provides it, old kernels
39
+ * do not.
40
+ */
31
41
  codeChallenge?: string;
32
- /** PKCE challenge 的算法;内核只用 `"S256"`。 */
42
+ /** The PKCE challenge algorithm; the kernel uses only `"S256"`. */
33
43
  codeChallengeMethod?: "S256";
34
44
  }): string;
35
45
  callback(args: {
@@ -38,7 +48,26 @@ export interface IdentitySource {
38
48
  query: Record<string, string>;
39
49
  nonce: string;
40
50
  signal: AbortSignal;
41
- /** 与本次发起的 `codeChallenge` 对应的 PKCE verifier;内核总会提供,旧内核不提供。 */
51
+ /**
52
+ * The PKCE verifier matching this flow's `codeChallenge`; the kernel always provides it, old
53
+ * kernels do not.
54
+ */
42
55
  codeVerifier?: string;
43
56
  }): Promise<ExternalIdentity>;
44
57
  }
58
+ /**
59
+ * Thrown by an identity source's `callback` when it refuses the account on purpose (a hosted domain
60
+ * or tenant the platform does not allow, a consumer account where only organization accounts are
61
+ * allowed): the login page then says the account is not allowed (`sso.account_not_allowed`) instead
62
+ * of a provider error. The message is logged by the kernel and never shown to the person. Throw it
63
+ * only after the response itself was verified (ID token, nonce, PKCE); every other failure stays a
64
+ * plain error.
65
+ */
66
+ export declare class IdentitySourceRefused extends Error {
67
+ constructor(message: string);
68
+ }
69
+ /**
70
+ * Whether `err` is an {@link IdentitySourceRefused}: any `Error` whose `name` is
71
+ * `"IdentitySourceRefused"`, so a plugin that bundles another copy of the SDK still matches.
72
+ */
73
+ export declare function isIdentitySourceRefused(err: unknown): boolean;
package/dist/identity.js CHANGED
@@ -1 +1,21 @@
1
- export {};
1
+ /**
2
+ * Thrown by an identity source's `callback` when it refuses the account on purpose (a hosted domain
3
+ * or tenant the platform does not allow, a consumer account where only organization accounts are
4
+ * allowed): the login page then says the account is not allowed (`sso.account_not_allowed`) instead
5
+ * of a provider error. The message is logged by the kernel and never shown to the person. Throw it
6
+ * only after the response itself was verified (ID token, nonce, PKCE); every other failure stays a
7
+ * plain error.
8
+ */
9
+ export class IdentitySourceRefused extends Error {
10
+ constructor(message) {
11
+ super(message);
12
+ this.name = "IdentitySourceRefused";
13
+ }
14
+ }
15
+ /**
16
+ * Whether `err` is an {@link IdentitySourceRefused}: any `Error` whose `name` is
17
+ * `"IdentitySourceRefused"`, so a plugin that bundles another copy of the SDK still matches.
18
+ */
19
+ export function isIdentitySourceRefused(err) {
20
+ return err instanceof Error && err.name === "IdentitySourceRefused";
21
+ }
package/dist/index.d.ts CHANGED
@@ -1,33 +1,60 @@
1
- export declare const SDK_VERSION = "0.1.0-rc.7";
1
+ export declare const SDK_VERSION = "0.1.0-rc.70";
2
2
  export * from "./agent-template.js";
3
+ export * from "./avatar-presets.js";
3
4
  export * from "./bootstrap.js";
4
5
  export * from "./cards.js";
5
6
  export * from "./channel.js";
7
+ export * from "./client-css.js";
8
+ export * from "./client-section.js";
6
9
  export * from "./config-ui.js";
10
+ export * from "./config-url-fetch.js";
7
11
  export * from "./connector.js";
8
12
  export * from "./connector-auth.js";
13
+ export * from "./context.js";
9
14
  export * from "./ctx.js";
10
15
  export * from "./define-extension.js";
11
- export * from "./device-protocol.js";
16
+ export { DEVICE_DEFAULT_STATE_PATH, DEVICE_DENIED_SECRET_PATHS } from "./device-denied-paths.js";
17
+ export * from "./device-operation.js";
18
+ export * from "./device-provider.js";
19
+ export * from "./device-service.js";
20
+ export * from "./dial-in.js";
12
21
  export * from "./directory.js";
13
22
  export * from "./extension-point.js";
14
23
  export * from "./file-preview.js";
24
+ export * from "./git-hosts.js";
15
25
  export * from "./hooks.js";
26
+ export * from "./http-access.js";
16
27
  export * from "./identity.js";
17
28
  export * from "./marketplace.js";
18
29
  export * from "./model.js";
19
30
  export * from "./model-params.js";
20
- export * from "./org-access.js";
31
+ export * from "./net.js";
32
+ export * from "./network-classes.js";
21
33
  export * from "./permissions.js";
34
+ export * from "./platform-only.js";
22
35
  export * from "./plugin-manifest.js";
23
36
  export * from "./plugin-package.js";
24
- export * from "./sandbox.js";
37
+ export * from "./push.js";
38
+ export { SANDBOX_RUNTIME_SOURCE, type SandboxRuntimeFeature, type SandboxRuntimeFile, } from "./sandbox-runtime-source.js";
39
+ export { isSandboxHomeWriteDenied, isSandboxMoveDenied, isSandboxWriteDenied, SANDBOX_GIT_ALLOWED_DIRECTORIES, SANDBOX_GIT_ALLOWED_FILES, SANDBOX_GIT_DENIED_INTERNALS, SANDBOX_HOME_WRITE_DENIES, SANDBOX_MANDATORY_WRITE_DENIES, SANDBOX_PROTECTED_PATH_NAMES, SANDBOX_RESERVED_NAME_PREFIX, SANDBOX_RUNTIME_DIRECTORIES, SANDBOX_SYSTEM_WRITE_DENIES, sandboxRuntimeDirectoryOf, } from "./sandbox-write-denies.js";
25
40
  export * from "./secret.js";
41
+ export * from "./setup-check.js";
26
42
  export * from "./setup-guide.js";
43
+ export { type ParsedSetupGuide, parseSetupGuide, type SetupGuideCheckLine, type SetupGuideCodeBlock, type SetupGuideParseIssue, type SetupGuideSection, } from "./setup-guide-parse.js";
44
+ export * from "./setup-guide-render.js";
45
+ export * from "./shell-capabilities.js";
46
+ export * from "./shell-environment.js";
27
47
  export * from "./skill.js";
28
48
  export * from "./skill-invocation.js";
29
49
  export * from "./storage.js";
50
+ export * from "./theme.js";
51
+ export * from "./theme-assets.js";
52
+ export * from "./theme-readability.js";
53
+ export * from "./theme-tokens.generated.js";
30
54
  export * from "./tool.js";
31
55
  export * from "./tool-key.js";
32
56
  export * from "./ui.js";
57
+ export * from "./ui-parts.js";
58
+ export * from "./ui-resolve.js";
59
+ export * from "./ui-slots.js";
33
60
  export * from "./web.js";