poe-code 10.0.3 → 11.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (32) hide show
  1. package/dist/cli/commands/harness.js +27 -1
  2. package/dist/cli/commands/harness.js.map +1 -1
  3. package/dist/index.js +1125 -888
  4. package/dist/index.js.map +4 -4
  5. package/dist/metafile.json +1 -1
  6. package/package.json +1 -1
  7. package/packages/agent-harness/dist/loader/run.js +4 -1
  8. package/packages/safejs/dist/chunks/{chunk-MRH5YDMR.js → chunk-ARFGEQTM.js} +213 -51
  9. package/packages/safejs/dist/chunks/chunk-ARFGEQTM.js.map +7 -0
  10. package/packages/safejs/dist/chunks/{chunk-A2XBEN3H.js → chunk-DKXGPEOM.js} +182 -133
  11. package/packages/safejs/dist/chunks/{chunk-A2XBEN3H.js.map → chunk-DKXGPEOM.js.map} +3 -3
  12. package/packages/safejs/dist/cli.js +51 -2
  13. package/packages/safejs/dist/cli.js.map +2 -2
  14. package/packages/safejs/dist/core.js +1 -1
  15. package/packages/safejs/dist/index.d.ts +3 -0
  16. package/packages/safejs/dist/index.js +8 -2
  17. package/packages/safejs/dist/index.js.map +1 -1
  18. package/packages/safejs/dist/interp/interpreter.js +73 -127
  19. package/packages/safejs/dist/interp/scope.js +3 -3
  20. package/packages/safejs/dist/migrate.d.ts +33 -0
  21. package/packages/safejs/dist/migrate.js +70 -0
  22. package/packages/safejs/dist/migration-file.d.ts +55 -0
  23. package/packages/safejs/dist/migration-file.js +79 -0
  24. package/packages/safejs/dist/restore.d.ts +2 -0
  25. package/packages/safejs/dist/restore.js +2 -0
  26. package/packages/safejs/dist/run.js +18 -2
  27. package/packages/safejs/dist/snapshot/dump-format.d.ts +1 -1
  28. package/packages/safejs/dist/snapshot/dump-format.js +1 -1
  29. package/packages/safejs/dist/snapshot/migration.d.ts +34 -0
  30. package/packages/safejs/dist/snapshot/migration.js +92 -0
  31. package/packages/safejs/dist/snapshot/validation.js +0 -4
  32. package/packages/safejs/dist/chunks/chunk-MRH5YDMR.js.map +0 -7
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "poe-code",
3
- "version": "10.0.3",
3
+ "version": "11.0.0",
4
4
  "description": "CLI tool to configure Poe API for developer workflows.",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -138,7 +138,10 @@ export async function runHarnessPair(mdPath, options) {
138
138
  throw error;
139
139
  }
140
140
  await hostCallReplay.flush();
