@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.
Files changed (44) hide show
  1. package/README.md +45 -0
  2. package/dist/helpers/beta/json-schema.d.mts +13 -3
  3. package/dist/helpers/beta/json-schema.d.ts.map +1 -1
  4. package/dist/helpers/beta/json-schema.js +10 -6
  5. package/dist/helpers/beta/json-schema.js.map +1 -1
  6. package/dist/helpers/beta/json-schema.mjs +10 -6
  7. package/dist/helpers/beta/json-schema.mjs.map +1 -1
  8. package/dist/internal/utils/promise.d.mts +11 -0
  9. package/dist/internal/utils/promise.d.ts.map +1 -0
  10. package/dist/internal/utils/promise.js +18 -0
  11. package/dist/internal/utils/promise.js.map +1 -0
  12. package/dist/internal/utils/promise.mjs +15 -0
  13. package/dist/internal/utils/promise.mjs.map +1 -0
  14. package/dist/lib/tools/BetaRunnableTool.d.mts +46 -1
  15. package/dist/lib/tools/BetaRunnableTool.d.ts.map +1 -1
  16. package/dist/lib/tools/BetaRunnableTool.js +26 -0
  17. package/dist/lib/tools/BetaRunnableTool.js.map +1 -1
  18. package/dist/lib/tools/BetaRunnableTool.mjs +24 -1
  19. package/dist/lib/tools/BetaRunnableTool.mjs.map +1 -1
  20. package/dist/tools/agent-toolset/fs-util.d.mts +50 -0
  21. package/dist/tools/agent-toolset/fs-util.d.ts.map +1 -0
  22. package/dist/tools/agent-toolset/fs-util.js +191 -0
  23. package/dist/tools/agent-toolset/fs-util.js.map +1 -0
  24. package/dist/tools/agent-toolset/fs-util.mjs +151 -0
  25. package/dist/tools/agent-toolset/fs-util.mjs.map +1 -0
  26. package/dist/tools/agent-toolset/node.browser.d.mts +51 -0
  27. package/dist/tools/agent-toolset/node.browser.d.ts.map +1 -0
  28. package/dist/tools/agent-toolset/node.browser.js +94 -0
  29. package/dist/tools/agent-toolset/node.browser.js.map +1 -0
  30. package/dist/tools/agent-toolset/node.browser.mjs +78 -0
  31. package/dist/tools/agent-toolset/node.browser.mjs.map +1 -0
  32. package/dist/tools/agent-toolset/node.d.mts +158 -0
  33. package/dist/tools/agent-toolset/node.d.ts.map +1 -0
  34. package/dist/tools/agent-toolset/node.js +814 -0
  35. package/dist/tools/agent-toolset/node.js.map +1 -0
  36. package/dist/tools/agent-toolset/node.mjs +765 -0
  37. package/dist/tools/agent-toolset/node.mjs.map +1 -0
  38. package/dist/tools/agent-toolset/skills.d.mts +75 -0
  39. package/dist/tools/agent-toolset/skills.d.ts.map +1 -0
  40. package/dist/tools/agent-toolset/skills.js +196 -0
  41. package/dist/tools/agent-toolset/skills.js.map +1 -0
  42. package/dist/tools/agent-toolset/skills.mjs +153 -0
  43. package/dist/tools/agent-toolset/skills.mjs.map +1 -0
  44. package/package.json +1 -1
