@swmansion/argent 0.34.1-next.26 → 0.34.1-next.28
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/cli-cmds.mjs +78 -39
- package/dist/client.js +62 -32
- package/dist/installer.mjs +11 -2
- package/dist/mcp-server.mjs +62 -32
- package/dist/tool-server.cjs +34 -22
- package/package.json +1 -1
package/dist/cli-cmds.mjs
CHANGED
|
@@ -9069,6 +9069,10 @@ function killSpawnedChild(child, pid) {
|
|
|
9069
9069
|
}
|
|
9070
9070
|
}
|
|
9071
9071
|
}
|
|
9072
|
+
function resolveToolsServerNode() {
|
|
9073
|
+
const { bun, deno, electron } = process.versions;
|
|
9074
|
+
return !(bun || deno || electron) && fs.existsSync(process.execPath) ? process.execPath : "node";
|
|
9075
|
+
}
|
|
9072
9076
|
function spawnToolsServer(paths, port, options = {}) {
|
|
9073
9077
|
return new Promise((resolve13, reject) => {
|
|
9074
9078
|
let logFd;
|
|
@@ -9078,8 +9082,7 @@ function spawnToolsServer(paths, port, options = {}) {
|
|
|
9078
9082
|
} catch {
|
|
9079
9083
|
logFd = fs.openSync("/dev/null", "w");
|
|
9080
9084
|
}
|
|
9081
|
-
const
|
|
9082
|
-
const nodeBin = !(bun || deno || electron) && fs.existsSync(process.execPath) ? process.execPath : "node";
|
|
9085
|
+
const nodeBin = resolveToolsServerNode();
|
|
9083
9086
|
const child = spawn(nodeBin, [paths.bundlePath, "start"], {
|
|
9084
9087
|
detached: true,
|
|
9085
9088
|
stdio: ["ignore", "pipe", logFd],
|
|
@@ -30956,7 +30959,7 @@ async function sniffFormat(archivePath) {
|
|
|
30956
30959
|
}
|
|
30957
30960
|
}
|
|
30958
30961
|
var ZSTD_FRAME_MAGIC = 4247762216;
|
|
30959
|
-
async function assertSingleCompleteZstdFrame(archivePath) {
|
|
30962
|
+
async function assertSingleCompleteZstdFrame(archivePath, signal) {
|
|
30960
30963
|
const fh = await open2(archivePath, "r");
|
|
30961
30964
|
try {
|
|
30962
30965
|
const { size } = await fh.stat();
|
|
@@ -30966,6 +30969,7 @@ async function assertSingleCompleteZstdFrame(archivePath) {
|
|
|
30966
30969
|
let pos = 0;
|
|
30967
30970
|
const read = async (n3) => {
|
|
30968
30971
|
if (pos < windowStart || pos + n3 > windowEnd) {
|
|
30972
|
+
signal?.throwIfAborted();
|
|
30969
30973
|
const { bytesRead } = await fh.read(window2, 0, window2.length, pos);
|
|
30970
30974
|
windowStart = pos;
|
|
30971
30975
|
windowEnd = pos + bytesRead;
|
|
@@ -31003,14 +31007,16 @@ function tarEnv(env) {
|
|
|
31003
31007
|
const characterType = env.LC_ALL || env.LC_CTYPE || env.LANG || "";
|
|
31004
31008
|
return /utf-?8/i.test(characterType) ? env : { ...env, LC_ALL: TAR_LOCALE };
|
|
31005
31009
|
}
|
|
31006
|
-
async function runTar(archive, args) {
|
|
31010
|
+
async function runTar(archive, args, signal) {
|
|
31007
31011
|
const child = spawn2("tar", [...args, "-f", "-"], {
|
|
31012
|
+
signal,
|
|
31008
31013
|
env: tarEnv(process.env)
|
|
31009
31014
|
});
|
|
31010
|
-
|
|
31011
|
-
|
|
31012
|
-
|
|
31015
|
+
let childError;
|
|
31016
|
+
child.on("error", (err) => {
|
|
31017
|
+
childError = err;
|
|
31013
31018
|
});
|
|
31019
|
+
const closed = new Promise((resolve13) => child.once("close", resolve13));
|
|
31014
31020
|
const stdout2 = collect(child.stdout, MAX_LISTING_BYTES, {
|
|
31015
31021
|
maxLines: MAX_LISTING_LINES,
|
|
31016
31022
|
onOverflow: () => child.kill()
|
|
@@ -31037,12 +31043,15 @@ async function runTar(archive, args) {
|
|
|
31037
31043
|
if (err) child.stdin?.destroy();
|
|
31038
31044
|
done(err);
|
|
31039
31045
|
}
|
|
31040
|
-
})
|
|
31046
|
+
}),
|
|
31047
|
+
{ signal }
|
|
31041
31048
|
).then(
|
|
31042
31049
|
() => null,
|
|
31043
31050
|
(err) => err
|
|
31044
31051
|
);
|
|
31045
|
-
const [code, feedError] = await Promise.all([
|
|
31052
|
+
const [code, feedError] = await Promise.all([closed, fed]);
|
|
31053
|
+
signal?.throwIfAborted();
|
|
31054
|
+
if (childError) throw childError;
|
|
31046
31055
|
if (stdout2.overflowed()) {
|
|
31047
31056
|
throw new Error(
|
|
31048
31057
|
`tar ${args.join(" ")} listed more than ${MAX_LISTING_LINES} members or ${MAX_LISTING_BYTES >> 20} MiB`
|
|
@@ -31067,21 +31076,22 @@ function isSafeTarMember(memberPath, destDir) {
|
|
|
31067
31076
|
const root = resolve6(destDir);
|
|
31068
31077
|
return resolve6(destDir, normalized).startsWith(root + sep2);
|
|
31069
31078
|
}
|
|
31070
|
-
async function readListing(archive, args) {
|
|
31079
|
+
async function readListing(archive, args, signal) {
|
|
31071
31080
|
try {
|
|
31072
|
-
return await runTar(archive, args);
|
|
31081
|
+
return await runTar(archive, args, signal);
|
|
31073
31082
|
} catch (err) {
|
|
31083
|
+
signal?.throwIfAborted();
|
|
31074
31084
|
throw new ArchiveError(
|
|
31075
31085
|
`Could not read archive: ${err instanceof Error ? err.message : String(err)}`
|
|
31076
31086
|
);
|
|
31077
31087
|
}
|
|
31078
31088
|
}
|
|
31079
|
-
async function listTarMembers(archive) {
|
|
31080
|
-
const stdout2 = await readListing(archive, ["-t"]);
|
|
31089
|
+
async function listTarMembers(archive, signal) {
|
|
31090
|
+
const stdout2 = await readListing(archive, ["-t"], signal);
|
|
31081
31091
|
return stdout2.split("\n").map((line) => line.trim()).filter((line) => line.length > 0);
|
|
31082
31092
|
}
|
|
31083
|
-
async function assertSafeMemberTypes(archive) {
|
|
31084
|
-
const stdout2 = await readListing(archive, ["-tv"]);
|
|
31093
|
+
async function assertSafeMemberTypes(archive, signal) {
|
|
31094
|
+
const stdout2 = await readListing(archive, ["-tv"], signal);
|
|
31085
31095
|
for (const line of stdout2.split("\n")) {
|
|
31086
31096
|
if (!line.trim()) continue;
|
|
31087
31097
|
const type = line[0];
|
|
@@ -31101,8 +31111,8 @@ async function assertSafeMemberTypes(archive) {
|
|
|
31101
31111
|
);
|
|
31102
31112
|
}
|
|
31103
31113
|
}
|
|
31104
|
-
async function assertSafeArchive(archive, destDir) {
|
|
31105
|
-
const members2 = await listTarMembers(archive);
|
|
31114
|
+
async function assertSafeArchive(archive, destDir, signal) {
|
|
31115
|
+
const members2 = await listTarMembers(archive, signal);
|
|
31106
31116
|
if (members2.length === 0) {
|
|
31107
31117
|
throw new ArchiveError("Archive is empty.");
|
|
31108
31118
|
}
|
|
@@ -31111,7 +31121,7 @@ async function assertSafeArchive(archive, destDir) {
|
|
|
31111
31121
|
throw new ArchiveError(`Archive contains an unsafe path "${member}" \u2014 refusing extraction.`);
|
|
31112
31122
|
}
|
|
31113
31123
|
}
|
|
31114
|
-
await assertSafeMemberTypes(archive);
|
|
31124
|
+
await assertSafeMemberTypes(archive, signal);
|
|
31115
31125
|
}
|
|
31116
31126
|
async function resolveMember(destDir, expectedName) {
|
|
31117
31127
|
const entries = await readdir3(destDir);
|
|
@@ -31126,19 +31136,24 @@ async function resolveMember(destDir, expectedName) {
|
|
|
31126
31136
|
}
|
|
31127
31137
|
return join9(destDir, real[0]);
|
|
31128
31138
|
}
|
|
31129
|
-
async function safeExtractArchive(archivePath, destDir, expectedName) {
|
|
31139
|
+
async function safeExtractArchive(archivePath, destDir, expectedName, signal) {
|
|
31140
|
+
signal?.throwIfAborted();
|
|
31130
31141
|
let archive;
|
|
31131
31142
|
try {
|
|
31132
31143
|
archive = { path: archivePath, format: await sniffFormat(archivePath) };
|
|
31133
|
-
if (archive.format === "zstd") await assertSingleCompleteZstdFrame(archivePath);
|
|
31144
|
+
if (archive.format === "zstd") await assertSingleCompleteZstdFrame(archivePath, signal);
|
|
31134
31145
|
} catch (err) {
|
|
31146
|
+
signal?.throwIfAborted();
|
|
31135
31147
|
throw new ArchiveError(
|
|
31136
31148
|
`Could not read archive: ${err instanceof Error ? err.message : String(err)}`
|
|
31137
31149
|
);
|
|
31138
31150
|
}
|
|
31139
|
-
await assertSafeArchive(archive, destDir);
|
|
31140
|
-
|
|
31141
|
-
|
|
31151
|
+
await assertSafeArchive(archive, destDir, signal);
|
|
31152
|
+
signal?.throwIfAborted();
|
|
31153
|
+
await runTar(archive, ["-x", "-C", destDir], signal);
|
|
31154
|
+
const member = await resolveMember(destDir, expectedName);
|
|
31155
|
+
signal?.throwIfAborted();
|
|
31156
|
+
return member;
|
|
31142
31157
|
}
|
|
31143
31158
|
|
|
31144
31159
|
// ../argent-tools-client/src/errors.ts
|
|
@@ -32324,7 +32339,16 @@ function createToolsClient(options = {}) {
|
|
|
32324
32339
|
}
|
|
32325
32340
|
|
|
32326
32341
|
// ../argent-tools-client/src/artifacts.ts
|
|
32327
|
-
import {
|
|
32342
|
+
import {
|
|
32343
|
+
copyFile,
|
|
32344
|
+
mkdir as mkdir4,
|
|
32345
|
+
mkdtemp,
|
|
32346
|
+
readFile as readFile6,
|
|
32347
|
+
realpath as realpath4,
|
|
32348
|
+
rm as rm3,
|
|
32349
|
+
stat as stat5,
|
|
32350
|
+
writeFile as writeFile4
|
|
32351
|
+
} from "node:fs/promises";
|
|
32328
32352
|
import { constants as fsConstants } from "node:fs";
|
|
32329
32353
|
import { tmpdir as tmpdir2 } from "node:os";
|
|
32330
32354
|
import { basename as basename7, dirname as dirname9, extname as extname2, isAbsolute as isAbsolute6, join as join13, normalize as normalize2, resolve as resolve8, sep as sep4 } from "node:path";
|
|
@@ -32468,16 +32492,22 @@ async function resolveLocalFile(handle) {
|
|
|
32468
32492
|
return null;
|
|
32469
32493
|
}
|
|
32470
32494
|
}
|
|
32471
|
-
async function downloadAndExtractArchive(handle, data, dir) {
|
|
32472
|
-
|
|
32495
|
+
async function downloadAndExtractArchive(handle, data, dir, signal) {
|
|
32496
|
+
signal?.throwIfAborted();
|
|
32497
|
+
const attemptDir = await mkdtemp(join13(dir, "bundle-"));
|
|
32498
|
+
const tarball = join13(attemptDir, "download.tar");
|
|
32499
|
+
const extractDir = join13(attemptDir, "files");
|
|
32473
32500
|
try {
|
|
32474
|
-
await writeFile4(tarball, data);
|
|
32475
|
-
|
|
32501
|
+
await writeFile4(tarball, data, { signal });
|
|
32502
|
+
await mkdir4(extractDir);
|
|
32503
|
+
const member = await safeExtractArchive(tarball, extractDir, handle.filename, signal);
|
|
32504
|
+
await rm3(tarball);
|
|
32505
|
+
signal?.throwIfAborted();
|
|
32506
|
+
return member;
|
|
32476
32507
|
} catch {
|
|
32477
|
-
|
|
32478
|
-
} finally {
|
|
32479
|
-
await rm3(tarball, { force: true }).catch(() => {
|
|
32508
|
+
await rm3(attemptDir, { recursive: true, force: true }).catch(() => {
|
|
32480
32509
|
});
|
|
32510
|
+
return null;
|
|
32481
32511
|
}
|
|
32482
32512
|
}
|
|
32483
32513
|
async function materializeArtifacts(result, ctx) {
|
|
@@ -32563,7 +32593,7 @@ async function materializeArtifacts(result, ctx) {
|
|
|
32563
32593
|
if (!data) return null;
|
|
32564
32594
|
await ensureDir();
|
|
32565
32595
|
if (value.archive === "tar.gz") {
|
|
32566
|
-
return await downloadAndExtractArchive(value, data, dir);
|
|
32596
|
+
return await downloadAndExtractArchive(value, data, dir, ctx.signal);
|
|
32567
32597
|
}
|
|
32568
32598
|
if (value.size > 0 && data.length !== value.size) return null;
|
|
32569
32599
|
const downloadedPath = join13(dir, sanitizeSegment(value.filename));
|
|
@@ -36142,7 +36172,7 @@ function isCi(env = process.env) {
|
|
|
36142
36172
|
var SESSION_ID2 = randomUUID5();
|
|
36143
36173
|
function readCliVersion() {
|
|
36144
36174
|
if (true) {
|
|
36145
|
-
return "0.34.1-next.
|
|
36175
|
+
return "0.34.1-next.28";
|
|
36146
36176
|
}
|
|
36147
36177
|
return "0.0.0";
|
|
36148
36178
|
}
|
|
@@ -39023,10 +39053,20 @@ async function runForeground(paths, port, host, idleTimeoutMinutes, token) {
|
|
|
39023
39053
|
idleTimeoutMinutes,
|
|
39024
39054
|
token
|
|
39025
39055
|
});
|
|
39026
|
-
const
|
|
39027
|
-
|
|
39028
|
-
|
|
39029
|
-
|
|
39056
|
+
const cannotStart = (err) => {
|
|
39057
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
39058
|
+
console.error(`argent server start: failed to spawn tool-server: ${message}`);
|
|
39059
|
+
process.exit(1);
|
|
39060
|
+
};
|
|
39061
|
+
let child;
|
|
39062
|
+
try {
|
|
39063
|
+
child = spawn4(resolveToolsServerNode(), [paths.bundlePath, "start"], {
|
|
39064
|
+
stdio: "inherit",
|
|
39065
|
+
env
|
|
39066
|
+
});
|
|
39067
|
+
} catch (err) {
|
|
39068
|
+
return cannotStart(err);
|
|
39069
|
+
}
|
|
39030
39070
|
const forward = (signal) => () => {
|
|
39031
39071
|
try {
|
|
39032
39072
|
child.kill(signal);
|
|
@@ -39067,8 +39107,7 @@ async function runForeground(paths, port, host, idleTimeoutMinutes, token) {
|
|
|
39067
39107
|
};
|
|
39068
39108
|
child.on("error", (err) => {
|
|
39069
39109
|
cleanup();
|
|
39070
|
-
|
|
39071
|
-
process.exit(1);
|
|
39110
|
+
cannotStart(err);
|
|
39072
39111
|
});
|
|
39073
39112
|
child.on("exit", (code, signal) => {
|
|
39074
39113
|
cleanup();
|
package/dist/client.js
CHANGED
|
@@ -8405,6 +8405,10 @@ function killSpawnedChild(child, pid) {
|
|
|
8405
8405
|
}
|
|
8406
8406
|
}
|
|
8407
8407
|
}
|
|
8408
|
+
function resolveToolsServerNode() {
|
|
8409
|
+
const { bun, deno, electron } = process.versions;
|
|
8410
|
+
return !(bun || deno || electron) && fs4.existsSync(process.execPath) ? process.execPath : "node";
|
|
8411
|
+
}
|
|
8408
8412
|
function spawnToolsServer(paths, port, options = {}) {
|
|
8409
8413
|
return new Promise((resolve9, reject) => {
|
|
8410
8414
|
let logFd;
|
|
@@ -8414,8 +8418,7 @@ function spawnToolsServer(paths, port, options = {}) {
|
|
|
8414
8418
|
} catch {
|
|
8415
8419
|
logFd = fs4.openSync("/dev/null", "w");
|
|
8416
8420
|
}
|
|
8417
|
-
const
|
|
8418
|
-
const nodeBin = !(bun || deno || electron) && fs4.existsSync(process.execPath) ? process.execPath : "node";
|
|
8421
|
+
const nodeBin = resolveToolsServerNode();
|
|
8419
8422
|
const child = spawn(nodeBin, [paths.bundlePath, "start"], {
|
|
8420
8423
|
detached: true,
|
|
8421
8424
|
stdio: ["ignore", "pipe", logFd],
|
|
@@ -9696,7 +9699,7 @@ async function sniffFormat(archivePath) {
|
|
|
9696
9699
|
}
|
|
9697
9700
|
}
|
|
9698
9701
|
var ZSTD_FRAME_MAGIC = 4247762216;
|
|
9699
|
-
async function assertSingleCompleteZstdFrame(archivePath) {
|
|
9702
|
+
async function assertSingleCompleteZstdFrame(archivePath, signal) {
|
|
9700
9703
|
const fh = await open(archivePath, "r");
|
|
9701
9704
|
try {
|
|
9702
9705
|
const { size } = await fh.stat();
|
|
@@ -9706,6 +9709,7 @@ async function assertSingleCompleteZstdFrame(archivePath) {
|
|
|
9706
9709
|
let pos = 0;
|
|
9707
9710
|
const read = async (n) => {
|
|
9708
9711
|
if (pos < windowStart || pos + n > windowEnd) {
|
|
9712
|
+
signal?.throwIfAborted();
|
|
9709
9713
|
const { bytesRead } = await fh.read(window, 0, window.length, pos);
|
|
9710
9714
|
windowStart = pos;
|
|
9711
9715
|
windowEnd = pos + bytesRead;
|
|
@@ -9743,14 +9747,16 @@ function tarEnv(env) {
|
|
|
9743
9747
|
const characterType = env.LC_ALL || env.LC_CTYPE || env.LANG || "";
|
|
9744
9748
|
return /utf-?8/i.test(characterType) ? env : { ...env, LC_ALL: TAR_LOCALE };
|
|
9745
9749
|
}
|
|
9746
|
-
async function runTar(archive, args) {
|
|
9750
|
+
async function runTar(archive, args, signal) {
|
|
9747
9751
|
const child = spawn2("tar", [...args, "-f", "-"], {
|
|
9752
|
+
signal,
|
|
9748
9753
|
env: tarEnv(process.env)
|
|
9749
9754
|
});
|
|
9750
|
-
|
|
9751
|
-
|
|
9752
|
-
|
|
9755
|
+
let childError;
|
|
9756
|
+
child.on("error", (err) => {
|
|
9757
|
+
childError = err;
|
|
9753
9758
|
});
|
|
9759
|
+
const closed = new Promise((resolve9) => child.once("close", resolve9));
|
|
9754
9760
|
const stdout = collect(child.stdout, MAX_LISTING_BYTES, {
|
|
9755
9761
|
maxLines: MAX_LISTING_LINES,
|
|
9756
9762
|
onOverflow: () => child.kill()
|
|
@@ -9777,12 +9783,15 @@ async function runTar(archive, args) {
|
|
|
9777
9783
|
if (err) child.stdin?.destroy();
|
|
9778
9784
|
done(err);
|
|
9779
9785
|
}
|
|
9780
|
-
})
|
|
9786
|
+
}),
|
|
9787
|
+
{ signal }
|
|
9781
9788
|
).then(
|
|
9782
9789
|
() => null,
|
|
9783
9790
|
(err) => err
|
|
9784
9791
|
);
|
|
9785
|
-
const [code, feedError] = await Promise.all([
|
|
9792
|
+
const [code, feedError] = await Promise.all([closed, fed]);
|
|
9793
|
+
signal?.throwIfAborted();
|
|
9794
|
+
if (childError) throw childError;
|
|
9786
9795
|
if (stdout.overflowed()) {
|
|
9787
9796
|
throw new Error(
|
|
9788
9797
|
`tar ${args.join(" ")} listed more than ${MAX_LISTING_LINES} members or ${MAX_LISTING_BYTES >> 20} MiB`
|
|
@@ -9807,21 +9816,22 @@ function isSafeTarMember(memberPath, destDir) {
|
|
|
9807
9816
|
const root = resolve6(destDir);
|
|
9808
9817
|
return resolve6(destDir, normalized).startsWith(root + sep2);
|
|
9809
9818
|
}
|
|
9810
|
-
async function readListing(archive, args) {
|
|
9819
|
+
async function readListing(archive, args, signal) {
|
|
9811
9820
|
try {
|
|
9812
|
-
return await runTar(archive, args);
|
|
9821
|
+
return await runTar(archive, args, signal);
|
|
9813
9822
|
} catch (err) {
|
|
9823
|
+
signal?.throwIfAborted();
|
|
9814
9824
|
throw new ArchiveError(
|
|
9815
9825
|
`Could not read archive: ${err instanceof Error ? err.message : String(err)}`
|
|
9816
9826
|
);
|
|
9817
9827
|
}
|
|
9818
9828
|
}
|
|
9819
|
-
async function listTarMembers(archive) {
|
|
9820
|
-
const stdout = await readListing(archive, ["-t"]);
|
|
9829
|
+
async function listTarMembers(archive, signal) {
|
|
9830
|
+
const stdout = await readListing(archive, ["-t"], signal);
|
|
9821
9831
|
return stdout.split("\n").map((line) => line.trim()).filter((line) => line.length > 0);
|
|
9822
9832
|
}
|
|
9823
|
-
async function assertSafeMemberTypes(archive) {
|
|
9824
|
-
const stdout = await readListing(archive, ["-tv"]);
|
|
9833
|
+
async function assertSafeMemberTypes(archive, signal) {
|
|
9834
|
+
const stdout = await readListing(archive, ["-tv"], signal);
|
|
9825
9835
|
for (const line of stdout.split("\n")) {
|
|
9826
9836
|
if (!line.trim()) continue;
|
|
9827
9837
|
const type = line[0];
|
|
@@ -9841,8 +9851,8 @@ async function assertSafeMemberTypes(archive) {
|
|
|
9841
9851
|
);
|
|
9842
9852
|
}
|
|
9843
9853
|
}
|
|
9844
|
-
async function assertSafeArchive(archive, destDir) {
|
|
9845
|
-
const members = await listTarMembers(archive);
|
|
9854
|
+
async function assertSafeArchive(archive, destDir, signal) {
|
|
9855
|
+
const members = await listTarMembers(archive, signal);
|
|
9846
9856
|
if (members.length === 0) {
|
|
9847
9857
|
throw new ArchiveError("Archive is empty.");
|
|
9848
9858
|
}
|
|
@@ -9851,7 +9861,7 @@ async function assertSafeArchive(archive, destDir) {
|
|
|
9851
9861
|
throw new ArchiveError(`Archive contains an unsafe path "${member}" \u2014 refusing extraction.`);
|
|
9852
9862
|
}
|
|
9853
9863
|
}
|
|
9854
|
-
await assertSafeMemberTypes(archive);
|
|
9864
|
+
await assertSafeMemberTypes(archive, signal);
|
|
9855
9865
|
}
|
|
9856
9866
|
async function resolveMember(destDir, expectedName) {
|
|
9857
9867
|
const entries = await readdir3(destDir);
|
|
@@ -9866,19 +9876,24 @@ async function resolveMember(destDir, expectedName) {
|
|
|
9866
9876
|
}
|
|
9867
9877
|
return join9(destDir, real[0]);
|
|
9868
9878
|
}
|
|
9869
|
-
async function safeExtractArchive(archivePath, destDir, expectedName) {
|
|
9879
|
+
async function safeExtractArchive(archivePath, destDir, expectedName, signal) {
|
|
9880
|
+
signal?.throwIfAborted();
|
|
9870
9881
|
let archive;
|
|
9871
9882
|
try {
|
|
9872
9883
|
archive = { path: archivePath, format: await sniffFormat(archivePath) };
|
|
9873
|
-
if (archive.format === "zstd") await assertSingleCompleteZstdFrame(archivePath);
|
|
9884
|
+
if (archive.format === "zstd") await assertSingleCompleteZstdFrame(archivePath, signal);
|
|
9874
9885
|
} catch (err) {
|
|
9886
|
+
signal?.throwIfAborted();
|
|
9875
9887
|
throw new ArchiveError(
|
|
9876
9888
|
`Could not read archive: ${err instanceof Error ? err.message : String(err)}`
|
|
9877
9889
|
);
|
|
9878
9890
|
}
|
|
9879
|
-
await assertSafeArchive(archive, destDir);
|
|
9880
|
-
|
|
9881
|
-
|
|
9891
|
+
await assertSafeArchive(archive, destDir, signal);
|
|
9892
|
+
signal?.throwIfAborted();
|
|
9893
|
+
await runTar(archive, ["-x", "-C", destDir], signal);
|
|
9894
|
+
const member = await resolveMember(destDir, expectedName);
|
|
9895
|
+
signal?.throwIfAborted();
|
|
9896
|
+
return member;
|
|
9882
9897
|
}
|
|
9883
9898
|
|
|
9884
9899
|
// ../argent-tools-client/src/errors.ts
|
|
@@ -11064,7 +11079,16 @@ function createToolsClient(options = {}) {
|
|
|
11064
11079
|
}
|
|
11065
11080
|
|
|
11066
11081
|
// ../argent-tools-client/src/artifacts.ts
|
|
11067
|
-
import {
|
|
11082
|
+
import {
|
|
11083
|
+
copyFile,
|
|
11084
|
+
mkdir as mkdir4,
|
|
11085
|
+
mkdtemp,
|
|
11086
|
+
readFile as readFile6,
|
|
11087
|
+
realpath as realpath4,
|
|
11088
|
+
rm as rm3,
|
|
11089
|
+
stat as stat5,
|
|
11090
|
+
writeFile as writeFile4
|
|
11091
|
+
} from "node:fs/promises";
|
|
11068
11092
|
import { constants as fsConstants } from "node:fs";
|
|
11069
11093
|
import { tmpdir as tmpdir2 } from "node:os";
|
|
11070
11094
|
import { basename as basename7, dirname as dirname9, extname as extname2, isAbsolute as isAbsolute6, join as join13, normalize as normalize2, resolve as resolve8, sep as sep4 } from "node:path";
|
|
@@ -11208,16 +11232,22 @@ async function resolveLocalFile(handle) {
|
|
|
11208
11232
|
return null;
|
|
11209
11233
|
}
|
|
11210
11234
|
}
|
|
11211
|
-
async function downloadAndExtractArchive(handle, data, dir) {
|
|
11212
|
-
|
|
11235
|
+
async function downloadAndExtractArchive(handle, data, dir, signal) {
|
|
11236
|
+
signal?.throwIfAborted();
|
|
11237
|
+
const attemptDir = await mkdtemp(join13(dir, "bundle-"));
|
|
11238
|
+
const tarball = join13(attemptDir, "download.tar");
|
|
11239
|
+
const extractDir = join13(attemptDir, "files");
|
|
11213
11240
|
try {
|
|
11214
|
-
await writeFile4(tarball, data);
|
|
11215
|
-
|
|
11241
|
+
await writeFile4(tarball, data, { signal });
|
|
11242
|
+
await mkdir4(extractDir);
|
|
11243
|
+
const member = await safeExtractArchive(tarball, extractDir, handle.filename, signal);
|
|
11244
|
+
await rm3(tarball);
|
|
11245
|
+
signal?.throwIfAborted();
|
|
11246
|
+
return member;
|
|
11216
11247
|
} catch {
|
|
11217
|
-
|
|
11218
|
-
} finally {
|
|
11219
|
-
await rm3(tarball, { force: true }).catch(() => {
|
|
11248
|
+
await rm3(attemptDir, { recursive: true, force: true }).catch(() => {
|
|
11220
11249
|
});
|
|
11250
|
+
return null;
|
|
11221
11251
|
}
|
|
11222
11252
|
}
|
|
11223
11253
|
async function materializeArtifacts(result, ctx) {
|
|
@@ -11303,7 +11333,7 @@ async function materializeArtifacts(result, ctx) {
|
|
|
11303
11333
|
if (!data) return null;
|
|
11304
11334
|
await ensureDir();
|
|
11305
11335
|
if (value.archive === "tar.gz") {
|
|
11306
|
-
return await downloadAndExtractArchive(value, data, dir);
|
|
11336
|
+
return await downloadAndExtractArchive(value, data, dir, ctx.signal);
|
|
11307
11337
|
}
|
|
11308
11338
|
if (value.size > 0 && data.length !== value.size) return null;
|
|
11309
11339
|
const downloadedPath = join13(dir, sanitizeSegment(value.filename));
|
package/dist/installer.mjs
CHANGED
|
@@ -16925,7 +16925,7 @@ function isCi(env = process.env) {
|
|
|
16925
16925
|
var SESSION_ID = randomUUID4();
|
|
16926
16926
|
function readCliVersion() {
|
|
16927
16927
|
if (true) {
|
|
16928
|
-
return "0.34.1-next.
|
|
16928
|
+
return "0.34.1-next.28";
|
|
16929
16929
|
}
|
|
16930
16930
|
return "0.0.0";
|
|
16931
16931
|
}
|
|
@@ -24301,7 +24301,16 @@ import * as path26 from "node:path";
|
|
|
24301
24301
|
var INLINE_MEMBERS_BYTES = 256 * 1024;
|
|
24302
24302
|
|
|
24303
24303
|
// ../argent-tools-client/src/artifacts.ts
|
|
24304
|
-
import {
|
|
24304
|
+
import {
|
|
24305
|
+
copyFile,
|
|
24306
|
+
mkdir as mkdir4,
|
|
24307
|
+
mkdtemp,
|
|
24308
|
+
readFile as readFile6,
|
|
24309
|
+
realpath as realpath4,
|
|
24310
|
+
rm as rm3,
|
|
24311
|
+
stat as stat5,
|
|
24312
|
+
writeFile as writeFile4
|
|
24313
|
+
} from "node:fs/promises";
|
|
24305
24314
|
import { constants as fsConstants } from "node:fs";
|
|
24306
24315
|
import { tmpdir as tmpdir2 } from "node:os";
|
|
24307
24316
|
import { basename as basename7, dirname as dirname17, extname as extname2, isAbsolute as isAbsolute8, join as join28, normalize as normalize2, resolve as resolve15, sep as sep6 } from "node:path";
|
package/dist/mcp-server.mjs
CHANGED
|
@@ -24550,6 +24550,10 @@ function killSpawnedChild(child, pid) {
|
|
|
24550
24550
|
}
|
|
24551
24551
|
}
|
|
24552
24552
|
}
|
|
24553
|
+
function resolveToolsServerNode() {
|
|
24554
|
+
const { bun, deno, electron } = process.versions;
|
|
24555
|
+
return !(bun || deno || electron) && fs.existsSync(process.execPath) ? process.execPath : "node";
|
|
24556
|
+
}
|
|
24553
24557
|
function spawnToolsServer(paths, port, options = {}) {
|
|
24554
24558
|
return new Promise((resolve10, reject) => {
|
|
24555
24559
|
let logFd;
|
|
@@ -24559,8 +24563,7 @@ function spawnToolsServer(paths, port, options = {}) {
|
|
|
24559
24563
|
} catch {
|
|
24560
24564
|
logFd = fs.openSync("/dev/null", "w");
|
|
24561
24565
|
}
|
|
24562
|
-
const
|
|
24563
|
-
const nodeBin = !(bun || deno || electron) && fs.existsSync(process.execPath) ? process.execPath : "node";
|
|
24566
|
+
const nodeBin = resolveToolsServerNode();
|
|
24564
24567
|
const child = spawn(nodeBin, [paths.bundlePath, "start"], {
|
|
24565
24568
|
detached: true,
|
|
24566
24569
|
stdio: ["ignore", "pipe", logFd],
|
|
@@ -26456,7 +26459,7 @@ async function sniffFormat(archivePath) {
|
|
|
26456
26459
|
}
|
|
26457
26460
|
}
|
|
26458
26461
|
var ZSTD_FRAME_MAGIC = 4247762216;
|
|
26459
|
-
async function assertSingleCompleteZstdFrame(archivePath) {
|
|
26462
|
+
async function assertSingleCompleteZstdFrame(archivePath, signal) {
|
|
26460
26463
|
const fh = await open2(archivePath, "r");
|
|
26461
26464
|
try {
|
|
26462
26465
|
const { size } = await fh.stat();
|
|
@@ -26466,6 +26469,7 @@ async function assertSingleCompleteZstdFrame(archivePath) {
|
|
|
26466
26469
|
let pos = 0;
|
|
26467
26470
|
const read = async (n) => {
|
|
26468
26471
|
if (pos < windowStart || pos + n > windowEnd) {
|
|
26472
|
+
signal?.throwIfAborted();
|
|
26469
26473
|
const { bytesRead } = await fh.read(window, 0, window.length, pos);
|
|
26470
26474
|
windowStart = pos;
|
|
26471
26475
|
windowEnd = pos + bytesRead;
|
|
@@ -26503,14 +26507,16 @@ function tarEnv(env) {
|
|
|
26503
26507
|
const characterType = env.LC_ALL || env.LC_CTYPE || env.LANG || "";
|
|
26504
26508
|
return /utf-?8/i.test(characterType) ? env : { ...env, LC_ALL: TAR_LOCALE };
|
|
26505
26509
|
}
|
|
26506
|
-
async function runTar(archive, args) {
|
|
26510
|
+
async function runTar(archive, args, signal) {
|
|
26507
26511
|
const child = spawn2("tar", [...args, "-f", "-"], {
|
|
26512
|
+
signal,
|
|
26508
26513
|
env: tarEnv(process.env)
|
|
26509
26514
|
});
|
|
26510
|
-
|
|
26511
|
-
|
|
26512
|
-
|
|
26515
|
+
let childError;
|
|
26516
|
+
child.on("error", (err) => {
|
|
26517
|
+
childError = err;
|
|
26513
26518
|
});
|
|
26519
|
+
const closed = new Promise((resolve10) => child.once("close", resolve10));
|
|
26514
26520
|
const stdout = collect(child.stdout, MAX_LISTING_BYTES, {
|
|
26515
26521
|
maxLines: MAX_LISTING_LINES,
|
|
26516
26522
|
onOverflow: () => child.kill()
|
|
@@ -26537,12 +26543,15 @@ async function runTar(archive, args) {
|
|
|
26537
26543
|
if (err) child.stdin?.destroy();
|
|
26538
26544
|
done(err);
|
|
26539
26545
|
}
|
|
26540
|
-
})
|
|
26546
|
+
}),
|
|
26547
|
+
{ signal }
|
|
26541
26548
|
).then(
|
|
26542
26549
|
() => null,
|
|
26543
26550
|
(err) => err
|
|
26544
26551
|
);
|
|
26545
|
-
const [code, feedError] = await Promise.all([
|
|
26552
|
+
const [code, feedError] = await Promise.all([closed, fed]);
|
|
26553
|
+
signal?.throwIfAborted();
|
|
26554
|
+
if (childError) throw childError;
|
|
26546
26555
|
if (stdout.overflowed()) {
|
|
26547
26556
|
throw new Error(
|
|
26548
26557
|
`tar ${args.join(" ")} listed more than ${MAX_LISTING_LINES} members or ${MAX_LISTING_BYTES >> 20} MiB`
|
|
@@ -26567,21 +26576,22 @@ function isSafeTarMember(memberPath, destDir) {
|
|
|
26567
26576
|
const root = resolve6(destDir);
|
|
26568
26577
|
return resolve6(destDir, normalized).startsWith(root + sep2);
|
|
26569
26578
|
}
|
|
26570
|
-
async function readListing(archive, args) {
|
|
26579
|
+
async function readListing(archive, args, signal) {
|
|
26571
26580
|
try {
|
|
26572
|
-
return await runTar(archive, args);
|
|
26581
|
+
return await runTar(archive, args, signal);
|
|
26573
26582
|
} catch (err) {
|
|
26583
|
+
signal?.throwIfAborted();
|
|
26574
26584
|
throw new ArchiveError(
|
|
26575
26585
|
`Could not read archive: ${err instanceof Error ? err.message : String(err)}`
|
|
26576
26586
|
);
|
|
26577
26587
|
}
|
|
26578
26588
|
}
|
|
26579
|
-
async function listTarMembers(archive) {
|
|
26580
|
-
const stdout = await readListing(archive, ["-t"]);
|
|
26589
|
+
async function listTarMembers(archive, signal) {
|
|
26590
|
+
const stdout = await readListing(archive, ["-t"], signal);
|
|
26581
26591
|
return stdout.split("\n").map((line) => line.trim()).filter((line) => line.length > 0);
|
|
26582
26592
|
}
|
|
26583
|
-
async function assertSafeMemberTypes(archive) {
|
|
26584
|
-
const stdout = await readListing(archive, ["-tv"]);
|
|
26593
|
+
async function assertSafeMemberTypes(archive, signal) {
|
|
26594
|
+
const stdout = await readListing(archive, ["-tv"], signal);
|
|
26585
26595
|
for (const line of stdout.split("\n")) {
|
|
26586
26596
|
if (!line.trim()) continue;
|
|
26587
26597
|
const type = line[0];
|
|
@@ -26601,8 +26611,8 @@ async function assertSafeMemberTypes(archive) {
|
|
|
26601
26611
|
);
|
|
26602
26612
|
}
|
|
26603
26613
|
}
|
|
26604
|
-
async function assertSafeArchive(archive, destDir) {
|
|
26605
|
-
const members2 = await listTarMembers(archive);
|
|
26614
|
+
async function assertSafeArchive(archive, destDir, signal) {
|
|
26615
|
+
const members2 = await listTarMembers(archive, signal);
|
|
26606
26616
|
if (members2.length === 0) {
|
|
26607
26617
|
throw new ArchiveError("Archive is empty.");
|
|
26608
26618
|
}
|
|
@@ -26611,7 +26621,7 @@ async function assertSafeArchive(archive, destDir) {
|
|
|
26611
26621
|
throw new ArchiveError(`Archive contains an unsafe path "${member}" \u2014 refusing extraction.`);
|
|
26612
26622
|
}
|
|
26613
26623
|
}
|
|
26614
|
-
await assertSafeMemberTypes(archive);
|
|
26624
|
+
await assertSafeMemberTypes(archive, signal);
|
|
26615
26625
|
}
|
|
26616
26626
|
async function resolveMember(destDir, expectedName) {
|
|
26617
26627
|
const entries = await readdir3(destDir);
|
|
@@ -26626,19 +26636,24 @@ async function resolveMember(destDir, expectedName) {
|
|
|
26626
26636
|
}
|
|
26627
26637
|
return join9(destDir, real[0]);
|
|
26628
26638
|
}
|
|
26629
|
-
async function safeExtractArchive(archivePath, destDir, expectedName) {
|
|
26639
|
+
async function safeExtractArchive(archivePath, destDir, expectedName, signal) {
|
|
26640
|
+
signal?.throwIfAborted();
|
|
26630
26641
|
let archive;
|
|
26631
26642
|
try {
|
|
26632
26643
|
archive = { path: archivePath, format: await sniffFormat(archivePath) };
|
|
26633
|
-
if (archive.format === "zstd") await assertSingleCompleteZstdFrame(archivePath);
|
|
26644
|
+
if (archive.format === "zstd") await assertSingleCompleteZstdFrame(archivePath, signal);
|
|
26634
26645
|
} catch (err) {
|
|
26646
|
+
signal?.throwIfAborted();
|
|
26635
26647
|
throw new ArchiveError(
|
|
26636
26648
|
`Could not read archive: ${err instanceof Error ? err.message : String(err)}`
|
|
26637
26649
|
);
|
|
26638
26650
|
}
|
|
26639
|
-
await assertSafeArchive(archive, destDir);
|
|
26640
|
-
|
|
26641
|
-
|
|
26651
|
+
await assertSafeArchive(archive, destDir, signal);
|
|
26652
|
+
signal?.throwIfAborted();
|
|
26653
|
+
await runTar(archive, ["-x", "-C", destDir], signal);
|
|
26654
|
+
const member = await resolveMember(destDir, expectedName);
|
|
26655
|
+
signal?.throwIfAborted();
|
|
26656
|
+
return member;
|
|
26642
26657
|
}
|
|
26643
26658
|
|
|
26644
26659
|
// ../argent-tools-client/src/errors.ts
|
|
@@ -27824,7 +27839,16 @@ function createToolsClient(options = {}) {
|
|
|
27824
27839
|
}
|
|
27825
27840
|
|
|
27826
27841
|
// ../argent-tools-client/src/artifacts.ts
|
|
27827
|
-
import {
|
|
27842
|
+
import {
|
|
27843
|
+
copyFile,
|
|
27844
|
+
mkdir as mkdir4,
|
|
27845
|
+
mkdtemp,
|
|
27846
|
+
readFile as readFile6,
|
|
27847
|
+
realpath as realpath4,
|
|
27848
|
+
rm as rm3,
|
|
27849
|
+
stat as stat5,
|
|
27850
|
+
writeFile as writeFile4
|
|
27851
|
+
} from "node:fs/promises";
|
|
27828
27852
|
import { constants as fsConstants } from "node:fs";
|
|
27829
27853
|
import { tmpdir as tmpdir2 } from "node:os";
|
|
27830
27854
|
import { basename as basename7, dirname as dirname9, extname as extname2, isAbsolute as isAbsolute6, join as join13, normalize as normalize2, resolve as resolve8, sep as sep4 } from "node:path";
|
|
@@ -27968,16 +27992,22 @@ async function resolveLocalFile(handle) {
|
|
|
27968
27992
|
return null;
|
|
27969
27993
|
}
|
|
27970
27994
|
}
|
|
27971
|
-
async function downloadAndExtractArchive(handle, data, dir) {
|
|
27972
|
-
|
|
27995
|
+
async function downloadAndExtractArchive(handle, data, dir, signal) {
|
|
27996
|
+
signal?.throwIfAborted();
|
|
27997
|
+
const attemptDir = await mkdtemp(join13(dir, "bundle-"));
|
|
27998
|
+
const tarball = join13(attemptDir, "download.tar");
|
|
27999
|
+
const extractDir = join13(attemptDir, "files");
|
|
27973
28000
|
try {
|
|
27974
|
-
await writeFile4(tarball, data);
|
|
27975
|
-
|
|
28001
|
+
await writeFile4(tarball, data, { signal });
|
|
28002
|
+
await mkdir4(extractDir);
|
|
28003
|
+
const member = await safeExtractArchive(tarball, extractDir, handle.filename, signal);
|
|
28004
|
+
await rm3(tarball);
|
|
28005
|
+
signal?.throwIfAborted();
|
|
28006
|
+
return member;
|
|
27976
28007
|
} catch {
|
|
27977
|
-
|
|
27978
|
-
} finally {
|
|
27979
|
-
await rm3(tarball, { force: true }).catch(() => {
|
|
28008
|
+
await rm3(attemptDir, { recursive: true, force: true }).catch(() => {
|
|
27980
28009
|
});
|
|
28010
|
+
return null;
|
|
27981
28011
|
}
|
|
27982
28012
|
}
|
|
27983
28013
|
async function materializeArtifacts(result, ctx) {
|
|
@@ -28063,7 +28093,7 @@ async function materializeArtifacts(result, ctx) {
|
|
|
28063
28093
|
if (!data) return null;
|
|
28064
28094
|
await ensureDir();
|
|
28065
28095
|
if (value.archive === "tar.gz") {
|
|
28066
|
-
return await downloadAndExtractArchive(value, data, dir);
|
|
28096
|
+
return await downloadAndExtractArchive(value, data, dir, ctx.signal);
|
|
28067
28097
|
}
|
|
28068
28098
|
if (value.size > 0 && data.length !== value.size) return null;
|
|
28069
28099
|
const downloadedPath = join13(dir, sanitizeSegment(value.filename));
|
package/dist/tool-server.cjs
CHANGED
|
@@ -101405,7 +101405,7 @@ function isCi(env = process.env) {
|
|
|
101405
101405
|
var SESSION_ID = (0, import_node_crypto3.randomUUID)();
|
|
101406
101406
|
function readCliVersion() {
|
|
101407
101407
|
if (true) {
|
|
101408
|
-
return "0.34.1-next.
|
|
101408
|
+
return "0.34.1-next.28";
|
|
101409
101409
|
}
|
|
101410
101410
|
return "0.0.0";
|
|
101411
101411
|
}
|
|
@@ -102329,7 +102329,7 @@ async function sniffFormat(archivePath) {
|
|
|
102329
102329
|
}
|
|
102330
102330
|
}
|
|
102331
102331
|
var ZSTD_FRAME_MAGIC = 4247762216;
|
|
102332
|
-
async function assertSingleCompleteZstdFrame(archivePath) {
|
|
102332
|
+
async function assertSingleCompleteZstdFrame(archivePath, signal) {
|
|
102333
102333
|
const fh = await (0, import_promises2.open)(archivePath, "r");
|
|
102334
102334
|
try {
|
|
102335
102335
|
const { size } = await fh.stat();
|
|
@@ -102339,6 +102339,7 @@ async function assertSingleCompleteZstdFrame(archivePath) {
|
|
|
102339
102339
|
let pos = 0;
|
|
102340
102340
|
const read = async (n) => {
|
|
102341
102341
|
if (pos < windowStart || pos + n > windowEnd) {
|
|
102342
|
+
signal?.throwIfAborted();
|
|
102342
102343
|
const { bytesRead } = await fh.read(window2, 0, window2.length, pos);
|
|
102343
102344
|
windowStart = pos;
|
|
102344
102345
|
windowEnd = pos + bytesRead;
|
|
@@ -102376,14 +102377,16 @@ function tarEnv(env) {
|
|
|
102376
102377
|
const characterType = env.LC_ALL || env.LC_CTYPE || env.LANG || "";
|
|
102377
102378
|
return /utf-?8/i.test(characterType) ? env : { ...env, LC_ALL: TAR_LOCALE };
|
|
102378
102379
|
}
|
|
102379
|
-
async function runTar(archive, args) {
|
|
102380
|
+
async function runTar(archive, args, signal) {
|
|
102380
102381
|
const child = (0, import_node_child_process2.spawn)("tar", [...args, "-f", "-"], {
|
|
102382
|
+
signal,
|
|
102381
102383
|
env: tarEnv(process.env)
|
|
102382
102384
|
});
|
|
102383
|
-
|
|
102384
|
-
|
|
102385
|
-
|
|
102385
|
+
let childError;
|
|
102386
|
+
child.on("error", (err) => {
|
|
102387
|
+
childError = err;
|
|
102386
102388
|
});
|
|
102389
|
+
const closed = new Promise((resolve20) => child.once("close", resolve20));
|
|
102387
102390
|
const stdout = collect(child.stdout, MAX_LISTING_BYTES, {
|
|
102388
102391
|
maxLines: MAX_LISTING_LINES,
|
|
102389
102392
|
onOverflow: () => child.kill()
|
|
@@ -102410,12 +102413,15 @@ async function runTar(archive, args) {
|
|
|
102410
102413
|
if (err) child.stdin?.destroy();
|
|
102411
102414
|
done(err);
|
|
102412
102415
|
}
|
|
102413
|
-
})
|
|
102416
|
+
}),
|
|
102417
|
+
{ signal }
|
|
102414
102418
|
).then(
|
|
102415
102419
|
() => null,
|
|
102416
102420
|
(err) => err
|
|
102417
102421
|
);
|
|
102418
|
-
const [code, feedError] = await Promise.all([
|
|
102422
|
+
const [code, feedError] = await Promise.all([closed, fed]);
|
|
102423
|
+
signal?.throwIfAborted();
|
|
102424
|
+
if (childError) throw childError;
|
|
102419
102425
|
if (stdout.overflowed()) {
|
|
102420
102426
|
throw new Error(
|
|
102421
102427
|
`tar ${args.join(" ")} listed more than ${MAX_LISTING_LINES} members or ${MAX_LISTING_BYTES >> 20} MiB`
|
|
@@ -102440,21 +102446,22 @@ function isSafeTarMember(memberPath2, destDir) {
|
|
|
102440
102446
|
const root = (0, import_node_path3.resolve)(destDir);
|
|
102441
102447
|
return (0, import_node_path3.resolve)(destDir, normalized).startsWith(root + import_node_path3.sep);
|
|
102442
102448
|
}
|
|
102443
|
-
async function readListing(archive, args) {
|
|
102449
|
+
async function readListing(archive, args, signal) {
|
|
102444
102450
|
try {
|
|
102445
|
-
return await runTar(archive, args);
|
|
102451
|
+
return await runTar(archive, args, signal);
|
|
102446
102452
|
} catch (err) {
|
|
102453
|
+
signal?.throwIfAborted();
|
|
102447
102454
|
throw new ArchiveError(
|
|
102448
102455
|
`Could not read archive: ${err instanceof Error ? err.message : String(err)}`
|
|
102449
102456
|
);
|
|
102450
102457
|
}
|
|
102451
102458
|
}
|
|
102452
|
-
async function listTarMembers(archive) {
|
|
102453
|
-
const stdout = await readListing(archive, ["-t"]);
|
|
102459
|
+
async function listTarMembers(archive, signal) {
|
|
102460
|
+
const stdout = await readListing(archive, ["-t"], signal);
|
|
102454
102461
|
return stdout.split("\n").map((line) => line.trim()).filter((line) => line.length > 0);
|
|
102455
102462
|
}
|
|
102456
|
-
async function assertSafeMemberTypes(archive) {
|
|
102457
|
-
const stdout = await readListing(archive, ["-tv"]);
|
|
102463
|
+
async function assertSafeMemberTypes(archive, signal) {
|
|
102464
|
+
const stdout = await readListing(archive, ["-tv"], signal);
|
|
102458
102465
|
for (const line of stdout.split("\n")) {
|
|
102459
102466
|
if (!line.trim()) continue;
|
|
102460
102467
|
const type = line[0];
|
|
@@ -102474,8 +102481,8 @@ async function assertSafeMemberTypes(archive) {
|
|
|
102474
102481
|
);
|
|
102475
102482
|
}
|
|
102476
102483
|
}
|
|
102477
|
-
async function assertSafeArchive(archive, destDir) {
|
|
102478
|
-
const members2 = await listTarMembers(archive);
|
|
102484
|
+
async function assertSafeArchive(archive, destDir, signal) {
|
|
102485
|
+
const members2 = await listTarMembers(archive, signal);
|
|
102479
102486
|
if (members2.length === 0) {
|
|
102480
102487
|
throw new ArchiveError("Archive is empty.");
|
|
102481
102488
|
}
|
|
@@ -102484,7 +102491,7 @@ async function assertSafeArchive(archive, destDir) {
|
|
|
102484
102491
|
throw new ArchiveError(`Archive contains an unsafe path "${member}" \u2014 refusing extraction.`);
|
|
102485
102492
|
}
|
|
102486
102493
|
}
|
|
102487
|
-
await assertSafeMemberTypes(archive);
|
|
102494
|
+
await assertSafeMemberTypes(archive, signal);
|
|
102488
102495
|
}
|
|
102489
102496
|
async function resolveMember(destDir, expectedName) {
|
|
102490
102497
|
const entries = await (0, import_promises2.readdir)(destDir);
|
|
@@ -102499,19 +102506,24 @@ async function resolveMember(destDir, expectedName) {
|
|
|
102499
102506
|
}
|
|
102500
102507
|
return (0, import_node_path3.join)(destDir, real[0]);
|
|
102501
102508
|
}
|
|
102502
|
-
async function safeExtractArchive(archivePath, destDir, expectedName) {
|
|
102509
|
+
async function safeExtractArchive(archivePath, destDir, expectedName, signal) {
|
|
102510
|
+
signal?.throwIfAborted();
|
|
102503
102511
|
let archive;
|
|
102504
102512
|
try {
|
|
102505
102513
|
archive = { path: archivePath, format: await sniffFormat(archivePath) };
|
|
102506
|
-
if (archive.format === "zstd") await assertSingleCompleteZstdFrame(archivePath);
|
|
102514
|
+
if (archive.format === "zstd") await assertSingleCompleteZstdFrame(archivePath, signal);
|
|
102507
102515
|
} catch (err) {
|
|
102516
|
+
signal?.throwIfAborted();
|
|
102508
102517
|
throw new ArchiveError(
|
|
102509
102518
|
`Could not read archive: ${err instanceof Error ? err.message : String(err)}`
|
|
102510
102519
|
);
|
|
102511
102520
|
}
|
|
102512
|
-
await assertSafeArchive(archive, destDir);
|
|
102513
|
-
|
|
102514
|
-
|
|
102521
|
+
await assertSafeArchive(archive, destDir, signal);
|
|
102522
|
+
signal?.throwIfAborted();
|
|
102523
|
+
await runTar(archive, ["-x", "-C", destDir], signal);
|
|
102524
|
+
const member = await resolveMember(destDir, expectedName);
|
|
102525
|
+
signal?.throwIfAborted();
|
|
102526
|
+
return member;
|
|
102515
102527
|
}
|
|
102516
102528
|
|
|
102517
102529
|
// ../tool-server/src/http.ts
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@swmansion/argent",
|
|
3
|
-
"version": "0.34.1-next.
|
|
3
|
+
"version": "0.34.1-next.28",
|
|
4
4
|
"mcpName": "io.github.software-mansion/argent",
|
|
5
5
|
"description": "MCP server for iOS Simulator, Android Emulator, Chromium app and Mac app control",
|
|
6
6
|
"license": "Apache-2.0",
|