141
- if (result.ok && options.preserveSnapshotOnSuccess !== true) {
141
+ if (result.ok && result.snapshot.migration !== undefined) {
142
+ await snapshotBackend.write(result.snapshot);
143
+ }
144
+ else if (result.ok && options.preserveSnapshotOnSuccess !== true) {
142
145
  await cleanupCompletedSnapshot(snapshotBackend, snapshotPath);
143
146
  }
144
147
  const usage = usageAccumulator.snapshot();
@@ -1,20 +1,179 @@
1
1
  import {
2
+ DUMP_FORMAT_VERSION,
3
+ EXECUTION_SEMANTICS,
2
4
  SandboxError,
3
5
  activateOtelSpan,
6
+ assertSnapshotInactive,
4
7
  bindOtelSpan,
5
8
  declareHostOperation,
6
9
  deepCopyToSandbox,
10
+ encodeReplayData,
7
11
  getActiveOtelSink,
8
12
  getOwnErrorCode,
9
13
  hasOwnErrorCode,
14
+ hashSource,
10
15
  hostErrorData,
11
16
  isSandboxClosure,
17
+ parseModule,
12
18
  runResources,
13
19
  safeAddEvent,
14
20
  safeEndSpan,
15
21
  safeRecordException,
16
- safeStartSpan
17
- } from "./chunk-A2XBEN3H.js";
22
+ safeStartSpan,
23
+ serializeSafeJSSnapshot,
24
+ validateDumpEnvelope,
25
+ validateMigrationJournal,
26
+ validateMigrationReconciliation,
27
+ validateMigrationSemantics,
28
+ validateSnapshotData,
29
+ validateSnapshotMigration
30
+ } from "./chunk-DKXGPEOM.js";
31
+
32
+ // packages/safejs/src/migrate.ts
33
+ import { createHash } from "node:crypto";
34
+ function inspectSnapshotMigration(snapshot, options) {
35
+ assertSnapshotInactive(snapshot);
36
+ validateSnapshotData(snapshot);
37
+ validateDumpEnvelope(snapshot);
38
+ validateMigrationSemantics(snapshot.executionSemantics);
39
+ const sourceHash = hashSource(options.source);
40
+ if (snapshot.sourceHash !== sourceHash)
41
+ throw new TypeError(
42
+ `Migration requires the original executable source (checkpoint hash ${snapshot.sourceHash}, supplied ${sourceHash}). Preserve the checkpoint; do not replace its hash.`
43
+ );
44
+ validateSnapshotMigration(snapshot.migration, sourceHash);
45
+ const replay = validateMigrationJournal(sourceHash, snapshot.replay, snapshot.hostCalls);
46
+ return {
47
+ checkpointDigest: createHash("sha256").update(canonicalData(snapshot)).digest("hex"),
48
+ sourceHash,
49
+ executionSemantics: snapshot.executionSemantics,
50
+ calls: replay.calls,
51
+ unresolvedCalls: replay.calls.filter(
52
+ (call) => !["settled", "consumed"].includes(call.lifecycle)
53
+ )
54
+ };
55
+ }
56
+ function migrateSnapshot(snapshot, options) {
57
+ if (!Object.hasOwn(options, "state"))
58
+ throw new TypeError("Migration requires explicit application state.");
59
+ const inspection = inspectSnapshotMigration(snapshot, { source: options.source });
60
+ parseModule(options.targetSource);
61
+ const targetSourceHash = hashSource(options.targetSource);
62
+ validateMigrationReconciliation(
63
+ options.reconciliation,
64
+ inspection.checkpointDigest,
65
+ inspection.calls
66
+ );
67
+ const state = encodeReplayData(deepCopyToSandbox(options.state));
68
+ const previous = snapshot.migration;
69
+ const migration = {
70
+ version: 1,
71
+ state,
72
+ history: [
73
+ ...structuredClone(previous?.history ?? []),
74
+ {
75
+ sourceHash: inspection.sourceHash,
76
+ targetSourceHash,
77
+ executionSemantics: inspection.executionSemantics,
78
+ replay: { version: 1, calls: inspection.calls },
79
+ reconciliation: structuredClone(options.reconciliation)
80
+ }
81
+ ]
82
+ };
83
+ validateSnapshotMigration(migration, targetSourceHash);
84
+ return {
85
+ version: DUMP_FORMAT_VERSION,
86
+ executionSemantics: EXECUTION_SEMANTICS,
87
+ sourceHash: targetSourceHash,
88
+ bindings: {},
89
+ replay: { version: 1, calls: [] },
90
+ migration
91
+ };
92
+ }
93
+ function canonicalData(value) {
94
+ if (Array.isArray(value)) return `[${value.map(canonicalData).join(",")}]`;
95
+ if (value !== null && typeof value === "object")
96
+ return `{${Object.keys(value).sort().map(
97
+ (key2) => `${JSON.stringify(key2)}:${canonicalData(value[key2])}`
98
+ ).join(",")}}`;
99
+ return JSON.stringify(value);
100
+ }
101
+
102
+ // packages/safejs/src/migration-file.ts
103
+ import { randomUUID } from "node:crypto";
104
+ import { link, open, readFile, unlink } from "node:fs/promises";
105
+ import path from "node:path";
106
+ async function migrateSnapshotFile(options) {
107
+ const cwd = options.cwd ?? process.cwd();
108
+ const resolvePath = (value, label) => {
109
+ if (typeof value !== "string" || value.trim().length === 0)
110
+ throw new TypeError(`Migration requires ${label}.`);
111
+ return path.resolve(cwd, value);
112
+ };
113
+ const snapshotPath = resolvePath(options.snapshotPath, "a snapshot path");
114
+ const sourcePath = resolvePath(options.sourcePath, "--from <original.ajs>");
115
+ if (options.inspect && [options.targetSourcePath, options.planPath, options.outputPath].some(
116
+ (value) => value !== void 0
117
+ ))
118
+ throw new TypeError("Migration --inspect cannot be combined with --to, --plan, or --output.");
119
+ const outputPath = options.inspect ? void 0 : resolvePath(options.outputPath, "--output <new-checkpoint.json>");
120
+ const targetSourcePath = options.inspect ? void 0 : resolvePath(options.targetSourcePath, "--to <continuation.ajs>");
121
+ const planPath = options.inspect ? void 0 : resolvePath(options.planPath, "--plan <migration.json>");
122
+ for (const filepath of [sourcePath, targetSourcePath]) {
123
+ if (filepath !== void 0 && ![".ajs", ".safejs"].includes(path.extname(filepath)))
124
+ throw new TypeError(
125
+ "Migration source paths must name executable .ajs or .safejs files, not harness Markdown."
126
+ );
127
+ }
128
+ const snapshot = JSON.parse(await readFile(snapshotPath, "utf8"));
129
+ const source = await readFile(sourcePath, "utf8");
130
+ const inspection = inspectSnapshotMigration(snapshot, { source });
131
+ if (options.inspect) return { inspection };
132
+ const plan = JSON.parse(await readFile(planPath, "utf8"));
133
+ if (plan === null || typeof plan !== "object" || !Object.hasOwn(plan, "state") || !Object.hasOwn(plan, "reconciliation"))
134
+ throw new TypeError("Migration plan requires explicit state and reconciliation fields.");
135
+ const targetSource = await readFile(targetSourcePath, "utf8");
136
+ const migrated = migrateSnapshot(snapshot, {
137
+ source,
138
+ targetSource,
139
+ state: plan.state,
140
+ reconciliation: plan.reconciliation
141
+ });
142
+ const contents = serializeSafeJSSnapshot(migrated);
143
+ if (!options.dryRun) {
144
+ const temporaryPath = path.join(
145
+ path.dirname(outputPath),
146
+ `.safejs-migration-${randomUUID()}.tmp`
147
+ );
148
+ let created = false;
149
+ try {
150
+ const handle = await open(temporaryPath, "wx", 384);
151
+ created = true;
152
+ try {
153
+ await handle.writeFile(contents, "utf8");
154
+ await handle.sync();
155
+ } finally {
156
+ await handle.close();
157
+ }
158
+ try {
159
+ await link(temporaryPath, outputPath);
160
+ } catch (error) {
161
+ if (hasOwnErrorCode(error, "EEXIST"))
162
+ throw Object.assign(
163
+ new Error(
164
+ `Migration output already exists: ${JSON.stringify(outputPath)}. Choose a new output path; existing files are never overwritten.`,
165
+ { cause: error }
166
+ ),
167
+ { code: "EEXIST" }
168
+ );
169
+ throw error;
170
+ }
171
+ } finally {
172
+ if (created) await unlink(temporaryPath);
173
+ }
174
+ }
175
+ return { inspection, outputPath, dryRun: options.dryRun === true };
176
+ }
18
177
 
