@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.
- package/CHANGELOG.md +21 -0
- package/client.d.mts +8 -2
- package/client.d.mts.map +1 -1
- package/client.d.ts +8 -2
- package/client.d.ts.map +1 -1
- package/client.js +6 -0
- package/client.js.map +1 -1
- package/client.mjs +6 -0
- package/client.mjs.map +1 -1
- package/helpers/beta/environments.d.mts +5 -4
- package/helpers/beta/environments.d.mts.map +1 -1
- package/helpers/beta/environments.d.ts +5 -4
- package/helpers/beta/environments.d.ts.map +1 -1
- package/helpers/beta/environments.js +5 -4
- package/helpers/beta/environments.js.map +1 -1
- package/helpers/beta/environments.mjs +5 -4
- package/helpers/beta/environments.mjs.map +1 -1
- package/internal/file-store.d.mts +136 -0
- package/internal/file-store.d.mts.map +1 -0
- package/internal/file-store.d.ts +136 -0
- package/internal/file-store.d.ts.map +1 -0
- package/internal/file-store.js +531 -0
- package/internal/file-store.js.map +1 -0
- package/internal/file-store.mjs +523 -0
- package/internal/file-store.mjs.map +1 -0
- package/lib/environments/poller.d.mts +6 -0
- package/lib/environments/poller.d.mts.map +1 -1
- package/lib/environments/poller.d.ts +6 -0
- package/lib/environments/poller.d.ts.map +1 -1
- package/lib/environments/poller.js +46 -1
- package/lib/environments/poller.js.map +1 -1
- package/lib/environments/poller.mjs +46 -1
- package/lib/environments/poller.mjs.map +1 -1
- package/lib/environments/worker.d.mts +89 -12
- package/lib/environments/worker.d.mts.map +1 -1
- package/lib/environments/worker.d.ts +89 -12
- package/lib/environments/worker.d.ts.map +1 -1
- package/lib/environments/worker.js +336 -67
- package/lib/environments/worker.js.map +1 -1
- package/lib/environments/worker.mjs +336 -68
- package/lib/environments/worker.mjs.map +1 -1
- package/lib/tools/BetaRunnableTool.d.mts +4 -1
- package/lib/tools/BetaRunnableTool.d.mts.map +1 -1
- package/lib/tools/BetaRunnableTool.d.ts +4 -1
- package/lib/tools/BetaRunnableTool.d.ts.map +1 -1
- package/lib/tools/BetaRunnableTool.js +7 -2
- package/lib/tools/BetaRunnableTool.js.map +1 -1
- package/lib/tools/BetaRunnableTool.mjs +7 -2
- package/lib/tools/BetaRunnableTool.mjs.map +1 -1
- package/lib/tools/BetaToolRunner.d.mts.map +1 -1
- package/lib/tools/BetaToolRunner.d.ts.map +1 -1
- package/lib/tools/BetaToolRunner.js +3 -1
- package/lib/tools/BetaToolRunner.js.map +1 -1
- package/lib/tools/BetaToolRunner.mjs +3 -1
- package/lib/tools/BetaToolRunner.mjs.map +1 -1
- package/package.json +1 -1
- package/resources/beta/agents/agents.d.mts +322 -27
- package/resources/beta/agents/agents.d.mts.map +1 -1
- package/resources/beta/agents/agents.d.ts +322 -27
- package/resources/beta/agents/agents.d.ts.map +1 -1
- package/resources/beta/agents/agents.js.map +1 -1
- package/resources/beta/agents/agents.mjs.map +1 -1
- package/resources/beta/agents/index.d.mts +1 -1
- package/resources/beta/agents/index.d.mts.map +1 -1
- package/resources/beta/agents/index.d.ts +1 -1
- package/resources/beta/agents/index.d.ts.map +1 -1
- package/resources/beta/agents/index.js.map +1 -1
- package/resources/beta/agents/index.mjs.map +1 -1
- package/resources/beta/beta.d.mts +6 -6
- package/resources/beta/beta.d.mts.map +1 -1
- package/resources/beta/beta.d.ts +6 -6
- package/resources/beta/beta.d.ts.map +1 -1
- package/resources/beta/beta.js.map +1 -1
- package/resources/beta/beta.mjs.map +1 -1
- package/resources/beta/environments/work.d.mts +5 -1
- package/resources/beta/environments/work.d.mts.map +1 -1
- package/resources/beta/environments/work.d.ts +5 -1
- package/resources/beta/environments/work.d.ts.map +1 -1
- package/resources/beta/environments/work.js +0 -17
- package/resources/beta/environments/work.js.map +1 -1
- package/resources/beta/environments/work.mjs +0 -17
- package/resources/beta/environments/work.mjs.map +1 -1
- package/resources/beta/files.d.mts +22 -22
- package/resources/beta/files.d.mts.map +1 -1
- package/resources/beta/files.d.ts +22 -22
- package/resources/beta/files.d.ts.map +1 -1
- package/resources/beta/files.js +4 -4
- package/resources/beta/files.js.map +1 -1
- package/resources/beta/files.mjs +4 -4
- package/resources/beta/files.mjs.map +1 -1
- package/resources/beta/index.d.mts +3 -3
- package/resources/beta/index.d.mts.map +1 -1
- package/resources/beta/index.d.ts +3 -3
- package/resources/beta/index.d.ts.map +1 -1
- package/resources/beta/index.js.map +1 -1
- package/resources/beta/index.mjs.map +1 -1
- package/resources/beta/messages/index.d.mts +1 -1
- package/resources/beta/messages/index.d.mts.map +1 -1
- package/resources/beta/messages/index.d.ts +1 -1
- package/resources/beta/messages/index.d.ts.map +1 -1
- package/resources/beta/messages/index.js.map +1 -1
- package/resources/beta/messages/index.mjs.map +1 -1
- package/resources/beta/messages/messages.d.mts +1202 -5
- package/resources/beta/messages/messages.d.mts.map +1 -1
- package/resources/beta/messages/messages.d.ts +1202 -5
- package/resources/beta/messages/messages.d.ts.map +1 -1
- package/resources/beta/messages/messages.js.map +1 -1
- package/resources/beta/messages/messages.mjs.map +1 -1
- package/resources/files.d.mts +105 -0
- package/resources/files.d.mts.map +1 -0
- package/resources/files.d.ts +105 -0
- package/resources/files.d.ts.map +1 -0
- package/resources/files.js +52 -0
- package/resources/files.js.map +1 -0
- package/resources/files.mjs +48 -0
- package/resources/files.mjs.map +1 -0
- package/resources/index.d.mts +3 -1
- package/resources/index.d.mts.map +1 -1
- package/resources/index.d.ts +3 -1
- package/resources/index.d.ts.map +1 -1
- package/resources/index.js +5 -1
- package/resources/index.js.map +1 -1
- package/resources/index.mjs +2 -0
- package/resources/index.mjs.map +1 -1
- package/resources/messages/index.d.mts +1 -1
- package/resources/messages/index.d.mts.map +1 -1
- package/resources/messages/index.d.ts +1 -1
- package/resources/messages/index.d.ts.map +1 -1
- package/resources/messages/index.js.map +1 -1
- package/resources/messages/index.mjs.map +1 -1
- package/resources/messages/messages.d.mts +1267 -7
- package/resources/messages/messages.d.mts.map +1 -1
- package/resources/messages/messages.d.ts +1267 -7
- package/resources/messages/messages.d.ts.map +1 -1
- package/resources/messages/messages.js.map +1 -1
- package/resources/messages/messages.mjs.map +1 -1
- package/resources/skills/index.d.mts +3 -0
- package/resources/skills/index.d.mts.map +1 -0
- package/resources/skills/index.d.ts +3 -0
- package/resources/skills/index.d.ts.map +1 -0
- package/resources/skills/index.js +9 -0
- package/resources/skills/index.js.map +1 -0
- package/resources/skills/index.mjs +4 -0
- package/resources/skills/index.mjs.map +1 -0
- package/resources/skills/skills.d.mts +129 -0
- package/resources/skills/skills.d.mts.map +1 -0
- package/resources/skills/skills.d.ts +129 -0
- package/resources/skills/skills.d.ts.map +1 -0
- package/resources/skills/skills.js +44 -0
- package/resources/skills/skills.js.map +1 -0
- package/resources/skills/skills.mjs +39 -0
- package/resources/skills/skills.mjs.map +1 -0
- package/resources/skills/versions.d.mts +104 -0
- package/resources/skills/versions.d.mts.map +1 -0
- package/resources/skills/versions.d.ts +104 -0
- package/resources/skills/versions.d.ts.map +1 -0
- package/resources/skills/versions.js +41 -0
- package/resources/skills/versions.js.map +1 -0
- package/resources/skills/versions.mjs +37 -0
- package/resources/skills/versions.mjs.map +1 -0
- package/resources/skills.d.mts +2 -0
- package/resources/skills.d.mts.map +1 -0
- package/resources/skills.d.ts +2 -0
- package/resources/skills.d.ts.map +1 -0
- package/resources/skills.js +6 -0
- package/resources/skills.js.map +1 -0
- package/resources/skills.mjs +3 -0
- package/resources/skills.mjs.map +1 -0
- package/src/client.ts +172 -0
- package/src/helpers/beta/environments.ts +5 -4
- package/src/internal/file-store.ts +550 -0
- package/src/lib/environments/poller.ts +47 -1
- package/src/lib/environments/worker.ts +419 -79
- package/src/lib/tools/BetaRunnableTool.ts +9 -2
- package/src/lib/tools/BetaToolRunner.ts +6 -1
- package/src/resources/beta/agents/agents.ts +435 -30
- package/src/resources/beta/agents/index.ts +17 -0
- package/src/resources/beta/beta.ts +160 -6
- package/src/resources/beta/environments/work.ts +7 -0
- package/src/resources/beta/files.ts +27 -27
- package/src/resources/beta/index.ts +80 -3
- package/src/resources/beta/messages/index.ts +60 -0
- package/src/resources/beta/messages/messages.ts +1865 -415
- package/src/resources/files.ts +163 -0
- package/src/resources/index.ts +83 -0
- package/src/resources/messages/index.ts +66 -0
- package/src/resources/messages/messages.ts +1648 -115
- package/src/resources/skills/index.ts +21 -0
- package/src/resources/skills/skills.ts +194 -0
- package/src/resources/skills/versions.ts +160 -0
- package/src/resources/skills.ts +3 -0
- package/src/tools/agent-toolset/fs-util.ts +40 -24
- package/src/tools/agent-toolset/memories.ts +1017 -0
- package/src/tools/agent-toolset/node.browser.ts +68 -0
- package/src/tools/agent-toolset/node.ts +139 -53
- package/src/tools/agent-toolset/skills.ts +29 -9
- package/src/tools/agent-toolset/sync-interval.ts +30 -0
- package/src/version.ts +1 -1
- package/tools/agent-toolset/fs-util.d.mts +23 -10
- package/tools/agent-toolset/fs-util.d.mts.map +1 -1
- package/tools/agent-toolset/fs-util.d.ts +23 -10
- package/tools/agent-toolset/fs-util.d.ts.map +1 -1
- package/tools/agent-toolset/fs-util.js +40 -25
- package/tools/agent-toolset/fs-util.js.map +1 -1
- package/tools/agent-toolset/fs-util.mjs +38 -25
- package/tools/agent-toolset/fs-util.mjs.map +1 -1
- package/tools/agent-toolset/memories.d.mts +173 -0
- package/tools/agent-toolset/memories.d.mts.map +1 -0
- package/tools/agent-toolset/memories.d.ts +173 -0
- package/tools/agent-toolset/memories.d.ts.map +1 -0
- package/tools/agent-toolset/memories.js +902 -0
- package/tools/agent-toolset/memories.js.map +1 -0
- package/tools/agent-toolset/memories.mjs +895 -0
- package/tools/agent-toolset/memories.mjs.map +1 -0
- package/tools/agent-toolset/node.browser.d.mts +31 -0
- package/tools/agent-toolset/node.browser.d.mts.map +1 -1
- package/tools/agent-toolset/node.browser.d.ts +31 -0
- package/tools/agent-toolset/node.browser.d.ts.map +1 -1
- package/tools/agent-toolset/node.browser.js +59 -1
- package/tools/agent-toolset/node.browser.js.map +1 -1
- package/tools/agent-toolset/node.browser.mjs +54 -0
- package/tools/agent-toolset/node.browser.mjs.map +1 -1
- package/tools/agent-toolset/node.d.mts +54 -22
- package/tools/agent-toolset/node.d.mts.map +1 -1
- package/tools/agent-toolset/node.d.ts +54 -22
- package/tools/agent-toolset/node.d.ts.map +1 -1
- package/tools/agent-toolset/node.js +83 -44
- package/tools/agent-toolset/node.js.map +1 -1
- package/tools/agent-toolset/node.mjs +77 -44
- package/tools/agent-toolset/node.mjs.map +1 -1
- package/tools/agent-toolset/skills.d.mts +16 -7
- package/tools/agent-toolset/skills.d.mts.map +1 -1
- package/tools/agent-toolset/skills.d.ts +16 -7
- package/tools/agent-toolset/skills.d.ts.map +1 -1
- package/tools/agent-toolset/skills.js +27 -9
- package/tools/agent-toolset/skills.js.map +1 -1
- package/tools/agent-toolset/skills.mjs +27 -9
- package/tools/agent-toolset/skills.mjs.map +1 -1
- package/tools/agent-toolset/sync-interval.d.mts +19 -0
- package/tools/agent-toolset/sync-interval.d.mts.map +1 -0
- package/tools/agent-toolset/sync-interval.d.ts +19 -0
- package/tools/agent-toolset/sync-interval.d.ts.map +1 -0
- package/tools/agent-toolset/sync-interval.js +29 -0
- package/tools/agent-toolset/sync-interval.js.map +1 -0
- package/tools/agent-toolset/sync-interval.mjs +25 -0
- package/tools/agent-toolset/sync-interval.mjs.map +1 -0
- package/version.d.mts +1 -1
- package/version.d.ts +1 -1
- package/version.js +1 -1
- 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
|
+
}
|
|
@@ -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
|
-
/**
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
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
|
|
86
|
-
* that resolve *outside* are rejected. Every symlink in
|
|
87
|
-
* leaf, even a dangling one) is resolved before the
|
|
88
|
-
* resolved path is what the caller then operates
|
|
89
|
-
* that points outside it can neither pass the
|
|
90
|
-
* `..` is collapsed lexically before any
|
|
91
|
-
* be resolved (symlink loop, unreadable
|
|
92
|
-
* `ToolError` naming `p`, never the host's
|
|
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?: {
|
|
116
|
+
opts?: { allowedRoots?: readonly string[] },
|
|
103
117
|
): Promise<string> {
|
|
104
|
-
const
|
|
105
|
-
const realRoot = await
|
|
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(
|
|
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
|
|
115
|
-
|
|
126
|
+
if (isWithin(realRoot, real) || (await containingRoot(allowedRoots, real)) !== undefined) {
|
|
127
|
+
return real;
|
|
116
128
|
}
|
|
117
|
-
|
|
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
|
/**
|