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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (149) hide show
  1. package/README.md +1 -1
  2. package/agent-docs/agent-templates.md +14 -2
  3. package/agent-docs/concepts.md +14 -5
  4. package/agent-docs/connector-templates.md +11 -3
  5. package/agent-docs/extension-points/channel.md +1 -1
  6. package/agent-docs/extension-points/context.md +15 -0
  7. package/agent-docs/extension-points/device-provider.md +15 -0
  8. package/agent-docs/extension-points/file-preview.md +3 -1
  9. package/agent-docs/extension-points/identity-source.md +2 -0
  10. package/agent-docs/extension-points/model-provider.md +3 -1
  11. package/agent-docs/extension-points/object-store.md +2 -0
  12. package/agent-docs/extension-points/push-provider.md +17 -0
  13. package/agent-docs/extensions.md +77 -4
  14. package/agent-docs/plugin-format.md +45 -10
  15. package/agent-docs/setup.md +54 -0
  16. package/dist/agent-template.d.ts +15 -6
  17. package/dist/agent-template.js +32 -13
  18. package/dist/avatar-presets.d.ts +8 -0
  19. package/dist/avatar-presets.js +17 -0
  20. package/dist/bootstrap.d.ts +109 -1
  21. package/dist/bootstrap.js +185 -2
  22. package/dist/cards.d.ts +60 -13
  23. package/dist/cards.js +88 -18
  24. package/dist/channel.d.ts +128 -47
  25. package/dist/channel.js +10 -5
  26. package/dist/client-css.d.ts +36 -0
  27. package/dist/client-css.js +326 -0
  28. package/dist/client-section.d.ts +35 -0
  29. package/dist/client-section.js +133 -0
  30. package/dist/config-ui.d.ts +28 -6
  31. package/dist/config-ui.js +88 -25
  32. package/dist/config-url-fetch.d.ts +19 -0
  33. package/dist/config-url-fetch.js +43 -0
  34. package/dist/connector-auth.d.ts +13 -2
  35. package/dist/connector-auth.js +82 -8
  36. package/dist/connector.d.ts +74 -32
  37. package/dist/context.d.ts +40 -0
  38. package/dist/context.js +2 -0
  39. package/dist/ctx.d.ts +224 -30
  40. package/dist/ctx.js +9 -1
  41. package/dist/define-extension.d.ts +23 -13
  42. package/dist/define-extension.js +19 -5
  43. package/dist/device-denied-paths.d.ts +20 -0
  44. package/dist/device-denied-paths.js +118 -0
  45. package/dist/device-operation.d.ts +339 -0
  46. package/dist/device-operation.js +312 -0
  47. package/dist/device-protocol.d.ts +285 -50
  48. package/dist/device-protocol.js +755 -90
  49. package/dist/device-provider.d.ts +780 -0
  50. package/dist/device-provider.js +409 -0
  51. package/dist/device-service.d.ts +126 -0
  52. package/dist/device-service.js +211 -0
  53. package/dist/dial-in.d.ts +286 -0
  54. package/dist/dial-in.js +213 -0
  55. package/dist/directory.d.ts +15 -12
  56. package/dist/extension-point.d.ts +2 -0
  57. package/dist/extension-point.js +7 -3
  58. package/dist/field-meta.d.ts +19 -0
  59. package/dist/field-meta.js +54 -0
  60. package/dist/file-preview.d.ts +43 -10
  61. package/dist/git-hosts.d.ts +53 -0
  62. package/dist/git-hosts.js +98 -0
  63. package/dist/hooks.d.ts +125 -20
  64. package/dist/hooks.js +5 -0
  65. package/dist/http-access.d.ts +71 -0
  66. package/dist/http-access.js +12 -0
  67. package/dist/identity.d.ts +70 -9
  68. package/dist/identity.js +46 -1
  69. package/dist/index.d.ts +28 -4
  70. package/dist/index.js +28 -4
  71. package/dist/model-params.d.ts +41 -22
  72. package/dist/model-params.js +28 -15
  73. package/dist/model.d.ts +210 -75
  74. package/dist/model.js +152 -19
  75. package/dist/native-failure.d.ts +13 -0
  76. package/dist/native-failure.js +31 -0
  77. package/dist/net.d.ts +52 -0
  78. package/dist/net.js +34 -0
  79. package/dist/network-classes.d.ts +98 -0
  80. package/dist/network-classes.js +291 -0
  81. package/dist/permissions.d.ts +65 -22
  82. package/dist/permissions.js +139 -43
  83. package/dist/platform-only.d.ts +27 -0
  84. package/dist/platform-only.js +35 -0
  85. package/dist/plugin-manifest.d.ts +30 -6
  86. package/dist/plugin-manifest.js +147 -55
  87. package/dist/plugin-package.d.ts +82 -39
  88. package/dist/plugin-package.js +68 -41
  89. package/dist/push.d.ts +75 -0
  90. package/dist/push.js +87 -0
  91. package/dist/sandbox-linux-runtime-source.d.ts +1 -0
  92. package/dist/sandbox-linux-runtime-source.js +2343 -0
  93. package/dist/sandbox-native-runtime-source.d.ts +10 -0
  94. package/dist/sandbox-native-runtime-source.js +480 -0
  95. package/dist/sandbox-runtime-source.d.ts +47 -0
  96. package/dist/sandbox-runtime-source.js +73 -0
  97. package/dist/sandbox-write-denies.d.ts +139 -0
  98. package/dist/sandbox-write-denies.js +869 -0
  99. package/dist/secret.d.ts +8 -2
  100. package/dist/secret.js +11 -4
  101. package/dist/setup-check.d.ts +128 -0
  102. package/dist/setup-check.js +142 -0
  103. package/dist/setup-guide-parse.d.ts +121 -0
  104. package/dist/setup-guide-parse.js +356 -0
  105. package/dist/setup-guide-render.d.ts +45 -0
  106. package/dist/setup-guide-render.js +351 -0
  107. package/dist/setup-guide.d.ts +86 -72
  108. package/dist/setup-guide.js +340 -108
  109. package/dist/shell-capabilities.d.ts +211 -0
  110. package/dist/shell-capabilities.js +44 -0
  111. package/dist/shell-environment.d.ts +57 -0
  112. package/dist/shell-environment.js +21 -0
  113. package/dist/skill-invocation.d.ts +5 -0
  114. package/dist/skill-invocation.js +4 -3
  115. package/dist/skill.d.ts +27 -17
  116. package/dist/skill.js +40 -26
  117. package/dist/storage.d.ts +52 -25
  118. package/dist/svg-viewbox.d.ts +10 -0
  119. package/dist/svg-viewbox.js +24 -0
  120. package/dist/theme-assets.d.ts +25 -9
  121. package/dist/theme-assets.js +87 -47
  122. package/dist/theme-tokens.generated.d.ts +26 -2
  123. package/dist/theme-tokens.generated.js +17 -0
  124. package/dist/theme.d.ts +48 -10
  125. package/dist/theme.js +100 -21
  126. package/dist/tool.d.ts +156 -30
  127. package/dist/tool.js +91 -9
  128. package/dist/ui-parts.d.ts +23 -0
  129. package/dist/ui-parts.js +385 -0
  130. package/dist/ui-resolve.d.ts +35 -0
  131. package/dist/ui-resolve.js +42 -0
  132. package/dist/ui-slots.d.ts +65 -0
  133. package/dist/ui-slots.js +261 -0
  134. package/dist/ui.d.ts +245 -77
  135. package/dist/ui.js +104 -27
  136. package/dist/url.d.ts +4 -1
  137. package/dist/url.js +4 -1
  138. package/dist/web.d.ts +26 -20
  139. package/package.json +12 -1
  140. package/schemas/bootstrap-extra.v1.schema.json +186 -0
  141. package/schemas/bootstrap.v1.schema.json +20 -0
  142. package/schemas/connector-template.v1.schema.json +62 -4
  143. package/schemas/plugin.v1.schema.json +74 -143
  144. package/schemas/theme.v1.schema.json +77 -0
  145. package/agent-docs/extension-points/sandbox.md +0 -15
  146. package/dist/org-access.d.ts +0 -27
  147. package/dist/org-access.js +0 -35
  148. package/dist/sandbox.d.ts +0 -254
  149. package/dist/sandbox.js +0 -153
