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

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 +97 -13
  23. package/dist/cards.js +121 -19
  24. package/dist/channel.d.ts +133 -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 +227 -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 +196 -31
  127. package/dist/tool.js +133 -13
  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
@@ -0,0 +1,42 @@
1
+ import { parseSlotRef, uiSlot } from "./ui-slots.js";
2
+ /**
3
+ * Resolves the slots of a manifest's `ui` against the catalog (UI slots spec §3.2). Assumes
4
+ * `validateUiContributions` passed; never throws. A contribution to an unknown slot or to a version
5
+ * other than the slot's is dropped; an `after` that is not an anchor of the slot is listed in
6
+ * `unknownAnchors` and the contribution keeps the slot's default position. Both lists keep manifest order.
7
+ */
8
+ export function resolveUiSlots(ui) {
9
+ const list = ui ?? [];
10
+ const own = new Map();
11
+ for (const c of list) {
12
+ const ref = parseSlotRef(c.slot);
13
+ const slot = ref === null ? undefined : uiSlot(ref.id);
14
+ own.set(c.id, ref === null || slot === undefined
15
+ ? { ok: false, reason: "unknown-slot" }
16
+ : ref.version !== slot.version
17
+ ? { ok: false, reason: "unsupported-version" }
18
+ : { ok: true, slot, version: ref.version });
19
+ }
20
+ const resolved = [];
21
+ const dropped = [];
22
+ const unknownAnchors = [];
23
+ for (const c of list) {
24
+ const r = own.get(c.id);
25
+ if (!r.ok) {
26
+ dropped.push({ id: c.id, ref: c.slot, reason: r.reason });
27
+ continue;
28
+ }
29
+ const anchors = r.slot.anchors ?? [];
30
+ if (c.after !== undefined && !anchors.includes(c.after)) {
31
+ unknownAnchors.push({ id: c.id, after: c.after });
32
+ }
33
+ const after = c.after !== undefined && anchors.includes(c.after) ? c.after : anchors[0];
34
+ resolved.push({
35
+ contribution: c,
36
+ slot: r.slot,
37
+ version: r.version,
38
+ ...(anchors.length > 0 && { after }),
39
+ });
40
+ }
41
+ return { resolved, dropped, unknownAnchors };
42
+ }
@@ -0,0 +1,65 @@
1
+ import type { UiKind } from "./ui.js";
2
+ export type UiSlotScope = "conversation" | "agent" | "org" | "platform" | "file";
3
+ export type UiSlotRole = "guest" | "member" | "admin" | "superAdmin";
4
+ /** Every slot id of the catalog, in catalog order (UI slots spec §3). */
5
+ export declare const UI_SLOT_IDS: readonly ["conversation.panel", "conversation.properties.section", "conversation.tool-result.card", "org.page", "file.preview", "agent.detail.section", "org.settings.section", "platform.page", "shell.brand", "shell.overlay", "conversation.empty", "conversation.composer.frame"];
6
+ /**
7
+ * What a slot (or a contribution) becomes on a compact screen (mobile layout spec §5.6): `kept` =
8
+ * rendered in its place, `drawer` = moved into a sheet or pushed page, `hidden` = not rendered.
9
+ * Order of narrowing: `kept` < `drawer` < `hidden`.
10
+ */
11
+ export type CompactForm = "kept" | "drawer" | "hidden";
12
+ /** True when `v` is one of the three compact forms (used to validate manifests). */
13
+ export declare function isCompactForm(v: unknown): v is CompactForm;
14
+ /** A contribution may narrow its slot's compact form, never widen it. */
15
+ export declare function effectiveCompact(slot: CompactForm, contribution?: CompactForm): CompactForm;
16
+ export type UiSlotId = (typeof UI_SLOT_IDS)[number];
17
+ /** One slot of the catalog: where extension UI may go and what it receives (UI slots spec §3.1). */
18
+ export interface UiSlotSpec {
19
+ id: UiSlotId;
20
+ /** Bumped only on an incompatible change of the slot's contract. */
21
+ version: number;
22
+ /** Path relative to `apps/web/src` of the component that renders the slot. */
23
+ owner: string;
24
+ scope: UiSlotScope;
25
+ accepts: readonly UiKind[];
26
+ /** `single`: one winner replaces the built-in; `list`: every contribution is shown. */
27
+ cardinality: "list" | "single";
28
+ /** A single slot replaces a built-in block (client extensions spec §6.1). */
29
+ replaceable?: true;
30
+ /** What a replaceable slot shows without a winner. */
31
+ builtin?: {
32
+ en: string;
33
+ zh: string;
34
+ };
35
+ minRole: UiSlotRole;
36
+ /** Context ids passed to render (`conversationId`, `agentId`, …). */
37
+ args: readonly string[];
38
+ density: "dense" | "regular";
39
+ icon: "required" | "optional" | "none";
40
+ /** The slot's form on a compact screen (mobile layout spec §5.6). */
41
+ compact: CompactForm;
42
+ /** Built-in parts a contribution may be placed after; the first is the default. */
43
+ anchors?: readonly string[];
44
+ limits?: {
45
+ maxShown?: number;
46
+ };
47
+ description: {
48
+ en: string;
49
+ zh: string;
50
+ };
51
+ }
52
+ export declare const UI_SLOTS: readonly UiSlotSpec[];
53
+ export declare function uiSlot(id: string): UiSlotSpec | undefined;
54
+ /** Reads `<id>` or `<id>@<version>` (version 1 when omitted); does not check the catalog. */
55
+ export declare function parseSlotRef(ref: string): {
56
+ id: string;
57
+ version: number;
58
+ } | null;
59
+ export declare const UI_ARRANGEABLE_SLOTS: readonly UiSlotId[];
60
+ /** Slots with one winner that replaces a built-in block. */
61
+ export declare const UI_SINGLE_SLOTS: readonly UiSlotId[];
62
+ /** Slots that accept the `component` kind. */
63
+ export declare const UI_COMPONENT_SLOTS: readonly UiSlotId[];
64
+ export declare const UI_CONTRIBUTION_KEY_RE: RegExp;
65
+ export declare function uiContributionKey(plugin: string, id: string): string;
@@ -0,0 +1,261 @@
1
+ /** Every slot id of the catalog, in catalog order (UI slots spec §3). */
2
+ export const UI_SLOT_IDS = [
3
+ "conversation.panel",
4
+ "conversation.properties.section",
5
+ "conversation.tool-result.card",
6
+ "org.page",
7
+ "file.preview",
8
+ "agent.detail.section",
9
+ "org.settings.section",
10
+ "platform.page",
11
+ "shell.brand",
12
+ "shell.overlay",
13
+ "conversation.empty",
14
+ "conversation.composer.frame",
15
+ ];
16
+ const COMPACT_ORDER = ["kept", "drawer", "hidden"];
17
+ /** True when `v` is one of the three compact forms (used to validate manifests). */
18
+ export function isCompactForm(v) {
19
+ return typeof v === "string" && COMPACT_ORDER.includes(v);
20
+ }
21
+ /** A contribution may narrow its slot's compact form, never widen it. */
22
+ export function effectiveCompact(slot, contribution) {
23
+ if (contribution === undefined)
24
+ return slot;
25
+ return COMPACT_ORDER.indexOf(contribution) > COMPACT_ORDER.indexOf(slot) ? contribution : slot;
26
+ }
27
+ const SLOT_DATA = [
28
+ {
29
+ id: "conversation.panel",
30
+ version: 1,
31
+ owner: "components/conversation/RightArea.tsx",
32
+ scope: "conversation",
33
+ accepts: ["view", "embed", "component"],
34
+ cardinality: "list",
35
+ minRole: "guest",
36
+ args: ["conversationId", "item"],
37
+ density: "regular",
38
+ icon: "optional",
39
+ compact: "drawer",
40
+ description: {
41
+ en: "A panel beside the conversation, opened from the right area.",
42
+ zh: "对话旁的面板,从右侧区域打开。",
43
+ },
44
+ },
45
+ {
46
+ id: "conversation.properties.section",
47
+ version: 1,
48
+ owner: "components/conversation/PropertiesSections.tsx",
49
+ scope: "conversation",
50
+ accepts: ["view", "embed", "component"],
51
+ cardinality: "list",
52
+ minRole: "guest",
53
+ args: ["conversationId"],
54
+ density: "dense",
55
+ icon: "optional",
56
+ compact: "kept",
57
+ anchors: ["context", "files", "background"],
58
+ description: {
59
+ en: "A section in the conversation properties list.",
60
+ zh: "对话属性列表中的一个分区。",
61
+ },
62
+ },
63
+ {
64
+ id: "conversation.tool-result.card",
65
+ version: 1,
66
+ owner: "components/conversation/RightArea.tsx",
67
+ scope: "conversation",
68
+ accepts: ["view", "embed", "component"],
69
+ cardinality: "list",
70
+ minRole: "guest",
71
+ args: ["conversationId", "card"],
72
+ density: "regular",
73
+ icon: "optional",
74
+ compact: "kept",
75
+ description: {
76
+ en: "A card a tool result opens in the conversation.",
77
+ zh: "工具结果在对话中打开的卡片。",
78
+ },
79
+ },
80
+ {
81
+ id: "org.page",
82
+ version: 1,
83
+ owner: "app/(app)/p/[plugin]/[id]/view.tsx",
84
+ scope: "org",
85
+ accepts: ["view", "embed", "component"],
86
+ cardinality: "list",
87
+ minRole: "member",
88
+ args: [],
89
+ density: "regular",
90
+ icon: "optional",
91
+ compact: "kept",
92
+ description: {
93
+ en: "A full page in the organization navigation.",
94
+ zh: "组织导航中的完整页面。",
95
+ },
96
+ },
97
+ {
98
+ id: "file.preview",
99
+ version: 1,
100
+ owner: "components/conversation/FilePanel.tsx",
101
+ scope: "file",
102
+ accepts: ["embed"],
103
+ cardinality: "list",
104
+ minRole: "guest",
105
+ args: ["conversationId", "fileId"],
106
+ density: "regular",
107
+ icon: "optional",
108
+ compact: "kept",
109
+ description: {
110
+ en: "A previewer for a file of the conversation.",
111
+ zh: "对话中文件的预览器。",
112
+ },
113
+ },
114
+ {
115
+ id: "agent.detail.section",
116
+ version: 1,
117
+ owner: "components/agent/AgentPage.tsx",
118
+ scope: "agent",
119
+ accepts: ["view", "embed", "component"],
120
+ cardinality: "list",
121
+ minRole: "guest",
122
+ args: ["agentId"],
123
+ density: "regular",
124
+ icon: "optional",
125
+ compact: "kept",
126
+ description: {
127
+ en: "A section on the detail page of an agent.",
128
+ zh: "智能体详情页中的一个分区。",
129
+ },
130
+ },
131
+ {
132
+ id: "org.settings.section",
133
+ version: 1,
134
+ owner: "app/(app)/settings/organization/view.tsx",
135
+ scope: "org",
136
+ accepts: ["view", "embed", "component"],
137
+ cardinality: "list",
138
+ minRole: "admin",
139
+ args: [],
140
+ density: "regular",
141
+ icon: "optional",
142
+ compact: "kept",
143
+ description: {
144
+ en: "A section on the organization settings page.",
145
+ zh: "组织设置页中的一个分区。",
146
+ },
147
+ },
148
+ {
149
+ id: "platform.page",
150
+ version: 1,
151
+ owner: "app/(app)/admin/p/[plugin]/[id]/view.tsx",
152
+ scope: "platform",
153
+ accepts: ["view", "embed", "component"],
154
+ cardinality: "list",
155
+ minRole: "superAdmin",
156
+ args: [],
157
+ density: "regular",
158
+ icon: "optional",
159
+ compact: "kept",
160
+ description: {
161
+ en: "A full page in the platform administration.",
162
+ zh: "平台管理中的完整页面。",
163
+ },
164
+ },
165
+ {
166
+ id: "shell.brand",
167
+ version: 1,
168
+ owner: "components/shell/AppFrame.tsx",
169
+ scope: "org",
170
+ accepts: ["component"],
171
+ cardinality: "single",
172
+ replaceable: true,
173
+ builtin: { en: "The logo and wordmark in the sidebar.", zh: "侧边栏中的标志与字标。" },
174
+ minRole: "guest",
175
+ args: [],
176
+ density: "regular",
177
+ icon: "none",
178
+ compact: "hidden",
179
+ description: {
180
+ en: "The brand row of the sidebar (the mark of the collapsed rail).",
181
+ zh: "侧边栏的品牌行(收起后的窄栏标记)。",
182
+ },
183
+ },
184
+ {
185
+ id: "shell.overlay",
186
+ version: 1,
187
+ owner: "components/shell/AppFrame.tsx",
188
+ scope: "org",
189
+ accepts: ["component"],
190
+ cardinality: "list",
191
+ minRole: "guest",
192
+ args: [],
193
+ density: "regular",
194
+ icon: "none",
195
+ compact: "kept",
196
+ limits: { maxShown: 4 },
197
+ description: {
198
+ en: "A full-viewport layer over the workspace shell.",
199
+ zh: "覆盖工作区外壳的全视口图层。",
200
+ },
201
+ },
202
+ {
203
+ id: "conversation.empty",
204
+ version: 1,
205
+ owner: "components/conversation/NewConversation.tsx",
206
+ scope: "org",
207
+ accepts: ["component"],
208
+ cardinality: "single",
209
+ replaceable: true,
210
+ builtin: { en: "The greeting of the new-conversation page.", zh: "新对话页的问候区。" },
211
+ minRole: "guest",
212
+ args: [],
213
+ density: "regular",
214
+ icon: "none",
215
+ compact: "kept",
216
+ description: {
217
+ en: "The hero of the new-conversation page.",
218
+ zh: "新对话页的主视觉区。",
219
+ },
220
+ },
221
+ {
222
+ id: "conversation.composer.frame",
223
+ version: 1,
224
+ owner: "components/conversation/ComposerBar.tsx",
225
+ scope: "org",
226
+ accepts: ["component"],
227
+ cardinality: "single",
228
+ replaceable: true,
229
+ builtin: { en: "The frame around the message composer.", zh: "消息输入框外的边框。" },
230
+ minRole: "guest",
231
+ args: [],
232
+ density: "regular",
233
+ icon: "none",
234
+ compact: "kept",
235
+ description: {
236
+ en: "The frame around the composer, on the new-conversation and conversation pages.",
237
+ zh: "新对话页与对话页中输入框外的边框。",
238
+ },
239
+ },
240
+ ];
241
+ export const UI_SLOTS = SLOT_DATA;
242
+ export function uiSlot(id) {
243
+ return UI_SLOTS.find((s) => s.id === id);
244
+ }
245
+ const SLOT_REF_RE = /^([a-z][a-z0-9-]*(?:\.[a-z][a-z0-9-]*)+)(?:@([1-9][0-9]{0,2}))?$/;
246
+ /** Reads `<id>` or `<id>@<version>` (version 1 when omitted); does not check the catalog. */
247
+ export function parseSlotRef(ref) {
248
+ const m = SLOT_REF_RE.exec(ref);
249
+ if (!m)
250
+ return null;
251
+ return { id: m[1], version: m[2] === undefined ? 1 : Number(m[2]) };
252
+ }
253
+ export const UI_ARRANGEABLE_SLOTS = UI_SLOT_IDS.filter((id) => id !== "file.preview");
254
+ /** Slots with one winner that replaces a built-in block. */
255
+ export const UI_SINGLE_SLOTS = UI_SLOTS.filter((s) => s.cardinality === "single").map((s) => s.id);
256
+ /** Slots that accept the `component` kind. */
257
+ export const UI_COMPONENT_SLOTS = UI_SLOTS.filter((s) => s.accepts.includes("component")).map((s) => s.id);
258
+ export const UI_CONTRIBUTION_KEY_RE = /^[a-z][a-z0-9-]{1,40}\/[a-z][a-z0-9-]{0,39}$/;
259
+ export function uiContributionKey(plugin, id) {
260
+ return `${plugin}/${id}`;
261
+ }