ppio-sandbox 2.1.0 → 2.1.1-a4

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.
@@ -60,7 +60,7 @@ import createClient from "openapi-fetch";
60
60
  import platform2 from "platform";
61
61
 
62
62
  // package.json
63
- var version = "2.1.0";
63
+ var version = "2.1.1-a4";
64
64
 
65
65
  // src/core/utils.ts
66
66
  import platform from "platform";
@@ -102,12 +102,6 @@ async function sha256(data) {
102
102
  function timeoutToSeconds(timeout) {
103
103
  return Math.ceil(timeout / 1e3);
104
104
  }
105
- function dynamicRequire(module) {
106
- if (runtime === "browser") {
107
- throw new Error("Browser runtime is not supported for require");
108
- }
109
- return __require(module);
110
- }
111
105
  async function dynamicImport(module) {
112
106
  if (runtime === "browser") {
113
107
  throw new Error("Browser runtime is not supported for dynamic import");
@@ -1458,7 +1452,7 @@ var Filesystem2 = class {
1458
1452
  this.defaultWatchRecursive = false;
1459
1453
  this.rpc = createClient5(Filesystem, transport);
1460
1454
  }
1461
- async read(path2, opts) {
1455
+ async read(path3, opts) {
1462
1456
  var _a3;
1463
1457
  const format = (_a3 = opts == null ? void 0 : opts.format) != null ? _a3 : "text";
1464
1458
  let user = opts == null ? void 0 : opts.user;
@@ -1472,7 +1466,7 @@ var Filesystem2 = class {
1472
1466
  const res = await this.envdApi.api.GET("/files", {
1473
1467
  params: {
1474
1468
  query: {
1475
- path: path2,
1469
+ path: path3,
1476
1470
  username: user
1477
1471
  }
1478
1472
  },
@@ -1505,7 +1499,7 @@ var Filesystem2 = class {
1505
1499
  "Cannot specify both path and array of files. You have to specify either path and data for a single file or an array for multiple files."
1506
1500
  );
1507
1501
  }
1508
- const { path: path2, writeOpts, writeFiles } = typeof pathOrFiles === "string" ? {
1502
+ const { path: path3, writeOpts, writeFiles } = typeof pathOrFiles === "string" ? {
1509
1503
  path: pathOrFiles,
1510
1504
  writeOpts: opts,
1511
1505
  writeFiles: [
@@ -1535,7 +1529,7 @@ var Filesystem2 = class {
1535
1529
  }
1536
1530
  const uploadResults = await Promise.all(
1537
1531
  writeFiles.map(async (file) => {
1538
- const filePath = path2 != null ? path2 : file.path;
1532
+ const filePath = path3 != null ? path3 : file.path;
1539
1533
  const body = await toUploadBody(file.data, useGzip);
1540
1534
  const res = await this.envdApi.api.POST("/files", {
1541
1535
  params: {
@@ -1573,13 +1567,13 @@ var Filesystem2 = class {
1573
1567
  formData.append(
1574
1568
  "file",
1575
1569
  await toBlob(file.data),
1576
- (_a3 = file.path) != null ? _a3 : path2
1570
+ (_a3 = file.path) != null ? _a3 : path3
1577
1571
  );
1578
1572
  }
1579
1573
  const res = await this.envdApi.api.POST("/files", {
1580
1574
  params: {
1581
1575
  query: {
1582
- path: path2,
1576
+ path: path3,
1583
1577
  username: user
1584
1578
  }
1585
1579
  },
@@ -1597,7 +1591,7 @@ var Filesystem2 = class {
1597
1591
  }
1598
1592
  results.push(...files);
1599
1593
  }
1600
- return results.length === 1 && path2 ? results[0] : results;
1594
+ return results.length === 1 && path3 ? results[0] : results;
1601
1595
  }
1602
1596
  /**
1603
1597
  * Write multiple files.
@@ -1625,7 +1619,7 @@ var Filesystem2 = class {
1625
1619
  *
1626
1620
  * @returns list of entries in the sandbox filesystem directory.
1627
1621
  */
1628
- async list(path2, opts) {
1622
+ async list(path3, opts) {
1629
1623
  var _a3;
1630
1624
  if (typeof (opts == null ? void 0 : opts.depth) === "number" && opts.depth < 1) {
1631
1625
  throw new InvalidArgumentError("depth should be at least one");
@@ -1633,7 +1627,7 @@ var Filesystem2 = class {
1633
1627
  try {
1634
1628
  const res = await this.rpc.listDir(
1635
1629
  {
1636
- path: path2,
1630
+ path: path3,
1637
1631
  depth: (_a3 = opts == null ? void 0 : opts.depth) != null ? _a3 : 1
1638
1632
  },
1639
1633
  {
@@ -1672,10 +1666,10 @@ var Filesystem2 = class {
1672
1666
  *
1673
1667
  * @returns `true` if the directory was created, `false` if it already exists.
1674
1668
  */
1675
- async makeDir(path2, opts) {
1669
+ async makeDir(path3, opts) {
1676
1670
  try {
1677
1671
  await this.rpc.makeDir(
1678
- { path: path2 },
1672
+ { path: path3 },
1679
1673
  {
1680
1674
  headers: authenticationHeader(this.envdApi.version, opts == null ? void 0 : opts.user),
1681
1675
  signal: this.connectionConfig.getSignal(opts == null ? void 0 : opts.requestTimeoutMs)
@@ -1738,10 +1732,10 @@ var Filesystem2 = class {
1738
1732
  * @param path path to a file or directory.
1739
1733
  * @param opts connection options.
1740
1734
  */
1741
- async remove(path2, opts) {
1735
+ async remove(path3, opts) {
1742
1736
  try {
1743
1737
  await this.rpc.remove(
1744
- { path: path2 },
1738
+ { path: path3 },
1745
1739
  {
1746
1740
  headers: authenticationHeader(this.envdApi.version, opts == null ? void 0 : opts.user),
1747
1741
  signal: this.connectionConfig.getSignal(opts == null ? void 0 : opts.requestTimeoutMs)
@@ -1759,10 +1753,10 @@ var Filesystem2 = class {
1759
1753
  *
1760
1754
  * @returns `true` if the file or directory exists, `false` otherwise
1761
1755
  */
1762
- async exists(path2, opts) {
1756
+ async exists(path3, opts) {
1763
1757
  try {
1764
1758
  await this.rpc.stat(
1765
- { path: path2 },
1759
+ { path: path3 },
1766
1760
  {
1767
1761
  headers: authenticationHeader(this.envdApi.version, opts == null ? void 0 : opts.user),
1768
1762
  signal: this.connectionConfig.getSignal(opts == null ? void 0 : opts.requestTimeoutMs)
@@ -1786,10 +1780,10 @@ var Filesystem2 = class {
1786
1780
  *
1787
1781
  * @returns information about the file or directory like name, type, and path.
1788
1782
  */
1789
- async getInfo(path2, opts) {
1783
+ async getInfo(path3, opts) {
1790
1784
  try {
1791
1785
  const res = await this.rpc.stat(
1792
- { path: path2 },
1786
+ { path: path3 },
1793
1787
  {
1794
1788
  headers: authenticationHeader(this.envdApi.version, opts == null ? void 0 : opts.user),
1795
1789
  signal: this.connectionConfig.getSignal(opts == null ? void 0 : opts.requestTimeoutMs)
@@ -1825,7 +1819,7 @@ var Filesystem2 = class {
1825
1819
  *
1826
1820
  * @returns `WatchHandle` object for stopping watching directory.
1827
1821
  */
1828
- async watchDir(path2, onEvent, opts) {
1822
+ async watchDir(path3, onEvent, opts) {
1829
1823
  var _a3, _b, _c;
1830
1824
  if ((opts == null ? void 0 : opts.recursive) && this.envdApi.version && compareVersions3(this.envdApi.version, ENVD_VERSION_RECURSIVE_WATCH) < 0) {
1831
1825
  throw new TemplateError(
@@ -1839,7 +1833,7 @@ var Filesystem2 = class {
1839
1833
  }, requestTimeoutMs) : void 0;
1840
1834
  const events = this.rpc.watchDir(
1841
1835
  {
1842
- path: path2,
1836
+ path: path3,
1843
1837
  recursive: (_b = opts == null ? void 0 : opts.recursive) != null ? _b : this.defaultWatchRecursive
1844
1838
  },
1845
1839
  {
@@ -2060,11 +2054,11 @@ function parseGitStatus(output) {
2060
2054
  }
2061
2055
  const indexStatus = line[0];
2062
2056
  const workingTreeStatus = line[1];
2063
- const path2 = line.slice(3);
2057
+ const path3 = line.slice(3);
2064
2058
  let renamedFrom;
2065
- let name = path2;
2066
- if (path2.includes(" -> ")) {
2067
- const parts = path2.split(" -> ");
2059
+ let name = path3;
2060
+ if (path3.includes(" -> ")) {
2061
+ const parts = path3.split(" -> ");
2068
2062
  renamedFrom = parts[0];
2069
2063
  name = parts.slice(1).join(" -> ");
2070
2064
  }
@@ -2173,16 +2167,16 @@ function buildUpstreamErrorMessage(action) {
2173
2167
  }
2174
2168
  return "Git pull failed because no upstream branch is configured. Pass remote and branch explicitly, or set upstream once (push with { setUpstream: true } or run: git branch --set-upstream-to=origin/<branch> <branch>).";
2175
2169
  }
2176
- function getRepoPathForScope(scope, path2) {
2170
+ function getRepoPathForScope(scope, path3) {
2177
2171
  if (scope !== "local") {
2178
2172
  return void 0;
2179
2173
  }
2180
- if (!path2) {
2174
+ if (!path3) {
2181
2175
  throw new InvalidArgumentError(
2182
2176
  'A repository path is required when using scope "local".'
2183
2177
  );
2184
2178
  }
2185
- return path2;
2179
+ return path3;
2186
2180
  }
2187
2181
 
2188
2182
  // src/core/sandbox/git/index.ts
@@ -2206,7 +2200,7 @@ var Git = class {
2206
2200
  password,
2207
2201
  branch,
2208
2202
  depth,
2209
- path: path2,
2203
+ path: path3,
2210
2204
  dangerouslyStoreCredentials
2211
2205
  } = _a3, rest = __objRest(_a3, [
2212
2206
  "username",
@@ -2225,7 +2219,7 @@ var Git = class {
2225
2219
  const urlWithCreds = authUsername && authPassword ? withCredentials(url, authUsername, authPassword) : url;
2226
2220
  const sanitizedUrl = stripCredentials(urlWithCreds);
2227
2221
  const stripInlineCreds = !dangerouslyStoreCredentials && sanitizedUrl !== urlWithCreds;
2228
- const repoPath = stripInlineCreds ? path2 != null ? path2 : deriveRepoDirFromUrl(url) : path2;
2222
+ const repoPath = stripInlineCreds ? path3 != null ? path3 : deriveRepoDirFromUrl(url) : path3;
2229
2223
  if (stripInlineCreds && !repoPath) {
2230
2224
  throw new InvalidArgumentError(
2231
2225
  "A destination path is required when using credentials without storing them."
@@ -2263,7 +2257,7 @@ var Git = class {
2263
2257
  * @param opts Init options.
2264
2258
  * @returns Command result from the command runner.
2265
2259
  */
2266
- async init(path2, opts) {
2260
+ async init(path3, opts) {
2267
2261
  const _a3 = opts != null ? opts : {}, { bare, initialBranch } = _a3, rest = __objRest(_a3, ["bare", "initialBranch"]);
2268
2262
  const args = ["init"];
2269
2263
  if (initialBranch) {
@@ -2272,7 +2266,7 @@ var Git = class {
2272
2266
  if (bare) {
2273
2267
  args.push("--bare");
2274
2268
  }
2275
- args.push(path2);
2269
+ args.push(path3);
2276
2270
  return this.runGit(args, void 0, rest);
2277
2271
  }
2278
2272
  /**
@@ -2284,7 +2278,7 @@ var Git = class {
2284
2278
  * @param opts Remote add options.
2285
2279
  * @returns Command result from the command runner.
2286
2280
  */
2287
- async remoteAdd(path2, name, url, opts) {
2281
+ async remoteAdd(path3, name, url, opts) {
2288
2282
  if (!name || !url) {
2289
2283
  throw new InvalidArgumentError(
2290
2284
  "Both remote name and URL are required to add a git remote."
@@ -2297,13 +2291,13 @@ var Git = class {
2297
2291
  }
2298
2292
  addArgs.push(name, url);
2299
2293
  if (!overwrite) {
2300
- return this.runGit(addArgs, path2, rest);
2294
+ return this.runGit(addArgs, path3, rest);
2301
2295
  }
2302
- const addCmd = buildGitCommand(addArgs, path2);
2303
- const setUrlCmd = buildGitCommand(["remote", "set-url", name, url], path2);
2296
+ const addCmd = buildGitCommand(addArgs, path3);
2297
+ const setUrlCmd = buildGitCommand(["remote", "set-url", name, url], path3);
2304
2298
  let cmd = `${addCmd} || ${setUrlCmd}`;
2305
2299
  if (fetch2) {
2306
- const fetchCmd = buildGitCommand(["fetch", name], path2);
2300
+ const fetchCmd = buildGitCommand(["fetch", name], path3);
2307
2301
  cmd = `(${cmd}) && ${fetchCmd}`;
2308
2302
  }
2309
2303
  return this.runShell(cmd, rest);
@@ -2318,11 +2312,11 @@ var Git = class {
2318
2312
  * @param opts Command execution options.
2319
2313
  * @returns Remote URL if present.
2320
2314
  */
2321
- async remoteGet(path2, name, opts) {
2315
+ async remoteGet(path3, name, opts) {
2322
2316
  if (!name) {
2323
2317
  throw new InvalidArgumentError("Remote name is required.");
2324
2318
  }
2325
- const cmd = `${buildGitCommand(["remote", "get-url", name], path2)} || true`;
2319
+ const cmd = `${buildGitCommand(["remote", "get-url", name], path3)} || true`;
2326
2320
  const result = await this.runShell(cmd, opts);
2327
2321
  const trimmed = result.stdout.trim();
2328
2322
  return trimmed.length > 0 ? trimmed : void 0;
@@ -2334,10 +2328,10 @@ var Git = class {
2334
2328
  * @param opts Command execution options.
2335
2329
  * @returns Parsed git status.
2336
2330
  */
2337
- async status(path2, opts) {
2331
+ async status(path3, opts) {
2338
2332
  const result = await this.runGit(
2339
2333
  ["status", "--porcelain=1", "-b"],
2340
- path2,
2334
+ path3,
2341
2335
  opts
2342
2336
  );
2343
2337
  return parseGitStatus(result.stdout);
@@ -2349,10 +2343,10 @@ var Git = class {
2349
2343
  * @param opts Command execution options.
2350
2344
  * @returns Parsed branch list.
2351
2345
  */
2352
- async branches(path2, opts) {
2346
+ async branches(path3, opts) {
2353
2347
  const result = await this.runGit(
2354
2348
  ["branch", "--format=%(refname:short) %(HEAD)"],
2355
- path2,
2349
+ path3,
2356
2350
  opts
2357
2351
  );
2358
2352
  return parseGitBranches(result.stdout);
@@ -2365,8 +2359,8 @@ var Git = class {
2365
2359
  * @param opts Command execution options.
2366
2360
  * @returns Command result from the command runner.
2367
2361
  */
2368
- async createBranch(path2, branch, opts) {
2369
- return this.runGit(["checkout", "-b", branch], path2, opts);
2362
+ async createBranch(path3, branch, opts) {
2363
+ return this.runGit(["checkout", "-b", branch], path3, opts);
2370
2364
  }
2371
2365
  /**
2372
2366
  * Check out an existing branch.
@@ -2376,8 +2370,8 @@ var Git = class {
2376
2370
  * @param opts Command execution options.
2377
2371
  * @returns Command result from the command runner.
2378
2372
  */
2379
- async checkoutBranch(path2, branch, opts) {
2380
- return this.runGit(["checkout", branch], path2, opts);
2373
+ async checkoutBranch(path3, branch, opts) {
2374
+ return this.runGit(["checkout", branch], path3, opts);
2381
2375
  }
2382
2376
  /**
2383
2377
  * Delete a branch.
@@ -2387,10 +2381,10 @@ var Git = class {
2387
2381
  * @param opts Delete options.
2388
2382
  * @returns Command result from the command runner.
2389
2383
  */
2390
- async deleteBranch(path2, branch, opts) {
2384
+ async deleteBranch(path3, branch, opts) {
2391
2385
  const _a3 = opts != null ? opts : {}, { force } = _a3, rest = __objRest(_a3, ["force"]);
2392
2386
  const args = ["branch", force ? "-D" : "-d", branch];
2393
- return this.runGit(args, path2, rest);
2387
+ return this.runGit(args, path3, rest);
2394
2388
  }
2395
2389
  /**
2396
2390
  * Stage files for commit.
@@ -2399,7 +2393,7 @@ var Git = class {
2399
2393
  * @param opts Add options.
2400
2394
  * @returns Command result from the command runner.
2401
2395
  */
2402
- async add(path2, opts) {
2396
+ async add(path3, opts) {
2403
2397
  const _a3 = opts != null ? opts : {}, { files, all = true } = _a3, rest = __objRest(_a3, ["files", "all"]);
2404
2398
  const args = ["add"];
2405
2399
  if (!files || files.length === 0) {
@@ -2407,7 +2401,7 @@ var Git = class {
2407
2401
  } else {
2408
2402
  args.push("--", ...files);
2409
2403
  }
2410
- return this.runGit(args, path2, rest);
2404
+ return this.runGit(args, path3, rest);
2411
2405
  }
2412
2406
  /**
2413
2407
  * Create a commit in the repository.
@@ -2417,7 +2411,7 @@ var Git = class {
2417
2411
  * @param opts Commit options.
2418
2412
  * @returns Command result from the command runner.
2419
2413
  */
2420
- async commit(path2, message, opts) {
2414
+ async commit(path3, message, opts) {
2421
2415
  const _a3 = opts != null ? opts : {}, { authorName, authorEmail, allowEmpty } = _a3, rest = __objRest(_a3, ["authorName", "authorEmail", "allowEmpty"]);
2422
2416
  const args = ["commit", "-m", message];
2423
2417
  if (allowEmpty) {
@@ -2430,7 +2424,7 @@ var Git = class {
2430
2424
  if (authorEmail) {
2431
2425
  authorArgs.push("-c", `user.email=${authorEmail}`);
2432
2426
  }
2433
- return this.runGit([...authorArgs, ...args], path2, rest);
2427
+ return this.runGit([...authorArgs, ...args], path3, rest);
2434
2428
  }
2435
2429
  /**
2436
2430
  * Reset the current HEAD to a specified state.
@@ -2439,7 +2433,7 @@ var Git = class {
2439
2433
  * @param opts Reset options.
2440
2434
  * @returns Command result from the command runner.
2441
2435
  */
2442
- async reset(path2, opts) {
2436
+ async reset(path3, opts) {
2443
2437
  const _a3 = opts != null ? opts : {}, { mode, target, paths: paths2 } = _a3, rest = __objRest(_a3, ["mode", "target", "paths"]);
2444
2438
  const allowedModes = [
2445
2439
  "soft",
@@ -2463,7 +2457,7 @@ var Git = class {
2463
2457
  if (paths2 && paths2.length > 0) {
2464
2458
  args.push("--", ...paths2);
2465
2459
  }
2466
- return this.runGit(args, path2, rest);
2460
+ return this.runGit(args, path3, rest);
2467
2461
  }
2468
2462
  /**
2469
2463
  * Restore working tree files or unstage changes.
@@ -2472,7 +2466,7 @@ var Git = class {
2472
2466
  * @param opts Restore options.
2473
2467
  * @returns Command result from the command runner.
2474
2468
  */
2475
- async restore(path2, opts) {
2469
+ async restore(path3, opts) {
2476
2470
  const _a3 = opts, { paths: paths2, staged, worktree, source } = _a3, rest = __objRest(_a3, ["paths", "staged", "worktree", "source"]);
2477
2471
  if (!paths2 || paths2.length === 0) {
2478
2472
  throw new InvalidArgumentError("At least one path is required.");
@@ -2502,7 +2496,7 @@ var Git = class {
2502
2496
  args.push("--source", source);
2503
2497
  }
2504
2498
  args.push("--", ...paths2);
2505
- return this.runGit(args, path2, rest);
2499
+ return this.runGit(args, path3, rest);
2506
2500
  }
2507
2501
  /**
2508
2502
  * Push commits to a remote.
@@ -2511,7 +2505,7 @@ var Git = class {
2511
2505
  * @param opts Push options.
2512
2506
  * @returns Command result from the command runner.
2513
2507
  */
2514
- async push(path2, opts) {
2508
+ async push(path3, opts) {
2515
2509
  const _a3 = opts != null ? opts : {}, {
2516
2510
  remote,
2517
2511
  branch,
@@ -2531,16 +2525,16 @@ var Git = class {
2531
2525
  );
2532
2526
  }
2533
2527
  if (username && password) {
2534
- const remoteName = await this.resolveRemoteName(path2, remote, rest);
2528
+ const remoteName = await this.resolveRemoteName(path3, remote, rest);
2535
2529
  return this.withRemoteCredentials(
2536
- path2,
2530
+ path3,
2537
2531
  remoteName,
2538
2532
  username,
2539
2533
  password,
2540
2534
  rest,
2541
2535
  () => this.runGit(
2542
2536
  buildPushArgs(remoteName, { remote, branch, setUpstream }),
2543
- path2,
2537
+ path3,
2544
2538
  rest
2545
2539
  )
2546
2540
  );
@@ -2548,7 +2542,7 @@ var Git = class {
2548
2542
  try {
2549
2543
  return await this.runGit(
2550
2544
  buildPushArgs(void 0, { remote, branch, setUpstream }),
2551
- path2,
2545
+ path3,
2552
2546
  rest
2553
2547
  );
2554
2548
  } catch (err) {
@@ -2570,7 +2564,7 @@ var Git = class {
2570
2564
  * @param opts Pull options.
2571
2565
  * @returns Command result from the command runner.
2572
2566
  */
2573
- async pull(path2, opts) {
2567
+ async pull(path3, opts) {
2574
2568
  const _a3 = opts != null ? opts : {}, { remote, branch, username, password } = _a3, rest = __objRest(_a3, ["remote", "branch", "username", "password"]);
2575
2569
  if (password && !username) {
2576
2570
  throw new InvalidArgumentError(
@@ -2578,7 +2572,7 @@ var Git = class {
2578
2572
  );
2579
2573
  }
2580
2574
  if (!remote && !branch) {
2581
- const hasUpstream = await this.hasUpstream(path2, rest);
2575
+ const hasUpstream = await this.hasUpstream(path3, rest);
2582
2576
  if (!hasUpstream) {
2583
2577
  throw new GitUpstreamError(buildUpstreamErrorMessage("pull"));
2584
2578
  }
@@ -2595,18 +2589,18 @@ var Git = class {
2595
2589
  return args;
2596
2590
  };
2597
2591
  if (username && password) {
2598
- const remoteName = await this.resolveRemoteName(path2, remote, rest);
2592
+ const remoteName = await this.resolveRemoteName(path3, remote, rest);
2599
2593
  return this.withRemoteCredentials(
2600
- path2,
2594
+ path3,
2601
2595
  remoteName,
2602
2596
  username,
2603
2597
  password,
2604
2598
  rest,
2605
- () => this.runGit(buildArgs(remoteName), path2, rest)
2599
+ () => this.runGit(buildArgs(remoteName), path3, rest)
2606
2600
  );
2607
2601
  }
2608
2602
  try {
2609
- return await this.runGit(buildArgs(), path2, rest);
2603
+ return await this.runGit(buildArgs(), path3, rest);
2610
2604
  } catch (err) {
2611
2605
  if (isAuthFailure(err)) {
2612
2606
  throw new GitAuthError(
@@ -2743,8 +2737,8 @@ var Git = class {
2743
2737
  envs: mergedEnvs
2744
2738
  }));
2745
2739
  }
2746
- async getRemoteUrl(path2, remote, opts) {
2747
- const result = await this.runGit(["remote", "get-url", remote], path2, opts);
2740
+ async getRemoteUrl(path3, remote, opts) {
2741
+ const result = await this.runGit(["remote", "get-url", remote], path3, opts);
2748
2742
  const url = result.stdout.trim();
2749
2743
  if (!url) {
2750
2744
  throw new InvalidArgumentError(
@@ -2753,11 +2747,11 @@ var Git = class {
2753
2747
  }
2754
2748
  return url;
2755
2749
  }
2756
- async resolveRemoteName(path2, remote, opts) {
2750
+ async resolveRemoteName(path3, remote, opts) {
2757
2751
  if (remote) {
2758
2752
  return remote;
2759
2753
  }
2760
- const result = await this.runGit(["remote"], path2, opts);
2754
+ const result = await this.runGit(["remote"], path3, opts);
2761
2755
  const remotes = result.stdout.split("\n").map((line) => line.trim()).filter(Boolean);
2762
2756
  if (remotes.length === 1) {
2763
2757
  return remotes[0];
@@ -2766,10 +2760,10 @@ var Git = class {
2766
2760
  "Remote is required when using username/password and the repository has multiple remotes."
2767
2761
  );
2768
2762
  }
2769
- async withRemoteCredentials(path2, remote, username, password, opts, operation) {
2770
- const originalUrl = await this.getRemoteUrl(path2, remote, opts);
2763
+ async withRemoteCredentials(path3, remote, username, password, opts, operation) {
2764
+ const originalUrl = await this.getRemoteUrl(path3, remote, opts);
2771
2765
  const credentialUrl = withCredentials(originalUrl, username, password);
2772
- await this.runGit(["remote", "set-url", remote, credentialUrl], path2, opts);
2766
+ await this.runGit(["remote", "set-url", remote, credentialUrl], path3, opts);
2773
2767
  let result;
2774
2768
  let operationError;
2775
2769
  try {
@@ -2779,7 +2773,7 @@ var Git = class {
2779
2773
  }
2780
2774
  let restoreError;
2781
2775
  try {
2782
- await this.runGit(["remote", "set-url", remote, originalUrl], path2, opts);
2776
+ await this.runGit(["remote", "set-url", remote, originalUrl], path3, opts);
2783
2777
  } catch (err) {
2784
2778
  restoreError = err;
2785
2779
  }
@@ -2791,11 +2785,11 @@ var Git = class {
2791
2785
  }
2792
2786
  return result;
2793
2787
  }
2794
- async hasUpstream(path2, opts) {
2788
+ async hasUpstream(path3, opts) {
2795
2789
  try {
2796
2790
  const result = await this.runGit(
2797
2791
  ["rev-parse", "--abbrev-ref", "--symbolic-full-name", "@{u}"],
2798
- path2,
2792
+ path3,
2799
2793
  opts
2800
2794
  );
2801
2795
  return result.stdout.trim().length > 0;
@@ -2963,11 +2957,11 @@ function normalizeSecretHosts(hosts) {
2963
2957
  }
2964
2958
  return normalizedHosts;
2965
2959
  }
2966
- async function request(method, path2, feature, opts, body) {
2960
+ async function request(method, path3, feature, opts, body) {
2967
2961
  const config = new ConnectionConfig(opts);
2968
2962
  raiseIfLegacy(config, feature, SecretError);
2969
2963
  const headers = __spreadValues(__spreadValues(__spreadValues(__spreadValues({}, config.headers), body ? { "Content-Type": "application/json" } : {}), config.apiKey ? { "X-API-KEY": config.apiKey } : {}), config.accessToken ? { Authorization: `Bearer ${config.accessToken}` } : {});
2970
- const response = await fetch(`${config.apiUrl}${path2}`, {
2964
+ const response = await fetch(`${config.apiUrl}${path3}`, {
2971
2965
  method,
2972
2966
  headers,
2973
2967
  body: body ? JSON.stringify(body) : void 0,
@@ -3282,7 +3276,7 @@ var SandboxApi = class {
3282
3276
  }
3283
3277
  return true;
3284
3278
  }
3285
- static async mountVolume(sandboxId, name, path2, opts) {
3279
+ static async mountVolume(sandboxId, name, path3, opts) {
3286
3280
  var _a3, _b;
3287
3281
  const config = new ConnectionConfig(opts);
3288
3282
  raiseIfLegacy(config, "Sandbox.mountVolume", SandboxError);
@@ -3293,7 +3287,7 @@ var SandboxApi = class {
3293
3287
  headers: getRawApiHeaders(config, {
3294
3288
  "Content-Type": "application/json"
3295
3289
  }),
3296
- body: JSON.stringify({ name, path: path2 }),
3290
+ body: JSON.stringify({ name, path: path3 }),
3297
3291
  signal: config.getSignal(opts == null ? void 0 : opts.requestTimeoutMs)
3298
3292
  }
3299
3293
  );
@@ -3318,14 +3312,14 @@ var SandboxApi = class {
3318
3312
  volumeMounts: (_b = data.volumeMounts) != null ? _b : []
3319
3313
  };
3320
3314
  }
3321
- static async unmountVolume(sandboxId, path2, opts) {
3315
+ static async unmountVolume(sandboxId, path3, opts) {
3322
3316
  var _a3, _b;
3323
3317
  const config = new ConnectionConfig(opts);
3324
3318
  raiseIfLegacy(config, "Sandbox.unmountVolume", SandboxError);
3325
3319
  const url = new URL(
3326
3320
  `${config.apiUrl}/sandboxes/${encodeURIComponent(sandboxId)}/volume-mounts`
3327
3321
  );
3328
- url.searchParams.set("path", path2);
3322
+ url.searchParams.set("path", path3);
3329
3323
  if (opts == null ? void 0 : opts.force) {
3330
3324
  url.searchParams.set("force", "true");
3331
3325
  }
@@ -3619,7 +3613,7 @@ var SandboxApi = class {
3619
3613
  return true;
3620
3614
  }
3621
3615
  static async createSandbox(template, timeoutMs, opts) {
3622
- var _a3, _b, _c, _d, _e, _f;
3616
+ var _a3, _b, _c, _d, _e, _f, _g;
3623
3617
  const config = new ConnectionConfig(opts);
3624
3618
  const lifecycle = getLifecycle(opts);
3625
3619
  const autoPause = lifecycle.onTimeout === "pause";
@@ -3628,8 +3622,13 @@ var SandboxApi = class {
3628
3622
  if (opts == null ? void 0 : opts.mcp) {
3629
3623
  raiseIfLegacy(config, "Sandbox.create mcp", SandboxError);
3630
3624
  }
3631
- if (opts == null ? void 0 : opts.network) {
3632
- raiseIfLegacy(config, "Sandbox.create network", SandboxError);
3625
+ const unsupportedNetworkOptions = Object.keys((_b = opts == null ? void 0 : opts.network) != null ? _b : {}).filter(
3626
+ (key) => key !== "allowPublicTraffic"
3627
+ );
3628
+ if (unsupportedNetworkOptions.length > 0) {
3629
+ throw new SandboxError(
3630
+ `Sandbox.create network only supports allowPublicTraffic on legacy domains; unsupported options: ${unsupportedNetworkOptions.join(", ")}`
3631
+ );
3633
3632
  }
3634
3633
  if (opts == null ? void 0 : opts.volumeMounts) {
3635
3634
  raiseIfLegacy(config, "Sandbox.create volumeMounts", SandboxError);
@@ -3637,14 +3636,14 @@ var SandboxApi = class {
3637
3636
  if (opts == null ? void 0 : opts.secretEnvs) {
3638
3637
  raiseIfLegacy(config, "Sandbox.create secretEnvs", SandboxError);
3639
3638
  }
3640
- const body2 = __spreadValues({
3639
+ const body2 = __spreadValues(__spreadValues({
3641
3640
  templateID: template,
3642
3641
  timeout: timeoutToSeconds(timeoutMs),
3643
- metadata: (_b = opts == null ? void 0 : opts.metadata) != null ? _b : {},
3644
- envVars: (_c = opts == null ? void 0 : opts.envs) != null ? _c : {},
3645
- secure: (_d = opts == null ? void 0 : opts.secure) != null ? _d : false,
3642
+ metadata: (_c = opts == null ? void 0 : opts.metadata) != null ? _c : {},
3643
+ envVars: (_d = opts == null ? void 0 : opts.envs) != null ? _d : {},
3644
+ secure: (_e = opts == null ? void 0 : opts.secure) != null ? _e : false,
3646
3645
  autoPause: autoPause != null ? autoPause : false
3647
- }, (opts == null ? void 0 : opts.nodeId) ? { nodeID: opts.nodeId } : {});
3646
+ }, (opts == null ? void 0 : opts.network) ? { network: opts.network } : {}), (opts == null ? void 0 : opts.nodeId) ? { nodeID: opts.nodeId } : {});
3648
3647
  const response = await fetch(`${config.apiUrl}/sandboxes`, {
3649
3648
  method: "POST",
3650
3649
  headers: getRawApiHeaders(config, {
@@ -3668,7 +3667,7 @@ var SandboxApi = class {
3668
3667
  sandboxDomain: data.domain || void 0,
3669
3668
  envdVersion: data.envdVersion,
3670
3669
  envdAccessToken: data.envdAccessToken,
3671
- trafficAccessToken: void 0
3670
+ trafficAccessToken: data.trafficAccessToken || void 0
3672
3671
  };
3673
3672
  }
3674
3673
  const client = new ApiClient(config);
@@ -3678,8 +3677,8 @@ var SandboxApi = class {
3678
3677
  mcp: opts == null ? void 0 : opts.mcp,
3679
3678
  envVars: opts == null ? void 0 : opts.envs,
3680
3679
  timeout: timeoutToSeconds(timeoutMs),
3681
- secure: (_e = opts == null ? void 0 : opts.secure) != null ? _e : true,
3682
- allow_internet_access: (_f = opts == null ? void 0 : opts.allowInternetAccess) != null ? _f : true,
3680
+ secure: (_f = opts == null ? void 0 : opts.secure) != null ? _f : true,
3681
+ allow_internet_access: (_g = opts == null ? void 0 : opts.allowInternetAccess) != null ? _g : true,
3683
3682
  network: opts == null ? void 0 : opts.network
3684
3683
  }, (opts == null ? void 0 : opts.nodeId) ? { nodeID: opts.nodeId } : {}), autoPause !== void 0 ? { autoPause } : {}), autoResumeEnabled !== void 0 ? { autoResume: { enabled: autoResumeEnabled } } : {});
3685
3684
  if (opts == null ? void 0 : opts.volumeMounts) {
@@ -3732,7 +3731,9 @@ var SandboxApi = class {
3732
3731
  headers: getRawApiHeaders(config, {
3733
3732
  "Content-Type": "application/json"
3734
3733
  }),
3735
- body: JSON.stringify({ timeout: timeoutToSeconds(timeoutMs) }),
3734
+ body: JSON.stringify(__spreadValues(__spreadValues(__spreadValues({
3735
+ timeout: timeoutToSeconds(timeoutMs)
3736
+ }, (opts == null ? void 0 : opts.secure) !== void 0 ? { secure: opts.secure } : {}), (opts == null ? void 0 : opts.allowPublicTraffic) !== void 0 ? { allowPublicTraffic: opts.allowPublicTraffic } : {}), (opts == null ? void 0 : opts.network) ? { network: opts.network } : {})),
3736
3737
  signal: config.getSignal(opts == null ? void 0 : opts.requestTimeoutMs)
3737
3738
  }
3738
3739
  );
@@ -3748,7 +3749,7 @@ var SandboxApi = class {
3748
3749
  sandboxDomain: data.domain || void 0,
3749
3750
  envdVersion: data.envdVersion || "0.0.0",
3750
3751
  envdAccessToken: data.envdAccessToken,
3751
- trafficAccessToken: void 0
3752
+ trafficAccessToken: data.trafficAccessToken || void 0
3752
3753
  };
3753
3754
  }
3754
3755
  const client = new ApiClient(config);
@@ -4005,7 +4006,7 @@ var SnapshotPaginator = class extends BasePaginator {
4005
4006
 
4006
4007
  // src/core/sandbox/signature.ts
4007
4008
  async function getSignature({
4008
- path: path2,
4009
+ path: path3,
4009
4010
  operation,
4010
4011
  user,
4011
4012
  expirationInSeconds,
@@ -4022,9 +4023,9 @@ async function getSignature({
4022
4023
  user = "";
4023
4024
  }
4024
4025
  if (signatureExpiration === null) {
4025
- signatureRaw = `${path2}:${operation}:${user}:${envdAccessToken}`;
4026
+ signatureRaw = `${path3}:${operation}:${user}:${envdAccessToken}`;
4026
4027
  } else {
4027
- signatureRaw = `${path2}:${operation}:${user}:${envdAccessToken}:${signatureExpiration.toString()}`;
4028
+ signatureRaw = `${path3}:${operation}:${user}:${envdAccessToken}:${signatureExpiration.toString()}`;
4028
4029
  }
4029
4030
  const hashBase64 = await sha256(signatureRaw);
4030
4031
  const signature = "v1_" + hashBase64.replace(/=+$/, "");
@@ -4208,8 +4209,8 @@ var Sandbox = class extends SandboxApi {
4208
4209
  *
4209
4210
  * @returns updated sandbox information.
4210
4211
  */
4211
- static async mountVolume(sandboxId, name, path2, opts) {
4212
- return await SandboxApi.mountVolume(sandboxId, name, path2, opts);
4212
+ static async mountVolume(sandboxId, name, path3, opts) {
4213
+ return await SandboxApi.mountVolume(sandboxId, name, path3, opts);
4213
4214
  }
4214
4215
  /**
4215
4216
  * Unmount a volume from a sandbox.
@@ -4221,8 +4222,8 @@ var Sandbox = class extends SandboxApi {
4221
4222
  *
4222
4223
  * @returns updated sandbox information.
4223
4224
  */
4224
- static async unmountVolume(sandboxId, path2, opts) {
4225
- return await SandboxApi.unmountVolume(sandboxId, path2, opts);
4225
+ static async unmountVolume(sandboxId, path3, opts) {
4226
+ return await SandboxApi.unmountVolume(sandboxId, path3, opts);
4226
4227
  }
4227
4228
  /**
4228
4229
  * Commit a sandbox to create a snapshot template.
@@ -4457,11 +4458,11 @@ var Sandbox = class extends SandboxApi {
4457
4458
  *
4458
4459
  * @returns updated sandbox information.
4459
4460
  */
4460
- async mountVolume(name, path2, opts) {
4461
+ async mountVolume(name, path3, opts) {
4461
4462
  return await SandboxApi.mountVolume(
4462
4463
  this.sandboxId,
4463
4464
  name,
4464
- path2,
4465
+ path3,
4465
4466
  this.resolveApiOpts(opts)
4466
4467
  );
4467
4468
  }
@@ -4474,10 +4475,10 @@ var Sandbox = class extends SandboxApi {
4474
4475
  *
4475
4476
  * @returns updated sandbox information.
4476
4477
  */
4477
- async unmountVolume(path2, opts) {
4478
+ async unmountVolume(path3, opts) {
4478
4479
  return await SandboxApi.unmountVolume(
4479
4480
  this.sandboxId,
4480
- path2,
4481
+ path3,
4481
4482
  this.resolveApiOpts(opts)
4482
4483
  );
4483
4484
  }
@@ -4611,7 +4612,7 @@ var Sandbox = class extends SandboxApi {
4611
4612
  *
4612
4613
  * @returns URL for uploading file.
4613
4614
  */
4614
- async uploadUrl(path2, opts) {
4615
+ async uploadUrl(path3, opts) {
4615
4616
  opts = opts != null ? opts : {};
4616
4617
  const useSignature = !!this.envdAccessToken;
4617
4618
  if (!useSignature && opts.useSignatureExpiration != void 0) {
@@ -4623,7 +4624,7 @@ var Sandbox = class extends SandboxApi {
4623
4624
  if (username == void 0 && compareVersions5(this.envdApi.version, ENVD_DEFAULT_USER) < 0) {
4624
4625
  username = defaultUsername;
4625
4626
  }
4626
- const filePath = path2 != null ? path2 : "";
4627
+ const filePath = path3 != null ? path3 : "";
4627
4628
  const fileUrl = this.fileUrl(filePath, username);
4628
4629
  if (useSignature) {
4629
4630
  const url = new URL(fileUrl);
@@ -4651,7 +4652,7 @@ var Sandbox = class extends SandboxApi {
4651
4652
  *
4652
4653
  * @returns URL for downloading file.
4653
4654
  */
4654
- async downloadUrl(path2, opts) {
4655
+ async downloadUrl(path3, opts) {
4655
4656
  opts = opts != null ? opts : {};
4656
4657
  const useSignature = !!this.envdAccessToken;
4657
4658
  if (!useSignature && opts.useSignatureExpiration != void 0) {
@@ -4663,11 +4664,11 @@ var Sandbox = class extends SandboxApi {
4663
4664
  if (username == void 0 && compareVersions5(this.envdApi.version, ENVD_DEFAULT_USER) < 0) {
4664
4665
  username = defaultUsername;
4665
4666
  }
4666
- const fileUrl = this.fileUrl(path2, username);
4667
+ const fileUrl = this.fileUrl(path3, username);
4667
4668
  if (useSignature) {
4668
4669
  const url = new URL(fileUrl);
4669
4670
  const sig = await getSignature({
4670
- path: path2,
4671
+ path: path3,
4671
4672
  operation: "read",
4672
4673
  user: username,
4673
4674
  expirationInSeconds: opts.useSignatureExpiration,
@@ -4721,13 +4722,13 @@ var Sandbox = class extends SandboxApi {
4721
4722
  resolveApiOpts(opts) {
4722
4723
  return __spreadValues(__spreadValues({}, this.connectionConfig), opts != null ? opts : {});
4723
4724
  }
4724
- fileUrl(path2, username) {
4725
+ fileUrl(path3, username) {
4725
4726
  const url = new URL("/files", this.envdApiUrl);
4726
4727
  if (username) {
4727
4728
  url.searchParams.set("username", username);
4728
4729
  }
4729
- if (path2) {
4730
- url.searchParams.set("path", path2);
4730
+ if (path3) {
4731
+ url.searchParams.set("path", path3);
4731
4732
  }
4732
4733
  return url.toString();
4733
4734
  }
@@ -4858,6 +4859,7 @@ function defaultBuildLogger(options) {
4858
4859
  import crypto2 from "crypto";
4859
4860
  import fs from "fs";
4860
4861
  import path from "path";
4862
+ import { fileURLToPath } from "url";
4861
4863
 
4862
4864
  // src/core/template/consts.ts
4863
4865
  var FINALIZE_STEP_NAME = "finalize";
@@ -4908,8 +4910,8 @@ function readDockerignore(contextPath) {
4908
4910
  const content = fs.readFileSync(dockerignorePath, "utf-8");
4909
4911
  return content.split("\n").map((line) => line.trim()).filter((line) => line && !line.startsWith("#"));
4910
4912
  }
4911
- function normalizePath(path2) {
4912
- return path2.replace(/\\/g, "/");
4913
+ function normalizePath(path3) {
4914
+ return path3.replace(/\\/g, "/");
4913
4915
  }
4914
4916
  async function getAllFilesInPath(src, contextPath, ignorePatterns, includeDirectories = true) {
4915
4917
  const { glob } = await dynamicImport("glob");
@@ -5021,7 +5023,6 @@ function getCallerDirectory(depth) {
5021
5023
  return void 0;
5022
5024
  }
5023
5025
  if (fileName.startsWith("file:")) {
5024
- const { fileURLToPath } = dynamicRequire("node:url");
5025
5026
  fileName = fileURLToPath(fileName);
5026
5027
  }
5027
5028
  return path.dirname(fileName);
@@ -6477,8 +6478,8 @@ var TemplateBase = class _TemplateBase {
6477
6478
  });
6478
6479
  return this;
6479
6480
  }
6480
- remove(path2, options) {
6481
- const paths2 = Array.isArray(path2) ? path2 : [path2];
6481
+ remove(path3, options) {
6482
+ const paths2 = Array.isArray(path3) ? path3 : [path3];
6482
6483
  const args = ["rm"];
6483
6484
  if (options == null ? void 0 : options.recursive) {
6484
6485
  args.push("-r");
@@ -6500,8 +6501,8 @@ var TemplateBase = class _TemplateBase {
6500
6501
  () => this.runCmd(args.join(" "), { user: options == null ? void 0 : options.user })
6501
6502
  );
6502
6503
  }
6503
- makeDir(path2, options) {
6504
- const paths2 = Array.isArray(path2) ? path2 : [path2];
6504
+ makeDir(path3, options) {
6505
+ const paths2 = Array.isArray(path3) ? path3 : [path3];
6505
6506
  const args = ["mkdir", "-p"];
6506
6507
  if (options == null ? void 0 : options.mode) {
6507
6508
  args.push(`-m ${padOctal(options.mode)}`);
@@ -6636,7 +6637,7 @@ var TemplateBase = class _TemplateBase {
6636
6637
  })
6637
6638
  );
6638
6639
  }
6639
- gitClone(url, path2, options) {
6640
+ gitClone(url, path3, options) {
6640
6641
  const args = ["git", "clone", url];
6641
6642
  if (options == null ? void 0 : options.branch) {
6642
6643
  args.push(`--branch ${options.branch}`);
@@ -6645,8 +6646,8 @@ var TemplateBase = class _TemplateBase {
6645
6646
  if (options == null ? void 0 : options.depth) {
6646
6647
  args.push(`--depth ${options.depth}`);
6647
6648
  }
6648
- if (path2) {
6649
- args.push(path2.toString());
6649
+ if (path3) {
6650
+ args.push(path3.toString());
6650
6651
  }
6651
6652
  return this.runInNewStackTraceContext(
6652
6653
  () => this.runCmd(args.join(" "), { user: options == null ? void 0 : options.user })
@@ -7361,6 +7362,8 @@ var Volume = class _Volume {
7361
7362
  };
7362
7363
 
7363
7364
  // src/core/client.ts
7365
+ import path2 from "path";
7366
+ import { fileURLToPath as fileURLToPath2 } from "url";
7364
7367
  function mergeConnectionOpts(base, next) {
7365
7368
  var _a3, _b;
7366
7369
  const baseHeaders = (_a3 = base.headers) != null ? _a3 : {};
@@ -7565,7 +7568,18 @@ var TemplateNamespace = class {
7565
7568
  this.toDockerfile = Template.toDockerfile;
7566
7569
  }
7567
7570
  new(options) {
7568
- return Template(options);
7571
+ var _a3;
7572
+ let callerContext = ".";
7573
+ for (const site of callsites(2)) {
7574
+ const fileName = site.getFileName();
7575
+ if (fileName && (!fileName.includes("/src/core/") || fileName.includes("/src/core/tests/")) && !fileName.includes("/node_modules/ppio-sandbox/")) {
7576
+ callerContext = path2.dirname(fileName.startsWith("file:") ? fileURLToPath2(fileName) : fileName);
7577
+ break;
7578
+ }
7579
+ }
7580
+ return Template(__spreadProps(__spreadValues({}, options), {
7581
+ fileContextPath: (_a3 = options == null ? void 0 : options.fileContextPath) != null ? _a3 : callerContext
7582
+ }));
7569
7583
  }
7570
7584
  list(opts) {
7571
7585
  return Template.list(mergeConnectionOpts(this.opts, opts));
@@ -7694,12 +7708,12 @@ var PPIO = class {
7694
7708
  this.secret = new SecretNamespace(opts);
7695
7709
  this.codeInterpreter = new RuntimeSandboxNamespace(
7696
7710
  opts,
7697
- () => import("./sandbox-FGY2BWMG.mjs")
7711
+ () => import("./sandbox-OAPKYDCZ.mjs")
7698
7712
  );
7699
7713
  this.code_interpreter = this.codeInterpreter;
7700
7714
  this.desktop = new RuntimeSandboxNamespace(
7701
7715
  opts,
7702
- () => import("./sandbox-7DONHEV2.mjs")
7716
+ () => import("./sandbox-IFBOTC7A.mjs")
7703
7717
  );
7704
7718
  }
7705
7719
  async create(templateOrOpts, opts) {
@@ -7777,4 +7791,4 @@ export {
7777
7791
  ALL_TRAFFIC,
7778
7792
  core_default
7779
7793
  };
7780
- //# sourceMappingURL=chunk-GFQFOIS4.mjs.map
7794
+ //# sourceMappingURL=chunk-6PRE7JOS.mjs.map