package/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,71 @@
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
+ /**
36
+ * A skill file previewer's token (`OrgEmbedClaims.skillFile`): the skill, version and path;
37
+ * no conversation.
38
+ */
39
+ skillFile?: {
40
+ skillId: string;
41
+ version: number;
42
+ path: string;
43
+ };
44
+ /** The token's expiry (Unix seconds): a long-lived response (SSE) ends by then. */
45
+ exp: number;
46
+ config: unknown;
47
+ } | {
48
+ access: "embed";
49
+ scope: "platform";
50
+ accountId: string;
51
+ role: "superAdmin";
52
+ contribution: string;
53
+ /** The token's expiry (Unix seconds): a long-lived response (SSE) ends by then. */
54
+ exp: number;
55
+ } | {
56
+ /** A share page's `file.preview` embed: no account, no role. */
57
+ access: "embed";
58
+ scope: "share";
59
+ orgId: string;
60
+ shareId: string;
61
+ contribution: string;
62
+ /** The token's expiry (Unix seconds): a long-lived response (SSE) ends by then. */
63
+ exp: number;
64
+ config: unknown;
65
+ } | {
66
+ access: "member" | "admin";
67
+ orgId: string;
68
+ accountId: string;
69
+ role: UiRole;
70
+ config: unknown;
71
+ };
@@ -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;
@@ -12,24 +16,62 @@ export interface ExternalIdentity {
12
16
  displayName: string;
13
17
  avatarUrl?: string;
14
18
  }
