@swmansion/argent 0.22.2-next.8 → 0.23.0

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.
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
package/dist/cli-cmds.mjs CHANGED
@@ -2287,6 +2287,9 @@ var FAILURE_CODES = {
2287
2287
  SIMULATOR_SERVER_READY_TIMEOUT: "SIMULATOR_SERVER_READY_TIMEOUT",
2288
2288
  SIMULATOR_SERVER_PROCESS_ERROR: "SIMULATOR_SERVER_PROCESS_ERROR",
2289
2289
  SIMULATOR_SERVER_TERMINATED: "SIMULATOR_SERVER_TERMINATED",
2290
+ SIMULATOR_COMMAND_REJECTED: "SIMULATOR_COMMAND_REJECTED",
2291
+ SIMULATOR_COMMAND_ACK_TIMEOUT: "SIMULATOR_COMMAND_ACK_TIMEOUT",
2292
+ SIMULATOR_COMMAND_TRANSPORT_FAILED: "SIMULATOR_COMMAND_TRANSPORT_FAILED",
2290
2293
  AX_QUERY_TIMEOUT: "AX_QUERY_TIMEOUT",
2291
2294
  AX_DAEMON_READY_TIMEOUT: "AX_DAEMON_READY_TIMEOUT",
2292
2295
  AX_DAEMON_EXITED_BEFORE_READY: "AX_DAEMON_EXITED_BEFORE_READY",
@@ -3289,6 +3292,14 @@ var CONFIG_SCHEMA = [
3289
3292
  // drained/reset, not just the file rewritten.
3290
3293
  manageCommand: "argent telemetry"
3291
3294
  },
3295
+ {
3296
+ key: "allowlist.enabled",
3297
+ description: "Whether `argent update` re-applies editor auto-approve allowlist rules. Unset (the default) keeps the current behavior: update refreshes the rules for editors that already have argent configured. Set to `false` to keep update from touching editor allowlists. `false` in either scope wins, so a committed project opt-out holds for every teammate.",
3298
+ scopes: ["project", "global"],
3299
+ parse: asBoolean,
3300
+ merge: "prioritize-restrictive",
3301
+ example: "false"
3302
+ },
3292
3303
  {
3293
3304
  key: "lens.agent",
3294
3305
  description: "Coding-agent id remembered by `argent lens` to skip the picker.",
@@ -7214,7 +7225,7 @@ var _CI_VENDOR_COUNT_FOR_TEST = vendors_default.length;
7214
7225
  var SESSION_ID2 = randomUUID5();
7215
7226
  function readCliVersion() {
7216
7227
  if (true) {
7217
- return "0.22.2-next.8";
7228
+ return "0.23.0";
7218
7229
  }
7219
7230
  return "0.0.0";
7220
7231
  }
@@ -15095,6 +15095,31 @@ function readConfigObject(scope = "global", options = {}) {
15095
15095
  }
15096
15096
  return {};
15097
15097
  }
15098
+ var FORBIDDEN_SEGMENTS = /* @__PURE__ */ new Set(["__proto__", "prototype", "constructor"]);
15099
+ function splitKey(dottedKey) {
15100
+ const parts = dottedKey.split(".");
15101
+ if (parts.length === 0 || parts.some((p) => p === "")) {
15102
+ throw new Error(`Invalid config key "${dottedKey}": empty path segment`);
15103
+ }
15104
+ for (const p of parts) {
15105
+ if (FORBIDDEN_SEGMENTS.has(p)) {
15106
+ throw new Error(`Invalid config key "${dottedKey}": forbidden segment "${p}"`);
15107
+ }
15108
+ }
15109
+ return parts;
15110
+ }
15111
+ function isPlainObject(value) {
15112
+ return !!value && typeof value === "object" && !Array.isArray(value);
15113
+ }
15114
+ function getAtPath(obj, dottedKey) {
15115
+ const parts = splitKey(dottedKey);
15116
+ let cur = obj;
15117
+ for (const part of parts) {
15118
+ if (!isPlainObject(cur)) return void 0;
15119
+ cur = cur[part];
15120
+ }
15121
+ return cur;
15122
+ }
15098
15123
  var LOCK_STALE_MS = 1e4;
15099
15124
  var LOCK_MAX_WAIT_MS = 2e3;
15100
15125
  var LOCK_RETRY_MS = 25;
@@ -15172,8 +15197,162 @@ var import_dotenv = __toESM(require_main(), 1);
15172
15197
  import * as fs4 from "node:fs";
15173
15198
  import * as path5 from "node:path";
15174
15199
 
15200
+ // ../configuration-core/src/merge.ts
15201
+ function mergeRestrictive(local, global2) {
15202
+ if (local === void 0) return global2;
15203
+ if (global2 === void 0) return local;
15204
+ if (typeof local === "boolean" && typeof global2 === "boolean") {
15205
+ return local && global2;
15206
+ }
15207
+ if (typeof local === "number" && typeof global2 === "number") {
15208
+ return Math.min(local, global2);
15209
+ }
15210
+ return local;
15211
+ }
15212
+ function toArray(value) {
15213
+ return Array.isArray(value) ? value : null;
15214
+ }
15215
+ function mergeUnion(local, global2) {
15216
+ const l2 = toArray(local);
15217
+ const g = toArray(global2);
15218
+ if (l2 === null && g === null) return local ?? global2;
15219
+ const merged = [...g ?? [], ...l2 ?? []];
15220
+ return Array.from(new Set(merged));
15221
+ }
15222
+ function mergeIntersection(local, global2) {
15223
+ const l2 = toArray(local);
15224
+ const g = toArray(global2);
15225
+ if (l2 === null && g === null) return local ?? global2;
15226
+ if (l2 === null) return global2;
15227
+ if (g === null) return local;
15228
+ const globalSet = new Set(g);
15229
+ return l2.filter((item) => globalSet.has(item));
15230
+ }
15231
+ function applyMergePolicy(policy, local, global2) {
15232
+ if (typeof policy === "function") return policy({ local, global: global2 });
15233
+ switch (policy) {
15234
+ case "prioritize-local":
15235
+ return local ?? global2;
15236
+ case "prioritize-global":
15237
+ return global2 ?? local;
15238
+ case "prioritize-restrictive":
15239
+ return mergeRestrictive(local, global2);
15240
+ case "union":
15241
+ return mergeUnion(local, global2);
15242
+ case "intersection":
15243
+ return mergeIntersection(local, global2);
15244
+ default: {
15245
+ const _exhaustive = policy;
15246
+ return _exhaustive;
15247
+ }
15248
+ }
15249
+ }
15250
+
15251
+ // ../configuration-core/src/config-schema.ts
15252
+ function asBoolean(raw) {
15253
+ return typeof raw === "boolean" ? raw : void 0;
15254
+ }
15255
+ function asString(raw) {
15256
+ if (typeof raw !== "string") return void 0;
15257
+ const trimmed = raw.trim();
15258
+ return trimmed === "" ? void 0 : trimmed;
15259
+ }
15260
+ function asStringArray(raw) {
15261
+ if (!Array.isArray(raw)) return void 0;
15262
+ const out = [];
15263
+ for (const item of raw) {
15264
+ if (typeof item === "string" && item.trim() !== "") out.push(item.trim());
15265
+ }
15266
+ return out;
15267
+ }
15268
+ var CONFIG_SCHEMA = [
15269
+ {
15270
+ key: "telemetry.enabled",
15271
+ description: "Whether anonymous opt-out telemetry is enabled (on by default; environment opt-outs like DO_NOT_TRACK are not reflected here \u2014 `argent telemetry status` shows effective consent). `false` in either scope wins, so a committed project opt-out holds for every teammate.",
15272
+ scopes: ["project", "global"],
15273
+ parse: asBoolean,
15274
+ merge: "prioritize-restrictive",
15275
+ // Opt-out: consent.ts reads an unstored value as enabled, so the config
15276
+ // surface must show the same rather than "(unset)".
15277
+ default: true,
15278
+ // Opt-in/out goes through the dedicated command so the live client is
15279
+ // drained/reset, not just the file rewritten.
15280
+ manageCommand: "argent telemetry"
15281
+ },
15282
+ {
15283
+ key: "allowlist.enabled",
15284
+ description: "Whether `argent update` re-applies editor auto-approve allowlist rules. Unset (the default) keeps the current behavior: update refreshes the rules for editors that already have argent configured. Set to `false` to keep update from touching editor allowlists. `false` in either scope wins, so a committed project opt-out holds for every teammate.",
15285
+ scopes: ["project", "global"],
15286
+ parse: asBoolean,
15287
+ merge: "prioritize-restrictive",
15288
+ example: "false"
15289
+ },
15290
+ {
15291
+ key: "lens.agent",
15292
+ description: "Coding-agent id remembered by `argent lens` to skip the picker.",
15293
+ scopes: ["project", "global"],
15294
+ parse: asString,
15295
+ merge: "prioritize-local",
15296
+ example: "claude"
15297
+ },
15298
+ {
15299
+ key: "ios.additionalDeviceSets",
15300
+ description: "Additional CoreSimulator device-set directories whose simulators argent should see alongside the default set. Absolute paths (or ~/\u2026); relative entries resolve against the project root (project scope) or home (global scope).",
15301
+ scopes: ["project", "global"],
15302
+ parse: asStringArray,
15303
+ // Additive rather than shadowing: global baseline first, project extras
15304
+ // after, deduplicated. `getAdditionalIosDeviceSets` re-implements this union
15305
+ // (path resolution must precede dedup) and guards on the preset staying "union".
15306
+ merge: "union",
15307
+ example: '["~/DeviceSets/ci"]'
15308
+ },
15309
+ {
15310
+ key: "recordings.directory",
15311
+ description: "Directory where finished screen recordings (mp4) are saved on the client host. Absolute, `~`-prefixed, or relative to the project root (home dir when not in a project). Unset \u21D2 `.argent/recordings` under the project root.",
15312
+ scopes: ["project", "global"],
15313
+ parse: asString,
15314
+ // Resolved on the client (the machine the mp4 is persisted to), so with a
15315
+ // remote `argent link` tool-server it is the *client's* config that decides.
15316
+ merge: "prioritize-local",
15317
+ example: "~/Movies/argent"
15318
+ }
15319
+ ];
15320
+ function getConfigDefinition(key, registry = CONFIG_SCHEMA) {
15321
+ return registry.find((def) => def.key === key);
15322
+ }
15323
+
15175
15324
  // ../configuration-core/src/config-access.ts
15176
15325
  import * as path6 from "node:path";
15326
+ function readScopeValue(def, scope, options) {
15327
+ if (!def.scopes.includes(scope)) return void 0;
15328
+ const raw = getAtPath(readConfigObject(scope, options), def.key);
15329
+ return raw === void 0 ? void 0 : def.parse(raw);
15330
+ }
15331
+ function getConfigValue(def, options = {}) {
15332
+ const local = readScopeValue(def, "project", options);
15333
+ const global2 = readScopeValue(def, "global", options);
15334
+ const merged = applyMergePolicy(def.merge, local, global2);
15335
+ return merged ?? def.default;
15336
+ }
15337
+ function getConfigValueByKey(key, options = {}, registry = CONFIG_SCHEMA) {
15338
+ const def = requireDefinition(key, registry);
15339
+ return getConfigValue(def, options);
15340
+ }
15341
+ function requireDefinition(key, registry = CONFIG_SCHEMA) {
15342
+ const def = getConfigDefinition(key, registry);
15343
+ if (!def) {
15344
+ throw new UnknownConfigKeyError(key);
15345
+ }
15346
+ return def;
15347
+ }
15348
+ var UnknownConfigKeyError = class extends Error {
15349
+ constructor(key) {
15350
+ super(`Unknown configuration key "${key}".`);
15351
+ this.key = key;
15352
+ this.name = "UnknownConfigKeyError";
15353
+ }
15354
+ key;
15355
+ };
15177
15356
 
15178
15357
  // ../telemetry/src/paths.ts
15179
15358
  function identityFilePath() {
@@ -15443,6 +15622,9 @@ var FAILURE_CODES = {
15443
15622
  SIMULATOR_SERVER_READY_TIMEOUT: "SIMULATOR_SERVER_READY_TIMEOUT",
15444
15623
  SIMULATOR_SERVER_PROCESS_ERROR: "SIMULATOR_SERVER_PROCESS_ERROR",
15445
15624
  SIMULATOR_SERVER_TERMINATED: "SIMULATOR_SERVER_TERMINATED",
15625
+ SIMULATOR_COMMAND_REJECTED: "SIMULATOR_COMMAND_REJECTED",
15626
+ SIMULATOR_COMMAND_ACK_TIMEOUT: "SIMULATOR_COMMAND_ACK_TIMEOUT",
15627
+ SIMULATOR_COMMAND_TRANSPORT_FAILED: "SIMULATOR_COMMAND_TRANSPORT_FAILED",
15446
15628
  AX_QUERY_TIMEOUT: "AX_QUERY_TIMEOUT",
15447
15629
  AX_DAEMON_READY_TIMEOUT: "AX_DAEMON_READY_TIMEOUT",
15448
15630
  AX_DAEMON_EXITED_BEFORE_READY: "AX_DAEMON_EXITED_BEFORE_READY",
@@ -16428,7 +16610,7 @@ var _CI_VENDOR_COUNT_FOR_TEST = vendors_default.length;
16428
16610
  var SESSION_ID = randomUUID4();
16429
16611
  function readCliVersion() {
16430
16612
  if (true) {
16431
- return "0.22.2-next.8";
16613
+ return "0.23.0";
16432
16614
  }
16433
16615
  return "0.0.0";
16434
16616
  }
@@ -23369,12 +23551,15 @@ async function update(args) {
23369
23551
  )
23370
23552
  );
23371
23553
  }
23372
- for (const [scope, adapters] of adaptersByScope) {
23373
- for (const adapter of adapters) {
23374
- if (!adapter.addAllowlist) continue;
23375
- try {
23376
- adapter.addAllowlist(projectRoot, scope);
23377
- } catch {
23554
+ const allowlistDisabled = getConfigValueByKey("allowlist.enabled", { cwd: projectRoot }) === false;
23555
+ if (!allowlistDisabled) {
23556
+ for (const [scope, adapters] of adaptersByScope) {
23557
+ for (const adapter of adapters) {
23558
+ if (!adapter.addAllowlist) continue;
23559
+ try {
23560
+ adapter.addAllowlist(projectRoot, scope);
23561
+ } catch {
23562
+ }
23378
23563
  }
23379
23564
  }
23380
23565
  }
@@ -23385,6 +23570,11 @@ async function update(args) {
23385
23570
  ...copyRulesAndAgents(localAdapters, projectRoot, "local", RULES_DIR, AGENTS_DIR)
23386
23571
  ];
23387
23572
  spinner2.stop("Configuration refreshed.");
23573
+ if (allowlistDisabled) {
23574
+ log.info(
23575
+ import_picocolors11.default.dim("Left editor auto-approve allowlists alone (allowlist.enabled is false).")
23576
+ );
23577
+ }
23388
23578
  if (results.length > 0) {
23389
23579
  note(results.join("\n"), "MCP Configs Updated");
23390
23580
  }
@@ -16471,6 +16471,9 @@ var FAILURE_CODES = {
16471
16471
  SIMULATOR_SERVER_READY_TIMEOUT: "SIMULATOR_SERVER_READY_TIMEOUT",
16472
16472
  SIMULATOR_SERVER_PROCESS_ERROR: "SIMULATOR_SERVER_PROCESS_ERROR",
16473
16473
  SIMULATOR_SERVER_TERMINATED: "SIMULATOR_SERVER_TERMINATED",
16474
+ SIMULATOR_COMMAND_REJECTED: "SIMULATOR_COMMAND_REJECTED",
16475
+ SIMULATOR_COMMAND_ACK_TIMEOUT: "SIMULATOR_COMMAND_ACK_TIMEOUT",
16476
+ SIMULATOR_COMMAND_TRANSPORT_FAILED: "SIMULATOR_COMMAND_TRANSPORT_FAILED",
16474
16477
  AX_QUERY_TIMEOUT: "AX_QUERY_TIMEOUT",
16475
16478
  AX_DAEMON_READY_TIMEOUT: "AX_DAEMON_READY_TIMEOUT",
16476
16479
  AX_DAEMON_EXITED_BEFORE_READY: "AX_DAEMON_EXITED_BEFORE_READY",
@@ -17153,6 +17156,14 @@ var CONFIG_SCHEMA = [
17153
17156
  // drained/reset, not just the file rewritten.
17154
17157
  manageCommand: "argent telemetry"
17155
17158
  },
17159
+ {
17160
+ key: "allowlist.enabled",
17161
+ description: "Whether `argent update` re-applies editor auto-approve allowlist rules. Unset (the default) keeps the current behavior: update refreshes the rules for editors that already have argent configured. Set to `false` to keep update from touching editor allowlists. `false` in either scope wins, so a committed project opt-out holds for every teammate.",
17162
+ scopes: ["project", "global"],
17163
+ parse: asBoolean,
17164
+ merge: "prioritize-restrictive",
17165
+ example: "false"
17166
+ },
17156
17167
  {
17157
17168
  key: "lens.agent",
17158
17169
  description: "Coding-agent id remembered by `argent lens` to skip the picker.",
@@ -628,6 +628,9 @@ var init_failure_codes = __esm({
628
628
  SIMULATOR_SERVER_READY_TIMEOUT: "SIMULATOR_SERVER_READY_TIMEOUT",
629
629
  SIMULATOR_SERVER_PROCESS_ERROR: "SIMULATOR_SERVER_PROCESS_ERROR",
630
630
  SIMULATOR_SERVER_TERMINATED: "SIMULATOR_SERVER_TERMINATED",
631
+ SIMULATOR_COMMAND_REJECTED: "SIMULATOR_COMMAND_REJECTED",
632
+ SIMULATOR_COMMAND_ACK_TIMEOUT: "SIMULATOR_COMMAND_ACK_TIMEOUT",
633
+ SIMULATOR_COMMAND_TRANSPORT_FAILED: "SIMULATOR_COMMAND_TRANSPORT_FAILED",
631
634
  AX_QUERY_TIMEOUT: "AX_QUERY_TIMEOUT",
632
635
  AX_DAEMON_READY_TIMEOUT: "AX_DAEMON_READY_TIMEOUT",
633
636
  AX_DAEMON_EXITED_BEFORE_READY: "AX_DAEMON_EXITED_BEFORE_READY",
@@ -90299,6 +90302,14 @@ var CONFIG_SCHEMA = [
90299
90302
  // drained/reset, not just the file rewritten.
90300
90303
  manageCommand: "argent telemetry"
90301
90304
  },
90305
+ {
90306
+ key: "allowlist.enabled",
90307
+ description: "Whether `argent update` re-applies editor auto-approve allowlist rules. Unset (the default) keeps the current behavior: update refreshes the rules for editors that already have argent configured. Set to `false` to keep update from touching editor allowlists. `false` in either scope wins, so a committed project opt-out holds for every teammate.",
90308
+ scopes: ["project", "global"],
90309
+ parse: asBoolean,
90310
+ merge: "prioritize-restrictive",
90311
+ example: "false"
90312
+ },
90302
90313
  {
90303
90314
  key: "lens.agent",
90304
90315
  description: "Coding-agent id remembered by `argent lens` to skip the picker.",
@@ -93890,7 +93901,7 @@ var _CI_VENDOR_COUNT_FOR_TEST = vendors_default.length;
93890
93901
  var SESSION_ID = (0, import_node_crypto3.randomUUID)();
93891
93902
  function readCliVersion() {
93892
93903
  if (true) {
93893
- return "0.22.2-next.8";
93904
+ return "0.23.0";
93894
93905
  }
93895
93906
  return "0.0.0";
93896
93907
  }
@@ -95241,7 +95252,7 @@ var import_node_path5 = __toESM(require("node:path"));
95241
95252
  var import_semver2 = __toESM(require_semver2());
95242
95253
 
95243
95254
  // ../tool-server/package.json
95244
- var version2 = "0.22.1";
95255
+ var version2 = "0.23.0";
95245
95256
 
95246
95257
  // ../tool-server/src/utils/update-checker.ts
95247
95258
  var import_update_core = __toESM(require_dist4());
@@ -106325,33 +106336,127 @@ var DEFAULT_SCREENSHOT_SCALE = 0.25;
106325
106336
  var NO_IMAGE_ERROR = /no image to export/i;
106326
106337
  var FIRST_FRAME_WAIT_MS = 6e3;
106327
106338
  var FIRST_FRAME_POLL_MS = 250;
106339
+ var COMMAND_ACK_TIMEOUT_MS = 5e3;
106328
106340
  var connections = /* @__PURE__ */ new Map();
106329
106341
  var cmdId = 0;
106330
- function getOrCreateWs(api) {
106342
+ function failAllPending(conn, makeError) {
106343
+ const entries = [...conn.pending.values()];
106344
+ conn.pending.clear();
106345
+ for (const entry of entries) entry.settle(makeError(entry.cmd));
106346
+ }
106347
+ function transportError(cmd, apiUrl, detail) {
106348
+ return new FailureError(
106349
+ `simulator-server did not accept the '${cmd}' command: ${detail}. The command was NOT delivered to the device. Check that the simulator is still booted and the simulator-server for ${apiUrl} is running.`,
106350
+ {
106351
+ error_code: FAILURE_CODES.SIMULATOR_COMMAND_TRANSPORT_FAILED,
106352
+ failure_stage: "simulator_command_transport",
106353
+ failure_area: "tool_server",
106354
+ error_kind: "network",
106355
+ network_failure: "connection_reset",
106356
+ failure_command: "simulator_server"
106357
+ }
106358
+ );
106359
+ }
106360
+ function getOrCreateConnection(api) {
106331
106361
  const key2 = api.apiUrl;
106332
106362
  const existing = connections.get(key2);
106333
- if (existing && (existing.readyState === wrapper_default.OPEN || existing.readyState === wrapper_default.CONNECTING)) {
106363
+ if (existing && (existing.ws.readyState === wrapper_default.OPEN || existing.ws.readyState === wrapper_default.CONNECTING)) {
106334
106364
  return existing;
106335
106365
  }
106336
106366
  const { host } = new URL(api.apiUrl);
106337
106367
  const ws = new wrapper_default(`ws://${host}/ws`);
106338
- ws.on("error", () => connections.delete(key2));
106339
- ws.on("close", () => connections.delete(key2));
106340
- connections.set(key2, ws);
106341
- return ws;
106368
+ const conn = { ws, pending: /* @__PURE__ */ new Map() };
106369
+ ws.on("message", (data) => {
106370
+ const text = Buffer.isBuffer(data) ? data.toString() : Array.isArray(data) ? Buffer.concat(data).toString() : Buffer.from(data).toString();
106371
+ let ack;
106372
+ try {
106373
+ ack = JSON.parse(text);
106374
+ } catch {
106375
+ return;
106376
+ }
106377
+ if (ack.status !== "ok" && ack.status !== "error") return;
106378
+ if (ack.id != null && !conn.pending.has(ack.id)) return;
106379
+ const id = ack.id ?? conn.pending.keys().next().value;
106380
+ if (id == null) return;
106381
+ const entry = conn.pending.get(id);
106382
+ if (entry == null) return;
106383
+ conn.pending.delete(id);
106384
+ if (ack.status === "ok") {
106385
+ entry.settle();
106386
+ return;
106387
+ }
106388
+ entry.settle(
106389
+ new FailureError(
106390
+ `simulator-server rejected the '${entry.cmd}' command: ${ack.message ?? "unknown error"}. The command was NOT delivered to the device.`,
106391
+ {
106392
+ error_code: FAILURE_CODES.SIMULATOR_COMMAND_REJECTED,
106393
+ failure_stage: "simulator_command_rejected",
106394
+ failure_area: "tool_server",
106395
+ error_kind: "unknown",
106396
+ failure_command: "simulator_server"
106397
+ }
106398
+ )
106399
+ );
106400
+ });
106401
+ ws.on("error", (err) => {
106402
+ connections.delete(key2);
106403
+ failAllPending(conn, (cmd) => transportError(cmd, key2, err.message));
106404
+ });
106405
+ ws.on("close", () => {
106406
+ connections.delete(key2);
106407
+ failAllPending(conn, (cmd) => transportError(cmd, key2, "the connection closed"));
106408
+ });
106409
+ connections.set(key2, conn);
106410
+ return conn;
106342
106411
  }
106343
106412
  function sendCommand(api, cmd) {
106344
106413
  if (api.transport) {
106345
106414
  routeViaTransport(api.transport, cmd);
106346
- return;
106347
- }
106348
- const ws = getOrCreateWs(api);
106349
- const payload = JSON.stringify({ id: String(++cmdId), ...cmd });
106350
- if (ws.readyState === wrapper_default.OPEN) {
106351
- ws.send(payload);
106352
- } else {
106353
- ws.once("open", () => ws.send(payload));
106415
+ return Promise.resolve();
106354
106416
  }
106417
+ const conn = getOrCreateConnection(api);
106418
+ const id = String(++cmdId);
106419
+ const cmdName = typeof cmd.cmd === "string" ? cmd.cmd : "unknown";
106420
+ const payload = JSON.stringify({ id, ...cmd });
106421
+ return new Promise((resolve12, reject) => {
106422
+ let done = false;
106423
+ const settle = (err) => {
106424
+ if (done) return;
106425
+ done = true;
106426
+ clearTimeout(timer);
106427
+ conn.pending.delete(id);
106428
+ if (err) reject(err);
106429
+ else resolve12();
106430
+ };
106431
+ const timer = setTimeout(
106432
+ () => settleAndDropConnection(
106433
+ new FailureError(
106434
+ `simulator-server did not acknowledge the '${cmdName}' command within ${COMMAND_ACK_TIMEOUT_MS}ms. The command may not have reached the device \u2014 the simulator may be wedged or the simulator-server unresponsive.`,
106435
+ {
106436
+ error_code: FAILURE_CODES.SIMULATOR_COMMAND_ACK_TIMEOUT,
106437
+ failure_stage: "simulator_command_ack",
106438
+ failure_area: "tool_server",
106439
+ error_kind: "timeout",
106440
+ network_failure: "timeout",
106441
+ failure_command: "simulator_server"
106442
+ }
106443
+ )
106444
+ ),
106445
+ COMMAND_ACK_TIMEOUT_MS
106446
+ );
106447
+ timer.unref?.();
106448
+ const settleAndDropConnection = (err) => {
106449
+ settle(err);
106450
+ connections.delete(api.apiUrl);
106451
+ conn.ws.close();
106452
+ };
106453
+ conn.pending.set(id, { settle, cmd: cmdName });
106454
+ const write = () => conn.ws.send(payload, (err) => {
106455
+ if (err) settle(transportError(cmdName, api.apiUrl, err.message));
106456
+ });
106457
+ if (conn.ws.readyState === wrapper_default.OPEN) write();
106458
+ else conn.ws.once("open", write);
106459
+ });
106355
106460
  }
106356
106461
  function setPointerVisible(api, show, signal) {
106357
106462
  return pointerPost(api, { show }, signal);
@@ -119444,7 +119549,7 @@ Before tapping, determine the correct coordinates by using discovery tools \u201
119444
119549
  const api = services.simulatorServer;
119445
119550
  for (let i = 1; i <= clickCount; i++) {
119446
119551
  if (i > 1) await sleep2(MULTI_TAP_GAP_MS);
119447
- sendCommand(api, {
119552
+ await sendCommand(api, {
119448
119553
  cmd: "touch",
119449
119554
  type: "Down",
119450
119555
  x: params.x,
@@ -119453,7 +119558,7 @@ Before tapping, determine the correct coordinates by using discovery tools \u201
119453
119558
  second_y: null
119454
119559
  });
119455
119560
  await sleep2(TAP_HOLD_MS);
119456
- sendCommand(api, {
119561
+ await sendCommand(api, {
119457
119562
  cmd: "touch",
119458
119563
  type: "Up",
119459
119564
  x: params.x,
@@ -119538,20 +119643,24 @@ Pass momentum:false for a momentum-free swipe that lands where the finger lifts
119538
119643
  let lastY = 0;
119539
119644
  for (let i = 0; i <= steps; i++) {
119540
119645
  if (ctx?.signal?.aborted) {
119541
- if (i > 0) {
119542
- sendCommand(api, {
119543
- cmd: "touch",
119544
- type: "Up",
119545
- x: lastX,
119546
- y: lastY,
119547
- second_x: null,
119548
- second_y: null
119549
- });
119550
- }
119551
119646
  const err = new Error(
119552
119647
  `gesture-swipe aborted - cancelled mid-gesture after ${i} of ${steps + 1} frames`
119553
119648
  );
119554
119649
  err.name = "AbortError";
119650
+ if (i > 0) {
119651
+ try {
119652
+ await sendCommand(api, {
119653
+ cmd: "touch",
119654
+ type: "Up",
119655
+ x: lastX,
119656
+ y: lastY,
119657
+ second_x: null,
119658
+ second_y: null
119659
+ });
119660
+ } catch (liftErr) {
119661
+ err.cause = liftErr;
119662
+ }
119663
+ }
119555
119664
  throw err;
119556
119665
  }
119557
119666
  const t = i / steps;
@@ -119560,7 +119669,7 @@ Pass momentum:false for a momentum-free swipe that lands where the finger lifts
119560
119669
  const y = params.fromY + (params.toY - params.fromY) * progress;
119561
119670
  const type = i === 0 ? "Down" : i === steps ? "Up" : "Move";
119562
119671
  if (type === "Up") {
119563
- sendCommand(api, {
119672
+ await sendCommand(api, {
119564
119673
  cmd: "touch",
119565
119674
  type: "Move",
119566
119675
  x,
@@ -119569,7 +119678,7 @@ Pass momentum:false for a momentum-free swipe that lands where the finger lifts
119569
119678
  second_y: null
119570
119679
  });
119571
119680
  }
119572
- sendCommand(api, {
119681
+ await sendCommand(api, {
119573
119682
  cmd: "touch",
119574
119683
  type,
119575
119684
  x,
@@ -119812,7 +119921,7 @@ function interpolateEvents(events, steps) {
119812
119921
  return result;
119813
119922
  }
119814
119923
  function sendTouchEvent(api, type, x, y, x2, y2) {
119815
- sendCommand(api, {
119924
+ return sendCommand(api, {
119816
119925
  cmd: "touch",
119817
119926
  type,
119818
119927
  x,
@@ -119883,7 +119992,7 @@ Example pinch-to-zoom (with interpolate:10 for smoothness):
119883
119992
  const events = params.interpolate && params.interpolate > 0 ? interpolateEvents(params.events, params.interpolate) : params.events;
119884
119993
  for (const event2 of events) {
119885
119994
  await sleep6(event2.delayMs ?? 16);
119886
- sendCommand(api, {
119995
+ await sendCommand(api, {
119887
119996
  cmd: "touch",
119888
119997
  type: event2.type,
119889
119998
  x: event2.x,
@@ -119966,7 +120075,7 @@ Use when you need to zoom in or out on a map, image, or zoomable view. Returns {
119966
120075
  const y2 = cy + halfDist * sinA;
119967
120076
  const type = i === 0 ? "Down" : i === steps ? "Up" : "Move";
119968
120077
  if (i === 0) timestampMs = Date.now();
119969
- sendTouchEvent(api, type, x1, y1, x2, y2);
120078
+ await sendTouchEvent(api, type, x1, y1, x2, y2);
119970
120079
  if (i < steps) await sleep(16);
119971
120080
  }
119972
120081
  return { pinched: true, timestampMs };
@@ -120044,11 +120153,17 @@ Size the orbit with radius, or with radiusX and radiusY together (the pair overr
120044
120153
  let lastY2 = 0;
120045
120154
  for (let i = 0; i <= steps; i++) {
120046
120155
  if (ctx?.signal?.aborted) {
120047
- if (i > 0) sendTouchEvent(api, "Up", lastX1, lastY1, lastX2, lastY2);
120048
120156
  const err = new Error(
120049
120157
  `gesture-rotate aborted \u2014 cancelled mid-gesture after ${i} of ${steps + 1} frames`
120050
120158
  );
120051
120159
  err.name = "AbortError";
120160
+ if (i > 0) {
120161
+ try {
120162
+ await sendTouchEvent(api, "Up", lastX1, lastY1, lastX2, lastY2);
120163
+ } catch (liftErr) {
120164
+ err.cause = liftErr;
120165
+ }
120166
+ }
120052
120167
  throw err;
120053
120168
  }
120054
120169
  const t = i / steps;
@@ -120060,7 +120175,7 @@ Size the orbit with radius, or with radiusX and radiusY together (the pair overr
120060
120175
  const y2 = params.centerY - radiusY * Math.sin(angleRad);
120061
120176
  const type = i === 0 ? "Down" : i === steps ? "Up" : "Move";
120062
120177
  if (i === 0) timestampMs = Date.now();
120063
- sendTouchEvent(api, type, x1, y1, x2, y2);
120178
+ await sendTouchEvent(api, type, x1, y1, x2, y2);
120064
120179
  lastX1 = x1;
120065
120180
  lastY1 = y1;
120066
120181
  lastX2 = x2;
@@ -120129,13 +120244,13 @@ Fails if the device backend is not reachable \u2014 the simulator-server for iOS
120129
120244
  return { pressed: params.button };
120130
120245
  }
120131
120246
  const api = services.simulatorServer;
120132
- sendCommand(api, {
120247
+ await sendCommand(api, {
120133
120248
  cmd: "button",
120134
120249
  direction: "Down",
120135
120250
  button: params.button
120136
120251
  });
120137
120252
  await sleep7(50);
120138
- sendCommand(api, { cmd: "button", direction: "Up", button: params.button });
120253
+ await sendCommand(api, { cmd: "button", direction: "Up", button: params.button });
120139
120254
  return { pressed: params.button };
120140
120255
  }
120141
120256
  };
@@ -120946,7 +121061,7 @@ Returns { orientation }. Fails if the target device is not booted.`,
120946
121061
  }),
120947
121062
  async execute(services, params) {
120948
121063
  const api = services.simulatorServer;
120949
- sendCommand(api, { cmd: "rotate", direction: params.orientation });
121064
+ await sendCommand(api, { cmd: "rotate", direction: params.orientation });
120950
121065
  return { orientation: params.orientation };
120951
121066
  }
120952
121067
  };
Binary file
Binary file
Binary file
Binary file
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@swmansion/argent",
3
- "version": "0.22.2-next.8",
3
+ "version": "0.23.0",
4
4
  "mcpName": "io.github.software-mansion/argent",
5
5
  "description": "MCP server for iOS Simulator and Android Emulator control",
6
6
  "license": "Apache-2.0",