@swmansion/argent 0.35.1-next.9 → 0.35.1-next.91
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/README.md +16 -15
- 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 +3275 -2158
- package/dist/cli.js +22 -3
- package/dist/cli.js.map +1 -1
- package/dist/client.js +844 -457
- package/dist/fatal-handlers.d.ts +1 -0
- package/dist/fatal-handlers.js +8 -2
- package/dist/fatal-handlers.js.map +1 -1
- package/dist/installer-help.js +4 -2
- package/dist/installer-help.js.map +1 -1
- package/dist/installer.mjs +823 -726
- package/dist/mcp-server.mjs +2107 -1563
- package/dist/tool-args.generated.d.ts +413 -326
- package/dist/tool-server.cjs +14071 -8488
- 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/skills/argent-android-emulator-setup/SKILL.md +2 -2
- package/skills/argent-create-e2e/SKILL.md +2 -1
- package/skills/argent-create-e2e/references/e2e-yaml.md +32 -5
- package/skills/argent-create-e2e/references/live-authoring.md +14 -4
- package/skills/argent-device-interact/SKILL.md +21 -94
- package/skills/argent-device-interact/references/advanced.md +64 -0
- package/skills/argent-ios-device-interact/SKILL.md +1 -1
- package/skills/argent-ios-device-setup/SKILL.md +1 -1
- package/skills/argent-ios-simulator-setup/SKILL.md +1 -1
- package/skills/argent-lens/SKILL.md +1 -1
- package/skills/argent-macos-app-interact/SKILL.md +3 -2
- package/skills/argent-macos-app-interact/references/e2e.md +1 -0
- package/skills/argent-metro-debugger/SKILL.md +4 -4
- package/skills/argent-native-profiler/SKILL.md +1 -1
- package/skills/argent-qa-e2e/SKILL.md +1 -1
- package/skills/argent-react-native-app-workflow/SKILL.md +1 -1
- package/skills/argent-react-native-optimization/SKILL.md +1 -1
- package/skills/argent-react-native-profiler/SKILL.md +1 -1
- package/skills/argent-screen-recording/SKILL.md +1 -1
- package/skills/argent-screenshot-diff/SKILL.md +1 -1
- package/skills/argent-settings-permissions/SKILL.md +1 -1
- package/skills/argent-test-ui-flow/SKILL.md +1 -1
- package/skills/argent-tv-interact/SKILL.md +1 -1
package/dist/client.js
CHANGED
|
@@ -504,17 +504,17 @@ var require_visit = __commonJS({
|
|
|
504
504
|
visit.BREAK = BREAK;
|
|
505
505
|
visit.SKIP = SKIP;
|
|
506
506
|
visit.REMOVE = REMOVE;
|
|
507
|
-
function visit_(key, node, visitor,
|
|
508
|
-
const ctrl = callVisitor(key, node, visitor,
|
|
507
|
+
function visit_(key, node, visitor, path16) {
|
|
508
|
+
const ctrl = callVisitor(key, node, visitor, path16);
|
|
509
509
|
if (identity.isNode(ctrl) || identity.isPair(ctrl)) {
|
|
510
|
-
replaceNode(key,
|
|
511
|
-
return visit_(key, ctrl, visitor,
|
|
510
|
+
replaceNode(key, path16, ctrl);
|
|
511
|
+
return visit_(key, ctrl, visitor, path16);
|
|
512
512
|
}
|
|
513
513
|
if (typeof ctrl !== "symbol") {
|
|
514
514
|
if (identity.isCollection(node)) {
|
|
515
|
-
|
|
515
|
+
path16 = Object.freeze(path16.concat(node));
|
|
516
516
|
for (let i = 0; i < node.items.length; ++i) {
|
|
517
|
-
const ci = visit_(i, node.items[i], visitor,
|
|
517
|
+
const ci = visit_(i, node.items[i], visitor, path16);
|
|
518
518
|
if (typeof ci === "number")
|
|
519
519
|
i = ci - 1;
|
|
520
520
|
else if (ci === BREAK)
|
|
@@ -525,13 +525,13 @@ var require_visit = __commonJS({
|
|
|
525
525
|
}
|
|
526
526
|
}
|
|
527
527
|
} else if (identity.isPair(node)) {
|
|
528
|
-
|
|
529
|
-
const ck = visit_("key", node.key, visitor,
|
|
528
|
+
path16 = Object.freeze(path16.concat(node));
|
|
529
|
+
const ck = visit_("key", node.key, visitor, path16);
|
|
530
530
|
if (ck === BREAK)
|
|
531
531
|
return BREAK;
|
|
532
532
|
else if (ck === REMOVE)
|
|
533
533
|
node.key = null;
|
|
534
|
-
const cv = visit_("value", node.value, visitor,
|
|
534
|
+
const cv = visit_("value", node.value, visitor, path16);
|
|
535
535
|
if (cv === BREAK)
|
|
536
536
|
return BREAK;
|
|
537
537
|
else if (cv === REMOVE)
|
|
@@ -552,17 +552,17 @@ var require_visit = __commonJS({
|
|
|
552
552
|
visitAsync.BREAK = BREAK;
|
|
553
553
|
visitAsync.SKIP = SKIP;
|
|
554
554
|
visitAsync.REMOVE = REMOVE;
|
|
555
|
-
async function visitAsync_(key, node, visitor,
|
|
556
|
-
const ctrl = await callVisitor(key, node, visitor,
|
|
555
|
+
async function visitAsync_(key, node, visitor, path16) {
|
|
556
|
+
const ctrl = await callVisitor(key, node, visitor, path16);
|
|
557
557
|
if (identity.isNode(ctrl) || identity.isPair(ctrl)) {
|
|
558
|
-
replaceNode(key,
|
|
559
|
-
return visitAsync_(key, ctrl, visitor,
|
|
558
|
+
replaceNode(key, path16, ctrl);
|
|
559
|
+
return visitAsync_(key, ctrl, visitor, path16);
|
|
560
560
|
}
|
|
561
561
|
if (typeof ctrl !== "symbol") {
|
|
562
562
|
if (identity.isCollection(node)) {
|
|
563
|
-
|
|
563
|
+
path16 = Object.freeze(path16.concat(node));
|
|
564
564
|
for (let i = 0; i < node.items.length; ++i) {
|
|
565
|
-
const ci = await visitAsync_(i, node.items[i], visitor,
|
|
565
|
+
const ci = await visitAsync_(i, node.items[i], visitor, path16);
|
|
566
566
|
if (typeof ci === "number")
|
|
567
567
|
i = ci - 1;
|
|
568
568
|
else if (ci === BREAK)
|
|
@@ -573,13 +573,13 @@ var require_visit = __commonJS({
|
|
|
573
573
|
}
|
|
574
574
|
}
|
|
575
575
|
} else if (identity.isPair(node)) {
|
|
576
|
-
|
|
577
|
-
const ck = await visitAsync_("key", node.key, visitor,
|
|
576
|
+
path16 = Object.freeze(path16.concat(node));
|
|
577
|
+
const ck = await visitAsync_("key", node.key, visitor, path16);
|
|
578
578
|
if (ck === BREAK)
|
|
579
579
|
return BREAK;
|
|
580
580
|
else if (ck === REMOVE)
|
|
581
581
|
node.key = null;
|
|
582
|
-
const cv = await visitAsync_("value", node.value, visitor,
|
|
582
|
+
const cv = await visitAsync_("value", node.value, visitor, path16);
|
|
583
583
|
if (cv === BREAK)
|
|
584
584
|
return BREAK;
|
|
585
585
|
else if (cv === REMOVE)
|
|
@@ -606,23 +606,23 @@ var require_visit = __commonJS({
|
|
|
606
606
|
}
|
|
607
607
|
return visitor;
|
|
608
608
|
}
|
|
609
|
-
function callVisitor(key, node, visitor,
|
|
609
|
+
function callVisitor(key, node, visitor, path16) {
|
|
610
610
|
if (typeof visitor === "function")
|
|
611
|
-
return visitor(key, node,
|
|
611
|
+
return visitor(key, node, path16);
|
|
612
612
|
if (identity.isMap(node))
|
|
613
|
-
return visitor.Map?.(key, node,
|
|
613
|
+
return visitor.Map?.(key, node, path16);
|
|
614
614
|
if (identity.isSeq(node))
|
|
615
|
-
return visitor.Seq?.(key, node,
|
|
615
|
+
return visitor.Seq?.(key, node, path16);
|
|
616
616
|
if (identity.isPair(node))
|
|
617
|
-
return visitor.Pair?.(key, node,
|
|
617
|
+
return visitor.Pair?.(key, node, path16);
|
|
618
618
|
if (identity.isScalar(node))
|
|
619
|
-
return visitor.Scalar?.(key, node,
|
|
619
|
+
return visitor.Scalar?.(key, node, path16);
|
|
620
620
|
if (identity.isAlias(node))
|
|
621
|
-
return visitor.Alias?.(key, node,
|
|
621
|
+
return visitor.Alias?.(key, node, path16);
|
|
622
622
|
return void 0;
|
|
623
623
|
}
|
|
624
|
-
function replaceNode(key,
|
|
625
|
-
const parent =
|
|
624
|
+
function replaceNode(key, path16, node) {
|
|
625
|
+
const parent = path16[path16.length - 1];
|
|
626
626
|
if (identity.isCollection(parent)) {
|
|
627
627
|
parent.items[key] = node;
|
|
628
628
|
} else if (identity.isPair(parent)) {
|
|
@@ -1234,10 +1234,10 @@ var require_Collection = __commonJS({
|
|
|
1234
1234
|
var createNode = require_createNode();
|
|
1235
1235
|
var identity = require_identity();
|
|
1236
1236
|
var Node = require_Node();
|
|
1237
|
-
function collectionFromPath(schema,
|
|
1237
|
+
function collectionFromPath(schema, path16, value) {
|
|
1238
1238
|
let v = value;
|
|
1239
|
-
for (let i =
|
|
1240
|
-
const k =
|
|
1239
|
+
for (let i = path16.length - 1; i >= 0; --i) {
|
|
1240
|
+
const k = path16[i];
|
|
1241
1241
|
if (typeof k === "number" && Number.isInteger(k) && k >= 0) {
|
|
1242
1242
|
const a = [];
|
|
1243
1243
|
a[k] = v;
|
|
@@ -1256,7 +1256,7 @@ var require_Collection = __commonJS({
|
|
|
1256
1256
|
sourceObjects: /* @__PURE__ */ new Map()
|
|
1257
1257
|
});
|
|
1258
1258
|
}
|
|
1259
|
-
var isEmptyPath = (
|
|
1259
|
+
var isEmptyPath = (path16) => path16 == null || typeof path16 === "object" && !!path16[Symbol.iterator]().next().done;
|
|
1260
1260
|
var Collection = class extends Node.NodeBase {
|
|
1261
1261
|
constructor(type, schema) {
|
|
1262
1262
|
super(type);
|
|
@@ -1286,11 +1286,11 @@ var require_Collection = __commonJS({
|
|
|
1286
1286
|
* be a Pair instance or a `{ key, value }` object, which may not have a key
|
|
1287
1287
|
* that already exists in the map.
|
|
1288
1288
|
*/
|
|
1289
|
-
addIn(
|
|
1290
|
-
if (isEmptyPath(
|
|
1289
|
+
addIn(path16, value) {
|
|
1290
|
+
if (isEmptyPath(path16))
|
|
1291
1291
|
this.add(value);
|
|
1292
1292
|
else {
|
|
1293
|
-
const [key, ...rest] =
|
|
1293
|
+
const [key, ...rest] = path16;
|
|
1294
1294
|
const node = this.get(key, true);
|
|
1295
1295
|
if (identity.isCollection(node))
|
|
1296
1296
|
node.addIn(rest, value);
|
|
@@ -1304,8 +1304,8 @@ var require_Collection = __commonJS({
|
|
|
1304
1304
|
* Removes a value from the collection.
|
|
1305
1305
|
* @returns `true` if the item was found and removed.
|
|
1306
1306
|
*/
|
|
1307
|
-
deleteIn(
|
|
1308
|
-
const [key, ...rest] =
|
|
1307
|
+
deleteIn(path16) {
|
|
1308
|
+
const [key, ...rest] = path16;
|
|
1309
1309
|
if (rest.length === 0)
|
|
1310
1310
|
return this.delete(key);
|
|
1311
1311
|
const node = this.get(key, true);
|
|
@@ -1319,8 +1319,8 @@ var require_Collection = __commonJS({
|
|
|
1319
1319
|
* scalar values from their surrounding node; to disable set `keepScalar` to
|
|
1320
1320
|
* `true` (collections are always returned intact).
|
|
1321
1321
|
*/
|
|
1322
|
-
getIn(
|
|
1323
|
-
const [key, ...rest] =
|
|
1322
|
+
getIn(path16, keepScalar) {
|
|
1323
|
+
const [key, ...rest] = path16;
|
|
1324
1324
|
const node = this.get(key, true);
|
|
1325
1325
|
if (rest.length === 0)
|
|
1326
1326
|
return !keepScalar && identity.isScalar(node) ? node.value : node;
|
|
@@ -1338,8 +1338,8 @@ var require_Collection = __commonJS({
|
|
|
1338
1338
|
/**
|
|
1339
1339
|
* Checks if the collection includes a value with the key `key`.
|
|
1340
1340
|
*/
|
|
1341
|
-
hasIn(
|
|
1342
|
-
const [key, ...rest] =
|
|
1341
|
+
hasIn(path16) {
|
|
1342
|
+
const [key, ...rest] = path16;
|
|
1343
1343
|
if (rest.length === 0)
|
|
1344
1344
|
return this.has(key);
|
|
1345
1345
|
const node = this.get(key, true);
|
|
@@ -1349,8 +1349,8 @@ var require_Collection = __commonJS({
|
|
|
1349
1349
|
* Sets a value in this collection. For `!!set`, `value` needs to be a
|
|
1350
1350
|
* boolean to add/remove the item from the set.
|
|
1351
1351
|
*/
|
|
1352
|
-
setIn(
|
|
1353
|
-
const [key, ...rest] =
|
|
1352
|
+
setIn(path16, value) {
|
|
1353
|
+
const [key, ...rest] = path16;
|
|
1354
1354
|
if (rest.length === 0) {
|
|
1355
1355
|
this.set(key, value);
|
|
1356
1356
|
} else {
|
|
@@ -3865,9 +3865,9 @@ var require_Document = __commonJS({
|
|
|
3865
3865
|
this.contents.add(value);
|
|
3866
3866
|
}
|
|
3867
3867
|
/** Adds a value to the document. */
|
|
3868
|
-
addIn(
|
|
3868
|
+
addIn(path16, value) {
|
|
3869
3869
|
if (assertCollection(this.contents))
|
|
3870
|
-
this.contents.addIn(
|
|
3870
|
+
this.contents.addIn(path16, value);
|
|
3871
3871
|
}
|
|
3872
3872
|
/**
|
|
3873
3873
|
* Create a new `Alias` node, ensuring that the target `node` has the required anchor.
|
|
@@ -3942,14 +3942,14 @@ var require_Document = __commonJS({
|
|
|
3942
3942
|
* Removes a value from the document.
|
|
3943
3943
|
* @returns `true` if the item was found and removed.
|
|
3944
3944
|
*/
|
|
3945
|
-
deleteIn(
|
|
3946
|
-
if (Collection.isEmptyPath(
|
|
3945
|
+
deleteIn(path16) {
|
|
3946
|
+
if (Collection.isEmptyPath(path16)) {
|
|
3947
3947
|
if (this.contents == null)
|
|
3948
3948
|
return false;
|
|
3949
3949
|
this.contents = null;
|
|
3950
3950
|
return true;
|
|
3951
3951
|
}
|
|
3952
|
-
return assertCollection(this.contents) ? this.contents.deleteIn(
|
|
3952
|
+
return assertCollection(this.contents) ? this.contents.deleteIn(path16) : false;
|
|
3953
3953
|
}
|
|
3954
3954
|
/**
|
|
3955
3955
|
* Returns item at `key`, or `undefined` if not found. By default unwraps
|
|
@@ -3964,10 +3964,10 @@ var require_Document = __commonJS({
|
|
|
3964
3964
|
* scalar values from their surrounding node; to disable set `keepScalar` to
|
|
3965
3965
|
* `true` (collections are always returned intact).
|
|
3966
3966
|
*/
|
|
3967
|
-
getIn(
|
|
3968
|
-
if (Collection.isEmptyPath(
|
|
3967
|
+
getIn(path16, keepScalar) {
|
|
3968
|
+
if (Collection.isEmptyPath(path16))
|
|
3969
3969
|
return !keepScalar && identity.isScalar(this.contents) ? this.contents.value : this.contents;
|
|
3970
|
-
return identity.isCollection(this.contents) ? this.contents.getIn(
|
|
3970
|
+
return identity.isCollection(this.contents) ? this.contents.getIn(path16, keepScalar) : void 0;
|
|
3971
3971
|
}
|
|
3972
3972
|
/**
|
|
3973
3973
|
* Checks if the document includes a value with the key `key`.
|
|
@@ -3978,10 +3978,10 @@ var require_Document = __commonJS({
|
|
|
3978
3978
|
/**
|
|
3979
3979
|
* Checks if the document includes a value at `path`.
|
|
3980
3980
|
*/
|
|
3981
|
-
hasIn(
|
|
3982
|
-
if (Collection.isEmptyPath(
|
|
3981
|
+
hasIn(path16) {
|
|
3982
|
+
if (Collection.isEmptyPath(path16))
|
|
3983
3983
|
return this.contents !== void 0;
|
|
3984
|
-
return identity.isCollection(this.contents) ? this.contents.hasIn(
|
|
3984
|
+
return identity.isCollection(this.contents) ? this.contents.hasIn(path16) : false;
|
|
3985
3985
|
}
|
|
3986
3986
|
/**
|
|
3987
3987
|
* Sets a value in this document. For `!!set`, `value` needs to be a
|
|
@@ -3998,13 +3998,13 @@ var require_Document = __commonJS({
|
|
|
3998
3998
|
* Sets a value in this document. For `!!set`, `value` needs to be a
|
|
3999
3999
|
* boolean to add/remove the item from the set.
|
|
4000
4000
|
*/
|
|
4001
|
-
setIn(
|
|
4002
|
-
if (Collection.isEmptyPath(
|
|
4001
|
+
setIn(path16, value) {
|
|
4002
|
+
if (Collection.isEmptyPath(path16)) {
|
|
4003
4003
|
this.contents = value;
|
|
4004
4004
|
} else if (this.contents == null) {
|
|
4005
|
-
this.contents = Collection.collectionFromPath(this.schema, Array.from(
|
|
4005
|
+
this.contents = Collection.collectionFromPath(this.schema, Array.from(path16), value);
|
|
4006
4006
|
} else if (assertCollection(this.contents)) {
|
|
4007
|
-
this.contents.setIn(
|
|
4007
|
+
this.contents.setIn(path16, value);
|
|
4008
4008
|
}
|
|
4009
4009
|
}
|
|
4010
4010
|
/**
|
|
@@ -4390,10 +4390,10 @@ var require_resolve_block_map = __commonJS({
|
|
|
4390
4390
|
let offset = bm.offset;
|
|
4391
4391
|
let commentEnd = null;
|
|
4392
4392
|
for (const collItem of bm.items) {
|
|
4393
|
-
const { start, key, sep:
|
|
4393
|
+
const { start, key, sep: sep8, value } = collItem;
|
|
4394
4394
|
const keyProps = resolveProps.resolveProps(start, {
|
|
4395
4395
|
indicator: "explicit-key-ind",
|
|
4396
|
-
next: key ??
|
|
4396
|
+
next: key ?? sep8?.[0],
|
|
4397
4397
|
offset,
|
|
4398
4398
|
onError,
|
|
4399
4399
|
parentIndent: bm.indent,
|
|
@@ -4407,7 +4407,7 @@ var require_resolve_block_map = __commonJS({
|
|
|
4407
4407
|
else if ("indent" in key && key.indent !== bm.indent)
|
|
4408
4408
|
onError(offset, "BAD_INDENT", startColMsg);
|
|
4409
4409
|
}
|
|
4410
|
-
if (!keyProps.anchor && !keyProps.tag && !
|
|
4410
|
+
if (!keyProps.anchor && !keyProps.tag && !sep8) {
|
|
4411
4411
|
commentEnd = keyProps.end;
|
|
4412
4412
|
if (keyProps.comment) {
|
|
4413
4413
|
if (map.comment)
|
|
@@ -4431,7 +4431,7 @@ var require_resolve_block_map = __commonJS({
|
|
|
4431
4431
|
ctx.atKey = false;
|
|
4432
4432
|
if (utilMapIncludes.mapIncludes(ctx, map.items, keyNode))
|
|
4433
4433
|
onError(keyStart, "DUPLICATE_KEY", "Map keys must be unique");
|
|
4434
|
-
const valueProps = resolveProps.resolveProps(
|
|
4434
|
+
const valueProps = resolveProps.resolveProps(sep8 ?? [], {
|
|
4435
4435
|
indicator: "map-value-ind",
|
|
4436
4436
|
next: value,
|
|
4437
4437
|
offset: keyNode.range[2],
|
|
@@ -4447,7 +4447,7 @@ var require_resolve_block_map = __commonJS({
|
|
|
4447
4447
|
if (ctx.options.strict && keyProps.start < valueProps.found.offset - 1024)
|
|
4448
4448
|
onError(keyNode.range, "KEY_OVER_1024_CHARS", "The : indicator must be at most 1024 chars after the start of an implicit block mapping key");
|
|
4449
4449
|
}
|
|
4450
|
-
const valueNode = value ? composeNode(ctx, value, valueProps, onError) : composeEmptyNode(ctx, offset,
|
|
4450
|
+
const valueNode = value ? composeNode(ctx, value, valueProps, onError) : composeEmptyNode(ctx, offset, sep8, null, valueProps, onError);
|
|
4451
4451
|
if (ctx.schema.compat)
|
|
4452
4452
|
utilFlowIndentCheck.flowIndentCheck(bm.indent, value, onError);
|
|
4453
4453
|
offset = valueNode.range[2];
|
|
@@ -4538,7 +4538,7 @@ var require_resolve_end = __commonJS({
|
|
|
4538
4538
|
let comment = "";
|
|
4539
4539
|
if (end) {
|
|
4540
4540
|
let hasSpace = false;
|
|
4541
|
-
let
|
|
4541
|
+
let sep8 = "";
|
|
4542
4542
|
for (const token of end) {
|
|
4543
4543
|
const { source, type } = token;
|
|
4544
4544
|
switch (type) {
|
|
@@ -4552,13 +4552,13 @@ var require_resolve_end = __commonJS({
|
|
|
4552
4552
|
if (!comment)
|
|
4553
4553
|
comment = cb;
|
|
4554
4554
|
else
|
|
4555
|
-
comment +=
|
|
4556
|
-
|
|
4555
|
+
comment += sep8 + cb;
|
|
4556
|
+
sep8 = "";
|
|
4557
4557
|
break;
|
|
4558
4558
|
}
|
|
4559
4559
|
case "newline":
|
|
4560
4560
|
if (comment)
|
|
4561
|
-
|
|
4561
|
+
sep8 += source;
|
|
4562
4562
|
hasSpace = true;
|
|
4563
4563
|
break;
|
|
4564
4564
|
default:
|
|
@@ -4601,18 +4601,18 @@ var require_resolve_flow_collection = __commonJS({
|
|
|
4601
4601
|
let offset = fc.offset + fc.start.source.length;
|
|
4602
4602
|
for (let i = 0; i < fc.items.length; ++i) {
|
|
4603
4603
|
const collItem = fc.items[i];
|
|
4604
|
-
const { start, key, sep:
|
|
4604
|
+
const { start, key, sep: sep8, value } = collItem;
|
|
4605
4605
|
const props = resolveProps.resolveProps(start, {
|
|
4606
4606
|
flow: fcName,
|
|
4607
4607
|
indicator: "explicit-key-ind",
|
|
4608
|
-
next: key ??
|
|
4608
|
+
next: key ?? sep8?.[0],
|
|
4609
4609
|
offset,
|
|
4610
4610
|
onError,
|
|
4611
4611
|
parentIndent: fc.indent,
|
|
4612
4612
|
startOnNewline: false
|
|
4613
4613
|
});
|
|
4614
4614
|
if (!props.found) {
|
|
4615
|
-
if (!props.anchor && !props.tag && !
|
|
4615
|
+
if (!props.anchor && !props.tag && !sep8 && !value) {
|
|
4616
4616
|
if (i === 0 && props.comma)
|
|
4617
4617
|
onError(props.comma, "UNEXPECTED_TOKEN", `Unexpected , in ${fcName}`);
|
|
4618
4618
|
else if (i < fc.items.length - 1)
|
|
@@ -4666,8 +4666,8 @@ var require_resolve_flow_collection = __commonJS({
|
|
|
4666
4666
|
}
|
|
4667
4667
|
}
|
|
4668
4668
|
}
|
|
4669
|
-
if (!isMap && !
|
|
4670
|
-
const valueNode = value ? composeNode(ctx, value, props, onError) : composeEmptyNode(ctx, props.end,
|
|
4669
|
+
if (!isMap && !sep8 && !props.found) {
|
|
4670
|
+
const valueNode = value ? composeNode(ctx, value, props, onError) : composeEmptyNode(ctx, props.end, sep8, null, props, onError);
|
|
4671
4671
|
coll.items.push(valueNode);
|
|
4672
4672
|
offset = valueNode.range[2];
|
|
4673
4673
|
if (isBlock(value))
|
|
@@ -4679,7 +4679,7 @@ var require_resolve_flow_collection = __commonJS({
|
|
|
4679
4679
|
if (isBlock(key))
|
|
4680
4680
|
onError(keyNode.range, "BLOCK_IN_FLOW", blockMsg);
|
|
4681
4681
|
ctx.atKey = false;
|
|
4682
|
-
const valueProps = resolveProps.resolveProps(
|
|
4682
|
+
const valueProps = resolveProps.resolveProps(sep8 ?? [], {
|
|
4683
4683
|
flow: fcName,
|
|
4684
4684
|
indicator: "map-value-ind",
|
|
4685
4685
|
next: value,
|
|
@@ -4690,8 +4690,8 @@ var require_resolve_flow_collection = __commonJS({
|
|
|
4690
4690
|
});
|
|
4691
4691
|
if (valueProps.found) {
|
|
4692
4692
|
if (!isMap && !props.found && ctx.options.strict) {
|
|
4693
|
-
if (
|
|
4694
|
-
for (const st of
|
|
4693
|
+
if (sep8)
|
|
4694
|
+
for (const st of sep8) {
|
|
4695
4695
|
if (st === valueProps.found)
|
|
4696
4696
|
break;
|
|
4697
4697
|
if (st.type === "newline") {
|
|
@@ -4708,7 +4708,7 @@ var require_resolve_flow_collection = __commonJS({
|
|
|
4708
4708
|
else
|
|
4709
4709
|
onError(valueProps.start, "MISSING_CHAR", `Missing , or : between ${fcName} items`);
|
|
4710
4710
|
}
|
|
4711
|
-
const valueNode = value ? composeNode(ctx, value, valueProps, onError) : valueProps.found ? composeEmptyNode(ctx, valueProps.end,
|
|
4711
|
+
const valueNode = value ? composeNode(ctx, value, valueProps, onError) : valueProps.found ? composeEmptyNode(ctx, valueProps.end, sep8, null, valueProps, onError) : null;
|
|
4712
4712
|
if (valueNode) {
|
|
4713
4713
|
if (isBlock(value))
|
|
4714
4714
|
onError(valueNode.range, "BLOCK_IN_FLOW", blockMsg);
|
|
@@ -4888,7 +4888,7 @@ var require_resolve_block_scalar = __commonJS({
|
|
|
4888
4888
|
chompStart = i + 1;
|
|
4889
4889
|
}
|
|
4890
4890
|
let value = "";
|
|
4891
|
-
let
|
|
4891
|
+
let sep8 = "";
|
|
4892
4892
|
let prevMoreIndented = false;
|
|
4893
4893
|
for (let i = 0; i < contentStart; ++i)
|
|
4894
4894
|
value += lines[i][0].slice(trimIndent) + "\n";
|
|
@@ -4905,24 +4905,24 @@ var require_resolve_block_scalar = __commonJS({
|
|
|
4905
4905
|
indent = "";
|
|
4906
4906
|
}
|
|
4907
4907
|
if (type === Scalar.Scalar.BLOCK_LITERAL) {
|
|
4908
|
-
value +=
|
|
4909
|
-
|
|
4908
|
+
value += sep8 + indent.slice(trimIndent) + content;
|
|
4909
|
+
sep8 = "\n";
|
|
4910
4910
|
} else if (indent.length > trimIndent || content[0] === " ") {
|
|
4911
|
-
if (
|
|
4912
|
-
|
|
4913
|
-
else if (!prevMoreIndented &&
|
|
4914
|
-
|
|
4915
|
-
value +=
|
|
4916
|
-
|
|
4911
|
+
if (sep8 === " ")
|
|
4912
|
+
sep8 = "\n";
|
|
4913
|
+
else if (!prevMoreIndented && sep8 === "\n")
|
|
4914
|
+
sep8 = "\n\n";
|
|
4915
|
+
value += sep8 + indent.slice(trimIndent) + content;
|
|
4916
|
+
sep8 = "\n";
|
|
4917
4917
|
prevMoreIndented = true;
|
|
4918
4918
|
} else if (content === "") {
|
|
4919
|
-
if (
|
|
4919
|
+
if (sep8 === "\n")
|
|
4920
4920
|
value += "\n";
|
|
4921
4921
|
else
|
|
4922
|
-
|
|
4922
|
+
sep8 = "\n";
|
|
4923
4923
|
} else {
|
|
4924
|
-
value +=
|
|
4925
|
-
|
|
4924
|
+
value += sep8 + content;
|
|
4925
|
+
sep8 = " ";
|
|
4926
4926
|
prevMoreIndented = false;
|
|
4927
4927
|
}
|
|
4928
4928
|
}
|
|
@@ -5105,25 +5105,25 @@ var require_resolve_flow_scalar = __commonJS({
|
|
|
5105
5105
|
trimBoth = /^[ \t]+|[ \t]+$/g;
|
|
5106
5106
|
}
|
|
5107
5107
|
let res = match[1].replace(trimEnd, "");
|
|
5108
|
-
let
|
|
5108
|
+
let sep8 = " ";
|
|
5109
5109
|
let pos = line.lastIndex;
|
|
5110
5110
|
while (match = line.exec(source)) {
|
|
5111
5111
|
const lm = match[1].replace(trimBoth, "");
|
|
5112
5112
|
if (lm === "") {
|
|
5113
|
-
if (
|
|
5114
|
-
res +=
|
|
5113
|
+
if (sep8 === "\n")
|
|
5114
|
+
res += sep8;
|
|
5115
5115
|
else
|
|
5116
|
-
|
|
5116
|
+
sep8 = "\n";
|
|
5117
5117
|
} else {
|
|
5118
|
-
res +=
|
|
5119
|
-
|
|
5118
|
+
res += sep8 + lm;
|
|
5119
|
+
sep8 = " ";
|
|
5120
5120
|
}
|
|
5121
5121
|
pos = line.lastIndex;
|
|
5122
5122
|
}
|
|
5123
5123
|
const last = /[ \t]*(.*)/sy;
|
|
5124
5124
|
last.lastIndex = pos;
|
|
5125
5125
|
match = last.exec(source);
|
|
5126
|
-
return res +
|
|
5126
|
+
return res + sep8 + (match?.[1] ?? "");
|
|
5127
5127
|
}
|
|
5128
5128
|
function doubleQuotedValue(source, onError) {
|
|
5129
5129
|
let res = "";
|
|
@@ -5933,14 +5933,14 @@ var require_cst_stringify = __commonJS({
|
|
|
5933
5933
|
}
|
|
5934
5934
|
}
|
|
5935
5935
|
}
|
|
5936
|
-
function stringifyItem({ start, key, sep:
|
|
5936
|
+
function stringifyItem({ start, key, sep: sep8, value }) {
|
|
5937
5937
|
let res = "";
|
|
5938
5938
|
for (const st of start)
|
|
5939
5939
|
res += st.source;
|
|
5940
5940
|
if (key)
|
|
5941
5941
|
res += stringifyToken(key);
|
|
5942
|
-
if (
|
|
5943
|
-
for (const st of
|
|
5942
|
+
if (sep8)
|
|
5943
|
+
for (const st of sep8)
|
|
5944
5944
|
res += st.source;
|
|
5945
5945
|
if (value)
|
|
5946
5946
|
res += stringifyToken(value);
|
|
@@ -5965,9 +5965,9 @@ var require_cst_visit = __commonJS({
|
|
|
5965
5965
|
visit.BREAK = BREAK;
|
|
5966
5966
|
visit.SKIP = SKIP;
|
|
5967
5967
|
visit.REMOVE = REMOVE;
|
|
5968
|
-
visit.itemAtPath = (cst,
|
|
5968
|
+
visit.itemAtPath = (cst, path16) => {
|
|
5969
5969
|
let item = cst;
|
|
5970
|
-
for (const [field, index] of
|
|
5970
|
+
for (const [field, index] of path16) {
|
|
5971
5971
|
const tok = item?.[field];
|
|
5972
5972
|
if (tok && "items" in tok) {
|
|
5973
5973
|
item = tok.items[index];
|
|
@@ -5976,23 +5976,23 @@ var require_cst_visit = __commonJS({
|
|
|
5976
5976
|
}
|
|
5977
5977
|
return item;
|
|
5978
5978
|
};
|
|
5979
|
-
visit.parentCollection = (cst,
|
|
5980
|
-
const parent = visit.itemAtPath(cst,
|
|
5981
|
-
const field =
|
|
5979
|
+
visit.parentCollection = (cst, path16) => {
|
|
5980
|
+
const parent = visit.itemAtPath(cst, path16.slice(0, -1));
|
|
5981
|
+
const field = path16[path16.length - 1][0];
|
|
5982
5982
|
const coll = parent?.[field];
|
|
5983
5983
|
if (coll && "items" in coll)
|
|
5984
5984
|
return coll;
|
|
5985
5985
|
throw new Error("Parent collection not found");
|
|
5986
5986
|
};
|
|
5987
|
-
function _visit(
|
|
5988
|
-
let ctrl = visitor(item,
|
|
5987
|
+
function _visit(path16, item, visitor) {
|
|
5988
|
+
let ctrl = visitor(item, path16);
|
|
5989
5989
|
if (typeof ctrl === "symbol")
|
|
5990
5990
|
return ctrl;
|
|
5991
5991
|
for (const field of ["key", "value"]) {
|
|
5992
5992
|
const token = item[field];
|
|
5993
5993
|
if (token && "items" in token) {
|
|
5994
5994
|
for (let i = 0; i < token.items.length; ++i) {
|
|
5995
|
-
const ci = _visit(Object.freeze(
|
|
5995
|
+
const ci = _visit(Object.freeze(path16.concat([[field, i]])), token.items[i], visitor);
|
|
5996
5996
|
if (typeof ci === "number")
|
|
5997
5997
|
i = ci - 1;
|
|
5998
5998
|
else if (ci === BREAK)
|
|
@@ -6003,10 +6003,10 @@ var require_cst_visit = __commonJS({
|
|
|
6003
6003
|
}
|
|
6004
6004
|
}
|
|
6005
6005
|
if (typeof ctrl === "function" && field === "key")
|
|
6006
|
-
ctrl = ctrl(item,
|
|
6006
|
+
ctrl = ctrl(item, path16);
|
|
6007
6007
|
}
|
|
6008
6008
|
}
|
|
6009
|
-
return typeof ctrl === "function" ? ctrl(item,
|
|
6009
|
+
return typeof ctrl === "function" ? ctrl(item, path16) : ctrl;
|
|
6010
6010
|
}
|
|
6011
6011
|
exports.visit = visit;
|
|
6012
6012
|
}
|
|
@@ -7107,18 +7107,18 @@ var require_parser = __commonJS({
|
|
|
7107
7107
|
if (this.type === "map-value-ind") {
|
|
7108
7108
|
const prev = getPrevProps(this.peek(2));
|
|
7109
7109
|
const start = getFirstKeyStartProps(prev);
|
|
7110
|
-
let
|
|
7110
|
+
let sep8;
|
|
7111
7111
|
if (scalar.end) {
|
|
7112
|
-
|
|
7113
|
-
|
|
7112
|
+
sep8 = scalar.end;
|
|
7113
|
+
sep8.push(this.sourceToken);
|
|
7114
7114
|
delete scalar.end;
|
|
7115
7115
|
} else
|
|
7116
|
-
|
|
7116
|
+
sep8 = [this.sourceToken];
|
|
7117
7117
|
const map = {
|
|
7118
7118
|
type: "block-map",
|
|
7119
7119
|
offset: scalar.offset,
|
|
7120
7120
|
indent: scalar.indent,
|
|
7121
|
-
items: [{ start, key: scalar, sep:
|
|
7121
|
+
items: [{ start, key: scalar, sep: sep8 }]
|
|
7122
7122
|
};
|
|
7123
7123
|
this.onKeyLine = true;
|
|
7124
7124
|
this.stack[this.stack.length - 1] = map;
|
|
@@ -7271,15 +7271,15 @@ var require_parser = __commonJS({
|
|
|
7271
7271
|
} else if (isFlowToken(it.key) && !includesToken(it.sep, "newline")) {
|
|
7272
7272
|
const start2 = getFirstKeyStartProps(it.start);
|
|
7273
7273
|
const key = it.key;
|
|
7274
|
-
const
|
|
7275
|
-
|
|
7274
|
+
const sep8 = it.sep;
|
|
7275
|
+
sep8.push(this.sourceToken);
|
|
7276
7276
|
delete it.key;
|
|
7277
7277
|
delete it.sep;
|
|
7278
7278
|
this.stack.push({
|
|
7279
7279
|
type: "block-map",
|
|
7280
7280
|
offset: this.offset,
|
|
7281
7281
|
indent: this.indent,
|
|
7282
|
-
items: [{ start: start2, key, sep:
|
|
7282
|
+
items: [{ start: start2, key, sep: sep8 }]
|
|
7283
7283
|
});
|
|
7284
7284
|
} else if (start.length > 0) {
|
|
7285
7285
|
it.sep = it.sep.concat(start, this.sourceToken);
|
|
@@ -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":
|
|
@@ -7473,13 +7473,13 @@ var require_parser = __commonJS({
|
|
|
7473
7473
|
const prev = getPrevProps(parent);
|
|
7474
7474
|
const start = getFirstKeyStartProps(prev);
|
|
7475
7475
|
fixFlowSeqItems(fc);
|
|
7476
|
-
const
|
|
7477
|
-
|
|
7476
|
+
const sep8 = fc.end.splice(1, fc.end.length);
|
|
7477
|
+
sep8.push(this.sourceToken);
|
|
7478
7478
|
const map = {
|
|
7479
7479
|
type: "block-map",
|
|
7480
7480
|
offset: fc.offset,
|
|
7481
7481
|
indent: fc.indent,
|
|
7482
|
-
items: [{ start, key: fc, sep:
|
|
7482
|
+
items: [{ start, key: fc, sep: sep8 }]
|
|
7483
7483
|
};
|
|
7484
7484
|
this.onKeyLine = true;
|
|
7485
7485
|
this.stack[this.stack.length - 1] = map;
|
|
@@ -7657,7 +7657,7 @@ var require_public_api = __commonJS({
|
|
|
7657
7657
|
}
|
|
7658
7658
|
return doc;
|
|
7659
7659
|
}
|
|
7660
|
-
function
|
|
7660
|
+
function parse3(src, reviver, options) {
|
|
7661
7661
|
let _reviver = void 0;
|
|
7662
7662
|
if (typeof reviver === "function") {
|
|
7663
7663
|
_reviver = reviver;
|
|
@@ -7698,7 +7698,7 @@ var require_public_api = __commonJS({
|
|
|
7698
7698
|
return value.toString(options);
|
|
7699
7699
|
return new Document.Document(value, _replacer, options).toString(options);
|
|
7700
7700
|
}
|
|
7701
|
-
exports.parse =
|
|
7701
|
+
exports.parse = parse3;
|
|
7702
7702
|
exports.parseAllDocuments = parseAllDocuments;
|
|
7703
7703
|
exports.parseDocument = parseDocument;
|
|
7704
7704
|
exports.stringify = stringify;
|
|
@@ -7758,9 +7758,65 @@ 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
|
+
import * as path2 from "node:path";
|
|
7763
|
+
|
|
7764
|
+
// ../configuration-core/src/home.ts
|
|
7765
|
+
import * as os from "node:os";
|
|
7762
7766
|
import * as path from "node:path";
|
|
7763
|
-
|
|
7767
|
+
var ARGENT_HOME_DIR_ENV = "ARGENT_HOME_DIR";
|
|
7768
|
+
function nonEmpty(value) {
|
|
7769
|
+
if (value == void 0) return null;
|
|
7770
|
+
const trimmed = value.trim();
|
|
7771
|
+
return trimmed === "" ? null : value;
|
|
7772
|
+
}
|
|
7773
|
+
function resolveHomeDir(options = {}) {
|
|
7774
|
+
if (options.homeDir) return options.homeDir;
|
|
7775
|
+
return process.platform === "win32" ? nonEmpty(process.env.USERPROFILE) ?? os.homedir() : nonEmpty(process.env.HOME) ?? os.homedir();
|
|
7776
|
+
}
|
|
7777
|
+
function argentHomeDir(options = {}) {
|
|
7778
|
+
const override = options.homeDir ? null : nonEmpty(process.env[ARGENT_HOME_DIR_ENV]);
|
|
7779
|
+
return override ? path.resolve(override.trim()) : path.join(resolveHomeDir(options), ".argent");
|
|
7780
|
+
}
|
|
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
|
+
|
|
7819
|
+
// ../configuration-core/src/flags.ts
|
|
7764
7820
|
var FLAG_REGISTRY = [
|
|
7765
7821
|
{
|
|
7766
7822
|
name: "disable-auto-screenshot",
|
|
@@ -7824,31 +7880,30 @@ function getFlagDefinition(name, registry = FLAG_REGISTRY) {
|
|
|
7824
7880
|
}
|
|
7825
7881
|
var PROJECT_MARKERS = [".argent", ".git", "package.json"];
|
|
7826
7882
|
function findProjectRoot(startDir) {
|
|
7827
|
-
let current =
|
|
7883
|
+
let current = path2.resolve(startDir);
|
|
7828
7884
|
while (true) {
|
|
7829
7885
|
for (const marker of PROJECT_MARKERS) {
|
|
7830
|
-
if (
|
|
7886
|
+
if (fs2.existsSync(path2.join(current, marker))) return current;
|
|
7831
7887
|
}
|
|
7832
|
-
const parent =
|
|
7888
|
+
const parent = path2.dirname(current);
|
|
7833
7889
|
if (parent === current) return null;
|
|
7834
7890
|
current = parent;
|
|
7835
7891
|
}
|
|
7836
7892
|
}
|
|
7837
7893
|
function resolveProjectRoot(startDir) {
|
|
7838
|
-
return findProjectRoot(startDir) ??
|
|
7894
|
+
return findProjectRoot(startDir) ?? path2.resolve(startDir);
|
|
7839
7895
|
}
|
|
7840
7896
|
function getFlagsPath(scope, options = {}) {
|
|
7841
|
-
const home = options.homeDir ?? homedir();
|
|
7842
7897
|
if (scope === "global") {
|
|
7843
|
-
return
|
|
7898
|
+
return path2.join(argentHomeDir({ homeDir: options.homeDir }), "flags.json");
|
|
7844
7899
|
}
|
|
7845
7900
|
const cwd = options.cwd ?? process.cwd();
|
|
7846
|
-
return
|
|
7901
|
+
return path2.join(resolveProjectRoot(cwd), ".argent", "flags.json");
|
|
7847
7902
|
}
|
|
7848
7903
|
function readFlagsFile(filePath) {
|
|
7849
7904
|
let raw;
|
|
7850
7905
|
try {
|
|
7851
|
-
raw =
|
|
7906
|
+
raw = fs2.readFileSync(filePath, "utf8");
|
|
7852
7907
|
} catch {
|
|
7853
7908
|
return {};
|
|
7854
7909
|
}
|
|
@@ -7885,49 +7940,34 @@ function isFeatureEnabled(name, options = {}, registry = FLAG_REGISTRY) {
|
|
|
7885
7940
|
}
|
|
7886
7941
|
|
|
7887
7942
|
// ../configuration-core/src/paths.ts
|
|
7888
|
-
import * as
|
|
7889
|
-
import * as
|
|
7890
|
-
import * as path2 from "node:path";
|
|
7891
|
-
function nonEmpty(value) {
|
|
7892
|
-
if (value == void 0) return null;
|
|
7893
|
-
const trimmed = value.trim();
|
|
7894
|
-
return trimmed === "" ? null : value;
|
|
7895
|
-
}
|
|
7896
|
-
function resolveHomeDir(options = {}) {
|
|
7897
|
-
if (options.homeDir) return options.homeDir;
|
|
7898
|
-
return process.platform === "win32" ? nonEmpty(process.env.USERPROFILE) ?? os.homedir() : nonEmpty(process.env.HOME) ?? os.homedir();
|
|
7899
|
-
}
|
|
7943
|
+
import * as fs3 from "node:fs";
|
|
7944
|
+
import * as path3 from "node:path";
|
|
7900
7945
|
function isHomeDir(dir, options = {}) {
|
|
7901
7946
|
return canonicalPath(dir) === canonicalPath(resolveHomeDir(options));
|
|
7902
7947
|
}
|
|
7903
7948
|
function canonicalPath(p) {
|
|
7904
7949
|
try {
|
|
7905
|
-
return
|
|
7950
|
+
return fs3.realpathSync.native(p);
|
|
7906
7951
|
} catch {
|
|
7907
|
-
return
|
|
7952
|
+
return path3.resolve(p);
|
|
7908
7953
|
}
|
|
7909
7954
|
}
|
|
7910
|
-
function argentHomeDir() {
|
|
7911
|
-
return path2.join(resolveHomeDir(), ".argent");
|
|
7912
|
-
}
|
|
7913
7955
|
function configDir(scope = "global", options = {}) {
|
|
7914
|
-
if (scope === "global")
|
|
7915
|
-
return path2.join(resolveHomeDir(options), ".argent");
|
|
7916
|
-
}
|
|
7956
|
+
if (scope === "global") return argentHomeDir(options);
|
|
7917
7957
|
const cwd = options.cwd ?? process.cwd();
|
|
7918
|
-
return
|
|
7958
|
+
return path3.join(resolveProjectRoot(cwd), ".argent");
|
|
7919
7959
|
}
|
|
7920
7960
|
function configFilePath(scope = "global", options = {}) {
|
|
7921
|
-
return
|
|
7961
|
+
return path3.join(configDir(scope, options), "config.json");
|
|
7922
7962
|
}
|
|
7923
7963
|
|
|
7924
7964
|
// ../configuration-core/src/config.ts
|
|
7925
7965
|
import * as crypto from "node:crypto";
|
|
7926
|
-
import * as
|
|
7927
|
-
import * as
|
|
7966
|
+
import * as fs4 from "node:fs";
|
|
7967
|
+
import * as path4 from "node:path";
|
|
7928
7968
|
function readConfigObject(scope = "global", options = {}) {
|
|
7929
7969
|
try {
|
|
7930
|
-
const raw =
|
|
7970
|
+
const raw = fs4.readFileSync(configFilePath(scope, options), "utf8");
|
|
7931
7971
|
const json = JSON.parse(raw);
|
|
7932
7972
|
if (json && typeof json === "object" && !Array.isArray(json)) {
|
|
7933
7973
|
return json;
|
|
@@ -7964,8 +8004,8 @@ function getAtPath(obj, dottedKey) {
|
|
|
7964
8004
|
|
|
7965
8005
|
// ../configuration-core/src/secrets.ts
|
|
7966
8006
|
var import_dotenv = __toESM(require_dist(), 1);
|
|
7967
|
-
import * as
|
|
7968
|
-
import * as
|
|
8007
|
+
import * as fs5 from "node:fs";
|
|
8008
|
+
import * as path5 from "node:path";
|
|
7969
8009
|
var SECRET_ENV_PREFIX = "ARGENT_SECRET_";
|
|
7970
8010
|
var SECRETS_FILE_NAME = "secrets.env";
|
|
7971
8011
|
var SHARED_ENV_FILES = [".env.local", ".env"];
|
|
@@ -7994,18 +8034,33 @@ function fileSource(filePath, exposure) {
|
|
|
7994
8034
|
names: [],
|
|
7995
8035
|
values: /* @__PURE__ */ new Map()
|
|
7996
8036
|
};
|
|
7997
|
-
if (!
|
|
8037
|
+
if (!fs5.statSync(filePath, { throwIfNoEntry: false })) return absent;
|
|
7998
8038
|
let content;
|
|
7999
8039
|
try {
|
|
8000
|
-
content =
|
|
8040
|
+
content = fs5.readFileSync(filePath, "utf8");
|
|
8001
8041
|
} catch {
|
|
8002
8042
|
return absent;
|
|
8003
8043
|
}
|
|
8044
|
+
return parsedFileSource(label, content, exposure);
|
|
8045
|
+
}
|
|
8046
|
+
function secretsFileSource(filePath) {
|
|
8047
|
+
const resolved = path5.resolve(filePath);
|
|
8048
|
+
let content;
|
|
8049
|
+
try {
|
|
8050
|
+
content = fs5.readFileSync(resolved, "utf8");
|
|
8051
|
+
} catch (err) {
|
|
8052
|
+
const code = err.code;
|
|
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);
|
|
8054
|
+
throw new Error(`Cannot read the secrets file ${resolved}: ${reason}`, { cause: err });
|
|
8055
|
+
}
|
|
8056
|
+
return parsedFileSource(`${resolved} (--secrets-file)`, content, "prefixed");
|
|
8057
|
+
}
|
|
8058
|
+
function parsedFileSource(label, content, exposure) {
|
|
8004
8059
|
const values = /* @__PURE__ */ new Map();
|
|
8005
8060
|
let skippedUnprefixed = false;
|
|
8006
8061
|
for (const [key, value] of Object.entries((0, import_dotenv.parse)(content))) {
|
|
8007
8062
|
const prefixed = key.startsWith(SECRET_ENV_PREFIX);
|
|
8008
|
-
if (exposure === "
|
|
8063
|
+
if (exposure === "prefixed" && !prefixed) {
|
|
8009
8064
|
skippedUnprefixed = true;
|
|
8010
8065
|
continue;
|
|
8011
8066
|
}
|
|
@@ -8022,27 +8077,32 @@ function fileSource(filePath, exposure) {
|
|
|
8022
8077
|
};
|
|
8023
8078
|
}
|
|
8024
8079
|
function secretSources(options = {}) {
|
|
8025
|
-
const sources = [
|
|
8080
|
+
const sources = [];
|
|
8081
|
+
const seen = /* @__PURE__ */ new Set();
|
|
8082
|
+
if (options.secretsFile !== void 0) {
|
|
8083
|
+
sources.push(secretsFileSource(options.secretsFile));
|
|
8084
|
+
seen.add(path5.resolve(options.secretsFile));
|
|
8085
|
+
}
|
|
8086
|
+
sources.push(envSource(options.env ?? process.env));
|
|
8026
8087
|
const home = resolveHomeDir(options);
|
|
8027
8088
|
const found = findProjectRoot(options.cwd ?? process.cwd());
|
|
8028
8089
|
const projectRoot = found && isHomeDir(found, options) ? home : found;
|
|
8029
8090
|
const filePaths = [];
|
|
8030
8091
|
if (projectRoot) {
|
|
8031
8092
|
filePaths.push({
|
|
8032
|
-
path:
|
|
8093
|
+
path: path5.join(projectRoot, ".argent", SECRETS_FILE_NAME),
|
|
8033
8094
|
exposure: "dedicated"
|
|
8034
8095
|
});
|
|
8035
8096
|
for (const name of SHARED_ENV_FILES) {
|
|
8036
|
-
filePaths.push({ path:
|
|
8097
|
+
filePaths.push({ path: path5.join(projectRoot, name), exposure: "prefixed" });
|
|
8037
8098
|
}
|
|
8038
8099
|
}
|
|
8039
8100
|
filePaths.push({
|
|
8040
|
-
path:
|
|
8101
|
+
path: path5.join(argentHomeDir(options), SECRETS_FILE_NAME),
|
|
8041
8102
|
exposure: "dedicated"
|
|
8042
8103
|
});
|
|
8043
|
-
const seen = /* @__PURE__ */ new Set();
|
|
8044
8104
|
for (const entry of filePaths) {
|
|
8045
|
-
const resolved =
|
|
8105
|
+
const resolved = path5.resolve(entry.path);
|
|
8046
8106
|
if (seen.has(resolved)) continue;
|
|
8047
8107
|
seen.add(resolved);
|
|
8048
8108
|
sources.push(fileSource(resolved, entry.exposure));
|
|
@@ -8052,6 +8112,15 @@ function secretSources(options = {}) {
|
|
|
8052
8112
|
function encodeClientSecrets(values) {
|
|
8053
8113
|
return Buffer.from(JSON.stringify(Object.fromEntries(values)), "utf8").toString("base64");
|
|
8054
8114
|
}
|
|
8115
|
+
function summarizeSecretSources(sources) {
|
|
8116
|
+
return sources.map(({ values: _values, ...summary }) => ({
|
|
8117
|
+
...summary,
|
|
8118
|
+
names: [...summary.names]
|
|
8119
|
+
}));
|
|
8120
|
+
}
|
|
8121
|
+
function encodeSecretSourceSummaries(sources) {
|
|
8122
|
+
return Buffer.from(JSON.stringify(sources), "utf8").toString("base64");
|
|
8123
|
+
}
|
|
8055
8124
|
function lookupSecret(name, sources) {
|
|
8056
8125
|
for (const source of sources) {
|
|
8057
8126
|
const value = source.values.get(name);
|
|
@@ -8157,7 +8226,9 @@ var CONFIG_SCHEMA = [
|
|
|
8157
8226
|
default: true,
|
|
8158
8227
|
// Opt-in/out goes through the dedicated command so the live client is
|
|
8159
8228
|
// drained/reset, not just the file rewritten.
|
|
8160
|
-
manageCommand: "argent telemetry"
|
|
8229
|
+
manageCommand: "argent telemetry",
|
|
8230
|
+
// consent.ts keeps a ~/.argent opt-out under a moved home; show the same.
|
|
8231
|
+
userHomeOptOut: true
|
|
8161
8232
|
},
|
|
8162
8233
|
{
|
|
8163
8234
|
key: "autoUpdate.enabled",
|
|
@@ -8166,6 +8237,8 @@ var CONFIG_SCHEMA = [
|
|
|
8166
8237
|
parse: asBoolean,
|
|
8167
8238
|
merge: "prioritize-local",
|
|
8168
8239
|
default: true,
|
|
8240
|
+
// The global install is shared by every Argent home.
|
|
8241
|
+
userHomeOptOut: true,
|
|
8169
8242
|
example: "false"
|
|
8170
8243
|
},
|
|
8171
8244
|
{
|
|
@@ -8256,7 +8329,8 @@ function getConfigDefinition(key, registry = CONFIG_SCHEMA) {
|
|
|
8256
8329
|
}
|
|
8257
8330
|
|
|
8258
8331
|
// ../configuration-core/src/config-access.ts
|
|
8259
|
-
import * as
|
|
8332
|
+
import * as fs6 from "node:fs";
|
|
8333
|
+
import * as path6 from "node:path";
|
|
8260
8334
|
function readScopeValue(def, scope, options) {
|
|
8261
8335
|
if (!def.scopes.includes(scope)) return void 0;
|
|
8262
8336
|
const raw = getAtPath(readConfigObject(scope, options), def.key);
|
|
@@ -8265,8 +8339,11 @@ function readScopeValue(def, scope, options) {
|
|
|
8265
8339
|
function getConfigValue(def, options = {}) {
|
|
8266
8340
|
const local = readScopeValue(def, "project", options);
|
|
8267
8341
|
const global = readScopeValue(def, "global", options);
|
|
8268
|
-
const merged = applyMergePolicy(def.merge, local, global);
|
|
8269
|
-
return merged
|
|
8342
|
+
const merged = applyMergePolicy(def.merge, local, global) ?? def.default;
|
|
8343
|
+
if (!def.userHomeOptOut) return merged;
|
|
8344
|
+
const userHome = { homeDir: resolveHomeDir(options) };
|
|
8345
|
+
if (argentHomeDir(options) === argentHomeDir(userHome)) return merged;
|
|
8346
|
+
return readScopeValue(def, "global", userHome) === false ? false : merged;
|
|
8270
8347
|
}
|
|
8271
8348
|
function getConfigValueByKey(key, options = {}, registry = CONFIG_SCHEMA) {
|
|
8272
8349
|
const def = requireDefinition(key, registry);
|
|
@@ -8288,22 +8365,149 @@ var UnknownConfigKeyError = class extends Error {
|
|
|
8288
8365
|
key;
|
|
8289
8366
|
};
|
|
8290
8367
|
|
|
8368
|
+
// ../configuration-core/src/cloud-android.ts
|
|
8369
|
+
import * as fs7 from "node:fs";
|
|
8370
|
+
import * as os2 from "node:os";
|
|
8371
|
+
import * as path7 from "node:path";
|
|
8372
|
+
var CLOUD_URL_ENV = "ARGENT_CLOUD_URL";
|
|
8373
|
+
var CLOUD_API_KEY_ENV = "ARGENT_CLOUD_API_KEY";
|
|
8374
|
+
function isLoopbackHost(hostname) {
|
|
8375
|
+
return hostname === "localhost" || hostname === "[::1]" || /^127(\.\d{1,3}){3}$/.test(hostname);
|
|
8376
|
+
}
|
|
8377
|
+
function parseCloudAndroidCredential(env) {
|
|
8378
|
+
const rawUrl = env[CLOUD_URL_ENV]?.trim();
|
|
8379
|
+
const apiKey = env[CLOUD_API_KEY_ENV]?.trim();
|
|
8380
|
+
if (!rawUrl || !apiKey) return null;
|
|
8381
|
+
let url;
|
|
8382
|
+
try {
|
|
8383
|
+
url = new URL(rawUrl);
|
|
8384
|
+
} catch {
|
|
8385
|
+
return null;
|
|
8386
|
+
}
|
|
8387
|
+
if (url.username || url.password || url.search || url.hash) return null;
|
|
8388
|
+
if (url.protocol !== "https:" && !(url.protocol === "http:" && isLoopbackHost(url.hostname))) {
|
|
8389
|
+
return null;
|
|
8390
|
+
}
|
|
8391
|
+
return { baseUrl: `${url.origin}${url.pathname.replace(/\/+$/, "")}`, apiKey };
|
|
8392
|
+
}
|
|
8393
|
+
function cloudAndroidMarkersDir() {
|
|
8394
|
+
if (markersDirOverride) return markersDirOverride;
|
|
8395
|
+
let home;
|
|
8396
|
+
try {
|
|
8397
|
+
home = os2.userInfo().homedir;
|
|
8398
|
+
} catch {
|
|
8399
|
+
home = "";
|
|
8400
|
+
}
|
|
8401
|
+
return path7.join(home || os2.homedir(), ".argent", "cloud-android-leases");
|
|
8402
|
+
}
|
|
8403
|
+
var markersDirOverride = null;
|
|
8404
|
+
function primaryGid() {
|
|
8405
|
+
try {
|
|
8406
|
+
return os2.userInfo().gid;
|
|
8407
|
+
} catch {
|
|
8408
|
+
return process.getgid?.();
|
|
8409
|
+
}
|
|
8410
|
+
}
|
|
8411
|
+
function untrusted(dir) {
|
|
8412
|
+
const uid = process.getuid?.();
|
|
8413
|
+
if (uid === void 0) return null;
|
|
8414
|
+
const otherCanWrite = (stat7) => {
|
|
8415
|
+
const ownPrivateGroup = process.platform === "linux" && stat7.gid === primaryGid();
|
|
8416
|
+
return (stat7.mode & 2) !== 0 || (stat7.mode & 16) !== 0 && !ownPrivateGroup;
|
|
8417
|
+
};
|
|
8418
|
+
let stat6;
|
|
8419
|
+
let parent;
|
|
8420
|
+
try {
|
|
8421
|
+
stat6 = fs7.lstatSync(dir);
|
|
8422
|
+
parent = fs7.statSync(path7.dirname(dir));
|
|
8423
|
+
} catch {
|
|
8424
|
+
return "it cannot be read";
|
|
8425
|
+
}
|
|
8426
|
+
if (!stat6.isDirectory()) return "it is not a directory";
|
|
8427
|
+
if (stat6.uid !== uid) return "another account owns it";
|
|
8428
|
+
if ((stat6.mode & 63) !== 0) return "other accounts can read or write it";
|
|
8429
|
+
if (parent.uid !== uid && parent.uid !== 0 || otherCanWrite(parent)) {
|
|
8430
|
+
return "other accounts can write its parent directory";
|
|
8431
|
+
}
|
|
8432
|
+
return null;
|
|
8433
|
+
}
|
|
8434
|
+
function trustedCloudAndroidMarkersDir() {
|
|
8435
|
+
const dir = cloudAndroidMarkersDir();
|
|
8436
|
+
return untrusted(dir) ? null : dir;
|
|
8437
|
+
}
|
|
8438
|
+
var CLOUD_ANDROID_MARKER_TTL_MS = 2 * 6e4;
|
|
8439
|
+
function readCloudAndroidMarker(file) {
|
|
8440
|
+
try {
|
|
8441
|
+
const raw = JSON.parse(fs7.readFileSync(file, "utf8"));
|
|
8442
|
+
if (typeof raw.pid !== "number" || typeof raw.lease !== "string") return null;
|
|
8443
|
+
if (typeof raw.serial !== "string") return null;
|
|
8444
|
+
return {
|
|
8445
|
+
serial: raw.serial,
|
|
8446
|
+
pid: raw.pid,
|
|
8447
|
+
lease: raw.lease,
|
|
8448
|
+
refreshedAt: fs7.statSync(file).mtimeMs
|
|
8449
|
+
};
|
|
8450
|
+
} catch {
|
|
8451
|
+
return null;
|
|
8452
|
+
}
|
|
8453
|
+
}
|
|
8454
|
+
function readCloudAndroidMarkers(dir = trustedCloudAndroidMarkersDir()) {
|
|
8455
|
+
if (!dir) return [];
|
|
8456
|
+
let names;
|
|
8457
|
+
try {
|
|
8458
|
+
names = fs7.readdirSync(dir);
|
|
8459
|
+
} catch {
|
|
8460
|
+
return [];
|
|
8461
|
+
}
|
|
8462
|
+
return names.filter((name) => name.endsWith(".json")).map((name) => readCloudAndroidMarker(path7.join(dir, name))).filter((marker) => marker !== null);
|
|
8463
|
+
}
|
|
8464
|
+
function pidAlive(pid) {
|
|
8465
|
+
try {
|
|
8466
|
+
process.kill(pid, 0);
|
|
8467
|
+
return true;
|
|
8468
|
+
} catch (err) {
|
|
8469
|
+
return err.code === "EPERM";
|
|
8470
|
+
}
|
|
8471
|
+
}
|
|
8472
|
+
function isLiveCloudAndroidMarker(marker, now = Date.now()) {
|
|
8473
|
+
return now - marker.refreshedAt < CLOUD_ANDROID_MARKER_TTL_MS && pidAlive(marker.pid);
|
|
8474
|
+
}
|
|
8475
|
+
function cloudAndroidLeaseHolders(dir = trustedCloudAndroidMarkersDir()) {
|
|
8476
|
+
const now = Date.now();
|
|
8477
|
+
return new Set(
|
|
8478
|
+
readCloudAndroidMarkers(dir).filter((marker) => isLiveCloudAndroidMarker(marker, now)).map((marker) => marker.pid)
|
|
8479
|
+
);
|
|
8480
|
+
}
|
|
8481
|
+
|
|
8291
8482
|
// ../argent-tools-client/src/launcher.ts
|
|
8292
8483
|
import * as net from "node:net";
|
|
8293
|
-
import * as
|
|
8294
|
-
import * as
|
|
8484
|
+
import * as os3 from "node:os";
|
|
8485
|
+
import * as fs8 from "node:fs";
|
|
8486
|
+
import * as path8 from "node:path";
|
|
8295
8487
|
import * as readline from "node:readline";
|
|
8296
|
-
import { homedir as homedir3 } from "node:os";
|
|
8297
8488
|
import { spawn, execFileSync } from "node:child_process";
|
|
8298
|
-
import { createHash, randomBytes } from "node:crypto";
|
|
8299
|
-
import {
|
|
8300
|
-
var STATE_DIR =
|
|
8301
|
-
var STATE_FILE =
|
|
8302
|
-
var LOG_FILE =
|
|
8303
|
-
var LOCK_FILE =
|
|
8489
|
+
import { createHash, randomBytes as randomBytes2 } from "node:crypto";
|
|
8490
|
+
import { readFile, readdir, unlink } from "node:fs/promises";
|
|
8491
|
+
var STATE_DIR = argentHomeDir();
|
|
8492
|
+
var STATE_FILE = path8.join(STATE_DIR, "tool-server.json");
|
|
8493
|
+
var LOG_FILE = path8.join(STATE_DIR, "tool-server.log");
|
|
8494
|
+
var LOCK_FILE = path8.join(STATE_DIR, "tool-server.lock");
|
|
8304
8495
|
var AUTH_TOKEN_BYTES = 32;
|
|
8305
8496
|
var AUTH_TOKEN_ENV = "ARGENT_AUTH_TOKEN";
|
|
8306
8497
|
var AUTOSPAWN_IDLE_TIMEOUT_MINUTES = 30;
|
|
8498
|
+
var CLOUD_URL_ENV2 = "ARGENT_CLOUD_URL";
|
|
8499
|
+
var CLOUD_API_KEY_ENV2 = "ARGENT_CLOUD_API_KEY";
|
|
8500
|
+
function cloudCredential(env = process.env) {
|
|
8501
|
+
const parsed = parseCloudAndroidCredential(env);
|
|
8502
|
+
return parsed ? { url: parsed.baseUrl, apiKey: parsed.apiKey } : null;
|
|
8503
|
+
}
|
|
8504
|
+
function linkedCloudCredentialNotice(env = process.env) {
|
|
8505
|
+
if (!cloudCredential(env)) return null;
|
|
8506
|
+
return "[argent] ARGENT_CLOUD_URL and ARGENT_CLOUD_API_KEY are not used over a linked tool-server (ARGENT_TOOLS_URL or `argent link`): it never receives them. Unlink to use them on this machine.";
|
|
8507
|
+
}
|
|
8508
|
+
function cloudProfileId(credential) {
|
|
8509
|
+
return createHash("sha256").update(`argent-cloud-android\0${credential.url}\0${credential.apiKey}`).digest("hex").slice(0, 12);
|
|
8510
|
+
}
|
|
8307
8511
|
var AUTOSPAWN_HOST = "127.0.0.1";
|
|
8308
8512
|
function buildToolsServerEnv(paths, port, baseEnv = process.env, options = {}) {
|
|
8309
8513
|
const env = {
|
|
@@ -8312,6 +8516,12 @@ function buildToolsServerEnv(paths, port, baseEnv = process.env, options = {}) {
|
|
|
8312
8516
|
ARGENT_SIMULATOR_SERVER_DIR: paths.simulatorServerDir,
|
|
8313
8517
|
ARGENT_NATIVE_DEVTOOLS_DIR: paths.nativeDevtoolsDir
|
|
8314
8518
|
};
|
|
8519
|
+
delete env[CLOUD_API_KEY_ENV2];
|
|
8520
|
+
delete env[CLOUD_URL_ENV2];
|
|
8521
|
+
if (options.cloud) {
|
|
8522
|
+
env[CLOUD_URL_ENV2] = options.cloud.url;
|
|
8523
|
+
env[CLOUD_API_KEY_ENV2] = options.cloud.apiKey;
|
|
8524
|
+
}
|
|
8315
8525
|
if (options.host !== void 0) env.ARGENT_HOST = options.host;
|
|
8316
8526
|
if (options.idleTimeoutMinutes !== void 0) {
|
|
8317
8527
|
env.ARGENT_IDLE_TIMEOUT_MINUTES = String(options.idleTimeoutMinutes);
|
|
@@ -8323,10 +8533,10 @@ function buildToolsServerEnv(paths, port, baseEnv = process.env, options = {}) {
|
|
|
8323
8533
|
return env;
|
|
8324
8534
|
}
|
|
8325
8535
|
function generateToken() {
|
|
8326
|
-
return
|
|
8536
|
+
return randomBytes2(AUTH_TOKEN_BYTES).toString("hex");
|
|
8327
8537
|
}
|
|
8328
8538
|
function findFreePort() {
|
|
8329
|
-
return new Promise((
|
|
8539
|
+
return new Promise((resolve12, reject) => {
|
|
8330
8540
|
const srv = net.createServer();
|
|
8331
8541
|
srv.listen(0, "127.0.0.1", () => {
|
|
8332
8542
|
const addr = srv.address();
|
|
@@ -8337,21 +8547,21 @@ function findFreePort() {
|
|
|
8337
8547
|
const port = addr.port;
|
|
8338
8548
|
srv.close((err) => {
|
|
8339
8549
|
if (err) reject(err);
|
|
8340
|
-
else
|
|
8550
|
+
else resolve12(port);
|
|
8341
8551
|
});
|
|
8342
8552
|
});
|
|
8343
8553
|
srv.on("error", reject);
|
|
8344
8554
|
});
|
|
8345
8555
|
}
|
|
8346
8556
|
function isVersionNewer(a, b) {
|
|
8347
|
-
const
|
|
8557
|
+
const parse3 = (v) => {
|
|
8348
8558
|
const [core = "", ...preParts] = v.split("+")[0].split("-");
|
|
8349
8559
|
const nums = core.split(".").map((n) => Number.parseInt(n, 10));
|
|
8350
8560
|
if (nums.length === 0 || nums.some((n) => Number.isNaN(n))) return null;
|
|
8351
8561
|
return { nums, pre: preParts.length > 0 ? preParts.join("-").split(".") : [] };
|
|
8352
8562
|
};
|
|
8353
|
-
const pa =
|
|
8354
|
-
const pb =
|
|
8563
|
+
const pa = parse3(a);
|
|
8564
|
+
const pb = parse3(b);
|
|
8355
8565
|
if (!pa || !pb) return false;
|
|
8356
8566
|
for (let i = 0; i < 3; i++) {
|
|
8357
8567
|
const x = pa.nums[i] ?? 0;
|
|
@@ -8379,7 +8589,7 @@ function isVersionNewer(a, b) {
|
|
|
8379
8589
|
function readBundlePackageVersion(bundlePath) {
|
|
8380
8590
|
try {
|
|
8381
8591
|
const pkg = JSON.parse(
|
|
8382
|
-
|
|
8592
|
+
fs8.readFileSync(path8.join(path8.dirname(bundlePath), "..", "package.json"), "utf8")
|
|
8383
8593
|
);
|
|
8384
8594
|
return typeof pkg.version === "string" ? pkg.version : void 0;
|
|
8385
8595
|
} catch {
|
|
@@ -8436,16 +8646,20 @@ function killSpawnedChild(child, pid) {
|
|
|
8436
8646
|
}
|
|
8437
8647
|
function resolveToolsServerNode() {
|
|
8438
8648
|
const { bun, deno, electron } = process.versions;
|
|
8439
|
-
return !(bun || deno || electron) &&
|
|
8649
|
+
return !(bun || deno || electron) && fs8.existsSync(process.execPath) ? process.execPath : "node";
|
|
8650
|
+
}
|
|
8651
|
+
function parseListeningPort(line) {
|
|
8652
|
+
const match = line.match(/Tools server listening on http:\/\/.+:(\d+)/);
|
|
8653
|
+
return match ? parseInt(match[1], 10) : null;
|
|
8440
8654
|
}
|
|
8441
8655
|
function spawnToolsServer(paths, port, options = {}) {
|
|
8442
|
-
return new Promise((
|
|
8656
|
+
return new Promise((resolve12, reject) => {
|
|
8443
8657
|
let logFd;
|
|
8444
8658
|
try {
|
|
8445
|
-
|
|
8446
|
-
logFd =
|
|
8659
|
+
fs8.mkdirSync(STATE_DIR, { recursive: true });
|
|
8660
|
+
logFd = fs8.openSync(LOG_FILE, "a");
|
|
8447
8661
|
} catch {
|
|
8448
|
-
logFd =
|
|
8662
|
+
logFd = fs8.openSync("/dev/null", "w");
|
|
8449
8663
|
}
|
|
8450
8664
|
const nodeBin = resolveToolsServerNode();
|
|
8451
8665
|
const child = spawn(nodeBin, [paths.bundlePath, "start"], {
|
|
@@ -8453,8 +8667,7 @@ function spawnToolsServer(paths, port, options = {}) {
|
|
|
8453
8667
|
stdio: ["ignore", "pipe", logFd],
|
|
8454
8668
|
env: buildToolsServerEnv(paths, port, process.env, options)
|
|
8455
8669
|
});
|
|
8456
|
-
|
|
8457
|
-
child.unref();
|
|
8670
|
+
fs8.closeSync(logFd);
|
|
8458
8671
|
const pid = child.pid;
|
|
8459
8672
|
if (!pid) {
|
|
8460
8673
|
child.once(
|
|
@@ -8479,13 +8692,13 @@ function spawnToolsServer(paths, port, options = {}) {
|
|
|
8479
8692
|
});
|
|
8480
8693
|
const rl = readline.createInterface({ input: child.stdout });
|
|
8481
8694
|
rl.on("line", (line) => {
|
|
8482
|
-
const
|
|
8483
|
-
if (
|
|
8484
|
-
const actualPort = parseInt(match[1], 10);
|
|
8695
|
+
const actualPort = parseListeningPort(line);
|
|
8696
|
+
if (actualPort !== null) {
|
|
8485
8697
|
rl.close();
|
|
8486
8698
|
child.stdout?.resume();
|
|
8487
8699
|
child.stdout?.unref?.();
|
|
8488
|
-
|
|
8700
|
+
child.unref();
|
|
8701
|
+
settle(() => resolve12({ port: actualPort, pid }));
|
|
8489
8702
|
}
|
|
8490
8703
|
});
|
|
8491
8704
|
child.on("error", (err) => {
|
|
@@ -8503,9 +8716,10 @@ function spawnToolsServer(paths, port, options = {}) {
|
|
|
8503
8716
|
rl.on("close", () => clearTimeout(timer));
|
|
8504
8717
|
});
|
|
8505
8718
|
}
|
|
8506
|
-
function stateFileForBundle(bundlePath) {
|
|
8719
|
+
function stateFileForBundle(bundlePath, cloudProfile) {
|
|
8507
8720
|
const key = createHash("sha256").update(bundlePath).digest("hex").slice(0, 12);
|
|
8508
|
-
|
|
8721
|
+
const profile = cloudProfile ? `-cloud-${cloudProfile}` : "";
|
|
8722
|
+
return path8.join(STATE_DIR, `tool-server-${key}${profile}.json`);
|
|
8509
8723
|
}
|
|
8510
8724
|
async function readStateFile(file) {
|
|
8511
8725
|
try {
|
|
@@ -8515,33 +8729,81 @@ async function readStateFile(file) {
|
|
|
8515
8729
|
return null;
|
|
8516
8730
|
}
|
|
8517
8731
|
}
|
|
8518
|
-
async function readToolsServerState(bundlePath) {
|
|
8732
|
+
async function readToolsServerState(bundlePath, cloudProfile) {
|
|
8519
8733
|
if (bundlePath === void 0) return readStateFile(STATE_FILE);
|
|
8734
|
+
if (cloudProfile) {
|
|
8735
|
+
const own2 = await readStateFile(stateFileForBundle(bundlePath, cloudProfile));
|
|
8736
|
+
return own2?.cloudProfile === cloudProfile ? own2 : null;
|
|
8737
|
+
}
|
|
8520
8738
|
const own = await readStateFile(stateFileForBundle(bundlePath));
|
|
8521
8739
|
if (own) return own;
|
|
8522
8740
|
const legacy = await readStateFile(STATE_FILE);
|
|
8523
8741
|
return legacy && legacy.bundlePath === bundlePath ? legacy : null;
|
|
8524
8742
|
}
|
|
8525
|
-
|
|
8526
|
-
const target = stateFileForBundle(state.bundlePath);
|
|
8527
|
-
await mkdir(STATE_DIR, { recursive: true });
|
|
8528
|
-
const tmp = `${target}.${process.pid}.tmp`;
|
|
8743
|
+
function primaryGid2() {
|
|
8529
8744
|
try {
|
|
8530
|
-
|
|
8531
|
-
|
|
8532
|
-
|
|
8533
|
-
|
|
8534
|
-
|
|
8535
|
-
|
|
8536
|
-
|
|
8537
|
-
|
|
8538
|
-
|
|
8539
|
-
|
|
8745
|
+
return os3.userInfo().gid;
|
|
8746
|
+
} catch {
|
|
8747
|
+
return process.getgid?.();
|
|
8748
|
+
}
|
|
8749
|
+
}
|
|
8750
|
+
var UnsafeArgentHomeError = class extends Error {
|
|
8751
|
+
name = "UnsafeArgentHomeError";
|
|
8752
|
+
};
|
|
8753
|
+
function statHome() {
|
|
8754
|
+
try {
|
|
8755
|
+
fs8.mkdirSync(path8.dirname(STATE_DIR), { recursive: true });
|
|
8756
|
+
fs8.mkdirSync(STATE_DIR, { mode: 448 });
|
|
8757
|
+
} catch {
|
|
8758
|
+
}
|
|
8759
|
+
try {
|
|
8760
|
+
return fs8.statSync(STATE_DIR);
|
|
8761
|
+
} catch {
|
|
8762
|
+
return null;
|
|
8540
8763
|
}
|
|
8541
8764
|
}
|
|
8542
|
-
|
|
8765
|
+
function isWritable(dir) {
|
|
8766
|
+
try {
|
|
8767
|
+
fs8.accessSync(dir, fs8.constants.W_OK);
|
|
8768
|
+
return true;
|
|
8769
|
+
} catch {
|
|
8770
|
+
return false;
|
|
8771
|
+
}
|
|
8772
|
+
}
|
|
8773
|
+
function assertPrivateArgentHome() {
|
|
8774
|
+
const uid = process.getuid?.();
|
|
8775
|
+
if (uid === void 0) return;
|
|
8776
|
+
const stat6 = statHome();
|
|
8777
|
+
if (!stat6) return;
|
|
8778
|
+
if (stat6.uid !== uid && !(stat6.uid === 0 && isWritable(STATE_DIR))) {
|
|
8779
|
+
throw new UnsafeArgentHomeError(
|
|
8780
|
+
`The Argent home ${STATE_DIR} belongs to another user. Change its owner or set ARGENT_HOME_DIR to a directory you own.`
|
|
8781
|
+
);
|
|
8782
|
+
}
|
|
8783
|
+
const ownPrivateGroup = process.platform === "linux" && stat6.gid === primaryGid2();
|
|
8784
|
+
const groupCanWrite = (stat6.mode & 16) !== 0 && !ownPrivateGroup;
|
|
8785
|
+
if ((stat6.mode & 2) !== 0 || groupCanWrite) {
|
|
8786
|
+
throw new UnsafeArgentHomeError(
|
|
8787
|
+
`The Argent home ${STATE_DIR} is writable by other users. If only you have used it, run \`chmod go-w '${STATE_DIR}'\`. Otherwise set ARGENT_HOME_DIR to a new private directory.`
|
|
8788
|
+
);
|
|
8789
|
+
}
|
|
8790
|
+
}
|
|
8791
|
+
async function writeToolsServerState(state) {
|
|
8792
|
+
writeToolsServerStateSync(state);
|
|
8793
|
+
}
|
|
8794
|
+
function writeToolsServerStateSync(state) {
|
|
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
|
+
);
|
|
8801
|
+
}
|
|
8802
|
+
async function clearToolsServerState(bundlePath, cloudProfile) {
|
|
8543
8803
|
const files = [STATE_FILE];
|
|
8544
|
-
if (bundlePath !== void 0) {
|
|
8804
|
+
if (bundlePath !== void 0 && cloudProfile) {
|
|
8805
|
+
files[0] = stateFileForBundle(bundlePath, cloudProfile);
|
|
8806
|
+
} else if (bundlePath !== void 0) {
|
|
8545
8807
|
files[0] = stateFileForBundle(bundlePath);
|
|
8546
8808
|
const legacy = await readStateFile(STATE_FILE);
|
|
8547
8809
|
if (legacy && legacy.bundlePath === bundlePath) files.push(STATE_FILE);
|
|
@@ -8553,7 +8815,7 @@ async function clearToolsServerState(bundlePath) {
|
|
|
8553
8815
|
}
|
|
8554
8816
|
}
|
|
8555
8817
|
}
|
|
8556
|
-
var STATE_FILE_RE = /^tool-server(-[0-9a-f]{12})?\.json$/;
|
|
8818
|
+
var STATE_FILE_RE = /^tool-server(-[0-9a-f]{12}(-cloud-[0-9a-f]{12})?)?\.json$/;
|
|
8557
8819
|
async function readAllToolsServerStates() {
|
|
8558
8820
|
let names;
|
|
8559
8821
|
try {
|
|
@@ -8564,7 +8826,7 @@ async function readAllToolsServerStates() {
|
|
|
8564
8826
|
const out = [];
|
|
8565
8827
|
for (const name of names) {
|
|
8566
8828
|
if (!STATE_FILE_RE.test(name)) continue;
|
|
8567
|
-
const file =
|
|
8829
|
+
const file = path8.join(STATE_DIR, name);
|
|
8568
8830
|
const state = await readStateFile(file);
|
|
8569
8831
|
if (state) out.push({ file, state });
|
|
8570
8832
|
}
|
|
@@ -8580,7 +8842,7 @@ async function sweepDeadStateFiles() {
|
|
|
8580
8842
|
});
|
|
8581
8843
|
continue;
|
|
8582
8844
|
}
|
|
8583
|
-
if (
|
|
8845
|
+
if (fs8.existsSync(fresh.bundlePath)) continue;
|
|
8584
8846
|
if (!couldBeOurToolServer(fresh.pid, fresh.bundlePath)) continue;
|
|
8585
8847
|
await unlink(file).catch(() => {
|
|
8586
8848
|
});
|
|
@@ -8617,17 +8879,21 @@ async function terminatePid(pid, stillOurs) {
|
|
|
8617
8879
|
}
|
|
8618
8880
|
await waitForExit(pid, SIGKILL_GRACE_MS);
|
|
8619
8881
|
}
|
|
8620
|
-
async function killToolServer(bundlePath) {
|
|
8621
|
-
const state = await readState(bundlePath);
|
|
8882
|
+
async function killToolServer(bundlePath, cloudProfile) {
|
|
8883
|
+
const state = await readState(bundlePath, cloudProfile);
|
|
8622
8884
|
if (!state) return false;
|
|
8623
8885
|
const stillOurs = () => couldBeOurToolServer(state.pid, state.bundlePath);
|
|
8624
8886
|
const alive = isProcessAlive(state.pid);
|
|
8625
8887
|
if (alive && !stillOurs()) return false;
|
|
8626
8888
|
if (alive) await terminatePid(state.pid, stillOurs);
|
|
8627
|
-
await clearToolsServerState(bundlePath ?? state.bundlePath);
|
|
8889
|
+
await clearToolsServerState(bundlePath ?? state.bundlePath, cloudProfile);
|
|
8628
8890
|
return alive;
|
|
8629
8891
|
}
|
|
8630
|
-
|
|
8892
|
+
function clientCloudProfile(env = process.env) {
|
|
8893
|
+
const cloud = cloudCredential(env);
|
|
8894
|
+
return cloud ? cloudProfileId(cloud) : void 0;
|
|
8895
|
+
}
|
|
8896
|
+
var PS_BIN = ["/bin/ps", "/usr/bin/ps"].find((p) => fs8.existsSync(p)) ?? "ps";
|
|
8631
8897
|
var PS_WIDTH_FLAGS = ["-ww"];
|
|
8632
8898
|
var PS_LOCALE = process.platform === "darwin" ? "en_US.UTF-8" : "C.UTF-8";
|
|
8633
8899
|
function readProcessCommandLine(pid, flags = PS_WIDTH_FLAGS, env = { ...process.env, LC_ALL: PS_LOCALE }) {
|
|
@@ -8674,13 +8940,13 @@ var LOCK_STALE_MS = 45e3;
|
|
|
8674
8940
|
var LOCK_POLL_MS = 100;
|
|
8675
8941
|
function spawnLockIsStale() {
|
|
8676
8942
|
try {
|
|
8677
|
-
const { pid, ts } = JSON.parse(
|
|
8943
|
+
const { pid, ts } = JSON.parse(fs8.readFileSync(LOCK_FILE, "utf8"));
|
|
8678
8944
|
if (typeof pid === "number" && pid > 0 && !isProcessAlive(pid)) return true;
|
|
8679
8945
|
if (typeof ts === "number" && Date.now() - ts > LOCK_STALE_MS) return true;
|
|
8680
8946
|
return false;
|
|
8681
8947
|
} catch {
|
|
8682
8948
|
try {
|
|
8683
|
-
return Date.now() -
|
|
8949
|
+
return Date.now() - fs8.statSync(LOCK_FILE).mtimeMs > LOCK_STALE_MS;
|
|
8684
8950
|
} catch {
|
|
8685
8951
|
return true;
|
|
8686
8952
|
}
|
|
@@ -8688,19 +8954,19 @@ function spawnLockIsStale() {
|
|
|
8688
8954
|
}
|
|
8689
8955
|
async function acquireSpawnLock() {
|
|
8690
8956
|
try {
|
|
8691
|
-
|
|
8957
|
+
fs8.mkdirSync(STATE_DIR, { recursive: true });
|
|
8692
8958
|
} catch {
|
|
8693
8959
|
return null;
|
|
8694
8960
|
}
|
|
8695
|
-
const nonce =
|
|
8961
|
+
const nonce = randomBytes2(8).toString("hex");
|
|
8696
8962
|
const deadline = Date.now() + LOCK_WAIT_TIMEOUT_MS;
|
|
8697
8963
|
for (; ; ) {
|
|
8698
8964
|
try {
|
|
8699
|
-
const fd =
|
|
8965
|
+
const fd = fs8.openSync(LOCK_FILE, "wx");
|
|
8700
8966
|
try {
|
|
8701
|
-
|
|
8967
|
+
fs8.writeSync(fd, JSON.stringify({ pid: process.pid, nonce, ts: Date.now() }));
|
|
8702
8968
|
} finally {
|
|
8703
|
-
|
|
8969
|
+
fs8.closeSync(fd);
|
|
8704
8970
|
}
|
|
8705
8971
|
let released = false;
|
|
8706
8972
|
return {
|
|
@@ -8708,8 +8974,8 @@ async function acquireSpawnLock() {
|
|
|
8708
8974
|
if (released) return;
|
|
8709
8975
|
released = true;
|
|
8710
8976
|
try {
|
|
8711
|
-
const cur = JSON.parse(
|
|
8712
|
-
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);
|
|
8713
8979
|
} catch {
|
|
8714
8980
|
}
|
|
8715
8981
|
}
|
|
@@ -8718,10 +8984,10 @@ async function acquireSpawnLock() {
|
|
|
8718
8984
|
if (err.code !== "EEXIST") return null;
|
|
8719
8985
|
if (spawnLockIsStale()) {
|
|
8720
8986
|
try {
|
|
8721
|
-
|
|
8987
|
+
fs8.unlinkSync(LOCK_FILE);
|
|
8722
8988
|
} catch {
|
|
8723
8989
|
}
|
|
8724
|
-
if (!
|
|
8990
|
+
if (!fs8.existsSync(LOCK_FILE)) continue;
|
|
8725
8991
|
}
|
|
8726
8992
|
if (Date.now() >= deadline) return null;
|
|
8727
8993
|
await new Promise((r) => setTimeout(r, LOCK_POLL_MS));
|
|
@@ -8731,7 +8997,8 @@ async function acquireSpawnLock() {
|
|
|
8731
8997
|
async function reusableHandle(state, wantBundlePath, wantVersion) {
|
|
8732
8998
|
if (!state || !isProcessAlive(state.pid)) return null;
|
|
8733
8999
|
if (wantBundlePath !== void 0 && state.bundlePath !== wantBundlePath) return null;
|
|
8734
|
-
|
|
9000
|
+
const holdsLease = state.cloudProfile !== void 0 && cloudAndroidLeaseHolders().has(state.pid);
|
|
9001
|
+
if (wantBundlePath !== void 0 && state.version !== void 0 && !holdsLease) {
|
|
8735
9002
|
const diskVersion = readBundlePackageVersion(wantBundlePath);
|
|
8736
9003
|
if (diskVersion !== void 0) {
|
|
8737
9004
|
if (diskVersion !== state.version) return null;
|
|
@@ -8744,24 +9011,24 @@ async function reusableHandle(state, wantBundlePath, wantVersion) {
|
|
|
8744
9011
|
if (!healthy) return null;
|
|
8745
9012
|
return { url: formatUrl(healthCheckHost(host), state.port), token: state.token ?? "" };
|
|
8746
9013
|
}
|
|
8747
|
-
async function ensureToolsServer(paths) {
|
|
8748
|
-
|
|
8749
|
-
|
|
8750
|
-
|
|
8751
|
-
|
|
8752
|
-
);
|
|
9014
|
+
async function ensureToolsServer(paths, env = process.env) {
|
|
9015
|
+
assertPrivateArgentHome();
|
|
9016
|
+
const cloud = cloudCredential(env) ?? void 0;
|
|
9017
|
+
const cloudProfile = clientCloudProfile(env);
|
|
9018
|
+
const readOwnState = () => readState(paths.bundlePath, cloudProfile);
|
|
9019
|
+
const fast = await reusableHandle(await readOwnState(), paths.bundlePath, paths.version);
|
|
8753
9020
|
if (fast) return fast;
|
|
8754
9021
|
const lock = await acquireSpawnLock();
|
|
8755
9022
|
try {
|
|
8756
|
-
const state = await
|
|
9023
|
+
const state = await readOwnState();
|
|
8757
9024
|
const reuse = await reusableHandle(state, paths.bundlePath, paths.version);
|
|
8758
9025
|
if (reuse) return reuse;
|
|
8759
9026
|
if (state && state.managed === "autospawn" && state.bundlePath === paths.bundlePath && isProcessAlive(state.pid) && couldBeOurToolServer(state.pid, state.bundlePath)) {
|
|
8760
9027
|
await terminatePid(state.pid, () => couldBeOurToolServer(state.pid, state.bundlePath));
|
|
8761
9028
|
}
|
|
8762
|
-
await clearToolsServerState(paths.bundlePath);
|
|
9029
|
+
await clearToolsServerState(paths.bundlePath, cloudProfile);
|
|
8763
9030
|
await sweepDeadStateFiles();
|
|
8764
|
-
if (!
|
|
9031
|
+
if (!fs8.existsSync(paths.bundlePath)) {
|
|
8765
9032
|
throw new Error(
|
|
8766
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.`
|
|
8767
9034
|
);
|
|
@@ -8772,9 +9039,11 @@ async function ensureToolsServer(paths) {
|
|
|
8772
9039
|
const { port: actualPort, pid } = await spawnToolsServer(paths, port, {
|
|
8773
9040
|
token,
|
|
8774
9041
|
host: AUTOSPAWN_HOST,
|
|
8775
|
-
idleTimeoutMinutes: AUTOSPAWN_IDLE_TIMEOUT_MINUTES
|
|
9042
|
+
idleTimeoutMinutes: AUTOSPAWN_IDLE_TIMEOUT_MINUTES,
|
|
9043
|
+
...cloud ? { cloud } : {}
|
|
8776
9044
|
});
|
|
8777
9045
|
await writeState({
|
|
9046
|
+
...cloudProfile ? { cloudProfile } : {},
|
|
8778
9047
|
port: actualPort,
|
|
8779
9048
|
pid,
|
|
8780
9049
|
startedAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
@@ -8794,12 +9063,17 @@ async function ensureToolsServer(paths) {
|
|
|
8794
9063
|
var import_yaml2 = __toESM(require_dist2(), 1);
|
|
8795
9064
|
import { readFile as readFile5 } from "node:fs/promises";
|
|
8796
9065
|
import { maxHeaderSize } from "node:http";
|
|
8797
|
-
import * as
|
|
9066
|
+
import * as path14 from "node:path";
|
|
8798
9067
|
|
|
8799
9068
|
// ../registry/src/types.ts
|
|
8800
9069
|
var LINKED_CALL_HEADER = "x-argent-linked";
|
|
8801
9070
|
var E2E_DIR_CLIENT_HEADER = "x-argent-e2e-dir";
|
|
8802
9071
|
var CLIENT_SECRETS_HEADER = "x-argent-client-secrets";
|
|
9072
|
+
var SESSION_HEADER = "x-argent-session";
|
|
9073
|
+
function isValidSession(session) {
|
|
9074
|
+
return /^[\x21-\x7e]{1,128}$/.test(session);
|
|
9075
|
+
}
|
|
9076
|
+
var CLIENT_SECRET_SOURCES_HEADER = "x-argent-client-secret-sources";
|
|
8803
9077
|
|
|
8804
9078
|
// ../registry/src/artifacts.ts
|
|
8805
9079
|
import { stat } from "node:fs/promises";
|
|
@@ -8855,8 +9129,8 @@ var UNEXPANDED_PATH = /^~|\$[A-Za-z0-9_{(]|`|%[A-Za-z_][A-Za-z0-9_]*%|^[A-Za-z][
|
|
|
8855
9129
|
function isUnexpandedPath(p) {
|
|
8856
9130
|
return UNEXPANDED_PATH.test(p);
|
|
8857
9131
|
}
|
|
8858
|
-
function isClientFileArgument({ spec, path:
|
|
8859
|
-
return spec.kind === "file" && spec.path === `\${${spec.target}}` &&
|
|
9132
|
+
function isClientFileArgument({ spec, path: path16 }) {
|
|
9133
|
+
return spec.kind === "file" && spec.path === `\${${spec.target}}` && path16.startsWith("/") && hasToolFileExtension(path16);
|
|
8860
9134
|
}
|
|
8861
9135
|
|
|
8862
9136
|
// ../registry/src/flow-platforms.ts
|
|
@@ -8864,26 +9138,26 @@ var LAUNCH_PLATFORMS = ["ios", "android", "chromium", "vega", "macos"];
|
|
|
8864
9138
|
var SELECTABLE_PLATFORMS = [...LAUNCH_PLATFORMS, "ios-remote"];
|
|
8865
9139
|
|
|
8866
9140
|
// ../registry/src/flow-file-refs.ts
|
|
8867
|
-
import * as
|
|
8868
|
-
import * as
|
|
9141
|
+
import * as fs10 from "node:fs/promises";
|
|
9142
|
+
import * as path10 from "node:path";
|
|
8869
9143
|
|
|
8870
9144
|
// ../registry/src/e2e-dirs.ts
|
|
8871
|
-
import * as
|
|
8872
|
-
import * as
|
|
8873
|
-
var E2E_DIR =
|
|
8874
|
-
var LEGACY_E2E_DIRS = Object.freeze([
|
|
9145
|
+
import * as fs9 from "node:fs/promises";
|
|
9146
|
+
import * as path9 from "node:path";
|
|
9147
|
+
var E2E_DIR = path9.join(".argent", "e2e");
|
|
9148
|
+
var LEGACY_E2E_DIRS = Object.freeze([path9.join(".argent", "flows")]);
|
|
8875
9149
|
var E2E_DIRS = Object.freeze([E2E_DIR, ...LEGACY_E2E_DIRS]);
|
|
8876
9150
|
function e2eDirFor(projectRoot) {
|
|
8877
|
-
return
|
|
9151
|
+
return path9.join(projectRoot, E2E_DIR);
|
|
8878
9152
|
}
|
|
8879
9153
|
function e2eDirsFor(projectRoot) {
|
|
8880
|
-
return E2E_DIRS.map((dir) =>
|
|
9154
|
+
return E2E_DIRS.map((dir) => path9.join(projectRoot, dir));
|
|
8881
9155
|
}
|
|
8882
9156
|
function e2eFileCandidates(projectRoot, name) {
|
|
8883
|
-
return e2eDirsFor(projectRoot).map((dir) =>
|
|
9157
|
+
return e2eDirsFor(projectRoot).map((dir) => path9.join(dir, `${name}.yaml`));
|
|
8884
9158
|
}
|
|
8885
9159
|
async function exists(file) {
|
|
8886
|
-
return
|
|
9160
|
+
return fs9.stat(file).then(
|
|
8887
9161
|
() => true,
|
|
8888
9162
|
() => false
|
|
8889
9163
|
);
|
|
@@ -8910,21 +9184,21 @@ async function pickE2eFile(candidates) {
|
|
|
8910
9184
|
function e2eShadowWarning(used, shadowed) {
|
|
8911
9185
|
return `${shadowed} is not used: ${used} has the same name and is read first.`;
|
|
8912
9186
|
}
|
|
8913
|
-
var E2E_DIR_NAMES = E2E_DIRS.map((dir) =>
|
|
9187
|
+
var E2E_DIR_NAMES = E2E_DIRS.map((dir) => path9.basename(dir));
|
|
8914
9188
|
function e2eDirProject(dir) {
|
|
8915
9189
|
const trimmed = dir.length > 1 ? dir.replace(/[\\/]+$/, "") : dir;
|
|
8916
|
-
const argent =
|
|
8917
|
-
if (!E2E_DIR_NAMES.includes(
|
|
9190
|
+
const argent = path9.dirname(trimmed);
|
|
9191
|
+
if (!E2E_DIR_NAMES.includes(path9.basename(trimmed)) || path9.basename(argent) !== ".argent") {
|
|
8918
9192
|
return null;
|
|
8919
9193
|
}
|
|
8920
|
-
return
|
|
9194
|
+
return path9.dirname(argent);
|
|
8921
9195
|
}
|
|
8922
9196
|
function e2eRunFallbackDirs(anchorDir, target) {
|
|
8923
9197
|
if (target.includes("/") || target.includes("\\")) return [];
|
|
8924
9198
|
const project = e2eDirProject(anchorDir);
|
|
8925
9199
|
if (project === null) return [];
|
|
8926
|
-
const anchor =
|
|
8927
|
-
return e2eDirsFor(project).filter((dir) =>
|
|
9200
|
+
const anchor = path9.resolve(anchorDir);
|
|
9201
|
+
return e2eDirsFor(project).filter((dir) => path9.resolve(dir) !== anchor);
|
|
8928
9202
|
}
|
|
8929
9203
|
|
|
8930
9204
|
// ../registry/src/tool-ids.ts
|
|
@@ -8974,10 +9248,10 @@ function canonicalToolArgs(tool, args) {
|
|
|
8974
9248
|
// ../registry/src/flow-file-refs.ts
|
|
8975
9249
|
async function canonicalFlowPath(p) {
|
|
8976
9250
|
try {
|
|
8977
|
-
return await
|
|
9251
|
+
return await fs10.realpath(p);
|
|
8978
9252
|
} catch {
|
|
8979
9253
|
try {
|
|
8980
|
-
return
|
|
9254
|
+
return path10.join(await fs10.realpath(path10.dirname(p)), path10.basename(p));
|
|
8981
9255
|
} catch {
|
|
8982
9256
|
return p;
|
|
8983
9257
|
}
|
|
@@ -8986,7 +9260,7 @@ async function canonicalFlowPath(p) {
|
|
|
8986
9260
|
function completeRunExtension(value) {
|
|
8987
9261
|
if (value.endsWith(".yaml")) return value;
|
|
8988
9262
|
const candidate = `${value}.yaml`;
|
|
8989
|
-
return FLOW_FILE_NAME_PATTERN.test(
|
|
9263
|
+
return FLOW_FILE_NAME_PATTERN.test(path10.posix.basename(candidate)) ? candidate : value;
|
|
8990
9264
|
}
|
|
8991
9265
|
var MAX_RUN_DEPTH = 20;
|
|
8992
9266
|
var MAX_BLOCK_NESTING = 64;
|
|
@@ -9008,9 +9282,9 @@ function collectFlowRequests(doc) {
|
|
|
9008
9282
|
for (const step of steps) {
|
|
9009
9283
|
if (!isRecord(step)) continue;
|
|
9010
9284
|
const run = step.run;
|
|
9011
|
-
if (typeof run === "string" && !run.includes("\\") && !
|
|
9285
|
+
if (typeof run === "string" && !run.includes("\\") && !path10.posix.isAbsolute(run) && !/^[A-Za-z]:/.test(run)) {
|
|
9012
9286
|
const target = completeRunExtension(run);
|
|
9013
|
-
if (FLOW_FILE_NAME_PATTERN.test(
|
|
9287
|
+
if (FLOW_FILE_NAME_PATTERN.test(path10.posix.basename(target))) runTargets.add(target);
|
|
9014
9288
|
}
|
|
9015
9289
|
const snapshot = isRecord(step.snapshot) ? step.snapshot.name : step.snapshot;
|
|
9016
9290
|
if (typeof snapshot === "string" && FLOW_NAME_PATTERN.test(snapshot)) snapshots.add(snapshot);
|
|
@@ -9023,18 +9297,21 @@ function collectFlowRequests(doc) {
|
|
|
9023
9297
|
visit(step.steps, depth + 1);
|
|
9024
9298
|
}
|
|
9025
9299
|
};
|
|
9026
|
-
if (isRecord(doc))
|
|
9300
|
+
if (isRecord(doc)) {
|
|
9301
|
+
visit(doc.steps, 0);
|
|
9302
|
+
visit(doc.shutdown, 0);
|
|
9303
|
+
}
|
|
9027
9304
|
return { runTargets: [...runTargets], snapshots: [...snapshots], toolSteps, nested };
|
|
9028
9305
|
}
|
|
9029
9306
|
function baselineKeyFor(canonicalPath2, flowName) {
|
|
9030
|
-
const stem =
|
|
9307
|
+
const stem = path10.basename(canonicalPath2, ".yaml");
|
|
9031
9308
|
return FLOW_NAME_PATTERN.test(stem) ? stem : flowName;
|
|
9032
9309
|
}
|
|
9033
9310
|
function flowMemberKey(anchorDir, target) {
|
|
9034
9311
|
return `${anchorDir}\0${target}`;
|
|
9035
9312
|
}
|
|
9036
9313
|
async function classifyOnDiskSpelling(dir, base, addressable = FLOW_FILE_NAME_PATTERN) {
|
|
9037
|
-
const entries = await
|
|
9314
|
+
const entries = await fs10.readdir(dir).catch(() => null);
|
|
9038
9315
|
if (entries === null || entries.includes(base)) return { state: "listed" };
|
|
9039
9316
|
const actual = entries.find((entry) => entry.toLowerCase() === base.toLowerCase());
|
|
9040
9317
|
if (actual === void 0) return { state: "absent" };
|
|
@@ -9056,11 +9333,11 @@ function nestedFlowTarget(args) {
|
|
|
9056
9333
|
return { kind: "name", projectRoot, name, path: paths[0], paths };
|
|
9057
9334
|
}
|
|
9058
9335
|
if (name !== void 0 || !isResolvedAbsolute(flowPath)) return void 0;
|
|
9059
|
-
if (!FLOW_FILE_NAME_PATTERN.test(
|
|
9336
|
+
if (!FLOW_FILE_NAME_PATTERN.test(path10.basename(flowPath))) return void 0;
|
|
9060
9337
|
return { kind: "e2e_test_path", path: flowPath };
|
|
9061
9338
|
}
|
|
9062
9339
|
function isResolvedAbsolute(value) {
|
|
9063
|
-
return typeof value === "string" &&
|
|
9340
|
+
return typeof value === "string" && path10.isAbsolute(value) && !value.split(/[\\/]+/).includes("..");
|
|
9064
9341
|
}
|
|
9065
9342
|
|
|
9066
9343
|
// ../registry/src/failure-codes.ts
|
|
@@ -9077,6 +9354,8 @@ var FAILURE_CODES = {
|
|
|
9077
9354
|
HTTP_CAPABILITY_UNSUPPORTED_OPERATION: "HTTP_CAPABILITY_UNSUPPORTED_OPERATION",
|
|
9078
9355
|
HTTP_DEVICE_RESOLUTION_FAILED: "HTTP_DEVICE_RESOLUTION_FAILED",
|
|
9079
9356
|
HTTP_DEPENDENCY_PREFLIGHT_MISSING: "HTTP_DEPENDENCY_PREFLIGHT_MISSING",
|
|
9357
|
+
// Another session holds a claim on the device the call names.
|
|
9358
|
+
DEVICE_IN_USE: "DEVICE_IN_USE",
|
|
9080
9359
|
// The client's POST /upload of a file input was refused, so the call was not sent.
|
|
9081
9360
|
FILE_INPUT_UPLOAD_FAILED: "FILE_INPUT_UPLOAD_FAILED",
|
|
9082
9361
|
CLI_RUN_TOOL_NOT_FOUND: "CLI_RUN_TOOL_NOT_FOUND",
|
|
@@ -9463,6 +9742,8 @@ var FAILURE_CODES = {
|
|
|
9463
9742
|
MACOS_APP_FILE_ACCESS_FAILED: "MACOS_APP_FILE_ACCESS_FAILED",
|
|
9464
9743
|
/** The app's loaded Argent library lacks support for the requested operation. */
|
|
9465
9744
|
MACOS_APP_LIBRARY_OUTDATED: "MACOS_APP_LIBRARY_OUTDATED",
|
|
9745
|
+
/** The user clicked, scrolled or typed in the app while argent's pointer moved, and took the pointer back. */
|
|
9746
|
+
MACOS_APP_POINTER_TAKEN_OVER: "MACOS_APP_POINTER_TAKEN_OVER",
|
|
9466
9747
|
KEYBOARD_KEY_UNSUPPORTED: "KEYBOARD_KEY_UNSUPPORTED",
|
|
9467
9748
|
KEYBOARD_CHARACTER_UNSUPPORTED: "KEYBOARD_CHARACTER_UNSUPPORTED",
|
|
9468
9749
|
KEYBOARD_TEXT_AND_KEY_COMBINED: "KEYBOARD_TEXT_AND_KEY_COMBINED",
|
|
@@ -9494,6 +9775,17 @@ var FAILURE_CODES = {
|
|
|
9494
9775
|
BOOT_HARMONY_STOP_TIMEOUT: "BOOT_HARMONY_STOP_TIMEOUT",
|
|
9495
9776
|
BOOT_HARMONY_MANAGER_EXITED: "BOOT_HARMONY_MANAGER_EXITED",
|
|
9496
9777
|
BOOT_HARMONY_START_FAILED: "BOOT_HARMONY_START_FAILED",
|
|
9778
|
+
/**
|
|
9779
|
+
* Argent Cloud Android emulators
|
|
9780
|
+
* @see [leases.ts](../../tool-server/src/utils/cloud-android/leases.ts)
|
|
9781
|
+
*/
|
|
9782
|
+
CLOUD_ANDROID_ACCESS_DENIED: "CLOUD_ANDROID_ACCESS_DENIED",
|
|
9783
|
+
CLOUD_ANDROID_ACQUIRE_FAILED: "CLOUD_ANDROID_ACQUIRE_FAILED",
|
|
9784
|
+
CLOUD_ANDROID_ADB_KEY_MISSING: "CLOUD_ANDROID_ADB_KEY_MISSING",
|
|
9785
|
+
CLOUD_ANDROID_ADB_SERVER_REMOTE: "CLOUD_ANDROID_ADB_SERVER_REMOTE",
|
|
9786
|
+
CLOUD_ANDROID_CONNECT_FAILED: "CLOUD_ANDROID_CONNECT_FAILED",
|
|
9787
|
+
CLOUD_ANDROID_LEASE_IN_USE: "CLOUD_ANDROID_LEASE_IN_USE",
|
|
9788
|
+
CLOUD_ANDROID_NO_EMULATOR: "CLOUD_ANDROID_NO_EMULATOR",
|
|
9497
9789
|
/**
|
|
9498
9790
|
* External device providers
|
|
9499
9791
|
* @see [external-devices.ts](../../tool-server/src/utils/external-devices.ts)
|
|
@@ -9528,9 +9820,9 @@ var FAILURE_SPAWN_CODE_SET = new Set(FAILURE_SPAWN_CODES);
|
|
|
9528
9820
|
import { randomUUID as randomUUID3 } from "node:crypto";
|
|
9529
9821
|
import { AsyncLocalStorage } from "node:async_hooks";
|
|
9530
9822
|
var resolvedDuringInvocation = new AsyncLocalStorage();
|
|
9531
|
-
function valueAtPath(root,
|
|
9823
|
+
function valueAtPath(root, path16) {
|
|
9532
9824
|
let current = root;
|
|
9533
|
-
for (const key of
|
|
9825
|
+
for (const key of path16) {
|
|
9534
9826
|
if (current === null || typeof current !== "object") return void 0;
|
|
9535
9827
|
if (!Object.hasOwn(current, key)) return void 0;
|
|
9536
9828
|
current = current[key];
|
|
@@ -9588,11 +9880,10 @@ function describeParamIssues(error, params) {
|
|
|
9588
9880
|
}
|
|
9589
9881
|
|
|
9590
9882
|
// ../argent-tools-client/src/link-config.ts
|
|
9591
|
-
import * as
|
|
9592
|
-
import {
|
|
9593
|
-
|
|
9594
|
-
var
|
|
9595
|
-
var LINK_FILE = path9.join(LINK_DIR, "link.json");
|
|
9883
|
+
import * as path11 from "node:path";
|
|
9884
|
+
import { mkdir, readFile as readFile2, unlink as unlink2 } from "node:fs/promises";
|
|
9885
|
+
var LINK_DIR = argentHomeDir();
|
|
9886
|
+
var LINK_FILE = path11.join(LINK_DIR, "link.json");
|
|
9596
9887
|
async function readLinkConfig() {
|
|
9597
9888
|
try {
|
|
9598
9889
|
const raw = await readFile2(LINK_FILE, "utf8");
|
|
@@ -9632,27 +9923,27 @@ async function getResolvedToolsUrl() {
|
|
|
9632
9923
|
|
|
9633
9924
|
// ../argent-tools-client/src/file-inputs.ts
|
|
9634
9925
|
import { createHash as createHash2, randomUUID as randomUUID4 } from "node:crypto";
|
|
9635
|
-
import { createReadStream as createReadStream2, rmSync as
|
|
9926
|
+
import { createReadStream as createReadStream2, rmSync as rmSync3 } from "node:fs";
|
|
9636
9927
|
import {
|
|
9637
|
-
chmod
|
|
9928
|
+
chmod,
|
|
9638
9929
|
lstat,
|
|
9639
|
-
mkdir as
|
|
9930
|
+
mkdir as mkdir2,
|
|
9640
9931
|
readFile as readFile3,
|
|
9641
9932
|
realpath as realpath2,
|
|
9642
|
-
rename
|
|
9933
|
+
rename,
|
|
9643
9934
|
rm as rm2,
|
|
9644
9935
|
stat as stat3,
|
|
9645
|
-
writeFile
|
|
9936
|
+
writeFile
|
|
9646
9937
|
} from "node:fs/promises";
|
|
9647
|
-
import { constants, tmpdir } from "node:os";
|
|
9648
|
-
import * as
|
|
9938
|
+
import { constants as constants3, tmpdir } from "node:os";
|
|
9939
|
+
import * as path12 from "node:path";
|
|
9649
9940
|
|
|
9650
9941
|
// ../archive/src/index.ts
|
|
9651
9942
|
import { spawn as spawn2 } from "node:child_process";
|
|
9652
9943
|
import { once } from "node:events";
|
|
9653
9944
|
import { createReadStream, createWriteStream } from "node:fs";
|
|
9654
9945
|
import { open, rm, readdir as readdir3 } from "node:fs/promises";
|
|
9655
|
-
import { basename as basename4, dirname as
|
|
9946
|
+
import { basename as basename4, dirname as dirname6, join as join11, resolve as resolve8, sep as sep2 } from "node:path";
|
|
9656
9947
|
import { Writable } from "node:stream";
|
|
9657
9948
|
import { pipeline } from "node:stream/promises";
|
|
9658
9949
|
import zlib from "node:zlib";
|
|
@@ -9676,7 +9967,7 @@ function createCompressor(format) {
|
|
|
9676
9967
|
}
|
|
9677
9968
|
function createTarArgs(sourcePath) {
|
|
9678
9969
|
const name = basename4(sourcePath);
|
|
9679
|
-
return ["-cf", "-", "-C",
|
|
9970
|
+
return ["-cf", "-", "-C", dirname6(sourcePath), /^[-@]/.test(name) ? `./${name}` : name];
|
|
9680
9971
|
}
|
|
9681
9972
|
var MAX_LISTING_BYTES = 32 << 20;
|
|
9682
9973
|
var MAX_LISTING_LINES = 1 << 18;
|
|
@@ -9801,13 +10092,14 @@ function tarEnv(env) {
|
|
|
9801
10092
|
async function runTar(archive, args, signal) {
|
|
9802
10093
|
const child = spawn2("tar", [...args, "-f", "-"], {
|
|
9803
10094
|
signal,
|
|
9804
|
-
env: tarEnv(process.env)
|
|
10095
|
+
env: tarEnv(process.env),
|
|
10096
|
+
windowsHide: true
|
|
9805
10097
|
});
|
|
9806
10098
|
let childError;
|
|
9807
10099
|
child.on("error", (err) => {
|
|
9808
10100
|
childError = err;
|
|
9809
10101
|
});
|
|
9810
|
-
const closed = new Promise((
|
|
10102
|
+
const closed = new Promise((resolve12) => child.once("close", resolve12));
|
|
9811
10103
|
const stdout = collect(child.stdout, MAX_LISTING_BYTES, {
|
|
9812
10104
|
maxLines: MAX_LISTING_LINES,
|
|
9813
10105
|
onOverflow: () => child.kill()
|
|
@@ -9856,16 +10148,16 @@ async function runTar(archive, args, signal) {
|
|
|
9856
10148
|
function normalizeTarMemberPath(memberPath) {
|
|
9857
10149
|
return memberPath.replace(/^\.\//, "").replace(/\\/g, "/");
|
|
9858
10150
|
}
|
|
9859
|
-
function isContainedPath(
|
|
9860
|
-
const slashed =
|
|
10151
|
+
function isContainedPath(path16, windows = process.platform === "win32") {
|
|
10152
|
+
const slashed = path16.replace(/\\/g, "/");
|
|
9861
10153
|
const drive = windows ? /^[A-Za-z]:/ : /^[A-Za-z]:\//;
|
|
9862
10154
|
return !slashed.startsWith("/") && !drive.test(slashed) && !slashed.split("/").includes("..");
|
|
9863
10155
|
}
|
|
9864
10156
|
function isSafeTarMember(memberPath, destDir) {
|
|
9865
10157
|
const normalized = normalizeTarMemberPath(memberPath);
|
|
9866
10158
|
if (!isContainedPath(normalized)) return false;
|
|
9867
|
-
const root =
|
|
9868
|
-
return
|
|
10159
|
+
const root = resolve8(destDir);
|
|
10160
|
+
return resolve8(destDir, normalized).startsWith(root + sep2);
|
|
9869
10161
|
}
|
|
9870
10162
|
async function readListing(archive, args, signal) {
|
|
9871
10163
|
try {
|
|
@@ -9917,7 +10209,7 @@ async function assertSafeArchive(archive, destDir, signal) {
|
|
|
9917
10209
|
async function resolveMember(destDir, expectedName) {
|
|
9918
10210
|
const entries = await readdir3(destDir);
|
|
9919
10211
|
if (entries.includes(expectedName)) {
|
|
9920
|
-
return
|
|
10212
|
+
return join11(destDir, expectedName);
|
|
9921
10213
|
}
|
|
9922
10214
|
const real = entries.filter((e) => !e.startsWith("._"));
|
|
9923
10215
|
if (real.length !== 1) {
|
|
@@ -9925,7 +10217,7 @@ async function resolveMember(destDir, expectedName) {
|
|
|
9925
10217
|
`Could not identify the extracted member (expected "${expectedName}", found ${real.length} entries).`
|
|
9926
10218
|
);
|
|
9927
10219
|
}
|
|
9928
|
-
return
|
|
10220
|
+
return join11(destDir, real[0]);
|
|
9929
10221
|
}
|
|
9930
10222
|
async function safeExtractArchive(archivePath, destDir, expectedName, signal) {
|
|
9931
10223
|
signal?.throwIfAborted();
|
|
@@ -9978,20 +10270,20 @@ function interpolatePath(template, args) {
|
|
|
9978
10270
|
return missing ? null : out;
|
|
9979
10271
|
}
|
|
9980
10272
|
function callerPath(p) {
|
|
9981
|
-
const onCurrentDrive =
|
|
9982
|
-
if (!onCurrentDrive && (
|
|
10273
|
+
const onCurrentDrive = path12.sep === "\\" && /^[\\/](?![\\/])/.test(p);
|
|
10274
|
+
if (!onCurrentDrive && (path12.isAbsolute(p) || path12.win32.isAbsolute(p) || isUnexpandedPath(p))) {
|
|
9983
10275
|
return p;
|
|
9984
10276
|
}
|
|
9985
|
-
const { root } =
|
|
10277
|
+
const { root } = path12.parse(p);
|
|
9986
10278
|
const rest = p.slice(root.length);
|
|
9987
10279
|
if (!rest.split(/[\\/]/).includes("..")) {
|
|
9988
|
-
const resolved =
|
|
9989
|
-
const last = p.split(
|
|
9990
|
-
const dirOnly = p !== last && (last === "" || last === ".") && !resolved.endsWith(
|
|
9991
|
-
return dirOnly ? `${resolved}${
|
|
10280
|
+
const resolved = path12.resolve(p);
|
|
10281
|
+
const last = p.split(path12.sep === "\\" ? /[\\/]/ : "/").at(-1);
|
|
10282
|
+
const dirOnly = p !== last && (last === "" || last === ".") && !resolved.endsWith(path12.sep);
|
|
10283
|
+
return dirOnly ? `${resolved}${path12.sep}` : resolved;
|
|
9992
10284
|
}
|
|
9993
|
-
const base =
|
|
9994
|
-
return base.endsWith(
|
|
10285
|
+
const base = path12.resolve(root);
|
|
10286
|
+
return base.endsWith(path12.sep) ? `${base}${rest}` : `${base}${path12.sep}${rest}`;
|
|
9995
10287
|
}
|
|
9996
10288
|
async function specPath(spec, args) {
|
|
9997
10289
|
if (spec.kind !== "file" || !spec.paths?.length) return interpolatePath(spec.path, args);
|
|
@@ -10008,7 +10300,7 @@ var ARCHIVE_SIGNALS = ["SIGINT", "SIGTERM", "SIGHUP"];
|
|
|
10008
10300
|
function removePendingArchives() {
|
|
10009
10301
|
for (const archive of pendingArchives) {
|
|
10010
10302
|
try {
|
|
10011
|
-
|
|
10303
|
+
rmSync3(archive, { force: true });
|
|
10012
10304
|
} catch {
|
|
10013
10305
|
}
|
|
10014
10306
|
}
|
|
@@ -10019,10 +10311,13 @@ function removePendingArchives() {
|
|
|
10019
10311
|
function removeArchivesOnSignal(signal) {
|
|
10020
10312
|
removePendingArchives();
|
|
10021
10313
|
if (process.listenerCount(signal) > 0) return;
|
|
10314
|
+
raiseSignal(signal);
|
|
10315
|
+
}
|
|
10316
|
+
function raiseSignal(signal) {
|
|
10022
10317
|
try {
|
|
10023
10318
|
process.kill(process.pid, signal);
|
|
10024
10319
|
} catch {
|
|
10025
|
-
process.exit(128 +
|
|
10320
|
+
process.exit(128 + constants3.signals[signal]);
|
|
10026
10321
|
}
|
|
10027
10322
|
}
|
|
10028
10323
|
function trackArchive(archive) {
|
|
@@ -10038,9 +10333,9 @@ function untrackArchive(archive) {
|
|
|
10038
10333
|
process.removeListener("exit", removePendingArchives);
|
|
10039
10334
|
}
|
|
10040
10335
|
function sha256File(filePath, signal) {
|
|
10041
|
-
return new Promise((
|
|
10336
|
+
return new Promise((resolve12, reject) => {
|
|
10042
10337
|
const hash = createHash2("sha256");
|
|
10043
|
-
createReadStream2(filePath, { signal }).on("data", (chunk) => hash.update(chunk)).on("end", () =>
|
|
10338
|
+
createReadStream2(filePath, { signal }).on("data", (chunk) => hash.update(chunk)).on("end", () => resolve12(hash.digest("hex"))).on("error", reject);
|
|
10044
10339
|
});
|
|
10045
10340
|
}
|
|
10046
10341
|
function toolServerError(text) {
|
|
@@ -10099,7 +10394,7 @@ async function uploadTar(tarPath, format, endpoint, signal) {
|
|
|
10099
10394
|
}
|
|
10100
10395
|
async function uploadFile(sourcePath, endpoint, signal) {
|
|
10101
10396
|
const format = pickArchiveFormat(endpoint.formats);
|
|
10102
|
-
const tarPath =
|
|
10397
|
+
const tarPath = path12.join(tmpdir(), `argent-upload-${randomUUID4()}.tar.gz`);
|
|
10103
10398
|
trackArchive(tarPath);
|
|
10104
10399
|
try {
|
|
10105
10400
|
await createArchiveFile(await realpath2(sourcePath), tarPath, format, signal);
|
|
@@ -10174,7 +10469,7 @@ async function prepareFileInputs(specs, args, opts) {
|
|
|
10174
10469
|
wire.mtimeMs = st.mtimeMs;
|
|
10175
10470
|
}
|
|
10176
10471
|
if (opts.uploadEndpoint && st) {
|
|
10177
|
-
process.stderr.write(`Uploading ${
|
|
10472
|
+
process.stderr.write(`Uploading ${path12.basename(filePath)} to the remote tool-server...
|
|
10178
10473
|
`);
|
|
10179
10474
|
Object.assign(wire, await uploadFile(filePath, opts.uploadEndpoint, opts.signal));
|
|
10180
10475
|
}
|
|
@@ -10184,7 +10479,7 @@ async function prepareFileInputs(specs, args, opts) {
|
|
|
10184
10479
|
return out;
|
|
10185
10480
|
}
|
|
10186
10481
|
function isAllowedClientFilePath(p) {
|
|
10187
|
-
if (!
|
|
10482
|
+
if (!path12.isAbsolute(p)) return false;
|
|
10188
10483
|
const segments = p.split(/[\\/]+/);
|
|
10189
10484
|
if (segments.includes("..")) return false;
|
|
10190
10485
|
const file = segments[segments.length - 1] ?? "";
|
|
@@ -10195,38 +10490,38 @@ function isClientFileDirective2(value) {
|
|
|
10195
10490
|
return !!value && typeof value === "object" && value[CLIENT_FILE_MARKER2] === true && typeof value.path === "string" && typeof value.content === "string";
|
|
10196
10491
|
}
|
|
10197
10492
|
async function replaceFile(target, bytes, mode) {
|
|
10198
|
-
const temp =
|
|
10493
|
+
const temp = path12.join(path12.dirname(target), `.baseline-${randomUUID4()}.tmp`);
|
|
10199
10494
|
try {
|
|
10200
|
-
await
|
|
10201
|
-
if (mode !== void 0) await
|
|
10202
|
-
await
|
|
10495
|
+
await writeFile(temp, bytes, { flag: "wx" });
|
|
10496
|
+
if (mode !== void 0) await chmod(temp, mode & 511);
|
|
10497
|
+
await rename(temp, target);
|
|
10203
10498
|
} catch (err) {
|
|
10204
10499
|
await rm2(temp, { force: true });
|
|
10205
10500
|
throw err;
|
|
10206
10501
|
}
|
|
10207
10502
|
}
|
|
10208
10503
|
async function writeBaselineFile(file, bytes, allowedDirs) {
|
|
10209
|
-
if (!
|
|
10504
|
+
if (!path12.isAbsolute(file) || path12.normalize(file) !== file || file.split(/[\\/]/).includes("..") || !file.endsWith(".png") || !allowedDirs.includes(path12.dirname(file))) {
|
|
10210
10505
|
return allowedDirs.length === 0 ? "this call writes no baselines" : `${file} is not a baseline of this call (${allowedDirs.map((d) => `${d}/<name>.png`).join(", ")})`;
|
|
10211
10506
|
}
|
|
10212
10507
|
if (bytes.length > MAX_CONTENT_BYTES) {
|
|
10213
10508
|
return `${file}: the baseline is larger than the 32 MiB cap on a file this client writes`;
|
|
10214
10509
|
}
|
|
10215
|
-
const dir =
|
|
10216
|
-
await
|
|
10510
|
+
const dir = path12.dirname(file);
|
|
10511
|
+
await mkdir2(dir, { recursive: true });
|
|
10217
10512
|
const link = await lstat(file).catch(() => null);
|
|
10218
10513
|
const real = link === null ? null : await realpath2(file).catch(() => null);
|
|
10219
10514
|
if (link !== null && real === null) return `${file} is a symbolic link to a missing file`;
|
|
10220
10515
|
if (real !== null) {
|
|
10221
10516
|
if (!real.endsWith(".png")) return `${file} links to a file that is not a PNG file`;
|
|
10222
|
-
if (
|
|
10517
|
+
if (path12.dirname(real) !== await realpath2(dir)) {
|
|
10223
10518
|
return `${file} links outside its baseline directory`;
|
|
10224
10519
|
}
|
|
10225
10520
|
}
|
|
10226
10521
|
const existing = real === null ? null : await stat3(real);
|
|
10227
10522
|
if (existing !== null && !existing.isFile()) return `${file} is not a regular file`;
|
|
10228
10523
|
await replaceFile(
|
|
10229
|
-
real ??
|
|
10524
|
+
real ?? path12.join(await realpath2(dir), path12.basename(file)),
|
|
10230
10525
|
bytes,
|
|
10231
10526
|
existing?.mode
|
|
10232
10527
|
);
|
|
@@ -10252,8 +10547,8 @@ async function applyClientFileDirectives(result, opts = {}) {
|
|
|
10252
10547
|
if (isClientFileDirective2(value)) {
|
|
10253
10548
|
if (!isAllowedClientFilePath(value.path)) return null;
|
|
10254
10549
|
try {
|
|
10255
|
-
await
|
|
10256
|
-
await
|
|
10550
|
+
await mkdir2(path12.dirname(value.path), { recursive: true });
|
|
10551
|
+
await writeFile(value.path, value.content, "utf8");
|
|
10257
10552
|
written.push(value.path);
|
|
10258
10553
|
return value.path;
|
|
10259
10554
|
} catch {
|
|
@@ -10281,13 +10576,13 @@ async function applyClientFileDirectives(result, opts = {}) {
|
|
|
10281
10576
|
// ../argent-tools-client/src/flow-files.ts
|
|
10282
10577
|
var import_yaml = __toESM(require_dist2(), 1);
|
|
10283
10578
|
import { readdir as readdir4, readFile as readFile4, realpath as realpath3, stat as stat4 } from "node:fs/promises";
|
|
10284
|
-
import * as
|
|
10579
|
+
import * as path13 from "node:path";
|
|
10285
10580
|
var INLINE_MEMBERS_BYTES = 256 * 1024;
|
|
10286
10581
|
function filesLogEnabled() {
|
|
10287
10582
|
return (process.env.ARGENT_E2E_FILES_LOG ?? process.env.ARGENT_FLOW_FILES_LOG) === "1";
|
|
10288
10583
|
}
|
|
10289
10584
|
function isWithin(inner, outer) {
|
|
10290
|
-
return inner === outer || inner.startsWith(outer.endsWith(
|
|
10585
|
+
return inner === outer || inner.startsWith(outer.endsWith(path13.sep) ? outer : outer + path13.sep);
|
|
10291
10586
|
}
|
|
10292
10587
|
function printable(text) {
|
|
10293
10588
|
return [...text].map(
|
|
@@ -10295,7 +10590,7 @@ function printable(text) {
|
|
|
10295
10590
|
).join("");
|
|
10296
10591
|
}
|
|
10297
10592
|
function isResolvedAbsolute2(value) {
|
|
10298
|
-
return typeof value === "string" &&
|
|
10593
|
+
return typeof value === "string" && path13.isAbsolute(value) && !value.split(/[\\/]+/).includes("..");
|
|
10299
10594
|
}
|
|
10300
10595
|
function namesValidFlow(args) {
|
|
10301
10596
|
let canonical;
|
|
@@ -10307,13 +10602,13 @@ function namesValidFlow(args) {
|
|
|
10307
10602
|
const { project_root, e2e_test_path: testPath, name } = canonical;
|
|
10308
10603
|
if (!isResolvedAbsolute2(project_root)) return false;
|
|
10309
10604
|
if (name === void 0) {
|
|
10310
|
-
return isResolvedAbsolute2(testPath) && FLOW_FILE_NAME_PATTERN.test(
|
|
10605
|
+
return isResolvedAbsolute2(testPath) && FLOW_FILE_NAME_PATTERN.test(path13.basename(testPath));
|
|
10311
10606
|
}
|
|
10312
10607
|
return testPath === void 0 && typeof name === "string" && FLOW_NAME_PATTERN.test(name);
|
|
10313
10608
|
}
|
|
10314
10609
|
function savedFlowProject(file) {
|
|
10315
|
-
if (!
|
|
10316
|
-
for (let dir =
|
|
10610
|
+
if (!path13.isAbsolute(file)) return null;
|
|
10611
|
+
for (let dir = path13.dirname(file); dir !== path13.dirname(dir); dir = path13.dirname(dir)) {
|
|
10317
10612
|
const project = e2eDirProject(dir);
|
|
10318
10613
|
if (project !== null) return project;
|
|
10319
10614
|
}
|
|
@@ -10328,11 +10623,11 @@ async function landing(spelled) {
|
|
|
10328
10623
|
const canonical = await canonicalFlowPath(spelled);
|
|
10329
10624
|
let at = spelled;
|
|
10330
10625
|
for (; ; ) {
|
|
10331
|
-
const parent =
|
|
10626
|
+
const parent = path13.dirname(at);
|
|
10332
10627
|
if (parent === at) return { canonical, fence: spelled, ...failure };
|
|
10333
10628
|
const real = await realpath3(parent).catch(() => null);
|
|
10334
10629
|
if (real !== null) {
|
|
10335
|
-
return { canonical, fence:
|
|
10630
|
+
return { canonical, fence: path13.join(real, path13.basename(at)), ...failure };
|
|
10336
10631
|
}
|
|
10337
10632
|
at = parent;
|
|
10338
10633
|
}
|
|
@@ -10340,10 +10635,10 @@ async function landing(spelled) {
|
|
|
10340
10635
|
}
|
|
10341
10636
|
async function closureRoots(rootPath, rootCanonical, projectRoot) {
|
|
10342
10637
|
const candidates = [];
|
|
10343
|
-
if (typeof projectRoot === "string" &&
|
|
10638
|
+
if (typeof projectRoot === "string" && path13.isAbsolute(projectRoot)) {
|
|
10344
10639
|
candidates.push(projectRoot, ...e2eDirsFor(projectRoot));
|
|
10345
10640
|
}
|
|
10346
|
-
candidates.push(
|
|
10641
|
+
candidates.push(path13.dirname(rootPath), path13.dirname(rootCanonical));
|
|
10347
10642
|
for (const file of [rootPath, rootCanonical]) {
|
|
10348
10643
|
const project = savedFlowProject(file);
|
|
10349
10644
|
if (project !== null) candidates.push(project);
|
|
@@ -10356,11 +10651,11 @@ async function closureRoots(rootPath, rootCanonical, projectRoot) {
|
|
|
10356
10651
|
return real.filter((root) => !real.some((other) => other !== root && isWithin(root, other)));
|
|
10357
10652
|
}
|
|
10358
10653
|
async function readFlowMember(anchorDir, target, roots, budget, opts) {
|
|
10359
|
-
const spelled = anchorDir +
|
|
10654
|
+
const spelled = anchorDir + path13.sep + target;
|
|
10360
10655
|
const { canonical, fence, missing, error } = await landing(spelled);
|
|
10361
10656
|
const spelling = await classifyOnDiskSpelling(
|
|
10362
|
-
|
|
10363
|
-
|
|
10657
|
+
path13.dirname(spelled),
|
|
10658
|
+
path13.posix.basename(target),
|
|
10364
10659
|
FLOW_FILE_NAME_PATTERN
|
|
10365
10660
|
);
|
|
10366
10661
|
const member = {
|
|
@@ -10385,7 +10680,7 @@ async function readFlowMember(anchorDir, target, roots, budget, opts) {
|
|
|
10385
10680
|
return { member: { ...member, state: "missing" }, sent: "missing" };
|
|
10386
10681
|
}
|
|
10387
10682
|
if (st.isDirectory()) return refuse("EISDIR: illegal operation on a directory, read");
|
|
10388
|
-
if (!/\.ya?ml$/i.test(
|
|
10683
|
+
if (!/\.ya?ml$/i.test(path13.basename(canonical))) {
|
|
10389
10684
|
return refuse(`${target} links to a file that is not a YAML file`);
|
|
10390
10685
|
}
|
|
10391
10686
|
const sent = await sendBytes(member, canonical, budget, opts);
|
|
@@ -10478,7 +10773,7 @@ function memberCollector(roots, opts) {
|
|
|
10478
10773
|
const runs = /* @__PURE__ */ new Set();
|
|
10479
10774
|
const baselineDirs = /* @__PURE__ */ new Map();
|
|
10480
10775
|
const budget = { inline: 0 };
|
|
10481
|
-
const logging = filesLogEnabled();
|
|
10776
|
+
const logging = filesLogEnabled() && opts.scanOnly !== true;
|
|
10482
10777
|
const log = opts.log ?? ((line) => void process.stderr.write(`${line}
|
|
10483
10778
|
`));
|
|
10484
10779
|
const emit = (member, sent) => {
|
|
@@ -10498,6 +10793,7 @@ function memberCollector(roots, opts) {
|
|
|
10498
10793
|
return entry;
|
|
10499
10794
|
}
|
|
10500
10795
|
async function toolFiles(step) {
|
|
10796
|
+
if (opts.scanOnly) return;
|
|
10501
10797
|
if (canonicalToolId(step.tool) === "e2e-execute") return;
|
|
10502
10798
|
for (const file of toolStepFiles(opts.toolFileInputs?.(step.tool), step.args)) {
|
|
10503
10799
|
const { unwrapWhenSet } = file.spec;
|
|
@@ -10510,12 +10806,12 @@ function memberCollector(roots, opts) {
|
|
|
10510
10806
|
}
|
|
10511
10807
|
async function savedTest(target) {
|
|
10512
10808
|
for (const candidate of target.paths) {
|
|
10513
|
-
const found = await flow(
|
|
10809
|
+
const found = await flow(path13.dirname(candidate), path13.basename(candidate), true);
|
|
10514
10810
|
if (found !== void 0) return found;
|
|
10515
10811
|
}
|
|
10516
10812
|
let first;
|
|
10517
10813
|
for (const candidate of target.paths) {
|
|
10518
|
-
first ??= await flow(
|
|
10814
|
+
first ??= await flow(path13.dirname(candidate), path13.basename(candidate));
|
|
10519
10815
|
}
|
|
10520
10816
|
return first;
|
|
10521
10817
|
}
|
|
@@ -10524,6 +10820,12 @@ function memberCollector(roots, opts) {
|
|
|
10524
10820
|
if (text === void 0 || hop >= MAX_RUN_DEPTH) return void 0;
|
|
10525
10821
|
return { canonical: member.canonical, text, flowName: target.name, hop, updates, platform };
|
|
10526
10822
|
}
|
|
10823
|
+
async function pathRun(target, hop, updates, platform) {
|
|
10824
|
+
const { member, text } = await flow(path13.dirname(target.path), path13.basename(target.path));
|
|
10825
|
+
if (text === void 0 || hop >= MAX_RUN_DEPTH) return void 0;
|
|
10826
|
+
const flowName = path13.basename(target.path, ".yaml");
|
|
10827
|
+
return { canonical: member.canonical, text, flowName, hop, updates, platform };
|
|
10828
|
+
}
|
|
10527
10829
|
async function runTarget(anchorDir, target) {
|
|
10528
10830
|
const found = await flow(anchorDir, target);
|
|
10529
10831
|
if (found.member.spelling?.state !== "absent") return found;
|
|
@@ -10552,7 +10854,7 @@ function memberCollector(roots, opts) {
|
|
|
10552
10854
|
const requests = collectFlowRequests(doc);
|
|
10553
10855
|
for (const name of requests.snapshots) snapshots.add(name);
|
|
10554
10856
|
for (const step of requests.toolSteps) await toolFiles(step);
|
|
10555
|
-
const anchorDir =
|
|
10857
|
+
const anchorDir = path13.dirname(file.canonical);
|
|
10556
10858
|
for (const target of requests.runTargets) {
|
|
10557
10859
|
const key = flowMemberKey(anchorDir, target);
|
|
10558
10860
|
if (visited.has(key)) continue;
|
|
@@ -10563,19 +10865,14 @@ function memberCollector(roots, opts) {
|
|
|
10563
10865
|
}
|
|
10564
10866
|
}
|
|
10565
10867
|
for (const { target, args } of requests.nested) {
|
|
10566
|
-
|
|
10567
|
-
const next = await nestedRun(
|
|
10568
|
-
target,
|
|
10569
|
-
file.hop + 1,
|
|
10570
|
-
nestedRunUpdates(run.updates, args),
|
|
10571
|
-
run.platform
|
|
10572
|
-
);
|
|
10868
|
+
const updates = nestedRunUpdates(run.updates, args);
|
|
10869
|
+
const next = target.kind === "name" ? await nestedRun(target, file.hop + 1, updates, run.platform) : opts.scanOnly ? await pathRun(target, file.hop + 1, updates, run.platform) : void 0;
|
|
10573
10870
|
if (next !== void 0) queue.push(next);
|
|
10574
10871
|
}
|
|
10575
10872
|
}
|
|
10576
10873
|
if (snapshots.size === 0) continue;
|
|
10577
|
-
const dir =
|
|
10578
|
-
|
|
10874
|
+
const dir = path13.join(
|
|
10875
|
+
path13.dirname(run.canonical),
|
|
10579
10876
|
"__baselines__",
|
|
10580
10877
|
baselineKeyFor(run.canonical, run.flowName)
|
|
10581
10878
|
);
|
|
@@ -10590,6 +10887,7 @@ function memberCollector(roots, opts) {
|
|
|
10590
10887
|
}
|
|
10591
10888
|
}
|
|
10592
10889
|
async function sendBaselines() {
|
|
10890
|
+
if (opts.scanOnly) return;
|
|
10593
10891
|
for (const [dir, { prefixes, updates }] of baselineDirs) {
|
|
10594
10892
|
const real = (await landing(dir)).canonical;
|
|
10595
10893
|
if (!roots.some((root) => isWithin(real, root))) continue;
|
|
@@ -10599,7 +10897,7 @@ function memberCollector(roots, opts) {
|
|
|
10599
10897
|
if (!name.endsWith(".png")) continue;
|
|
10600
10898
|
const compared = [...prefixes].some((prefix) => name.startsWith(prefix));
|
|
10601
10899
|
if (!updates && !compared) continue;
|
|
10602
|
-
const file =
|
|
10900
|
+
const file = path13.join(dir, name);
|
|
10603
10901
|
if (tools.has(file)) continue;
|
|
10604
10902
|
const member = { role: "baseline", key: file, path: file };
|
|
10605
10903
|
const entry = await baselineEntry(file, roots, updates && !compared);
|
|
@@ -10622,19 +10920,19 @@ async function collectFlowMembers(rootPath, rootBytes, args, opts) {
|
|
|
10622
10920
|
if (!namesValidFlow(args)) return {};
|
|
10623
10921
|
const canonical = await canonicalFlowPath(rootPath);
|
|
10624
10922
|
const spelling = await classifyOnDiskSpelling(
|
|
10625
|
-
|
|
10626
|
-
|
|
10923
|
+
path13.dirname(rootPath),
|
|
10924
|
+
path13.basename(rootPath),
|
|
10627
10925
|
FLOW_FILE_NAME_PATTERN
|
|
10628
10926
|
);
|
|
10629
10927
|
const collector = memberCollector(
|
|
10630
|
-
await closureRoots(rootPath, canonical, args.project_root),
|
|
10928
|
+
opts.scanOnly ? [path13.parse(path13.resolve(rootPath)).root] : await closureRoots(rootPath, canonical, args.project_root),
|
|
10631
10929
|
opts
|
|
10632
10930
|
);
|
|
10633
10931
|
await collector.walk([
|
|
10634
10932
|
{
|
|
10635
10933
|
canonical,
|
|
10636
10934
|
text: rootBytes.toString("utf8"),
|
|
10637
|
-
flowName:
|
|
10935
|
+
flowName: path13.basename(rootPath, ".yaml"),
|
|
10638
10936
|
hop: 0,
|
|
10639
10937
|
updates: args.updateBaselines === true,
|
|
10640
10938
|
platform: callPlatform(args)
|
|
@@ -10663,31 +10961,31 @@ async function collectStepMembers(args, opts, recordingDirFor = e2eDirFor) {
|
|
|
10663
10961
|
if (typeof name !== "string" || !FLOW_NAME_PATTERN.test(name) || !isResolvedAbsolute2(projectRoot) || step === void 0) {
|
|
10664
10962
|
return [];
|
|
10665
10963
|
}
|
|
10666
|
-
const recording =
|
|
10964
|
+
const recording = path13.join(recordingDirFor(projectRoot), `${name}.yaml`);
|
|
10667
10965
|
const collector = memberCollector(
|
|
10668
|
-
await closureRoots(recording, (await landing(recording)).canonical, projectRoot),
|
|
10966
|
+
opts.scanOnly ? [path13.parse(recording).root] : await closureRoots(recording, (await landing(recording)).canonical, projectRoot),
|
|
10669
10967
|
opts
|
|
10670
10968
|
);
|
|
10671
10969
|
await collector.toolFiles(step);
|
|
10672
10970
|
if (canonicalToolId(step.tool) === "e2e-execute") {
|
|
10673
|
-
const self = await collector.flow(
|
|
10971
|
+
const self = await collector.flow(path13.dirname(recording), path13.basename(recording));
|
|
10674
10972
|
let runArgs = step.args;
|
|
10675
10973
|
const named = nestedFlowTarget(runArgs);
|
|
10676
10974
|
if (named?.kind === "e2e_test_path") {
|
|
10677
|
-
const stem =
|
|
10678
|
-
const base =
|
|
10679
|
-
const dir =
|
|
10680
|
-
const recordingDir =
|
|
10975
|
+
const stem = path13.basename(named.path, ".yaml");
|
|
10976
|
+
const base = path13.basename(named.path);
|
|
10977
|
+
const dir = path13.resolve(path13.dirname(named.path));
|
|
10978
|
+
const recordingDir = path13.dirname(recording);
|
|
10681
10979
|
const dirs = [recordingDir, ...e2eRunFallbackDirs(recordingDir, base)];
|
|
10682
|
-
if (dirs.some((d) =>
|
|
10683
|
-
await collector.flow(
|
|
10980
|
+
if (dirs.some((d) => path13.resolve(d) === dir)) {
|
|
10981
|
+
await collector.flow(path13.dirname(named.path), base);
|
|
10684
10982
|
runArgs = { ...runArgs, name: stem };
|
|
10685
10983
|
delete runArgs.e2e_test_path;
|
|
10686
10984
|
}
|
|
10687
10985
|
}
|
|
10688
10986
|
const target = nestedFlowTarget(runArgs);
|
|
10689
10987
|
if (target?.kind === "name") {
|
|
10690
|
-
await collector.flow(
|
|
10988
|
+
await collector.flow(path13.dirname(self.member.canonical), `${target.name}.yaml`);
|
|
10691
10989
|
const run = await collector.nestedRun(
|
|
10692
10990
|
target,
|
|
10693
10991
|
0,
|
|
@@ -10881,10 +11179,10 @@ function assertFiniteNumbers(args) {
|
|
|
10881
11179
|
if (typeof item === "object" && item !== null) {
|
|
10882
11180
|
pending.push({ value: item, key, parent: visit });
|
|
10883
11181
|
} else if (typeof item === "number" && !Number.isFinite(item)) {
|
|
10884
|
-
const
|
|
10885
|
-
for (let at = visit; at.parent; at = at.parent)
|
|
10886
|
-
|
|
10887
|
-
issues.push({ code: "invalid_type", path:
|
|
11182
|
+
const path16 = [key];
|
|
11183
|
+
for (let at = visit; at.parent; at = at.parent) path16.push(at.key);
|
|
11184
|
+
path16.reverse();
|
|
11185
|
+
issues.push({ code: "invalid_type", path: path16, message: `expected a number, got ${item}` });
|
|
10888
11186
|
if (issues.length === MAX_NON_FINITE_ISSUES) break;
|
|
10889
11187
|
}
|
|
10890
11188
|
}
|
|
@@ -10911,8 +11209,31 @@ function carriesMembers(args) {
|
|
|
10911
11209
|
function carriesUpload(args) {
|
|
10912
11210
|
return carriesMembers(args) || wiresOf(args).some((wire) => typeof wire.uploadId === "string");
|
|
10913
11211
|
}
|
|
10914
|
-
|
|
10915
|
-
|
|
11212
|
+
function secretValues(names, sources) {
|
|
11213
|
+
const values = /* @__PURE__ */ new Map();
|
|
11214
|
+
for (const rawName of names) {
|
|
11215
|
+
const { name, value } = lookupPlaceholderSecret(rawName, sources);
|
|
11216
|
+
if (value !== void 0) values.set(name, value);
|
|
11217
|
+
}
|
|
11218
|
+
return values;
|
|
11219
|
+
}
|
|
11220
|
+
async function callerSecrets(scanned, remote, secretsFile) {
|
|
11221
|
+
const forward = !remote || isFeatureEnabled("forward-secrets");
|
|
11222
|
+
if (!forward && secretsFile === void 0) return void 0;
|
|
11223
|
+
const names = await placeholderNamesIn(scanned);
|
|
11224
|
+
if (remote) {
|
|
11225
|
+
if (names.size === 0) return void 0;
|
|
11226
|
+
if (!forward) {
|
|
11227
|
+
const values = secretValues(names, [secretsFileSource(secretsFile)]);
|
|
11228
|
+
return values.size === 0 ? void 0 : { values };
|
|
11229
|
+
}
|
|
11230
|
+
return { values: secretValues(names, secretSources({ secretsFile })) };
|
|
11231
|
+
}
|
|
11232
|
+
if (names.size === 0) return { values: /* @__PURE__ */ new Map() };
|
|
11233
|
+
const sources = secretSources({ secretsFile });
|
|
11234
|
+
return { values: secretValues(names, sources), sources: summarizeSecretSources(sources) };
|
|
11235
|
+
}
|
|
11236
|
+
async function placeholderNamesIn(args) {
|
|
10916
11237
|
const names = /* @__PURE__ */ new Set();
|
|
10917
11238
|
const scan = (text) => {
|
|
10918
11239
|
for (const name of placeholderNames(text)) names.add(name);
|
|
@@ -10949,15 +11270,33 @@ async function forwardedSecrets(args) {
|
|
|
10949
11270
|
}
|
|
10950
11271
|
};
|
|
10951
11272
|
await visit(args);
|
|
10952
|
-
|
|
10953
|
-
|
|
10954
|
-
|
|
10955
|
-
|
|
10956
|
-
|
|
10957
|
-
|
|
10958
|
-
|
|
10959
|
-
|
|
10960
|
-
|
|
11273
|
+
return names;
|
|
11274
|
+
}
|
|
11275
|
+
async function localScanArgs(meta, args, prepare) {
|
|
11276
|
+
const scanned = [args];
|
|
11277
|
+
const collecting = meta?.fileInputs?.filter((spec) => spec.collect !== void 0) ?? [];
|
|
11278
|
+
if (meta && RECORDING_TOOLS.has(canonicalToolId(meta.name))) {
|
|
11279
|
+
collecting.push(RECORDING_FILE_INPUT);
|
|
11280
|
+
}
|
|
11281
|
+
if (collecting.length > 0) {
|
|
11282
|
+
scanned.push(await prepare(collecting).catch(() => void 0));
|
|
11283
|
+
}
|
|
11284
|
+
return scanned;
|
|
11285
|
+
}
|
|
11286
|
+
var RECORDING_TOOLS = /* @__PURE__ */ new Set([
|
|
11287
|
+
"e2e-start-recording",
|
|
11288
|
+
"e2e-add-script",
|
|
11289
|
+
"e2e-add-step",
|
|
11290
|
+
"e2e-finish-recording"
|
|
11291
|
+
]);
|
|
11292
|
+
var RECORDING_FILE_INPUT = {
|
|
11293
|
+
target: "__recording",
|
|
11294
|
+
path: `\${project_root}/${E2E_DIRS[0].split(path14.sep).join("/")}/\${name}.yaml`,
|
|
11295
|
+
paths: E2E_DIRS.map((dir) => `\${project_root}/${dir.split(path14.sep).join("/")}/\${name}.yaml`),
|
|
11296
|
+
kind: "file",
|
|
11297
|
+
optional: true,
|
|
11298
|
+
collect: "flow"
|
|
11299
|
+
};
|
|
10961
11300
|
function secretsTransportRefusal(url) {
|
|
10962
11301
|
if (!URL.canParse(url)) return `${url} is not a URL`;
|
|
10963
11302
|
const { protocol, hostname } = new URL(url);
|
|
@@ -11000,15 +11339,36 @@ function failedRun(result) {
|
|
|
11000
11339
|
}
|
|
11001
11340
|
return result;
|
|
11002
11341
|
}
|
|
11342
|
+
function sessionFromEnv() {
|
|
11343
|
+
const session = process.env.ARGENT_SESSION?.trim();
|
|
11344
|
+
if (!session) return void 0;
|
|
11345
|
+
if (!isValidSession(session)) {
|
|
11346
|
+
throw new ToolInvocationError(
|
|
11347
|
+
"ARGENT_SESSION must be 1 to 128 printable ASCII characters without spaces."
|
|
11348
|
+
);
|
|
11349
|
+
}
|
|
11350
|
+
return session;
|
|
11351
|
+
}
|
|
11352
|
+
function hasSessionHeader(headers) {
|
|
11353
|
+
return Object.keys(headers).some((name) => name.toLowerCase() === SESSION_HEADER);
|
|
11354
|
+
}
|
|
11003
11355
|
function createToolsClient(options = {}) {
|
|
11004
11356
|
let cached = null;
|
|
11357
|
+
let linkedNoticeShown = false;
|
|
11358
|
+
let cachedToolList;
|
|
11005
11359
|
const doFetch = options.fetchImpl ?? ((url, init) => fetch(url, init));
|
|
11006
11360
|
const diagnose = options.onDiagnostic ?? ((message) => void process.stderr.write(`${message}
|
|
11007
11361
|
`));
|
|
11008
11362
|
async function route() {
|
|
11009
11363
|
if (options.baseUrl) return options.baseUrl();
|
|
11364
|
+
assertPrivateArgentHome();
|
|
11010
11365
|
const resolved = await getResolvedToolsUrl();
|
|
11011
11366
|
if (resolved.url) {
|
|
11367
|
+
if (!linkedNoticeShown) {
|
|
11368
|
+
linkedNoticeShown = true;
|
|
11369
|
+
const notice = linkedCloudCredentialNotice();
|
|
11370
|
+
if (notice) diagnose(notice);
|
|
11371
|
+
}
|
|
11012
11372
|
return { url: resolved.url, token: resolved.token ?? "", remote: true };
|
|
11013
11373
|
}
|
|
11014
11374
|
if (!cached) {
|
|
@@ -11028,13 +11388,16 @@ function createToolsClient(options = {}) {
|
|
|
11028
11388
|
async function fetchToolList(opts) {
|
|
11029
11389
|
opts?.signal?.throwIfAborted();
|
|
11030
11390
|
const { url, token } = await baseUrl();
|
|
11391
|
+
if (cachedToolList?.url === url) return cachedToolList.list;
|
|
11031
11392
|
const res = await doFetch(
|
|
11032
11393
|
`${url}/tools`,
|
|
11033
11394
|
{ headers: { ...options.headers?.(), ...authHeaders2(token) }, signal: opts?.signal },
|
|
11034
11395
|
{ longRunning: false, carriesUpload: false }
|
|
11035
11396
|
);
|
|
11036
11397
|
if (!res.ok) throw new Error(`GET /tools failed: ${res.status} ${res.statusText}`);
|
|
11037
|
-
|
|
11398
|
+
const list = await res.json();
|
|
11399
|
+
if (options.cacheToolList) cachedToolList = { url, list };
|
|
11400
|
+
return list;
|
|
11038
11401
|
}
|
|
11039
11402
|
async function fetchTools(opts) {
|
|
11040
11403
|
return (await fetchToolList(opts)).tools;
|
|
@@ -11045,6 +11408,7 @@ function createToolsClient(options = {}) {
|
|
|
11045
11408
|
async function callTool(name, args, opts) {
|
|
11046
11409
|
opts?.signal?.throwIfAborted();
|
|
11047
11410
|
assertFiniteNumbers(args);
|
|
11411
|
+
const envSession = options.ignoreEnvSession || hasSessionHeader(options.headers?.() ?? {}) ? void 0 : sessionFromEnv();
|
|
11048
11412
|
const { url, token, remote } = await route();
|
|
11049
11413
|
let finalArgs = canonicalToolArgs(name, args);
|
|
11050
11414
|
const { tools, uploadFormats } = await fetchToolList({ signal: opts?.signal });
|
|
@@ -11061,6 +11425,23 @@ function createToolsClient(options = {}) {
|
|
|
11061
11425
|
const shadowWarning = await e2eShadowWarningFor(name, args);
|
|
11062
11426
|
const baselineDirs = [];
|
|
11063
11427
|
let unwrittenBaselines = [];
|
|
11428
|
+
const memberOptions = {
|
|
11429
|
+
collectMembers: collectFlowMembers,
|
|
11430
|
+
collectStepMembers: olderServer ? (record, o) => collectStepMembers(record, o, (root) => path14.join(root, LEGACY_E2E_DIRS[0])) : collectStepMembers,
|
|
11431
|
+
toolFileInputs: (tool) => findTool(tools, tool)?.fileInputs,
|
|
11432
|
+
signal: opts?.signal
|
|
11433
|
+
};
|
|
11434
|
+
const scanned = remote ? void 0 : await localScanArgs(
|
|
11435
|
+
meta,
|
|
11436
|
+
finalArgs,
|
|
11437
|
+
(specs) => prepareFileInputs(specs, finalArgs ?? {}, {
|
|
11438
|
+
includeContent: true,
|
|
11439
|
+
scanOnly: true,
|
|
11440
|
+
log: () => {
|
|
11441
|
+
},
|
|
11442
|
+
...memberOptions
|
|
11443
|
+
})
|
|
11444
|
+
);
|
|
11064
11445
|
if (meta?.fileInputs?.length) {
|
|
11065
11446
|
if (remote) assertRequiredPresent(meta, finalArgs);
|
|
11066
11447
|
finalArgs = await prepareFileInputs(meta.fileInputs, finalArgs ?? {}, {
|
|
@@ -11068,10 +11449,7 @@ function createToolsClient(options = {}) {
|
|
|
11068
11449
|
uploadEndpoint: remote ? { url, token, formats: uploadFormats } : void 0,
|
|
11069
11450
|
log: diagnose,
|
|
11070
11451
|
baselineDirs,
|
|
11071
|
-
|
|
11072
|
-
collectStepMembers: olderServer ? (record, o) => collectStepMembers(record, o, (root) => path12.join(root, LEGACY_E2E_DIRS[0])) : collectStepMembers,
|
|
11073
|
-
toolFileInputs: (tool) => findTool(tools, tool)?.fileInputs,
|
|
11074
|
-
signal: opts?.signal
|
|
11452
|
+
...memberOptions
|
|
11075
11453
|
});
|
|
11076
11454
|
}
|
|
11077
11455
|
const settle = async (data2) => {
|
|
@@ -11082,7 +11460,7 @@ function createToolsClient(options = {}) {
|
|
|
11082
11460
|
}
|
|
11083
11461
|
if (filesLogEnabled()) {
|
|
11084
11462
|
for (const file of applied.written) {
|
|
11085
|
-
if (baselineDirs.includes(
|
|
11463
|
+
if (baselineDirs.includes(path14.dirname(file))) {
|
|
11086
11464
|
diagnose(`[e2e-files] baseline ${file}: written`);
|
|
11087
11465
|
}
|
|
11088
11466
|
}
|
|
@@ -11096,17 +11474,18 @@ function createToolsClient(options = {}) {
|
|
|
11096
11474
|
const unwrittenFailure = () => unwrittenBaselines.length > 0 ? `Baselines not written on this client: ${unwrittenBaselines.join(", ")}` : void 0;
|
|
11097
11475
|
const stream = opts?.onProgress !== void 0 || carriesMembers(finalArgs);
|
|
11098
11476
|
const sentOnce = carriesUpload(finalArgs);
|
|
11099
|
-
const
|
|
11100
|
-
const encodedSecrets =
|
|
11101
|
-
const clientSecrets =
|
|
11477
|
+
const sent = await callerSecrets(remote ? finalArgs : scanned, remote, options.secretsFile);
|
|
11478
|
+
const encodedSecrets = sent ? encodeClientSecrets(sent.values) : void 0;
|
|
11479
|
+
const clientSecrets = sent?.values.size ? sent.values : void 0;
|
|
11102
11480
|
const refusal = clientSecrets ? secretsTransportRefusal(url) : void 0;
|
|
11103
11481
|
if (refusal !== void 0) {
|
|
11104
11482
|
throw new Error(
|
|
11105
|
-
`
|
|
11483
|
+
`argent sends secret values only over https:// with the certificate checked, or to a loopback address, so the call was not sent (it names ${[...clientSecrets.keys()].join(", ")}): ${refusal}.`
|
|
11106
11484
|
);
|
|
11107
11485
|
}
|
|
11108
11486
|
const toolUrl = `${url}/tools/${encodeURIComponent(meta?.name ?? name)}`;
|
|
11109
11487
|
const headers = {
|
|
11488
|
+
...envSession ? { [SESSION_HEADER]: envSession } : {},
|
|
11110
11489
|
...options.headers?.(),
|
|
11111
11490
|
"Content-Type": "application/json",
|
|
11112
11491
|
// Tells the tool-server the call came over a link, a link to
|
|
@@ -11121,16 +11500,21 @@ function createToolsClient(options = {}) {
|
|
|
11121
11500
|
...stream ? { "Accept": "application/x-ndjson", "Accept-Encoding": "identity" } : {},
|
|
11122
11501
|
...authHeaders2(token)
|
|
11123
11502
|
};
|
|
11124
|
-
|
|
11125
|
-
|
|
11126
|
-
|
|
11127
|
-
|
|
11128
|
-
|
|
11129
|
-
|
|
11130
|
-
throw new Error(
|
|
11131
|
-
`forward-secrets would send ${[...clientSecrets.keys()].join(", ")} in an ${CLIENT_SECRETS_HEADER} header of ${encodedSecrets.length} bytes, which takes the request headers past the ${maxHeaderSize} bytes a tool-server accepts, so the call was not sent. Define a secret this large on the machine running the tool-server instead.`
|
|
11503
|
+
const headBytes = () => toolUrl.length + FETCH_HEAD_BYTES + Object.entries(headers).reduce((sum, [key, value]) => sum + key.length + value.length + 4, 0);
|
|
11504
|
+
if (sent?.sources) {
|
|
11505
|
+
headers[CLIENT_SECRET_SOURCES_HEADER] = encodeSecretSourceSummaries(sent.sources);
|
|
11506
|
+
if (headBytes() > maxHeaderSize) {
|
|
11507
|
+
headers[CLIENT_SECRET_SOURCES_HEADER] = encodeSecretSourceSummaries(
|
|
11508
|
+
sent.sources.map((source) => ({ ...source, names: [] }))
|
|
11132
11509
|
);
|
|
11133
11510
|
}
|
|
11511
|
+
if (headBytes() > maxHeaderSize) delete headers[CLIENT_SECRET_SOURCES_HEADER];
|
|
11512
|
+
}
|
|
11513
|
+
if (clientSecrets !== void 0 && encodedSecrets !== void 0 && headBytes() > maxHeaderSize) {
|
|
11514
|
+
const names = [...clientSecrets.keys()].join(", ");
|
|
11515
|
+
throw new Error(
|
|
11516
|
+
remote ? `This call would send ${names} in an ${CLIENT_SECRETS_HEADER} header of ${encodedSecrets.length} bytes, which takes the request headers to about ${headBytes()} bytes, past the ${maxHeaderSize} bytes a tool-server accepts, so the call was not sent. Define a secret this large only on the machine running the tool-server instead.` : `The values of ${names} take the ${CLIENT_SECRETS_HEADER} header to ${encodedSecrets.length} bytes and the request headers to about ${headBytes()} bytes, past the ${maxHeaderSize} bytes the tool-server accepts, so the call was not sent. One call can send about 11 KiB of secret values: split the text across several calls.`
|
|
11517
|
+
);
|
|
11134
11518
|
}
|
|
11135
11519
|
const res = await doFetch(
|
|
11136
11520
|
toolUrl,
|
|
@@ -11183,13 +11567,13 @@ function createToolsClient(options = {}) {
|
|
|
11183
11567
|
}
|
|
11184
11568
|
if (clientSecrets && res.status >= 300 && res.status < 400) {
|
|
11185
11569
|
throw new ToolInvocationError(
|
|
11186
|
-
`The tool-server answered ${res.status} ${res.statusText} to ${name}.
|
|
11570
|
+
`The tool-server answered ${res.status} ${res.statusText} to ${name}. argent does not follow a redirect with secret values, so the call was not sent on; link the URL it points to instead.`
|
|
11187
11571
|
);
|
|
11188
11572
|
}
|
|
11189
11573
|
const headersRefused = res.status === 431 || res.status === 400 && errorBodyMessage(json) === void 0;
|
|
11190
11574
|
if (clientSecrets && headersRefused) {
|
|
11191
11575
|
throw new ToolInvocationError(
|
|
11192
|
-
`The tool-server, or a proxy in front of it, refused the request headers (${res.status}), as it does when they are too large. The ${CLIENT_SECRETS_HEADER} header carried ${[...clientSecrets.keys()].join(", ")}; define a secret this large on the machine running the tool-server instead.`
|
|
11576
|
+
`The tool-server, or a proxy in front of it, refused the request headers (${res.status}), as it does when they are too large. The ${CLIENT_SECRETS_HEADER} header carried ${[...clientSecrets.keys()].join(", ")}; ` + (remote ? `define a secret this large on the machine running the tool-server instead.` : `split the text across several calls.`)
|
|
11193
11577
|
);
|
|
11194
11578
|
}
|
|
11195
11579
|
if (!res.ok) {
|
|
@@ -11216,17 +11600,17 @@ function createToolsClient(options = {}) {
|
|
|
11216
11600
|
// ../argent-tools-client/src/artifacts.ts
|
|
11217
11601
|
import {
|
|
11218
11602
|
copyFile,
|
|
11219
|
-
mkdir as
|
|
11603
|
+
mkdir as mkdir3,
|
|
11220
11604
|
mkdtemp,
|
|
11221
11605
|
readFile as readFile6,
|
|
11222
11606
|
realpath as realpath4,
|
|
11223
11607
|
rm as rm3,
|
|
11224
11608
|
stat as stat5,
|
|
11225
|
-
writeFile as
|
|
11609
|
+
writeFile as writeFile2
|
|
11226
11610
|
} from "node:fs/promises";
|
|
11227
11611
|
import { constants as fsConstants } from "node:fs";
|
|
11228
11612
|
import { tmpdir as tmpdir2 } from "node:os";
|
|
11229
|
-
import { basename as basename7,
|
|
11613
|
+
import { basename as basename7, extname as extname2, isAbsolute as isAbsolute6, join as join15, normalize as normalize2, resolve as resolve11, sep as sep6 } from "node:path";
|
|
11230
11614
|
import { createHash as createHash3 } from "node:crypto";
|
|
11231
11615
|
var ARTIFACT_MARKER2 = "__argentArtifact";
|
|
11232
11616
|
function isArtifactHandle(value) {
|
|
@@ -11250,16 +11634,16 @@ function projectSlug() {
|
|
|
11250
11634
|
return `${name}-${hash}`;
|
|
11251
11635
|
}
|
|
11252
11636
|
function artifactsRoot() {
|
|
11253
|
-
return process.env.ARGENT_ARTIFACTS_DIR ??
|
|
11637
|
+
return process.env.ARGENT_ARTIFACTS_DIR ?? join15(tmpdir2(), "argent-artifacts");
|
|
11254
11638
|
}
|
|
11255
11639
|
function artifactDir(deviceId) {
|
|
11256
11640
|
const parts = [artifactsRoot(), projectSlug(), sessionId()];
|
|
11257
11641
|
if (deviceId) parts.push(sanitizeSegment(deviceId));
|
|
11258
|
-
return
|
|
11642
|
+
return join15(...parts);
|
|
11259
11643
|
}
|
|
11260
11644
|
function durableBaseDir() {
|
|
11261
11645
|
const projectRoot = findProjectRoot(process.cwd());
|
|
11262
|
-
return projectRoot ??
|
|
11646
|
+
return projectRoot ?? resolveHomeDir();
|
|
11263
11647
|
}
|
|
11264
11648
|
var ALLOWED_SAVE_DIRS = /* @__PURE__ */ new Set([normalize2(".argent/recordings")]);
|
|
11265
11649
|
var RECORDINGS_SAVE_DIR = normalize2(".argent/recordings");
|
|
@@ -11273,9 +11657,9 @@ function configuredRecordingsDir() {
|
|
|
11273
11657
|
if (typeof value !== "string") return null;
|
|
11274
11658
|
const trimmed = value.trim();
|
|
11275
11659
|
if (trimmed === "") return null;
|
|
11276
|
-
const home =
|
|
11277
|
-
const expanded = trimmed === "~" ? home : trimmed.startsWith("~/") || trimmed.startsWith(`~${
|
|
11278
|
-
return
|
|
11660
|
+
const home = resolveHomeDir();
|
|
11661
|
+
const expanded = trimmed === "~" ? home : trimmed.startsWith("~/") || trimmed.startsWith(`~${sep6}`) ? join15(home, trimmed.slice(2)) : trimmed;
|
|
11662
|
+
return resolve11(durableBaseDir(), expanded);
|
|
11279
11663
|
}
|
|
11280
11664
|
var MAX_ARTIFACT_BYTES = 2 * 1024 * 1024 * 1024;
|
|
11281
11665
|
async function readCapped(res, cap) {
|
|
@@ -11308,10 +11692,10 @@ async function writeDurableUnique(dir, filename, write) {
|
|
|
11308
11692
|
const stem = filename.slice(0, filename.length - ext.length);
|
|
11309
11693
|
for (let i = 1; i <= 1e3; i++) {
|
|
11310
11694
|
const candidate = i === 1 ? filename : `${stem} (${i})${ext}`;
|
|
11311
|
-
const
|
|
11695
|
+
const path16 = join15(dir, candidate);
|
|
11312
11696
|
try {
|
|
11313
|
-
await write(
|
|
11314
|
-
return
|
|
11697
|
+
await write(path16);
|
|
11698
|
+
return path16;
|
|
11315
11699
|
} catch (err) {
|
|
11316
11700
|
if (err?.code === "EEXIST") continue;
|
|
11317
11701
|
throw err;
|
|
@@ -11322,7 +11706,7 @@ async function writeDurableUnique(dir, filename, write) {
|
|
|
11322
11706
|
function durableSaveTarget(handle) {
|
|
11323
11707
|
if (typeof handle.saveDir !== "string" || !handle.saveDir || handle.archive) return null;
|
|
11324
11708
|
const rel = normalize2(handle.saveDir);
|
|
11325
|
-
if (isAbsolute6(rel) || rel === ".." || rel.startsWith(`..${
|
|
11709
|
+
if (isAbsolute6(rel) || rel === ".." || rel.startsWith(`..${sep6}`) || rel.split(sep6).includes("..")) {
|
|
11326
11710
|
return null;
|
|
11327
11711
|
}
|
|
11328
11712
|
if (!ALLOWED_SAVE_DIRS.has(rel)) return null;
|
|
@@ -11331,21 +11715,21 @@ function durableSaveTarget(handle) {
|
|
|
11331
11715
|
if (configured) {
|
|
11332
11716
|
return {
|
|
11333
11717
|
dir: configured,
|
|
11334
|
-
path:
|
|
11718
|
+
path: join15(configured, sanitizeSegment(handle.filename)),
|
|
11335
11719
|
base: configured,
|
|
11336
11720
|
rel: ""
|
|
11337
11721
|
};
|
|
11338
11722
|
}
|
|
11339
11723
|
}
|
|
11340
11724
|
const base = durableBaseDir();
|
|
11341
|
-
const dir =
|
|
11342
|
-
return { dir, path:
|
|
11725
|
+
const dir = join15(base, rel);
|
|
11726
|
+
return { dir, path: join15(dir, sanitizeSegment(handle.filename)), base, rel };
|
|
11343
11727
|
}
|
|
11344
11728
|
async function confineToRealBase(dir, base, rel) {
|
|
11345
11729
|
try {
|
|
11346
11730
|
const realDir = await realpath4(dir);
|
|
11347
11731
|
const realBase = await realpath4(base);
|
|
11348
|
-
return realDir ===
|
|
11732
|
+
return realDir === join15(realBase, rel);
|
|
11349
11733
|
} catch {
|
|
11350
11734
|
return false;
|
|
11351
11735
|
}
|
|
@@ -11369,12 +11753,12 @@ async function resolveLocalFile(handle) {
|
|
|
11369
11753
|
}
|
|
11370
11754
|
async function downloadAndExtractArchive(handle, data, dir, signal) {
|
|
11371
11755
|
signal?.throwIfAborted();
|
|
11372
|
-
const attemptDir = await mkdtemp(
|
|
11373
|
-
const tarball =
|
|
11374
|
-
const extractDir =
|
|
11756
|
+
const attemptDir = await mkdtemp(join15(dir, "bundle-"));
|
|
11757
|
+
const tarball = join15(attemptDir, "download.tar");
|
|
11758
|
+
const extractDir = join15(attemptDir, "files");
|
|
11375
11759
|
try {
|
|
11376
|
-
await
|
|
11377
|
-
await
|
|
11760
|
+
await writeFile2(tarball, data, { signal });
|
|
11761
|
+
await mkdir3(extractDir);
|
|
11378
11762
|
const member = await safeExtractArchive(tarball, extractDir, handle.filename, signal);
|
|
11379
11763
|
await rm3(tarball);
|
|
11380
11764
|
signal?.throwIfAborted();
|
|
@@ -11393,7 +11777,7 @@ async function materializeArtifacts(result, ctx) {
|
|
|
11393
11777
|
let dirReady = false;
|
|
11394
11778
|
async function ensureDir() {
|
|
11395
11779
|
if (!dirReady) {
|
|
11396
|
-
await
|
|
11780
|
+
await mkdir3(dir, { recursive: true });
|
|
11397
11781
|
dirReady = true;
|
|
11398
11782
|
}
|
|
11399
11783
|
}
|
|
@@ -11404,7 +11788,7 @@ async function materializeArtifacts(result, ctx) {
|
|
|
11404
11788
|
if (saveTarget) {
|
|
11405
11789
|
const filename = basename7(saveTarget.path);
|
|
11406
11790
|
try {
|
|
11407
|
-
await
|
|
11791
|
+
await mkdir3(saveTarget.dir, { recursive: true });
|
|
11408
11792
|
if (!await confineToRealBase(saveTarget.dir, saveTarget.base, saveTarget.rel)) {
|
|
11409
11793
|
return null;
|
|
11410
11794
|
}
|
|
@@ -11437,7 +11821,7 @@ async function materializeArtifacts(result, ctx) {
|
|
|
11437
11821
|
const finalPath = await writeDurableUnique(
|
|
11438
11822
|
saveTarget.dir,
|
|
11439
11823
|
filename,
|
|
11440
|
-
(p) =>
|
|
11824
|
+
(p) => writeFile2(p, data, { flag: "wx" })
|
|
11441
11825
|
);
|
|
11442
11826
|
if (!finalPath) return null;
|
|
11443
11827
|
if (value.mimeType.startsWith("image/")) {
|
|
@@ -11471,8 +11855,8 @@ async function materializeArtifacts(result, ctx) {
|
|
|
11471
11855
|
return await downloadAndExtractArchive(value, data, dir, ctx.signal);
|
|
11472
11856
|
}
|
|
11473
11857
|
if (value.size > 0 && data.length !== value.size) return null;
|
|
11474
|
-
const downloadedPath =
|
|
11475
|
-
await
|
|
11858
|
+
const downloadedPath = join15(dir, sanitizeSegment(value.filename));
|
|
11859
|
+
await writeFile2(downloadedPath, data);
|
|
11476
11860
|
if (value.mimeType.startsWith("image/")) {
|
|
11477
11861
|
images.push({ localPath: downloadedPath, data, mimeType: value.mimeType });
|
|
11478
11862
|
}
|
|
@@ -11504,13 +11888,16 @@ function getDeviceIdFromArgs(args) {
|
|
|
11504
11888
|
return void 0;
|
|
11505
11889
|
}
|
|
11506
11890
|
|
|
11891
|
+
// ../argent-tools-client/src/auto-capture.ts
|
|
11892
|
+
import { setTimeout as sleep } from "node:timers/promises";
|
|
11893
|
+
|
|
11507
11894
|
// src/bundled-paths.ts
|
|
11508
|
-
import * as
|
|
11509
|
-
import * as
|
|
11895
|
+
import * as fs11 from "node:fs";
|
|
11896
|
+
import * as path15 from "node:path";
|
|
11510
11897
|
function readPackageVersion() {
|
|
11511
11898
|
try {
|
|
11512
11899
|
const pkg = JSON.parse(
|
|
11513
|
-
|
|
11900
|
+
fs11.readFileSync(path15.join(import.meta.dirname, "..", "package.json"), "utf8")
|
|
11514
11901
|
);
|
|
11515
11902
|
return pkg.version;
|
|
11516
11903
|
} catch {
|
|
@@ -11521,15 +11908,15 @@ var PACKAGE_NAME = "@swmansion/argent";
|
|
|
11521
11908
|
function findDeclaringRoot(startDir) {
|
|
11522
11909
|
let dir = startDir;
|
|
11523
11910
|
for (; ; ) {
|
|
11524
|
-
if (
|
|
11911
|
+
if (fs11.existsSync(path15.join(dir, ".argent", "install.json"))) return dir;
|
|
11525
11912
|
try {
|
|
11526
|
-
const manifest = JSON.parse(
|
|
11913
|
+
const manifest = JSON.parse(fs11.readFileSync(path15.join(dir, "package.json"), "utf8"));
|
|
11527
11914
|
if (manifest.devDependencies?.[PACKAGE_NAME] || manifest.dependencies?.[PACKAGE_NAME] || manifest.optionalDependencies?.[PACKAGE_NAME]) {
|
|
11528
11915
|
return dir;
|
|
11529
11916
|
}
|
|
11530
11917
|
} catch {
|
|
11531
11918
|
}
|
|
11532
|
-
const parent =
|
|
11919
|
+
const parent = path15.dirname(dir);
|
|
11533
11920
|
if (parent === dir) return null;
|
|
11534
11921
|
dir = parent;
|
|
11535
11922
|
}
|
|
@@ -11537,12 +11924,12 @@ function findDeclaringRoot(startDir) {
|
|
|
11537
11924
|
function findStablePackageDir(startDir, packageRoot) {
|
|
11538
11925
|
let dir = startDir;
|
|
11539
11926
|
for (; ; ) {
|
|
11540
|
-
const candidate =
|
|
11927
|
+
const candidate = path15.join(dir, "node_modules", PACKAGE_NAME);
|
|
11541
11928
|
try {
|
|
11542
|
-
if (
|
|
11929
|
+
if (fs11.realpathSync(candidate) === packageRoot) return candidate;
|
|
11543
11930
|
} catch {
|
|
11544
11931
|
}
|
|
11545
|
-
const parent =
|
|
11932
|
+
const parent = path15.dirname(dir);
|
|
11546
11933
|
if (parent === dir) return void 0;
|
|
11547
11934
|
dir = parent;
|
|
11548
11935
|
}
|
|
@@ -11552,7 +11939,7 @@ function classifyInstall() {
|
|
|
11552
11939
|
let dir;
|
|
11553
11940
|
let cwd;
|
|
11554
11941
|
try {
|
|
11555
|
-
packageRoot =
|
|
11942
|
+
packageRoot = fs11.realpathSync(path15.join(import.meta.dirname, ".."));
|
|
11556
11943
|
cwd = process.cwd();
|
|
11557
11944
|
dir = cwd;
|
|
11558
11945
|
} catch {
|
|
@@ -11560,8 +11947,8 @@ function classifyInstall() {
|
|
|
11560
11947
|
}
|
|
11561
11948
|
for (; ; ) {
|
|
11562
11949
|
try {
|
|
11563
|
-
const nmReal =
|
|
11564
|
-
if (packageRoot === nmReal || packageRoot.startsWith(nmReal +
|
|
11950
|
+
const nmReal = fs11.realpathSync(path15.join(dir, "node_modules"));
|
|
11951
|
+
if (packageRoot === nmReal || packageRoot.startsWith(nmReal + path15.sep)) {
|
|
11565
11952
|
return {
|
|
11566
11953
|
kind: "local",
|
|
11567
11954
|
projectRoot: findDeclaringRoot(cwd) ?? dir,
|
|
@@ -11570,22 +11957,22 @@ function classifyInstall() {
|
|
|
11570
11957
|
}
|
|
11571
11958
|
} catch {
|
|
11572
11959
|
}
|
|
11573
|
-
const parent =
|
|
11960
|
+
const parent = path15.dirname(dir);
|
|
11574
11961
|
if (parent === dir) break;
|
|
11575
11962
|
dir = parent;
|
|
11576
11963
|
}
|
|
11577
|
-
if (packageRoot.includes(`${
|
|
11964
|
+
if (packageRoot.includes(`${path15.sep}.yarn${path15.sep}`)) {
|
|
11578
11965
|
const declRoot = findDeclaringRoot(cwd);
|
|
11579
11966
|
if (declRoot) return { kind: "local", projectRoot: declRoot };
|
|
11580
11967
|
}
|
|
11581
11968
|
return { kind: "global" };
|
|
11582
11969
|
}
|
|
11583
11970
|
var classifiedInstall = classifyInstall();
|
|
11584
|
-
var packageDir = classifiedInstall.stablePackageDir ??
|
|
11971
|
+
var packageDir = classifiedInstall.stablePackageDir ?? path15.join(import.meta.dirname, "..");
|
|
11585
11972
|
var BUNDLED_RUNTIME_PATHS = {
|
|
11586
|
-
bundlePath:
|
|
11587
|
-
simulatorServerDir:
|
|
11588
|
-
nativeDevtoolsDir:
|
|
11973
|
+
bundlePath: path15.join(packageDir, "dist", "tool-server.cjs"),
|
|
11974
|
+
simulatorServerDir: path15.join(packageDir, "bin"),
|
|
11975
|
+
nativeDevtoolsDir: path15.join(packageDir, "dylibs"),
|
|
11589
11976
|
version: readPackageVersion(),
|
|
11590
11977
|
installKind: classifiedInstall.kind,
|
|
11591
11978
|
installProjectRoot: classifiedInstall.projectRoot
|
|
@@ -11617,7 +12004,7 @@ function listFlags() {
|
|
|
11617
12004
|
function createArgentClient() {
|
|
11618
12005
|
let client = createToolsClient({ paths: BUNDLED_RUNTIME_PATHS });
|
|
11619
12006
|
async function stopServer() {
|
|
11620
|
-
const stopped = await killToolServer(BUNDLED_RUNTIME_PATHS.bundlePath);
|
|
12007
|
+
const stopped = await killToolServer(BUNDLED_RUNTIME_PATHS.bundlePath, clientCloudProfile());
|
|
11621
12008
|
client = createToolsClient({ paths: BUNDLED_RUNTIME_PATHS });
|
|
11622
12009
|
return stopped;
|
|
11623
12010
|
}
|