@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
@@ -0,0 +1,211 @@
1
+ import type { PushPlatform } from "./push.js";
2
+ /**
3
+ * Desktop shell capabilities (desktop client spec §8): the shapes of the objects a desktop shell
4
+ * puts in `window.capybaraShell.capabilities` under the keys of `SHELL_CAPABILITY_KEYS`. Types and
5
+ * key constants only; `capybara-hq/clients` implements them. A rejected call carries
6
+ * `{ code: ShellCallError }`.
7
+ */
8
+ /** Capability keys, `name@major`; each value is a key of `SHELL_CAPABILITIES`. */
9
+ export declare const SHELL_CAPABILITY_KEYS: {
10
+ readonly chrome: "chrome@1";
11
+ readonly notify: "notify@1";
12
+ readonly openExternal: "openExternal@1";
13
+ readonly signIn: "signIn@1";
14
+ readonly haptics: "haptics@1";
15
+ readonly share: "share@1";
16
+ readonly menu: "menu@1";
17
+ readonly nav: "nav@1";
18
+ readonly profiles: "profiles@1";
19
+ readonly push: "push@1";
20
+ };
21
+ /** The `code` of a rejected shell call. */
22
+ export type ShellCallError = "busy" | "no_activation" | "cancelled" | "failed";
23
+ /** `notify@1`: a native notification; `path` is the in-app path opened on click. */
24
+ export interface NotifyCapabilityV1 {
25
+ notify(input: {
26
+ title: string;
27
+ body: string;
28
+ path?: string;
29
+ }): Promise<void>;
30
+ }
31
+ /** `openExternal@1`: open a URL in the system browser. */
32
+ export interface OpenExternalCapabilityV1 {
33
+ open(url: string): Promise<void>;
34
+ }
35
+ /** `signIn@1`: sign in through the system browser (desktop client spec §6.5). */
36
+ export interface SignInCapabilityV1 {
37
+ start(): Promise<"signedIn" | "cancelled">;
38
+ }
39
+ /**
40
+ * The page's main color tokens (the computed `--cb-bg`, `--cb-panel`, `--cb-ink`, `--cb-muted`,
41
+ * `--cb-line`, `--cb-accent`, `--cb-on-accent`), each a CSS hex or `rgb()` / `rgba()` color. The
42
+ * shell validates them and uses them only as custom properties of its own pages, never as markup.
43
+ */
44
+ export interface ShellChromeTokens {
45
+ bg: string;
46
+ panel: string;
47
+ ink: string;
48
+ muted: string;
49
+ line: string;
50
+ accent: string;
51
+ onAccent: string;
52
+ }
53
+ /**
54
+ * `chrome@1` (mobile layout spec §9.2): the native chrome (window background, title bar, the
55
+ * shell's own pages) follows the page's theme. `tokens` is sent only when all seven are colors;
56
+ * `singleScheme` is true under a UI theme with one scheme (no light / dark toggle on either side).
57
+ */
58
+ export interface ChromeCapabilityV1 {
59
+ setAppearance(input: {
60
+ scheme: "light" | "dark";
61
+ background: string;
62
+ tokens?: ShellChromeTokens;
63
+ singleScheme?: boolean;
64
+ }): Promise<void>;
65
+ /** The web's first paint is done (mobile app spec §5.2); a shell may leave it out. */
66
+ ready?(): Promise<void>;
67
+ }
68
+ export type HapticKind = "selection" | "light" | "success" | "warning";
69
+ /** `haptics@1`: a haptic impact (mobile app spec §5.2). */
70
+ export interface HapticsCapabilityV1 {
71
+ impact(kind: HapticKind): Promise<void>;
72
+ }
73
+ export interface ShareInputV1 {
74
+ title?: string;
75
+ text?: string;
76
+ url?: string;
77
+ }
78
+ /** `share@1`: the system share sheet; resolves whether shared or dismissed. */
79
+ export interface ShareCapabilityV1 {
80
+ share(input: ShareInputV1): Promise<void>;
81
+ }
82
+ export interface MenuItemV1 {
83
+ id: string;
84
+ label: string;
85
+ destructive?: boolean;
86
+ disabled?: boolean;
87
+ }
88
+ export interface MenuInputV1 {
89
+ title?: string;
90
+ items: MenuItemV1[];
91
+ /** A rect in CSS px from the web view's top-left corner. */
92
+ anchor?: {
93
+ x: number;
94
+ y: number;
95
+ width: number;
96
+ height: number;
97
+ };
98
+ }
99
+ /** `menu@1`: a native menu; resolves the chosen item id, or null when dismissed. */
100
+ export interface MenuCapabilityV1 {
101
+ show(input: MenuInputV1): Promise<string | null>;
102
+ }
103
+ /** The shell validates every input against these (and the web keeps within them). */
104
+ export declare const MOBILE_SHELL_LIMITS: {
105
+ readonly menuItems: 12;
106
+ readonly menuLabel: 64;
107
+ readonly menuTitle: 128;
108
+ readonly shareTitle: 256;
109
+ readonly shareText: 4000;
110
+ readonly url: 2048;
111
+ /** `nav@1`: an item or action label is 1..32 characters. */
112
+ readonly navLabel: 32;
113
+ /** `nav@1`: a badge count is an integer 0..9999 (`countMore` says there are more). */
114
+ readonly navCount: 9999;
115
+ /** `nav@1`: the account's name is 1..64 characters (its initial 1..2). */
116
+ readonly navAccountName: 64;
117
+ };
118
+ /** The menu item id pattern, checked on `menu@1.show` (the shell validates every input). */
119
+ export declare const MENU_ITEM_ID: RegExp;
120
+ /**
121
+ * The strip's items: the four sections and, last, `search` (opens the web's command palette; never
122
+ * `current`).
123
+ */
124
+ export type NavSectionId = "chats" | "inbox" | "agents" | "schedules" | "search";
125
+ /** The strip's items in display order. */
126
+ export declare const NAV_SECTION_ORDER: readonly NavSectionId[];
127
+ export interface NavBadgeV1 {
128
+ count?: number;
129
+ countMore?: boolean;
130
+ }
131
+ export interface NavItemV1 extends NavBadgeV1 {
132
+ id: NavSectionId;
133
+ label: string;
134
+ }
135
+ /**
136
+ * The pill's top item, accent-filled: the page's primary action, else the new conversation
137
+ * (`id` matches MENU_ITEM_ID, `label` 1..navLabel; the shell draws its own glyph per `icon`).
138
+ */
139
+ export interface NavActionV1 {
140
+ id: string;
141
+ label: string;
142
+ icon: "plus" | "square-pen";
143
+ }
144
+ /**
145
+ * The account avatar under the strip's status: the image at `avatarUrl` (an absolute https URL
146
+ * or one on the profile's origin), else `initial` in a circle; `badge` a count 0..navCount.
147
+ */
148
+ export interface NavAccountV1 {
149
+ name: string;
150
+ avatarUrl?: string | null;
151
+ initial: string;
152
+ badge?: number;
153
+ }
154
+ export interface NavStateV1 {
155
+ /** The items the person sees, in NAV_SECTION_ORDER (a guest has no `schedules`). */
156
+ items: NavItemV1[];
157
+ /**
158
+ * The section of the page on screen; `null`: no section is selected and the shell clears its
159
+ * highlight (the new-conversation home, a page outside the sections). Never `search`.
160
+ */
161
+ current: NavSectionId | null;
162
+ /** The pill's top item: the page's primary, else the new conversation (no menu button, D12). */
163
+ action: NavActionV1;
164
+ /** The avatar under the status (absent: the shell shows none). */
165
+ account?: NavAccountV1;
166
+ }
167
+ /**
168
+ * `nav@1`: offered only while the window has a strip (mobile app spec §6.1): presence is
169
+ * visibility. `side` is the edge the strip is on (right unless the app is the left one of a
170
+ * split), reported with the capability and updated with the envelope's `change`. The shell and
171
+ * the web ship this shape in lockstep (no older-shell path before 0.1.0): the shell's nav@1
172
+ * minor version of 2026-11-22 ships with or before the web that sends it.
173
+ */
174
+ export interface NavCapabilityV1 {
175
+ set(state: NavStateV1): Promise<void>;
176
+ onSelect(listener: (id: NavSectionId) => void): () => void;
177
+ /** The pill's top item was tapped: the web runs the action. */
178
+ onAction(listener: () => void): () => void;
179
+ /** The account avatar was tapped: the web opens its account sheet. */
180
+ onAccount(listener: () => void): () => void;
181
+ readonly side?: "left" | "right";
182
+ }
183
+ /** `profiles@1`: the native profile switcher. */
184
+ export interface ProfilesCapabilityV1 {
185
+ /** Opens the native profile switcher; resolves when it closes, with nothing. */
186
+ show(): Promise<void>;
187
+ }
188
+ export type PushPermission = "granted" | "denied" | "prompt";
189
+ export interface PushStatus {
190
+ permission: PushPermission;
191
+ /** The server-side registration id this install holds, or null. */
192
+ registrationId: string | null;
193
+ /** The OS token differs from the one last registered. */
194
+ tokenChanged: boolean;
195
+ }
196
+ /** What the shell hands the web app to register with the deployment. */
197
+ export interface PushRegistration {
198
+ platform: PushPlatform;
199
+ appId: string;
200
+ provider: string;
201
+ token: string;
202
+ }
203
+ /** `push@1`: native push registration (mobile shells). */
204
+ export interface PushCapabilityV1 {
205
+ status(): Promise<PushStatus>;
206
+ /** User activation only when permission is "prompt"; rejects { code: "cancelled" } when denied. */
207
+ register(): Promise<PushRegistration>;
208
+ /** Tells the shell the deployment's registration id for this install. */
209
+ registered(id: string): Promise<void>;
210
+ unregister(): Promise<void>;
211
+ }
@@ -0,0 +1,44 @@
1
+ /**
2
+ * Desktop shell capabilities (desktop client spec §8): the shapes of the objects a desktop shell
3
+ * puts in `window.capybaraShell.capabilities` under the keys of `SHELL_CAPABILITY_KEYS`. Types and
4
+ * key constants only; `capybara-hq/clients` implements them. A rejected call carries
5
+ * `{ code: ShellCallError }`.
6
+ */
7
+ /** Capability keys, `name@major`; each value is a key of `SHELL_CAPABILITIES`. */
8
+ export const SHELL_CAPABILITY_KEYS = {
9
+ chrome: "chrome@1",
10
+ notify: "notify@1",
11
+ openExternal: "openExternal@1",
12
+ signIn: "signIn@1",
13
+ haptics: "haptics@1",
14
+ share: "share@1",
15
+ menu: "menu@1",
16
+ nav: "nav@1",
17
+ profiles: "profiles@1",
18
+ push: "push@1",
19
+ };
20
+ /** The shell validates every input against these (and the web keeps within them). */
21
+ export const MOBILE_SHELL_LIMITS = {
22
+ menuItems: 12,
23
+ menuLabel: 64,
24
+ menuTitle: 128,
25
+ shareTitle: 256,
26
+ shareText: 4000,
27
+ url: 2048,
28
+ /** `nav@1`: an item or action label is 1..32 characters. */
29
+ navLabel: 32,
30
+ /** `nav@1`: a badge count is an integer 0..9999 (`countMore` says there are more). */
31
+ navCount: 9999,
32
+ /** `nav@1`: the account's name is 1..64 characters (its initial 1..2). */
33
+ navAccountName: 64,
34
+ };
35
+ /** The menu item id pattern, checked on `menu@1.show` (the shell validates every input). */
36
+ export const MENU_ITEM_ID = /^[A-Za-z0-9_.-]{1,64}$/;
37
+ /** The strip's items in display order. */
38
+ export const NAV_SECTION_ORDER = [
39
+ "chats",
40
+ "inbox",
41
+ "agents",
42
+ "schedules",
43
+ "search",
44
+ ];
@@ -0,0 +1,57 @@
1
+ /**
2
+ * Shell environment (mobile layout spec §9, desktop client spec): the contract of the global a
3
+ * native shell injects as `window.capybaraShell`, only into the top frame of the deployment's
4
+ * origin. Types and the capability registry only; `capybara-hq/clients` implements it.
5
+ */
6
+ export interface CapybaraShell {
7
+ /** The envelope version; bumped only on an incompatible change of this shape. */
8
+ readonly version: 1;
9
+ /** Which shell: drives nothing but the shell attributes. */
10
+ readonly kind: "desktop" | "mobile";
11
+ /** The operating system, for platform conventions only (traffic lights, back gesture). */
12
+ readonly platform: "macos" | "windows" | "linux" | "ios" | "android";
13
+ /** The shell's own version, for reports and diagnostics; never parsed for features. */
14
+ readonly shellVersion: string;
15
+ /**
16
+ * CSS px the shell's own chrome covers at each edge of the web view, beyond the OS safe areas
17
+ * (macOS traffic lights with `titleBarStyle: hiddenInset`, a native title bar overlay).
18
+ */
19
+ readonly insets: {
20
+ top: number;
21
+ right: number;
22
+ bottom: number;
23
+ left: number;
24
+ };
25
+ /**
26
+ * The rectangle the shell's window controls occupy over the web view, in CSS px from the web
27
+ * view's top-left corner (macOS traffic lights, a Windows caption-button overlay at the right);
28
+ * null when there are none or they are hidden (fullscreen). Modelled on Window Controls
29
+ * Overlay's `titlebar-area-*`. Optional: a shell without overlaid controls omits it.
30
+ */
31
+ readonly controls?: {
32
+ x: number;
33
+ y: number;
34
+ width: number;
35
+ height: number;
36
+ } | null;
37
+ /** Capabilities by `name@major` (as extension points are named, `channel@1`). */
38
+ readonly capabilities: Readonly<Record<string, object>>;
39
+ /**
40
+ * Insets, controls or capabilities changed (fullscreen hides the traffic lights; a capability
41
+ * appears after load). Returns unsubscribe.
42
+ */
43
+ on(event: "change", listener: () => void): () => void;
44
+ }
45
+ declare global {
46
+ interface Window {
47
+ capybaraShell?: CapybaraShell;
48
+ }
49
+ }
50
+ /**
51
+ * The registry of capability names (mobile layout spec §9.2). A new capability is added here
52
+ * (key, owner) by the spec that defines it; the owner names the spec holding its functions.
53
+ */
54
+ export declare const SHELL_CAPABILITIES: readonly {
55
+ key: string;
56
+ owner: string;
57
+ }[];
@@ -0,0 +1,21 @@
1
+ /**
2
+ * Shell environment (mobile layout spec §9, desktop client spec): the contract of the global a
3
+ * native shell injects as `window.capybaraShell`, only into the top frame of the deployment's
4
+ * origin. Types and the capability registry only; `capybara-hq/clients` implements it.
5
+ */
6
+ /**
7
+ * The registry of capability names (mobile layout spec §9.2). A new capability is added here
8
+ * (key, owner) by the spec that defines it; the owner names the spec holding its functions.
9
+ */
10
+ export const SHELL_CAPABILITIES = [
11
+ { key: "notify@1", owner: "desktop client spec (2026-11-07-desktop-client-design.md)" },
12
+ { key: "openExternal@1", owner: "desktop client spec (2026-11-07-desktop-client-design.md)" },
13
+ { key: "signIn@1", owner: "desktop client spec (2026-11-07-desktop-client-design.md), §6.5" },
14
+ { key: "chrome@1", owner: "mobile layout spec (2026-11-19-mobile-layout-design.md)" },
15
+ { key: "haptics@1", owner: "mobile app spec (2026-11-20-mobile-app-design.md), §5.2" },
16
+ { key: "share@1", owner: "mobile app spec (2026-11-20-mobile-app-design.md), §5.2" },
17
+ { key: "menu@1", owner: "mobile app spec (2026-11-20-mobile-app-design.md), §5.2" },
18
+ { key: "nav@1", owner: "mobile app spec (2026-11-20-mobile-app-design.md), §5.2" },
19
+ { key: "profiles@1", owner: "mobile app spec (2026-11-20-mobile-app-design.md), §5.2" },
20
+ { key: "push@1", owner: "mobile app spec (2026-11-20-mobile-app-design.md), §5.2 and §9" },
21
+ ];
@@ -64,6 +64,11 @@ export interface RenderSkillInvocationInput {
64
64
  };