19
+ /** How an identity source describes its tenants to the admin console. */
20
+ export interface IdentitySourceTenant {
21
+ /** The field label in Chinese and English, e.g. the Slack workspace ID. */
22
+ label: {
23
+ zh: string;
24
+ en: string;
25
+ };
26
+ /** Where to find the tenant id. */
27
+ help?: {
28
+ zh: string;
29
+ en: string;
30
+ };
31
+ /** A regular expression (JavaScript syntax) a tenant id must match, e.g. `^T[A-Z0-9]+$`. */
32
+ pattern?: string;
33
+ /** An example tenant id shown as the placeholder. */
34
+ placeholder?: string;
35
+ /** Tenant ids that may never be trusted for email merge (Google: `consumer`). */
36
+ neverTrusted?: string[];
37
+ }
15
38
  /**
16
- * 第三方登录(`identity-source@1`)。state、nonce 与 PKCE 都由内核生成并保存在服务端:
17
- * 插件把 `codeChallenge` / `codeChallengeMethod` 放进授权地址(`code_challenge` / `code_challenge_method`),
18
- * 回调换 token 时带上 `codeVerifier`(`code_verifier`)。平台不支持 PKCE 时忽略这几个字段即可。
39
+ * Checks a tenant id against a source's tenant declaration: `"empty"` for a blank id, `"pattern"`
40
+ * when it does not match the declared pattern (an invalid pattern counts as none),
41
+ * `"never_trusted"` when the source lists it in `neverTrusted`, else `"ok"`. The id is trimmed
42
+ * first. The kernel uses it before storing trusted tenants.
43
+ */
44
+ export declare function validateTenantId(decl: IdentitySourceTenant | undefined, id: string): "ok" | "pattern" | "never_trusted" | "empty";
45
+ /**
46
+ * Third-party login (`identity-source@1`). State, nonce and PKCE are all generated by the kernel
47
+ * and kept server-side:
48
+ * the plugin puts `codeChallenge` / `codeChallengeMethod` into the authorization URL
49
+ * (`code_challenge` / `code_challenge_method`),
50
+ * and passes `codeVerifier` (`code_verifier`) when exchanging the token at the callback. If the
51
+ * platform does not support PKCE, just ignore these fields.
19
52
  */
