@anthropic-ai/sdk 0.118.0 → 0.120.0

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 (250) hide show
  1. package/CHANGELOG.md +21 -0
  2. package/client.d.mts +8 -2
  3. package/client.d.mts.map +1 -1
  4. package/client.d.ts +8 -2
  5. package/client.d.ts.map +1 -1
  6. package/client.js +6 -0
  7. package/client.js.map +1 -1
  8. package/client.mjs +6 -0
  9. package/client.mjs.map +1 -1
  10. package/helpers/beta/environments.d.mts +5 -4
  11. package/helpers/beta/environments.d.mts.map +1 -1
  12. package/helpers/beta/environments.d.ts +5 -4
  13. package/helpers/beta/environments.d.ts.map +1 -1
  14. package/helpers/beta/environments.js +5 -4
  15. package/helpers/beta/environments.js.map +1 -1
  16. package/helpers/beta/environments.mjs +5 -4
  17. package/helpers/beta/environments.mjs.map +1 -1
  18. package/internal/file-store.d.mts +136 -0
  19. package/internal/file-store.d.mts.map +1 -0
  20. package/internal/file-store.d.ts +136 -0
  21. package/internal/file-store.d.ts.map +1 -0
  22. package/internal/file-store.js +531 -0
  23. package/internal/file-store.js.map +1 -0
  24. package/internal/file-store.mjs +523 -0
  25. package/internal/file-store.mjs.map +1 -0
  26. package/lib/environments/poller.d.mts +6 -0
  27. package/lib/environments/poller.d.mts.map +1 -1
  28. package/lib/environments/poller.d.ts +6 -0
  29. package/lib/environments/poller.d.ts.map +1 -1
  30. package/lib/environments/poller.js +46 -1
  31. package/lib/environments/poller.js.map +1 -1
  32. package/lib/environments/poller.mjs +46 -1
  33. package/lib/environments/poller.mjs.map +1 -1
  34. package/lib/environments/worker.d.mts +89 -12
  35. package/lib/environments/worker.d.mts.map +1 -1
  36. package/lib/environments/worker.d.ts +89 -12
  37. package/lib/environments/worker.d.ts.map +1 -1
  38. package/lib/environments/worker.js +336 -67
  39. package/lib/environments/worker.js.map +1 -1
  40. package/lib/environments/worker.mjs +336 -68
  41. package/lib/environments/worker.mjs.map +1 -1
  42. package/lib/tools/BetaRunnableTool.d.mts +4 -1
  43. package/lib/tools/BetaRunnableTool.d.mts.map +1 -1
  44. package/lib/tools/BetaRunnableTool.d.ts +4 -1
  45. package/lib/tools/BetaRunnableTool.d.ts.map +1 -1
  46. package/lib/tools/BetaRunnableTool.js +7 -2
  47. package/lib/tools/BetaRunnableTool.js.map +1 -1
  48. package/lib/tools/BetaRunnableTool.mjs +7 -2
  49. package/lib/tools/BetaRunnableTool.mjs.map +1 -1
  50. package/lib/tools/BetaToolRunner.d.mts.map +1 -1
  51. package/lib/tools/BetaToolRunner.d.ts.map +1 -1
  52. package/lib/tools/BetaToolRunner.js +3 -1
  53. package/lib/tools/BetaToolRunner.js.map +1 -1
  54. package/lib/tools/BetaToolRunner.mjs +3 -1
  55. package/lib/tools/BetaToolRunner.mjs.map +1 -1
  56. package/package.json +1 -1
  57. package/resources/beta/agents/agents.d.mts +322 -27
  58. package/resources/beta/agents/agents.d.mts.map +1 -1
  59. package/resources/beta/agents/agents.d.ts +322 -27
  60. package/resources/beta/agents/agents.d.ts.map +1 -1
  61. package/resources/beta/agents/agents.js.map +1 -1
  62. package/resources/beta/agents/agents.mjs.map +1 -1
  63. package/resources/beta/agents/index.d.mts +1 -1
  64. package/resources/beta/agents/index.d.mts.map +1 -1
  65. package/resources/beta/agents/index.d.ts +1 -1
  66. package/resources/beta/agents/index.d.ts.map +1 -1
  67. package/resources/beta/agents/index.js.map +1 -1
  68. package/resources/beta/agents/index.mjs.map +1 -1
  69. package/resources/beta/beta.d.mts +6 -6
  70. package/resources/beta/beta.d.mts.map +1 -1
  71. package/resources/beta/beta.d.ts +6 -6
  72. package/resources/beta/beta.d.ts.map +1 -1
  73. package/resources/beta/beta.js.map +1 -1
  74. package/resources/beta/beta.mjs.map +1 -1
  75. package/resources/beta/environments/work.d.mts +5 -1
  76. package/resources/beta/environments/work.d.mts.map +1 -1
  77. package/resources/beta/environments/work.d.ts +5 -1
  78. package/resources/beta/environments/work.d.ts.map +1 -1
  79. package/resources/beta/environments/work.js +0 -17
  80. package/resources/beta/environments/work.js.map +1 -1
  81. package/resources/beta/environments/work.mjs +0 -17
  82. package/resources/beta/environments/work.mjs.map +1 -1
  83. package/resources/beta/files.d.mts +22 -22
  84. package/resources/beta/files.d.mts.map +1 -1
  85. package/resources/beta/files.d.ts +22 -22
  86. package/resources/beta/files.d.ts.map +1 -1
  87. package/resources/beta/files.js +4 -4
  88. package/resources/beta/files.js.map +1 -1
  89. package/resources/beta/files.mjs +4 -4
  90. package/resources/beta/files.mjs.map +1 -1
  91. package/resources/beta/index.d.mts +3 -3
  92. package/resources/beta/index.d.mts.map +1 -1
  93. package/resources/beta/index.d.ts +3 -3
  94. package/resources/beta/index.d.ts.map +1 -1
  95. package/resources/beta/index.js.map +1 -1
  96. package/resources/beta/index.mjs.map +1 -1
  97. package/resources/beta/messages/index.d.mts +1 -1
  98. package/resources/beta/messages/index.d.mts.map +1 -1
  99. package/resources/beta/messages/index.d.ts +1 -1
  100. package/resources/beta/messages/index.d.ts.map +1 -1
  101. package/resources/beta/messages/index.js.map +1 -1
  102. package/resources/beta/messages/index.mjs.map +1 -1
  103. package/resources/beta/messages/messages.d.mts +1202 -5
  104. package/resources/beta/messages/messages.d.mts.map +1 -1
  105. package/resources/beta/messages/messages.d.ts +1202 -5
  106. package/resources/beta/messages/messages.d.ts.map +1 -1
  107. package/resources/beta/messages/messages.js.map +1 -1
  108. package/resources/beta/messages/messages.mjs.map +1 -1
  109. package/resources/files.d.mts +105 -0
  110. package/resources/files.d.mts.map +1 -0
  111. package/resources/files.d.ts +105 -0
  112. package/resources/files.d.ts.map +1 -0
  113. package/resources/files.js +52 -0
  114. package/resources/files.js.map +1 -0
  115. package/resources/files.mjs +48 -0
  116. package/resources/files.mjs.map +1 -0
  117. package/resources/index.d.mts +3 -1
  118. package/resources/index.d.mts.map +1 -1
  119. package/resources/index.d.ts +3 -1
  120. package/resources/index.d.ts.map +1 -1
  121. package/resources/index.js +5 -1
  122. package/resources/index.js.map +1 -1
  123. package/resources/index.mjs +2 -0
  124. package/resources/index.mjs.map +1 -1
  125. package/resources/messages/index.d.mts +1 -1
  126. package/resources/messages/index.d.mts.map +1 -1
  127. package/resources/messages/index.d.ts +1 -1
  128. package/resources/messages/index.d.ts.map +1 -1
  129. package/resources/messages/index.js.map +1 -1
  130. package/resources/messages/index.mjs.map +1 -1
  131. package/resources/messages/messages.d.mts +1267 -7
  132. package/resources/messages/messages.d.mts.map +1 -1
  133. package/resources/messages/messages.d.ts +1267 -7
  134. package/resources/messages/messages.d.ts.map +1 -1
  135. package/resources/messages/messages.js.map +1 -1
  136. package/resources/messages/messages.mjs.map +1 -1
  137. package/resources/skills/index.d.mts +3 -0
  138. package/resources/skills/index.d.mts.map +1 -0
  139. package/resources/skills/index.d.ts +3 -0
  140. package/resources/skills/index.d.ts.map +1 -0
  141. package/resources/skills/index.js +9 -0
  142. package/resources/skills/index.js.map +1 -0
  143. package/resources/skills/index.mjs +4 -0
  144. package/resources/skills/index.mjs.map +1 -0
  145. package/resources/skills/skills.d.mts +129 -0
  146. package/resources/skills/skills.d.mts.map +1 -0
  147. package/resources/skills/skills.d.ts +129 -0
  148. package/resources/skills/skills.d.ts.map +1 -0
  149. package/resources/skills/skills.js +44 -0
  150. package/resources/skills/skills.js.map +1 -0
  151. package/resources/skills/skills.mjs +39 -0
  152. package/resources/skills/skills.mjs.map +1 -0
  153. package/resources/skills/versions.d.mts +104 -0
  154. package/resources/skills/versions.d.mts.map +1 -0
  155. package/resources/skills/versions.d.ts +104 -0
  156. package/resources/skills/versions.d.ts.map +1 -0
  157. package/resources/skills/versions.js +41 -0
  158. package/resources/skills/versions.js.map +1 -0
  159. package/resources/skills/versions.mjs +37 -0
  160. package/resources/skills/versions.mjs.map +1 -0
  161. package/resources/skills.d.mts +2 -0
  162. package/resources/skills.d.mts.map +1 -0
  163. package/resources/skills.d.ts +2 -0
  164. package/resources/skills.d.ts.map +1 -0
  165. package/resources/skills.js +6 -0
  166. package/resources/skills.js.map +1 -0
  167. package/resources/skills.mjs +3 -0
  168. package/resources/skills.mjs.map +1 -0
  169. package/src/client.ts +172 -0
  170. package/src/helpers/beta/environments.ts +5 -4
  171. package/src/internal/file-store.ts +550 -0
  172. package/src/lib/environments/poller.ts +47 -1
  173. package/src/lib/environments/worker.ts +419 -79
  174. package/src/lib/tools/BetaRunnableTool.ts +9 -2
  175. package/src/lib/tools/BetaToolRunner.ts +6 -1
  176. package/src/resources/beta/agents/agents.ts +435 -30
  177. package/src/resources/beta/agents/index.ts +17 -0
  178. package/src/resources/beta/beta.ts +160 -6
  179. package/src/resources/beta/environments/work.ts +7 -0
  180. package/src/resources/beta/files.ts +27 -27
  181. package/src/resources/beta/index.ts +80 -3
  182. package/src/resources/beta/messages/index.ts +60 -0
  183. package/src/resources/beta/messages/messages.ts +1865 -415
  184. package/src/resources/files.ts +163 -0
  185. package/src/resources/index.ts +83 -0
  186. package/src/resources/messages/index.ts +66 -0
  187. package/src/resources/messages/messages.ts +1648 -115
  188. package/src/resources/skills/index.ts +21 -0
  189. package/src/resources/skills/skills.ts +194 -0
  190. package/src/resources/skills/versions.ts +160 -0
  191. package/src/resources/skills.ts +3 -0
  192. package/src/tools/agent-toolset/fs-util.ts +40 -24
  193. package/src/tools/agent-toolset/memories.ts +1017 -0
  194. package/src/tools/agent-toolset/node.browser.ts +68 -0
  195. package/src/tools/agent-toolset/node.ts +139 -53
  196. package/src/tools/agent-toolset/skills.ts +29 -9
  197. package/src/tools/agent-toolset/sync-interval.ts +30 -0
  198. package/src/version.ts +1 -1
  199. package/tools/agent-toolset/fs-util.d.mts +23 -10
  200. package/tools/agent-toolset/fs-util.d.mts.map +1 -1
  201. package/tools/agent-toolset/fs-util.d.ts +23 -10
  202. package/tools/agent-toolset/fs-util.d.ts.map +1 -1
  203. package/tools/agent-toolset/fs-util.js +40 -25
  204. package/tools/agent-toolset/fs-util.js.map +1 -1
  205. package/tools/agent-toolset/fs-util.mjs +38 -25
  206. package/tools/agent-toolset/fs-util.mjs.map +1 -1
  207. package/tools/agent-toolset/memories.d.mts +173 -0
  208. package/tools/agent-toolset/memories.d.mts.map +1 -0
  209. package/tools/agent-toolset/memories.d.ts +173 -0
  210. package/tools/agent-toolset/memories.d.ts.map +1 -0
  211. package/tools/agent-toolset/memories.js +902 -0
  212. package/tools/agent-toolset/memories.js.map +1 -0
  213. package/tools/agent-toolset/memories.mjs +895 -0
  214. package/tools/agent-toolset/memories.mjs.map +1 -0
  215. package/tools/agent-toolset/node.browser.d.mts +31 -0
  216. package/tools/agent-toolset/node.browser.d.mts.map +1 -1
  217. package/tools/agent-toolset/node.browser.d.ts +31 -0
  218. package/tools/agent-toolset/node.browser.d.ts.map +1 -1
  219. package/tools/agent-toolset/node.browser.js +59 -1
  220. package/tools/agent-toolset/node.browser.js.map +1 -1
  221. package/tools/agent-toolset/node.browser.mjs +54 -0
  222. package/tools/agent-toolset/node.browser.mjs.map +1 -1
  223. package/tools/agent-toolset/node.d.mts +54 -22
  224. package/tools/agent-toolset/node.d.mts.map +1 -1
  225. package/tools/agent-toolset/node.d.ts +54 -22
  226. package/tools/agent-toolset/node.d.ts.map +1 -1
  227. package/tools/agent-toolset/node.js +83 -44
  228. package/tools/agent-toolset/node.js.map +1 -1
  229. package/tools/agent-toolset/node.mjs +77 -44
  230. package/tools/agent-toolset/node.mjs.map +1 -1
  231. package/tools/agent-toolset/skills.d.mts +16 -7
  232. package/tools/agent-toolset/skills.d.mts.map +1 -1
  233. package/tools/agent-toolset/skills.d.ts +16 -7
  234. package/tools/agent-toolset/skills.d.ts.map +1 -1
  235. package/tools/agent-toolset/skills.js +27 -9
  236. package/tools/agent-toolset/skills.js.map +1 -1
  237. package/tools/agent-toolset/skills.mjs +27 -9
  238. package/tools/agent-toolset/skills.mjs.map +1 -1
  239. package/tools/agent-toolset/sync-interval.d.mts +19 -0
  240. package/tools/agent-toolset/sync-interval.d.mts.map +1 -0
  241. package/tools/agent-toolset/sync-interval.d.ts +19 -0
  242. package/tools/agent-toolset/sync-interval.d.ts.map +1 -0
  243. package/tools/agent-toolset/sync-interval.js +29 -0
  244. package/tools/agent-toolset/sync-interval.js.map +1 -0
  245. package/tools/agent-toolset/sync-interval.mjs +25 -0
  246. package/tools/agent-toolset/sync-interval.mjs.map +1 -0
  247. package/version.d.mts +1 -1
  248. package/version.d.ts +1 -1
  249. package/version.js +1 -1
  250. package/version.mjs +1 -1