65
65
  /** false: leave out the lead sentence (a forked skill's task for the sub-agent). Default true. */
66
66
  lead?: boolean;
67
+ /**
68
+ * The skills root of the conversation's device (`SandboxRoots.skills`, e.g. a connected
69
+ * machine's real path), used for `${CLAUDE_SKILL_DIR}` and the files line. Default `/skills`.
70
+ */
71
+ skillsRoot?: string;
67
72
  }
68
73
  /**
69
74
  * Both `skill_invocation` wrapper tags made inert (`<\/skill_invocation`, `<\skill_invocation`, any
@@ -6,7 +6,8 @@
6
6
  * The argument rules follow Claude Code (re-checked 2026-10-27): `$ARGUMENTS` is the whole argument
7
7
  * string, `$ARGUMENTS[N]` / `$N` are 0-based positional values (a missing one stays as written),
8
8
  * `$name` takes its value from frontmatter `arguments` (a missing one becomes empty), `\$` is a
9
- * literal `$`, `${CLAUDE_SKILL_DIR}` is `/skills/<name>@<digest>` and every other `${…}` stays as written.
9
+ * literal `$`, `${CLAUDE_SKILL_DIR}` is `<skills root>/<name>@<digest>` (the device's skills root,
10
+ * default `/skills`) and every other `${…}` stays as written.
10
11
  * When the body has no argument placeholder and the arguments are not empty, they are appended as
11
12
  * `ARGUMENTS: <args>`. Substituted text is never scanned again. Nothing is executed: shell
12
13
  * injections (`` !`cmd` ``) stay text, and the model is told how to run them.
@@ -183,14 +184,14 @@ const escapeAttr = (s) => s.replace(/&/g, "&amp;").replace(/"/g, "&quot;").repla
183
184
  */
