@swmansion/argent 0.27.1-next.20 → 0.27.1-next.22
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli-cmds.mjs +331 -56
- package/dist/client.js +296 -48
- package/dist/installer.mjs +17 -7
- package/dist/mcp-server.mjs +306 -52
- package/dist/tool-args.generated.d.ts +1 -1
- package/dist/tool-server.cjs +853 -591
- package/package.json +1 -1
- package/skills/argent-create-flow/references/live-authoring.md +9 -1
package/dist/client.js
CHANGED
|
@@ -8566,6 +8566,35 @@ var FLOW_NAME_CHARSET = "[A-Za-z0-9_-]+";
|
|
|
8566
8566
|
var FLOW_NAME_PATTERN = new RegExp(`^${FLOW_NAME_CHARSET}$`);
|
|
8567
8567
|
var FLOW_FILE_NAME_PATTERN = new RegExp(`^${FLOW_NAME_CHARSET}\\.yaml$`);
|
|
8568
8568
|
var SCRIPT_FILE_NAME_PATTERN = new RegExp(`^${FLOW_NAME_CHARSET}\\.mjs$`);
|
|
8569
|
+
function interpolateFileInputPath(template, args) {
|
|
8570
|
+
let missing = false;
|
|
8571
|
+
const out = template.replace(/\$\{([A-Za-z0-9_]+)\}/g, (_m, name) => {
|
|
8572
|
+
const v = args[name];
|
|
8573
|
+
if (typeof v !== "string" || v.length === 0) {
|
|
8574
|
+
missing = true;
|
|
8575
|
+
return "";
|
|
8576
|
+
}
|
|
8577
|
+
return v;
|
|
8578
|
+
});
|
|
8579
|
+
return missing ? null : out;
|
|
8580
|
+
}
|
|
8581
|
+
var TOOL_FILE_EXTENSIONS = [".png", ".yaml"];
|
|
8582
|
+
function hasToolFileExtension(file) {
|
|
8583
|
+
const name = file.toLowerCase();
|
|
8584
|
+
return TOOL_FILE_EXTENSIONS.some((extension) => name.endsWith(extension));
|
|
8585
|
+
}
|
|
8586
|
+
function toolStepFiles(specs, args) {
|
|
8587
|
+
const files = [];
|
|
8588
|
+
for (const spec of specs ?? []) {
|
|
8589
|
+
if (spec.skipWhenSet !== void 0 && args[spec.skipWhenSet] !== void 0) continue;
|
|
8590
|
+
const filled = interpolateFileInputPath(spec.path, args);
|
|
8591
|
+
if (filled !== null) files.push({ spec, path: filled });
|
|
8592
|
+
}
|
|
8593
|
+
return files;
|
|
8594
|
+
}
|
|
8595
|
+
function isClientFileArgument({ spec, path: path12 }) {
|
|
8596
|
+
return spec.kind === "file" && spec.path === `\${${spec.target}}` && path12.startsWith("/") && hasToolFileExtension(path12);
|
|
8597
|
+
}
|
|
8569
8598
|
|
|
8570
8599
|
// ../registry/src/flow-file-refs.ts
|
|
8571
8600
|
import * as fs5 from "node:fs/promises";
|
|
@@ -8593,6 +8622,8 @@ function isRecord(value) {
|
|
|
8593
8622
|
}
|
|
8594
8623
|
function collectFlowRequests(doc) {
|
|
8595
8624
|
const runTargets = /* @__PURE__ */ new Set();
|
|
8625
|
+
const snapshots = /* @__PURE__ */ new Set();
|
|
8626
|
+
const toolSteps = [];
|
|
8596
8627
|
const seen = /* @__PURE__ */ new Set();
|
|
8597
8628
|
const visit = (steps, depth) => {
|
|
8598
8629
|
if (!Array.isArray(steps) || depth > MAX_BLOCK_NESTING || seen.has(steps)) return;
|
|
@@ -8604,11 +8635,20 @@ function collectFlowRequests(doc) {
|
|
|
8604
8635
|
const target = completeRunExtension(run);
|
|
8605
8636
|
if (FLOW_FILE_NAME_PATTERN.test(path7.posix.basename(target))) runTargets.add(target);
|
|
8606
8637
|
}
|
|
8638
|
+
const snapshot = isRecord(step.snapshot) ? step.snapshot.name : step.snapshot;
|
|
8639
|
+
if (typeof snapshot === "string" && FLOW_NAME_PATTERN.test(snapshot)) snapshots.add(snapshot);
|
|
8640
|
+
if (typeof step.tool === "string") {
|
|
8641
|
+
toolSteps.push({ tool: step.tool, args: isRecord(step.args) ? step.args : {} });
|
|
8642
|
+
}
|
|
8607
8643
|
visit(step.steps, depth + 1);
|
|
8608
8644
|
}
|
|
8609
8645
|
};
|
|
8610
8646
|
if (isRecord(doc)) visit(doc.steps, 0);
|
|
8611
|
-
return { runTargets: [...runTargets] };
|
|
8647
|
+
return { runTargets: [...runTargets], snapshots: [...snapshots], toolSteps };
|
|
8648
|
+
}
|
|
8649
|
+
function baselineKeyFor(canonicalPath, flowName) {
|
|
8650
|
+
const stem = path7.basename(canonicalPath, ".yaml");
|
|
8651
|
+
return FLOW_NAME_PATTERN.test(stem) ? stem : flowName;
|
|
8612
8652
|
}
|
|
8613
8653
|
function flowMemberKey(anchorDir, target) {
|
|
8614
8654
|
return `${anchorDir}\0${target}`;
|
|
@@ -9045,7 +9085,17 @@ async function getResolvedToolsUrl() {
|
|
|
9045
9085
|
// ../argent-tools-client/src/file-inputs.ts
|
|
9046
9086
|
import { createHash as createHash2, randomUUID as randomUUID4 } from "node:crypto";
|
|
9047
9087
|
import { createReadStream, rmSync as rmSync2 } from "node:fs";
|
|
9048
|
-
import {
|
|
9088
|
+
import {
|
|
9089
|
+
chmod as chmod3,
|
|
9090
|
+
lstat,
|
|
9091
|
+
mkdir as mkdir3,
|
|
9092
|
+
readFile as readFile3,
|
|
9093
|
+
realpath as realpath2,
|
|
9094
|
+
rename as rename2,
|
|
9095
|
+
rm as rm2,
|
|
9096
|
+
stat as stat2,
|
|
9097
|
+
writeFile as writeFile3
|
|
9098
|
+
} from "node:fs/promises";
|
|
9049
9099
|
import { constants, tmpdir } from "node:os";
|
|
9050
9100
|
import * as path9 from "node:path";
|
|
9051
9101
|
|
|
@@ -9354,9 +9404,61 @@ function isAllowedClientFilePath(p) {
|
|
|
9354
9404
|
function isClientFileDirective2(value) {
|
|
9355
9405
|
return !!value && typeof value === "object" && value[CLIENT_FILE_MARKER2] === true && typeof value.path === "string" && typeof value.content === "string";
|
|
9356
9406
|
}
|
|
9357
|
-
async function
|
|
9407
|
+
async function replaceFile(target, bytes, mode) {
|
|
9408
|
+
const temp = path9.join(path9.dirname(target), `.baseline-${randomUUID4()}.tmp`);
|
|
9409
|
+
try {
|
|
9410
|
+
await writeFile3(temp, bytes, { flag: "wx" });
|
|
9411
|
+
if (mode !== void 0) await chmod3(temp, mode & 511);
|
|
9412
|
+
await rename2(temp, target);
|
|
9413
|
+
} catch (err) {
|
|
9414
|
+
await rm2(temp, { force: true });
|
|
9415
|
+
throw err;
|
|
9416
|
+
}
|
|
9417
|
+
}
|
|
9418
|
+
async function writeBaselineFile(file, bytes, allowedDirs) {
|
|
9419
|
+
if (!path9.isAbsolute(file) || path9.normalize(file) !== file || file.split(/[\\/]/).includes("..") || !file.endsWith(".png") || !allowedDirs.includes(path9.dirname(file))) {
|
|
9420
|
+
return allowedDirs.length === 0 ? "this call writes no baselines" : `${file} is not a baseline of this call (${allowedDirs.map((d) => `${d}/<name>.png`).join(", ")})`;
|
|
9421
|
+
}
|
|
9422
|
+
if (bytes.length > MAX_CONTENT_BYTES) {
|
|
9423
|
+
return `${file}: the baseline is larger than the 32 MiB cap on a file this client writes`;
|
|
9424
|
+
}
|
|
9425
|
+
const dir = path9.dirname(file);
|
|
9426
|
+
await mkdir3(dir, { recursive: true });
|
|
9427
|
+
const link = await lstat(file).catch(() => null);
|
|
9428
|
+
const real = link === null ? null : await realpath2(file).catch(() => null);
|
|
9429
|
+
if (link !== null && real === null) return `${file} is a symbolic link to a missing file`;
|
|
9430
|
+
if (real !== null) {
|
|
9431
|
+
if (!real.endsWith(".png")) return `${file} links to a file that is not a PNG file`;
|
|
9432
|
+
if (path9.dirname(real) !== await realpath2(dir)) {
|
|
9433
|
+
return `${file} links outside its baseline directory`;
|
|
9434
|
+
}
|
|
9435
|
+
}
|
|
9436
|
+
const existing = real === null ? null : await stat2(real);
|
|
9437
|
+
if (existing !== null && !existing.isFile()) return `${file} is not a regular file`;
|
|
9438
|
+
await replaceFile(
|
|
9439
|
+
real ?? path9.join(await realpath2(dir), path9.basename(file)),
|
|
9440
|
+
bytes,
|
|
9441
|
+
existing?.mode
|
|
9442
|
+
);
|
|
9443
|
+
return null;
|
|
9444
|
+
}
|
|
9445
|
+
async function applyClientFileDirectives(result, opts = {}) {
|
|
9358
9446
|
const written = [];
|
|
9447
|
+
const failed = [];
|
|
9359
9448
|
async function walk(value) {
|
|
9449
|
+
if (isClientFileDirective2(value) && value.encoding === "base64") {
|
|
9450
|
+
const error = await writeBaselineFile(
|
|
9451
|
+
value.path,
|
|
9452
|
+
Buffer.from(value.content, "base64"),
|
|
9453
|
+
opts.allowedDirs ?? []
|
|
9454
|
+
).catch((err) => err instanceof Error ? err.message : String(err));
|
|
9455
|
+
if (error !== null) {
|
|
9456
|
+
failed.push({ path: value.path, error });
|
|
9457
|
+
return { path: value.path, error };
|
|
9458
|
+
}
|
|
9459
|
+
written.push(value.path);
|
|
9460
|
+
return value.path;
|
|
9461
|
+
}
|
|
9360
9462
|
if (isClientFileDirective2(value)) {
|
|
9361
9463
|
if (!isAllowedClientFilePath(value.path)) return null;
|
|
9362
9464
|
try {
|
|
@@ -9369,7 +9471,9 @@ async function applyClientFileDirectives(result) {
|
|
|
9369
9471
|
}
|
|
9370
9472
|
}
|
|
9371
9473
|
if (Array.isArray(value)) {
|
|
9372
|
-
|
|
9474
|
+
const out = [];
|
|
9475
|
+
for (const item of value) out.push(await walk(item));
|
|
9476
|
+
return out;
|
|
9373
9477
|
}
|
|
9374
9478
|
if (value && typeof value === "object") {
|
|
9375
9479
|
const out = {};
|
|
@@ -9381,12 +9485,12 @@ async function applyClientFileDirectives(result) {
|
|
|
9381
9485
|
return value;
|
|
9382
9486
|
}
|
|
9383
9487
|
const rewritten = await walk(result);
|
|
9384
|
-
return { result: rewritten, written };
|
|
9488
|
+
return { result: rewritten, written, failed };
|
|
9385
9489
|
}
|
|
9386
9490
|
|
|
9387
9491
|
// ../argent-tools-client/src/flow-files.ts
|
|
9388
9492
|
var import_yaml = __toESM(require_dist(), 1);
|
|
9389
|
-
import { readFile as readFile4, realpath as
|
|
9493
|
+
import { readdir as readdir4, readFile as readFile4, realpath as realpath3, stat as stat3 } from "node:fs/promises";
|
|
9390
9494
|
import * as path10 from "node:path";
|
|
9391
9495
|
var INLINE_MEMBERS_BYTES = 256 * 1024;
|
|
9392
9496
|
var FLOW_FILES_LOG_ENV = "ARGENT_FLOW_FILES_LOG";
|
|
@@ -9421,7 +9525,7 @@ function savedFlowProject(file) {
|
|
|
9421
9525
|
}
|
|
9422
9526
|
async function landing(spelled) {
|
|
9423
9527
|
try {
|
|
9424
|
-
const canonical = await
|
|
9528
|
+
const canonical = await realpath3(spelled);
|
|
9425
9529
|
return { canonical, fence: canonical };
|
|
9426
9530
|
} catch (err) {
|
|
9427
9531
|
const failure = err.code === "ENOENT" ? { missing: true } : { error: err.message };
|
|
@@ -9430,7 +9534,7 @@ async function landing(spelled) {
|
|
|
9430
9534
|
for (; ; ) {
|
|
9431
9535
|
const parent = path10.dirname(at);
|
|
9432
9536
|
if (parent === at) return { canonical, fence: spelled, ...failure };
|
|
9433
|
-
const real = await
|
|
9537
|
+
const real = await realpath3(parent).catch(() => null);
|
|
9434
9538
|
if (real !== null) {
|
|
9435
9539
|
return { canonical, fence: path10.join(real, path10.basename(at)), ...failure };
|
|
9436
9540
|
}
|
|
@@ -9450,7 +9554,7 @@ async function closureRoots(rootPath, rootCanonical, projectRoot) {
|
|
|
9450
9554
|
}
|
|
9451
9555
|
const real = [];
|
|
9452
9556
|
for (const candidate of candidates) {
|
|
9453
|
-
const resolved = await
|
|
9557
|
+
const resolved = await realpath3(candidate).catch(() => null);
|
|
9454
9558
|
if (resolved !== null && !real.includes(resolved)) real.push(resolved);
|
|
9455
9559
|
}
|
|
9456
9560
|
return real.filter((root) => !real.some((other) => other !== root && isWithin(root, other)));
|
|
@@ -9488,31 +9592,120 @@ async function readFlowMember(anchorDir, target, roots, budget, opts) {
|
|
|
9488
9592
|
if (!/\.ya?ml$/i.test(path10.basename(canonical))) {
|
|
9489
9593
|
return refuse(`${target} links to a file that is not a YAML file`);
|
|
9490
9594
|
}
|
|
9491
|
-
const
|
|
9595
|
+
const sent = await sendBytes(member, canonical, budget, opts);
|
|
9596
|
+
return { ...sent, text: sent.bytes?.toString("utf8") };
|
|
9597
|
+
}
|
|
9598
|
+
async function readToolMember(file, roots, budget, opts) {
|
|
9599
|
+
const member = { role: "tool", key: file, path: file };
|
|
9600
|
+
const refuse = (reason) => ({
|
|
9601
|
+
member: { ...member, state: "refused", error: reason },
|
|
9602
|
+
sent: `refused (${reason})`
|
|
9603
|
+
});
|
|
9604
|
+
const { canonical } = await landing(file);
|
|
9605
|
+
if (!roots.some((root) => isWithin(canonical, root))) {
|
|
9606
|
+
return refuse(`${file} is outside every root this client serves (${roots.join(", ")})`);
|
|
9607
|
+
}
|
|
9608
|
+
if (!hasToolFileExtension(canonical)) {
|
|
9609
|
+
return refuse(`${file} links to a file that is not one of ${TOOL_FILE_EXTENSIONS.join(", ")}`);
|
|
9610
|
+
}
|
|
9611
|
+
const st = await stat3(canonical).catch((err) => err);
|
|
9612
|
+
if (st instanceof Error) {
|
|
9613
|
+
if (st.code === "ENOENT" || st.code === "ENOTDIR") {
|
|
9614
|
+
return { member: { ...member, state: "missing" }, sent: "missing" };
|
|
9615
|
+
}
|
|
9616
|
+
return refuse(st.message);
|
|
9617
|
+
}
|
|
9618
|
+
if (st.isDirectory()) return refuse("EISDIR: illegal operation on a directory, read");
|
|
9619
|
+
return sendBytes(member, canonical, budget, opts);
|
|
9620
|
+
}
|
|
9621
|
+
function callPlatform(args) {
|
|
9622
|
+
if (typeof args.device === "string" && args.device.startsWith("chromium-cdp-")) return "chromium";
|
|
9623
|
+
if (typeof args.platform !== "string") return void 0;
|
|
9624
|
+
return args.platform === "ios-remote" ? "ios" : args.platform;
|
|
9625
|
+
}
|
|
9626
|
+
async function baselineEntry(file, roots, forWrite) {
|
|
9627
|
+
const { canonical, error } = await landing(file);
|
|
9628
|
+
if (!roots.some((root) => isWithin(canonical, root))) {
|
|
9629
|
+
return {
|
|
9630
|
+
state: "refused",
|
|
9631
|
+
error: `${file} is outside every root this client serves (${roots.join(", ")})`
|
|
9632
|
+
};
|
|
9633
|
+
}
|
|
9634
|
+
if (error !== void 0) return { state: "refused", error };
|
|
9635
|
+
const st = await stat3(canonical).catch((err) => err);
|
|
9636
|
+
if (st instanceof Error) {
|
|
9637
|
+
if (st.code !== "ENOENT") return { state: "refused", error: st.message };
|
|
9638
|
+
return forWrite ? { state: "refused", error: `${file} is a symbolic link to a missing file` } : { state: "missing" };
|
|
9639
|
+
}
|
|
9640
|
+
if (!canonical.endsWith(".png")) {
|
|
9641
|
+
return { state: "refused", error: `${file} links to a file that is not a PNG file` };
|
|
9642
|
+
}
|
|
9643
|
+
if (forWrite && !st.isFile()) return { state: "refused", error: `${file} is not a regular file` };
|
|
9644
|
+
if (st.isDirectory()) {
|
|
9645
|
+
return { state: "refused", error: "EISDIR: illegal operation on a directory, read" };
|
|
9646
|
+
}
|
|
9647
|
+
return st.isFile() ? { state: "ok", real: canonical } : { state: "missing" };
|
|
9648
|
+
}
|
|
9649
|
+
async function sendBytes(member, real, budget, opts) {
|
|
9650
|
+
const read = await readFileInputWire(real, { includeContent: true });
|
|
9492
9651
|
if (read?.contentOmitted) {
|
|
9493
|
-
|
|
9652
|
+
const error = `${real} is larger than the 32 MiB cap on a file sent to the tool-server`;
|
|
9653
|
+
return { member: { ...member, state: "refused", error }, sent: `refused (${error})` };
|
|
9494
9654
|
}
|
|
9495
9655
|
if (read?.content === void 0) {
|
|
9496
|
-
|
|
9497
|
-
|
|
9498
|
-
|
|
9499
|
-
(err) => err instanceof Error ? err.message : String(err)
|
|
9500
|
-
)
|
|
9656
|
+
const error = await readFile4(real).then(
|
|
9657
|
+
() => `${real} could not be read on this client`,
|
|
9658
|
+
(err) => err instanceof Error ? err.message : String(err)
|
|
9501
9659
|
);
|
|
9660
|
+
return { member: { ...member, state: "refused", error }, sent: `refused (${error})` };
|
|
9502
9661
|
}
|
|
9503
|
-
const
|
|
9662
|
+
const bytes = Buffer.from(read.content, "base64");
|
|
9504
9663
|
const size = read.size ?? 0;
|
|
9505
9664
|
if (budget.inline + size <= INLINE_MEMBERS_BYTES || !opts.uploadEndpoint) {
|
|
9506
9665
|
budget.inline += size;
|
|
9507
|
-
return { member: { ...member, ...read },
|
|
9666
|
+
return { member: { ...member, ...read }, sent: `inline ${size}`, bytes };
|
|
9508
9667
|
}
|
|
9509
|
-
const uploaded = await uploadFile(
|
|
9668
|
+
const uploaded = await uploadFile(real, opts.uploadEndpoint, opts.signal);
|
|
9510
9669
|
return {
|
|
9511
9670
|
member: { ...member, size: read.size, mtimeMs: read.mtimeMs, ...uploaded },
|
|
9512
|
-
|
|
9513
|
-
|
|
9671
|
+
sent: `upload ${size}`,
|
|
9672
|
+
bytes
|
|
9514
9673
|
};
|
|
9515
9674
|
}
|
|
9675
|
+
async function collectBaselineMembers(canonical, flowName, snapshots, args, roots, budget, opts, sent, emit) {
|
|
9676
|
+
const dir = path10.join(
|
|
9677
|
+
path10.dirname(canonical),
|
|
9678
|
+
"__baselines__",
|
|
9679
|
+
baselineKeyFor(canonical, flowName)
|
|
9680
|
+
);
|
|
9681
|
+
const real = (await landing(dir)).canonical;
|
|
9682
|
+
if (!roots.some((root) => isWithin(real, root))) return;
|
|
9683
|
+
const updates = args.updateBaselines === true;
|
|
9684
|
+
if (updates) opts.baselineDirs?.push(dir);
|
|
9685
|
+
const platform = callPlatform(args);
|
|
9686
|
+
const prefixes = snapshots.map(
|
|
9687
|
+
(name) => `${name}__${platform === void 0 ? "" : `${platform}-`}`
|
|
9688
|
+
);
|
|
9689
|
+
const names = await readdir4(dir).catch(() => []);
|
|
9690
|
+
for (const name of names.sort()) {
|
|
9691
|
+
if (!name.endsWith(".png")) continue;
|
|
9692
|
+
if (!updates && !prefixes.some((prefix) => name.startsWith(prefix))) continue;
|
|
9693
|
+
const file = path10.join(dir, name);
|
|
9694
|
+
if (sent.has(file)) continue;
|
|
9695
|
+
const member = { role: "baseline", key: file, path: file };
|
|
9696
|
+
const entry = await baselineEntry(file, roots, updates);
|
|
9697
|
+
if (entry.state === "refused") {
|
|
9698
|
+
emit({ ...member, state: "refused", error: entry.error }, `refused (${entry.error})`);
|
|
9699
|
+
} else if (entry.state === "missing") {
|
|
9700
|
+
emit({ ...member, state: "missing" }, "missing");
|
|
9701
|
+
} else if (updates) {
|
|
9702
|
+
emit({ ...member, state: "listed" }, "listed");
|
|
9703
|
+
} else {
|
|
9704
|
+
const sent2 = await sendBytes(member, entry.real, budget, opts);
|
|
9705
|
+
emit(sent2.member, sent2.sent);
|
|
9706
|
+
}
|
|
9707
|
+
}
|
|
9708
|
+
}
|
|
9516
9709
|
async function collectFlowMembers(rootPath, rootBytes, args, opts) {
|
|
9517
9710
|
if (!namesValidFlow(args)) return {};
|
|
9518
9711
|
const canonical = await canonicalFlowPath(rootPath);
|
|
@@ -9524,10 +9717,16 @@ async function collectFlowMembers(rootPath, rootBytes, args, opts) {
|
|
|
9524
9717
|
const roots = await closureRoots(rootPath, canonical, args.project_root);
|
|
9525
9718
|
const members = [];
|
|
9526
9719
|
const seen = /* @__PURE__ */ new Set();
|
|
9720
|
+
const snapshots = /* @__PURE__ */ new Set();
|
|
9527
9721
|
const budget = { inline: 0 };
|
|
9528
9722
|
const logging = process.env[FLOW_FILES_LOG_ENV] === "1";
|
|
9529
9723
|
const log = opts.log ?? ((line) => void process.stderr.write(`${line}
|
|
9530
9724
|
`));
|
|
9725
|
+
const emit = (member, sent) => {
|
|
9726
|
+
members.push(member);
|
|
9727
|
+
const subject = member.role === "flow" ? member.canonical : member.key;
|
|
9728
|
+
if (logging) log(printable(`[flow-files] ${member.role} ${subject}: ${sent}`));
|
|
9729
|
+
};
|
|
9531
9730
|
const queue = [{ canonical, text: rootBytes.toString("utf8"), hop: 0 }];
|
|
9532
9731
|
for (let file = queue.shift(); file !== void 0; file = queue.shift()) {
|
|
9533
9732
|
let doc;
|
|
@@ -9536,19 +9735,45 @@ async function collectFlowMembers(rootPath, rootBytes, args, opts) {
|
|
|
9536
9735
|
} catch {
|
|
9537
9736
|
continue;
|
|
9538
9737
|
}
|
|
9738
|
+
const requests = collectFlowRequests(doc);
|
|
9739
|
+
for (const name of requests.snapshots) snapshots.add(name);
|
|
9740
|
+
for (const step of requests.toolSteps) {
|
|
9741
|
+
if (step.tool === "flow-execute") continue;
|
|
9742
|
+
for (const file2 of toolStepFiles(opts.toolFileInputs?.(step.tool), step.args)) {
|
|
9743
|
+
const { unwrapWhenSet } = file2.spec;
|
|
9744
|
+
if (unwrapWhenSet !== void 0 && step.args[unwrapWhenSet] !== void 0) continue;
|
|
9745
|
+
if (!isClientFileArgument(file2) || seen.has(file2.path)) continue;
|
|
9746
|
+
seen.add(file2.path);
|
|
9747
|
+
const read = await readToolMember(file2.path, roots, budget, opts);
|
|
9748
|
+
emit(read.member, read.sent);
|
|
9749
|
+
}
|
|
9750
|
+
}
|
|
9539
9751
|
const anchorDir = path10.dirname(file.canonical);
|
|
9540
|
-
for (const target of
|
|
9752
|
+
for (const target of requests.runTargets) {
|
|
9541
9753
|
const key = flowMemberKey(anchorDir, target);
|
|
9542
9754
|
if (seen.has(key)) continue;
|
|
9543
9755
|
seen.add(key);
|
|
9544
9756
|
const { member, text, sent } = await readFlowMember(anchorDir, target, roots, budget, opts);
|
|
9545
|
-
|
|
9546
|
-
if (logging) log(printable(`[flow-files] flow ${member.canonical}: ${sent}`));
|
|
9757
|
+
emit(member, sent);
|
|
9547
9758
|
if (text !== void 0 && file.hop + 1 < MAX_RUN_DEPTH) {
|
|
9548
9759
|
queue.push({ canonical: member.canonical, text, hop: file.hop + 1 });
|
|
9549
9760
|
}
|
|
9550
9761
|
}
|
|
9551
9762
|
}
|
|
9763
|
+
if (snapshots.size > 0) {
|
|
9764
|
+
const flowName = path10.basename(rootPath, ".yaml");
|
|
9765
|
+
await collectBaselineMembers(
|
|
9766
|
+
canonical,
|
|
9767
|
+
flowName,
|
|
9768
|
+
[...snapshots],
|
|
9769
|
+
args,
|
|
9770
|
+
roots,
|
|
9771
|
+
budget,
|
|
9772
|
+
opts,
|
|
9773
|
+
seen,
|
|
9774
|
+
emit
|
|
9775
|
+
);
|
|
9776
|
+
}
|
|
9552
9777
|
return { canonical, spelling, members };
|
|
9553
9778
|
}
|
|
9554
9779
|
|
|
@@ -9583,7 +9808,20 @@ async function consumeToolStream(name, body, onProgress, signal) {
|
|
|
9583
9808
|
}
|
|
9584
9809
|
};
|
|
9585
9810
|
const decoder = new TextDecoder();
|
|
9586
|
-
let
|
|
9811
|
+
let pieces = [];
|
|
9812
|
+
const take = (text) => {
|
|
9813
|
+
let start = 0;
|
|
9814
|
+
let newline;
|
|
9815
|
+
while ((newline = text.indexOf("\n", start)) !== -1) {
|
|
9816
|
+
signal?.throwIfAborted();
|
|
9817
|
+
pieces.push(text.slice(start, newline));
|
|
9818
|
+
const line = pieces.join("");
|
|
9819
|
+
pieces = [];
|
|
9820
|
+
start = newline + 1;
|
|
9821
|
+
handleLine(line);
|
|
9822
|
+
}
|
|
9823
|
+
if (start < text.length) pieces.push(text.slice(start));
|
|
9824
|
+
};
|
|
9587
9825
|
try {
|
|
9588
9826
|
for (; ; ) {
|
|
9589
9827
|
let chunk;
|
|
@@ -9595,17 +9833,11 @@ async function consumeToolStream(name, body, onProgress, signal) {
|
|
|
9595
9833
|
}
|
|
9596
9834
|
const { done, value } = chunk;
|
|
9597
9835
|
if (done) break;
|
|
9598
|
-
|
|
9599
|
-
let newline;
|
|
9600
|
-
while ((newline = buffered.indexOf("\n")) !== -1) {
|
|
9601
|
-
signal?.throwIfAborted();
|
|
9602
|
-
const line = buffered.slice(0, newline);
|
|
9603
|
-
buffered = buffered.slice(newline + 1);
|
|
9604
|
-
handleLine(line);
|
|
9605
|
-
}
|
|
9836
|
+
take(decoder.decode(value, { stream: true }));
|
|
9606
9837
|
}
|
|
9607
|
-
|
|
9608
|
-
|
|
9838
|
+
take(decoder.decode());
|
|
9839
|
+
const last = pieces.join("");
|
|
9840
|
+
if (last.trim()) handleLine(last);
|
|
9609
9841
|
} catch (err) {
|
|
9610
9842
|
void reader.cancel().catch(() => {
|
|
9611
9843
|
});
|
|
@@ -9615,8 +9847,7 @@ async function consumeToolStream(name, body, onProgress, signal) {
|
|
|
9615
9847
|
if (!final) {
|
|
9616
9848
|
throw brokenStream(name, "the stream ended without a result", progress);
|
|
9617
9849
|
}
|
|
9618
|
-
|
|
9619
|
-
return { data, note: final.note };
|
|
9850
|
+
return { data: final.data, note: final.note };
|
|
9620
9851
|
}
|
|
9621
9852
|
function errorBodyMessage(body) {
|
|
9622
9853
|
if (Array.isArray(body.issues) && typeof body.message === "string") return body.message;
|
|
@@ -9704,17 +9935,31 @@ function createToolsClient(options = {}) {
|
|
|
9704
9935
|
opts?.signal?.throwIfAborted();
|
|
9705
9936
|
const { url, token, remote } = await route();
|
|
9706
9937
|
let finalArgs = args;
|
|
9707
|
-
const
|
|
9938
|
+
const tools = await fetchTools({ signal: opts?.signal });
|
|
9939
|
+
const meta = tools.find((t) => t.name === name) ?? null;
|
|
9940
|
+
const baselineDirs = [];
|
|
9708
9941
|
if (meta?.fileInputs?.length) {
|
|
9709
9942
|
if (remote) assertRequiredPresent(meta, args);
|
|
9710
9943
|
finalArgs = await prepareFileInputs(meta.fileInputs, args ?? {}, {
|
|
9711
9944
|
includeContent: remote,
|
|
9712
9945
|
uploadEndpoint: remote ? { url, token } : void 0,
|
|
9713
9946
|
log: diagnose,
|
|
9947
|
+
baselineDirs,
|
|
9714
9948
|
collectMembers: collectFlowMembers,
|
|
9949
|
+
toolFileInputs: (tool) => tools.find((t) => t.name === tool)?.fileInputs,
|
|
9715
9950
|
signal: opts?.signal
|
|
9716
9951
|
});
|
|
9717
9952
|
}
|
|
9953
|
+
const settle = async (data) => {
|
|
9954
|
+
const applied = await applyClientFileDirectives(data, { allowedDirs: baselineDirs });
|
|
9955
|
+
for (const { path: file, error } of applied.failed) {
|
|
9956
|
+
diagnose(`The baseline ${file} was not written on this client: ${error}`);
|
|
9957
|
+
}
|
|
9958
|
+
if (process.env.ARGENT_FLOW_FILES_LOG === "1") {
|
|
9959
|
+
for (const file of applied.written) diagnose(`[flow-files] baseline ${file}: written`);
|
|
9960
|
+
}
|
|
9961
|
+
return applied.result;
|
|
9962
|
+
};
|
|
9718
9963
|
const stream = opts?.onProgress !== void 0 || carriesMembers(finalArgs);
|
|
9719
9964
|
const sentOnce = carriesUpload(finalArgs);
|
|
9720
9965
|
const res = await doFetch(
|
|
@@ -9746,7 +9991,11 @@ function createToolsClient(options = {}) {
|
|
|
9746
9991
|
}),
|
|
9747
9992
|
opts?.signal
|
|
9748
9993
|
);
|
|
9749
|
-
return {
|
|
9994
|
+
return {
|
|
9995
|
+
data: await settle(streamed.data),
|
|
9996
|
+
note: streamed.note,
|
|
9997
|
+
outputHint: meta?.outputHint
|
|
9998
|
+
};
|
|
9750
9999
|
}
|
|
9751
10000
|
let json;
|
|
9752
10001
|
try {
|
|
@@ -9770,17 +10019,16 @@ function createToolsClient(options = {}) {
|
|
|
9770
10019
|
});
|
|
9771
10020
|
}
|
|
9772
10021
|
opts?.signal?.throwIfAborted();
|
|
9773
|
-
|
|
9774
|
-
return { data, note: json.note, outputHint: meta?.outputHint };
|
|
10022
|
+
return { data: await settle(json.data), note: json.note, outputHint: meta?.outputHint };
|
|
9775
10023
|
}
|
|
9776
10024
|
return { fetchTools, fetchTool, callTool, baseUrl };
|
|
9777
10025
|
}
|
|
9778
10026
|
|
|
9779
10027
|
// ../argent-tools-client/src/artifacts.ts
|
|
9780
|
-
import { copyFile, mkdir as mkdir4, readFile as readFile5, realpath as
|
|
10028
|
+
import { copyFile, mkdir as mkdir4, readFile as readFile5, realpath as realpath4, rm as rm3, stat as stat4, writeFile as writeFile4 } from "node:fs/promises";
|
|
9781
10029
|
import { constants as fsConstants } from "node:fs";
|
|
9782
10030
|
import { tmpdir as tmpdir2 } from "node:os";
|
|
9783
|
-
import { basename as basename6, dirname as dirname7, extname as extname2, isAbsolute as isAbsolute5, join as join11, normalize, resolve as resolve6, sep as sep4 } from "node:path";
|
|
10031
|
+
import { basename as basename6, dirname as dirname7, extname as extname2, isAbsolute as isAbsolute5, join as join11, normalize as normalize2, resolve as resolve6, sep as sep4 } from "node:path";
|
|
9784
10032
|
import { createHash as createHash3 } from "node:crypto";
|
|
9785
10033
|
var ARTIFACT_MARKER2 = "__argentArtifact";
|
|
9786
10034
|
function isArtifactHandle(value) {
|
|
@@ -9815,8 +10063,8 @@ function durableBaseDir() {
|
|
|
9815
10063
|
const projectRoot = findProjectRoot(process.cwd());
|
|
9816
10064
|
return projectRoot ?? dirname7(argentHomeDir());
|
|
9817
10065
|
}
|
|
9818
|
-
var ALLOWED_SAVE_DIRS = /* @__PURE__ */ new Set([
|
|
9819
|
-
var RECORDINGS_SAVE_DIR =
|
|
10066
|
+
var ALLOWED_SAVE_DIRS = /* @__PURE__ */ new Set([normalize2(".argent/recordings")]);
|
|
10067
|
+
var RECORDINGS_SAVE_DIR = normalize2(".argent/recordings");
|
|
9820
10068
|
function configuredRecordingsDir() {
|
|
9821
10069
|
let value;
|
|
9822
10070
|
try {
|
|
@@ -9875,7 +10123,7 @@ async function writeDurableUnique(dir, filename, write) {
|
|
|
9875
10123
|
}
|
|
9876
10124
|
function durableSaveTarget(handle) {
|
|
9877
10125
|
if (typeof handle.saveDir !== "string" || !handle.saveDir || handle.archive) return null;
|
|
9878
|
-
const rel =
|
|
10126
|
+
const rel = normalize2(handle.saveDir);
|
|
9879
10127
|
if (isAbsolute5(rel) || rel === ".." || rel.startsWith(`..${sep4}`) || rel.split(sep4).includes("..")) {
|
|
9880
10128
|
return null;
|
|
9881
10129
|
}
|
|
@@ -9897,8 +10145,8 @@ function durableSaveTarget(handle) {
|
|
|
9897
10145
|
}
|
|
9898
10146
|
async function confineToRealBase(dir, base, rel) {
|
|
9899
10147
|
try {
|
|
9900
|
-
const realDir = await
|
|
9901
|
-
const realBase = await
|
|
10148
|
+
const realDir = await realpath4(dir);
|
|
10149
|
+
const realBase = await realpath4(base);
|
|
9902
10150
|
return realDir === join11(realBase, rel);
|
|
9903
10151
|
} catch {
|
|
9904
10152
|
return false;
|
package/dist/installer.mjs
CHANGED
|
@@ -16736,7 +16736,7 @@ var _CI_VENDOR_COUNT_FOR_TEST = vendors_default.length;
|
|
|
16736
16736
|
var SESSION_ID = randomUUID4();
|
|
16737
16737
|
function readCliVersion() {
|
|
16738
16738
|
if (true) {
|
|
16739
|
-
return "0.27.1-next.
|
|
16739
|
+
return "0.27.1-next.22";
|
|
16740
16740
|
}
|
|
16741
16741
|
return "0.0.0";
|
|
16742
16742
|
}
|
|
@@ -23323,7 +23323,17 @@ var LINK_FILE = path20.join(LINK_DIR, "link.json");
|
|
|
23323
23323
|
// ../argent-tools-client/src/file-inputs.ts
|
|
23324
23324
|
import { createHash as createHash3, randomUUID as randomUUID6 } from "node:crypto";
|
|
23325
23325
|
import { createReadStream, rmSync as rmSync6 } from "node:fs";
|
|
23326
|
-
import {
|
|
23326
|
+
import {
|
|
23327
|
+
chmod as chmod3,
|
|
23328
|
+
lstat,
|
|
23329
|
+
mkdir as mkdir3,
|
|
23330
|
+
readFile as readFile3,
|
|
23331
|
+
realpath as realpath2,
|
|
23332
|
+
rename as rename2,
|
|
23333
|
+
rm as rm2,
|
|
23334
|
+
stat as stat2,
|
|
23335
|
+
writeFile as writeFile3
|
|
23336
|
+
} from "node:fs/promises";
|
|
23327
23337
|
import { constants, tmpdir } from "node:os";
|
|
23328
23338
|
import * as path21 from "node:path";
|
|
23329
23339
|
|
|
@@ -23339,18 +23349,18 @@ var MAX_CONTENT_BYTES = 32 * 1024 * 1024;
|
|
|
23339
23349
|
|
|
23340
23350
|
// ../argent-tools-client/src/flow-files.ts
|
|
23341
23351
|
var import_yaml3 = __toESM(require_dist(), 1);
|
|
23342
|
-
import { readFile as readFile4, realpath as
|
|
23352
|
+
import { readdir as readdir4, readFile as readFile4, realpath as realpath3, stat as stat3 } from "node:fs/promises";
|
|
23343
23353
|
import * as path22 from "node:path";
|
|
23344
23354
|
var INLINE_MEMBERS_BYTES = 256 * 1024;
|
|
23345
23355
|
|
|
23346
23356
|
// ../argent-tools-client/src/artifacts.ts
|
|
23347
|
-
import { copyFile, mkdir as mkdir4, readFile as readFile5, realpath as
|
|
23357
|
+
import { copyFile, mkdir as mkdir4, readFile as readFile5, realpath as realpath4, rm as rm3, stat as stat4, writeFile as writeFile4 } from "node:fs/promises";
|
|
23348
23358
|
import { constants as fsConstants } from "node:fs";
|
|
23349
23359
|
import { tmpdir as tmpdir2 } from "node:os";
|
|
23350
|
-
import { basename as basename6, dirname as dirname15, extname as extname2, isAbsolute as isAbsolute7, join as join23, normalize, resolve as resolve13, sep as sep6 } from "node:path";
|
|
23360
|
+
import { basename as basename6, dirname as dirname15, extname as extname2, isAbsolute as isAbsolute7, join as join23, normalize as normalize2, resolve as resolve13, sep as sep6 } from "node:path";
|
|
23351
23361
|
import { createHash as createHash4 } from "node:crypto";
|
|
23352
|
-
var ALLOWED_SAVE_DIRS = /* @__PURE__ */ new Set([
|
|
23353
|
-
var RECORDINGS_SAVE_DIR =
|
|
23362
|
+
var ALLOWED_SAVE_DIRS = /* @__PURE__ */ new Set([normalize2(".argent/recordings")]);
|
|
23363
|
+
var RECORDINGS_SAVE_DIR = normalize2(".argent/recordings");
|
|
23354
23364
|
var MAX_DURABLE_BYTES = 2 * 1024 * 1024 * 1024;
|
|
23355
23365
|
|
|
23356
23366
|
// ../argent-installer/src/update.ts
|