@swmansion/argent 0.36.0 → 0.36.1-next.1

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.
@@ -1435,11 +1435,12 @@ function isValidSession(session) {
1435
1435
  function isLiveServiceState(state3) {
1436
1436
  return state3 === "RUNNING" /* RUNNING */ || state3 === "STARTING" /* STARTING */;
1437
1437
  }
1438
- var LINKED_CALL_HEADER, E2E_DIR_CLIENT_HEADER, CLIENT_SECRETS_HEADER, SESSION_HEADER, CLIENT_SECRET_SOURCES_HEADER;
1438
+ var LINKED_CALL_HEADER, CALLER_DEADLINE_HEADER, E2E_DIR_CLIENT_HEADER, CLIENT_SECRETS_HEADER, SESSION_HEADER, CLIENT_SECRET_SOURCES_HEADER;
1439
1439
  var init_types = __esm({
1440
1440
  "../registry/src/types.ts"() {
1441
1441
  "use strict";
1442
1442
  LINKED_CALL_HEADER = "x-argent-linked";
1443
+ CALLER_DEADLINE_HEADER = "x-argent-deadline-ms";
1443
1444
  E2E_DIR_CLIENT_HEADER = "x-argent-e2e-dir";
1444
1445
  CLIENT_SECRETS_HEADER = "x-argent-client-secrets";
1445
1446
  SESSION_HEADER = "x-argent-session";
@@ -1828,6 +1829,8 @@ var init_failure_codes = __esm({
1828
1829
  REGISTRY_TOOL_EXECUTION_FAILED: "REGISTRY_TOOL_EXECUTION_FAILED",
1829
1830
  REGISTRY_TOOL_FAILURE_UNCLASSIFIED: "REGISTRY_TOOL_FAILURE_UNCLASSIFIED",
1830
1831
  REGISTRY_SERVICE_TERMINATING: "REGISTRY_SERVICE_TERMINATING",
1832
+ REGISTRY_TOOL_CALL_CANCELLED: "REGISTRY_TOOL_CALL_CANCELLED",
1833
+ REGISTRY_TOOL_CALL_TIMED_OUT: "REGISTRY_TOOL_CALL_TIMED_OUT",
1831
1834
  HTTP_TOOL_NOT_FOUND: "HTTP_TOOL_NOT_FOUND",
1832
1835
  HTTP_ZOD_VALIDATION_FAILED: "HTTP_ZOD_VALIDATION_FAILED",
1833
1836
  HTTP_CAPABILITY_UNSUPPORTED_OPERATION: "HTTP_CAPABILITY_UNSUPPORTED_OPERATION",
@@ -2034,7 +2037,6 @@ var init_failure_codes = __esm({
2034
2037
  DEBUGGER_RELOAD_FAILED: "DEBUGGER_RELOAD_FAILED",
2035
2038
  // e2e-add-step refused a debugger-* call that answered `not_connected`.
2036
2039
  DEBUGGER_NOT_CONNECTED: "DEBUGGER_NOT_CONNECTED",
2037
- JS_RUNTIME_CONSOLE_SERVER_BIND_FAILED: "JS_RUNTIME_CONSOLE_SERVER_BIND_FAILED",
2038
2040
  JS_RUNTIME_PAYLOAD_INVALID: "JS_RUNTIME_PAYLOAD_INVALID",
2039
2041
  JS_RUNTIME_PAYLOAD_DEVICE_MISSING: "JS_RUNTIME_PAYLOAD_DEVICE_MISSING",
2040
2042
  JS_RUNTIME_PAYLOAD_PORT_INVALID: "JS_RUNTIME_PAYLOAD_PORT_INVALID",
@@ -2312,6 +2314,17 @@ function wrapFailure(error63, fallback, message) {
2312
2314
  cause
2313
2315
  });
2314
2316
  }
2317
+ function callerDeadlineReason() {
2318
+ const reason2 = new DOMException(
2319
+ "This operation was aborted at the caller's deadline",
2320
+ "AbortError"
2321
+ );
2322
+ Object.defineProperty(reason2, CALLER_DEADLINE, { value: true });
2323
+ return reason2;
2324
+ }
2325
+ function isCallerDeadlineReason(reason2) {
2326
+ return reason2 instanceof DOMException && CALLER_DEADLINE in reason2;
2327
+ }
2315
2328
  function subprocessFailureMetadata(error63, failure_command) {
2316
2329
  const metadata = { failure_command };
2317
2330
  const err = error63;
@@ -2330,7 +2343,7 @@ function subprocessFailureMetadata(error63, failure_command) {
2330
2343
  }
2331
2344
  return metadata;
2332
2345
  }
2333
- var FAILURE_AREAS, FAILURE_KINDS, FAILURE_COMMANDS, FAILURE_SIGNAL_NAMES, FAILURE_SPAWN_CODES, NETWORK_FAILURES, FAILURE_SIGNAL, FALLBACK_SIGNAL, FailureError, FAILURE_SIGNAL_NAME_SET, FAILURE_SPAWN_CODE_SET, ServiceNotFoundError, ServiceInitializationError, ToolNotFoundError, ToolExecutionError;
2346
+ var FAILURE_AREAS, FAILURE_KINDS, FAILURE_COMMANDS, FAILURE_SIGNAL_NAMES, FAILURE_SPAWN_CODES, NETWORK_FAILURES, FAILURE_SIGNAL, FALLBACK_SIGNAL, FailureError, CALLER_DEADLINE, FAILURE_SIGNAL_NAME_SET, FAILURE_SPAWN_CODE_SET, ServiceNotFoundError, ServiceInitializationError, ToolNotFoundError, ToolExecutionError;
2334
2347
  var init_errors = __esm({
2335
2348
  "../registry/src/errors.ts"() {
2336
2349
  "use strict";
@@ -2346,6 +2359,7 @@ var init_errors = __esm({
2346
2359
  "network",
2347
2360
  "subprocess",
2348
2361
  "crash",
2362
+ "cancelled",
2349
2363
  "unknown"
2350
2364
  ];
2351
2365
  FAILURE_COMMANDS = [
@@ -2408,6 +2422,7 @@ var init_errors = __esm({
2408
2422
  withFailureSignal(this, signal);
2409
2423
  }
2410
2424
  };
2425
+ CALLER_DEADLINE = /* @__PURE__ */ Symbol.for("argent.caller_deadline");
2411
2426
  FAILURE_SIGNAL_NAME_SET = new Set(FAILURE_SIGNAL_NAMES);
2412
2427
  FAILURE_SPAWN_CODE_SET = new Set(FAILURE_SPAWN_CODES);
2413
2428
  ServiceNotFoundError = class extends Error {
@@ -22898,6 +22913,14 @@ var init_zod_to_json_schema = __esm({
22898
22913
  });
22899
22914
 
22900
22915
  // ../registry/src/registry.ts
22916
+ function hasCause(error63, cause) {
22917
+ let current = error63;
22918
+ for (let depth = 0; current instanceof Error && depth < 16; depth++) {
22919
+ if (current === cause) return true;
22920
+ current = current.cause;
22921
+ }
22922
+ return false;
22923
+ }
22901
22924
  function terminatingSignalCause(message) {
22902
22925
  return new FailureError(message, {
22903
22926
  error_code: FAILURE_CODES.REGISTRY_SERVICE_TERMINATING,
@@ -22975,7 +22998,7 @@ function formatInteractionMessage(format, fallback) {
22975
22998
  return fallback;
22976
22999
  }
22977
23000
  }
22978
- var import_node_crypto3, import_node_async_hooks, resolvedDuringInvocation, Registry, MAX_UNION_ALTERNATIVES;
23001
+ var import_node_crypto3, import_node_async_hooks, resolvedDuringInvocation, Registry, CANCELLED_SIGNAL, TIMED_OUT_SIGNAL, MAX_UNION_ALTERNATIVES;
22979
23002
  var init_registry = __esm({
22980
23003
  "../registry/src/registry.ts"() {
22981
23004
  "use strict";
@@ -23144,6 +23167,14 @@ var init_registry = __esm({
23144
23167
  }) : new ToolExecutionError(toolId, originalMsg, {
23145
23168
  cause: error63 instanceof Error ? error63 : new Error(String(error63))
23146
23169
  });
23170
+ const signal = options?.signal;
23171
+ if (signal?.aborted && (error63 instanceof Error && error63.name === "AbortError" || hasCause(error63, signal.reason))) {
23172
+ if (!isCallerDeadlineReason(signal.reason)) {
23173
+ withFailureSignal(wrappedError, CANCELLED_SIGNAL);
23174
+ } else if (!getFailureSignal(error63)) {
23175
+ withFailureSignal(wrappedError, TIMED_OUT_SIGNAL);
23176
+ }
23177
+ }
23147
23178
  const failureSignal2 = getFailureSignalOrFallback(wrappedError);
23148
23179
  const failedMsg = formatInteractionMessage(
23149
23180
  () => definition.interaction?.failedMsg?.({
@@ -23369,6 +23400,18 @@ var init_registry = __esm({
23369
23400
  this._transition(node2, cause ? "ERROR" /* ERROR */ : "IDLE" /* IDLE */, cause);
23370
23401
  }
23371
23402
  };
23403
+ CANCELLED_SIGNAL = {
23404
+ error_code: FAILURE_CODES.REGISTRY_TOOL_CALL_CANCELLED,
23405
+ failure_stage: "registry_tool_cancelled",
23406
+ failure_area: "registry",
23407
+ error_kind: "cancelled"
23408
+ };
23409
+ TIMED_OUT_SIGNAL = {
23410
+ error_code: FAILURE_CODES.REGISTRY_TOOL_CALL_TIMED_OUT,
23411
+ failure_stage: "registry_tool_timed_out",
23412
+ failure_area: "registry",
23413
+ error_kind: "timeout"
23414
+ };
23372
23415
  MAX_UNION_ALTERNATIVES = 12;
23373
23416
  }
23374
23417
  });
@@ -45884,7 +45927,7 @@ var require_application = __commonJS({
45884
45927
  var finalhandler = require_finalhandler();
45885
45928
  var debug = require_src()("express:application");
45886
45929
  var View = require_view();
45887
- var http8 = require("node:http");
45930
+ var http6 = require("node:http");
45888
45931
  var methods = require_utils3().methods;
45889
45932
  var compileETag = require_utils3().compileETag;
45890
45933
  var compileQueryParser = require_utils3().compileQueryParser;
@@ -46117,7 +46160,7 @@ var require_application = __commonJS({
46117
46160
  tryRender(view, renderOptions, done);
46118
46161
  };
46119
46162
  app.listen = function listen4() {
46120
- var server = http8.createServer(this);
46163
+ var server = http6.createServer(this);
46121
46164
  var args = slice.call(arguments);
46122
46165
  if (typeof args[args.length - 1] === "function") {
46123
46166
  var done = args[args.length - 1] = once5(args[args.length - 1]);
@@ -46892,12 +46935,12 @@ var require_request = __commonJS({
46892
46935
  var accepts = require_accepts();
46893
46936
  var isIP = require("node:net").isIP;
46894
46937
  var typeis = require_type_is();
46895
- var http8 = require("node:http");
46938
+ var http6 = require("node:http");
46896
46939
  var fresh = require_fresh();
46897
46940
  var parseRange = require_range_parser();
46898
46941
  var parse5 = require_parseurl();
46899
46942
  var proxyaddr = require_proxy_addr();
46900
- var req = Object.create(http8.IncomingMessage.prototype);
46943
+ var req = Object.create(http6.IncomingMessage.prototype);
46901
46944
  module2.exports = req;
46902
46945
  req.get = req.header = function header(name) {
46903
46946
  if (!name) {
@@ -48071,7 +48114,7 @@ var require_response = __commonJS({
48071
48114
  var deprecate = require_depd()("express");
48072
48115
  var encodeUrl = require_encodeurl();
48073
48116
  var escapeHtml = require_escape_html();
48074
- var http8 = require("node:http");
48117
+ var http6 = require("node:http");
48075
48118
  var onFinished = require_on_finished();
48076
48119
  var mime = require_mime_types();
48077
48120
  var path78 = require("node:path");
@@ -48088,7 +48131,7 @@ var require_response = __commonJS({
48088
48131
  var basename25 = path78.basename;
48089
48132
  var vary = require_vary();
48090
48133
  var { Buffer: Buffer2 } = require("node:buffer");
48091
- var res = Object.create(http8.ServerResponse.prototype);
48134
+ var res = Object.create(http6.ServerResponse.prototype);
48092
48135
  module2.exports = res;
48093
48136
  res.status = function status(code) {
48094
48137
  if (!Number.isInteger(code)) {
@@ -62427,7 +62470,7 @@ var require_websocket = __commonJS({
62427
62470
  "use strict";
62428
62471
  var EventEmitter2 = require("events");
62429
62472
  var https2 = require("https");
62430
- var http8 = require("http");
62473
+ var http6 = require("http");
62431
62474
  var net14 = require("net");
62432
62475
  var tls = require("tls");
62433
62476
  var { randomBytes: randomBytes6, createHash: createHash13 } = require("crypto");
@@ -62982,7 +63025,7 @@ var require_websocket = __commonJS({
62982
63025
  }
62983
63026
  const defaultPort = isSecure2 ? 443 : 80;
62984
63027
  const key2 = randomBytes6(16).toString("base64");
62985
- const request4 = isSecure2 ? https2.request : http8.request;
63028
+ const request4 = isSecure2 ? https2.request : http6.request;
62986
63029
  const protocolSet = /* @__PURE__ */ new Set();
62987
63030
  let perMessageDeflate;
62988
63031
  opts.createConnection = opts.createConnection || (isSecure2 ? tlsConnect : netConnect);
@@ -63478,7 +63521,7 @@ var require_websocket_server = __commonJS({
63478
63521
  "../../node_modules/ws/lib/websocket-server.js"(exports2, module2) {
63479
63522
  "use strict";
63480
63523
  var EventEmitter2 = require("events");
63481
- var http8 = require("http");
63524
+ var http6 = require("http");
63482
63525
  var { Duplex: Duplex2 } = require("stream");
63483
63526
  var { createHash: createHash13 } = require("crypto");
63484
63527
  var extension2 = require_extension();
@@ -63559,8 +63602,8 @@ var require_websocket_server = __commonJS({
63559
63602
  );
63560
63603
  }
63561
63604
  if (options.port != null) {
63562
- this._server = http8.createServer((req, res) => {
63563
- const body = http8.STATUS_CODES[426];
63605
+ this._server = http6.createServer((req, res) => {
63606
+ const body = http6.STATUS_CODES[426];
63564
63607
  res.writeHead(426, {
63565
63608
  "Content-Length": body.length,
63566
63609
  "Content-Type": "text/plain"
@@ -63849,7 +63892,7 @@ var require_websocket_server = __commonJS({
63849
63892
  this.destroy();
63850
63893
  }
63851
63894
  function abortHandshake(socket, code, message, headers) {
63852
- message = message || http8.STATUS_CODES[code];
63895
+ message = message || http6.STATUS_CODES[code];
63853
63896
  headers = {
63854
63897
  Connection: "close",
63855
63898
  "Content-Type": "text/html",
@@ -63858,7 +63901,7 @@ var require_websocket_server = __commonJS({
63858
63901
  };
63859
63902
  socket.once("finish", socket.destroy);
63860
63903
  socket.end(
63861
- `HTTP/1.1 ${code} ${http8.STATUS_CODES[code]}\r
63904
+ `HTTP/1.1 ${code} ${http6.STATUS_CODES[code]}\r
63862
63905
  ` + Object.keys(headers).map((h) => `${h}: ${headers[h]}`).join("\r\n") + "\r\n\r\n" + message
63863
63906
  );
63864
63907
  }
@@ -73425,7 +73468,7 @@ function isCi(env = process.env) {
73425
73468
  var SESSION_ID = (0, import_node_crypto4.randomUUID)();
73426
73469
  function readCliVersion() {
73427
73470
  if (true) {
73428
- return "0.36.0";
73471
+ return "0.36.1-next.1";
73429
73472
  }
73430
73473
  return "0.0.0";
73431
73474
  }
@@ -78475,7 +78518,7 @@ function describeSelector(s) {
78475
78518
  const { loose: _loose, any: any2, within: within3, after, next, ...rest } = s;
78476
78519
  const scopes = { within: within3, after, next };
78477
78520
  const fields = Object.entries(rest).map(
78478
- ([k, v]) => k === "textMatches" ? `text=/${escapeInline(String(v))}/` : `${k === "identifier" ? "id" : k}=${JSON.stringify(String(v))}`
78521
+ ([k, v]) => k === "textMatches" ? `text=/${escapeInline(String(v))}/` : `${k === "identifier" ? "id" : k}=${escapeInline(JSON.stringify(String(v)))}`
78479
78522
  ).join(" ");
78480
78523
  const parts2 = [any2 ? "*" : void 0, fields || void 0].filter((p) => p !== void 0);
78481
78524
  for (const relation of SELECTOR_RELATIONS) {
@@ -78489,9 +78532,9 @@ function describeTextExpectation(expectedText, textMatch, verbForm = "mode") {
78489
78532
  const mode = textMatch ?? "contains";
78490
78533
  switch (mode) {
78491
78534
  case "contains":
78492
- return `${verbForm === "infinitive" ? "contain" : mode} ${JSON.stringify(expected)}`;
78535
+ return `${verbForm === "infinitive" ? "contain" : mode} ${escapeInline(JSON.stringify(expected))}`;
78493
78536
  case "equals":
78494
- return `${verbForm === "infinitive" ? "equal" : mode} ${JSON.stringify(expected)}`;
78537
+ return `${verbForm === "infinitive" ? "equal" : mode} ${escapeInline(JSON.stringify(expected))}`;
78495
78538
  case "matches":
78496
78539
  return `${verbForm === "infinitive" ? "match" : mode} /${escapeInline(expected)}/`;
78497
78540
  }
@@ -78791,6 +78834,7 @@ function toYamlStep(step) {
78791
78834
  }
78792
78835
  }
78793
78836
  var MAX_ENTRY_RENDER_CHARS = 200;
78837
+ var RENDERED_CHAR = /\\u[0-9a-f]{4}|\\?[\s\S]/gu;
78794
78838
  function renderEntry(raw) {
78795
78839
  let rendered;
78796
78840
  try {
@@ -78798,11 +78842,10 @@ function renderEntry(raw) {
78798
78842
  } catch {
78799
78843
  rendered = "[cyclic entry]";
78800
78844
  }
78801
- if (rendered.length > MAX_ENTRY_RENDER_CHARS) {
78802
- const elided = rendered.length - MAX_ENTRY_RENDER_CHARS;
78803
- rendered = `${rendered.slice(0, MAX_ENTRY_RENDER_CHARS)}\u2026(+${elided} chars)`;
78804
- }
78805
- return rendered;
78845
+ const chars = escapeInline(rendered).match(RENDERED_CHAR) ?? [];
78846
+ if (chars.length <= MAX_ENTRY_RENDER_CHARS) return chars.join("");
78847
+ const elided = chars.length - MAX_ENTRY_RENDER_CHARS;
78848
+ return `${chars.slice(0, MAX_ENTRY_RENDER_CHARS).join("")}\u2026(+${elided} chars)`;
78806
78849
  }
78807
78850
  function entryError(raw, detail) {
78808
78851
  return new FailureError(`Unrecognized e2e test entry (${detail}): ${renderEntry(raw)}`, {
@@ -79712,7 +79755,7 @@ function nameMapProblem(value, example) {
79712
79755
  }
79713
79756
  for (const [name, entry] of Object.entries(value)) {
79714
79757
  if (!VAR_NAME_RE.test(name)) {
79715
- return `has an invalid name ${JSON.stringify(name)}: use letters, digits and _, not starting with a digit`;
79758
+ return `has an invalid name ${escapeInline(JSON.stringify(name))}: use letters, digits and _, not starting with a digit`;
79716
79759
  }
79717
79760
  if (name === "__proto__") return "cannot set __proto__";
79718
79761
  if (typeof entry === "number" || typeof entry === "boolean") {
@@ -79737,7 +79780,7 @@ function scriptEnvProblem(value) {
79737
79780
  if (problem) return problem;
79738
79781
  for (const [name, entry] of Object.entries(value)) {
79739
79782
  const referenceProblem = outputReferenceProblem(entry) ?? varReferenceProblem(entry);
79740
- if (referenceProblem) return `${name} ${referenceProblem}`;
79783
+ if (referenceProblem) return `${name} ${escapeInline(referenceProblem)}`;
79741
79784
  }
79742
79785
  return void 0;
79743
79786
  }
@@ -80063,14 +80106,16 @@ function secretVarProblem(step, vars) {
80063
80106
  function stepReferenceProblem(step) {
80064
80107
  for (const field2 of outputReferenceFields(step)) {
80065
80108
  if (!holdsReferenceMarker(field2.value)) continue;
80066
- const locator = field2.altWhere ? `\`${field2.where}\` (spelled \`${field2.altWhere}\` if the target sits under \`on:\`)` : `\`${field2.where}\``;
80109
+ const locator = escapeInline(
80110
+ field2.altWhere ? `\`${field2.where}\` (spelled \`${field2.altWhere}\` if the target sits under \`on:\`)` : `\`${field2.where}\``
80111
+ );
80067
80112
  if (field2.set) {
80068
80113
  const problem = outputReferenceProblem(field2.value) ?? varReferenceProblem(field2.value);
80069
- if (problem) return `${locator} ${problem}`;
80114
+ if (problem) return `${locator} ${escapeInline(problem)}`;
80070
80115
  continue;
80071
80116
  }
80072
80117
  const rendered = field2.value.length > MAX_ENTRY_RENDER_CHARS ? `${field2.value.slice(0, MAX_ENTRY_RENDER_CHARS)}\u2026` : field2.value;
80073
- return `${locator} takes no {{output:...}} or {{var:...}} reference. Replace it with the literal value the step needs: ${JSON.stringify(rendered)}`;
80118
+ return `${locator} takes no {{output:...}} or {{var:...}} reference. Replace it with the literal value the step needs: ${escapeInline(JSON.stringify(rendered))}`;
80074
80119
  }
80075
80120
  return void 0;
80076
80121
  }
@@ -116219,9 +116264,11 @@ data: ${JSON.stringify(data)}
116219
116264
  }
116220
116265
  res.set("Cache-Control", "no-store");
116221
116266
  res.type(mime);
116222
- import_node_fs11.default.createReadStream(real).on("error", () => {
116267
+ const stream = import_node_fs11.default.createReadStream(real).on("error", () => {
116223
116268
  if (!res.headersSent) res.status(404).end();
116224
- }).pipe(res);
116269
+ });
116270
+ res.on("close", () => stream.destroy());
116271
+ stream.pipe(res);
116225
116272
  });
116226
116273
  router.get("/describe/:udid", async (req, res) => {
116227
116274
  const udid = req.params.udid;
@@ -116301,6 +116348,7 @@ function makeArtifactRoute(registry2) {
116301
116348
  res.status(410).json({ error: `Artifact "${id}" file no longer exists on the tool-server host` });
116302
116349
  return;
116303
116350
  }
116351
+ if (res.destroyed) return;
116304
116352
  if (entry.isDirectory) {
116305
116353
  streamDirectoryAsArchive(id, entry, req, res);
116306
116354
  return;
@@ -116310,12 +116358,18 @@ function makeArtifactRoute(registry2) {
116310
116358
  if (entry.size > 0) res.setHeader("Content-Length", String(entry.size));
116311
116359
  const stream = (0, import_node_fs12.createReadStream)(entry.path);
116312
116360
  stream.on("error", () => {
116313
- if (!res.headersSent) res.status(500).json({ error: `Failed to read artifact "${id}"` });
116361
+ if (!res.headersSent) sendDownloadError(res, `Failed to read artifact "${id}"`);
116314
116362
  else res.destroy();
116315
116363
  });
116364
+ res.on("close", () => stream.destroy());
116316
116365
  stream.pipe(res);
116317
116366
  };
116318
116367
  }
116368
+ function sendDownloadError(res, error63) {
116369
+ res.removeHeader("Content-Type");
116370
+ res.removeHeader("Content-Disposition");
116371
+ res.status(500).json({ error: error63 });
116372
+ }
116319
116373
  function makeArtifactListRoute(registry2) {
116320
116374
  return function handleArtifactListRequest(_req, res) {
116321
116375
  const artifacts = registry2.artifacts.list();
@@ -116334,9 +116388,7 @@ function streamDirectoryAsArchive(id, entry, req, res) {
116334
116388
  });
116335
116389
  child.on("error", (err) => {
116336
116390
  if (!res.headersSent) {
116337
- res.removeHeader("Content-Disposition");
116338
- res.type("json");
116339
- res.status(500).json({ error: `Failed to archive artifact "${id}": ${err.message}` });
116391
+ sendDownloadError(res, `Failed to archive artifact "${id}": ${err.message}`);
116340
116392
  } else {
116341
116393
  res.destroy();
116342
116394
  }
@@ -127766,8 +127818,6 @@ function publishedMetroPort(deviceId, used) {
127766
127818
  init_device_info();
127767
127819
 
127768
127820
  // ../tool-server/src/blueprints/chromium-js-runtime-debugger.ts
127769
- init_wrapper();
127770
- var http4 = __toESM(require("node:http"));
127771
127821
  init_src2();
127772
127822
 
127773
127823
  // ../tool-server/src/utils/debugger/source-maps.ts
@@ -127844,8 +127894,6 @@ var CLUSTER_KEY_LENGTH = 80;
127844
127894
  var SOURCE_EXT = /\.(tsx?|jsx?|mjs|cjs)$/;
127845
127895
  var RECENT_PER_LEVEL = 100;
127846
127896
  var RECENT_MESSAGE_CHARS = 300;
127847
- var LINE_RE = /^\[L:(\d+)\] (\S+) (\S+)\s+(\S+) \| (.*)$/;
127848
- var CAMEL_LEVELS = ["startGroup", "startGroupCollapsed", "endGroup", "profileEnd", "timeEnd"];
127849
127897
  var liveLogFiles = /* @__PURE__ */ new Set();
127850
127898
  var lastTimestamp = 0;
127851
127899
  var LogFileWriter = class {
@@ -127988,24 +128036,6 @@ ${line}` : line);
127988
128036
  sourceLine: c.sourceLine
127989
128037
  }));
127990
128038
  }
127991
- readAll() {
127992
- if (this.closed || !this.ready) return [];
127993
- try {
127994
- const content = fs47.readFileSync(this.filePath, "utf-8");
127995
- return content.split("\n").filter((line) => line.length > 0).map(parseFlatLine).filter((entry) => entry !== null);
127996
- } catch {
127997
- return [];
127998
- }
127999
- }
128000
- readFiltered(opts) {
128001
- const all = this.readAll();
128002
- let filtered = opts.level ? all.filter((e) => e.level === opts.level) : all;
128003
- const total = filtered.length;
128004
- if (opts.limit) {
128005
- filtered = filtered.slice(-opts.limit);
128006
- }
128007
- return { entries: filtered, total };
128008
- }
128009
128039
  /** `keepFile` leaves the log to the sweep, 24h after the close. */
128010
128040
  close({ keepFile = false } = {}) {
128011
128041
  if (this.closed) return;
@@ -128081,20 +128111,6 @@ function isHighSurrogate(code) {
128081
128111
  function detachedCopy(text) {
128082
128112
  return Buffer.from(text, "utf16le").toString("utf16le");
128083
128113
  }
128084
- function parseFlatLine(line) {
128085
- const match = LINE_RE.exec(line);
128086
- if (!match) return null;
128087
- const [, idStr, timestamp, levelRaw, , message] = match;
128088
- const level = CAMEL_LEVELS.find((l) => l.toUpperCase() === levelRaw) ?? levelRaw.toLowerCase();
128089
- return {
128090
- marker: `[L:${idStr}]`,
128091
- id: parseInt(idStr, 10),
128092
- timestamp,
128093
- level,
128094
- message
128095
- // stackTrace is not stored in the flat file
128096
- };
128097
- }
128098
128114
 
128099
128115
  // ../tool-server/src/utils/debugger/console-timestamp.ts
128100
128116
  var MAX_TIMESTAMP_MS = 864e13;
@@ -128266,7 +128282,6 @@ function browserLogMessage(params) {
128266
128282
  const entry = params.entry ?? {};
128267
128283
  const text = entry.text ?? "";
128268
128284
  return {
128269
- args: [],
128270
128285
  level: entry.level === "verbose" ? "debug" : entry.level ?? "info",
128271
128286
  message: withEntryUrl(text, entry),
128272
128287
  timestamp: entry.timestamp ?? NaN
@@ -128278,47 +128293,12 @@ function uncaughtExceptionMessage(params) {
128278
128293
  const thrown = exception?.description?.split("\n")[0] ?? (exception && "value" in exception ? stringifyConsoleValue(exception.value) : void 0);
128279
128294
  const text = details.text ?? "Uncaught";
128280
128295
  return {
128281
- args: [],
128282
128296
  level: "error",
128283
128297
  message: thrown ? `${text} ${thrown}` : text,
128284
128298
  timestamp: params.timestamp ?? NaN,
128285
128299
  stackTrace: details.stackTrace
128286
128300
  };
128287
128301
  }
128288
- function createConsoleLogServer(consoleEvents, logWriter) {
128289
- return new Promise((resolve24, reject) => {
128290
- const server = http4.createServer();
128291
- const wss = new import_websocket_server.default({ server });
128292
- wss.on("connection", (ws) => {
128293
- for (const entry of logWriter.readAll()) {
128294
- ws.send(JSON.stringify(entry));
128295
- }
128296
- const onLog = (entry) => {
128297
- if (ws.readyState === import_websocket.default.OPEN) {
128298
- ws.send(JSON.stringify(entry));
128299
- }
128300
- };
128301
- consoleEvents.on("log", onLog);
128302
- ws.on("close", () => consoleEvents.off("log", onLog));
128303
- });
128304
- server.listen(0, "127.0.0.1", () => {
128305
- const addr = server.address();
128306
- if (!addr || typeof addr === "string") {
128307
- reject(new Error("Failed to bind console log server"));
128308
- return;
128309
- }
128310
- const url2 = `ws://127.0.0.1:${addr.port}`;
128311
- resolve24({
128312
- url: url2,
128313
- close: () => new Promise((res) => {
128314
- wss.clients.forEach((c) => c.close());
128315
- wss.close(() => server.close(() => res()));
128316
- })
128317
- });
128318
- });
128319
- server.on("error", reject);
128320
- });
128321
- }
128322
128302
  function makeStubSourceResolver() {
128323
128303
  const unsupported2 = () => {
128324
128304
  throw new Error(
@@ -128367,7 +128347,6 @@ var chromiumJsRuntimeDebuggerBlueprint = {
128367
128347
  };
128368
128348
  cdp.events.on("disconnected", onDisconnected);
128369
128349
  const logWriter = new LogFileWriter(port);
128370
- const consoleEvents = new TypedEventEmitter();
128371
128350
  let nextLogId = 0;
128372
128351
  const replays = createReplayFilter();
128373
128352
  cdp.events.on("connected", replays.attached);
@@ -128375,26 +128354,17 @@ var chromiumJsRuntimeDebuggerBlueprint = {
128375
128354
  const isReplay = (domain2, fields) => Number.isFinite(fields.timestamp) && replays.isReplay(domain2, replayKey(chromium.server.tabs.activeTargetId(), fields));
128376
128355
  const record2 = (domain2, fields, { redactSecrets: redactSecrets2 = false } = {}) => {
128377
128356
  if (isReplay(domain2, fields)) return;
128378
- const message = redactSecrets2 ? networkSecretRedactor()(fields.message) : fields.message;
128379
- const ts = Number.isFinite(fields.timestamp) ? fields.timestamp : Date.now();
128380
- const entry = { ...fields, id: nextLogId++, message, timestamp: ts };
128381
128357
  logWriter.write({
128382
- id: entry.id,
128383
- timestamp: consoleTimestampToIso(ts),
128384
- level: entry.level,
128385
- message: entry.message,
128386
- stackTrace: entry.stackTrace
128358
+ id: nextLogId++,
128359
+ timestamp: consoleTimestampToIso(fields.timestamp),
128360
+ level: fields.level,
128361
+ message: redactSecrets2 ? networkSecretRedactor()(fields.message) : fields.message,
128362
+ stackTrace: fields.stackTrace
128387
128363
  });
128388
- consoleEvents.emit("log", entry);
128389
128364
  };
128390
128365
  const onConsoleAPI = (params) => {
128391
128366
  record2("Runtime", {
128392
128367
  level: params.type,
128393
- args: params.args.map((a) => ({
128394
- type: a.type,
128395
- value: a.value,
128396
- description: a.description
128397
- })),
128398
128368
  message: formatConsoleArgs(params),
128399
128369
  timestamp: params.timestamp,
128400
128370
  stackTrace: params.stackTrace
@@ -128409,7 +128379,6 @@ var chromiumJsRuntimeDebuggerBlueprint = {
128409
128379
  }
128410
128380
  };
128411
128381
  cdp.events.on("event", onBrowserEvent);
128412
- const consoleServer = await createConsoleLogServer(consoleEvents, logWriter);
128413
128382
  await cdp.addBinding("__argent_callback").catch(() => {
128414
128383
  });
128415
128384
  const sourceMaps = new SourceMapsRegistry();
@@ -128427,9 +128396,7 @@ var chromiumJsRuntimeDebuggerBlueprint = {
128427
128396
  cdp,
128428
128397
  sourceResolver,
128429
128398
  sourceMaps,
128430
- logWriter,
128431
- consoleEvents,
128432
- consoleSocketUrl: consoleServer.url
128399
+ logWriter
128433
128400
  };
128434
128401
  return {
128435
128402
  api,
@@ -128439,7 +128406,6 @@ var chromiumJsRuntimeDebuggerBlueprint = {
128439
128406
  cdp.events.off("connected", replays.attached);
128440
128407
  cdp.events.off("domainEnabled", replays.enabled);
128441
128408
  cdp.events.off("disconnected", onDisconnected);
128442
- await consoleServer.close();
128443
128409
  const captured2 = logWriter.getStats().totalEntries;
128444
128410
  const connectionLost = !cdp.isConnected();
128445
128411
  const inFile = logWriter.getFileEntryCount();
@@ -128712,6 +128678,7 @@ function directCallFailure(tool, result) {
128712
128678
 
128713
128679
  // ../tool-server/src/http.ts
128714
128680
  var AUTO_SUPPRESS_MS = 30 * 60 * 1e3;
128681
+ var CALLER_DEADLINE_SLACK_MS = 2e3;
128715
128682
  var AUTH_TOKEN_ENV = "ARGENT_AUTH_TOKEN";
128716
128683
  var BEARER_PREFIX = "Bearer ";
128717
128684
  var ARTIFACTS_LIST_ENDPOINT_FLAG = "artifacts-list-endpoint";
@@ -128801,6 +128768,10 @@ function inferDeviceAttribution(deviceId) {
128801
128768
  function firstHeader(value) {
128802
128769
  return Array.isArray(value) ? value[0] : value;
128803
128770
  }
128771
+ function parseCallerDeadlineMs(value) {
128772
+ const ms3 = Number(value);
128773
+ return Number.isSafeInteger(ms3) && ms3 > 0 ? ms3 : void 0;
128774
+ }
128804
128775
  function extractAiTelemetryMeta(req) {
128805
128776
  const meta3 = {};
128806
128777
  const client2 = firstHeader(req.headers["x-argent-ai-client"]);
@@ -128934,6 +128905,11 @@ function takeToolNote(data) {
128934
128905
  }
128935
128906
  function createHttpApp(registry2, options) {
128936
128907
  const app = (0, import_express3.default)();
128908
+ const arrivedAt = /* @__PURE__ */ new WeakMap();
128909
+ app.use((req, _res, next) => {
128910
+ arrivedAt.set(req, performance.now());
128911
+ next();
128912
+ });
128937
128913
  app.use(import_express3.default.json({ limit: "48mb" }));
128938
128914
  const maxUploadBytes = options?.maxUploadBytes ?? MAX_UPLOAD_STREAM_BYTES;
128939
128915
  const maxPendingUploadBytes = options?.maxPendingUploadBytes ?? MAX_PENDING_UPLOAD_BYTES;
@@ -129421,8 +129397,12 @@ function createHttpApp(registry2, options) {
129421
129397
  }
129422
129398
  }
129423
129399
  const controller = new AbortController();
129400
+ const deadlineMs = parseCallerDeadlineMs(firstHeader(req.headers[CALLER_DEADLINE_HEADER]));
129401
+ let lastSentAt = arrivedAt.get(req);
129424
129402
  res.on("close", () => {
129425
- if (!res.writableFinished) controller.abort();
129403
+ if (res.writableFinished) return;
129404
+ const atDeadline = deadlineMs !== void 0 && performance.now() - lastSentAt >= deadlineMs - CALLER_DEADLINE_SLACK_MS;
129405
+ controller.abort(atDeadline ? callerDeadlineReason() : void 0);
129426
129406
  });
129427
129407
  const keepAlive = def.longRunning && options?.idleTimeoutMs && options.idleTimeoutMs > 0 ? setInterval(() => idleTimer.touch(), Math.max(1e3, IDLE_CHECK_INTERVAL_MS / 2)) : null;
129428
129408
  if (keepAlive) keepAlive.unref?.();
@@ -129444,6 +129424,7 @@ function createHttpApp(registry2, options) {
129444
129424
  const writeLine = (payload) => {
129445
129425
  res.write(`${JSON.stringify(payload)}
129446
129426
  `);
129427
+ lastSentAt = performance.now();
129447
129428
  };
129448
129429
  if (wantsStream) {
129449
129430
  res.writeHead(200, {
@@ -131594,7 +131575,7 @@ function sleep4(ms3) {
131594
131575
  init_src2();
131595
131576
 
131596
131577
  // ../tool-server/src/utils/network-shaping-proxy.ts
131597
- var http5 = __toESM(require("node:http"));
131578
+ var http4 = __toESM(require("node:http"));
131598
131579
  var net11 = __toESM(require("node:net"));
131599
131580
 
131600
131581
  // ../tool-server/src/utils/shaped-link.ts
@@ -131996,7 +131977,7 @@ function listen3(server) {
131996
131977
  async function startShapingProxy(options) {
131997
131978
  const link = new ShapedLink();
131998
131979
  const sockets = /* @__PURE__ */ new Set();
131999
- const agent = new http5.Agent({ keepAlive: true });
131980
+ const agent = new http4.Agent({ keepAlive: true });
132000
131981
  const track2 = (socket) => {
132001
131982
  sockets.add(socket);
132002
131983
  socket.on("close", () => sockets.delete(socket));
@@ -132032,7 +132013,7 @@ async function startShapingProxy(options) {
132032
132013
  const target = await resolve24(requested);
132033
132014
  if (res.destroyed) return;
132034
132015
  if (!target) return void res.writeHead(502).end();
132035
- const upstream = http5.request({
132016
+ const upstream = http4.request({
132036
132017
  agent,
132037
132018
  host: target.host,
132038
132019
  port: target.port,
@@ -132091,7 +132072,7 @@ async function startShapingProxy(options) {
132091
132072
  const target = requestLineTarget(requestLine);
132092
132073
  return target !== null && options.bypass(target.host, target.port);
132093
132074
  };
132094
- const server = http5.createServer({ requestTimeout: 0 });
132075
+ const server = http4.createServer({ requestTimeout: 0 });
132095
132076
  server.on("request", (req, res) => void onRequest(req, res).catch(() => res.destroy()));
132096
132077
  server.on("connect", (req, client2, head) => {
132097
132078
  void onConnect(req, client2, head).catch(() => client2.destroy());
@@ -134029,8 +134010,6 @@ var DISABLE_LOGBOX_SCRIPT = `(function() {
134029
134010
  })()`;
134030
134011
 
134031
134012
  // ../tool-server/src/blueprints/js-runtime-debugger.ts
134032
- init_wrapper();
134033
- var http6 = __toESM(require("node:http"));
134034
134013
  var JS_RUNTIME_DEBUGGER_NAMESPACE = "JsRuntimeDebugger";
134035
134014
  function unconfirmedMatchError(deviceId, port, deviceName, where, targets) {
134036
134015
  const listed = [
@@ -134066,47 +134045,6 @@ function formatConsoleArgs2(params) {
134066
134045
  return `[${arg.type}]`;
134067
134046
  }).join(" ");
134068
134047
  }
134069
- function createConsoleLogServer2(consoleEvents, logWriter) {
134070
- return new Promise((resolve24, reject) => {
134071
- const server = http6.createServer();
134072
- const wss = new import_websocket_server.default({ server });
134073
- wss.on("connection", (ws) => {
134074
- for (const entry of logWriter.readAll()) {
134075
- ws.send(JSON.stringify(entry));
134076
- }
134077
- const onLog = (entry) => {
134078
- if (ws.readyState === import_websocket.default.OPEN) {
134079
- ws.send(JSON.stringify(entry));
134080
- }
134081
- };
134082
- consoleEvents.on("log", onLog);
134083
- ws.on("close", () => consoleEvents.off("log", onLog));
134084
- });
134085
- server.listen(0, "127.0.0.1", () => {
134086
- const addr = server.address();
134087
- if (!addr || typeof addr === "string") {
134088
- reject(
134089
- new FailureError("Failed to bind console log server", {
134090
- error_code: FAILURE_CODES.JS_RUNTIME_CONSOLE_SERVER_BIND_FAILED,
134091
- failure_stage: "js_runtime_console_server_bind",
134092
- failure_area: "tool_server",
134093
- error_kind: "network"
134094
- })
134095
- );
134096
- return;
134097
- }
134098
- const url2 = `ws://127.0.0.1:${addr.port}`;
134099
- resolve24({
134100
- url: url2,
134101
- close: () => new Promise((res) => {
134102
- wss.clients.forEach((c) => c.close());
134103
- wss.close(() => server.close(() => res()));
134104
- })
134105
- });
134106
- });
134107
- server.on("error", reject);
134108
- });
134109
- }
134110
134048
  var BEFORE_THAT = " Before that: ";
134111
134049
  var KEPT_AT = " is kept at ";
134112
134050
  function cdpDisconnectedError() {
@@ -134208,29 +134146,15 @@ var jsRuntimeDebuggerBlueprint = {
134208
134146
  throw unconfirmedMatchError(deviceId, port, selected.deviceName, where, metro.targets);
134209
134147
  }
134210
134148
  const logWriter = new LogFileWriter(port);
134211
- const consoleEvents = new TypedEventEmitter();
134212
134149
  let nextLogId = 0;
134213
134150
  const onConsoleAPI = (params) => {
134214
- const entry = {
134151
+ logWriter.write({
134215
134152
  id: nextLogId++,
134153
+ timestamp: consoleTimestampToIso(params.timestamp),
134216
134154
  level: params.type,
134217
- args: params.args.map((a) => ({
134218
- type: a.type,
134219
- value: a.value,
134220
- description: a.description
134221
- })),
134222
134155
  message: formatConsoleArgs2(params),
134223
- timestamp: params.timestamp,
134224
134156
  stackTrace: params.stackTrace
134225
- };
134226
- logWriter.write({
134227
- id: entry.id,
134228
- timestamp: consoleTimestampToIso(entry.timestamp),
134229
- level: entry.level,
134230
- message: entry.message,
134231
- stackTrace: entry.stackTrace
134232
134157
  });
134233
- consoleEvents.emit("log", entry);
134234
134158
  };
134235
134159
  cdp.events.on("consoleAPICalled", onConsoleAPI);
134236
134160
  const logicalDeviceId = selected.target.reactNative?.logicalDeviceId;
@@ -134295,12 +134219,8 @@ var jsRuntimeDebuggerBlueprint = {
134295
134219
  await cdp.addBinding("__argent_callback", { legacyInspector: selected.legacyInspector });
134296
134220
  await cdp.evaluate(DISABLE_LOGBOX_SCRIPT).catch(warnOnError("DISABLE_LOGBOX_SCRIPT"));
134297
134221
  await sourceMaps.waitForPending();
134222
+ if (!cdp.isConnected()) throw cdpDisconnectedError();
134298
134223
  const sourceResolver = createSourceResolver(port, metro.projectRoot);
134299
- const consoleServer = await createConsoleLogServer2(consoleEvents, logWriter);
134300
- if (!cdp.isConnected()) {
134301
- await consoleServer.close();
134302
- throw cdpDisconnectedError();
134303
- }
134304
134224
  const api = {
134305
134225
  port,
134306
134226
  projectRoot: metro.projectRoot,
@@ -134312,9 +134232,7 @@ var jsRuntimeDebuggerBlueprint = {
134312
134232
  cdp,
134313
134233
  sourceResolver,
134314
134234
  sourceMaps,
134315
- logWriter,
134316
- consoleEvents,
134317
- consoleSocketUrl: consoleServer.url
134235
+ logWriter
134318
134236
  };
134319
134237
  rememberDeviceAlias(api.logicalDeviceId, deviceId);
134320
134238
  rememberLogicalKeyedDevice(api.logicalDeviceId, deviceId);
@@ -134327,7 +134245,6 @@ var jsRuntimeDebuggerBlueprint = {
134327
134245
  dispose: async () => {
134328
134246
  forgetDeviceAlias(api.logicalDeviceId);
134329
134247
  forgetLogicalKeyedDevice(deviceId);
134330
- await consoleServer.close();
134331
134248
  closeLog({ breadcrumb: true });
134332
134249
  await cdp.disconnect();
134333
134250
  },
@@ -172080,16 +171997,16 @@ async function prepareNestedFlow(registry2, project, toolId, args) {
172080
171997
  // ../tool-server/src/tools/flows/flow-step-definitions.ts
172081
171998
  function yamlSelectorLabel(sel) {
172082
171999
  const yaml = selectorToYaml(sel);
172083
- if (typeof yaml !== "object" || yaml === null) return JSON.stringify(yaml);
172000
+ if (typeof yaml !== "object" || yaml === null) return escapeInline(JSON.stringify(yaml));
172084
172001
  const sorted = Object.fromEntries(
172085
172002
  Object.entries(yaml).sort(([a], [b]) => a < b ? -1 : a > b ? 1 : 0)
172086
172003
  );
172087
- return JSON.stringify(sorted);
172004
+ return escapeInline(JSON.stringify(sorted));
172088
172005
  }
172089
172006
  function yamlTextConditionLabel(sel, expectedText, textMatch) {
172090
172007
  const selector = yamlSelectorLabel(sel);
172091
172008
  const expected = expectedText ?? "";
172092
- return textMatch === "matches" ? `text ${selector} matches /${escapeInline(expected)}/` : textMatch === "equals" ? `text ${selector} == ${JSON.stringify(expected)}` : `text ${selector} contains ${JSON.stringify(expected)}`;
172009
+ return textMatch === "matches" ? `text ${selector} matches /${escapeInline(expected)}/` : textMatch === "equals" ? `text ${selector} == ${escapeInline(JSON.stringify(expected))}` : `text ${selector} contains ${escapeInline(JSON.stringify(expected))}`;
172093
172010
  }
172094
172011
  function foldLabel(step) {
172095
172012
  return step.posture ?? `${step.angle}\xB0`;
@@ -172100,7 +172017,7 @@ function yamlConditionLabel(cond) {
172100
172017
  function selectorLabel(sel) {
172101
172018
  const parts2 = [];
172102
172019
  if (sel.any) parts2.push("*");
172103
- if (sel.text !== void 0) parts2.push(JSON.stringify(sel.text));
172020
+ if (sel.text !== void 0) parts2.push(escapeInline(JSON.stringify(sel.text)));
172104
172021
  if (sel.textMatches !== void 0) parts2.push(`/${escapeInline(sel.textMatches)}/`);
172105
172022
  if (sel.identifier) parts2.push(`id=${escapeInline(sel.identifier)}`);
172106
172023
  if (sel.role) parts2.push(`role=${escapeInline(sel.role)}`);
@@ -172141,7 +172058,7 @@ function describeWhenCondition(cond) {
172141
172058
  }
172142
172059
  function renderToolArgs(args) {
172143
172060
  try {
172144
- return JSON.stringify(args);
172061
+ return escapeInline(JSON.stringify(args));
172145
172062
  } catch {
172146
172063
  return "[cyclic args]";
172147
172064
  }
@@ -172154,9 +172071,9 @@ function delayLabel(step) {
172154
172071
  var MAX_TARGET_TEXT_CHARS = 200;
172155
172072
  function typedTextLabel(text) {
172156
172073
  const chars = Array.from(text);
172157
- if (chars.length <= MAX_TARGET_TEXT_CHARS) return JSON.stringify(text);
172074
+ if (chars.length <= MAX_TARGET_TEXT_CHARS) return escapeInline(JSON.stringify(text));
172158
172075
  const elided = chars.length - MAX_TARGET_TEXT_CHARS;
172159
- return `${JSON.stringify(chars.slice(0, MAX_TARGET_TEXT_CHARS).join(""))}\u2026(+${elided} chars)`;
172076
+ return `${escapeInline(JSON.stringify(chars.slice(0, MAX_TARGET_TEXT_CHARS).join("")))}\u2026(+${elided} chars)`;
172160
172077
  }
172161
172078
  var POINT_GESTURE_STEP = {
172162
172079
  // `times` (tap) and `duration` (long-press) change what replays, so a summary
@@ -172202,7 +172119,7 @@ var FLOW_STEP_DEFINITIONS = {
172202
172119
  target: () => void 0
172203
172120
  },
172204
172121
  "launch": {
172205
- summary: (step) => typeof step.app === "string" ? escapeInline(step.app) : JSON.stringify(step.app),
172122
+ summary: (step) => escapeInline(typeof step.app === "string" ? step.app : JSON.stringify(step.app)),
172206
172123
  // A launch's app id may be per-platform (`appIdForPlatform`), and a step
172207
172124
  // alone does not know the run device.
172208
172125
  target: () => void 0
@@ -172238,7 +172155,7 @@ var FLOW_STEP_DEFINITIONS = {
172238
172155
  target: (step) => swipeLabel(step, selectorLabel)
172239
172156
  },
172240
172157
  "type": {
172241
- summary: (step) => `${yamlSelectorLabel(step.into)} \u2190 ${JSON.stringify(step.text)}`,
172158
+ summary: (step) => `${yamlSelectorLabel(step.into)} \u2190 ${escapeInline(JSON.stringify(step.text))}`,
172242
172159
  // The typed text rides along, the way an await/assert target carries its
172243
172160
  // expectation: two steps into the same field with different text would
172244
172161
  // otherwise render identical targets.
@@ -177525,7 +177442,8 @@ function summarize(flowName, deviceId, executionPrerequisite, steps, aborted2, t
177525
177442
  e2eTest: flowName,
177526
177443
  flow: flowName,
177527
177444
  device: deviceId,
177528
- executionPrerequisite,
177445
+ // Flow-file text, printed on one line (`assumes:`, `Prerequisite:`).
177446
+ executionPrerequisite: escapeInline(executionPrerequisite),
177529
177447
  // A cancelled run must never read as PASS — it may contain skips alone
177530
177448
  // (no fail/error report), so the verdict folds the abort in directly. A
177531
177449
  // skip by itself is NOT a failure: an unmet `when:` guard skips its block
@@ -177543,10 +177461,16 @@ function summarize(flowName, deviceId, executionPrerequisite, steps, aborted2, t
177543
177461
  }
177544
177462
  function pushReport(state3, report2) {
177545
177463
  if (report2.e2eTest !== void 0) report2.flow = report2.e2eTest;
177464
+ if (report2.tool !== void 0) report2.tool = escapeInline(String(report2.tool));
177465
+ if (report2.reason !== void 0) report2.reason = escapeLines(report2.reason);
177466
+ if (report2.scriptLog !== void 0) report2.scriptLog = escapeLines(report2.scriptLog);
177546
177467
  if (state3.inShutdown) report2.shutdown = true;
177547
177468
  state3.reports.push(report2);
177548
177469
  state3.onStepReport?.(report2);
177549
177470
  }
177471
+ function escapeLines(text) {
177472
+ return text.split(/\r?\n/).map(escapeInline).join("\n");
177473
+ }
177550
177474
  function scopeVars2(state3, scope) {
177551
177475
  return mergeScriptEnv(scope.fileVars, state3.runVars);
177552
177476
  }
@@ -177914,7 +177838,7 @@ async function execRunStep(state3, step, scope) {
177914
177838
  await execSteps(state3, fragment.steps, fragmentScope);
177915
177839
  }
177916
177840
  function oneLineReason(text) {
177917
- return text.replace(/\\/g, "\\\\").replace(/\n/g, "\\n").replace(/\r/g, "\\r").replace(/\t/g, "\\t");
177841
+ return escapeInline(text.replace(/\\/g, "\\\\"));
177918
177842
  }
177919
177843
  async function runScriptStep(state3, step, scope) {
177920
177844
  const { outcome, result, unknownSecret } = await runFlowScriptStep({
@@ -180227,10 +180151,10 @@ async function collectHostDepsReport() {
180227
180151
  }
180228
180152
 
180229
180153
  // ../tool-server/src/utils/probe-argent-tool-server.ts
180230
- var http7 = __toESM(require("node:http"));
180154
+ var http5 = __toESM(require("node:http"));
180231
180155
  function probeArgentToolServer(host, port, timeoutMs = 500) {
180232
180156
  return new Promise((resolve24) => {
180233
- const req = http7.request(
180157
+ const req = http5.request(
180234
180158
  { host, port, path: "/tools", method: "GET", timeout: timeoutMs },
180235
180159
  (res) => {
180236
180160
  const isArgentPeer = (res.statusCode === 200 || res.statusCode === 401) && peerArgentHomeId(res.headers[ARGENT_HOME_HEADER]) === argentHomeId();