@@ -0,0 +1,21 @@
1
+ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2
+
3
+ export {
4
+ Skills,
5
+ type DeletedSkill,
6
+ type Skill,
7
+ type SkillSource,
8
+ type SkillCreateParams,
9
+ type SkillListParams,
10
+ type SkillsPageCursor,
11
+ } from './skills';
12
+ export {
13
+ Versions,
14
+ type DeletedSkillVersion,
15
+ type SkillVersion,
16
+ type VersionCreateParams,
17
+ type VersionRetrieveParams,
18
+ type VersionListParams,
19
+ type VersionDeleteParams,
20
+ type SkillVersionsPageCursor,
21
+ } from './versions';
@@ -0,0 +1,194 @@
1
+ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2
+
3
+ import { APIResource } from '../../core/resource';
4
+ import * as VersionsAPI from './versions';
5
+ import {
6
+ DeletedSkillVersion,
7
+ SkillVersion,
8
+ SkillVersionsPageCursor,
9
+ VersionCreateParams,
10
+ VersionDeleteParams,
11
+ VersionListParams,
12
+ VersionRetrieveParams,
13
+ Versions,
14
+ } from './versions';
15
+ import { APIPromise } from '../../core/api-promise';
16
+ import { PageCursor, type PageCursorParams, PagePromise } from '../../core/pagination';
17
+ import { type Uploadable } from '../../core/uploads';
18
+ import { RequestOptions } from '../../internal/request-options';
19
+ import { multipartFormRequestOptions } from '../../internal/uploads';
20
+ import { path } from '../../internal/utils/path';
21
+
22
+ export class Skills extends APIResource {
23
+ versions: VersionsAPI.Versions = new VersionsAPI.Versions(this._client);
24
+
25
+ /**
26
+ * Create Skill
27
+ */
28
+ create(body: SkillCreateParams, options?: RequestOptions): APIPromise<Skill> {
29
+ return this._client.post(
30
+ '/v1/skills',
31
+ multipartFormRequestOptions({ body, ...options }, this._client, false),
32
+ );
33
+ }
34
+
35
+ /**
36
+ * Get Skill
37
+ */
38
+ retrieve(skillID: string, options?: RequestOptions): APIPromise<Skill> {
39
+ return this._client.get(path`/v1/skills/${skillID}`, options);
40
+ }
41
+
42
+ /**
43
+ * List Skills
44
+ */
45
+ list(
46
+ query: SkillListParams | null | undefined = {},
47
+ options?: RequestOptions,
48
+ ): PagePromise<SkillsPageCursor, Skill> {
49
+ return this._client.getAPIList('/v1/skills', PageCursor<Skill>, { query, ...options });
50
+ }
51
+
52
+ /**
53
+ * Delete Skill
54
+ */
55
+ delete(skillID: string, options?: RequestOptions): APIPromise<DeletedSkill> {
56
+ return this._client.delete(path`/v1/skills/${skillID}`, options);
57
+ }
58
+ }
59
+
60
+ export type SkillsPageCursor = PageCursor<Skill>;
61
+
62
+ export interface DeletedSkill {
63
+ /**
64
+ * Unique identifier for the skill.
65
+ *
66
+ * The format and length of IDs may change over time.
67
+ */
68
+ id: string;
69
+
70
+ /**
71
+ * Deleted object type.
72
+ *
73
+ * For Skills, this is always `"skill_deleted"`.
74
+ */
75
+ type: 'skill_deleted';
76
+ }
77
+
78
+ export interface Skill {
79
+ /**
80
+ * Unique identifier for the skill.
81
+ *
82
+ * The format and length of IDs may change over time.
83
+ */
84
+ id: string;
85
+
86
+ /**
87
+ * ISO 8601 timestamp of when the skill was created.
88
+ */
89
+ created_at: string;
90
+
91
+ /**
92
+ * Human-readable, single-line label for the Skill. Maximum 255 characters. Always
93
+ * set: derived from the SKILL.md frontmatter `name` when omitted at creation. Not
94
+ * unique.
95
+ */
96
+ display_name: string;
97
+
98
+ /**
99
+ * ID of the newest Skill Version — what `latest` references resolve to. Always
100
+ * set: a Skill holds at least one version.
101
+ */
102
+ latest_version_id: string;
103
+
104
+ /**
105
+ * Where the Skill comes from.
106
+ *
107
+ * Possible values:
108
+ *
109
+ * - `"custom"`: authored by the platform user; private to their workspace
110
+ * - `"anthropic"`: published by Anthropic; shared and read-only
111
+ * - `"anthropic_example"`: Anthropic-published sample Skill
112
+ * - `"plugin"`: resolved from an installed plugin
113
+ */
114
+ source: SkillSource;
115
+
116
+ /**
117
+ * Object type.
118
+ *
119
+ * For Skills, this is always `"skill"`.
120
+ */
121
+ type: 'skill';
122
+
123
+ /**
124
+ * ISO 8601 timestamp of when the skill was last updated.
125
+ */
126
+ updated_at: string;
127
+ }
128
+
129
+ export interface SkillSource {
130
+ /**
131
+ * Where the Skill comes from.
132
+ *
133
+ * Possible values:
134
+ *
135
+ * - `"custom"`: authored by the platform user; private to their workspace
136
+ * - `"anthropic"`: published by Anthropic; shared and read-only
137
+ * - `"anthropic_example"`: Anthropic-published sample Skill
138
+ * - `"plugin"`: resolved from an installed plugin
139
+ */
140
+ type: 'custom' | 'anthropic' | 'anthropic_example' | 'plugin';
141
+ }
142
+
143
+ export interface SkillCreateParams {
144
+ /**
145
+ * Files to upload for the skill.
146
+ *
147
+ * All files must be in the same top-level directory and must include a SKILL.md
148
+ * file at the root of that directory.
149
+ */
150
+ files: Array<Uploadable>;
151
+
152
+ /**
153
+ * Human-readable, single-line label for the Skill. Maximum 255 characters. Always
154
+ * set: derived from the SKILL.md frontmatter `name` when omitted at creation. Not
155
+ * unique.
156
+ */
157
+ display_name?: string | null;
158
+ }
159
+
160
+ export interface SkillListParams extends PageCursorParams {
161
+ /**
162
+ * Filter skills by source.
163
+ *
164
+ * If provided, only skills from the specified source will be returned:
165
+ *
166
+ * - `"custom"`: only return user-created skills
167
+ * - `"anthropic"`: only return Anthropic-created skills
168
+ */
169
+ source?: string | null;
170
+ }
171
+
172
+ Skills.Versions = Versions;
173
+
174
+ export declare namespace Skills {
175
+ export {
176
+ type DeletedSkill as DeletedSkill,
177
+ type Skill as Skill,
178
+ type SkillSource as SkillSource,
179
+ type SkillsPageCursor as SkillsPageCursor,
180
+ type SkillCreateParams as SkillCreateParams,
181
+ type SkillListParams as SkillListParams,
182
+ };
183
+
184
+ export {
185
+ Versions as Versions,
186
+ type DeletedSkillVersion as DeletedSkillVersion,
187
+ type SkillVersion as SkillVersion,
188
+ type SkillVersionsPageCursor as SkillVersionsPageCursor,
189
+ type VersionCreateParams as VersionCreateParams,
190
+ type VersionRetrieveParams as VersionRetrieveParams,
191
+ type VersionListParams as VersionListParams,
192
+ type VersionDeleteParams as VersionDeleteParams,
193
+ };
194
+ }
@@ -0,0 +1,160 @@
1
+ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2
+
3
+ import { APIResource } from '../../core/resource';
4
+ import { APIPromise } from '../../core/api-promise';
5
+ import { PageCursor, type PageCursorParams, PagePromise } from '../../core/pagination';
6
+ import { type Uploadable } from '../../core/uploads';
7
+ import { RequestOptions } from '../../internal/request-options';
8
+ import { multipartFormRequestOptions } from '../../internal/uploads';
9
+ import { path } from '../../internal/utils/path';
10
+
11
+ export class Versions extends APIResource {
12
+ /**
13
+ * Create Skill Version
14
+ */
15
+ create(skillID: string, body: VersionCreateParams, options?: RequestOptions): APIPromise<SkillVersion> {
16
+ return this._client.post(
17
+ path`/v1/skills/${skillID}/versions`,
18
+ multipartFormRequestOptions({ body, ...options }, this._client, false),
19
+ );
20
+ }
21
+
22
+ /**
23
+ * Get Skill Version
24
+ */
25
+ retrieve(
26
+ version: string,
27
+ params: VersionRetrieveParams,
28
+ options?: RequestOptions,
29
+ ): APIPromise<SkillVersion> {
30
+ const { skill_id } = params;
31
+ return this._client.get(path`/v1/skills/${skill_id}/versions/${version}`, options);
32
+ }
33
+
34
+ /**
35
+ * List Skill Versions
36
+ */
37
+ list(
38
+ skillID: string,
39
+ query: VersionListParams | null | undefined = {},
40
+ options?: RequestOptions,
41
+ ): PagePromise<SkillVersionsPageCursor, SkillVersion> {
42
+ return this._client.getAPIList(path`/v1/skills/${skillID}/versions`, PageCursor<SkillVersion>, {
43
+ query,
44
+ ...options,
45
+ });
46
+ }
47
+
48
+ /**
49
+ * Delete Skill Version
50
+ */
51
+ delete(
52
+ version: string,
53
+ params: VersionDeleteParams,
54
+ options?: RequestOptions,
55
+ ): APIPromise<DeletedSkillVersion> {
56
+ const { skill_id } = params;
57
+ return this._client.delete(path`/v1/skills/${skill_id}/versions/${version}`, options);
58
+ }
59
+ }
60
+
61
+ export type SkillVersionsPageCursor = PageCursor<SkillVersion>;
62
+
63
+ export interface DeletedSkillVersion {
64
+ /**
65
+ * Unique identifier for this Skill Version. The id addresses the version in paths
66
+ * and pins it in references.
67
+ */
68
+ id: string;
69
+
70
+ /**
71
+ * Deleted object type.
72
+ *
73
+ * For Skill Versions, this is always `"skill_version_deleted"`.
74
+ */
75
+ type: 'skill_version_deleted';
76
+ }
77
+
78
+ export interface SkillVersion {
79
+ /**
80
+ * Unique identifier for this Skill Version. The id addresses the version in paths
81
+ * and pins it in references.
82
+ */
83
+ id: string;
84
+
85
+ /**
86
+ * ISO 8601 timestamp of when the skill was created.
87
+ */
88
+ created_at: string;
89
+
90
+ /**
91
+ * Description of the skill version.
92
+ *
93
+ * This is extracted from the SKILL.md file in the skill upload.
94
+ */
95
+ description: string;
96
+
97
+ /**
98
+ * The Skill's immutable kebab-case slug, set at creation from the first upload's
99
+ * SKILL.md frontmatter `name` (or its enclosing directory). Every later upload
100
+ * must resolve to the same value. Also the top-level directory of the Skill's
101
+ * mounted files and the base name of a downloaded archive.
102
+ */
103
+ name: string;
104
+
105
+ /**
106
+ * Unique identifier for the skill.
107
+ *
108
+ * The format and length of IDs may change over time.
109
+ */
110
+ skill_id: string;
111
+
112
+ /**
113
+ * Object type.
114
+ *
115
+ * For Skill Versions, this is always `"skill_version"`.
116
+ */
117
+ type: 'skill_version';
118
+ }
119
+
120
+ export interface VersionCreateParams {
121
+ /**
122
+ * Files to upload for the skill.
123
+ *
124
+ * All files must be in the same top-level directory and must include a SKILL.md
125
+ * file at the root of that directory.
126
+ */
127
+ files: Array<Uploadable>;
128
+ }
129
+
130
+ export interface VersionRetrieveParams {
131
+ /**
132
+ * Unique identifier for the skill.
133
+ *
134
+ * The format and length of IDs may change over time.
135
+ */
136
+ skill_id: string;
137
+ }
138
+
139
+ export interface VersionListParams extends PageCursorParams {}
140
+
141
+ export interface VersionDeleteParams {
142
+ /**
143
+ * Unique identifier for the skill.
144
+ *
145
+ * The format and length of IDs may change over time.
146
+ */
147
+ skill_id: string;
148
+ }
149
+
150
+ export declare namespace Versions {
151
+ export {
152
+ type DeletedSkillVersion as DeletedSkillVersion,
153
+ type SkillVersion as SkillVersion,
154
+ type SkillVersionsPageCursor as SkillVersionsPageCursor,
155
+ type VersionCreateParams as VersionCreateParams,
156
+ type VersionRetrieveParams as VersionRetrieveParams,
157
+ type VersionListParams as VersionListParams,
158
+ type VersionDeleteParams as VersionDeleteParams,
159
+ };
160
+ }
@@ -0,0 +1,3 @@
1
+ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2
+
3
+ export * from './skills/index';
@@ -15,13 +15,25 @@ export const DIR_CREATE_MODE = 0o755;
15
15
  /** Mode for files the file tools create. */
