@molecule/api-code-sandbox-e2b 1.0.2 → 1.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/provider.d.ts.map +1 -1
- package/dist/provider.js +40 -8
- package/package.json +1 -1
package/dist/provider.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"provider.d.ts","sourceRoot":"","sources":["../src/provider.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,KAAK,EAEV,aAAa,EAKb,OAAO,EACP,aAAa,EACb,eAAe,EAChB,MAAM,4BAA4B,CAAA;AAEnC,OAAO,KAAK,EAAE,SAAS,EAAE,oBAAoB,EAAkB,MAAM,YAAY,CAAA;
|
|
1
|
+
{"version":3,"file":"provider.d.ts","sourceRoot":"","sources":["../src/provider.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,KAAK,EAEV,aAAa,EAKb,OAAO,EACP,aAAa,EACb,eAAe,EAChB,MAAM,4BAA4B,CAAA;AAEnC,OAAO,KAAK,EAAE,SAAS,EAAE,oBAAoB,EAAkB,MAAM,YAAY,CAAA;AAqYjF;;;;;;;;;GASG;AACH,qBAAa,kBAAmB,YAAW,eAAe;IACxD,QAAQ,CAAC,IAAI,SAAQ;IAErB,OAAO,CAAC,QAAQ,CAAC,MAAM,CAA0D;IACjF,OAAO,CAAC,aAAa,CAA6C;IAClE,OAAO,CAAC,QAAQ,CAAC,cAAc,CAAC,CAAsB;IAEtD;;;;;OAKG;gBACS,MAAM,GAAE,SAAc,EAAE,cAAc,CAAC,EAAE,oBAAoB;IAYzE;;;;OAIG;YACW,MAAM;IASpB;;;;;OAKG;IACG,MAAM,CAAC,MAAM,EAAE,aAAa,GAAG,OAAO,CAAC,OAAO,CAAC;IAmBrD;;;;;OAKG;IACG,GAAG,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,GAAG,IAAI,CAAC;IAgB9C;;;;;OAKG;IACG,IAAI,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,EAAE,CAAC;IAY/C;;;;OAIG;IACG,OAAO,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAcxC;;;;;;;;;;;OAWG;IACG,YAAY,IAAI,OAAO,CAAC,aAAa,CAAC;CAyD7C;AAED;;;;;;GAMG;AACH,wBAAgB,cAAc,CAC5B,MAAM,GAAE,SAAc,EACtB,cAAc,CAAC,EAAE,oBAAoB,GACpC,kBAAkB,CAEpB;AAED,kEAAkE;AAClE,eAAO,MAAM,QAAQ,EAAE,eAAkC,CAAA"}
|
package/dist/provider.js
CHANGED
|
@@ -236,14 +236,46 @@ class E2BSandbox {
|
|
|
236
236
|
* @returns The directory entries.
|
|
237
237
|
*/
|
|
238
238
|
async readDir(path) {
|
|
239
|
-
//
|
|
240
|
-
//
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
}
|
|
239
|
+
// Use `ls -la`, NOT the SDK's `files.list`: files.list reports only
|
|
240
|
+
// name/type/size and cannot distinguish a symlink from its target, so a
|
|
241
|
+
// symlink like `.claude -> .agents` came back as a plain directory and showed
|
|
242
|
+
// up in the file tree as a second, fully-expandable copy of its target. Parsing
|
|
243
|
+
// `ls -la` (same approach as the docker bond) lets us set `symlinkTarget` so the
|
|
244
|
+
// UI can render it AS a symlink. A trailing slash makes ls resolve a directory
|
|
245
|
+
// symlink passed as `path` itself (e.g. /workspace).
|
|
246
|
+
const dirPath = path.endsWith('/') ? path : `${path}/`;
|
|
247
|
+
const result = await this.exec(`ls -la --time-style=+%s '${dirPath.replace(/'/g, `'\\''`)}'`);
|
|
248
|
+
// Contract: a missing directory THROWS (an empty array means "exists and
|
|
249
|
+
// empty"). ls exits non-zero on a missing path.
|
|
250
|
+
if (result.exitCode !== 0) {
|
|
251
|
+
throw new Error(`Failed to list ${path}: ${result.stderr || `exit ${result.exitCode}`}`);
|
|
252
|
+
}
|
|
253
|
+
return result.stdout
|
|
254
|
+
.trim()
|
|
255
|
+
.split('\n')
|
|
256
|
+
.filter(Boolean)
|
|
257
|
+
.filter((line) => !/^total\s/.test(line)) // ls's summary header
|
|
258
|
+
.map((line) => {
|
|
259
|
+
const parts = line.split(/\s+/);
|
|
260
|
+
// With --time-style=+%s the columns are: perms links owner group size
|
|
261
|
+
// <epoch> name…, so the name begins at index 6.
|
|
262
|
+
const rawName = parts.slice(6).join(' ');
|
|
263
|
+
const isSymlink = line.startsWith('l');
|
|
264
|
+
// ls renders a symlink as "name -> target".
|
|
265
|
+
const arrowIdx = rawName.indexOf(' -> ');
|
|
266
|
+
const name = isSymlink && arrowIdx !== -1 ? rawName.slice(0, arrowIdx) : rawName;
|
|
267
|
+
if (name === '.' || name === '..' || name === '')
|
|
268
|
+
return null;
|
|
269
|
+
const symlinkTarget = isSymlink && arrowIdx !== -1 ? rawName.slice(arrowIdx + 4) : undefined;
|
|
270
|
+
const size = Number.parseInt(parts[4] ?? '', 10);
|
|
271
|
+
return {
|
|
272
|
+
name,
|
|
273
|
+
type: line.startsWith('d') ? 'directory' : 'file',
|
|
274
|
+
...(Number.isFinite(size) ? { size } : {}),
|
|
275
|
+
...(symlinkTarget ? { symlinkTarget } : {}),
|
|
276
|
+
};
|
|
277
|
+
})
|
|
278
|
+
.filter((e) => e !== null);
|
|
247
279
|
}
|
|
248
280
|
/**
|
|
249
281
|
* Delete a file.
|
package/package.json
CHANGED