20
53
  export interface IdentitySource {
21
54
  label: {
22
55
  zh: string;
23
56
  en: string;
24
57
  };
58
+ /**
59
+ * What a tenant is on this platform, so the admin console can label and check the trusted
60
+ * tenants of this source (a tenant id is the `<tenant>` of the source key `<plugin>:<tenant>`).
61
+ * Without it the console shows a plain tenant id field.
62
+ */
63
+ tenant?: IdentitySourceTenant;
25
64
  authorizeUrl(args: {
26
65
  config: unknown;
27
66
  redirectUri: string;
28
67
  state: string;
29
68
  nonce: string;
30
- /** PKCE challenge(base64url(SHA-256(codeVerifier)));内核总会提供,旧内核不提供。 */
69
+ /**
70
+ * PKCE challenge (base64url(SHA-256(codeVerifier))); the kernel always provides it, old kernels
71
+ * do not.
72
+ */
31
73
  codeChallenge?: string;
32
- /** PKCE challenge 的算法;内核只用 `"S256"`。 */
74
+ /** The PKCE challenge algorithm; the kernel uses only `"S256"`. */
33
75
  codeChallengeMethod?: "S256";
34
76
  }): string;
35
77
  callback(args: {
@@ -38,7 +80,26 @@ export interface IdentitySource {
38
80
  query: Record<string, string>;
39
81
  nonce: string;
40
82
  signal: AbortSignal;
41
- /** 与本次发起的 `codeChallenge` 对应的 PKCE verifier;内核总会提供,旧内核不提供。 */
83
+ /**
84
+ * The PKCE verifier matching this flow's `codeChallenge`; the kernel always provides it, old
85
+ * kernels do not.
86
+ */
42
87
  codeVerifier?: string;
43
88
  }): Promise<ExternalIdentity>;
44
89
  }
90
+ /**
91
+ * Thrown by an identity source's `callback` when it refuses the account on purpose (a hosted domain
92
+ * or tenant the platform does not allow, a consumer account where only organization accounts are
93
+ * allowed): the login page then says the account is not allowed (`sso.account_not_allowed`) instead
94
+ * of a provider error. The message is logged by the kernel and never shown to the person. Throw it
95
+ * only after the response itself was verified (ID token, nonce, PKCE); every other failure stays a
96
+ * plain error.
97
+ */
98
+ export declare class IdentitySourceRefused extends Error {
99
+ constructor(message: string);
100
+ }
101
+ /**
102
+ * Whether `err` is an {@link IdentitySourceRefused}: any `Error` whose `name` is
103
+ * `"IdentitySourceRefused"`, so a plugin that bundles another copy of the SDK still matches.
104
+ */
105
+ export declare function isIdentitySourceRefused(err: unknown): boolean;
package/dist/identity.js CHANGED
@@ -1 +1,46 @@
1
- export {};
1
+ /**
2
+ * Checks a tenant id against a source's tenant declaration: `"empty"` for a blank id, `"pattern"`
3
+ * when it does not match the declared pattern (an invalid pattern counts as none),
4
+ * `"never_trusted"` when the source lists it in `neverTrusted`, else `"ok"`. The id is trimmed
5
+ * first. The kernel uses it before storing trusted tenants.
6
+ */
7
+ export function validateTenantId(decl, id) {
8
+ const value = id.trim();
9
+ if (value === "")
10
+ return "empty";
11
+ if (decl?.pattern) {
12
+ let re;
13
+ try {
14
+ re = new RegExp(decl.pattern);
15
+ }
16
+ catch {
17
+ re = undefined;
18
+ }
19
+ if (re && !re.test(value))
20
+ return "pattern";
21
+ }
22
+ if (decl?.neverTrusted?.includes(value))
23
+ return "never_trusted";
24
+ return "ok";
25
+ }
26
+ /**
27
+ * Thrown by an identity source's `callback` when it refuses the account on purpose (a hosted domain
28
+ * or tenant the platform does not allow, a consumer account where only organization accounts are
29
+ * allowed): the login page then says the account is not allowed (`sso.account_not_allowed`) instead
30
+ * of a provider error. The message is logged by the kernel and never shown to the person. Throw it
31
+ * only after the response itself was verified (ID token, nonce, PKCE); every other failure stays a
32
+ * plain error.
33
+ */
34
+ export class IdentitySourceRefused extends Error {
35
+ constructor(message) {
36
+ super(message);
37
+ this.name = "IdentitySourceRefused";
38
+ }
39
+ }
40
+ /**
41
+ * Whether `err` is an {@link IdentitySourceRefused}: any `Error` whose `name` is
42
+ * `"IdentitySourceRefused"`, so a plugin that bundles another copy of the SDK still matches.
43
+ */
44
+ export function isIdentitySourceRefused(err) {
45
+ return err instanceof Error && err.name === "IdentitySourceRefused";
46
+ }
package/dist/index.d.ts CHANGED
@@ -1,29 +1,50 @@
1
- export declare const SDK_VERSION = "0.1.0-rc.8";
1
+ export declare const SDK_VERSION = "0.1.0-rc.80";
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 "./native-failure.js";
32
+ export * from "./net.js";
33
+ export * from "./network-classes.js";
21
34
  export * from "./permissions.js";
35
+ export * from "./platform-only.js";
22
36
  export * from "./plugin-manifest.js";
23
37
  export * from "./plugin-package.js";
24
- export * from "./sandbox.js";
38
+ export * from "./push.js";
39
+ export { SANDBOX_RUNTIME_SOURCE, type SandboxRuntimeFeature, type SandboxRuntimeFile, } from "./sandbox-runtime-source.js";
40
+ 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
41
  export * from "./secret.js";
42
+ export * from "./setup-check.js";
26
43
  export * from "./setup-guide.js";
44
+ export { type ParsedSetupGuide, parseSetupGuide, type SetupGuideCheckLine, type SetupGuideCodeBlock, type SetupGuideParseIssue, type SetupGuideSection, } from "./setup-guide-parse.js";
45
+ export * from "./setup-guide-render.js";
46
+ export * from "./shell-capabilities.js";
47
+ export * from "./shell-environment.js";
27
48
  export * from "./skill.js";
28
49
  export * from "./skill-invocation.js";
29
50
  export * from "./storage.js";
@@ -34,4 +55,7 @@ export * from "./theme-tokens.generated.js";
34
55
  export * from "./tool.js";
35
56
  export * from "./tool-key.js";
36
57
  export * from "./ui.js";
58
+ export * from "./ui-parts.js";
59
+ export * from "./ui-resolve.js";
60
+ export * from "./ui-slots.js";
37
61
  export * from "./web.js";
package/dist/index.js CHANGED
@@ -1,29 +1,50 @@
1
- export const SDK_VERSION = "0.1.0-rc.8";
1
+ export const SDK_VERSION = "0.1.0-rc.80";
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 "./native-failure.js";
32
+ export * from "./net.js";
33
+ export * from "./network-classes.js";
21
34
  export * from "./permissions.js";
35
+ export * from "./platform-only.js";
22
36
  export * from "./plugin-manifest.js";
23
37
  export * from "./plugin-package.js";
24
- export * from "./sandbox.js";
38
+ export * from "./push.js";
39
+ export { SANDBOX_RUNTIME_SOURCE, } from "./sandbox-runtime-source.js";
40
+ 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
41
  export * from "./secret.js";
42
+ export * from "./setup-check.js";
26
43
  export * from "./setup-guide.js";
44
+ export { parseSetupGuide, } from "./setup-guide-parse.js";
45
+ export * from "./setup-guide-render.js";
46
+ export * from "./shell-capabilities.js";
47
+ export * from "./shell-environment.js";
27
48
  export * from "./skill.js";
28
49
  export * from "./skill-invocation.js";
29
50
  export * from "./storage.js";
@@ -34,4 +55,7 @@ export * from "./theme-tokens.generated.js";
34
55
  export * from "./tool.js";
35
56
  export * from "./tool-key.js";
36
57
  export * from "./ui.js";
58
+ export * from "./ui-parts.js";
59
+ export * from "./ui-resolve.js";
60
+ export * from "./ui-slots.js";
37
61
  export * from "./web.js";