@swmansion/argent 0.34.1-next.27 → 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 +58 -31
- package/dist/client.js +57 -30
- package/dist/installer.mjs +11 -2
- package/dist/mcp-server.mjs +57 -30
- package/dist/tool-server.cjs +34 -22
- package/package.json +1 -1
package/dist/cli-cmds.mjs
CHANGED
|
@@ -30959,7 +30959,7 @@ async function sniffFormat(archivePath) {
|
|
|
30959
30959
|
}
|
|
30960
30960
|
}
|
|
30961
30961
|
var ZSTD_FRAME_MAGIC = 4247762216;
|
|
30962
|
-
async function assertSingleCompleteZstdFrame(archivePath) {
|
|
30962
|
+
async function assertSingleCompleteZstdFrame(archivePath, signal) {
|
|
30963
30963
|
const fh = await open2(archivePath, "r");
|
|
30964
30964
|
try {
|
|
30965
30965
|
const { size } = await fh.stat();
|
|
@@ -30969,6 +30969,7 @@ async function assertSingleCompleteZstdFrame(archivePath) {
|
|
|
30969
30969
|
let pos = 0;
|
|
30970
30970
|
const read = async (n3) => {
|
|
30971
30971
|
if (pos < windowStart || pos + n3 > windowEnd) {
|
|
30972
|
+
signal?.throwIfAborted();
|
|
30972
30973
|
const { bytesRead } = await fh.read(window2, 0, window2.length, pos);
|
|
30973
30974
|
windowStart = pos;
|
|
30974
30975
|
windowEnd = pos + bytesRead;
|
|
@@ -31006,14 +31007,16 @@ function tarEnv(env) {
|
|
|
31006
31007
|
const characterType = env.LC_ALL || env.LC_CTYPE || env.LANG || "";
|
|
31007
31008
|
return /utf-?8/i.test(characterType) ? env : { ...env, LC_ALL: TAR_LOCALE };
|
|
31008
31009
|
}
|
|
31009
|
-
async function runTar(archive, args) {
|
|
31010
|
+
async function runTar(archive, args, signal) {
|
|
31010
31011
|
const child = spawn2("tar", [...args, "-f", "-"], {
|
|
31012
|
+
signal,
|
|
31011
31013
|
env: tarEnv(process.env)
|
|
31012
31014
|
});
|
|
31013
|
-
|
|
31014
|
-
|
|
31015
|
-
|
|
31015
|
+
let childError;
|
|
31016
|
+
child.on("error", (err) => {
|
|
31017
|
+
childError = err;
|
|
31016
31018
|
});
|
|
31019
|
+
const closed = new Promise((resolve13) => child.once("close", resolve13));
|
|
31017
31020
|
const stdout2 = collect(child.stdout, MAX_LISTING_BYTES, {
|
|
31018
31021
|
maxLines: MAX_LISTING_LINES,
|
|
31019
31022
|
onOverflow: () => child.kill()
|
|
@@ -31040,12 +31043,15 @@ async function runTar(archive, args) {
|
|
|
31040
31043
|
if (err) child.stdin?.destroy();
|
|
31041
31044
|
done(err);
|
|
31042
31045
|
}
|
|
31043
|
-
})
|
|
31046
|
+
}),
|
|
31047
|
+
{ signal }
|
|
31044
31048
|
).then(
|
|
31045
31049
|
() => null,
|
|
31046
31050
|
(err) => err
|
|
31047
31051
|
);
|
|
31048
|
-
const [code, feedError] = await Promise.all([
|
|
31052
|
+
const [code, feedError] = await Promise.all([closed, fed]);
|
|
31053
|
+
signal?.throwIfAborted();
|
|
31054
|
+
if (childError) throw childError;
|
|
31049
31055
|
if (stdout2.overflowed()) {
|
|
31050
31056
|
throw new Error(
|
|
31051
31057
|
`tar ${args.join(" ")} listed more than ${MAX_LISTING_LINES} members or ${MAX_LISTING_BYTES >> 20} MiB`
|
|
@@ -31070,21 +31076,22 @@ function isSafeTarMember(memberPath, destDir) {
|
|
|
31070
31076
|
const root = resolve6(destDir);
|
|
31071
31077
|
return resolve6(destDir, normalized).startsWith(root + sep2);
|
|
31072
31078
|
}
|
|
31073
|
-
async function readListing(archive, args) {
|
|
31079
|
+
async function readListing(archive, args, signal) {
|
|
31074
31080
|
try {
|
|
31075
|
-
return await runTar(archive, args);
|
|
31081
|
+
return await runTar(archive, args, signal);
|
|
31076
31082
|
} catch (err) {
|
|
31083
|
+
signal?.throwIfAborted();
|
|
31077
31084
|
throw new ArchiveError(
|
|
31078
31085
|
`Could not read archive: ${err instanceof Error ? err.message : String(err)}`
|
|
31079
31086
|
);
|
|
31080
31087
|
}
|
|
31081
31088
|
}
|
|
31082
|
-
async function listTarMembers(archive) {
|
|
31083
|
-
const stdout2 = await readListing(archive, ["-t"]);
|
|
31089
|
+
async function listTarMembers(archive, signal) {
|
|
31090
|
+
const stdout2 = await readListing(archive, ["-t"], signal);
|
|
31084
31091
|
return stdout2.split("\n").map((line) => line.trim()).filter((line) => line.length > 0);
|
|
31085
31092
|
}
|
|
31086
|
-
async function assertSafeMemberTypes(archive) {
|
|
31087
|
-
const stdout2 = await readListing(archive, ["-tv"]);
|
|
31093
|
+
async function assertSafeMemberTypes(archive, signal) {
|
|
31094
|
+
const stdout2 = await readListing(archive, ["-tv"], signal);
|
|
31088
31095
|
for (const line of stdout2.split("\n")) {
|
|
31089
31096
|
if (!line.trim()) continue;
|
|
31090
31097
|
const type = line[0];
|
|
@@ -31104,8 +31111,8 @@ async function assertSafeMemberTypes(archive) {
|
|
|
31104
31111
|
);
|
|
31105
31112
|
}
|
|
31106
31113
|
}
|
|
31107
|
-
async function assertSafeArchive(archive, destDir) {
|
|
31108
|
-
const members2 = await listTarMembers(archive);
|
|
31114
|
+
async function assertSafeArchive(archive, destDir, signal) {
|
|
31115
|
+
const members2 = await listTarMembers(archive, signal);
|
|
31109
31116
|
if (members2.length === 0) {
|
|
31110
31117
|
throw new ArchiveError("Archive is empty.");
|
|
31111
31118
|
}
|
|
@@ -31114,7 +31121,7 @@ async function assertSafeArchive(archive, destDir) {
|
|
|
31114
31121
|
throw new ArchiveError(`Archive contains an unsafe path "${member}" \u2014 refusing extraction.`);
|
|
31115
31122
|
}
|
|
31116
31123
|
}
|
|
31117
|
-
await assertSafeMemberTypes(archive);
|
|
31124
|
+
await assertSafeMemberTypes(archive, signal);
|
|
31118
31125
|
}
|
|
31119
31126
|
async function resolveMember(destDir, expectedName) {
|
|
31120
31127
|
const entries = await readdir3(destDir);
|
|
@@ -31129,19 +31136,24 @@ async function resolveMember(destDir, expectedName) {
|
|
|
31129
31136
|
}
|
|
31130
31137
|
return join9(destDir, real[0]);
|
|
31131
31138
|
}
|
|
31132
|
-
async function safeExtractArchive(archivePath, destDir, expectedName) {
|
|
31139
|
+
async function safeExtractArchive(archivePath, destDir, expectedName, signal) {
|
|
31140
|
+
signal?.throwIfAborted();
|
|
31133
31141
|
let archive;
|
|
31134
31142
|
try {
|
|
31135
31143
|
archive = { path: archivePath, format: await sniffFormat(archivePath) };
|
|
31136
|
-
if (archive.format === "zstd") await assertSingleCompleteZstdFrame(archivePath);
|
|
31144
|
+
if (archive.format === "zstd") await assertSingleCompleteZstdFrame(archivePath, signal);
|
|
31137
31145
|
} catch (err) {
|
|
31146
|
+
signal?.throwIfAborted();
|
|
31138
31147
|
throw new ArchiveError(
|
|
31139
31148
|
`Could not read archive: ${err instanceof Error ? err.message : String(err)}`
|
|
31140
31149
|
);
|
|
31141
31150
|
}
|
|
31142
|
-
await assertSafeArchive(archive, destDir);
|
|
31143
|
-
|
|
31144
|
-
|
|
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;
|
|
31145
31157
|
}
|
|
31146
31158
|
|
|
31147
31159
|
// ../argent-tools-client/src/errors.ts
|
|
@@ -32327,7 +32339,16 @@ function createToolsClient(options = {}) {
|
|
|
32327
32339
|
}
|
|
32328
32340
|
|
|
32329
32341
|
// ../argent-tools-client/src/artifacts.ts
|
|
32330
|
-
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";
|
|
32331
32352
|
import { constants as fsConstants } from "node:fs";
|
|
32332
32353
|
import { tmpdir as tmpdir2 } from "node:os";
|
|
32333
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";
|
|
@@ -32471,16 +32492,22 @@ async function resolveLocalFile(handle) {
|
|
|
32471
32492
|
return null;
|
|
32472
32493
|
}
|
|
32473
32494
|
}
|
|
32474
|
-
async function downloadAndExtractArchive(handle, data, dir) {
|
|
32475
|
-
|
|
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");
|
|
32476
32500
|
try {
|
|
32477
|
-
await writeFile4(tarball, data);
|
|
32478
|
-
|
|
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;
|
|
32479
32507
|
} catch {
|
|
32480
|
-
|
|
32481
|
-
} finally {
|
|
32482
|
-
await rm3(tarball, { force: true }).catch(() => {
|
|
32508
|
+
await rm3(attemptDir, { recursive: true, force: true }).catch(() => {
|
|
32483
32509
|
});
|
|
32510
|
+
return null;
|
|
32484
32511
|
}
|
|
32485
32512
|
}
|
|
32486
32513
|
async function materializeArtifacts(result, ctx) {
|
|
@@ -32566,7 +32593,7 @@ async function materializeArtifacts(result, ctx) {
|
|
|
32566
32593
|
if (!data) return null;
|
|
32567
32594
|
await ensureDir();
|
|
32568
32595
|
if (value.archive === "tar.gz") {
|
|
32569
|
-
return await downloadAndExtractArchive(value, data, dir);
|
|
32596
|
+
return await downloadAndExtractArchive(value, data, dir, ctx.signal);
|
|
32570
32597
|
}
|
|
32571
32598
|
if (value.size > 0 && data.length !== value.size) return null;
|
|
32572
32599
|
const downloadedPath = join13(dir, sanitizeSegment(value.filename));
|
|
@@ -36145,7 +36172,7 @@ function isCi(env = process.env) {
|
|
|
36145
36172
|
var SESSION_ID2 = randomUUID5();
|
|
36146
36173
|
function readCliVersion() {
|
|
36147
36174
|
if (true) {
|
|
36148
|
-
return "0.34.1-next.
|
|
36175
|
+
return "0.34.1-next.28";
|
|
36149
36176
|
}
|
|
36150
36177
|
return "0.0.0";
|
|
36151
36178
|
}
|
package/dist/client.js
CHANGED
|
@@ -9699,7 +9699,7 @@ async function sniffFormat(archivePath) {
|
|
|
9699
9699
|
}
|
|
9700
9700
|
}
|
|
9701
9701
|
var ZSTD_FRAME_MAGIC = 4247762216;
|
|
9702
|
-
async function assertSingleCompleteZstdFrame(archivePath) {
|
|
9702
|
+
async function assertSingleCompleteZstdFrame(archivePath, signal) {
|
|
9703
9703
|
const fh = await open(archivePath, "r");
|
|
9704
9704
|
try {
|
|
9705
9705
|
const { size } = await fh.stat();
|
|
@@ -9709,6 +9709,7 @@ async function assertSingleCompleteZstdFrame(archivePath) {
|
|
|
9709
9709
|
let pos = 0;
|
|
9710
9710
|
const read = async (n) => {
|
|
9711
9711
|
if (pos < windowStart || pos + n > windowEnd) {
|
|
9712
|
+
signal?.throwIfAborted();
|
|
9712
9713
|
const { bytesRead } = await fh.read(window, 0, window.length, pos);
|
|
9713
9714
|
windowStart = pos;
|
|
9714
9715
|
windowEnd = pos + bytesRead;
|
|
@@ -9746,14 +9747,16 @@ function tarEnv(env) {
|
|
|
9746
9747
|
const characterType = env.LC_ALL || env.LC_CTYPE || env.LANG || "";
|
|
9747
9748
|
return /utf-?8/i.test(characterType) ? env : { ...env, LC_ALL: TAR_LOCALE };
|
|
9748
9749
|
}
|
|
9749
|
-
async function runTar(archive, args) {
|
|
9750
|
+
async function runTar(archive, args, signal) {
|
|
9750
9751
|
const child = spawn2("tar", [...args, "-f", "-"], {
|
|
9752
|
+
signal,
|
|
9751
9753
|
env: tarEnv(process.env)
|
|
9752
9754
|
});
|
|
9753
|
-
|
|
9754
|
-
|
|
9755
|
-
|
|
9755
|
+
let childError;
|
|
9756
|
+
child.on("error", (err) => {
|
|
9757
|
+
childError = err;
|
|
9756
9758
|
});
|
|
9759
|
+
const closed = new Promise((resolve9) => child.once("close", resolve9));
|
|
9757
9760
|
const stdout = collect(child.stdout, MAX_LISTING_BYTES, {
|
|
9758
9761
|
maxLines: MAX_LISTING_LINES,
|
|
9759
9762
|
onOverflow: () => child.kill()
|
|
@@ -9780,12 +9783,15 @@ async function runTar(archive, args) {
|
|
|
9780
9783
|
if (err) child.stdin?.destroy();
|
|
9781
9784
|
done(err);
|
|
9782
9785
|
}
|
|
9783
|
-
})
|
|
9786
|
+
}),
|
|
9787
|
+
{ signal }
|
|
9784
9788
|
).then(
|
|
9785
9789
|
() => null,
|
|
9786
9790
|
(err) => err
|
|
9787
9791
|
);
|
|
9788
|
-
const [code, feedError] = await Promise.all([
|
|
9792
|
+
const [code, feedError] = await Promise.all([closed, fed]);
|
|
9793
|
+
signal?.throwIfAborted();
|
|
9794
|
+
if (childError) throw childError;
|
|
9789
9795
|
if (stdout.overflowed()) {
|
|
9790
9796
|
throw new Error(
|
|
9791
9797
|
`tar ${args.join(" ")} listed more than ${MAX_LISTING_LINES} members or ${MAX_LISTING_BYTES >> 20} MiB`
|
|
@@ -9810,21 +9816,22 @@ function isSafeTarMember(memberPath, destDir) {
|
|
|
9810
9816
|
const root = resolve6(destDir);
|
|
9811
9817
|
return resolve6(destDir, normalized).startsWith(root + sep2);
|
|
9812
9818
|
}
|
|
9813
|
-
async function readListing(archive, args) {
|
|
9819
|
+
async function readListing(archive, args, signal) {
|
|
9814
9820
|
try {
|
|
9815
|
-
return await runTar(archive, args);
|
|
9821
|
+
return await runTar(archive, args, signal);
|
|
9816
9822
|
} catch (err) {
|
|
9823
|
+
signal?.throwIfAborted();
|
|
9817
9824
|
throw new ArchiveError(
|
|
9818
9825
|
`Could not read archive: ${err instanceof Error ? err.message : String(err)}`
|
|
9819
9826
|
);
|
|
9820
9827
|
}
|
|
9821
9828
|
}
|
|
9822
|
-
async function listTarMembers(archive) {
|
|
9823
|
-
const stdout = await readListing(archive, ["-t"]);
|
|
9829
|
+
async function listTarMembers(archive, signal) {
|
|
9830
|
+
const stdout = await readListing(archive, ["-t"], signal);
|
|
9824
9831
|
return stdout.split("\n").map((line) => line.trim()).filter((line) => line.length > 0);
|
|
9825
9832
|
}
|
|
9826
|
-
async function assertSafeMemberTypes(archive) {
|
|
9827
|
-
const stdout = await readListing(archive, ["-tv"]);
|
|
9833
|
+
async function assertSafeMemberTypes(archive, signal) {
|
|
9834
|
+
const stdout = await readListing(archive, ["-tv"], signal);
|
|
9828
9835
|
for (const line of stdout.split("\n")) {
|
|
9829
9836
|
if (!line.trim()) continue;
|
|
9830
9837
|
const type = line[0];
|
|
@@ -9844,8 +9851,8 @@ async function assertSafeMemberTypes(archive) {
|
|
|
9844
9851
|
);
|
|
9845
9852
|
}
|
|
9846
9853
|
}
|
|
9847
|
-
async function assertSafeArchive(archive, destDir) {
|
|
9848
|
-
const members = await listTarMembers(archive);
|
|
9854
|
+
async function assertSafeArchive(archive, destDir, signal) {
|
|
9855
|
+
const members = await listTarMembers(archive, signal);
|
|
9849
9856
|
if (members.length === 0) {
|
|
9850
9857
|
throw new ArchiveError("Archive is empty.");
|
|
9851
9858
|
}
|
|
@@ -9854,7 +9861,7 @@ async function assertSafeArchive(archive, destDir) {
|
|
|
9854
9861
|
throw new ArchiveError(`Archive contains an unsafe path "${member}" \u2014 refusing extraction.`);
|
|
9855
9862
|
}
|
|
9856
9863
|
}
|
|
9857
|
-
await assertSafeMemberTypes(archive);
|
|
9864
|
+
await assertSafeMemberTypes(archive, signal);
|
|
9858
9865
|
}
|
|
9859
9866
|
async function resolveMember(destDir, expectedName) {
|
|
9860
9867
|
const entries = await readdir3(destDir);
|
|
@@ -9869,19 +9876,24 @@ async function resolveMember(destDir, expectedName) {
|
|
|
9869
9876
|
}
|
|
9870
9877
|
return join9(destDir, real[0]);
|
|
9871
9878
|
}
|
|
9872
|
-
async function safeExtractArchive(archivePath, destDir, expectedName) {
|
|
9879
|
+
async function safeExtractArchive(archivePath, destDir, expectedName, signal) {
|
|
9880
|
+
signal?.throwIfAborted();
|
|
9873
9881
|
let archive;
|
|
9874
9882
|
try {
|
|
9875
9883
|
archive = { path: archivePath, format: await sniffFormat(archivePath) };
|
|
9876
|
-
if (archive.format === "zstd") await assertSingleCompleteZstdFrame(archivePath);
|
|
9884
|
+
if (archive.format === "zstd") await assertSingleCompleteZstdFrame(archivePath, signal);
|
|
9877
9885
|
} catch (err) {
|
|
9886
|
+
signal?.throwIfAborted();
|
|
9878
9887
|
throw new ArchiveError(
|
|
9879
9888
|
`Could not read archive: ${err instanceof Error ? err.message : String(err)}`
|
|
9880
9889
|
);
|
|
9881
9890
|
}
|
|
9882
|
-
await assertSafeArchive(archive, destDir);
|
|
9883
|
-
|
|
9884
|
-
|
|
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;
|
|
9885
9897
|
}
|
|
9886
9898
|
|
|
9887
9899
|
// ../argent-tools-client/src/errors.ts
|
|
@@ -11067,7 +11079,16 @@ function createToolsClient(options = {}) {
|
|
|
11067
11079
|
}
|
|
11068
11080
|
|
|
11069
11081
|
// ../argent-tools-client/src/artifacts.ts
|
|
11070
|
-
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";
|
|
11071
11092
|
import { constants as fsConstants } from "node:fs";
|
|
11072
11093
|
import { tmpdir as tmpdir2 } from "node:os";
|
|
11073
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";
|
|
@@ -11211,16 +11232,22 @@ async function resolveLocalFile(handle) {
|
|
|
11211
11232
|
return null;
|
|
11212
11233
|
}
|
|
11213
11234
|
}
|
|
11214
|
-
async function downloadAndExtractArchive(handle, data, dir) {
|
|
11215
|
-
|
|
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");
|
|
11216
11240
|
try {
|
|
11217
|
-
await writeFile4(tarball, data);
|
|
11218
|
-
|
|
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;
|
|
11219
11247
|
} catch {
|
|
11220
|
-
|
|
11221
|
-
} finally {
|
|
11222
|
-
await rm3(tarball, { force: true }).catch(() => {
|
|
11248
|
+
await rm3(attemptDir, { recursive: true, force: true }).catch(() => {
|
|
11223
11249
|
});
|
|
11250
|
+
return null;
|
|
11224
11251
|
}
|
|
11225
11252
|
}
|
|
11226
11253
|
async function materializeArtifacts(result, ctx) {
|
|
@@ -11306,7 +11333,7 @@ async function materializeArtifacts(result, ctx) {
|
|
|
11306
11333
|
if (!data) return null;
|
|
11307
11334
|
await ensureDir();
|
|
11308
11335
|
if (value.archive === "tar.gz") {
|
|
11309
|
-
return await downloadAndExtractArchive(value, data, dir);
|
|
11336
|
+
return await downloadAndExtractArchive(value, data, dir, ctx.signal);
|
|
11310
11337
|
}
|
|
11311
11338
|
if (value.size > 0 && data.length !== value.size) return null;
|
|
11312
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
|
@@ -26459,7 +26459,7 @@ async function sniffFormat(archivePath) {
|
|
|
26459
26459
|
}
|
|
26460
26460
|
}
|
|
26461
26461
|
var ZSTD_FRAME_MAGIC = 4247762216;
|
|
26462
|
-
async function assertSingleCompleteZstdFrame(archivePath) {
|
|
26462
|
+
async function assertSingleCompleteZstdFrame(archivePath, signal) {
|
|
26463
26463
|
const fh = await open2(archivePath, "r");
|
|
26464
26464
|
try {
|
|
26465
26465
|
const { size } = await fh.stat();
|
|
@@ -26469,6 +26469,7 @@ async function assertSingleCompleteZstdFrame(archivePath) {
|
|
|
26469
26469
|
let pos = 0;
|
|
26470
26470
|
const read = async (n) => {
|
|
26471
26471
|
if (pos < windowStart || pos + n > windowEnd) {
|
|
26472
|
+
signal?.throwIfAborted();
|
|
26472
26473
|
const { bytesRead } = await fh.read(window, 0, window.length, pos);
|
|
26473
26474
|
windowStart = pos;
|
|
26474
26475
|
windowEnd = pos + bytesRead;
|
|
@@ -26506,14 +26507,16 @@ function tarEnv(env) {
|
|
|
26506
26507
|
const characterType = env.LC_ALL || env.LC_CTYPE || env.LANG || "";
|
|
26507
26508
|
return /utf-?8/i.test(characterType) ? env : { ...env, LC_ALL: TAR_LOCALE };
|
|
26508
26509
|
}
|
|
26509
|
-
async function runTar(archive, args) {
|
|
26510
|
+
async function runTar(archive, args, signal) {
|
|
26510
26511
|
const child = spawn2("tar", [...args, "-f", "-"], {
|
|
26512
|
+
signal,
|
|
26511
26513
|
env: tarEnv(process.env)
|
|
26512
26514
|
});
|
|
26513
|
-
|
|
26514
|
-
|
|
26515
|
-
|
|
26515
|
+
let childError;
|
|
26516
|
+
child.on("error", (err) => {
|
|
26517
|
+
childError = err;
|
|
26516
26518
|
});
|
|
26519
|
+
const closed = new Promise((resolve10) => child.once("close", resolve10));
|
|
26517
26520
|
const stdout = collect(child.stdout, MAX_LISTING_BYTES, {
|
|
26518
26521
|
maxLines: MAX_LISTING_LINES,
|
|
26519
26522
|
onOverflow: () => child.kill()
|
|
@@ -26540,12 +26543,15 @@ async function runTar(archive, args) {
|
|
|
26540
26543
|
if (err) child.stdin?.destroy();
|
|
26541
26544
|
done(err);
|
|
26542
26545
|
}
|
|
26543
|
-
})
|
|
26546
|
+
}),
|
|
26547
|
+
{ signal }
|
|
26544
26548
|
).then(
|
|
26545
26549
|
() => null,
|
|
26546
26550
|
(err) => err
|
|
26547
26551
|
);
|
|
26548
|
-
const [code, feedError] = await Promise.all([
|
|
26552
|
+
const [code, feedError] = await Promise.all([closed, fed]);
|
|
26553
|
+
signal?.throwIfAborted();
|
|
26554
|
+
if (childError) throw childError;
|
|
26549
26555
|
if (stdout.overflowed()) {
|
|
26550
26556
|
throw new Error(
|
|
26551
26557
|
`tar ${args.join(" ")} listed more than ${MAX_LISTING_LINES} members or ${MAX_LISTING_BYTES >> 20} MiB`
|
|
@@ -26570,21 +26576,22 @@ function isSafeTarMember(memberPath, destDir) {
|
|
|
26570
26576
|
const root = resolve6(destDir);
|
|
26571
26577
|
return resolve6(destDir, normalized).startsWith(root + sep2);
|
|
26572
26578
|
}
|
|
26573
|
-
async function readListing(archive, args) {
|
|
26579
|
+
async function readListing(archive, args, signal) {
|
|
26574
26580
|
try {
|
|
26575
|
-
return await runTar(archive, args);
|
|
26581
|
+
return await runTar(archive, args, signal);
|
|
26576
26582
|
} catch (err) {
|
|
26583
|
+
signal?.throwIfAborted();
|
|
26577
26584
|
throw new ArchiveError(
|
|
26578
26585
|
`Could not read archive: ${err instanceof Error ? err.message : String(err)}`
|
|
26579
26586
|
);
|
|
26580
26587
|
}
|
|
26581
26588
|
}
|
|
26582
|
-
async function listTarMembers(archive) {
|
|
26583
|
-
const stdout = await readListing(archive, ["-t"]);
|
|
26589
|
+
async function listTarMembers(archive, signal) {
|
|
26590
|
+
const stdout = await readListing(archive, ["-t"], signal);
|
|
26584
26591
|
return stdout.split("\n").map((line) => line.trim()).filter((line) => line.length > 0);
|
|
26585
26592
|
}
|
|
26586
|
-
async function assertSafeMemberTypes(archive) {
|
|
26587
|
-
const stdout = await readListing(archive, ["-tv"]);
|
|
26593
|
+
async function assertSafeMemberTypes(archive, signal) {
|
|
26594
|
+
const stdout = await readListing(archive, ["-tv"], signal);
|
|
26588
26595
|
for (const line of stdout.split("\n")) {
|
|
26589
26596
|
if (!line.trim()) continue;
|
|
26590
26597
|
const type = line[0];
|
|
@@ -26604,8 +26611,8 @@ async function assertSafeMemberTypes(archive) {
|
|
|
26604
26611
|
);
|
|
26605
26612
|
}
|
|
26606
26613
|
}
|
|
26607
|
-
async function assertSafeArchive(archive, destDir) {
|
|
26608
|
-
const members2 = await listTarMembers(archive);
|
|
26614
|
+
async function assertSafeArchive(archive, destDir, signal) {
|
|
26615
|
+
const members2 = await listTarMembers(archive, signal);
|
|
26609
26616
|
if (members2.length === 0) {
|
|
26610
26617
|
throw new ArchiveError("Archive is empty.");
|
|
26611
26618
|
}
|
|
@@ -26614,7 +26621,7 @@ async function assertSafeArchive(archive, destDir) {
|
|
|
26614
26621
|
throw new ArchiveError(`Archive contains an unsafe path "${member}" \u2014 refusing extraction.`);
|
|
26615
26622
|
}
|
|
26616
26623
|
}
|
|
26617
|
-
await assertSafeMemberTypes(archive);
|
|
26624
|
+
await assertSafeMemberTypes(archive, signal);
|
|
26618
26625
|
}
|
|
26619
26626
|
async function resolveMember(destDir, expectedName) {
|
|
26620
26627
|
const entries = await readdir3(destDir);
|
|
@@ -26629,19 +26636,24 @@ async function resolveMember(destDir, expectedName) {
|
|
|
26629
26636
|
}
|
|
26630
26637
|
return join9(destDir, real[0]);
|
|
26631
26638
|
}
|
|
26632
|
-
async function safeExtractArchive(archivePath, destDir, expectedName) {
|
|
26639
|
+
async function safeExtractArchive(archivePath, destDir, expectedName, signal) {
|
|
26640
|
+
signal?.throwIfAborted();
|
|
26633
26641
|
let archive;
|
|
26634
26642
|
try {
|
|
26635
26643
|
archive = { path: archivePath, format: await sniffFormat(archivePath) };
|
|
26636
|
-
if (archive.format === "zstd") await assertSingleCompleteZstdFrame(archivePath);
|
|
26644
|
+
if (archive.format === "zstd") await assertSingleCompleteZstdFrame(archivePath, signal);
|
|
26637
26645
|
} catch (err) {
|
|
26646
|
+
signal?.throwIfAborted();
|
|
26638
26647
|
throw new ArchiveError(
|
|
26639
26648
|
`Could not read archive: ${err instanceof Error ? err.message : String(err)}`
|
|
26640
26649
|
);
|
|
26641
26650
|
}
|
|
26642
|
-
await assertSafeArchive(archive, destDir);
|
|
26643
|
-
|
|
26644
|
-
|
|
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;
|
|
26645
26657
|
}
|
|
26646
26658
|
|
|
26647
26659
|
// ../argent-tools-client/src/errors.ts
|
|
@@ -27827,7 +27839,16 @@ function createToolsClient(options = {}) {
|
|
|
27827
27839
|
}
|
|
27828
27840
|
|
|
27829
27841
|
// ../argent-tools-client/src/artifacts.ts
|
|
27830
|
-
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";
|
|
27831
27852
|
import { constants as fsConstants } from "node:fs";
|
|
27832
27853
|
import { tmpdir as tmpdir2 } from "node:os";
|
|
27833
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";
|
|
@@ -27971,16 +27992,22 @@ async function resolveLocalFile(handle) {
|
|
|
27971
27992
|
return null;
|
|
27972
27993
|
}
|
|
27973
27994
|
}
|
|
27974
|
-
async function downloadAndExtractArchive(handle, data, dir) {
|
|
27975
|
-
|
|
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");
|
|
27976
28000
|
try {
|
|
27977
|
-
await writeFile4(tarball, data);
|
|
27978
|
-
|
|
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;
|
|
27979
28007
|
} catch {
|
|
27980
|
-
|
|
27981
|
-
} finally {
|
|
27982
|
-
await rm3(tarball, { force: true }).catch(() => {
|
|
28008
|
+
await rm3(attemptDir, { recursive: true, force: true }).catch(() => {
|
|
27983
28009
|
});
|
|
28010
|
+
return null;
|
|
27984
28011
|
}
|
|
27985
28012
|
}
|
|
27986
28013
|
async function materializeArtifacts(result, ctx) {
|
|
@@ -28066,7 +28093,7 @@ async function materializeArtifacts(result, ctx) {
|
|
|
28066
28093
|
if (!data) return null;
|
|
28067
28094
|
await ensureDir();
|
|
28068
28095
|
if (value.archive === "tar.gz") {
|
|
28069
|
-
return await downloadAndExtractArchive(value, data, dir);
|
|
28096
|
+
return await downloadAndExtractArchive(value, data, dir, ctx.signal);
|
|
28070
28097
|
}
|
|
28071
28098
|
if (value.size > 0 && data.length !== value.size) return null;
|
|
28072
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",
|