@@ -0,0 +1,191 @@
1
+ "use strict";
2
+ /**
3
+ * Shared, Node-only filesystem helpers for the agent toolset's file tools:
4
+ * path confinement (symlink-aware), an atomic write, and language-independent
5
+ * error messages. Kept out of `node.ts` so the tool implementations stay focused
6
+ * and these helpers can be reused by every file tool.
7
+ */
8
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
9
+ if (k2 === undefined) k2 = k;
10
+ var desc = Object.getOwnPropertyDescriptor(m, k);
11
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
12
+ desc = { enumerable: true, get: function() { return m[k]; } };
13
+ }
14
+ Object.defineProperty(o, k2, desc);
15
+ }) : (function(o, m, k, k2) {
16
+ if (k2 === undefined) k2 = k;
17
+ o[k2] = m[k];
18
+ }));
19
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
20
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
21
+ }) : function(o, v) {
22
+ o["default"] = v;
23
+ });
24
+ var __importStar = (this && this.__importStar) || (function () {
25
+ var ownKeys = function(o) {
26
+ ownKeys = Object.getOwnPropertyNames || function (o) {
27
+ var ar = [];
28
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
29
+ return ar;
30
+ };
31
+ return ownKeys(o);
32
+ };
33
+ return function (mod) {
34
+ if (mod && mod.__esModule) return mod;
35
+ var result = {};
36
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
37
+ __setModuleDefault(result, mod);
38
+ return result;
39
+ };
40
+ })();
41
+ Object.defineProperty(exports, "__esModule", { value: true });
42
+ exports.FILE_CREATE_MODE = exports.DIR_CREATE_MODE = void 0;
43
+ exports.canonicalize = canonicalize;
44
+ exports.confineToRoot = confineToRoot;
45
+ exports.atomicWriteFile = atomicWriteFile;
46
+ exports.fsErrorMessage = fsErrorMessage;
47
+ const fs = __importStar(require("node:fs/promises"));
48
+ const path = __importStar(require("node:path"));
49
+ const node_crypto_1 = require("node:crypto");
50
+ const ToolError_js_1 = require("../../lib/tools/ToolError.js");
51
+ /** Mode for directories the file tools create — not world-writable under a 0 umask. */
52
+ exports.DIR_CREATE_MODE = 0o755;
53
+ /** Mode for files the file tools create. */
54
+ exports.FILE_CREATE_MODE = 0o644;
55
+ /** `realpath` `p`, or return `p` unchanged when it cannot be resolved. */
56
+ async function realpathOrSelf(p) {
57
+ try {
58
+ return await fs.realpath(p);
59
+ }
60
+ catch {
61
+ return p;
62
+ }
63
+ }
64
+ /**
65
+ * Fully resolve `abs`: `realpath` the longest existing ancestor and re-append
66
+ * the rest, but never re-append a component that is itself a symlink — read the
67
+ * link and continue from its target instead. This handles paths being created
68
+ * (write/edit) without letting a symlink leaf (e.g. a dangling one pointing
69
+ * outside a confinement root) slip through unresolved.
70
+ */
71
+ async function canonicalize(abs) {
72
+ const tail = [];
73
+ let prefix = abs;
74
+ let hops = 0;
75
+ for (;;) {
76
+ let real;
77
+ try {
78
+ real = await fs.realpath(prefix);
79
+ }
80
+ catch {
81
+ let isLink = false;
82
+ try {
83
+ isLink = (await fs.lstat(prefix)).isSymbolicLink();
84
+ }
85
+ catch {
86
+ /* prefix truly doesn't exist (ENOENT) — fall through and walk up */
87
+ }
88
+ if (isLink) {
89
+ // Resolve the symlink ourselves and retry; `tail` (the part below it)
90
+ // still applies to the link's target. The hop cap matches Linux
91
+ // MAXSYMLINKS — the same threshold at which `realpath` itself would
92
+ // have returned ELOOP — so a cycle of unresolvable links terminates.
93
+ if (++hops > 40) {
94
+ throw new ToolError_js_1.ToolError(`path ${JSON.stringify(abs)} has too many levels of symbolic links`);
95
+ }
96
+ prefix = path.resolve(path.dirname(prefix), await fs.readlink(prefix));
97
+ continue;
98
+ }
99
+ const parent = path.dirname(prefix);
100
+ if (parent === prefix)
101
+ return abs; // walked past the FS root without a hit
102
+ tail.push(path.basename(prefix));
103
+ prefix = parent;
104
+ continue;
105
+ }
106
+ return tail.length ? path.join(real, ...tail.reverse()) : real;
107
+ }
108
+ }
109
+ /**
110
+ * Resolve `p` and confine it to `root`.
111
+ *
112
+ * Absolute and relative inputs go through the same canonicalise-then-contain
113
+ * check — an absolute path that lands inside `root` is permitted, only paths
114
+ * that resolve *outside* are rejected. Every symlink in `p` (including the
115
+ * leaf, even a dangling one) is resolved before the confinement check, and the
116
+ * resolved path is what the caller then operates on, so a symlink inside `root`
117
+ * that points outside it can neither pass the check nor be followed afterwards.
118
+ *
119
+ * Residual TOCTOU: a component could still be swapped for a symlink between this
120
+ * call and the eventual `fs` operation. Closing that fully needs per-component
121
+ * `O_NOFOLLOW`/`openat`, which Node does not expose ergonomically; this is why a
122
+ * sandbox is still recommended for the toolset as a whole.
123
+ */
124
+ async function confineToRoot(root, p, opts) {
125
+ const allowOutside = opts?.allowOutside ?? false;
126
+ const realRoot = await realpathOrSelf(path.resolve(root));
127
+ const abs = path.resolve(realRoot, p);
128
+ if (allowOutside)
129
+ return abs;
130
+ const real = await canonicalize(abs);
131
+ if (real !== realRoot && !real.startsWith(realRoot + path.sep)) {
132
+ throw new ToolError_js_1.ToolError(`path ${JSON.stringify(p)} escapes workdir`);
133
+ }
134
+ return real;
135
+ }
136
+ /**
137
+ * Atomically write `content` to `targetPath`: write a sibling temp file, fsync
138
+ * it, then rename over the target. The rename is atomic on most filesystems, so
139
+ * a crash mid-write never leaves the target half-written.
140
+ */
141
+ async function atomicWriteFile(targetPath, content) {
142
+ const dir = path.dirname(targetPath);
143
+ const tempPath = path.join(dir, `.tmp-${process.pid}-${(0, node_crypto_1.randomUUID)()}`);
144
+ let handle;
145
+ try {
146
+ handle = await fs.open(tempPath, 'wx', exports.FILE_CREATE_MODE);
147
+ await handle.writeFile(content, 'utf-8');
148
+ await handle.sync();
149
+ await handle.close();
150
+ handle = undefined;
151
+ await fs.rename(tempPath, targetPath);
152
+ }
153
+ catch (err) {
154
+ if (handle)
155
+ await handle.close().catch(() => { });
156
+ await fs.unlink(tempPath).catch(() => { });
157
+ throw err;
158
+ }
159
+ }
160
+ /**
161
+ * Map a thrown filesystem error to a consistent, language-independent message,
162
+ * so the model sees the same wording regardless of the runtime (Node's raw
163
+ * `ENOENT: no such file...` text would otherwise leak through). Falls back to
164
+ * the raw error message for codes we don't special-case.
165
+ */
166
+ function fsErrorMessage(err, file) {
167
+ const code = err?.code;
168
+ switch (code) {
169
+ case 'ENOENT':
170
+ return `${file}: no such file or directory`;
171
+ case 'EACCES':
172
+ case 'EPERM':
173
+ return `${file}: permission denied`;
174
+ case 'ENOTDIR':
175
+ return `${file}: not a directory`;
176
+ case 'EISDIR':
177
+ return `${file}: is a directory`;
178
+ case 'ELOOP':
179
+ return `${file}: too many levels of symbolic links`;
180
+ case 'ENAMETOOLONG':
181
+ return `${file}: file name too long`;
182
+ case 'ENOSPC':
183
+ return `${file}: no space left on device`;
184
+ case 'EMFILE':
185
+ case 'ENFILE':
186
+ return `${file}: too many open files`;
187
+ default:
188
+ return `${file}: ${err instanceof Error ? err.message : String(err)}`;
189
+ }
190
+ }
191
+ //# sourceMappingURL=fs-util.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fs-util.js","sourceRoot":"","sources":["../../../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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,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,EAAE,CAAC;IAC1E,CAAC;AACH,CAAC"}
@@ -0,0 +1,151 @@
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
+ import * as fs from 'node:fs/promises';
8
+ import * as path from 'node:path';
9
+ import { randomUUID } from 'node:crypto';
10
+ import { ToolError } from '../../lib/tools/ToolError.js';
11
+ /** Mode for directories the file tools create — not world-writable under a 0 umask. */
12
+ export const DIR_CREATE_MODE = 0o755;
13
+ /** Mode for files the file tools create. */
14
+ export const FILE_CREATE_MODE = 0o644;
15
+ /** `realpath` `p`, or return `p` unchanged when it cannot be resolved. */
16
+ async function realpathOrSelf(p) {
17
+ try {
18
+ return await fs.realpath(p);
19
+ }
20
+ catch {
21
+ return p;
22
+ }
23
+ }
24
+ /**
25
+ * Fully resolve `abs`: `realpath` the longest existing ancestor and re-append
26
+ * the rest, but never re-append a component that is itself a symlink — read the
27
+ * link and continue from its target instead. This handles paths being created
28
+ * (write/edit) without letting a symlink leaf (e.g. a dangling one pointing
29
+ * outside a confinement root) slip through unresolved.
30
+ */
31
+ export async function canonicalize(abs) {
32
+ const tail = [];
33
+ let prefix = abs;
34
+ let hops = 0;
35
+ for (;;) {
36
+ let real;
37
+ try {
38
+ real = await fs.realpath(prefix);
39
+ }
40
+ catch {
41
+ let isLink = false;
42
+ try {
43
+ isLink = (await fs.lstat(prefix)).isSymbolicLink();
44
+ }
45
+ catch {
46
+ /* prefix truly doesn't exist (ENOENT) — fall through and walk up */
47
+ }
48
+ if (isLink) {
49
+ // Resolve the symlink ourselves and retry; `tail` (the part below it)
50
+ // still applies to the link's target. The hop cap matches Linux
51
+ // MAXSYMLINKS — the same threshold at which `realpath` itself would
52
+ // have returned ELOOP — so a cycle of unresolvable links terminates.
53
+ if (++hops > 40) {
54
+ throw new ToolError(`path ${JSON.stringify(abs)} has too many levels of symbolic links`);
55
+ }
56
+ prefix = path.resolve(path.dirname(prefix), await fs.readlink(prefix));
57
+ continue;
58
+ }
59
+ const parent = path.dirname(prefix);
60
+ if (parent === prefix)
61
+ return abs; // walked past the FS root without a hit
62
+ tail.push(path.basename(prefix));
63
+ prefix = parent;
64
+ continue;
65
+ }
66
+ return tail.length ? path.join(real, ...tail.reverse()) : real;
67
+ }
68
+ }
69
+ /**
70
+ * Resolve `p` and confine it to `root`.
71
+ *
72
+ * Absolute and relative inputs go through the same canonicalise-then-contain
73
+ * check — an absolute path that lands inside `root` is permitted, only paths
74
+ * that resolve *outside* are rejected. Every symlink in `p` (including the
75
+ * leaf, even a dangling one) is resolved before the confinement check, and the
76
+ * resolved path is what the caller then operates on, so a symlink inside `root`
77
+ * that points outside it can neither pass the check nor be followed afterwards.
78
+ *
79
+ * Residual TOCTOU: a component could still be swapped for a symlink between this
80
+ * call and the eventual `fs` operation. Closing that fully needs per-component
81
+ * `O_NOFOLLOW`/`openat`, which Node does not expose ergonomically; this is why a
82
+ * sandbox is still recommended for the toolset as a whole.
83
+ */
84
+ export async function confineToRoot(root, p, opts) {
85
+ const allowOutside = opts?.allowOutside ?? false;
86
+ const realRoot = await realpathOrSelf(path.resolve(root));
87
+ const abs = path.resolve(realRoot, p);
88
+ if (allowOutside)
89
+ return abs;
90
+ const real = await canonicalize(abs);
91
+ if (real !== realRoot && !real.startsWith(realRoot + path.sep)) {
92
+ throw new ToolError(`path ${JSON.stringify(p)} escapes workdir`);
93
+ }
94
+ return real;
95
+ }
96
+ /**
97
+ * Atomically write `content` to `targetPath`: write a sibling temp file, fsync
98
+ * it, then rename over the target. The rename is atomic on most filesystems, so
99
+ * a crash mid-write never leaves the target half-written.
100
+ */
101
+ export async function atomicWriteFile(targetPath, content) {
102
+ const dir = path.dirname(targetPath);
103
+ const tempPath = path.join(dir, `.tmp-${process.pid}-${randomUUID()}`);
104
+ let handle;
105
+ try {
106
+ handle = await fs.open(tempPath, 'wx', FILE_CREATE_MODE);
107
+ await handle.writeFile(content, 'utf-8');
108
+ await handle.sync();
109
+ await handle.close();
110
+ handle = undefined;
111
+ await fs.rename(tempPath, targetPath);
112
+ }
113
+ catch (err) {
114
+ if (handle)
115
+ await handle.close().catch(() => { });
116
+ await fs.unlink(tempPath).catch(() => { });
117
+ throw err;
118
+ }
119
+ }
120
+ /**
121
+ * Map a thrown filesystem error to a consistent, language-independent message,
122
+ * so the model sees the same wording regardless of the runtime (Node's raw
123
+ * `ENOENT: no such file...` text would otherwise leak through). Falls back to
124
+ * the raw error message for codes we don't special-case.
125
+ */
126
+ export function fsErrorMessage(err, file) {
127
+ const code = err?.code;
128
+ switch (code) {
129
+ case 'ENOENT':
130
+ return `${file}: no such file or directory`;
131
+ case 'EACCES':
132
+ case 'EPERM':
133
+ return `${file}: permission denied`;
134
+ case 'ENOTDIR':
135
+ return `${file}: not a directory`;
136
+ case 'EISDIR':
137
+ return `${file}: is a directory`;
138
+ case 'ELOOP':
139
+ return `${file}: too many levels of symbolic links`;
140
+ case 'ENAMETOOLONG':
141
+ return `${file}: file name too long`;
142
+ case 'ENOSPC':
143
+ return `${file}: no space left on device`;
144
+ case 'EMFILE':
145
+ case 'ENFILE':
146
+ return `${file}: too many open files`;
147
+ default:
148
+ return `${file}: ${err instanceof Error ? err.message : String(err)}`;
149
+ }
150
+ }
151
+ //# sourceMappingURL=fs-util.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fs-util.js","sourceRoot":"","sources":["../../../src/vendor/tools/agent-toolset/fs-util.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,MAAM,kBAAkB,CAAC;AACvC,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAClC,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,SAAS,EAAE,MAAM,8BAA8B,CAAC;AAEzD,uFAAuF;AACvF,MAAM,CAAC,MAAM,eAAe,GAAG,KAAK,CAAC;AACrC,4CAA4C;AAC5C,MAAM,CAAC,MAAM,gBAAgB,GAAG,KAAK,CAAC;AAEtC,0EAA0E;AAC1E,KAAK,UAAU,cAAc,CAAC,CAAS;IACrC,IAAI,CAAC;QACH,OAAO,MAAM,EAAE,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC;IAC9B,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,CAAC,CAAC;IACX,CAAC;AACH,CAAC;AAED;;;;;;GAMG;AACH,MAAM,CAAC,KAAK,UAAU,YAAY,CAAC,GAAW;IAC5C,MAAM,IAAI,GAAa,EAAE,CAAC;IAC1B,IAAI,MAAM,GAAG,GAAG,CAAC;IACjB,IAAI,IAAI,GAAG,CAAC,CAAC;IACb,SAAS,CAAC;QACR,IAAI,IAAY,CAAC;QACjB,IAAI,CAAC;YACH,IAAI,GAAG,MAAM,EAAE,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;QACnC,CAAC;QAAC,MAAM,CAAC;YACP,IAAI,MAAM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,KAAK,EAAE,CAAC,KAAK,CAAC,GAAG,EAAE,GAAE,CAAC,CAAC,CAAC;QACjD,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;;;;;GAKG;AACH,MAAM,UAAU,cAAc,CAAC,GAAY,EAAE,IAAY;IACvD,MAAM,IAAI,GAAI,GAAgC,EAAE,IAAI,CAAC;IACrD,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,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,EAAE,CAAC;IAC1E,CAAC;AACH,CAAC"}
@@ -0,0 +1,51 @@
1
+ /**
2
+ * Browser stub for `tools/agent-toolset/node`.
3
+ *
4
+ * The real module implements the `agent_toolset_20260401` tools on top of Node
5
+ * built-ins (`node:child_process`, `node:fs`, …), which browser bundlers cannot
6
+ * resolve. The `browser` field in `package.json` substitutes this stub in
7
+ * browser builds so the SDK bundles cleanly for web targets; Node runtimes and
8
+ * node-target bundles ignore the mapping and load the real implementation.
9
+ *
10
+ * Every value export here throws an {@link AnthropicError} when used — the
11
+ * agent toolset only works in Node.js or a Node-compatible runtime. Type
12
+ * exports are re-exported from the real module (erased at build time), so
13
+ * type-level usage is unaffected.
14
+ */
15
+ import { AnthropicError } from '../../core/error.js';
16
+ import type { PukuAI as Anthropic } from '../../client.js';
17
+ import type { BetaRunnableTool } from '../../lib/tools/BetaRunnableTool.js';
18
+ import type { AgentToolContext } from './node.js';
19
+ export type { AgentToolContext } from './node.js';
20
+ export declare function setupSkills(_ctx: AgentToolContext): Promise<() => Promise<void>>;
21
+ export declare function resolveSkillVersion(_client: Anthropic, _skillId: string, _version: string): Promise<string>;
22
+ export declare function extractSkillArchive(_resp: Response, _dest: string): Promise<void>;
23
+ export declare function betaAgentToolset20260401(_ctx: AgentToolContext): BetaRunnableTool[];
24
+ export declare function resolvePath(_ctx: AgentToolContext, _p: string): Promise<string>;
25
+ /**
26
+ * A bash command exceeded its `timeoutMs`. Carries the timeout so a caller can
27
+ * tell it apart from an abort without matching on the message text.
28
+ */
29
+ export declare class BashTimeoutError extends AnthropicError {
30
+ readonly timeoutMs: number;
31
+ constructor(timeoutMs: number);
32
+ }
33
+ export declare class BashSession {
34
+ constructor(_dir: string, _env?: NodeJS.ProcessEnv);
35
+ get closed(): boolean;
36
+ exec(_command: string, _opts?: {
37
+ timeoutMs?: number;
38
+ signal?: AbortSignal | null | undefined;
39
+ }): Promise<{
40
+ output: string;
41
+ exitCode: number;
42
+ }>;
43
+ close(): void;
44
+ }
45
+ export declare function betaBashTool(_ctx: AgentToolContext): BetaRunnableTool;
46
+ export declare function betaReadTool(_ctx: AgentToolContext): BetaRunnableTool;
47
+ export declare function betaWriteTool(_ctx: AgentToolContext): BetaRunnableTool;
48
+ export declare function betaEditTool(_ctx: AgentToolContext): BetaRunnableTool;
49
+ export declare function betaGlobTool(_ctx: AgentToolContext): BetaRunnableTool;
50
+ export declare function betaGrepTool(_ctx: AgentToolContext): BetaRunnableTool;
51
+ //# sourceMappingURL=node.browser.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"node.browser.d.ts","sourceRoot":"","sources":["../../../src/vendor/tools/agent-toolset/node.browser.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AACrD,OAAO,KAAK,EAAE,MAAM,IAAI,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC3D,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,qCAAqC,CAAC;AAC5E,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,WAAW,CAAC;AAElD,YAAY,EAAE,gBAAgB,EAAE,MAAM,WAAW,CAAC;AAMlD,wBAAgB,WAAW,CAAC,IAAI,EAAE,gBAAgB,GAAG,OAAO,CAAC,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC,CAEhF;AAED,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAE3G;AAED,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAEjF;AAED,wBAAgB,wBAAwB,CAAC,IAAI,EAAE,gBAAgB,GAAG,gBAAgB,EAAE,CAEnF;AAED,wBAAgB,WAAW,CAAC,IAAI,EAAE,gBAAgB,EAAE,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAE/E;AAED;;;GAGG;AACH,qBAAa,gBAAiB,SAAQ,cAAc;IAClD,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;gBAEf,SAAS,EAAE,MAAM;CAK9B;AAED,qBAAa,WAAW;gBACV,IAAI,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,MAAM,CAAC,UAAU;IAIlD,IAAI,MAAM,IAAI,OAAO,CAEpB;IAED,IAAI,CACF,QAAQ,EAAE,MAAM,EAChB,KAAK,GAAE;QAAE,SAAS,CAAC,EAAE,MAAM,CAAC;QAAC,MAAM,CAAC,EAAE,WAAW,GAAG,IAAI,GAAG,SAAS,CAAA;KAAO,GAC1E,OAAO,CAAC;QAAE,MAAM,EAAE,MAAM,CAAC;QAAC,QAAQ,EAAE,MAAM,CAAA;KAAE,CAAC;IAIhD,KAAK,IAAI,IAAI;CAGd;AAED,wBAAgB,YAAY,CAAC,IAAI,EAAE,gBAAgB,GAAG,gBAAgB,CAErE;AAED,wBAAgB,YAAY,CAAC,IAAI,EAAE,gBAAgB,GAAG,gBAAgB,CAErE;AAED,wBAAgB,aAAa,CAAC,IAAI,EAAE,gBAAgB,GAAG,gBAAgB,CAEtE;AAED,wBAAgB,YAAY,CAAC,IAAI,EAAE,gBAAgB,GAAG,gBAAgB,CAErE;AAED,wBAAgB,YAAY,CAAC,IAAI,EAAE,gBAAgB,GAAG,gBAAgB,CAErE;AAED,wBAAgB,YAAY,CAAC,IAAI,EAAE,gBAAgB,GAAG,gBAAgB,CAErE"}
@@ -0,0 +1,94 @@
1
+ "use strict";
2
+ /**
3
+ * Browser stub for `tools/agent-toolset/node`.
4
+ *
5
+ * The real module implements the `agent_toolset_20260401` tools on top of Node
6
+ * built-ins (`node:child_process`, `node:fs`, …), which browser bundlers cannot
7
+ * resolve. The `browser` field in `package.json` substitutes this stub in
8
+ * browser builds so the SDK bundles cleanly for web targets; Node runtimes and
9
+ * node-target bundles ignore the mapping and load the real implementation.
10
+ *
11
+ * Every value export here throws an {@link AnthropicError} when used — the
12
+ * agent toolset only works in Node.js or a Node-compatible runtime. Type
13
+ * exports are re-exported from the real module (erased at build time), so
14
+ * type-level usage is unaffected.
15
+ */
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ exports.BashSession = exports.BashTimeoutError = void 0;
18
+ exports.setupSkills = setupSkills;
19
+ exports.resolveSkillVersion = resolveSkillVersion;
20
+ exports.extractSkillArchive = extractSkillArchive;
21
+ exports.betaAgentToolset20260401 = betaAgentToolset20260401;
22
+ exports.resolvePath = resolvePath;
23
+ exports.betaBashTool = betaBashTool;
24
+ exports.betaReadTool = betaReadTool;
25
+ exports.betaWriteTool = betaWriteTool;
26
+ exports.betaEditTool = betaEditTool;
27
+ exports.betaGlobTool = betaGlobTool;
28
+ exports.betaGrepTool = betaGrepTool;
29
+ const error_js_1 = require("../../core/error.js");
30
+ function nodeOnly(name) {
31
+ throw new error_js_1.AnthropicError(`${name} requires Node.js or a Node-compatible runtime`);
32
+ }
33
+ function setupSkills(_ctx) {
34
+ return nodeOnly('setupSkills');
35
+ }
36
+ function resolveSkillVersion(_client, _skillId, _version) {
37
+ return nodeOnly('resolveSkillVersion');
38
+ }
39
+ function extractSkillArchive(_resp, _dest) {
40
+ return nodeOnly('extractSkillArchive');
41
+ }
42
+ function betaAgentToolset20260401(_ctx) {
43
+ return nodeOnly('betaAgentToolset20260401');
44
+ }
45
+ function resolvePath(_ctx, _p) {
46
+ return nodeOnly('resolvePath');
47
+ }
48
+ /**
49
+ * A bash command exceeded its `timeoutMs`. Carries the timeout so a caller can
50
+ * tell it apart from an abort without matching on the message text.
51
+ */
52
+ class BashTimeoutError extends error_js_1.AnthropicError {
53
+ timeoutMs;
54
+ constructor(timeoutMs) {
55
+ super(`bash command timed out after ${timeoutMs}ms`);
56
+ this.name = 'BashTimeoutError';
57
+ this.timeoutMs = timeoutMs;
58
+ }
59
+ }
60
+ exports.BashTimeoutError = BashTimeoutError;
61
+ class BashSession {
62
+ constructor(_dir, _env) {
63
+ nodeOnly('BashSession');
64
+ }
65
+ get closed() {
66
+ return nodeOnly('BashSession');
67
+ }
68
+ exec(_command, _opts = {}) {
69
+ return nodeOnly('BashSession');
70
+ }
71
+ close() {
72
+ nodeOnly('BashSession');
73
+ }
74
+ }
75
+ exports.BashSession = BashSession;
76
+ function betaBashTool(_ctx) {
77
+ return nodeOnly('betaBashTool');
78
+ }
79
+ function betaReadTool(_ctx) {
80
+ return nodeOnly('betaReadTool');
81
+ }
82
+ function betaWriteTool(_ctx) {
83
+ return nodeOnly('betaWriteTool');
84
+ }
85
+ function betaEditTool(_ctx) {
86
+ return nodeOnly('betaEditTool');
87
+ }
88
+ function betaGlobTool(_ctx) {
89
+ return nodeOnly('betaGlobTool');
90
+ }
91
+ function betaGrepTool(_ctx) {
92
+ return nodeOnly('betaGrepTool');
93
+ }
94
+ //# sourceMappingURL=node.browser.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"node.browser.js","sourceRoot":"","sources":["../../../src/vendor/tools/agent-toolset/node.browser.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;GAaG;;;AAaH,kCAEC;AAED,kDAEC;AAED,kDAEC;AAED,4DAEC;AAED,kCAEC;AAqCD,oCAEC;AAED,oCAEC;AAED,sCAEC;AAED,oCAEC;AAED,oCAEC;AAED,oCAEC;AAxFD,kDAAqD;AAOrD,SAAS,QAAQ,CAAC,IAAY;IAC5B,MAAM,IAAI,yBAAc,CAAC,GAAG,IAAI,gDAAgD,CAAC,CAAC;AACpF,CAAC;AAED,SAAgB,WAAW,CAAC,IAAsB;IAChD,OAAO,QAAQ,CAAC,aAAa,CAAC,CAAC;AACjC,CAAC;AAED,SAAgB,mBAAmB,CAAC,OAAkB,EAAE,QAAgB,EAAE,QAAgB;IACxF,OAAO,QAAQ,CAAC,qBAAqB,CAAC,CAAC;AACzC,CAAC;AAED,SAAgB,mBAAmB,CAAC,KAAe,EAAE,KAAa;IAChE,OAAO,QAAQ,CAAC,qBAAqB,CAAC,CAAC;AACzC,CAAC;AAED,SAAgB,wBAAwB,CAAC,IAAsB;IAC7D,OAAO,QAAQ,CAAC,0BAA0B,CAAC,CAAC;AAC9C,CAAC;AAED,SAAgB,WAAW,CAAC,IAAsB,EAAE,EAAU;IAC5D,OAAO,QAAQ,CAAC,aAAa,CAAC,CAAC;AACjC,CAAC;AAED;;;GAGG;AACH,MAAa,gBAAiB,SAAQ,yBAAc;IACzC,SAAS,CAAS;IAE3B,YAAY,SAAiB;QAC3B,KAAK,CAAC,gCAAgC,SAAS,IAAI,CAAC,CAAC;QACrD,IAAI,CAAC,IAAI,GAAG,kBAAkB,CAAC;QAC/B,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC;IAC7B,CAAC;CACF;AARD,4CAQC;AAED,MAAa,WAAW;IACtB,YAAY,IAAY,EAAE,IAAwB;QAChD,QAAQ,CAAC,aAAa,CAAC,CAAC;IAC1B,CAAC;IAED,IAAI,MAAM;QACR,OAAO,QAAQ,CAAC,aAAa,CAAC,CAAC;IACjC,CAAC;IAED,IAAI,CACF,QAAgB,EAChB,QAAyE,EAAE;QAE3E,OAAO,QAAQ,CAAC,aAAa,CAAC,CAAC;IACjC,CAAC;IAED,KAAK;QACH,QAAQ,CAAC,aAAa,CAAC,CAAC;IAC1B,CAAC;CACF;AAnBD,kCAmBC;AAED,SAAgB,YAAY,CAAC,IAAsB;IACjD,OAAO,QAAQ,CAAC,cAAc,CAAC,CAAC;AAClC,CAAC;AAED,SAAgB,YAAY,CAAC,IAAsB;IACjD,OAAO,QAAQ,CAAC,cAAc,CAAC,CAAC;AAClC,CAAC;AAED,SAAgB,aAAa,CAAC,IAAsB;IAClD,OAAO,QAAQ,CAAC,eAAe,CAAC,CAAC;AACnC,CAAC;AAED,SAAgB,YAAY,CAAC,IAAsB;IACjD,OAAO,QAAQ,CAAC,cAAc,CAAC,CAAC;AAClC,CAAC;AAED,SAAgB,YAAY,CAAC,IAAsB;IACjD,OAAO,QAAQ,CAAC,cAAc,CAAC,CAAC;AAClC,CAAC;AAED,SAAgB,YAAY,CAAC,IAAsB;IACjD,OAAO,QAAQ,CAAC,cAAc,CAAC,CAAC;AAClC,CAAC"}
@@ -0,0 +1,78 @@
1
+ /**
2
+ * Browser stub for `tools/agent-toolset/node`.
3
+ *
4
+ * The real module implements the `agent_toolset_20260401` tools on top of Node
5
+ * built-ins (`node:child_process`, `node:fs`, …), which browser bundlers cannot
6
+ * resolve. The `browser` field in `package.json` substitutes this stub in
7
+ * browser builds so the SDK bundles cleanly for web targets; Node runtimes and
8
+ * node-target bundles ignore the mapping and load the real implementation.
9
+ *
10
+ * Every value export here throws an {@link AnthropicError} when used — the
11
+ * agent toolset only works in Node.js or a Node-compatible runtime. Type
12
+ * exports are re-exported from the real module (erased at build time), so
13
+ * type-level usage is unaffected.
14
+ */
15
+ import { AnthropicError } from '../../core/error.js';
16
+ function nodeOnly(name) {
17
+ throw new AnthropicError(`${name} requires Node.js or a Node-compatible runtime`);
18
+ }
19
+ export function setupSkills(_ctx) {
20
+ return nodeOnly('setupSkills');
21
+ }
22
+ export function resolveSkillVersion(_client, _skillId, _version) {
23
+ return nodeOnly('resolveSkillVersion');
24
+ }
25
+ export function extractSkillArchive(_resp, _dest) {
26
+ return nodeOnly('extractSkillArchive');
27
+ }
28
+ export function betaAgentToolset20260401(_ctx) {
29
+ return nodeOnly('betaAgentToolset20260401');
30
+ }
31
+ export function resolvePath(_ctx, _p) {
32
+ return nodeOnly('resolvePath');
33
+ }
34
+ /**
35
+ * A bash command exceeded its `timeoutMs`. Carries the timeout so a caller can
36
+ * tell it apart from an abort without matching on the message text.
37
+ */
38
+ export class BashTimeoutError extends AnthropicError {
39
+ timeoutMs;
40
+ constructor(timeoutMs) {
41
+ super(`bash command timed out after ${timeoutMs}ms`);
42
+ this.name = 'BashTimeoutError';
43
+ this.timeoutMs = timeoutMs;
44
+ }
45
+ }
46
+ export class BashSession {
47
+ constructor(_dir, _env) {
48
+ nodeOnly('BashSession');
49
+ }
50
+ get closed() {
51
+ return nodeOnly('BashSession');
52
+ }
53
+ exec(_command, _opts = {}) {
54
+ return nodeOnly('BashSession');
55
+ }
56
+ close() {
57
+ nodeOnly('BashSession');
58
+ }
59
+ }
60
+ export function betaBashTool(_ctx) {
61
+ return nodeOnly('betaBashTool');
62
+ }
63
+ export function betaReadTool(_ctx) {
64
+ return nodeOnly('betaReadTool');
65
+ }
66
+ export function betaWriteTool(_ctx) {
67
+ return nodeOnly('betaWriteTool');
68
+ }
69
+ export function betaEditTool(_ctx) {
70
+ return nodeOnly('betaEditTool');
71
+ }
72
+ export function betaGlobTool(_ctx) {
73
+ return nodeOnly('betaGlobTool');
74
+ }
75
+ export function betaGrepTool(_ctx) {
76
+ return nodeOnly('betaGrepTool');
77
+ }
78
+ //# sourceMappingURL=node.browser.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"node.browser.js","sourceRoot":"","sources":["../../../src/vendor/tools/agent-toolset/node.browser.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAOrD,SAAS,QAAQ,CAAC,IAAY;IAC5B,MAAM,IAAI,cAAc,CAAC,GAAG,IAAI,gDAAgD,CAAC,CAAC;AACpF,CAAC;AAED,MAAM,UAAU,WAAW,CAAC,IAAsB;IAChD,OAAO,QAAQ,CAAC,aAAa,CAAC,CAAC;AACjC,CAAC;AAED,MAAM,UAAU,mBAAmB,CAAC,OAAkB,EAAE,QAAgB,EAAE,QAAgB;IACxF,OAAO,QAAQ,CAAC,qBAAqB,CAAC,CAAC;AACzC,CAAC;AAED,MAAM,UAAU,mBAAmB,CAAC,KAAe,EAAE,KAAa;IAChE,OAAO,QAAQ,CAAC,qBAAqB,CAAC,CAAC;AACzC,CAAC;AAED,MAAM,UAAU,wBAAwB,CAAC,IAAsB;IAC7D,OAAO,QAAQ,CAAC,0BAA0B,CAAC,CAAC;AAC9C,CAAC;AAED,MAAM,UAAU,WAAW,CAAC,IAAsB,EAAE,EAAU;IAC5D,OAAO,QAAQ,CAAC,aAAa,CAAC,CAAC;AACjC,CAAC;AAED;;;GAGG;AACH,MAAM,OAAO,gBAAiB,SAAQ,cAAc;IACzC,SAAS,CAAS;IAE3B,YAAY,SAAiB;QAC3B,KAAK,CAAC,gCAAgC,SAAS,IAAI,CAAC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