@swmansion/argent 0.35.1-next.80 → 0.35.1-next.81
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/bin/argent-android-devtools-0.4.0.apk +0 -0
- package/bin/darwin/argent-macos-helper +0 -0
- package/bin/darwin/ax-service +0 -0
- package/bin/darwin/tvos-ax-service +0 -0
- package/bin/darwin/tvos-hid-daemon +0 -0
- package/bin/network-inspector/network-inspector.jar +0 -0
- package/bin/tcp/ax-service +0 -0
- package/dist/cli-cmds.mjs +345 -307
- package/dist/client.js +121 -88
- package/dist/installer.mjs +306 -271
- package/dist/mcp-server.mjs +196 -163
- package/dist/tool-server.cjs +609 -580
- package/dylibs/libArgentAudio.dylib +0 -0
- package/dylibs/libArgentInjectionBootstrap.dylib +0 -0
- package/dylibs/libKeyboardPatch.dylib +0 -0
- package/dylibs/libNativeDevtoolsIos.dylib +0 -0
- package/dylibs/macos/libArgentInjectionBootstrap.dylib +0 -0
- package/dylibs/macos/libNativeDevtoolsMacos.dylib +0 -0
- package/dylibs/tcp/argent-audio-feeder +0 -0
- package/dylibs/tcp/libArgentAudio.dylib +0 -0
- package/dylibs/tcp/libArgentInjectionBootstrap.dylib +0 -0
- package/dylibs/tcp/libKeyboardPatch.dylib +0 -0
- package/dylibs/tcp/libNativeDevtoolsIos.dylib +0 -0
- package/dylibs/tvos/libArgentInjectionBootstrap.dylib +0 -0
- package/dylibs/tvos/libKeyboardPatch.dylib +0 -0
- package/dylibs/tvos/libNativeDevtoolsIos.dylib +0 -0
- package/package.json +2 -2
package/dist/client.js
CHANGED
|
@@ -7308,14 +7308,14 @@ var require_parser = __commonJS({
|
|
|
7308
7308
|
case "scalar":
|
|
7309
7309
|
case "single-quoted-scalar":
|
|
7310
7310
|
case "double-quoted-scalar": {
|
|
7311
|
-
const
|
|
7311
|
+
const fs12 = this.flowScalar(this.type);
|
|
7312
7312
|
if (atNextItem || it.value) {
|
|
7313
|
-
map.items.push({ start, key:
|
|
7313
|
+
map.items.push({ start, key: fs12, sep: [] });
|
|
7314
7314
|
this.onKeyLine = true;
|
|
7315
7315
|
} else if (it.sep) {
|
|
7316
|
-
this.stack.push(
|
|
7316
|
+
this.stack.push(fs12);
|
|
7317
7317
|
} else {
|
|
7318
|
-
Object.assign(it, { key:
|
|
7318
|
+
Object.assign(it, { key: fs12, sep: [] });
|
|
7319
7319
|
this.onKeyLine = true;
|
|
7320
7320
|
}
|
|
7321
7321
|
return;
|
|
@@ -7443,13 +7443,13 @@ var require_parser = __commonJS({
|
|
|
7443
7443
|
case "scalar":
|
|
7444
7444
|
case "single-quoted-scalar":
|
|
7445
7445
|
case "double-quoted-scalar": {
|
|
7446
|
-
const
|
|
7446
|
+
const fs12 = this.flowScalar(this.type);
|
|
7447
7447
|
if (!it || it.value)
|
|
7448
|
-
fc.items.push({ start: [], key:
|
|
7448
|
+
fc.items.push({ start: [], key: fs12, sep: [] });
|
|
7449
7449
|
else if (it.sep)
|
|
7450
|
-
this.stack.push(
|
|
7450
|
+
this.stack.push(fs12);
|
|
7451
7451
|
else
|
|
7452
|
-
Object.assign(it, { key:
|
|
7452
|
+
Object.assign(it, { key: fs12, sep: [] });
|
|
7453
7453
|
return;
|
|
7454
7454
|
}
|
|
7455
7455
|
case "flow-map-end":
|
|
@@ -7758,7 +7758,7 @@ var require_dist2 = __commonJS({
|
|
|
7758
7758
|
});
|
|
7759
7759
|
|
|
7760
7760
|
// ../configuration-core/src/flags.ts
|
|
7761
|
-
import * as
|
|
7761
|
+
import * as fs2 from "node:fs";
|
|
7762
7762
|
import * as path2 from "node:path";
|
|
7763
7763
|
|
|
7764
7764
|
// ../configuration-core/src/home.ts
|
|
@@ -7779,6 +7779,43 @@ function argentHomeDir(options = {}) {
|
|
|
7779
7779
|
return override ? path.resolve(override.trim()) : path.join(resolveHomeDir(options), ".argent");
|
|
7780
7780
|
}
|
|
7781
7781
|
|
|
7782
|
+
// ../configuration-core/src/write-file.ts
|
|
7783
|
+
import * as fs from "node:fs";
|
|
7784
|
+
import { randomBytes } from "node:crypto";
|
|
7785
|
+
function writeFileAtomicSync(file, data, mode = 438) {
|
|
7786
|
+
const tmp = `${file}.${randomBytes(8).toString("hex")}.tmp`;
|
|
7787
|
+
try {
|
|
7788
|
+
fs.writeFileSync(tmp, data, { flag: "wx", mode });
|
|
7789
|
+
fs.renameSync(tmp, file);
|
|
7790
|
+
} catch (err) {
|
|
7791
|
+
fs.rmSync(tmp, { force: true });
|
|
7792
|
+
if (err.code !== "EBUSY" || !writeOwnFileInPlace(file, data, mode)) {
|
|
7793
|
+
throw err;
|
|
7794
|
+
}
|
|
7795
|
+
}
|
|
7796
|
+
}
|
|
7797
|
+
var IN_PLACE_FLAGS = fs.constants.O_WRONLY | fs.constants.O_NOFOLLOW | fs.constants.O_NONBLOCK;
|
|
7798
|
+
function writeOwnFileInPlace(file, data, mode) {
|
|
7799
|
+
const uid = process.getuid?.();
|
|
7800
|
+
if (uid === void 0) return false;
|
|
7801
|
+
let fd;
|
|
7802
|
+
try {
|
|
7803
|
+
fd = fs.openSync(file, IN_PLACE_FLAGS);
|
|
7804
|
+
} catch {
|
|
7805
|
+
return false;
|
|
7806
|
+
}
|
|
7807
|
+
try {
|
|
7808
|
+
const stat6 = fs.fstatSync(fd);
|
|
7809
|
+
if (!stat6.isFile() || stat6.uid !== uid && uid !== 0) return false;
|
|
7810
|
+
fs.fchmodSync(fd, stat6.mode & mode & 511);
|
|
7811
|
+
fs.ftruncateSync(fd);
|
|
7812
|
+
fs.writeFileSync(fd, data);
|
|
7813
|
+
return true;
|
|
7814
|
+
} finally {
|
|
7815
|
+
fs.closeSync(fd);
|
|
7816
|
+
}
|
|
7817
|
+
}
|
|
7818
|
+
|
|
7782
7819
|
// ../configuration-core/src/flags.ts
|
|
7783
7820
|
var FLAG_REGISTRY = [
|
|
7784
7821
|
{
|
|
@@ -7846,7 +7883,7 @@ function findProjectRoot(startDir) {
|
|
|
7846
7883
|
let current = path2.resolve(startDir);
|
|
7847
7884
|
while (true) {
|
|
7848
7885
|
for (const marker of PROJECT_MARKERS) {
|
|
7849
|
-
if (
|
|
7886
|
+
if (fs2.existsSync(path2.join(current, marker))) return current;
|
|
7850
7887
|
}
|
|
7851
7888
|
const parent = path2.dirname(current);
|
|
7852
7889
|
if (parent === current) return null;
|
|
@@ -7866,7 +7903,7 @@ function getFlagsPath(scope, options = {}) {
|
|
|
7866
7903
|
function readFlagsFile(filePath) {
|
|
7867
7904
|
let raw;
|
|
7868
7905
|
try {
|
|
7869
|
-
raw =
|
|
7906
|
+
raw = fs2.readFileSync(filePath, "utf8");
|
|
7870
7907
|
} catch {
|
|
7871
7908
|
return {};
|
|
7872
7909
|
}
|
|
@@ -7903,14 +7940,14 @@ function isFeatureEnabled(name, options = {}, registry = FLAG_REGISTRY) {
|
|
|
7903
7940
|
}
|
|
7904
7941
|
|
|
7905
7942
|
// ../configuration-core/src/paths.ts
|
|
7906
|
-
import * as
|
|
7943
|
+
import * as fs3 from "node:fs";
|
|
7907
7944
|
import * as path3 from "node:path";
|
|
7908
7945
|
function isHomeDir(dir, options = {}) {
|
|
7909
7946
|
return canonicalPath(dir) === canonicalPath(resolveHomeDir(options));
|
|
7910
7947
|
}
|
|
7911
7948
|
function canonicalPath(p) {
|
|
7912
7949
|
try {
|
|
7913
|
-
return
|
|
7950
|
+
return fs3.realpathSync.native(p);
|
|
7914
7951
|
} catch {
|
|
7915
7952
|
return path3.resolve(p);
|
|
7916
7953
|
}
|
|
@@ -7926,11 +7963,11 @@ function configFilePath(scope = "global", options = {}) {
|
|
|
7926
7963
|
|
|
7927
7964
|
// ../configuration-core/src/config.ts
|
|
7928
7965
|
import * as crypto from "node:crypto";
|
|
7929
|
-
import * as
|
|
7966
|
+
import * as fs4 from "node:fs";
|
|
7930
7967
|
import * as path4 from "node:path";
|
|
7931
7968
|
function readConfigObject(scope = "global", options = {}) {
|
|
7932
7969
|
try {
|
|
7933
|
-
const raw =
|
|
7970
|
+
const raw = fs4.readFileSync(configFilePath(scope, options), "utf8");
|
|
7934
7971
|
const json = JSON.parse(raw);
|
|
7935
7972
|
if (json && typeof json === "object" && !Array.isArray(json)) {
|
|
7936
7973
|
return json;
|
|
@@ -7967,7 +8004,7 @@ function getAtPath(obj, dottedKey) {
|
|
|
7967
8004
|
|
|
7968
8005
|
// ../configuration-core/src/secrets.ts
|
|
7969
8006
|
var import_dotenv = __toESM(require_dist(), 1);
|
|
7970
|
-
import * as
|
|
8007
|
+
import * as fs5 from "node:fs";
|
|
7971
8008
|
import * as path5 from "node:path";
|
|
7972
8009
|
var SECRET_ENV_PREFIX = "ARGENT_SECRET_";
|
|
7973
8010
|
var SECRETS_FILE_NAME = "secrets.env";
|
|
@@ -7997,10 +8034,10 @@ function fileSource(filePath, exposure) {
|
|
|
7997
8034
|
names: [],
|
|
7998
8035
|
values: /* @__PURE__ */ new Map()
|
|
7999
8036
|
};
|
|
8000
|
-
if (!
|
|
8037
|
+
if (!fs5.statSync(filePath, { throwIfNoEntry: false })) return absent;
|
|
8001
8038
|
let content;
|
|
8002
8039
|
try {
|
|
8003
|
-
content =
|
|
8040
|
+
content = fs5.readFileSync(filePath, "utf8");
|
|
8004
8041
|
} catch {
|
|
8005
8042
|
return absent;
|
|
8006
8043
|
}
|
|
@@ -8010,7 +8047,7 @@ function secretsFileSource(filePath) {
|
|
|
8010
8047
|
const resolved = path5.resolve(filePath);
|
|
8011
8048
|
let content;
|
|
8012
8049
|
try {
|
|
8013
|
-
content =
|
|
8050
|
+
content = fs5.readFileSync(resolved, "utf8");
|
|
8014
8051
|
} catch (err) {
|
|
8015
8052
|
const code = err.code;
|
|
8016
8053
|
const reason = code === "ENOENT" ? "no such file" : code === "EISDIR" ? "it is a directory" : code === "EACCES" ? "permission denied" : err instanceof Error ? err.message : String(err);
|
|
@@ -8292,7 +8329,7 @@ function getConfigDefinition(key, registry = CONFIG_SCHEMA) {
|
|
|
8292
8329
|
}
|
|
8293
8330
|
|
|
8294
8331
|
// ../configuration-core/src/config-access.ts
|
|
8295
|
-
import * as
|
|
8332
|
+
import * as fs6 from "node:fs";
|
|
8296
8333
|
import * as path6 from "node:path";
|
|
8297
8334
|
function readScopeValue(def, scope, options) {
|
|
8298
8335
|
if (!def.scopes.includes(scope)) return void 0;
|
|
@@ -8329,7 +8366,7 @@ var UnknownConfigKeyError = class extends Error {
|
|
|
8329
8366
|
};
|
|
8330
8367
|
|
|
8331
8368
|
// ../configuration-core/src/cloud-android.ts
|
|
8332
|
-
import * as
|
|
8369
|
+
import * as fs7 from "node:fs";
|
|
8333
8370
|
import * as os2 from "node:os";
|
|
8334
8371
|
import * as path7 from "node:path";
|
|
8335
8372
|
var CLOUD_URL_ENV = "ARGENT_CLOUD_URL";
|
|
@@ -8381,8 +8418,8 @@ function untrusted(dir) {
|
|
|
8381
8418
|
let stat6;
|
|
8382
8419
|
let parent;
|
|
8383
8420
|
try {
|
|
8384
|
-
stat6 =
|
|
8385
|
-
parent =
|
|
8421
|
+
stat6 = fs7.lstatSync(dir);
|
|
8422
|
+
parent = fs7.statSync(path7.dirname(dir));
|
|
8386
8423
|
} catch {
|
|
8387
8424
|
return "it cannot be read";
|
|
8388
8425
|
}
|
|
@@ -8401,14 +8438,14 @@ function trustedCloudAndroidMarkersDir() {
|
|
|
8401
8438
|
var CLOUD_ANDROID_MARKER_TTL_MS = 2 * 6e4;
|
|
8402
8439
|
function readCloudAndroidMarker(file) {
|
|
8403
8440
|
try {
|
|
8404
|
-
const raw = JSON.parse(
|
|
8441
|
+
const raw = JSON.parse(fs7.readFileSync(file, "utf8"));
|
|
8405
8442
|
if (typeof raw.pid !== "number" || typeof raw.lease !== "string") return null;
|
|
8406
8443
|
if (typeof raw.serial !== "string") return null;
|
|
8407
8444
|
return {
|
|
8408
8445
|
serial: raw.serial,
|
|
8409
8446
|
pid: raw.pid,
|
|
8410
8447
|
lease: raw.lease,
|
|
8411
|
-
refreshedAt:
|
|
8448
|
+
refreshedAt: fs7.statSync(file).mtimeMs
|
|
8412
8449
|
};
|
|
8413
8450
|
} catch {
|
|
8414
8451
|
return null;
|
|
@@ -8418,7 +8455,7 @@ function readCloudAndroidMarkers(dir = trustedCloudAndroidMarkersDir()) {
|
|
|
8418
8455
|
if (!dir) return [];
|
|
8419
8456
|
let names;
|
|
8420
8457
|
try {
|
|
8421
|
-
names =
|
|
8458
|
+
names = fs7.readdirSync(dir);
|
|
8422
8459
|
} catch {
|
|
8423
8460
|
return [];
|
|
8424
8461
|
}
|
|
@@ -8445,11 +8482,11 @@ function cloudAndroidLeaseHolders(dir = trustedCloudAndroidMarkersDir()) {
|
|
|
8445
8482
|
// ../argent-tools-client/src/launcher.ts
|
|
8446
8483
|
import * as net from "node:net";
|
|
8447
8484
|
import * as os3 from "node:os";
|
|
8448
|
-
import * as
|
|
8485
|
+
import * as fs8 from "node:fs";
|
|
8449
8486
|
import * as path8 from "node:path";
|
|
8450
8487
|
import * as readline from "node:readline";
|
|
8451
8488
|
import { spawn, execFileSync } from "node:child_process";
|
|
8452
|
-
import { createHash, randomBytes } from "node:crypto";
|
|
8489
|
+
import { createHash, randomBytes as randomBytes2 } from "node:crypto";
|
|
8453
8490
|
import { readFile, readdir, unlink } from "node:fs/promises";
|
|
8454
8491
|
var STATE_DIR = argentHomeDir();
|
|
8455
8492
|
var STATE_FILE = path8.join(STATE_DIR, "tool-server.json");
|
|
@@ -8496,7 +8533,7 @@ function buildToolsServerEnv(paths, port, baseEnv = process.env, options = {}) {
|
|
|
8496
8533
|
return env;
|
|
8497
8534
|
}
|
|
8498
8535
|
function generateToken() {
|
|
8499
|
-
return
|
|
8536
|
+
return randomBytes2(AUTH_TOKEN_BYTES).toString("hex");
|
|
8500
8537
|
}
|
|
8501
8538
|
function findFreePort() {
|
|
8502
8539
|
return new Promise((resolve12, reject) => {
|
|
@@ -8552,7 +8589,7 @@ function isVersionNewer(a, b) {
|
|
|
8552
8589
|
function readBundlePackageVersion(bundlePath) {
|
|
8553
8590
|
try {
|
|
8554
8591
|
const pkg = JSON.parse(
|
|
8555
|
-
|
|
8592
|
+
fs8.readFileSync(path8.join(path8.dirname(bundlePath), "..", "package.json"), "utf8")
|
|
8556
8593
|
);
|
|
8557
8594
|
return typeof pkg.version === "string" ? pkg.version : void 0;
|
|
8558
8595
|
} catch {
|
|
@@ -8609,7 +8646,7 @@ function killSpawnedChild(child, pid) {
|
|
|
8609
8646
|
}
|
|
8610
8647
|
function resolveToolsServerNode() {
|
|
8611
8648
|
const { bun, deno, electron } = process.versions;
|
|
8612
|
-
return !(bun || deno || electron) &&
|
|
8649
|
+
return !(bun || deno || electron) && fs8.existsSync(process.execPath) ? process.execPath : "node";
|
|
8613
8650
|
}
|
|
8614
8651
|
function parseListeningPort(line) {
|
|
8615
8652
|
const match = line.match(/Tools server listening on http:\/\/.+:(\d+)/);
|
|
@@ -8619,10 +8656,10 @@ function spawnToolsServer(paths, port, options = {}) {
|
|
|
8619
8656
|
return new Promise((resolve12, reject) => {
|
|
8620
8657
|
let logFd;
|
|
8621
8658
|
try {
|
|
8622
|
-
|
|
8623
|
-
logFd =
|
|
8659
|
+
fs8.mkdirSync(STATE_DIR, { recursive: true });
|
|
8660
|
+
logFd = fs8.openSync(LOG_FILE, "a");
|
|
8624
8661
|
} catch {
|
|
8625
|
-
logFd =
|
|
8662
|
+
logFd = fs8.openSync("/dev/null", "w");
|
|
8626
8663
|
}
|
|
8627
8664
|
const nodeBin = resolveToolsServerNode();
|
|
8628
8665
|
const child = spawn(nodeBin, [paths.bundlePath, "start"], {
|
|
@@ -8630,7 +8667,7 @@ function spawnToolsServer(paths, port, options = {}) {
|
|
|
8630
8667
|
stdio: ["ignore", "pipe", logFd],
|
|
8631
8668
|
env: buildToolsServerEnv(paths, port, process.env, options)
|
|
8632
8669
|
});
|
|
8633
|
-
|
|
8670
|
+
fs8.closeSync(logFd);
|
|
8634
8671
|
const pid = child.pid;
|
|
8635
8672
|
if (!pid) {
|
|
8636
8673
|
child.once(
|
|
@@ -8715,19 +8752,19 @@ var UnsafeArgentHomeError = class extends Error {
|
|
|
8715
8752
|
};
|
|
8716
8753
|
function statHome() {
|
|
8717
8754
|
try {
|
|
8718
|
-
|
|
8719
|
-
|
|
8755
|
+
fs8.mkdirSync(path8.dirname(STATE_DIR), { recursive: true });
|
|
8756
|
+
fs8.mkdirSync(STATE_DIR, { mode: 448 });
|
|
8720
8757
|
} catch {
|
|
8721
8758
|
}
|
|
8722
8759
|
try {
|
|
8723
|
-
return
|
|
8760
|
+
return fs8.statSync(STATE_DIR);
|
|
8724
8761
|
} catch {
|
|
8725
8762
|
return null;
|
|
8726
8763
|
}
|
|
8727
8764
|
}
|
|
8728
8765
|
function isWritable(dir) {
|
|
8729
8766
|
try {
|
|
8730
|
-
|
|
8767
|
+
fs8.accessSync(dir, fs8.constants.W_OK);
|
|
8731
8768
|
return true;
|
|
8732
8769
|
} catch {
|
|
8733
8770
|
return false;
|
|
@@ -8755,16 +8792,12 @@ async function writeToolsServerState(state) {
|
|
|
8755
8792
|
writeToolsServerStateSync(state);
|
|
8756
8793
|
}
|
|
8757
8794
|
function writeToolsServerStateSync(state) {
|
|
8758
|
-
|
|
8759
|
-
|
|
8760
|
-
|
|
8761
|
-
|
|
8762
|
-
|
|
8763
|
-
|
|
8764
|
-
} catch (err) {
|
|
8765
|
-
fs7.rmSync(tmp, { force: true });
|
|
8766
|
-
throw err;
|
|
8767
|
-
}
|
|
8795
|
+
fs8.mkdirSync(STATE_DIR, { recursive: true });
|
|
8796
|
+
writeFileAtomicSync(
|
|
8797
|
+
stateFileForBundle(state.bundlePath, state.cloudProfile),
|
|
8798
|
+
JSON.stringify(state, null, 2) + "\n",
|
|
8799
|
+
384
|
|
8800
|
+
);
|
|
8768
8801
|
}
|
|
8769
8802
|
async function clearToolsServerState(bundlePath, cloudProfile) {
|
|
8770
8803
|
const files = [STATE_FILE];
|
|
@@ -8809,7 +8842,7 @@ async function sweepDeadStateFiles() {
|
|
|
8809
8842
|
});
|
|
8810
8843
|
continue;
|
|
8811
8844
|
}
|
|
8812
|
-
if (
|
|
8845
|
+
if (fs8.existsSync(fresh.bundlePath)) continue;
|
|
8813
8846
|
if (!couldBeOurToolServer(fresh.pid, fresh.bundlePath)) continue;
|
|
8814
8847
|
await unlink(file).catch(() => {
|
|
8815
8848
|
});
|
|
@@ -8860,7 +8893,7 @@ function clientCloudProfile(env = process.env) {
|
|
|
8860
8893
|
const cloud = cloudCredential(env);
|
|
8861
8894
|
return cloud ? cloudProfileId(cloud) : void 0;
|
|
8862
8895
|
}
|
|
8863
|
-
var PS_BIN = ["/bin/ps", "/usr/bin/ps"].find((p) =>
|
|
8896
|
+
var PS_BIN = ["/bin/ps", "/usr/bin/ps"].find((p) => fs8.existsSync(p)) ?? "ps";
|
|
8864
8897
|
var PS_WIDTH_FLAGS = ["-ww"];
|
|
8865
8898
|
var PS_LOCALE = process.platform === "darwin" ? "en_US.UTF-8" : "C.UTF-8";
|
|
8866
8899
|
function readProcessCommandLine(pid, flags = PS_WIDTH_FLAGS, env = { ...process.env, LC_ALL: PS_LOCALE }) {
|
|
@@ -8907,13 +8940,13 @@ var LOCK_STALE_MS = 45e3;
|
|
|
8907
8940
|
var LOCK_POLL_MS = 100;
|
|
8908
8941
|
function spawnLockIsStale() {
|
|
8909
8942
|
try {
|
|
8910
|
-
const { pid, ts } = JSON.parse(
|
|
8943
|
+
const { pid, ts } = JSON.parse(fs8.readFileSync(LOCK_FILE, "utf8"));
|
|
8911
8944
|
if (typeof pid === "number" && pid > 0 && !isProcessAlive(pid)) return true;
|
|
8912
8945
|
if (typeof ts === "number" && Date.now() - ts > LOCK_STALE_MS) return true;
|
|
8913
8946
|
return false;
|
|
8914
8947
|
} catch {
|
|
8915
8948
|
try {
|
|
8916
|
-
return Date.now() -
|
|
8949
|
+
return Date.now() - fs8.statSync(LOCK_FILE).mtimeMs > LOCK_STALE_MS;
|
|
8917
8950
|
} catch {
|
|
8918
8951
|
return true;
|
|
8919
8952
|
}
|
|
@@ -8921,19 +8954,19 @@ function spawnLockIsStale() {
|
|
|
8921
8954
|
}
|
|
8922
8955
|
async function acquireSpawnLock() {
|
|
8923
8956
|
try {
|
|
8924
|
-
|
|
8957
|
+
fs8.mkdirSync(STATE_DIR, { recursive: true });
|
|
8925
8958
|
} catch {
|
|
8926
8959
|
return null;
|
|
8927
8960
|
}
|
|
8928
|
-
const nonce =
|
|
8961
|
+
const nonce = randomBytes2(8).toString("hex");
|
|
8929
8962
|
const deadline = Date.now() + LOCK_WAIT_TIMEOUT_MS;
|
|
8930
8963
|
for (; ; ) {
|
|
8931
8964
|
try {
|
|
8932
|
-
const fd =
|
|
8965
|
+
const fd = fs8.openSync(LOCK_FILE, "wx");
|
|
8933
8966
|
try {
|
|
8934
|
-
|
|
8967
|
+
fs8.writeSync(fd, JSON.stringify({ pid: process.pid, nonce, ts: Date.now() }));
|
|
8935
8968
|
} finally {
|
|
8936
|
-
|
|
8969
|
+
fs8.closeSync(fd);
|
|
8937
8970
|
}
|
|
8938
8971
|
let released = false;
|
|
8939
8972
|
return {
|
|
@@ -8941,8 +8974,8 @@ async function acquireSpawnLock() {
|
|
|
8941
8974
|
if (released) return;
|
|
8942
8975
|
released = true;
|
|
8943
8976
|
try {
|
|
8944
|
-
const cur = JSON.parse(
|
|
8945
|
-
if (cur.pid === process.pid && cur.nonce === nonce)
|
|
8977
|
+
const cur = JSON.parse(fs8.readFileSync(LOCK_FILE, "utf8"));
|
|
8978
|
+
if (cur.pid === process.pid && cur.nonce === nonce) fs8.unlinkSync(LOCK_FILE);
|
|
8946
8979
|
} catch {
|
|
8947
8980
|
}
|
|
8948
8981
|
}
|
|
@@ -8951,10 +8984,10 @@ async function acquireSpawnLock() {
|
|
|
8951
8984
|
if (err.code !== "EEXIST") return null;
|
|
8952
8985
|
if (spawnLockIsStale()) {
|
|
8953
8986
|
try {
|
|
8954
|
-
|
|
8987
|
+
fs8.unlinkSync(LOCK_FILE);
|
|
8955
8988
|
} catch {
|
|
8956
8989
|
}
|
|
8957
|
-
if (!
|
|
8990
|
+
if (!fs8.existsSync(LOCK_FILE)) continue;
|
|
8958
8991
|
}
|
|
8959
8992
|
if (Date.now() >= deadline) return null;
|
|
8960
8993
|
await new Promise((r) => setTimeout(r, LOCK_POLL_MS));
|
|
@@ -8995,7 +9028,7 @@ async function ensureToolsServer(paths, env = process.env) {
|
|
|
8995
9028
|
}
|
|
8996
9029
|
await clearToolsServerState(paths.bundlePath, cloudProfile);
|
|
8997
9030
|
await sweepDeadStateFiles();
|
|
8998
|
-
if (!
|
|
9031
|
+
if (!fs8.existsSync(paths.bundlePath)) {
|
|
8999
9032
|
throw new Error(
|
|
9000
9033
|
`The argent install serving this session is gone from disk (${paths.bundlePath}) \u2014 it was likely updated or removed. Restart the editor's MCP connection to reconnect.`
|
|
9001
9034
|
);
|
|
@@ -9101,11 +9134,11 @@ var LAUNCH_PLATFORMS = ["ios", "android", "chromium", "vega", "macos"];
|
|
|
9101
9134
|
var SELECTABLE_PLATFORMS = [...LAUNCH_PLATFORMS, "ios-remote"];
|
|
9102
9135
|
|
|
9103
9136
|
// ../registry/src/flow-file-refs.ts
|
|
9104
|
-
import * as
|
|
9137
|
+
import * as fs10 from "node:fs/promises";
|
|
9105
9138
|
import * as path10 from "node:path";
|
|
9106
9139
|
|
|
9107
9140
|
// ../registry/src/e2e-dirs.ts
|
|
9108
|
-
import * as
|
|
9141
|
+
import * as fs9 from "node:fs/promises";
|
|
9109
9142
|
import * as path9 from "node:path";
|
|
9110
9143
|
var E2E_DIR = path9.join(".argent", "e2e");
|
|
9111
9144
|
var LEGACY_E2E_DIRS = Object.freeze([path9.join(".argent", "flows")]);
|
|
@@ -9120,7 +9153,7 @@ function e2eFileCandidates(projectRoot, name) {
|
|
|
9120
9153
|
return e2eDirsFor(projectRoot).map((dir) => path9.join(dir, `${name}.yaml`));
|
|
9121
9154
|
}
|
|
9122
9155
|
async function exists(file) {
|
|
9123
|
-
return
|
|
9156
|
+
return fs9.stat(file).then(
|
|
9124
9157
|
() => true,
|
|
9125
9158
|
() => false
|
|
9126
9159
|
);
|
|
@@ -9211,10 +9244,10 @@ function canonicalToolArgs(tool, args) {
|
|
|
9211
9244
|
// ../registry/src/flow-file-refs.ts
|
|
9212
9245
|
async function canonicalFlowPath(p) {
|
|
9213
9246
|
try {
|
|
9214
|
-
return await
|
|
9247
|
+
return await fs10.realpath(p);
|
|
9215
9248
|
} catch {
|
|
9216
9249
|
try {
|
|
9217
|
-
return path10.join(await
|
|
9250
|
+
return path10.join(await fs10.realpath(path10.dirname(p)), path10.basename(p));
|
|
9218
9251
|
} catch {
|
|
9219
9252
|
return p;
|
|
9220
9253
|
}
|
|
@@ -9274,7 +9307,7 @@ function flowMemberKey(anchorDir, target) {
|
|
|
9274
9307
|
return `${anchorDir}\0${target}`;
|
|
9275
9308
|
}
|
|
9276
9309
|
async function classifyOnDiskSpelling(dir, base, addressable = FLOW_FILE_NAME_PATTERN) {
|
|
9277
|
-
const entries = await
|
|
9310
|
+
const entries = await fs10.readdir(dir).catch(() => null);
|
|
9278
9311
|
if (entries === null || entries.includes(base)) return { state: "listed" };
|
|
9279
9312
|
const actual = entries.find((entry) => entry.toLowerCase() === base.toLowerCase());
|
|
9280
9313
|
if (actual === void 0) return { state: "absent" };
|
|
@@ -9842,7 +9875,7 @@ function describeParamIssues(error, params) {
|
|
|
9842
9875
|
|
|
9843
9876
|
// ../argent-tools-client/src/link-config.ts
|
|
9844
9877
|
import * as path11 from "node:path";
|
|
9845
|
-
import { mkdir,
|
|
9878
|
+
import { mkdir, readFile as readFile2, unlink as unlink2 } from "node:fs/promises";
|
|
9846
9879
|
var LINK_DIR = argentHomeDir();
|
|
9847
9880
|
var LINK_FILE = path11.join(LINK_DIR, "link.json");
|
|
9848
9881
|
async function readLinkConfig() {
|
|
@@ -9886,7 +9919,7 @@ async function getResolvedToolsUrl() {
|
|
|
9886
9919
|
import { createHash as createHash2, randomUUID as randomUUID4 } from "node:crypto";
|
|
9887
9920
|
import { createReadStream as createReadStream2, rmSync as rmSync3 } from "node:fs";
|
|
9888
9921
|
import {
|
|
9889
|
-
chmod
|
|
9922
|
+
chmod,
|
|
9890
9923
|
lstat,
|
|
9891
9924
|
mkdir as mkdir2,
|
|
9892
9925
|
readFile as readFile3,
|
|
@@ -9894,9 +9927,9 @@ import {
|
|
|
9894
9927
|
rename,
|
|
9895
9928
|
rm as rm2,
|
|
9896
9929
|
stat as stat3,
|
|
9897
|
-
writeFile
|
|
9930
|
+
writeFile
|
|
9898
9931
|
} from "node:fs/promises";
|
|
9899
|
-
import { constants as
|
|
9932
|
+
import { constants as constants3, tmpdir } from "node:os";
|
|
9900
9933
|
import * as path12 from "node:path";
|
|
9901
9934
|
|
|
9902
9935
|
// ../archive/src/index.ts
|
|
@@ -10274,7 +10307,7 @@ function removeArchivesOnSignal(signal) {
|
|
|
10274
10307
|
try {
|
|
10275
10308
|
process.kill(process.pid, signal);
|
|
10276
10309
|
} catch {
|
|
10277
|
-
process.exit(128 +
|
|
10310
|
+
process.exit(128 + constants3.signals[signal]);
|
|
10278
10311
|
}
|
|
10279
10312
|
}
|
|
10280
10313
|
function trackArchive(archive) {
|
|
@@ -10449,8 +10482,8 @@ function isClientFileDirective2(value) {
|
|
|
10449
10482
|
async function replaceFile(target, bytes, mode) {
|
|
10450
10483
|
const temp = path12.join(path12.dirname(target), `.baseline-${randomUUID4()}.tmp`);
|
|
10451
10484
|
try {
|
|
10452
|
-
await
|
|
10453
|
-
if (mode !== void 0) await
|
|
10485
|
+
await writeFile(temp, bytes, { flag: "wx" });
|
|
10486
|
+
if (mode !== void 0) await chmod(temp, mode & 511);
|
|
10454
10487
|
await rename(temp, target);
|
|
10455
10488
|
} catch (err) {
|
|
10456
10489
|
await rm2(temp, { force: true });
|
|
@@ -10505,7 +10538,7 @@ async function applyClientFileDirectives(result, opts = {}) {
|
|
|
10505
10538
|
if (!isAllowedClientFilePath(value.path)) return null;
|
|
10506
10539
|
try {
|
|
10507
10540
|
await mkdir2(path12.dirname(value.path), { recursive: true });
|
|
10508
|
-
await
|
|
10541
|
+
await writeFile(value.path, value.content, "utf8");
|
|
10509
10542
|
written.push(value.path);
|
|
10510
10543
|
return value.path;
|
|
10511
10544
|
} catch {
|
|
@@ -11544,7 +11577,7 @@ import {
|
|
|
11544
11577
|
realpath as realpath4,
|
|
11545
11578
|
rm as rm3,
|
|
11546
11579
|
stat as stat5,
|
|
11547
|
-
writeFile as
|
|
11580
|
+
writeFile as writeFile2
|
|
11548
11581
|
} from "node:fs/promises";
|
|
11549
11582
|
import { constants as fsConstants } from "node:fs";
|
|
11550
11583
|
import { tmpdir as tmpdir2 } from "node:os";
|
|
@@ -11695,7 +11728,7 @@ async function downloadAndExtractArchive(handle, data, dir, signal) {
|
|
|
11695
11728
|
const tarball = join15(attemptDir, "download.tar");
|
|
11696
11729
|
const extractDir = join15(attemptDir, "files");
|
|
11697
11730
|
try {
|
|
11698
|
-
await
|
|
11731
|
+
await writeFile2(tarball, data, { signal });
|
|
11699
11732
|
await mkdir3(extractDir);
|
|
11700
11733
|
const member = await safeExtractArchive(tarball, extractDir, handle.filename, signal);
|
|
11701
11734
|
await rm3(tarball);
|
|
@@ -11759,7 +11792,7 @@ async function materializeArtifacts(result, ctx) {
|
|
|
11759
11792
|
const finalPath = await writeDurableUnique(
|
|
11760
11793
|
saveTarget.dir,
|
|
11761
11794
|
filename,
|
|
11762
|
-
(p) =>
|
|
11795
|
+
(p) => writeFile2(p, data, { flag: "wx" })
|
|
11763
11796
|
);
|
|
11764
11797
|
if (!finalPath) return null;
|
|
11765
11798
|
if (value.mimeType.startsWith("image/")) {
|
|
@@ -11794,7 +11827,7 @@ async function materializeArtifacts(result, ctx) {
|
|
|
11794
11827
|
}
|
|
11795
11828
|
if (value.size > 0 && data.length !== value.size) return null;
|
|
11796
11829
|
const downloadedPath = join15(dir, sanitizeSegment(value.filename));
|
|
11797
|
-
await
|
|
11830
|
+
await writeFile2(downloadedPath, data);
|
|
11798
11831
|
if (value.mimeType.startsWith("image/")) {
|
|
11799
11832
|
images.push({ localPath: downloadedPath, data, mimeType: value.mimeType });
|
|
11800
11833
|
}
|
|
@@ -11827,12 +11860,12 @@ function getDeviceIdFromArgs(args) {
|
|
|
11827
11860
|
}
|
|
11828
11861
|
|
|
11829
11862
|
// src/bundled-paths.ts
|
|
11830
|
-
import * as
|
|
11863
|
+
import * as fs11 from "node:fs";
|
|
11831
11864
|
import * as path15 from "node:path";
|
|
11832
11865
|
function readPackageVersion() {
|
|
11833
11866
|
try {
|
|
11834
11867
|
const pkg = JSON.parse(
|
|
11835
|
-
|
|
11868
|
+
fs11.readFileSync(path15.join(import.meta.dirname, "..", "package.json"), "utf8")
|
|
11836
11869
|
);
|
|
11837
11870
|
return pkg.version;
|
|
11838
11871
|
} catch {
|
|
@@ -11843,9 +11876,9 @@ var PACKAGE_NAME = "@swmansion/argent";
|
|
|
11843
11876
|
function findDeclaringRoot(startDir) {
|
|
11844
11877
|
let dir = startDir;
|
|
11845
11878
|
for (; ; ) {
|
|
11846
|
-
if (
|
|
11879
|
+
if (fs11.existsSync(path15.join(dir, ".argent", "install.json"))) return dir;
|
|
11847
11880
|
try {
|
|
11848
|
-
const manifest = JSON.parse(
|
|
11881
|
+
const manifest = JSON.parse(fs11.readFileSync(path15.join(dir, "package.json"), "utf8"));
|
|
11849
11882
|
if (manifest.devDependencies?.[PACKAGE_NAME] || manifest.dependencies?.[PACKAGE_NAME] || manifest.optionalDependencies?.[PACKAGE_NAME]) {
|
|
11850
11883
|
return dir;
|
|
11851
11884
|
}
|
|
@@ -11861,7 +11894,7 @@ function findStablePackageDir(startDir, packageRoot) {
|
|
|
11861
11894
|
for (; ; ) {
|
|
11862
11895
|
const candidate = path15.join(dir, "node_modules", PACKAGE_NAME);
|
|
11863
11896
|
try {
|
|
11864
|
-
if (
|
|
11897
|
+
if (fs11.realpathSync(candidate) === packageRoot) return candidate;
|
|
11865
11898
|
} catch {
|
|
11866
11899
|
}
|
|
11867
11900
|
const parent = path15.dirname(dir);
|
|
@@ -11874,7 +11907,7 @@ function classifyInstall() {
|
|
|
11874
11907
|
let dir;
|
|
11875
11908
|
let cwd;
|
|
11876
11909
|
try {
|
|
11877
|
-
packageRoot =
|
|
11910
|
+
packageRoot = fs11.realpathSync(path15.join(import.meta.dirname, ".."));
|
|
11878
11911
|
cwd = process.cwd();
|
|
11879
11912
|
dir = cwd;
|
|
11880
11913
|
} catch {
|
|
@@ -11882,7 +11915,7 @@ function classifyInstall() {
|
|
|
11882
11915
|
}
|
|
11883
11916
|
for (; ; ) {
|
|
11884
11917
|
try {
|
|
11885
|
-
const nmReal =
|
|
11918
|
+
const nmReal = fs11.realpathSync(path15.join(dir, "node_modules"));
|
|
11886
11919
|
if (packageRoot === nmReal || packageRoot.startsWith(nmReal + path15.sep)) {
|
|
11887
11920
|
return {
|
|
11888
11921
|
kind: "local",
|