@anthropic-ai/sdk 0.123.0 → 0.124.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 +28 -0
- package/client.d.mts +6 -5
- package/client.d.mts.map +1 -1
- package/client.d.ts +6 -5
- package/client.d.ts.map +1 -1
- package/client.js +2 -1
- package/client.js.map +1 -1
- package/client.mjs +2 -1
- package/client.mjs.map +1 -1
- package/core/streaming.js +4 -2
- package/core/streaming.js.map +1 -1
- package/core/streaming.mjs +4 -2
- package/core/streaming.mjs.map +1 -1
- package/package.json +1 -1
- package/resources/beta/agents/agents.d.mts +45 -0
- package/resources/beta/agents/agents.d.mts.map +1 -1
- package/resources/beta/agents/agents.d.ts +45 -0
- package/resources/beta/agents/agents.d.ts.map +1 -1
- package/resources/beta/agents/agents.js +25 -10
- package/resources/beta/agents/agents.js.map +1 -1
- package/resources/beta/agents/agents.mjs +25 -10
- package/resources/beta/agents/agents.mjs.map +1 -1
- package/resources/beta/agents/versions.d.mts +9 -0
- package/resources/beta/agents/versions.d.mts.map +1 -1
- package/resources/beta/agents/versions.d.ts +9 -0
- package/resources/beta/agents/versions.d.ts.map +1 -1
- package/resources/beta/agents/versions.js +5 -2
- package/resources/beta/agents/versions.js.map +1 -1
- package/resources/beta/agents/versions.mjs +5 -2
- package/resources/beta/agents/versions.mjs.map +1 -1
- package/resources/beta/deployment-runs.d.mts +18 -0
- package/resources/beta/deployment-runs.d.mts.map +1 -1
- package/resources/beta/deployment-runs.d.ts +18 -0
- package/resources/beta/deployment-runs.d.ts.map +1 -1
- package/resources/beta/deployment-runs.js +10 -4
- package/resources/beta/deployment-runs.js.map +1 -1
- package/resources/beta/deployment-runs.mjs +10 -4
- package/resources/beta/deployment-runs.mjs.map +1 -1
- package/resources/beta/deployments.d.mts +72 -0
- package/resources/beta/deployments.d.mts.map +1 -1
- package/resources/beta/deployments.d.ts +72 -0
- package/resources/beta/deployments.d.ts.map +1 -1
- package/resources/beta/deployments.js +40 -16
- package/resources/beta/deployments.js.map +1 -1
- package/resources/beta/deployments.mjs +40 -16
- package/resources/beta/deployments.mjs.map +1 -1
- package/resources/beta/dreams.d.mts +45 -0
- package/resources/beta/dreams.d.mts.map +1 -1
- package/resources/beta/dreams.d.ts +45 -0
- package/resources/beta/dreams.d.ts.map +1 -1
- package/resources/beta/dreams.js +25 -10
- package/resources/beta/dreams.js.map +1 -1
- package/resources/beta/dreams.mjs +25 -10
- package/resources/beta/dreams.mjs.map +1 -1
- package/resources/beta/environments/environments.d.mts +54 -0
- package/resources/beta/environments/environments.d.mts.map +1 -1
- package/resources/beta/environments/environments.d.ts +54 -0
- package/resources/beta/environments/environments.d.ts.map +1 -1
- package/resources/beta/environments/environments.js +30 -12
- package/resources/beta/environments/environments.js.map +1 -1
- package/resources/beta/environments/environments.mjs +30 -12
- package/resources/beta/environments/environments.mjs.map +1 -1
- package/resources/beta/environments/work.d.mts +36 -0
- package/resources/beta/environments/work.d.mts.map +1 -1
- package/resources/beta/environments/work.d.ts +36 -0
- package/resources/beta/environments/work.d.ts.map +1 -1
- package/resources/beta/environments/work.js +20 -8
- package/resources/beta/environments/work.js.map +1 -1
- package/resources/beta/environments/work.mjs +20 -8
- package/resources/beta/environments/work.mjs.map +1 -1
- package/resources/beta/files.d.mts +48 -1
- package/resources/beta/files.d.mts.map +1 -1
- package/resources/beta/files.d.ts +48 -1
- package/resources/beta/files.d.ts.map +1 -1
- package/resources/beta/files.js +22 -9
- package/resources/beta/files.js.map +1 -1
- package/resources/beta/files.mjs +22 -9
- package/resources/beta/files.mjs.map +1 -1
- package/resources/beta/memory-stores/memories.d.mts +45 -0
- package/resources/beta/memory-stores/memories.d.mts.map +1 -1
- package/resources/beta/memory-stores/memories.d.ts +45 -0
- package/resources/beta/memory-stores/memories.d.ts.map +1 -1
- package/resources/beta/memory-stores/memories.js +25 -10
- package/resources/beta/memory-stores/memories.js.map +1 -1
- package/resources/beta/memory-stores/memories.mjs +25 -10
- package/resources/beta/memory-stores/memories.mjs.map +1 -1
- package/resources/beta/memory-stores/memory-stores.d.mts +54 -0
- package/resources/beta/memory-stores/memory-stores.d.mts.map +1 -1
- package/resources/beta/memory-stores/memory-stores.d.ts +54 -0
- package/resources/beta/memory-stores/memory-stores.d.ts.map +1 -1
- package/resources/beta/memory-stores/memory-stores.js +30 -12
- package/resources/beta/memory-stores/memory-stores.js.map +1 -1
- package/resources/beta/memory-stores/memory-stores.mjs +30 -12
- package/resources/beta/memory-stores/memory-stores.mjs.map +1 -1
- package/resources/beta/memory-stores/memory-versions.d.mts +31 -4
- package/resources/beta/memory-stores/memory-versions.d.mts.map +1 -1
- package/resources/beta/memory-stores/memory-versions.d.ts +31 -4
- package/resources/beta/memory-stores/memory-versions.d.ts.map +1 -1
- package/resources/beta/memory-stores/memory-versions.js +15 -6
- package/resources/beta/memory-stores/memory-versions.js.map +1 -1
- package/resources/beta/memory-stores/memory-versions.mjs +15 -6
- package/resources/beta/memory-stores/memory-versions.mjs.map +1 -1
- package/resources/beta/messages/batches.d.mts +54 -0
- package/resources/beta/messages/batches.d.mts.map +1 -1
- package/resources/beta/messages/batches.d.ts +54 -0
- package/resources/beta/messages/batches.d.ts.map +1 -1
- package/resources/beta/messages/batches.js +25 -11
- package/resources/beta/messages/batches.js.map +1 -1
- package/resources/beta/messages/batches.mjs +25 -11
- package/resources/beta/messages/batches.mjs.map +1 -1
- package/resources/beta/messages/messages.d.mts +18 -0
- package/resources/beta/messages/messages.d.mts.map +1 -1
- package/resources/beta/messages/messages.d.ts +18 -0
- package/resources/beta/messages/messages.d.ts.map +1 -1
- package/resources/beta/messages/messages.js +4 -2
- package/resources/beta/messages/messages.js.map +1 -1
- package/resources/beta/messages/messages.mjs +4 -2
- package/resources/beta/messages/messages.mjs.map +1 -1
- package/resources/beta/models.d.mts +18 -0
- package/resources/beta/models.d.mts.map +1 -1
- package/resources/beta/models.d.ts +18 -0
- package/resources/beta/models.d.ts.map +1 -1
- package/resources/beta/models.js +10 -4
- package/resources/beta/models.js.map +1 -1
- package/resources/beta/models.mjs +10 -4
- package/resources/beta/models.mjs.map +1 -1
- package/resources/beta/organization/compliance-settings.d.mts +5 -3
- package/resources/beta/organization/compliance-settings.d.mts.map +1 -1
- package/resources/beta/organization/compliance-settings.d.ts +5 -3
- package/resources/beta/organization/compliance-settings.d.ts.map +1 -1
- package/resources/beta/organization/index.d.mts +1 -1
- package/resources/beta/organization/index.d.mts.map +1 -1
- package/resources/beta/organization/index.d.ts +1 -1
- package/resources/beta/organization/index.d.ts.map +1 -1
- package/resources/beta/organization/index.js.map +1 -1
- package/resources/beta/organization/index.mjs.map +1 -1
- package/resources/beta/organization/organization.d.mts +2 -2
- package/resources/beta/organization/organization.d.mts.map +1 -1
- package/resources/beta/organization/organization.d.ts +2 -2
- package/resources/beta/organization/organization.d.ts.map +1 -1
- package/resources/beta/organization/organization.js.map +1 -1
- package/resources/beta/organization/organization.mjs.map +1 -1
- package/resources/beta/sessions/events.d.mts +27 -0
- package/resources/beta/sessions/events.d.mts.map +1 -1
- package/resources/beta/sessions/events.d.ts +27 -0
- package/resources/beta/sessions/events.d.ts.map +1 -1
- package/resources/beta/sessions/events.js +15 -6
- package/resources/beta/sessions/events.js.map +1 -1
- package/resources/beta/sessions/events.mjs +15 -6
- package/resources/beta/sessions/events.mjs.map +1 -1
- package/resources/beta/sessions/resources.d.mts +45 -0
- package/resources/beta/sessions/resources.d.mts.map +1 -1
- package/resources/beta/sessions/resources.d.ts +45 -0
- package/resources/beta/sessions/resources.d.ts.map +1 -1
- package/resources/beta/sessions/resources.js +25 -10
- package/resources/beta/sessions/resources.js.map +1 -1
- package/resources/beta/sessions/resources.mjs +25 -10
- package/resources/beta/sessions/resources.mjs.map +1 -1
- package/resources/beta/sessions/sessions.d.mts +54 -0
- package/resources/beta/sessions/sessions.d.mts.map +1 -1
- package/resources/beta/sessions/sessions.d.ts +54 -0
- package/resources/beta/sessions/sessions.d.ts.map +1 -1
- package/resources/beta/sessions/sessions.js +30 -12
- package/resources/beta/sessions/sessions.js.map +1 -1
- package/resources/beta/sessions/sessions.mjs +30 -12
- package/resources/beta/sessions/sessions.mjs.map +1 -1
- package/resources/beta/sessions/threads/events.d.mts +18 -0
- package/resources/beta/sessions/threads/events.d.mts.map +1 -1
- package/resources/beta/sessions/threads/events.d.ts +18 -0
- package/resources/beta/sessions/threads/events.d.ts.map +1 -1
- package/resources/beta/sessions/threads/events.js +10 -4
- package/resources/beta/sessions/threads/events.js.map +1 -1
- package/resources/beta/sessions/threads/events.mjs +10 -4
- package/resources/beta/sessions/threads/events.mjs.map +1 -1
- package/resources/beta/sessions/threads/threads.d.mts +27 -0
- package/resources/beta/sessions/threads/threads.d.mts.map +1 -1
- package/resources/beta/sessions/threads/threads.d.ts +27 -0
- package/resources/beta/sessions/threads/threads.d.ts.map +1 -1
- package/resources/beta/sessions/threads/threads.js +15 -6
- package/resources/beta/sessions/threads/threads.js.map +1 -1
- package/resources/beta/sessions/threads/threads.mjs +15 -6
- package/resources/beta/sessions/threads/threads.mjs.map +1 -1
- package/resources/beta/skills/skills.d.mts +36 -0
- package/resources/beta/skills/skills.d.mts.map +1 -1
- package/resources/beta/skills/skills.d.ts +36 -0
- package/resources/beta/skills/skills.d.ts.map +1 -1
- package/resources/beta/skills/skills.js +20 -8
- package/resources/beta/skills/skills.js.map +1 -1
- package/resources/beta/skills/skills.mjs +20 -8
- package/resources/beta/skills/skills.mjs.map +1 -1
- package/resources/beta/skills/versions.d.mts +45 -0
- package/resources/beta/skills/versions.d.mts.map +1 -1
- package/resources/beta/skills/versions.d.ts +45 -0
- package/resources/beta/skills/versions.d.ts.map +1 -1
- package/resources/beta/skills/versions.js +22 -9
- package/resources/beta/skills/versions.js.map +1 -1
- package/resources/beta/skills/versions.mjs +22 -9
- package/resources/beta/skills/versions.mjs.map +1 -1
- package/resources/beta/tunnels/certificates.d.mts +36 -0
- package/resources/beta/tunnels/certificates.d.mts.map +1 -1
- package/resources/beta/tunnels/certificates.d.ts +36 -0
- package/resources/beta/tunnels/certificates.d.ts.map +1 -1
- package/resources/beta/tunnels/certificates.js +20 -8
- package/resources/beta/tunnels/certificates.js.map +1 -1
- package/resources/beta/tunnels/certificates.mjs +20 -8
- package/resources/beta/tunnels/certificates.mjs.map +1 -1
- package/resources/beta/tunnels/tunnels.d.mts +54 -0
- package/resources/beta/tunnels/tunnels.d.mts.map +1 -1
- package/resources/beta/tunnels/tunnels.d.ts +54 -0
- package/resources/beta/tunnels/tunnels.d.ts.map +1 -1
- package/resources/beta/tunnels/tunnels.js +30 -12
- package/resources/beta/tunnels/tunnels.js.map +1 -1
- package/resources/beta/tunnels/tunnels.mjs +30 -12
- package/resources/beta/tunnels/tunnels.mjs.map +1 -1
- package/resources/beta/vaults/credentials.d.mts +63 -0
- package/resources/beta/vaults/credentials.d.mts.map +1 -1
- package/resources/beta/vaults/credentials.d.ts +63 -0
- package/resources/beta/vaults/credentials.d.ts.map +1 -1
- package/resources/beta/vaults/credentials.js +35 -14
- package/resources/beta/vaults/credentials.js.map +1 -1
- package/resources/beta/vaults/credentials.mjs +35 -14
- package/resources/beta/vaults/credentials.mjs.map +1 -1
- package/resources/beta/vaults/vaults.d.mts +54 -0
- package/resources/beta/vaults/vaults.d.mts.map +1 -1
- package/resources/beta/vaults/vaults.d.ts +54 -0
- package/resources/beta/vaults/vaults.d.ts.map +1 -1
- package/resources/beta/vaults/vaults.js +30 -12
- package/resources/beta/vaults/vaults.js.map +1 -1
- package/resources/beta/vaults/vaults.mjs +30 -12
- package/resources/beta/vaults/vaults.mjs.map +1 -1
- package/resources/completions.d.mts +9 -0
- package/resources/completions.d.mts.map +1 -1
- package/resources/completions.d.ts +9 -0
- package/resources/completions.d.ts.map +1 -1
- package/resources/completions.js +5 -2
- package/resources/completions.js.map +1 -1
- package/resources/completions.mjs +5 -2
- package/resources/completions.mjs.map +1 -1
- package/resources/files.d.mts +104 -15
- package/resources/files.d.mts.map +1 -1
- package/resources/files.d.ts +104 -15
- package/resources/files.d.ts.map +1 -1
- package/resources/files.js +79 -10
- package/resources/files.js.map +1 -1
- package/resources/files.mjs +79 -10
- package/resources/files.mjs.map +1 -1
- package/resources/index.d.mts +2 -2
- package/resources/index.d.mts.map +1 -1
- package/resources/index.d.ts +2 -2
- package/resources/index.d.ts.map +1 -1
- package/resources/index.js.map +1 -1
- package/resources/index.mjs.map +1 -1
- package/resources/messages/batches.d.mts +68 -6
- package/resources/messages/batches.d.mts.map +1 -1
- package/resources/messages/batches.d.ts +68 -6
- package/resources/messages/batches.d.ts.map +1 -1
- package/resources/messages/batches.js +52 -13
- package/resources/messages/batches.js.map +1 -1
- package/resources/messages/batches.mjs +52 -13
- package/resources/messages/batches.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 +20 -2
- package/resources/messages/messages.d.mts.map +1 -1
- package/resources/messages/messages.d.ts +20 -2
- package/resources/messages/messages.d.ts.map +1 -1
- package/resources/messages/messages.js +10 -4
- package/resources/messages/messages.js.map +1 -1
- package/resources/messages/messages.mjs +10 -4
- package/resources/messages/messages.mjs.map +1 -1
- package/resources/models.d.mts +31 -0
- package/resources/models.d.mts.map +1 -1
- package/resources/models.d.ts +31 -0
- package/resources/models.d.ts.map +1 -1
- package/resources/models.js +23 -4
- package/resources/models.js.map +1 -1
- package/resources/models.mjs +23 -4
- package/resources/models.mjs.map +1 -1
- package/resources/skills/index.d.mts +1 -1
- package/resources/skills/index.d.mts.map +1 -1
- package/resources/skills/index.d.ts +1 -1
- package/resources/skills/index.d.ts.map +1 -1
- package/resources/skills/index.js.map +1 -1
- package/resources/skills/index.mjs.map +1 -1
- package/resources/skills/skills.d.mts +75 -10
- package/resources/skills/skills.d.mts.map +1 -1
- package/resources/skills/skills.d.ts +75 -10
- package/resources/skills/skills.d.ts.map +1 -1
- package/resources/skills/skills.js +64 -8
- package/resources/skills/skills.js.map +1 -1
- package/resources/skills/skills.mjs +64 -8
- package/resources/skills/skills.mjs.map +1 -1
- package/resources/skills/versions.d.mts +75 -5
- package/resources/skills/versions.d.mts.map +1 -1
- package/resources/skills/versions.d.ts +75 -5
- package/resources/skills/versions.d.ts.map +1 -1
- package/resources/skills/versions.js +67 -7
- package/resources/skills/versions.js.map +1 -1
- package/resources/skills/versions.mjs +67 -7
- package/resources/skills/versions.mjs.map +1 -1
- package/src/client.ts +12 -1
- package/src/core/streaming.ts +4 -2
- package/src/resources/beta/agents/agents.ts +75 -10
- package/src/resources/beta/agents/versions.ts +15 -2
- package/src/resources/beta/deployment-runs.ts +30 -4
- package/src/resources/beta/deployments.ts +120 -16
- package/src/resources/beta/dreams.ts +75 -10
- package/src/resources/beta/environments/environments.ts +90 -12
- package/src/resources/beta/environments/work.ts +60 -8
- package/src/resources/beta/files.ts +75 -11
- package/src/resources/beta/memory-stores/memories.ts +75 -10
- package/src/resources/beta/memory-stores/memory-stores.ts +90 -12
- package/src/resources/beta/memory-stores/memory-versions.ts +49 -10
- package/src/resources/beta/messages/batches.ts +85 -11
- package/src/resources/beta/messages/messages.ts +24 -2
- package/src/resources/beta/models.ts +30 -4
- package/src/resources/beta/organization/compliance-settings.ts +12 -2
- package/src/resources/beta/organization/index.ts +2 -0
- package/src/resources/beta/organization/organization.ts +4 -0
- package/src/resources/beta/sessions/events.ts +45 -6
- package/src/resources/beta/sessions/resources.ts +75 -10
- package/src/resources/beta/sessions/sessions.ts +90 -12
- package/src/resources/beta/sessions/threads/events.ts +30 -4
- package/src/resources/beta/sessions/threads/threads.ts +45 -6
- package/src/resources/beta/skills/skills.ts +60 -8
- package/src/resources/beta/skills/versions.ts +72 -9
- package/src/resources/beta/tunnels/certificates.ts +60 -8
- package/src/resources/beta/tunnels/tunnels.ts +90 -12
- package/src/resources/beta/vaults/credentials.ts +105 -14
- package/src/resources/beta/vaults/vaults.ts +90 -12
- package/src/resources/completions.ts +15 -2
- package/src/resources/files.ts +161 -18
- package/src/resources/index.ts +5 -0
- package/src/resources/messages/batches.ts +137 -13
- package/src/resources/messages/index.ts +4 -0
- package/src/resources/messages/messages.ts +38 -4
- package/src/resources/models.ts +43 -4
- package/src/resources/skills/index.ts +2 -0
- package/src/resources/skills/skills.ts +127 -13
- package/src/resources/skills/versions.ts +115 -11
- package/src/tools/agent-toolset/fs-util.ts +16 -4
- package/src/version.ts +1 -1
- package/tools/agent-toolset/fs-util.d.mts +11 -4
- package/tools/agent-toolset/fs-util.d.mts.map +1 -1
- package/tools/agent-toolset/fs-util.d.ts +11 -4
- package/tools/agent-toolset/fs-util.d.ts.map +1 -1
- package/tools/agent-toolset/fs-util.js +14 -4
- package/tools/agent-toolset/fs-util.js.map +1 -1
- package/tools/agent-toolset/fs-util.mjs +14 -4
- package/tools/agent-toolset/fs-util.mjs.map +1 -1
- package/version.d.mts +1 -1
- package/version.d.ts +1 -1
- package/version.js +1 -1
- package/version.mjs +1 -1
|
@@ -15,6 +15,7 @@ import {
|
|
|
15
15
|
import { APIPromise } from '../../core/api-promise';
|
|
16
16
|
import { PageCursor, type PageCursorParams, PagePromise } from '../../core/pagination';
|
|
17
17
|
import { type Uploadable } from '../../core/uploads';
|
|
18
|
+
import { buildHeaders } from '../../internal/headers';
|
|
18
19
|
import { RequestOptions } from '../../internal/request-options';
|
|
19
20
|
import { multipartFormRequestOptions } from '../../internal/uploads';
|
|
20
21
|
import { path } from '../../internal/utils/path';
|
|
@@ -24,36 +25,103 @@ export class Skills extends APIResource {
|
|
|
24
25
|
|
|
25
26
|
/**
|
|
26
27
|
* Create Skill
|
|
28
|
+
*
|
|
29
|
+
* @example
|
|
30
|
+
* ```ts
|
|
31
|
+
* const skill = await client.skills.create({
|
|
32
|
+
* files: [fs.createReadStream('path/to/file')],
|
|
33
|
+
* });
|
|
34
|
+
* ```
|
|
27
35
|
*/
|
|
28
|
-
create(
|
|
36
|
+
create(params: SkillCreateParams, options?: RequestOptions): APIPromise<Skill> {
|
|
37
|
+
const { workspace_id, ...body } = params;
|
|
29
38
|
return this._client.post(
|
|
30
39
|
'/v1/skills',
|
|
31
|
-
multipartFormRequestOptions(
|
|
40
|
+
multipartFormRequestOptions(
|
|
41
|
+
{
|
|
42
|
+
body,
|
|
43
|
+
...options,
|
|
44
|
+
headers: buildHeaders([
|
|
45
|
+
{ ...(workspace_id != null ? { 'anthropic-workspace-id': workspace_id } : undefined) },
|
|
46
|
+
options?.headers,
|
|
47
|
+
]),
|
|
48
|
+
},
|
|
49
|
+
this._client,
|
|
50
|
+
false,
|
|
51
|
+
),
|
|
32
52
|
);
|
|
33
53
|
}
|
|
34
54
|
|
|
35
55
|
/**
|
|
36
56
|
* Get Skill
|
|
57
|
+
*
|
|
58
|
+
* @example
|
|
59
|
+
* ```ts
|
|
60
|
+
* const skill = await client.skills.retrieve('skill_id');
|
|
61
|
+
* ```
|
|
37
62
|
*/
|
|
38
|
-
retrieve(
|
|
39
|
-
|
|
63
|
+
retrieve(
|
|
64
|
+
skillID: string,
|
|
65
|
+
params: SkillRetrieveParams | null | undefined = {},
|
|
66
|
+
options?: RequestOptions,
|
|
67
|
+
): APIPromise<Skill> {
|
|
68
|
+
const { workspace_id } = params ?? {};
|
|
69
|
+
return this._client.get(path`/v1/skills/${skillID}`, {
|
|
70
|
+
...options,
|
|
71
|
+
headers: buildHeaders([
|
|
72
|
+
{ ...(workspace_id != null ? { 'anthropic-workspace-id': workspace_id } : undefined) },
|
|
73
|
+
options?.headers,
|
|
74
|
+
]),
|
|
75
|
+
});
|
|
40
76
|
}
|
|
41
77
|
|
|
42
78
|
/**
|
|
43
79
|
* List Skills
|
|
80
|
+
*
|
|
81
|
+
* @example
|
|
82
|
+
* ```ts
|
|
83
|
+
* // Automatically fetches more pages as needed.
|
|
84
|
+
* for await (const skill of client.skills.list()) {
|
|
85
|
+
* // ...
|
|
86
|
+
* }
|
|
87
|
+
* ```
|
|
44
88
|
*/
|
|
45
89
|
list(
|
|
46
|
-
|
|
90
|
+
params: SkillListParams | null | undefined = {},
|
|
47
91
|
options?: RequestOptions,
|
|
48
92
|
): PagePromise<SkillsPageCursor, Skill> {
|
|
49
|
-
|
|
93
|
+
const { workspace_id, ...query } = params ?? {};
|
|
94
|
+
return this._client.getAPIList('/v1/skills', PageCursor<Skill>, {
|
|
95
|
+
query,
|
|
96
|
+
...options,
|
|
97
|
+
headers: buildHeaders([
|
|
98
|
+
{ ...(workspace_id != null ? { 'anthropic-workspace-id': workspace_id } : undefined) },
|
|
99
|
+
options?.headers,
|
|
100
|
+
]),
|
|
101
|
+
});
|
|
50
102
|
}
|
|
51
103
|
|
|
52
104
|
/**
|
|
53
105
|
* Delete Skill
|
|
106
|
+
*
|
|
107
|
+
* @example
|
|
108
|
+
* ```ts
|
|
109
|
+
* const deletedSkill = await client.skills.delete('skill_id');
|
|
110
|
+
* ```
|
|
54
111
|
*/
|
|
55
|
-
delete(
|
|
56
|
-
|
|
112
|
+
delete(
|
|
113
|
+
skillID: string,
|
|
114
|
+
params: SkillDeleteParams | null | undefined = {},
|
|
115
|
+
options?: RequestOptions,
|
|
116
|
+
): APIPromise<DeletedSkill> {
|
|
117
|
+
const { workspace_id } = params ?? {};
|
|
118
|
+
return this._client.delete(path`/v1/skills/${skillID}`, {
|
|
119
|
+
...options,
|
|
120
|
+
headers: buildHeaders([
|
|
121
|
+
{ ...(workspace_id != null ? { 'anthropic-workspace-id': workspace_id } : undefined) },
|
|
122
|
+
options?.headers,
|
|
123
|
+
]),
|
|
124
|
+
});
|
|
57
125
|
}
|
|
58
126
|
}
|
|
59
127
|
|
|
@@ -142,7 +210,7 @@ export interface SkillSource {
|
|
|
142
210
|
|
|
143
211
|
export interface SkillCreateParams {
|
|
144
212
|
/**
|
|
145
|
-
* Files to upload for the skill.
|
|
213
|
+
* Body param: Files to upload for the skill.
|
|
146
214
|
*
|
|
147
215
|
* All files must be in the same top-level directory and must include a SKILL.md
|
|
148
216
|
* file at the root of that directory.
|
|
@@ -150,16 +218,38 @@ export interface SkillCreateParams {
|
|
|
150
218
|
files: Array<Uploadable>;
|
|
151
219
|
|
|
152
220
|
/**
|
|
153
|
-
* Human-readable, single-line label for the Skill. Maximum 255
|
|
154
|
-
* set: derived from the SKILL.md frontmatter `name` when
|
|
155
|
-
* unique.
|
|
221
|
+
* Body param: Human-readable, single-line label for the Skill. Maximum 255
|
|
222
|
+
* characters. Always set: derived from the SKILL.md frontmatter `name` when
|
|
223
|
+
* omitted at creation. Not unique.
|
|
156
224
|
*/
|
|
157
225
|
display_name?: string | null;
|
|
226
|
+
|
|
227
|
+
/**
|
|
228
|
+
* Header param: Optional header to select the Workspace for this request. The
|
|
229
|
+
* value is a Workspace ID (for example, `wrkspc_011CZkZaBF1tNoB5wlCeusgy`).
|
|
230
|
+
*
|
|
231
|
+
* Only needed for credentials that can act on more than one Workspace. A
|
|
232
|
+
* credential that belongs to a specific Workspace may omit it; if sent, it must
|
|
233
|
+
* match that Workspace.
|
|
234
|
+
*/
|
|
235
|
+
workspace_id?: string;
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
export interface SkillRetrieveParams {
|
|
239
|
+
/**
|
|
240
|
+
* Optional header to select the Workspace for this request. The value is a
|
|
241
|
+
* Workspace ID (for example, `wrkspc_011CZkZaBF1tNoB5wlCeusgy`).
|
|
242
|
+
*
|
|
243
|
+
* Only needed for credentials that can act on more than one Workspace. A
|
|
244
|
+
* credential that belongs to a specific Workspace may omit it; if sent, it must
|
|
245
|
+
* match that Workspace.
|
|
246
|
+
*/
|
|
247
|
+
workspace_id?: string;
|
|
158
248
|
}
|
|
159
249
|
|
|
160
250
|
export interface SkillListParams extends PageCursorParams {
|
|
161
251
|
/**
|
|
162
|
-
* Filter skills by source.
|
|
252
|
+
* Query param: Filter skills by source.
|
|
163
253
|
*
|
|
164
254
|
* If provided, only skills from the specified source will be returned:
|
|
165
255
|
*
|
|
@@ -167,6 +257,28 @@ export interface SkillListParams extends PageCursorParams {
|
|
|
167
257
|
* - `"anthropic"`: only return Anthropic-created skills
|
|
168
258
|
*/
|
|
169
259
|
source?: string | null;
|
|
260
|
+
|
|
261
|
+
/**
|
|
262
|
+
* Header param: Optional header to select the Workspace for this request. The
|
|
263
|
+
* value is a Workspace ID (for example, `wrkspc_011CZkZaBF1tNoB5wlCeusgy`).
|
|
264
|
+
*
|
|
265
|
+
* Only needed for credentials that can act on more than one Workspace. A
|
|
266
|
+
* credential that belongs to a specific Workspace may omit it; if sent, it must
|
|
267
|
+
* match that Workspace.
|
|
268
|
+
*/
|
|
269
|
+
workspace_id?: string;
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
export interface SkillDeleteParams {
|
|
273
|
+
/**
|
|
274
|
+
* Optional header to select the Workspace for this request. The value is a
|
|
275
|
+
* Workspace ID (for example, `wrkspc_011CZkZaBF1tNoB5wlCeusgy`).
|
|
276
|
+
*
|
|
277
|
+
* Only needed for credentials that can act on more than one Workspace. A
|
|
278
|
+
* credential that belongs to a specific Workspace may omit it; if sent, it must
|
|
279
|
+
* match that Workspace.
|
|
280
|
+
*/
|
|
281
|
+
workspace_id?: string;
|
|
170
282
|
}
|
|
171
283
|
|
|
172
284
|
Skills.Versions = Versions;
|
|
@@ -178,7 +290,9 @@ export declare namespace Skills {
|
|
|
178
290
|
type SkillSource as SkillSource,
|
|
179
291
|
type SkillsPageCursor as SkillsPageCursor,
|
|
180
292
|
type SkillCreateParams as SkillCreateParams,
|
|
293
|
+
type SkillRetrieveParams as SkillRetrieveParams,
|
|
181
294
|
type SkillListParams as SkillListParams,
|
|
295
|
+
type SkillDeleteParams as SkillDeleteParams,
|
|
182
296
|
};
|
|
183
297
|
|
|
184
298
|
export {
|
|
@@ -4,6 +4,7 @@ import { APIResource } from '../../core/resource';
|
|
|
4
4
|
import { APIPromise } from '../../core/api-promise';
|
|
5
5
|
import { PageCursor, type PageCursorParams, PagePromise } from '../../core/pagination';
|
|
6
6
|
import { type Uploadable } from '../../core/uploads';
|
|
7
|
+
import { buildHeaders } from '../../internal/headers';
|
|
7
8
|
import { RequestOptions } from '../../internal/request-options';
|
|
8
9
|
import { multipartFormRequestOptions } from '../../internal/uploads';
|
|
9
10
|
import { path } from '../../internal/utils/path';
|
|
@@ -11,50 +12,113 @@ import { path } from '../../internal/utils/path';
|
|
|
11
12
|
export class Versions extends APIResource {
|
|
12
13
|
/**
|
|
13
14
|
* Create Skill Version
|
|
15
|
+
*
|
|
16
|
+
* @example
|
|
17
|
+
* ```ts
|
|
18
|
+
* const skillVersion = await client.skills.versions.create(
|
|
19
|
+
* 'skill_id',
|
|
20
|
+
* { files: [fs.createReadStream('path/to/file')] },
|
|
21
|
+
* );
|
|
22
|
+
* ```
|
|
14
23
|
*/
|
|
15
|
-
create(skillID: string,
|
|
24
|
+
create(skillID: string, params: VersionCreateParams, options?: RequestOptions): APIPromise<SkillVersion> {
|
|
25
|
+
const { workspace_id, ...body } = params;
|
|
16
26
|
return this._client.post(
|
|
17
27
|
path`/v1/skills/${skillID}/versions`,
|
|
18
|
-
multipartFormRequestOptions(
|
|
28
|
+
multipartFormRequestOptions(
|
|
29
|
+
{
|
|
30
|
+
body,
|
|
31
|
+
...options,
|
|
32
|
+
headers: buildHeaders([
|
|
33
|
+
{ ...(workspace_id != null ? { 'anthropic-workspace-id': workspace_id } : undefined) },
|
|
34
|
+
options?.headers,
|
|
35
|
+
]),
|
|
36
|
+
},
|
|
37
|
+
this._client,
|
|
38
|
+
false,
|
|
39
|
+
),
|
|
19
40
|
);
|
|
20
41
|
}
|
|
21
42
|
|
|
22
43
|
/**
|
|
23
44
|
* Get Skill Version
|
|
45
|
+
*
|
|
46
|
+
* @example
|
|
47
|
+
* ```ts
|
|
48
|
+
* const skillVersion = await client.skills.versions.retrieve(
|
|
49
|
+
* 'version',
|
|
50
|
+
* { skill_id: 'skill_id' },
|
|
51
|
+
* );
|
|
52
|
+
* ```
|
|
24
53
|
*/
|
|
25
54
|
retrieve(
|
|
26
55
|
version: string,
|
|
27
56
|
params: VersionRetrieveParams,
|
|
28
57
|
options?: RequestOptions,
|
|
29
58
|
): APIPromise<SkillVersion> {
|
|
30
|
-
const { skill_id } = params;
|
|
31
|
-
return this._client.get(path`/v1/skills/${skill_id}/versions/${version}`,
|
|
59
|
+
const { skill_id, workspace_id } = params;
|
|
60
|
+
return this._client.get(path`/v1/skills/${skill_id}/versions/${version}`, {
|
|
61
|
+
...options,
|
|
62
|
+
headers: buildHeaders([
|
|
63
|
+
{ ...(workspace_id != null ? { 'anthropic-workspace-id': workspace_id } : undefined) },
|
|
64
|
+
options?.headers,
|
|
65
|
+
]),
|
|
66
|
+
});
|
|
32
67
|
}
|
|
33
68
|
|
|
34
69
|
/**
|
|
35
70
|
* List Skill Versions
|
|
71
|
+
*
|
|
72
|
+
* @example
|
|
73
|
+
* ```ts
|
|
74
|
+
* // Automatically fetches more pages as needed.
|
|
75
|
+
* for await (const skillVersion of client.skills.versions.list(
|
|
76
|
+
* 'skill_id',
|
|
77
|
+
* )) {
|
|
78
|
+
* // ...
|
|
79
|
+
* }
|
|
80
|
+
* ```
|
|
36
81
|
*/
|
|
37
82
|
list(
|
|
38
83
|
skillID: string,
|
|
39
|
-
|
|
84
|
+
params: VersionListParams | null | undefined = {},
|
|
40
85
|
options?: RequestOptions,
|
|
41
86
|
): PagePromise<SkillVersionsPageCursor, SkillVersion> {
|
|
87
|
+
const { workspace_id, ...query } = params ?? {};
|
|
42
88
|
return this._client.getAPIList(path`/v1/skills/${skillID}/versions`, PageCursor<SkillVersion>, {
|
|
43
89
|
query,
|
|
44
90
|
...options,
|
|
91
|
+
headers: buildHeaders([
|
|
92
|
+
{ ...(workspace_id != null ? { 'anthropic-workspace-id': workspace_id } : undefined) },
|
|
93
|
+
options?.headers,
|
|
94
|
+
]),
|
|
45
95
|
});
|
|
46
96
|
}
|
|
47
97
|
|
|
48
98
|
/**
|
|
49
99
|
* Delete Skill Version
|
|
100
|
+
*
|
|
101
|
+
* @example
|
|
102
|
+
* ```ts
|
|
103
|
+
* const deletedSkillVersion =
|
|
104
|
+
* await client.skills.versions.delete('version', {
|
|
105
|
+
* skill_id: 'skill_id',
|
|
106
|
+
* });
|
|
107
|
+
* ```
|
|
50
108
|
*/
|
|
51
109
|
delete(
|
|
52
110
|
version: string,
|
|
53
111
|
params: VersionDeleteParams,
|
|
54
112
|
options?: RequestOptions,
|
|
55
113
|
): APIPromise<DeletedSkillVersion> {
|
|
56
|
-
const { skill_id } = params;
|
|
57
|
-
return this._client.delete(path`/v1/skills/${skill_id}/versions/${version}`,
|
|
114
|
+
const { skill_id, workspace_id } = params;
|
|
115
|
+
return this._client.delete(path`/v1/skills/${skill_id}/versions/${version}`, {
|
|
116
|
+
...options,
|
|
117
|
+
headers: buildHeaders([
|
|
118
|
+
{ ...(workspace_id != null ? { 'anthropic-workspace-id': workspace_id } : undefined) },
|
|
119
|
+
options?.headers,
|
|
120
|
+
]),
|
|
121
|
+
});
|
|
58
122
|
}
|
|
59
123
|
}
|
|
60
124
|
|
|
@@ -119,32 +183,72 @@ export interface SkillVersion {
|
|
|
119
183
|
|
|
120
184
|
export interface VersionCreateParams {
|
|
121
185
|
/**
|
|
122
|
-
* Files to upload for the skill.
|
|
186
|
+
* Body param: Files to upload for the skill.
|
|
123
187
|
*
|
|
124
188
|
* All files must be in the same top-level directory and must include a SKILL.md
|
|
125
189
|
* file at the root of that directory.
|
|
126
190
|
*/
|
|
127
191
|
files: Array<Uploadable>;
|
|
192
|
+
|
|
193
|
+
/**
|
|
194
|
+
* Header param: Optional header to select the Workspace for this request. The
|
|
195
|
+
* value is a Workspace ID (for example, `wrkspc_011CZkZaBF1tNoB5wlCeusgy`).
|
|
196
|
+
*
|
|
197
|
+
* Only needed for credentials that can act on more than one Workspace. A
|
|
198
|
+
* credential that belongs to a specific Workspace may omit it; if sent, it must
|
|
199
|
+
* match that Workspace.
|
|
200
|
+
*/
|
|
201
|
+
workspace_id?: string;
|
|
128
202
|
}
|
|
129
203
|
|
|
130
204
|
export interface VersionRetrieveParams {
|
|
131
205
|
/**
|
|
132
|
-
* Unique identifier for the skill.
|
|
206
|
+
* Path param: Unique identifier for the skill.
|
|
133
207
|
*
|
|
134
208
|
* The format and length of IDs may change over time.
|
|
135
209
|
*/
|
|
136
210
|
skill_id: string;
|
|
211
|
+
|
|
212
|
+
/**
|
|
213
|
+
* Header param: Optional header to select the Workspace for this request. The
|
|
214
|
+
* value is a Workspace ID (for example, `wrkspc_011CZkZaBF1tNoB5wlCeusgy`).
|
|
215
|
+
*
|
|
216
|
+
* Only needed for credentials that can act on more than one Workspace. A
|
|
217
|
+
* credential that belongs to a specific Workspace may omit it; if sent, it must
|
|
218
|
+
* match that Workspace.
|
|
219
|
+
*/
|
|
220
|
+
workspace_id?: string;
|
|
137
221
|
}
|
|
138
222
|
|
|
139
|
-
export interface VersionListParams extends PageCursorParams {
|
|
223
|
+
export interface VersionListParams extends PageCursorParams {
|
|
224
|
+
/**
|
|
225
|
+
* Header param: Optional header to select the Workspace for this request. The
|
|
226
|
+
* value is a Workspace ID (for example, `wrkspc_011CZkZaBF1tNoB5wlCeusgy`).
|
|
227
|
+
*
|
|
228
|
+
* Only needed for credentials that can act on more than one Workspace. A
|
|
229
|
+
* credential that belongs to a specific Workspace may omit it; if sent, it must
|
|
230
|
+
* match that Workspace.
|
|
231
|
+
*/
|
|
232
|
+
workspace_id?: string;
|
|
233
|
+
}
|
|
140
234
|
|
|
141
235
|
export interface VersionDeleteParams {
|
|
142
236
|
/**
|
|
143
|
-
* Unique identifier for the skill.
|
|
237
|
+
* Path param: Unique identifier for the skill.
|
|
144
238
|
*
|
|
145
239
|
* The format and length of IDs may change over time.
|
|
146
240
|
*/
|
|
147
241
|
skill_id: string;
|
|
242
|
+
|
|
243
|
+
/**
|
|
244
|
+
* Header param: Optional header to select the Workspace for this request. The
|
|
245
|
+
* value is a Workspace ID (for example, `wrkspc_011CZkZaBF1tNoB5wlCeusgy`).
|
|
246
|
+
*
|
|
247
|
+
* Only needed for credentials that can act on more than one Workspace. A
|
|
248
|
+
* credential that belongs to a specific Workspace may omit it; if sent, it must
|
|
249
|
+
* match that Workspace.
|
|
250
|
+
*/
|
|
251
|
+
workspace_id?: string;
|
|
148
252
|
}
|
|
149
253
|
|
|
150
254
|
export declare namespace Versions {
|
|
@@ -11,10 +11,13 @@ import { ToolError } from '../../lib/tools/ToolError';
|
|
|
11
11
|
|
|
12
12
|
const fs = nodefs.promises;
|
|
13
13
|
|
|
14
|
-
/** Mode for directories the file tools create
|
|
15
|
-
export const DIR_CREATE_MODE =
|
|
16
|
-
/**
|
|
17
|
-
|
|
14
|
+
/** Mode for directories the file tools create: owner-only under any umask, like the memory tool. */
|
|
15
|
+
export const DIR_CREATE_MODE = 0o700;
|
|
16
|
+
/**
|
|
17
|
+
* Mode for files the file tools create: owner-only, so other local users can't
|
|
18
|
+
* read what an agent wrote. A file that already exists keeps its own mode.
|
|
19
|
+
*/
|
|
20
|
+
export const FILE_CREATE_MODE = 0o600;
|
|
18
21
|
|
|
19
22
|
/** True when `p` is `root` itself or lexically contained within it. */
|
|
20
23
|
export function isWithin(root: string, p: string): boolean {
|
|
@@ -138,13 +141,22 @@ export async function confineToRoot(
|
|
|
138
141
|
* Atomically write `content` to `targetPath`: write a sibling temp file, fsync
|
|
139
142
|
* it, then rename over the target. The rename is atomic on most filesystems, so
|
|
140
143
|
* a crash mid-write never leaves the target half-written.
|
|
144
|
+
*
|
|
145
|
+
* A new file is created {@link FILE_CREATE_MODE}; an existing one keeps its
|
|
146
|
+
* permission bits (the rename replaces the inode, so they are copied onto the
|
|
147
|
+
* temp file first) — an edit must not strip `+x` or sharing the owner chose.
|
|
141
148
|
*/
|
|
142
149
|
export async function atomicWriteFile(targetPath: string, content: string): Promise<void> {
|
|
143
150
|
const dir = path.dirname(targetPath);
|
|
144
151
|
const tempPath = path.join(dir, `.tmp-${process.pid}-${crypto.randomUUID()}`);
|
|
152
|
+
const existingMode = await fs.stat(targetPath).then(
|
|
153
|
+
(st) => st.mode & 0o777,
|
|
154
|
+
() => undefined,
|
|
155
|
+
);
|
|
145
156
|
let handle: FileHandle | undefined;
|
|
146
157
|
try {
|
|
147
158
|
handle = await fs.open(tempPath, 'wx', FILE_CREATE_MODE);
|
|
159
|
+
if (existingMode !== undefined) await handle.chmod(existingMode);
|
|
148
160
|
await handle.writeFile(content, 'utf-8');
|
|
149
161
|
await handle.sync();
|
|
150
162
|
await handle.close();
|
package/src/version.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const VERSION = '0.
|
|
1
|
+
export const VERSION = '0.124.0'; // x-release-please-version
|
|
@@ -4,10 +4,13 @@
|
|
|
4
4
|
* error messages. Kept out of `node.ts` so the tool implementations stay focused
|
|
5
5
|
* and these helpers can be reused by every file tool.
|
|
6
6
|
*/
|
|
7
|
-
/** Mode for directories the file tools create
|
|
8
|
-
export declare const DIR_CREATE_MODE =
|
|
9
|
-
/**
|
|
10
|
-
|
|
7
|
+
/** Mode for directories the file tools create: owner-only under any umask, like the memory tool. */
|
|
8
|
+
export declare const DIR_CREATE_MODE = 448;
|
|
9
|
+
/**
|
|
10
|
+
* Mode for files the file tools create: owner-only, so other local users can't
|
|
11
|
+
* read what an agent wrote. A file that already exists keeps its own mode.
|
|
12
|
+
*/
|
|
13
|
+
export declare const FILE_CREATE_MODE = 384;
|
|
11
14
|
/** True when `p` is `root` itself or lexically contained within it. */
|
|
12
15
|
export declare function isWithin(root: string, p: string): boolean;
|
|
13
16
|
/**
|
|
@@ -62,6 +65,10 @@ export declare function confineToRoot(root: string, p: string, opts?: {
|
|
|
62
65
|
* Atomically write `content` to `targetPath`: write a sibling temp file, fsync
|
|
63
66
|
* it, then rename over the target. The rename is atomic on most filesystems, so
|
|
64
67
|
* a crash mid-write never leaves the target half-written.
|
|
68
|
+
*
|
|
69
|
+
* A new file is created {@link FILE_CREATE_MODE}; an existing one keeps its
|
|
70
|
+
* permission bits (the rename replaces the inode, so they are copied onto the
|
|
71
|
+
* temp file first) — an edit must not strip `+x` or sharing the owner chose.
|
|
65
72
|
*/
|
|
66
73
|
export declare function atomicWriteFile(targetPath: string, content: string): Promise<void>;
|
|
67
74
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fs-util.d.mts","sourceRoot":"","sources":["../../src/tools/agent-toolset/fs-util.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAQH,
|
|
1
|
+
{"version":3,"file":"fs-util.d.mts","sourceRoot":"","sources":["../../src/tools/agent-toolset/fs-util.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAQH,oGAAoG;AACpG,eAAO,MAAM,eAAe,MAAQ,CAAC;AACrC;;;GAGG;AACH,eAAO,MAAM,gBAAgB,MAAQ,CAAC;AAEtC,uEAAuE;AACvE,wBAAgB,QAAQ,CAAC,IAAI,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG,OAAO,CAGzD;AAED;;;;;;;GAOG;AACH,wBAAsB,cAAc,CAAC,KAAK,EAAE,SAAS,MAAM,EAAE,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC,CAK1G;AAKD,2EAA2E;AAC3E,wBAAgB,SAAS,CAAC,GAAG,EAAE,OAAO,GAAG,MAAM,GAAG,SAAS,CAG1D;AAED;;;;;;;;;;;;GAYG;AACH,wBAAsB,YAAY,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CA8B/D;AAED;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAsB,aAAa,CACjC,IAAI,EAAE,MAAM,EACZ,CAAC,EAAE,MAAM,EACT,IAAI,CAAC,EAAE;IAAE,YAAY,CAAC,EAAE,SAAS,MAAM,EAAE,CAAA;CAAE,GAC1C,OAAO,CAAC,MAAM,CAAC,CAiBjB;AAED;;;;;;;;GAQG;AACH,wBAAsB,eAAe,CAAC,UAAU,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAqBxF;AAED;;;;;;GAMG;AACH,wBAAgB,cAAc,CAAC,GAAG,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM,CAwBjE"}
|
|
@@ -4,10 +4,13 @@
|
|
|
4
4
|
* error messages. Kept out of `node.ts` so the tool implementations stay focused
|
|
5
5
|
* and these helpers can be reused by every file tool.
|
|
6
6
|
*/
|
|
7
|
-
/** Mode for directories the file tools create
|
|
8
|
-
export declare const DIR_CREATE_MODE =
|
|
9
|
-
/**
|
|
10
|
-
|
|
7
|
+
/** Mode for directories the file tools create: owner-only under any umask, like the memory tool. */
|
|
8
|
+
export declare const DIR_CREATE_MODE = 448;
|
|
9
|
+
/**
|
|
10
|
+
* Mode for files the file tools create: owner-only, so other local users can't
|
|
11
|
+
* read what an agent wrote. A file that already exists keeps its own mode.
|
|
12
|
+
*/
|
|
13
|
+
export declare const FILE_CREATE_MODE = 384;
|
|
11
14
|
/** True when `p` is `root` itself or lexically contained within it. */
|
|
12
15
|
export declare function isWithin(root: string, p: string): boolean;
|
|
13
16
|
/**
|
|
@@ -62,6 +65,10 @@ export declare function confineToRoot(root: string, p: string, opts?: {
|
|
|
62
65
|
* Atomically write `content` to `targetPath`: write a sibling temp file, fsync
|
|
63
66
|
* it, then rename over the target. The rename is atomic on most filesystems, so
|
|
64
67
|
* a crash mid-write never leaves the target half-written.
|
|
68
|
+
*
|
|
69
|
+
* A new file is created {@link FILE_CREATE_MODE}; an existing one keeps its
|
|
70
|
+
* permission bits (the rename replaces the inode, so they are copied onto the
|
|
71
|
+
* temp file first) — an edit must not strip `+x` or sharing the owner chose.
|
|
65
72
|
*/
|
|
66
73
|
export declare function atomicWriteFile(targetPath: string, content: string): Promise<void>;
|
|
67
74
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fs-util.d.ts","sourceRoot":"","sources":["../../src/tools/agent-toolset/fs-util.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAQH,
|
|
1
|
+
{"version":3,"file":"fs-util.d.ts","sourceRoot":"","sources":["../../src/tools/agent-toolset/fs-util.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAQH,oGAAoG;AACpG,eAAO,MAAM,eAAe,MAAQ,CAAC;AACrC;;;GAGG;AACH,eAAO,MAAM,gBAAgB,MAAQ,CAAC;AAEtC,uEAAuE;AACvE,wBAAgB,QAAQ,CAAC,IAAI,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG,OAAO,CAGzD;AAED;;;;;;;GAOG;AACH,wBAAsB,cAAc,CAAC,KAAK,EAAE,SAAS,MAAM,EAAE,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC,CAK1G;AAKD,2EAA2E;AAC3E,wBAAgB,SAAS,CAAC,GAAG,EAAE,OAAO,GAAG,MAAM,GAAG,SAAS,CAG1D;AAED;;;;;;;;;;;;GAYG;AACH,wBAAsB,YAAY,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CA8B/D;AAED;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAsB,aAAa,CACjC,IAAI,EAAE,MAAM,EACZ,CAAC,EAAE,MAAM,EACT,IAAI,CAAC,EAAE;IAAE,YAAY,CAAC,EAAE,SAAS,MAAM,EAAE,CAAA;CAAE,GAC1C,OAAO,CAAC,MAAM,CAAC,CAiBjB;AAED;;;;;;;;GAQG;AACH,wBAAsB,eAAe,CAAC,UAAU,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAqBxF;AAED;;;;;;GAMG;AACH,wBAAgB,cAAc,CAAC,GAAG,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM,CAwBjE"}
|
|
@@ -17,10 +17,13 @@ exports.fsErrorMessage = fsErrorMessage;
|
|
|
17
17
|
const node_1 = require("../../internal/node.js");
|
|
18
18
|
const ToolError_1 = require("../../lib/tools/ToolError.js");
|
|
19
19
|
const fs = node_1.fs.promises;
|
|
20
|
-
/** Mode for directories the file tools create
|
|
21
|
-
exports.DIR_CREATE_MODE =
|
|
22
|
-
/**
|
|
23
|
-
|
|
20
|
+
/** Mode for directories the file tools create: owner-only under any umask, like the memory tool. */
|
|
21
|
+
exports.DIR_CREATE_MODE = 0o700;
|
|
22
|
+
/**
|
|
23
|
+
* Mode for files the file tools create: owner-only, so other local users can't
|
|
24
|
+
* read what an agent wrote. A file that already exists keeps its own mode.
|
|
25
|
+
*/
|
|
26
|
+
exports.FILE_CREATE_MODE = 0o600;
|
|
24
27
|
/** True when `p` is `root` itself or lexically contained within it. */
|
|
25
28
|
function isWithin(root, p) {
|
|
26
29
|
const rel = node_1.path.relative(root, p);
|
|
@@ -139,13 +142,20 @@ async function confineToRoot(root, p, opts) {
|
|
|
139
142
|
* Atomically write `content` to `targetPath`: write a sibling temp file, fsync
|
|
140
143
|
* it, then rename over the target. The rename is atomic on most filesystems, so
|
|
141
144
|
* a crash mid-write never leaves the target half-written.
|
|
145
|
+
*
|
|
146
|
+
* A new file is created {@link FILE_CREATE_MODE}; an existing one keeps its
|
|
147
|
+
* permission bits (the rename replaces the inode, so they are copied onto the
|
|
148
|
+
* temp file first) — an edit must not strip `+x` or sharing the owner chose.
|
|
142
149
|
*/
|
|
143
150
|
async function atomicWriteFile(targetPath, content) {
|
|
144
151
|
const dir = node_1.path.dirname(targetPath);
|
|
145
152
|
const tempPath = node_1.path.join(dir, `.tmp-${process.pid}-${node_1.crypto.randomUUID()}`);
|
|
153
|
+
const existingMode = await fs.stat(targetPath).then((st) => st.mode & 0o777, () => undefined);
|
|
146
154
|
let handle;
|
|
147
155
|
try {
|
|
148
156
|
handle = await fs.open(tempPath, 'wx', exports.FILE_CREATE_MODE);
|
|
157
|
+
if (existingMode !== undefined)
|
|
158
|
+
await handle.chmod(existingMode);
|
|
149
159
|
await handle.writeFile(content, 'utf-8');
|
|
150
160
|
await handle.sync();
|
|
151
161
|
await handle.close();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fs-util.js","sourceRoot":"","sources":["../../src/tools/agent-toolset/fs-util.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;
|
|
1
|
+
{"version":3,"file":"fs-util.js","sourceRoot":"","sources":["../../src/tools/agent-toolset/fs-util.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;AAiBH,4BAGC;AAUD,wCAKC;AAMD,8BAGC;AAeD,oCA8BC;AAsBD,sCAqBC;AAWD,0CAqBC;AASD,wCAwBC;AAlMD,iDAAiE;AACjE,4DAAsD;AAEtD,MAAM,EAAE,GAAG,SAAM,CAAC,QAAQ,CAAC;AAE3B,oGAAoG;AACvF,QAAA,eAAe,GAAG,KAAK,CAAC;AACrC;;;GAGG;AACU,QAAA,gBAAgB,GAAG,KAAK,CAAC;AAEtC,uEAAuE;AACvE,SAAgB,QAAQ,CAAC,IAAY,EAAE,CAAS;IAC9C,MAAM,GAAG,GAAG,WAAI,CAAC,QAAQ,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC;IACnC,OAAO,GAAG,KAAK,EAAE,IAAI,CAAC,CAAC,GAAG,CAAC,UAAU,CAAC,IAAI,GAAG,WAAI,CAAC,GAAG,CAAC,IAAI,GAAG,KAAK,IAAI,IAAI,CAAC,WAAI,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC,CAAC;AACnG,CAAC;AAED;;;;;;;GAOG;AACI,KAAK,UAAU,cAAc,CAAC,KAAwB,EAAE,MAAc;IAC3E,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;QACzB,IAAI,QAAQ,CAAC,MAAM,YAAY,CAAC,WAAI,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,EAAE,MAAM,CAAC;YAAE,OAAO,IAAI,CAAC;IAC5E,CAAC;IACD,OAAO,SAAS,CAAC;AACnB,CAAC;AAED,yFAAyF;AACzF,MAAM,gBAAgB,GAAG,EAAE,CAAC;AAE5B,2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jD,MAAM,EAAE,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,KAAK,CAAC,GAAG,EAAE,GAAE,CAAC,CAAC,CAAC;QAC1C,MAAM,GAAG,CAAC;IACZ,CAAC;AACH,CAAC;AAED;;;;;;GAMG;AACH,SAAgB,cAAc,CAAC,GAAY,EAAE,IAAY;IACvD,MAAM,IAAI,GAAG,SAAS,CAAC,GAAG,CAAC,CAAC;IAC5B,QAAQ,IAAI,EAAE,CAAC;QACb,KAAK,QAAQ;YACX,OAAO,GAAG,IAAI,6BAA6B,CAAC;QAC9C,KAAK,QAAQ,CAAC;QACd,KAAK,OAAO;YACV,OAAO,GAAG,IAAI,qBAAqB,CAAC;QACtC,KAAK,SAAS;YACZ,OAAO,GAAG,IAAI,mBAAmB,CAAC;QACpC,KAAK,QAAQ;YACX,OAAO,GAAG,IAAI,kBAAkB,CAAC;QACnC,KAAK,OAAO;YACV,OAAO,GAAG,IAAI,qCAAqC,CAAC;QACtD,KAAK,cAAc;YACjB,OAAO,GAAG,IAAI,sBAAsB,CAAC;QACvC,KAAK,QAAQ;YACX,OAAO,GAAG,IAAI,2BAA2B,CAAC;QAC5C,KAAK,QAAQ,CAAC;QACd,KAAK,QAAQ;YACX,OAAO,GAAG,IAAI,uBAAuB,CAAC;QACxC;YACE,OAAO,GAAG,IAAI,KAAK,IAAI,KAAK,SAAS,CAAC,CAAC,CAAC,cAAc,IAAI,GAAG,CAAC,CAAC,CAAC,WAAW,EAAE,CAAC;IAClF,CAAC;AACH,CAAC"}
|
|
@@ -7,10 +7,13 @@
|
|
|
7
7
|
import { crypto, fs as nodefs, path } from "../../internal/node.mjs";
|
|
8
8
|
import { ToolError } from "../../lib/tools/ToolError.mjs";
|
|
9
9
|
const fs = nodefs.promises;
|
|
10
|
-
/** Mode for directories the file tools create
|
|
11
|
-
export const DIR_CREATE_MODE =
|
|
12
|
-
/**
|
|
13
|
-
|
|
10
|
+
/** Mode for directories the file tools create: owner-only under any umask, like the memory tool. */
|
|
11
|
+
export const DIR_CREATE_MODE = 0o700;
|
|
12
|
+
/**
|
|
13
|
+
* Mode for files the file tools create: owner-only, so other local users can't
|
|
14
|
+
* read what an agent wrote. A file that already exists keeps its own mode.
|
|
15
|
+
*/
|
|
16
|
+
export const FILE_CREATE_MODE = 0o600;
|
|
14
17
|
/** True when `p` is `root` itself or lexically contained within it. */
|
|
15
18
|
export function isWithin(root, p) {
|
|
16
19
|
const rel = path.relative(root, p);
|
|
@@ -129,13 +132,20 @@ export async function confineToRoot(root, p, opts) {
|
|
|
129
132
|
* Atomically write `content` to `targetPath`: write a sibling temp file, fsync
|
|
130
133
|
* it, then rename over the target. The rename is atomic on most filesystems, so
|
|
131
134
|
* a crash mid-write never leaves the target half-written.
|
|
135
|
+
*
|
|
136
|
+
* A new file is created {@link FILE_CREATE_MODE}; an existing one keeps its
|
|
137
|
+
* permission bits (the rename replaces the inode, so they are copied onto the
|
|
138
|
+
* temp file first) — an edit must not strip `+x` or sharing the owner chose.
|
|
132
139
|
*/
|
|
133
140
|
export async function atomicWriteFile(targetPath, content) {
|
|
134
141
|
const dir = path.dirname(targetPath);
|
|
135
142
|
const tempPath = path.join(dir, `.tmp-${process.pid}-${crypto.randomUUID()}`);
|
|
143
|
+
const existingMode = await fs.stat(targetPath).then((st) => st.mode & 0o777, () => undefined);
|
|
136
144
|
let handle;
|
|
137
145
|
try {
|
|
138
146
|
handle = await fs.open(tempPath, 'wx', FILE_CREATE_MODE);
|
|
147
|
+
if (existingMode !== undefined)
|
|
148
|
+
await handle.chmod(existingMode);
|
|
139
149
|
await handle.writeFile(content, 'utf-8');
|
|
140
150
|
await handle.sync();
|
|
141
151
|
await handle.close();
|