@puku-ai/sdk 2.0.2 → 2.0.3
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/README.md +45 -0
- package/dist/helpers/beta/json-schema.d.mts +13 -3
- package/dist/helpers/beta/json-schema.d.ts.map +1 -1
- package/dist/helpers/beta/json-schema.js +10 -6
- package/dist/helpers/beta/json-schema.js.map +1 -1
- package/dist/helpers/beta/json-schema.mjs +10 -6
- package/dist/helpers/beta/json-schema.mjs.map +1 -1
- package/dist/internal/utils/promise.d.mts +11 -0
- package/dist/internal/utils/promise.d.ts.map +1 -0
- package/dist/internal/utils/promise.js +18 -0
- package/dist/internal/utils/promise.js.map +1 -0
- package/dist/internal/utils/promise.mjs +15 -0
- package/dist/internal/utils/promise.mjs.map +1 -0
- package/dist/lib/tools/BetaRunnableTool.d.mts +46 -1
- package/dist/lib/tools/BetaRunnableTool.d.ts.map +1 -1
- package/dist/lib/tools/BetaRunnableTool.js +26 -0
- package/dist/lib/tools/BetaRunnableTool.js.map +1 -1
- package/dist/lib/tools/BetaRunnableTool.mjs +24 -1
- package/dist/lib/tools/BetaRunnableTool.mjs.map +1 -1
- package/dist/tools/agent-toolset/fs-util.d.mts +50 -0
- package/dist/tools/agent-toolset/fs-util.d.ts.map +1 -0
- package/dist/tools/agent-toolset/fs-util.js +191 -0
- package/dist/tools/agent-toolset/fs-util.js.map +1 -0
- package/dist/tools/agent-toolset/fs-util.mjs +151 -0
- package/dist/tools/agent-toolset/fs-util.mjs.map +1 -0
- package/dist/tools/agent-toolset/node.browser.d.mts +51 -0
- package/dist/tools/agent-toolset/node.browser.d.ts.map +1 -0
- package/dist/tools/agent-toolset/node.browser.js +94 -0
- package/dist/tools/agent-toolset/node.browser.js.map +1 -0
- package/dist/tools/agent-toolset/node.browser.mjs +78 -0
- package/dist/tools/agent-toolset/node.browser.mjs.map +1 -0
- package/dist/tools/agent-toolset/node.d.mts +158 -0
- package/dist/tools/agent-toolset/node.d.ts.map +1 -0
- package/dist/tools/agent-toolset/node.js +814 -0
- package/dist/tools/agent-toolset/node.js.map +1 -0
- package/dist/tools/agent-toolset/node.mjs +765 -0
- package/dist/tools/agent-toolset/node.mjs.map +1 -0
- package/dist/tools/agent-toolset/skills.d.mts +75 -0
- package/dist/tools/agent-toolset/skills.d.ts.map +1 -0
- package/dist/tools/agent-toolset/skills.js +196 -0
- package/dist/tools/agent-toolset/skills.js.map +1 -0
- package/dist/tools/agent-toolset/skills.mjs +153 -0
- package/dist/tools/agent-toolset/skills.mjs.map +1 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -159,6 +159,7 @@ PUKU_API_KEY=pk_live_... \
|
|
|
159
159
|
| `client.beta.messages.toolRunner(...).runUntilDone()` | ✅ works | `client.beta.messages` |
|
|
160
160
|
| `ToolError` class (exceptions from the runner) | ✅ works | `helpers/beta` |
|
|
161
161
|
| MCP helpers (`mcpTool`, `mcpTools`, `mcpMessage`, `mcpMessages`, `mcpResourceToContent`, `mcpResourceToFile`) | ✅ exported | `helpers/beta/mcp` |
|
|
162
|
+
| Agent toolset (`betaAgentToolset20260401`, `betaBashTool`, `betaReadTool`, `betaWriteTool`, `betaEditTool`, `betaGlobTool`, `betaGrepTool`) | ✅ exported | `tools/agent-toolset` |
|
|
162
163
|
| Full error hierarchy (`APIError`, `RateLimitError`, `AuthenticationError`, …) | ✅ works | static on `PukuAI` |
|
|
163
164
|
|
|
164
165
|
### Known gateway gaps (SDK calls the correct path, gateway returns 404)
|
|
@@ -271,6 +272,50 @@ const reply = await client.beta.messages.create({
|
|
|
271
272
|
});
|
|
272
273
|
```
|
|
273
274
|
|
|
275
|
+
### Example: agent toolset (bash / read / write / edit / glob / grep)
|
|
276
|
+
|
|
277
|
+
The SDK ships the upstream `tools/agent-toolset` surface — the same `BetaRunnableTool[]`
|
|
278
|
+
factory used by puku-cli's agent mode to give the model a sandboxed shell + filesystem.
|
|
279
|
+
|
|
280
|
+
```ts
|
|
281
|
+
import { betaAgentToolset20260401 } from "@puku-ai/sdk/tools/agent-toolset/node";
|
|
282
|
+
|
|
283
|
+
const tools = betaAgentToolset20260401({ workdir: "/tmp/sandbox" });
|
|
284
|
+
// -> [bash, read, write, edit, glob, grep]
|
|
285
|
+
|
|
286
|
+
const runner = client.beta.messages.toolRunner({
|
|
287
|
+
model: "puku-ai-2.8",
|
|
288
|
+
max_tokens: 1024,
|
|
289
|
+
messages: [{ role: "user", content: "List /tmp/sandbox and grep for TODO" }],
|
|
290
|
+
tools,
|
|
291
|
+
});
|
|
292
|
+
const final = await runner.runUntilDone();
|
|
293
|
+
```
|
|
294
|
+
|
|
295
|
+
Drop individual tools in or out:
|
|
296
|
+
|
|
297
|
+
```ts
|
|
298
|
+
const tools = betaAgentToolset20260401({ workdir: "/tmp/sandbox" })
|
|
299
|
+
.filter((t) => t.name !== "bash"); // no shell access
|
|
300
|
+
```
|
|
301
|
+
|
|
302
|
+
Or pick the individual factories:
|
|
303
|
+
|
|
304
|
+
```ts
|
|
305
|
+
import { betaReadTool, betaBashTool } from "@puku-ai/sdk/tools/agent-toolset/node";
|
|
306
|
+
|
|
307
|
+
const tools = [betaReadTool({ workdir: "/tmp/sandbox" })];
|
|
308
|
+
```
|
|
309
|
+
|
|
310
|
+
> `setupSkills`, `resolveSkillVersion`, and `extractSkillArchive` require
|
|
311
|
+
> `/v1/skills/{id}/versions/{version}` (download/retrieve/list) and
|
|
312
|
+
> `/v1/sessions/{id}`, which the Puku gateway doesn't proxy. They throw
|
|
313
|
+
> a clear `AnthropicError` at runtime if invoked, mirroring how
|
|
314
|
+
> `node.browser.ts` stubs Node-only APIs for the browser bundle. The
|
|
315
|
+
> archive-validation helpers (`assertSafeMemberNames`,
|
|
316
|
+
> `assertNoSpecialMembers`, `runArchiveTool`, `archiveTopDir`, `readHead`)
|
|
317
|
+
> stay available — they are pure functions and don't touch the gateway.
|
|
318
|
+
|
|
274
319
|
## Namespace
|
|
275
320
|
|
|
276
321
|
Resource and helper types live on the `PukuAI` class so they can be used
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { FromSchema, JSONSchema } from 'json-schema-to-ts';
|
|
2
|
-
import { Promisable, BetaRunnableTool } from '../../lib/tools/BetaRunnableTool.js';
|
|
2
|
+
import { Promisable, BetaRunnableTool, BetaToolRunContext } from '../../lib/tools/BetaRunnableTool.js';
|
|
3
3
|
import { BetaToolResultContentBlockParam } from '../../resources/beta.js';
|
|
4
4
|
import { AutoParseableBetaOutputFormat } from '../../lib/beta-parser.js';
|
|
5
5
|
type NoInfer<T> = T extends infer R ? R : never;
|
|
@@ -7,6 +7,11 @@ type NoInfer<T> = T extends infer R ? R : never;
|
|
|
7
7
|
* Creates a Tool with a provided JSON schema that can be passed
|
|
8
8
|
* to the `.toolRunner()` method. The schema is used to automatically validate
|
|
9
9
|
* the input arguments for the tool.
|
|
10
|
+
*
|
|
11
|
+
* Mirrors upstream `@anthropic-ai/sdk`'s `betaTool`: `run` may take an
|
|
12
|
+
* optional `BetaToolRunContext` and `close` is honored on the resulting
|
|
13
|
+
* `BetaRunnableTool` so callers that hold resources (e.g. a persistent
|
|
14
|
+
* shell) can clean them up when iteration ends.
|
|
10
15
|
*/
|
|
11
16
|
export declare function betaTool<const Schema extends Exclude<JSONSchema, boolean> & {
|
|
12
17
|
type: 'object';
|
|
@@ -14,10 +19,15 @@ export declare function betaTool<const Schema extends Exclude<JSONSchema, boolea
|
|
|
14
19
|
name: string;
|
|
15
20
|
inputSchema: Schema;
|
|
16
21
|
description: string;
|
|
17
|
-
run: (args: NoInfer<FromSchema<Schema
|
|
22
|
+
run: (args: NoInfer<FromSchema<Schema>>, context?: BetaToolRunContext) => Promisable<string | Array<BetaToolResultContentBlockParam>>;
|
|
23
|
+
/**
|
|
24
|
+
* Optional cleanup hook for tools that hold process-level resources
|
|
25
|
+
* (e.g. a persistent shell).
|
|
26
|
+
*/
|
|
27
|
+
close?: () => Promisable<void>;
|
|
18
28
|
}): BetaRunnableTool<NoInfer<FromSchema<Schema>>>;
|
|
19
29
|
/**
|
|
20
|
-
* Creates a JSON schema output format object
|
|
30
|
+
* Creates a JSON schema output format object with the given JSON schema.
|
|
21
31
|
* If this is passed to the `.parse()` method then the response message will contain a
|
|
22
32
|
* `.parsed_output` property that is the result of parsing the content with the given JSON schema.
|
|
23
33
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"json-schema.d.ts","sourceRoot":"","sources":["../../../src/vendor/helpers/beta/json-schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAC3D,OAAO,EAAE,UAAU,EAAE,gBAAgB,EAAE,MAAM,qCAAqC,CAAC;
|
|
1
|
+
{"version":3,"file":"json-schema.d.ts","sourceRoot":"","sources":["../../../src/vendor/helpers/beta/json-schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAC3D,OAAO,EAAE,UAAU,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,MAAM,qCAAqC,CAAC;AACvG,OAAO,EAAE,+BAA+B,EAAE,MAAM,yBAAyB,CAAC;AAC1E,OAAO,EAAE,6BAA6B,EAAE,MAAM,0BAA0B,CAAC;AAIzE,KAAK,OAAO,CAAC,CAAC,IAAI,CAAC,SAAS,MAAM,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC;AAEhD;;;;;;;;;GASG;AACH,wBAAgB,QAAQ,CAAC,KAAK,CAAC,MAAM,SAAS,OAAO,CAAC,UAAU,EAAE,OAAO,CAAC,GAAG;IAAE,IAAI,EAAE,QAAQ,CAAA;CAAE,EAAE,OAAO,EAAE;IACxG,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,WAAW,EAAE,MAAM,CAAC;IACpB,GAAG,EAAE,CACH,IAAI,EAAE,OAAO,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC,EACjC,OAAO,CAAC,EAAE,kBAAkB,KACzB,UAAU,CAAC,MAAM,GAAG,KAAK,CAAC,+BAA+B,CAAC,CAAC,CAAC;IACjE;;;OAGG;IACH,KAAK,CAAC,EAAE,MAAM,UAAU,CAAC,IAAI,CAAC,CAAC;CAChC,GAAG,gBAAgB,CAAC,OAAO,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC,CAAC,CAgBhD;AAED;;;;;GAKG;AACH,wBAAgB,0BAA0B,CACxC,KAAK,CAAC,MAAM,SAAS,OAAO,CAAC,UAAU,EAAE,OAAO,CAAC,GAAG;IAAE,IAAI,EAAE,QAAQ,CAAA;CAAE,EAEtE,UAAU,EAAE,MAAM,EAClB,OAAO,CAAC,EAAE;IACR,SAAS,CAAC,EAAE,OAAO,CAAC;CACrB,GACA,6BAA6B,CAAC,OAAO,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC,CAAC,CAuB5D"}
|
|
@@ -8,6 +8,11 @@ const transform_json_schema_js_1 = require("../../lib/transform-json-schema.js")
|
|
|
8
8
|
* Creates a Tool with a provided JSON schema that can be passed
|
|
9
9
|
* to the `.toolRunner()` method. The schema is used to automatically validate
|
|
10
10
|
* the input arguments for the tool.
|
|
11
|
+
*
|
|
12
|
+
* Mirrors upstream `@anthropic-ai/sdk`'s `betaTool`: `run` may take an
|
|
13
|
+
* optional `BetaToolRunContext` and `close` is honored on the resulting
|
|
14
|
+
* `BetaRunnableTool` so callers that hold resources (e.g. a persistent
|
|
15
|
+
* shell) can clean them up when iteration ends.
|
|
11
16
|
*/
|
|
12
17
|
function betaTool(options) {
|
|
13
18
|
if (options.inputSchema.type !== 'object') {
|
|
@@ -20,10 +25,11 @@ function betaTool(options) {
|
|
|
20
25
|
description: options.description,
|
|
21
26
|
run: options.run,
|
|
22
27
|
parse: (content) => content,
|
|
28
|
+
...(options.close ? { close: options.close } : {}),
|
|
23
29
|
};
|
|
24
30
|
}
|
|
25
31
|
/**
|
|
26
|
-
* Creates a JSON schema output format object
|
|
32
|
+
* Creates a JSON schema output format object with the given JSON schema.
|
|
27
33
|
* If this is passed to the `.parse()` method then the response message will contain a
|
|
28
34
|
* `.parsed_output` property that is the result of parsing the content with the given JSON schema.
|
|
29
35
|
*
|
|
@@ -33,11 +39,9 @@ function betaJSONSchemaOutputFormat(jsonSchema, options) {
|
|
|
33
39
|
throw new Error(`JSON schema for tool must be an object, but got ${jsonSchema.type}`);
|
|
34
40
|
}
|
|
35
41
|
const transform = options?.transform ?? true;
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
jsonSchema = (0, transform_json_schema_js_1.transformJSONSchema)(jsonSchema);
|
|
40
|
-
}
|
|
42
|
+
// todo: doing this is arguably necessary, but it does change the schema the user passed in
|
|
43
|
+
// so I'm not sure how we should handle that
|
|
44
|
+
jsonSchema = (0, transform_json_schema_js_1.transformJSONSchema)(jsonSchema);
|
|
41
45
|
return {
|
|
42
46
|
type: 'json_schema',
|
|
43
47
|
schema: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"json-schema.js","sourceRoot":"","sources":["../../../src/vendor/helpers/beta/json-schema.ts"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"json-schema.js","sourceRoot":"","sources":["../../../src/vendor/helpers/beta/json-schema.ts"],"names":[],"mappings":";;AAmBA,4BA6BC;AAQD,gEA8BC;AAlFD,6CAAgD;AAChD,iFAAyE;AAIzE;;;;;;;;;GASG;AACH,SAAgB,QAAQ,CAAyE,OAahG;IACC,IAAI,OAAO,CAAC,WAAW,CAAC,IAAI,KAAK,QAAQ,EAAE,CAAC;QAC1C,MAAM,IAAI,KAAK,CACb,yBAAyB,OAAO,CAAC,IAAI,gCAAgC,OAAO,CAAC,WAAW,CAAC,IAAI,EAAE,CAChG,CAAC;IACJ,CAAC;IAED,OAAO;QACL,IAAI,EAAE,QAAQ;QACd,IAAI,EAAE,OAAO,CAAC,IAAI;QAClB,YAAY,EAAE,OAAO,CAAC,WAAW;QACjC,WAAW,EAAE,OAAO,CAAC,WAAW;QAChC,GAAG,EAAE,OAAO,CAAC,GAAG;QAChB,KAAK,EAAE,CAAC,OAAgB,EAAE,EAAE,CAAC,OAA6B;QAC1D,GAAG,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,OAAO,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;KAC5C,CAAC;AACX,CAAC;AAED;;;;;GAKG;AACH,SAAgB,0BAA0B,CAGxC,UAAkB,EAClB,OAEC;IAED,IAAI,UAAU,CAAC,IAAI,KAAK,QAAQ,EAAE,CAAC;QACjC,MAAM,IAAI,KAAK,CAAC,mDAAmD,UAAU,CAAC,IAAI,EAAE,CAAC,CAAC;IACxF,CAAC;IAED,MAAM,SAAS,GAAG,OAAO,EAAE,SAAS,IAAI,IAAI,CAAC;IAC7C,2FAA2F;IAC3F,4CAA4C;IAC5C,UAAU,GAAG,IAAA,8CAAmB,EAAC,UAAU,CAAW,CAAC;IAEvD,OAAO;QACL,IAAI,EAAE,aAAa;QACnB,MAAM,EAAE;YACN,GAAG,UAAU;SACd;QACD,KAAK,EAAE,CAAC,OAAO,EAAE,EAAE;YACjB,IAAI,CAAC;gBACH,OAAO,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;YAC7B,CAAC;YAAC,OAAO,KAAK,EAAE,CAAC;gBACf,MAAM,IAAI,yBAAc,CAAC,sCAAsC,KAAK,EAAE,CAAC,CAAC;YAC1E,CAAC;QACH,CAAC;KACF,CAAC;AACJ,CAAC"}
|
|
@@ -4,6 +4,11 @@ import { transformJSONSchema } from '../../lib/transform-json-schema.js';
|
|
|
4
4
|
* Creates a Tool with a provided JSON schema that can be passed
|
|
5
5
|
* to the `.toolRunner()` method. The schema is used to automatically validate
|
|
6
6
|
* the input arguments for the tool.
|
|
7
|
+
*
|
|
8
|
+
* Mirrors upstream `@anthropic-ai/sdk`'s `betaTool`: `run` may take an
|
|
9
|
+
* optional `BetaToolRunContext` and `close` is honored on the resulting
|
|
10
|
+
* `BetaRunnableTool` so callers that hold resources (e.g. a persistent
|
|
11
|
+
* shell) can clean them up when iteration ends.
|
|
7
12
|
*/
|
|
8
13
|
export function betaTool(options) {
|
|
9
14
|
if (options.inputSchema.type !== 'object') {
|
|
@@ -16,10 +21,11 @@ export function betaTool(options) {
|
|
|
16
21
|
description: options.description,
|
|
17
22
|
run: options.run,
|
|
18
23
|
parse: (content) => content,
|
|
24
|
+
...(options.close ? { close: options.close } : {}),
|
|
19
25
|
};
|
|
20
26
|
}
|
|
21
27
|
/**
|
|
22
|
-
* Creates a JSON schema output format object
|
|
28
|
+
* Creates a JSON schema output format object with the given JSON schema.
|
|
23
29
|
* If this is passed to the `.parse()` method then the response message will contain a
|
|
24
30
|
* `.parsed_output` property that is the result of parsing the content with the given JSON schema.
|
|
25
31
|
*
|
|
@@ -29,11 +35,9 @@ export function betaJSONSchemaOutputFormat(jsonSchema, options) {
|
|
|
29
35
|
throw new Error(`JSON schema for tool must be an object, but got ${jsonSchema.type}`);
|
|
30
36
|
}
|
|
31
37
|
const transform = options?.transform ?? true;
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
jsonSchema = transformJSONSchema(jsonSchema);
|
|
36
|
-
}
|
|
38
|
+
// todo: doing this is arguably necessary, but it does change the schema the user passed in
|
|
39
|
+
// so I'm not sure how we should handle that
|
|
40
|
+
jsonSchema = transformJSONSchema(jsonSchema);
|
|
37
41
|
return {
|
|
38
42
|
type: 'json_schema',
|
|
39
43
|
schema: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"json-schema.js","sourceRoot":"","sources":["../../../src/vendor/helpers/beta/json-schema.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAChD,OAAO,EAAE,mBAAmB,EAAE,MAAM,oCAAoC,CAAC;AAIzE
|
|
1
|
+
{"version":3,"file":"json-schema.js","sourceRoot":"","sources":["../../../src/vendor/helpers/beta/json-schema.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAChD,OAAO,EAAE,mBAAmB,EAAE,MAAM,oCAAoC,CAAC;AAIzE;;;;;;;;;GASG;AACH,MAAM,UAAU,QAAQ,CAAyE,OAahG;IACC,IAAI,OAAO,CAAC,WAAW,CAAC,IAAI,KAAK,QAAQ,EAAE,CAAC;QAC1C,MAAM,IAAI,KAAK,CACb,yBAAyB,OAAO,CAAC,IAAI,gCAAgC,OAAO,CAAC,WAAW,CAAC,IAAI,EAAE,CAChG,CAAC;IACJ,CAAC;IAED,OAAO;QACL,IAAI,EAAE,QAAQ;QACd,IAAI,EAAE,OAAO,CAAC,IAAI;QAClB,YAAY,EAAE,OAAO,CAAC,WAAW;QACjC,WAAW,EAAE,OAAO,CAAC,WAAW;QAChC,GAAG,EAAE,OAAO,CAAC,GAAG;QAChB,KAAK,EAAE,CAAC,OAAgB,EAAE,EAAE,CAAC,OAA6B;QAC1D,GAAG,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,OAAO,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;KAC5C,CAAC;AACX,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,0BAA0B,CAGxC,UAAkB,EAClB,OAEC;IAED,IAAI,UAAU,CAAC,IAAI,KAAK,QAAQ,EAAE,CAAC;QACjC,MAAM,IAAI,KAAK,CAAC,mDAAmD,UAAU,CAAC,IAAI,EAAE,CAAC,CAAC;IACxF,CAAC;IAED,MAAM,SAAS,GAAG,OAAO,EAAE,SAAS,IAAI,IAAI,CAAC;IAC7C,2FAA2F;IAC3F,4CAA4C;IAC5C,UAAU,GAAG,mBAAmB,CAAC,UAAU,CAAW,CAAC;IAEvD,OAAO;QACL,IAAI,EAAE,aAAa;QACnB,MAAM,EAAE;YACN,GAAG,UAAU;SACd;QACD,KAAK,EAAE,CAAC,OAAO,EAAE,EAAE;YACjB,IAAI,CAAC;gBACH,OAAO,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;YAC7B,CAAC;YAAC,OAAO,KAAK,EAAE,CAAC;gBACf,MAAM,IAAI,cAAc,CAAC,sCAAsC,KAAK,EAAE,CAAC,CAAC;YAC1E,CAAC;QACH,CAAC;KACF,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A deferred: a `Promise` together with its `resolve` / `reject` functions.
|
|
3
|
+
* This is `Promise.withResolvers()`, which is not available in all supported
|
|
4
|
+
* runtimes.
|
|
5
|
+
*/
|
|
6
|
+
export declare function promiseWithResolvers<T>(): {
|
|
7
|
+
promise: Promise<T>;
|
|
8
|
+
resolve: (value: T | PromiseLike<T>) => void;
|
|
9
|
+
reject: (reason?: unknown) => void;
|
|
10
|
+
};
|
|
11
|
+
//# sourceMappingURL=promise.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"promise.d.ts","sourceRoot":"","sources":["../../../src/vendor/internal/utils/promise.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,wBAAgB,oBAAoB,CAAC,CAAC,KAAK;IACzC,OAAO,EAAE,OAAO,CAAC,CAAC,CAAC,CAAC;IACpB,OAAO,EAAE,CAAC,KAAK,EAAE,CAAC,GAAG,WAAW,CAAC,CAAC,CAAC,KAAK,IAAI,CAAC;IAC7C,MAAM,EAAE,CAAC,MAAM,CAAC,EAAE,OAAO,KAAK,IAAI,CAAC;CACpC,CAQA"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.promiseWithResolvers = promiseWithResolvers;
|
|
4
|
+
/**
|
|
5
|
+
* A deferred: a `Promise` together with its `resolve` / `reject` functions.
|
|
6
|
+
* This is `Promise.withResolvers()`, which is not available in all supported
|
|
7
|
+
* runtimes.
|
|
8
|
+
*/
|
|
9
|
+
function promiseWithResolvers() {
|
|
10
|
+
let resolve;
|
|
11
|
+
let reject;
|
|
12
|
+
const promise = new Promise((res, rej) => {
|
|
13
|
+
resolve = res;
|
|
14
|
+
reject = rej;
|
|
15
|
+
});
|
|
16
|
+
return { promise, resolve, reject };
|
|
17
|
+
}
|
|
18
|
+
//# sourceMappingURL=promise.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"promise.js","sourceRoot":"","sources":["../../../src/vendor/internal/utils/promise.ts"],"names":[],"mappings":";;AAKA,oDAYC;AAjBD;;;;GAIG;AACH,SAAgB,oBAAoB;IAKlC,IAAI,OAA6C,CAAC;IAClD,IAAI,MAAmC,CAAC;IACxC,MAAM,OAAO,GAAG,IAAI,OAAO,CAAI,CAAC,GAAG,EAAE,GAAG,EAAE,EAAE;QAC1C,OAAO,GAAG,GAAG,CAAC;QACd,MAAM,GAAG,GAAG,CAAC;IACf,CAAC,CAAC,CAAC;IACH,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,CAAC;AACtC,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A deferred: a `Promise` together with its `resolve` / `reject` functions.
|
|
3
|
+
* This is `Promise.withResolvers()`, which is not available in all supported
|
|
4
|
+
* runtimes.
|
|
5
|
+
*/
|
|
6
|
+
export function promiseWithResolvers() {
|
|
7
|
+
let resolve;
|
|
8
|
+
let reject;
|
|
9
|
+
const promise = new Promise((res, rej) => {
|
|
10
|
+
resolve = res;
|
|
11
|
+
reject = rej;
|
|
12
|
+
});
|
|
13
|
+
return { promise, resolve, reject };
|
|
14
|
+
}
|
|
15
|
+
//# sourceMappingURL=promise.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"promise.js","sourceRoot":"","sources":["../../../src/vendor/internal/utils/promise.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,MAAM,UAAU,oBAAoB;IAKlC,IAAI,OAA6C,CAAC;IAClD,IAAI,MAAmC,CAAC;IACxC,MAAM,OAAO,GAAG,IAAI,OAAO,CAAI,CAAC,GAAG,EAAE,GAAG,EAAE,EAAE;QAC1C,OAAO,GAAG,GAAG,CAAC;QACd,MAAM,GAAG,GAAG,CAAC;IACf,CAAC,CAAC,CAAC;IACH,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,CAAC;AACtC,CAAC"}
|
|
@@ -1,12 +1,57 @@
|
|
|
1
1
|
import { BetaMemoryTool20250818, BetaTool, BetaToolBash20241022, BetaToolBash20250124, BetaToolComputerUse20241022, BetaToolComputerUse20250124, BetaToolComputerUse20251124, BetaToolResultContentBlockParam, BetaToolTextEditor20241022, BetaToolTextEditor20250124, BetaToolTextEditor20250429, BetaToolTextEditor20250728 } from '../../resources/beta.js';
|
|
2
|
+
import { BetaToolUseBlock } from '../../resources/beta/messages/messages.js';
|
|
2
3
|
export type Promisable<T> = T | Promise<T>;
|
|
3
4
|
/**
|
|
4
5
|
* Tool types that can be implemented on the client.
|
|
5
6
|
* Excludes server-side tools like code execution, web search, and MCP toolsets.
|
|
6
7
|
*/
|
|
7
8
|
export type BetaClientRunnableToolType = BetaTool | BetaMemoryTool20250818 | BetaToolBash20241022 | BetaToolBash20250124 | BetaToolComputerUse20241022 | BetaToolComputerUse20250124 | BetaToolComputerUse20251124 | BetaToolTextEditor20241022 | BetaToolTextEditor20250124 | BetaToolTextEditor20250429 | BetaToolTextEditor20250728;
|
|
9
|
+
/**
|
|
10
|
+
* Context passed to a {@link BetaRunnableTool.run} callback. Carries the
|
|
11
|
+
* tool-use block that triggered the run, an optional abort signal, and a
|
|
12
|
+
* deprecated alias for `toolUse`.
|
|
13
|
+
*
|
|
14
|
+
* The shape is intentionally minimal: the upstream Anthropic SDK also wires
|
|
15
|
+
* managed-agents events through this type, but @puku-ai/sdk does not yet
|
|
16
|
+
* vendor that resource surface, so the type falls back to a
|
|
17
|
+
* `BetaToolUseBlock`.
|
|
18
|
+
*/
|
|
19
|
+
export type BetaToolRunContext = {
|
|
20
|
+
/** The tool-use block that triggered this run. */
|
|
21
|
+
toolUse: BetaToolUseBlock;
|
|
22
|
+
/**
|
|
23
|
+
* @deprecated Renamed to `toolUse`. Kept here so existing call-sites
|
|
24
|
+
* that read `ctx.toolUseBlock` keep working.
|
|
25
|
+
*/
|
|
26
|
+
toolUseBlock: BetaToolUseBlock;
|
|
27
|
+
signal?: AbortSignal | null | undefined;
|
|
28
|
+
};
|
|
8
29
|
export type BetaRunnableTool<Input = any> = BetaClientRunnableToolType & {
|
|
9
|
-
run: (args: Input) => Promisable<string | Array<BetaToolResultContentBlockParam>>;
|
|
30
|
+
run: (args: Input, context?: BetaToolRunContext) => Promisable<string | Array<BetaToolResultContentBlockParam>>;
|
|
10
31
|
parse: (content: unknown) => Input;
|
|
32
|
+
/**
|
|
33
|
+
* Optional cleanup hook for tools that hold process-level resources
|
|
34
|
+
* (e.g. a persistent shell). The existing `toolRunner()` surfaces in
|
|
35
|
+
* @puku-ai/sdk don't yet invoke this, but matching upstream keeps the
|
|
36
|
+
* shape compatible with future agent-tool runners.
|
|
37
|
+
*/
|
|
38
|
+
close?: () => Promisable<void>;
|
|
11
39
|
};
|
|
40
|
+
/**
|
|
41
|
+
* Format a thrown value into tool-result content: a {@link ToolError} carries
|
|
42
|
+
* its own structured content, anything else becomes an `Error: <message>`
|
|
43
|
+
* string. Shared so every `toolRunner()` surface reports tool failures the
|
|
44
|
+
* same way to the model.
|
|
45
|
+
*/
|
|
46
|
+
export declare function toolErrorContent(e: unknown): string | Array<BetaToolResultContentBlockParam>;
|
|
47
|
+
/** Outcome of {@link runRunnableTool}: the content to post back and whether it is an error. */
|
|
48
|
+
export interface RunnableToolOutcome {
|
|
49
|
+
content: string | Array<BetaToolResultContentBlockParam>;
|
|
50
|
+
isError: boolean;
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Run a {@link BetaRunnableTool} end-to-end: parse the raw input, invoke `run`,
|
|
54
|
+
* and format any thrown value via {@link toolErrorContent}.
|
|
55
|
+
*/
|
|
56
|
+
export declare function runRunnableTool(tool: BetaRunnableTool, rawInput: unknown, context: BetaToolRunContext): Promise<RunnableToolOutcome>;
|
|
12
57
|
//# sourceMappingURL=BetaRunnableTool.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BetaRunnableTool.d.ts","sourceRoot":"","sources":["../../../src/vendor/lib/tools/BetaRunnableTool.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,sBAAsB,EACtB,QAAQ,EACR,oBAAoB,EACpB,oBAAoB,EACpB,2BAA2B,EAC3B,2BAA2B,EAC3B,2BAA2B,EAC3B,+BAA+B,EAC/B,0BAA0B,EAC1B,0BAA0B,EAC1B,0BAA0B,EAC1B,0BAA0B,EAC3B,MAAM,yBAAyB,CAAC;
|
|
1
|
+
{"version":3,"file":"BetaRunnableTool.d.ts","sourceRoot":"","sources":["../../../src/vendor/lib/tools/BetaRunnableTool.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,sBAAsB,EACtB,QAAQ,EACR,oBAAoB,EACpB,oBAAoB,EACpB,2BAA2B,EAC3B,2BAA2B,EAC3B,2BAA2B,EAC3B,+BAA+B,EAC/B,0BAA0B,EAC1B,0BAA0B,EAC1B,0BAA0B,EAC1B,0BAA0B,EAC3B,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAAE,gBAAgB,EAAE,MAAM,2CAA2C,CAAC;AAG7E,MAAM,MAAM,UAAU,CAAC,CAAC,IAAI,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC;AAE3C;;;GAGG;AACH,MAAM,MAAM,0BAA0B,GAClC,QAAQ,GACR,sBAAsB,GACtB,oBAAoB,GACpB,oBAAoB,GACpB,2BAA2B,GAC3B,2BAA2B,GAC3B,2BAA2B,GAC3B,0BAA0B,GAC1B,0BAA0B,GAC1B,0BAA0B,GAC1B,0BAA0B,CAAC;AAE/B;;;;;;;;;GASG;AACH,MAAM,MAAM,kBAAkB,GAAG;IAC/B,kDAAkD;IAClD,OAAO,EAAE,gBAAgB,CAAC;IAC1B;;;OAGG;IACH,YAAY,EAAE,gBAAgB,CAAC;IAC/B,MAAM,CAAC,EAAE,WAAW,GAAG,IAAI,GAAG,SAAS,CAAC;CACzC,CAAC;AAIF,MAAM,MAAM,gBAAgB,CAAC,KAAK,GAAG,GAAG,IAAI,0BAA0B,GAAG;IACvE,GAAG,EAAE,CACH,IAAI,EAAE,KAAK,EACX,OAAO,CAAC,EAAE,kBAAkB,KACzB,UAAU,CAAC,MAAM,GAAG,KAAK,CAAC,+BAA+B,CAAC,CAAC,CAAC;IACjE,KAAK,EAAE,CAAC,OAAO,EAAE,OAAO,KAAK,KAAK,CAAC;IACnC;;;;;OAKG;IACH,KAAK,CAAC,EAAE,MAAM,UAAU,CAAC,IAAI,CAAC,CAAC;CAChC,CAAC;AAEF;;;;;GAKG;AACH,wBAAgB,gBAAgB,CAAC,CAAC,EAAE,OAAO,GAAG,MAAM,GAAG,KAAK,CAAC,+BAA+B,CAAC,CAE5F;AAED,+FAA+F;AAC/F,MAAM,WAAW,mBAAmB;IAClC,OAAO,EAAE,MAAM,GAAG,KAAK,CAAC,+BAA+B,CAAC,CAAC;IACzD,OAAO,EAAE,OAAO,CAAC;CAClB;AAED;;;GAGG;AACH,wBAAsB,eAAe,CACnC,IAAI,EAAE,gBAAgB,EACtB,QAAQ,EAAE,OAAO,EACjB,OAAO,EAAE,kBAAkB,GAC1B,OAAO,CAAC,mBAAmB,CAAC,CAQ9B"}
|
|
@@ -1,3 +1,29 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.toolErrorContent = toolErrorContent;
|
|
4
|
+
exports.runRunnableTool = runRunnableTool;
|
|
5
|
+
const ToolError_js_1 = require("./ToolError.js");
|
|
6
|
+
/**
|
|
7
|
+
* Format a thrown value into tool-result content: a {@link ToolError} carries
|
|
8
|
+
* its own structured content, anything else becomes an `Error: <message>`
|
|
9
|
+
* string. Shared so every `toolRunner()` surface reports tool failures the
|
|
10
|
+
* same way to the model.
|
|
11
|
+
*/
|
|
12
|
+
function toolErrorContent(e) {
|
|
13
|
+
return e instanceof ToolError_js_1.ToolError ? e.content : `Error: ${e instanceof Error ? e.message : String(e)}`;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Run a {@link BetaRunnableTool} end-to-end: parse the raw input, invoke `run`,
|
|
17
|
+
* and format any thrown value via {@link toolErrorContent}.
|
|
18
|
+
*/
|
|
19
|
+
async function runRunnableTool(tool, rawInput, context) {
|
|
20
|
+
try {
|
|
21
|
+
const input = tool.parse ? tool.parse(rawInput) : rawInput;
|
|
22
|
+
const content = await tool.run(input, context);
|
|
23
|
+
return { content, isError: false };
|
|
24
|
+
}
|
|
25
|
+
catch (e) {
|
|
26
|
+
return { content: toolErrorContent(e), isError: true };
|
|
27
|
+
}
|
|
28
|
+
}
|
|
3
29
|
//# sourceMappingURL=BetaRunnableTool.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BetaRunnableTool.js","sourceRoot":"","sources":["../../../src/vendor/lib/tools/BetaRunnableTool.ts"],"names":[],"mappings":""}
|
|
1
|
+
{"version":3,"file":"BetaRunnableTool.js","sourceRoot":"","sources":["../../../src/vendor/lib/tools/BetaRunnableTool.ts"],"names":[],"mappings":";;AAgFA,4CAEC;AAYD,0CAYC;AA3FD,iDAA2C;AA2D3C;;;;;GAKG;AACH,SAAgB,gBAAgB,CAAC,CAAU;IACzC,OAAO,CAAC,YAAY,wBAAS,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,UAAU,CAAC,YAAY,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC;AACrG,CAAC;AAQD;;;GAGG;AACI,KAAK,UAAU,eAAe,CACnC,IAAsB,EACtB,QAAiB,EACjB,OAA2B;IAE3B,IAAI,CAAC;QACH,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC;QAC3D,MAAM,OAAO,GAAG,MAAM,IAAI,CAAC,GAAG,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC;QAC/C,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC;IACrC,CAAC;IAAC,OAAO,CAAC,EAAE,CAAC;QACX,OAAO,EAAE,OAAO,EAAE,gBAAgB,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;IACzD,CAAC;AACH,CAAC"}
|
|
@@ -1,2 +1,25 @@
|
|
|
1
|
-
|
|
1
|
+
import { ToolError } from './ToolError.js';
|
|
2
|
+
/**
|
|
3
|
+
* Format a thrown value into tool-result content: a {@link ToolError} carries
|
|
4
|
+
* its own structured content, anything else becomes an `Error: <message>`
|
|
5
|
+
* string. Shared so every `toolRunner()` surface reports tool failures the
|
|
6
|
+
* same way to the model.
|
|
7
|
+
*/
|
|
8
|
+
export function toolErrorContent(e) {
|
|
9
|
+
return e instanceof ToolError ? e.content : `Error: ${e instanceof Error ? e.message : String(e)}`;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Run a {@link BetaRunnableTool} end-to-end: parse the raw input, invoke `run`,
|
|
13
|
+
* and format any thrown value via {@link toolErrorContent}.
|
|
14
|
+
*/
|
|
15
|
+
export async function runRunnableTool(tool, rawInput, context) {
|
|
16
|
+
try {
|
|
17
|
+
const input = tool.parse ? tool.parse(rawInput) : rawInput;
|
|
18
|
+
const content = await tool.run(input, context);
|
|
19
|
+
return { content, isError: false };
|
|
20
|
+
}
|
|
21
|
+
catch (e) {
|
|
22
|
+
return { content: toolErrorContent(e), isError: true };
|
|
23
|
+
}
|
|
24
|
+
}
|
|
2
25
|
//# sourceMappingURL=BetaRunnableTool.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BetaRunnableTool.js","sourceRoot":"","sources":["../../../src/vendor/lib/tools/BetaRunnableTool.ts"],"names":[],"mappings":""}
|
|
1
|
+
{"version":3,"file":"BetaRunnableTool.js","sourceRoot":"","sources":["../../../src/vendor/lib/tools/BetaRunnableTool.ts"],"names":[],"mappings":"AAeA,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AA2D3C;;;;;GAKG;AACH,MAAM,UAAU,gBAAgB,CAAC,CAAU;IACzC,OAAO,CAAC,YAAY,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,UAAU,CAAC,YAAY,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC;AACrG,CAAC;AAQD;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,eAAe,CACnC,IAAsB,EACtB,QAAiB,EACjB,OAA2B;IAE3B,IAAI,CAAC;QACH,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC;QAC3D,MAAM,OAAO,GAAG,MAAM,IAAI,CAAC,GAAG,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC;QAC/C,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC;IACrC,CAAC;IAAC,OAAO,CAAC,EAAE,CAAC;QACX,OAAO,EAAE,OAAO,EAAE,gBAAgB,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;IACzD,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared, Node-only filesystem helpers for the agent toolset's file tools:
|
|
3
|
+
* path confinement (symlink-aware), an atomic write, and language-independent
|
|
4
|
+
* error messages. Kept out of `node.ts` so the tool implementations stay focused
|
|
5
|
+
* and these helpers can be reused by every file tool.
|
|
6
|
+
*/
|
|
7
|
+
/** Mode for directories the file tools create — not world-writable under a 0 umask. */
|
|
8
|
+
export declare const DIR_CREATE_MODE = 493;
|
|
9
|
+
/** Mode for files the file tools create. */
|
|
10
|
+
export declare const FILE_CREATE_MODE = 420;
|
|
11
|
+
/**
|
|
12
|
+
* Fully resolve `abs`: `realpath` the longest existing ancestor and re-append
|
|
13
|
+
* the rest, but never re-append a component that is itself a symlink — read the
|
|
14
|
+
* link and continue from its target instead. This handles paths being created
|
|
15
|
+
* (write/edit) without letting a symlink leaf (e.g. a dangling one pointing
|
|
16
|
+
* outside a confinement root) slip through unresolved.
|
|
17
|
+
*/
|
|
18
|
+
export declare function canonicalize(abs: string): Promise<string>;
|
|
19
|
+
/**
|
|
20
|
+
* Resolve `p` and confine it to `root`.
|
|
21
|
+
*
|
|
22
|
+
* Absolute and relative inputs go through the same canonicalise-then-contain
|
|
23
|
+
* check — an absolute path that lands inside `root` is permitted, only paths
|
|
24
|
+
* that resolve *outside* are rejected. Every symlink in `p` (including the
|
|
25
|
+
* leaf, even a dangling one) is resolved before the confinement check, and the
|
|
26
|
+
* resolved path is what the caller then operates on, so a symlink inside `root`
|
|
27
|
+
* that points outside it can neither pass the check nor be followed afterwards.
|
|
28
|
+
*
|
|
29
|
+
* Residual TOCTOU: a component could still be swapped for a symlink between this
|
|
30
|
+
* call and the eventual `fs` operation. Closing that fully needs per-component
|
|
31
|
+
* `O_NOFOLLOW`/`openat`, which Node does not expose ergonomically; this is why a
|
|
32
|
+
* sandbox is still recommended for the toolset as a whole.
|
|
33
|
+
*/
|
|
34
|
+
export declare function confineToRoot(root: string, p: string, opts?: {
|
|
35
|
+
allowOutside?: boolean;
|
|
36
|
+
}): Promise<string>;
|
|
37
|
+
/**
|
|
38
|
+
* Atomically write `content` to `targetPath`: write a sibling temp file, fsync
|
|
39
|
+
* it, then rename over the target. The rename is atomic on most filesystems, so
|
|
40
|
+
* a crash mid-write never leaves the target half-written.
|
|
41
|
+
*/
|
|
42
|
+
export declare function atomicWriteFile(targetPath: string, content: string): Promise<void>;
|
|
43
|
+
/**
|
|
44
|
+
* Map a thrown filesystem error to a consistent, language-independent message,
|
|
45
|
+
* so the model sees the same wording regardless of the runtime (Node's raw
|
|
46
|
+
* `ENOENT: no such file...` text would otherwise leak through). Falls back to
|
|
47
|
+
* the raw error message for codes we don't special-case.
|
|
48
|
+
*/
|
|
49
|
+
export declare function fsErrorMessage(err: unknown, file: string): string;
|
|
50
|
+
//# sourceMappingURL=fs-util.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fs-util.d.ts","sourceRoot":"","sources":["../../../src/vendor/tools/agent-toolset/fs-util.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAOH,uFAAuF;AACvF,eAAO,MAAM,eAAe,MAAQ,CAAC;AACrC,4CAA4C;AAC5C,eAAO,MAAM,gBAAgB,MAAQ,CAAC;AAWtC;;;;;;GAMG;AACH,wBAAsB,YAAY,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAkC/D;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAsB,aAAa,CACjC,IAAI,EAAE,MAAM,EACZ,CAAC,EAAE,MAAM,EACT,IAAI,CAAC,EAAE;IAAE,YAAY,CAAC,EAAE,OAAO,CAAA;CAAE,GAChC,OAAO,CAAC,MAAM,CAAC,CAUjB;AAED;;;;GAIG;AACH,wBAAsB,eAAe,CAAC,UAAU,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAgBxF;AAED;;;;;GAKG;AACH,wBAAgB,cAAc,CAAC,GAAG,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM,CAwBjE"}
|