184
185
  export function renderSkillInvocation(i) {
185
186
  const args = trimmedArgs(i.args);
186
- const body = renderSkillBody(i.body, i.invocation, args, i.skillName, i.digest).replace(CLOSE_TAG_RE, "<\\/$1");
187
+ const body = renderSkillBody(i.body, i.invocation, args, i.skillName, i.digest, i.skillsRoot).replace(CLOSE_TAG_RE, "<\\/$1");
187
188
  const parts = [];
188
189
  if (i.lead !== false) {
189
190
  parts.push(escapeTags(`The user invoked the skill "${i.name}" with /${i.name}${args === "" ? "" : ` ${args}`}. Follow its instructions for this request.`));
190
191
  }
191
192
  parts.push(`<skill_invocation name="${escapeAttr(i.name)}" version="${i.version}">\n${body}\n</skill_invocation>`);
192
193
  if (i.lines.files === "load") {
193
- parts.push(`Its files are not in the sandbox yet: call Skill with "${i.name}" to copy them to ${skillSandboxDir(i.skillName, i.digest)}/ before running its scripts.`);
194
+ parts.push(`Its files are not in the sandbox yet: call Skill with "${i.name}" to copy them to ${skillSandboxDir(i.skillName, i.digest, i.skillsRoot)}/ before running its scripts.`);
194
195
  }
195
196
  else if (i.lines.files === "unavailable") {
196
197
  parts.push("Its other files are not available in this conversation.");
package/dist/skill.d.ts CHANGED
@@ -1,17 +1,20 @@
1
- /** 技能包的上限。 */
1
+ /** Limits of a skill package. */
2
2
  export declare const SKILL_LIMITS: {
3
3
  readonly nameMaxChars: 64;
4
4
  readonly descriptionMaxChars: 1024;
5
5
  readonly compatibilityMaxChars: 500;
6
- /** 单个文件解压后的上限(字节)。 */
6
+ /** Upper bound of a single file after extraction (bytes). */
7
7
  readonly fileBytes: number;
8
- /** 全部文件解压后的总量上限(字节)。 */
8
+ /** Upper bound of the total of all files after extraction (bytes). */
9
9
  readonly totalBytes: number;
10
- /** 文件数上限。 */
10
+ /** Upper bound on the number of files. */
11
11
  readonly maxFiles: 1000;
12
- /** 包内相对路径的长度上限(字符)。 */
12
+ /** Upper bound on the length of a relative path inside the package (characters). */
13
13
  readonly pathMaxChars: 512;
14
- /** frontmatter(两条 `---` 之间)的长度上限(字符),超过不做 YAML 解析。 */
14
+ /**
15
+ * Upper bound on the length of the frontmatter (between the two `---` lines) in characters; above
16
+ * it no YAML parsing is done.
17
+ */
15
18
  readonly frontmatterMaxChars: number;
16
19
  };
17
20
  /** Limits of the invocation keys of a SKILL.md (see `SkillInvocation`). */
@@ -28,14 +31,14 @@ export declare const SKILL_INVOCATION_LIMITS: {
28
31
  */
29
32
  readonly renderedMaxChars: 200000;
30
33
  };
31
- /** 技能入口文件(包根目录,大小写敏感)。 */
34
+ /** The skill entry file (package root, case-sensitive). */
32
35
  export declare const SKILL_ENTRY_FILE = "SKILL.md";
33
36
  /**
34
37
  * The sandbox root for skills: each skill version is copied (read-only to commands) to
35
38
  * `/skills/<name>@<digest>/` ({@link skillSandboxDir}).
36
39
  */
37
40
  export declare const SKILLS_SANDBOX_ROOT = "/skills";
38
- /** 是否为合法的技能名(见文件头的规范说明)。 */
41
+ /** Whether it is a valid skill name (see the specification at the top of the file). */
39
42
  export declare function isSkillName(s: unknown): s is string;
40
43
  /**
41
44
  * The digest of a skill version's file manifest: the first 12 hex digits of the sha256 of its
@@ -56,12 +59,12 @@ export declare function skillDigest(files: {
56
59
  export declare function skillSandboxDir(name: string, digest: string, root?: string): string;
57
60
  /** A skill file's path in the sandbox: `<root>/<name>@<digest>/<path>` ({@link skillSandboxDir}). */
58
61
  export declare function skillSandboxPath(name: string, digest: string, path: string, root?: string): string;
59
- /** {@link parseSkillMd} 成功时的结果。 */
62
+ /** The result of a successful {@link parseSkillMd}. */
60
63
  export interface ParsedSkillMd {
61
64
  name: string;
62
- /** 去掉首尾空白。 */
65
+ /** Trimmed of leading and trailing whitespace. */
63
66
  description: string;
64
- /** frontmatter 之后的 Markdown 正文。 */
67
+ /** The Markdown body after the frontmatter. */
65
68
  body: string;
66
69
  /**
67
70
  * The parsed YAML frontmatter mapping: every key, values unchanged (e.g. Claude Code's
@@ -79,17 +82,24 @@ export interface ParseSkillMdOptions {
79
82
  invocationKeys?: boolean;
80
83
  }
81
84
  /**
82
- * 解析 SKILL.md:开头是 `---` 行包住的 YAML frontmatter,之后是正文。容忍 BOM 与 CRLF(正文里的 CRLF 换成 LF)。
83
- * 返回 name / description / 正文,或全部问题(英文,可直接给模型或管理员看)。
85
+ * Parses SKILL.md: it starts with YAML frontmatter wrapped in `---` lines, followed by the body.
86
+ * Tolerates BOM and CRLF (CRLF in the body becomes LF).
87
+ * Returns name / description / body, or all problems (in English, directly showable to a model or
88
+ * an admin).
84
89
  */
85
90
  export declare function parseSkillMd(text: string, options?: ParseSkillMdOptions): ParsedSkillMd | {
86
91
  errors: string[];
87
92
  };
88
93
  /**
89
- * 校验技能包的文件清单(路径相对于包根目录,只含文件、不含目录项):
90
- * 根目录必须有 `SKILL.md`;单文件 ≤ {@link SKILL_LIMITS.fileBytes};总量 ≤ {@link SKILL_LIMITS.totalBytes};
91
- * 文件数 ≤ {@link SKILL_LIMITS.maxFiles};路径不能越界(绝对路径、`..`、反斜杠、盘符、控制字符),不能重复
92
- * (只差大小写也算重复:大小写不敏感的文件系统上会互相覆盖),文件不能与目录同名。返回问题列表,空数组表示合法。
94
+ * Validates a skill package's file list (paths relative to the package root, files only, no
95
+ * directory entries):
96
+ * the root must have `SKILL.md`; single file ≤ {@link SKILL_LIMITS.fileBytes}; total ≤ {@link
97
+ * SKILL_LIMITS.totalBytes};
98
+ * file count ≤ {@link SKILL_LIMITS.maxFiles}; paths must not escape (absolute paths, `..`,
99
+ * backslashes, drive letters, control characters), must not repeat
100
+ * (differing only in case also counts as repeating: they would overwrite each other on
101
+ * case-insensitive file systems), and a file must not share a name with a directory. Returns the
102
+ * list of problems; an empty array means valid.
93
103
  */
94
104
  export declare function validateSkillPackage(files: {
95
105
  path: string;
package/dist/skill.js CHANGED
@@ -1,13 +1,17 @@
1
1
  /**
2
- * 技能(Agent Skills 格式)的纯解析与校验函数:内核上传技能包、agent 提议技能改动时都用它们。
2
+ * Pure parsing and validation functions for skills (Agent Skills format): used when the kernel
3
+ * uploads a skill package and when an agent proposes a skill change.
3
4
  *
4
- * 格式依据(2026-10-21 核实):
5
- * - Agent Skills 规范 https://agentskills.io/specification :`name` 必填,1–64 个字符,只能是小写字母、数字与
6
- * 连字符,不能以连字符开头或结尾,不能有连续连字符,须与所在目录同名;`description` 必填,1–1024 个字符;
7
- * 可选 `license`、`compatibility`(1–500 个字符)、`metadata`、`allowed-tools`。
8
- * - Anthropic 文档 https://platform.claude.com/docs/en/agents-and-tools/agent-skills/overview :
9
- * `name` 与 `description` 不能含 XML 标签(另有保留词 "anthropic" / "claude",那是 Anthropic 平台自己的规则,
10
- * 这里不采用)。
5
+ * Format sources (verified 2026-10-21):
6
+ * - Agent Skills specification https://agentskills.io/specification : `name` is required, 1–64
7
+ * characters, only lowercase letters, digits and
8
+ * hyphens, must not start or end with a hyphen, no consecutive hyphens, and must match its
9
+ * directory name; `description` is required, 1–1024 characters;
10
+ * optional `license`, `compatibility` (1–500 characters), `metadata`, `allowed-tools`.
11
+ * - Anthropic docs https://platform.claude.com/docs/en/agents-and-tools/agent-skills/overview :
12
+ * `name` and `description` must not contain XML tags (there are also reserved words "anthropic" /
13
+ * "claude", which are Anthropic's own platform rules and
14
+ * are not adopted here).
11
15
  *
12
16
  * Choices: the description goes into the model's system prompt, so XML tags are refused as Anthropic
13
17
  * does (no forged prompt structure). Keys outside the specification are allowed and ignored, so
@@ -19,24 +23,27 @@
19
23
  * `/skills/<name>@<digest>/` ({@link skillSandboxDir}, {@link skillDigest}).
20
24
  */
21
25
  import { createHash } from "node:crypto";
26
+ import { validateSandboxPath } from "./device-provider.js";
22
27
  import { readFrontmatter } from "./frontmatter.js";
23
28
  import { hasControlChars } from "./model.js";
24
- import { validateSandboxPath } from "./sandbox.js";
25
29
  import { argumentHintText, SKILL_ARGUMENT_NAME_RE } from "./skill-keys.js";
26
- /** 技能包的上限。 */
30
+ /** Limits of a skill package. */
27
31
  export const SKILL_LIMITS = {
28
32
  nameMaxChars: 64,
29
33
  descriptionMaxChars: 1024,
30
34
  compatibilityMaxChars: 500,
31
- /** 单个文件解压后的上限(字节)。 */
35
+ /** Upper bound of a single file after extraction (bytes). */
32
36
  fileBytes: 10 * 1024 * 1024,
33
- /** 全部文件解压后的总量上限(字节)。 */
37
+ /** Upper bound of the total of all files after extraction (bytes). */
34
38
  totalBytes: 50 * 1024 * 1024,
35
- /** 文件数上限。 */
39
+ /** Upper bound on the number of files. */
36
40
  maxFiles: 1000,
37
- /** 包内相对路径的长度上限(字符)。 */
41
+ /** Upper bound on the length of a relative path inside the package (characters). */
38
42
  pathMaxChars: 512,
39
- /** frontmatter(两条 `---` 之间)的长度上限(字符),超过不做 YAML 解析。 */
43
+ /**
44
+ * Upper bound on the length of the frontmatter (between the two `---` lines) in characters; above
45
+ * it no YAML parsing is done.
46
+ */
40
47
  frontmatterMaxChars: 64 * 1024,
41
48
  };
42
49
  /** Limits of the invocation keys of a SKILL.md (see `SkillInvocation`). */
@@ -53,7 +60,7 @@ export const SKILL_INVOCATION_LIMITS = {
53
60
  */
54
61
  renderedMaxChars: 200_000,
55
62
  };
56
- /** 技能入口文件(包根目录,大小写敏感)。 */
63
+ /** The skill entry file (package root, case-sensitive). */
57
64
  export const SKILL_ENTRY_FILE = "SKILL.md";
58
65
  /**
59
66
  * The sandbox root for skills: each skill version is copied (read-only to commands) to
@@ -63,7 +70,7 @@ export const SKILLS_SANDBOX_ROOT = "/skills";
63
70
  const NAME_RE = /^[a-z0-9]+(-[a-z0-9]+)*$/;
64
71
  const XML_TAG_RE = /<\/?[A-Za-z][^<>]*>/;
65
72
  const DRIVE_RE = /^[A-Za-z]:/;
66
- /** 是否为合法的技能名(见文件头的规范说明)。 */
73
+ /** Whether it is a valid skill name (see the specification at the top of the file). */
67
74
  export function isSkillName(s) {
68
75
  return typeof s === "string" && s.length <= SKILL_LIMITS.nameMaxChars && NAME_RE.test(s);
69
76
  }
@@ -94,8 +101,10 @@ export function skillSandboxPath(name, digest, path, root = SKILLS_SANDBOX_ROOT)
94
101
  }
95
102
  const chars = (s) => [...s].length;
96
103
  /**
97
- * 解析 SKILL.md:开头是 `---` 行包住的 YAML frontmatter,之后是正文。容忍 BOM 与 CRLF(正文里的 CRLF 换成 LF)。
98
- * 返回 name / description / 正文,或全部问题(英文,可直接给模型或管理员看)。
104
+ * Parses SKILL.md: it starts with YAML frontmatter wrapped in `---` lines, followed by the body.
105
+ * Tolerates BOM and CRLF (CRLF in the body becomes LF).
106
+ * Returns name / description / body, or all problems (in English, directly showable to a model or
107
+ * an admin).
99
108
  */
100
109
  export function parseSkillMd(text, options = {}) {
101
110
  const read = readFrontmatter(text, "SKILL.md", SKILL_LIMITS.frontmatterMaxChars);
@@ -178,9 +187,9 @@ function invocationKeyErrors(fm) {
178
187
  }
179
188
  return errors;
180
189
  }
181
- /** 给人看的路径:含控制字符时用 JSON 转义。 */
190
+ /** A path for humans to read: JSON-escaped when it contains control characters. */
182
191
  const show = (p) => (hasControlChars(p) || p === "" ? JSON.stringify(p) : p);
183
- /** 单个相对路径的问题(第一个),合法时为 null。 */
192
+ /** The problem of a single relative path (the first one), null when valid. */
184
193
  function pathProblem(p) {
185
194
  if (typeof p !== "string" || p === "")
186
195
  return "path must be a non-empty string";
@@ -203,15 +212,20 @@ function pathProblem(p) {
203
212
  if (seg === "." || seg === "..")
204
213
  return "path must not contain '.' or '..' segments";
205
214
  }
206
- // 再按沙箱路径规则核一遍(百分号编码的 `..` 等)
215
+ // Then check again against the sandbox path rules (percent-encoded `..` etc.)
207
216
  const errs = validateSandboxPath(skillSandboxPath("skill", "000000000000", p));
208
217
  return errs[0] ?? null;
209
218
  }
210
219
  /**
211
- * 校验技能包的文件清单(路径相对于包根目录,只含文件、不含目录项):
212
- * 根目录必须有 `SKILL.md`;单文件 ≤ {@link SKILL_LIMITS.fileBytes};总量 ≤ {@link SKILL_LIMITS.totalBytes};
213
- * 文件数 ≤ {@link SKILL_LIMITS.maxFiles};路径不能越界(绝对路径、`..`、反斜杠、盘符、控制字符),不能重复
214
- * (只差大小写也算重复:大小写不敏感的文件系统上会互相覆盖),文件不能与目录同名。返回问题列表,空数组表示合法。
220
+ * Validates a skill package's file list (paths relative to the package root, files only, no
221
+ * directory entries):
222
+ * the root must have `SKILL.md`; single file ≤ {@link SKILL_LIMITS.fileBytes}; total ≤ {@link
223
+ * SKILL_LIMITS.totalBytes};
224
+ * file count ≤ {@link SKILL_LIMITS.maxFiles}; paths must not escape (absolute paths, `..`,
225
+ * backslashes, drive letters, control characters), must not repeat
226
+ * (differing only in case also counts as repeating: they would overwrite each other on
227
+ * case-insensitive file systems), and a file must not share a name with a directory. Returns the
228
+ * list of problems; an empty array means valid.
215
229
  */
216
230
  export function validateSkillPackage(files) {
217
231
  if (files.length > SKILL_LIMITS.maxFiles) {