16
16
  export const FILE_CREATE_MODE = 0o644;
17
17
 
18
- /** `realpath` `p`, or return `p` unchanged when it cannot be resolved. */
19
- async function realpathOrSelf(p: string): Promise<string> {
20
- try {
21
- return await fs.realpath(p);
22
- } catch {
23
- return p;
18
+ /** True when `p` is `root` itself or lexically contained within it. */
19
+ export function isWithin(root: string, p: string): boolean {
20
+ const rel = path.relative(root, p);
21
+ return rel === '' || (!rel.startsWith('..' + path.sep) && rel !== '..' && !path.isAbsolute(rel));
22
+ }
23
+
24
+ /**
25
+ * The first entry of `roots` whose canonical form contains the
26
+ * already-canonical `target`, returned as configured; `undefined` when none
27
+ * does. Each root goes through {@link canonicalize} at check time, exactly like
28
+ * the workdir in {@link confineToRoot}, so granting access (`allowedRoots`)
29
+ * and refusing writes (`readOnlyRoots`) can never resolve the same entry two
30
+ * different ways.
31
+ */
32
+ export async function containingRoot(roots: readonly string[], target: string): Promise<string | undefined> {
33
+ for (const root of roots) {
34
+ if (isWithin(await canonicalize(path.resolve(root)), target)) return root;
24
35
  }
36
+ return undefined;
25
37
  }
26
38
 
27
39
  /** Matches Linux MAXSYMLINKS, the threshold at which `realpath` itself reports ELOOP. */
@@ -79,17 +91,19 @@ export async function canonicalize(abs: string): Promise<string> {
79
91
  }
80
92
 
81
93
  /**
82
- * Resolve `p` and confine it to `root`.
94
+ * Resolve `p` against `root` and confine it to `root` or one of `allowedRoots`
95
+ * (absolute paths, resolved at check time exactly like `root`).
83
96
  *
84
97
  * Absolute and relative inputs go through the same canonicalise-then-contain
85
- * check — an absolute path that lands inside `root` is permitted, only paths
86
- * that resolve *outside* are rejected. Every symlink in `p` (including the
87
- * leaf, even a dangling one) is resolved before the confinement check, and the
88
- * resolved path is what the caller then operates on, so a symlink inside `root`
89
- * that points outside it can neither pass the check nor be followed afterwards.
90
- * `..` is collapsed lexically before any symlink is followed. A path that cannot
91
- * be resolved (symlink loop, unreadable component) is rejected with a
92
- * `ToolError` naming `p`, never the host's absolute path.
98
+ * check — an absolute path that lands inside a permitted root is accepted,
99
+ * only paths that resolve *outside* all of them are rejected. Every symlink in
100
+ * `p` (including the leaf, even a dangling one) is resolved before the
101
+ * confinement check, and the resolved path is what the caller then operates
102
+ * on, so a symlink inside `root` that points outside it can neither pass the
103
+ * check nor be followed afterwards. `..` is collapsed lexically before any
104
+ * symlink is followed. A path that cannot be resolved (symlink loop, unreadable
105
+ * component) is rejected with a `ToolError` naming `p`, never the host's
106
+ * absolute path.
93
107
  *
94
108
  * Residual TOCTOU: a component could still be swapped for a symlink between this
95
109
  * call and the eventual `fs` operation. Closing that fully needs per-component
@@ -99,22 +113,24 @@ export async function canonicalize(abs: string): Promise<string> {
99
113
  export async function confineToRoot(
100
114
  root: string,
101
115
  p: string,
102
- opts?: { allowOutside?: boolean },
116
+ opts?: { allowedRoots?: readonly string[] },
103
117
  ): Promise<string> {
104
- const allowOutside = opts?.allowOutside ?? false;
105
- const realRoot = await realpathOrSelf(path.resolve(root));
106
- const abs = path.resolve(realRoot, p);
107
- if (allowOutside) return abs;
118
+ const allowedRoots = opts?.allowedRoots ?? [];
119
+ const realRoot = await canonicalize(path.resolve(root));
108
120
  let real: string;
109
121
  try {
110
- real = await canonicalize(abs);
122
+ real = await canonicalize(path.resolve(realRoot, p));
111
123
  } catch (err) {
112
124
  throw new ToolError(fsErrorMessage(err, `path ${JSON.stringify(p)}`));
113
125
  }
114
- if (real !== realRoot && !real.startsWith(realRoot + path.sep)) {
115
- throw new ToolError(`path ${JSON.stringify(p)} escapes workdir`);
126
+ if (isWithin(realRoot, real) || (await containingRoot(allowedRoots, real)) !== undefined) {
127
+ return real;
116
128
  }
117
- return real;
129
+ const permitted =
130
+ allowedRoots.length ?
131
+ "the session's working directory and its other permitted directories"
132
+ : "the session's working directory";
133
+ throw new ToolError(`path ${JSON.stringify(p)} is outside ${permitted}`);
118
134
  }
119
135
 
120
136
  /**