@junando/worker 0.11.1 → 0.12.1

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.
@@ -1,5 +1,5 @@
1
1
  const require_rolldown_runtime = require('./rolldown-runtime-CfAboj1T.cjs');
2
- const require_sdk = require('./sdk-BD78kZ4E.cjs');
2
+ const require_sdk = require('./sdk-a89HQ1X4.cjs');
3
3
  let node_crypto = require("node:crypto");
4
4
  node_crypto = require_rolldown_runtime.__toESM(node_crypto, 1);
5
5
  let node_fs = require("node:fs");
@@ -16,7 +16,7 @@ let node_readline = require("node:readline");
16
16
  node_readline = require_rolldown_runtime.__toESM(node_readline, 1);
17
17
  let node_stream_promises = require("node:stream/promises");
18
18
 
19
- //#region ../../node_modules/.pnpm/@anthropic-ai+sdk@0.102.0_zod@4.4.3/node_modules/@anthropic-ai/sdk/lib/transform-json-schema.mjs
19
+ //#region ../../node_modules/.pnpm/@anthropic-ai+sdk@0.112.3_zod@4.4.3/node_modules/@anthropic-ai/sdk/lib/transform-json-schema.mjs
20
20
  const SUPPORTED_STRING_FORMATS = new Set([
21
21
  "date-time",
22
22
  "time",
@@ -111,7 +111,7 @@ function _transformJSONSchema(jsonSchema) {
111
111
  }
112
112
 
113
113
  //#endregion
114
- //#region ../../node_modules/.pnpm/@anthropic-ai+sdk@0.102.0_zod@4.4.3/node_modules/@anthropic-ai/sdk/helpers/beta/json-schema.mjs
114
+ //#region ../../node_modules/.pnpm/@anthropic-ai+sdk@0.112.3_zod@4.4.3/node_modules/@anthropic-ai/sdk/helpers/beta/json-schema.mjs
115
115
  /**
116
116
  * Creates a Tool with a provided JSON schema that can be passed
117
117
  * to the `.toolRunner()` method. The schema is used to automatically validate
@@ -159,7 +159,7 @@ function betaJSONSchemaOutputFormat(jsonSchema, options) {
159
159
  }
160
160
 
161
161
  //#endregion
162
- //#region ../../node_modules/.pnpm/@anthropic-ai+sdk@0.102.0_zod@4.4.3/node_modules/@anthropic-ai/sdk/tools/agent-toolset/fs-util.mjs
162
+ //#region ../../node_modules/.pnpm/@anthropic-ai+sdk@0.112.3_zod@4.4.3/node_modules/@anthropic-ai/sdk/tools/agent-toolset/fs-util.mjs
163
163
  /**
164
164
  * Shared, Node-only filesystem helpers for the agent toolset's file tools:
165
165
  * path confinement (symlink-aware), an atomic write, and language-independent
@@ -188,6 +188,7 @@ async function realpathOrSelf(p) {
188
188
  async function canonicalize(abs) {
189
189
  const tail = [];
190
190
  let prefix = abs;
191
+ let hops = 0;
191
192
  for (;;) {
192
193
  let real;
193
194
  try {
@@ -198,6 +199,9 @@ async function canonicalize(abs) {
198
199
  isLink = (await node_fs_promises.lstat(prefix)).isSymbolicLink();
199
200
  } catch {}
200
201
  if (isLink) {
202
+ if (++hops > 40) {
203
+ throw new require_sdk.ToolError(`path ${JSON.stringify(abs)} has too many levels of symbolic links`);
204
+ }
201
205
  prefix = node_path.resolve(node_path.dirname(prefix), await node_fs_promises.readlink(prefix));
202
206
  continue;
203
207
  }
@@ -213,9 +217,10 @@ async function canonicalize(abs) {
213
217
  /**
214
218
  * Resolve `p` and confine it to `root`.
215
219
  *
216
- * Unless `allowOutside` is set, absolute inputs are rejected and the
217
- * **canonical** path is returned every symlink in `p` (including the leaf,
218
- * even a dangling one) is resolved before the confinement check, and the
220
+ * Absolute and relative inputs go through the same canonicalise-then-contain
221
+ * check an absolute path that lands inside `root` is permitted, only paths
222
+ * that resolve *outside* are rejected. Every symlink in `p` (including the
223
+ * leaf, even a dangling one) is resolved before the confinement check, and the
219
224
  * resolved path is what the caller then operates on, so a symlink inside `root`
220
225
  * that points outside it can neither pass the check nor be followed afterwards.
221
226
  *
@@ -226,18 +231,11 @@ async function canonicalize(abs) {
226
231
  */
227
232
  async function confineToRoot(root, p, opts) {
228
233
  const allowOutside = opts?.allowOutside ?? false;
229
- if (node_path.isAbsolute(p)) {
230
- if (!allowOutside) {
231
- throw new require_sdk.ToolError(`absolute path ${JSON.stringify(p)} not permitted`);
232
- }
233
- return node_path.resolve(p);
234
- }
235
234
  const realRoot = await realpathOrSelf(node_path.resolve(root));
236
235
  const abs = node_path.resolve(realRoot, p);
237
236
  if (allowOutside) return abs;
238
237
  const real = await canonicalize(abs);
239
- const rootSep = realRoot.endsWith(node_path.sep) ? realRoot : realRoot + node_path.sep;
240
- if (real !== realRoot && !real.startsWith(rootSep)) {
238
+ if (real !== realRoot && !real.startsWith(realRoot + node_path.sep)) {
241
239
  throw new require_sdk.ToolError(`path ${JSON.stringify(p)} escapes workdir`);
242
240
  }
243
241
  return real;
@@ -288,7 +286,7 @@ function fsErrorMessage(err, file) {
288
286
  }
289
287
 
290
288
  //#endregion
291
- //#region ../../node_modules/.pnpm/@anthropic-ai+sdk@0.102.0_zod@4.4.3/node_modules/@anthropic-ai/sdk/tools/agent-toolset/skills.mjs
289
+ //#region ../../node_modules/.pnpm/@anthropic-ai+sdk@0.112.3_zod@4.4.3/node_modules/@anthropic-ai/sdk/tools/agent-toolset/skills.mjs
292
290
  /**
293
291
  * Node-only skill plumbing for the agent toolset: downloading a session
294
292
  * agent's skills into the workdir and extracting the archives. Kept in its own
@@ -526,7 +524,7 @@ async function readHead(file, n) {
526
524
  }
527
525
 
528
526
  //#endregion
529
- //#region ../../node_modules/.pnpm/@anthropic-ai+sdk@0.102.0_zod@4.4.3/node_modules/@anthropic-ai/sdk/tools/agent-toolset/node.mjs
527
+ //#region ../../node_modules/.pnpm/@anthropic-ai+sdk@0.112.3_zod@4.4.3/node_modules/@anthropic-ai/sdk/tools/agent-toolset/node.mjs
530
528
  /**
531
529
  * Node implementation of the `agent_toolset_20260401` tools — `bash`, `read`,
532
530
  * `write`, `edit`, `glob`, `grep` — plus the workdir/skills
@@ -606,12 +604,14 @@ function betaAgentToolset20260401(ctx) {
606
604
  ];
607
605
  }
608
606
  /**
609
- * Resolve `p` relative to `ctx.workdir`. Unless `unrestrictedPaths` is set,
610
- * absolute inputs are rejected and the **canonical** path is returned — every
611
- * symlink in `p` (including the leaf, even a dangling one) is resolved before
612
- * the workdir check, and the resolved path is what the tool then operates on, so
613
- * a symlink inside the workdir that points outside it can neither pass the check
614
- * nor be followed afterwards. See the trust model on {@link AgentToolContext}.
607
+ * Resolve `p` against `ctx.workdir`. Absolute and relative inputs go through
608
+ * the same canonicalise-then-contain check an absolute path that lands inside
609
+ * the workdir is permitted, only paths that resolve *outside* are rejected.
610
+ * Every symlink in `p` (including the leaf, even a dangling one) is resolved
611
+ * before the workdir check, and the resolved path is what the tool then operates
612
+ * on, so a symlink inside the workdir that points outside it can neither pass
613
+ * the check nor be followed afterwards. See the trust model on
614
+ * {@link AgentToolContext}.
615
615
  *
616
616
  * Residual TOCTOU: a component could still be swapped for a symlink between this
617
617
  * call and the eventual `fs` operation. Closing that fully needs per-component
@@ -990,6 +990,7 @@ function betaGlobTool(ctx) {
990
990
  if (!ctx.unrestrictedPaths && pat.split(/[\\/]/).includes("..")) {
991
991
  throw new require_sdk.ToolError("glob: \"..\" is not permitted in the pattern");
992
992
  }
993
+ const realRoot = ctx.unrestrictedPaths ? root : await node_fs_promises.realpath(root).catch(() => root);
993
994
  const matches = [];
994
995
  try {
995
996
  for await (const entry of fsGlob(pat, {
@@ -999,7 +1000,15 @@ function betaGlobTool(ctx) {
999
1000
  })) {
1000
1001
  if (!entry.isFile()) continue;
1001
1002
  const full = node_path.join(entry.parentPath, entry.name);
1002
- if (!ctx.unrestrictedPaths && !isWithin(root, full)) continue;
1003
+ if (!ctx.unrestrictedPaths) {
1004
+ let real;
1005
+ try {
1006
+ real = await node_fs_promises.realpath(full);
1007
+ } catch {
1008
+ continue;
1009
+ }
1010
+ if (!isWithin(realRoot, real)) continue;
1011
+ }
1003
1012
  let mtime = 0;
1004
1013
  try {
1005
1014
  mtime = (await node_fs_promises.stat(full)).mtimeMs;