19
178
  // packages/safejs/src/error/format.ts
20
179
  var DEFAULT_MAX_MESSAGE_LENGTH = 1e4;
@@ -2729,9 +2888,9 @@ import { basename, dirname, isAbsolute, relative, resolve, sep } from "node:path
2729
2888
  var MISSING_PATH_CODES = ["ENOENT", "ENOTDIR"];
2730
2889
  var NOT_A_SYMLINK_CODES = [...MISSING_PATH_CODES, "EINVAL"];
2731
2890
  var MAX_SYMLINK_FOLLOWS = 32;
2732
- async function resolveCanonicalPath({ realpath, readlink }, path4) {
2891
+ async function resolveCanonicalPath({ realpath, readlink }, path5) {
2733
2892
  const missingSegments = [];
2734
- let current = path4;
2893
+ let current = path5;
2735
2894
  let follows = 0;
2736
2895
  while (true) {
2737
2896
  try {
@@ -2744,23 +2903,23 @@ async function resolveCanonicalPath({ realpath, readlink }, path4) {
2744
2903
  const target = await readSymlinkTarget(readlink, current);
2745
2904
  if (target !== void 0) {
2746
2905
  if (++follows > MAX_SYMLINK_FOLLOWS) {
2747
- throw createLoopError(path4);
2906
+ throw createLoopError(path5);
2748
2907
  }
2749
2908
  current = isAbsolute(target) ? resolve(target) : resolve(dirname(current), target);
2750
2909
  continue;
2751
2910
  }
2752
2911
  const parent = dirname(current);
2753
2912
  if (parent === current) {
2754
- return resolve(path4);
2913
+ return resolve(path5);
2755
2914
  }
2756
2915
  missingSegments.push(basename(current));
2757
2916
  current = parent;
2758
2917
  }
2759
2918
  }
2760
2919
  }
2761
- async function readSymlinkTarget(readlink, path4) {
2920
+ async function readSymlinkTarget(readlink, path5) {
2762
2921
  try {
2763
- return await readlink(path4);
2922
+ return await readlink(path5);
2764
2923
  } catch (error) {
2765
2924
  if (NOT_A_SYMLINK_CODES.includes(getOwnErrorCode(error) ?? "")) {
2766
2925
  return void 0;
@@ -2768,9 +2927,9 @@ async function readSymlinkTarget(readlink, path4) {
2768
2927
  throw error;
2769
2928
  }
2770
2929
  }
2771
- function createLoopError(path4) {
2930
+ function createLoopError(path5) {
2772
2931
  const error = new Error(
2773
- `ELOOP: too many symbolic links encountered, realpath '${path4}'`
2932
+ `ELOOP: too many symbolic links encountered, realpath '${path5}'`
2774
2933
  );
2775
2934
  error.code = "ELOOP";
2776
2935
  return error;
@@ -2813,9 +2972,9 @@ async function descendsFromRoot(stat, canonicalRoot, canonicalPath) {
2813
2972
  current = parent;
2814
2973
  }
2815
2974
  }
2816
- async function readIdentity(stat, path4) {
2975
+ async function readIdentity(stat, path5) {
2817
2976
  try {
2818
- const { dev, ino } = await stat(path4);
2977
+ const { dev, ino } = await stat(path5);
2819
2978
  return { dev, ino };
2820
2979
  } catch (error) {
2821
2980
  if (MISSING_PATH_CODES.includes(getOwnErrorCode(error) ?? "")) {
@@ -3088,32 +3247,32 @@ async function resolvePathArguments(fs2, root, name, args) {
3088
3247
  return resolved;
3089
3248
  }
3090
3249
  const paths = FS_PATH_ARGUMENTS[name].map((_, index) => {
3091
- const path4 = readPath(canonicalRoot, args[index]);
3092
- resolved[index] = path4;
3093
- return path4;
3250
+ const path5 = readPath(canonicalRoot, args[index]);
3251
+ resolved[index] = path5;
3252
+ return path5;
3094
3253
  });
3095
3254
  await assertInsideRoot(fs2, canonicalRoot, name, paths);
3096
3255
  return resolved;
3097
3256
  }
3098
3257
  async function assertInsideRoot(fs2, canonicalRoot, name, paths) {
3099
- for (const path4 of paths) {
3100
- if (await escapesRoot(fs2, canonicalRoot, path4)) {
3258
+ for (const path5 of paths) {
3259
+ if (await escapesRoot(fs2, canonicalRoot, path5)) {
3101
3260
  throw createAccessDeniedError(name, paths[0], paths[1]);
3102
3261
  }
3103
3262
  }
3104
3263
  }
3105
- async function escapesRoot(fs2, canonicalRoot, path4) {
3106
- const canonicalPath = await resolveCanonicalPath(readCanonicalPathFs(fs2), path4);
3264
+ async function escapesRoot(fs2, canonicalRoot, path5) {
3265
+ const canonicalPath = await resolveCanonicalPath(readCanonicalPathFs(fs2), path5);
3107
3266
  return !await containsPath(readStat(fs2), canonicalRoot, canonicalPath);
3108
3267
  }
3109
3268
  function readCanonicalPathFs(fs2) {
3110
3269
  return {
3111
- realpath: async (path4) => await invoke(fs2, "realpath", [path4]),
3112
- readlink: async (path4) => await invoke(fs2, "readlink", [path4])
3270
+ realpath: async (path5) => await invoke(fs2, "realpath", [path5]),
3271
+ readlink: async (path5) => await invoke(fs2, "readlink", [path5])
3113
3272
  };
3114
3273
  }
3115
3274
  function readStat(fs2) {
3116
- return async (path4) => await invoke(fs2, "stat", [path4]);
3275
+ return async (path5) => await invoke(fs2, "stat", [path5]);
3117
3276
  }
3118
3277
  function assertSupportedPath(name, argument, value) {
3119
3278
  if (typeof value === "string") {
@@ -3164,19 +3323,19 @@ function describeReceivedValue(value) {
3164
3323
  return `type ${typeof value} (${inspect(value)})`;
3165
3324
  }
3166
3325
  function readPath(base, value) {
3167
- const path4 = value;
3168
- return isAbsolute2(path4) ? resolve2(path4) : resolve2(base, path4);
3326
+ const path5 = value;
3327
+ return isAbsolute2(path5) ? resolve2(path5) : resolve2(base, path5);
3169
3328
  }
3170
- function createAccessDeniedError(name, path4, dest) {
3329
+ function createAccessDeniedError(name, path5, dest) {
3171
3330
  const syscall = FS_SYSCALLS[name];
3172
- const target = dest === void 0 ? `'${path4}'` : `'${path4}' -> '${dest}'`;
3331
+ const target = dest === void 0 ? `'${path5}'` : `'${path5}' -> '${dest}'`;
3173
3332
  const error = new Error(
3174
3333
  `${ACCESS_DENIED_CODE}: ${ACCESS_DENIED_MESSAGE}, ${syscall} ${target}`
3175
3334
  );
3176
3335
  error.code = ACCESS_DENIED_CODE;
3177
3336
  error.errno = ACCESS_DENIED_ERRNO;
3178
3337
  error.syscall = syscall;
3179
- error.path = path4;
3338
+ error.path = path5;
3180
3339
  if (dest !== void 0) {
3181
3340
  error.dest = dest;
3182
3341
  }
@@ -3521,7 +3680,7 @@ function readNonEmptyString4(value, label) {
3521
3680
 
3522
3681
  // packages/safejs/src/modules/mcp-transport.ts
3523
3682
  import { spawn as spawn3 } from "node:child_process";
3524
- import path3 from "node:path";
3683
+ import path4 from "node:path";
3525
3684
 
3526
3685
  // packages/tiny-mcp-client/src/internal.ts
3527
3686
  import { spawn as spawn2 } from "node:child_process";
@@ -3529,13 +3688,13 @@ import { PassThrough } from "node:stream";
3529
3688
 
3530
3689
  // packages/mcp-oauth/src/client/auth-store-session-store.ts
3531
3690
  import crypto from "node:crypto";
3532
- import path2 from "node:path";
3691
+ import path3 from "node:path";
3533
3692
 
3534
3693
  // packages/auth-store/src/encrypted-file-store.ts
3535
- import { createCipheriv, createDecipheriv, randomBytes, randomUUID, scrypt } from "node:crypto";
3694
+ import { createCipheriv, createDecipheriv, randomBytes, randomUUID as randomUUID2, scrypt } from "node:crypto";
3536
3695
  import { promises as fs } from "node:fs";
3537
3696
  import { homedir, hostname, userInfo } from "node:os";
3538
- import path from "node:path";
3697
+ import path2 from "node:path";
3539
3698
 
3540
3699
  // packages/auth-store/src/error-codes.ts
3541
3700
  function hasOwnErrorCode2(error, code) {
@@ -3567,7 +3726,7 @@ var EncryptedFileStore = class {
3567
3726
  const defaultFileName = input.defaultFileName ?? "credentials.enc";
3568
3727
  assertSafeDefaultDirectory(defaultDirectory);
3569
3728
  assertSafeDefaultFileName(defaultFileName);
3570
- this.filePath = path.join(
3729
+ this.filePath = path2.join(
3571
3730
  homeDirectory,
3572
3731
  defaultDirectory,
3573
3732
  defaultFileName
@@ -3630,9 +3789,9 @@ var EncryptedFileStore = class {
3630
3789
  authTag: authTag.toString("base64"),
3631
3790
  ciphertext: ciphertext.toString("base64")
3632
3791
  };
3633
- await this.fs.mkdir(path.dirname(this.filePath), { recursive: true });
3792
+ await this.fs.mkdir(path2.dirname(this.filePath), { recursive: true });
3634
3793
  await this.assertCredentialPathHasNoSymbolicLinks(this.filePath);
3635
- const temporaryPath = `${this.filePath}.${process.pid}.${randomUUID()}.tmp`;
3794
+ const temporaryPath = `${this.filePath}.${process.pid}.${randomUUID2()}.tmp`;
3636
3795
  let temporaryCreated = false;
3637
3796
  try {
3638
3797
  await this.assertCredentialPathHasNoSymbolicLinks(temporaryPath);
@@ -3662,7 +3821,7 @@ var EncryptedFileStore = class {
3662
3821
  }
3663
3822
  }
3664
3823
  async assertCredentialPathHasNoSymbolicLinks(targetPath) {
3665
- const resolvedPath = path.resolve(targetPath);
3824
+ const resolvedPath = path2.resolve(targetPath);
3666
3825
  const protectedPaths = getProtectedCredentialPaths(
3667
3826
  resolvedPath,
3668
3827
  this.symbolicLinkCheckStartPath
@@ -3696,26 +3855,26 @@ var EncryptedFileStore = class {
3696
3855
  };
3697
3856
  function resolveDefaultDirectoryCheckStart(homeDirectory, defaultDirectory) {
3698
3857
  const [firstSegment] = defaultDirectory.split(/[\\/]+/).filter(Boolean);
3699
- return path.resolve(homeDirectory, firstSegment ?? ".");
3858
+ return path2.resolve(homeDirectory, firstSegment ?? ".");
3700
3859
  }
3701
3860
  function getProtectedCredentialPaths(resolvedPath, symbolicLinkCheckStartPath) {
3702
3861
  if (symbolicLinkCheckStartPath === null) {
3703
3862
  return getExplicitProtectedCredentialPaths(resolvedPath);
3704
3863
  }
3705
- const resolvedStartPath = path.resolve(symbolicLinkCheckStartPath);
3864
+ const resolvedStartPath = path2.resolve(symbolicLinkCheckStartPath);
3706
3865
  if (!isPathInsideOrEqual(resolvedPath, resolvedStartPath)) {
3707
- return [path.dirname(resolvedPath), resolvedPath];
3866
+ return [path2.dirname(resolvedPath), resolvedPath];
3708
3867
  }
3709
3868
  const protectedPaths = [resolvedStartPath];
3710
3869
  let currentPath = resolvedStartPath;
3711
- for (const segment of path.relative(resolvedStartPath, resolvedPath).split(path.sep).filter(Boolean)) {
3712
- currentPath = path.join(currentPath, segment);
3870
+ for (const segment of path2.relative(resolvedStartPath, resolvedPath).split(path2.sep).filter(Boolean)) {
3871
+ currentPath = path2.join(currentPath, segment);
3713
3872
  protectedPaths.push(currentPath);
3714
3873
  }
3715
3874
  return protectedPaths;
3716
3875
  }
3717
3876
  function assertSafeDefaultDirectory(defaultDirectory) {
3718
- if (path.isAbsolute(defaultDirectory) || path.win32.isAbsolute(defaultDirectory)) {
3877
+ if (path2.isAbsolute(defaultDirectory) || path2.win32.isAbsolute(defaultDirectory)) {
3719
3878
  throw new Error("defaultDirectory must be a relative path inside the home directory");
3720
3879
  }
3721
3880
  for (const segment of splitPathSegments(defaultDirectory)) {
@@ -3733,15 +3892,15 @@ function splitPathSegments(value) {
3733
3892
  return value.split("/").flatMap((segment) => segment.split("\\")).filter((segment) => segment.length > 0);
3734
3893
  }
3735
3894
  function getExplicitProtectedCredentialPaths(resolvedPath) {
3736
- const parsed = path.parse(resolvedPath);
3737
- const segments = resolvedPath.slice(parsed.root.length).split(path.sep).filter((segment) => segment.length > 0);
3895
+ const parsed = path2.parse(resolvedPath);
3896
+ const segments = resolvedPath.slice(parsed.root.length).split(path2.sep).filter((segment) => segment.length > 0);
3738
3897
  if (segments.length <= 1) {
3739
3898
  return [resolvedPath];
3740
3899
  }
3741
3900
  const protectedPaths = [];
3742
3901
  let currentPath = parsed.root;
3743
3902
  for (const [index, segment] of segments.entries()) {
3744
- currentPath = path.join(currentPath, segment);
3903
+ currentPath = path2.join(currentPath, segment);
3745
3904
  if (index === 0) {
3746
3905
  continue;
3747
3906
  }
@@ -3750,8 +3909,8 @@ function getExplicitProtectedCredentialPaths(resolvedPath) {
3750
3909
  return protectedPaths;
3751
3910
  }
3752
3911
  function isPathInsideOrEqual(childPath, parentPath) {
3753
- const relativePath = path.relative(parentPath, childPath);
3754
- return relativePath === "" || !relativePath.startsWith("..") && !path.isAbsolute(relativePath);
3912
+ const relativePath = path2.relative(parentPath, childPath);
3913
+ return relativePath === "" || !relativePath.startsWith("..") && !path2.isAbsolute(relativePath);
3755
3914
  }
3756
3915
  async function removeIfPresent(fileSystem, filePath) {
3757
3916
  try {
@@ -4113,10 +4272,10 @@ function createAuthStoreClientStore(options) {
4113
4272
  function createNamedSecretStore(key2, options, defaults) {
4114
4273
  const hash = crypto.createHash("sha256").update(key2).digest("hex");
4115
4274
  const configuredFilePath = options.fileStore?.filePath;
4116
- const parsedFilePath = configuredFilePath === void 0 ? null : path2.parse(configuredFilePath);
4275
+ const parsedFilePath = configuredFilePath === void 0 ? null : path3.parse(configuredFilePath);
4117
4276
  const fileStore = {
4118
4277
  ...options.fileStore,
4119
- filePath: parsedFilePath === null ? void 0 : path2.join(
4278
+ filePath: parsedFilePath === null ? void 0 : path3.join(
4120
4279
  parsedFilePath.dir,
4121
4280
  `${parsedFilePath.name}-${hash}${parsedFilePath.ext || ".enc"}`
4122
4281
  ),
@@ -7240,9 +7399,9 @@ function parseMcpConfig(source, directory) {
7240
7399
  ]);
7241
7400
  for (const server of Object.values(options.servers)) {
7242
7401
  if ("command" in server) {
7243
- server.cwd = path3.resolve(directory, server.cwd ?? ".");
7402
+ server.cwd = path4.resolve(directory, server.cwd ?? ".");
7244
7403
  if (server.command.includes("/") || server.command.includes("\\")) {
7245
- server.command = path3.resolve(directory, server.command);
7404
+ server.command = path4.resolve(directory, server.command);
7246
7405
  }
7247
7406
  }
7248
7407
  }
@@ -7858,6 +8017,9 @@ function isPlainObjectRecord(value) {
7858
8017
  }
7859
8018
 
7860
8019
  export {
8020
+ inspectSnapshotMigration,
8021
+ migrateSnapshot,
8022
+ migrateSnapshotFile,
7861
8023
  formatInterpreterError,
7862
8024
  SPAWN_MODES,
7863
8025
  supportsSpawnMode,
@@ -7886,4 +8048,4 @@ export {
7886
8048
  parseMcpConfig,
7887
8049
  makeMcpModule
7888
8050
  };
7889
- //# sourceMappingURL=chunk-MRH5YDMR.js.map
8051
+ //# sourceMappingURL=chunk-ARFGEQTM.js.map