@moxxy/cli 0.12.3 → 0.12.6

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/bin.js CHANGED
@@ -195,6 +195,22 @@ var init_log = __esm({
195
195
  listeners = /* @__PURE__ */ new Set();
196
196
  clearListeners = /* @__PURE__ */ new Set();
197
197
  now;
198
+ /**
199
+ * Lazy secondary indexes so `ofType`/`byTurn` are O(matches) instead of an
200
+ * O(n) full-array `filter` per call (these back hot paths: token-accounting's
201
+ * `ofType('provider_response')`, lazy-tool gating's
202
+ * `ofType('tool_call_requested')`, and remote-session's per-turn
203
+ * `byTurn(turnId)` priming). Built lazily on first query so a cold/seeded log
204
+ * pays the one-time O(n) build only if anything ever queries it, then kept
205
+ * O(1) per append/ingest. Reset to `null` (rebuild-on-next-query) by
206
+ * `clear`/`rebase`, which mutate `events` wholesale.
207
+ *
208
+ * Each index holds the SAME event object references in their original
209
+ * append order — so a query returns an array deep-equal to the old
210
+ * `events.filter(...)` for every input.
211
+ */
212
+ byType = null;
213
+ byTurnId = null;
198
214
  /**
199
215
  * Seq of the FIRST event this log holds. 0 for an authoring log; a mirror
200
216
  * primed by a partial attach replay (runner protocol v6 `replay.start`)
@@ -224,11 +240,53 @@ var init_log = __esm({
224
240
  slice(from = 0, to = this.base + this.events.length) {
225
241
  return this.events.slice(Math.max(0, from - this.base), Math.max(0, to - this.base));
226
242
  }
243
+ /** Build both secondary indexes from the current `events` array, preserving
244
+ * append order. Bucket arrays hold the original event references. */
245
+ buildIndexes() {
246
+ const byType = /* @__PURE__ */ new Map();
247
+ const byTurnId = /* @__PURE__ */ new Map();
248
+ for (const e3 of this.events) {
249
+ let typeBucket = byType.get(e3.type);
250
+ if (!typeBucket)
251
+ byType.set(e3.type, typeBucket = []);
252
+ typeBucket.push(e3);
253
+ let turnBucket = byTurnId.get(e3.turnId);
254
+ if (!turnBucket)
255
+ byTurnId.set(e3.turnId, turnBucket = []);
256
+ turnBucket.push(e3);
257
+ }
258
+ this.byType = byType;
259
+ this.byTurnId = byTurnId;
260
+ }
261
+ /** Append one event to the live indexes (no-op while they're cold). Called
262
+ * after the event is pushed to `events`, so order is preserved. */
263
+ indexEvent(e3) {
264
+ if (this.byType) {
265
+ const bucket = this.byType.get(e3.type);
266
+ if (bucket)
267
+ bucket.push(e3);
268
+ else
269
+ this.byType.set(e3.type, [e3]);
270
+ }
271
+ if (this.byTurnId) {
272
+ const bucket = this.byTurnId.get(e3.turnId);
273
+ if (bucket)
274
+ bucket.push(e3);
275
+ else
276
+ this.byTurnId.set(e3.turnId, [e3]);
277
+ }
278
+ }
227
279
  ofType(type) {
228
- return this.events.filter((e3) => e3.type === type);
280
+ if (!this.byType)
281
+ this.buildIndexes();
282
+ const bucket = this.byType.get(type);
283
+ return bucket ? [...bucket] : [];
229
284
  }
230
285
  byTurn(turnId) {
231
- return this.events.filter((e3) => e3.turnId === turnId);
286
+ if (!this.byTurnId)
287
+ this.buildIndexes();
288
+ const bucket = this.byTurnId.get(turnId);
289
+ return bucket ? [...bucket] : [];
232
290
  }
233
291
  toJSON() {
234
292
  return [...this.events];
@@ -236,6 +294,7 @@ var init_log = __esm({
236
294
  async append(partial) {
237
295
  const event = materializeEvent(partial, this.base + this.events.length, this.now);
238
296
  this.events.push(event);
297
+ this.indexEvent(event);
239
298
  const snapshot = [...this.listeners];
240
299
  for (const fn of snapshot) {
241
300
  try {
@@ -262,6 +321,7 @@ var init_log = __esm({
262
321
  if (event.seq !== this.base + this.events.length)
263
322
  return;
264
323
  this.events.push(event);
324
+ this.indexEvent(event);
265
325
  const snapshot = [...this.listeners];
266
326
  for (const fn of snapshot) {
267
327
  try {
@@ -300,9 +360,13 @@ var init_log = __esm({
300
360
  throw new Error(`EventLog.rebase(${seq}): seq must be a non-negative integer`);
301
361
  }
302
362
  this.base = seq;
363
+ this.byType = null;
364
+ this.byTurnId = null;
303
365
  }
304
366
  clear() {
305
367
  this.events.length = 0;
368
+ this.byType = null;
369
+ this.byTurnId = null;
306
370
  this.base = 0;
307
371
  const snapshot = [...this.clearListeners];
308
372
  for (const fn of snapshot) {
@@ -820,7 +884,7 @@ async function* runTurn(session, prompt, opts = {}) {
820
884
  yield queue.shift();
821
885
  if (done)
822
886
  break;
823
- await new Promise((resolve13) => waiters.push(resolve13));
887
+ await new Promise((resolve12) => waiters.push(resolve12));
824
888
  }
825
889
  } finally {
826
890
  unsubscribe();
@@ -2224,6 +2288,18 @@ var init_host2 = __esm({
2224
2288
  dataListeners = /* @__PURE__ */ new Set();
2225
2289
  /** In-flight opens, so concurrent `open(kind)` calls share one instance. */
2226
2290
  opening = /* @__PURE__ */ new Map();
2291
+ /**
2292
+ * Viewer attach count per kind. A surface is SHARED (the agent's tool + every
2293
+ * attached viewer drive the same PTY/page), so `open` retains and `close`
2294
+ * releases; the instance is only torn down when the last viewer detaches.
2295
+ * Without this, a single viewer's `close` would destroy the resource out from
2296
+ * under the others — and React StrictMode (dev) makes that routine: it
2297
+ * mounts → unmounts → remounts, so the first mount's late-resolving `open`
2298
+ * closes the very instance the remount just attached to, leaving `input`/
2299
+ * `resize` to hit a now-missing instance (output still flows from the
2300
+ * snapshot, but keystrokes/navigation silently vanish).
2301
+ */
2302
+ refs = /* @__PURE__ */ new Map();
2227
2303
  constructor(registry, ctx, logger) {
2228
2304
  this.registry = registry;
2229
2305
  this.ctx = ctx;
@@ -2256,28 +2332,25 @@ var init_host2 = __esm({
2256
2332
  async open(kind3) {
2257
2333
  const existing = this.instances.get(kind3);
2258
2334
  if (existing) {
2259
- return {
2260
- surfaceId: existing.id,
2261
- kind: existing.kind,
2262
- ...existing.snapshot ? { snapshot: existing.snapshot() } : {}
2263
- };
2335
+ this.retain(kind3);
2336
+ return this.describe(existing);
2264
2337
  }
2265
2338
  const pending2 = this.opening.get(kind3);
2266
- if (pending2)
2267
- return pending2;
2339
+ if (pending2) {
2340
+ const res = await pending2;
2341
+ this.retain(kind3);
2342
+ return res;
2343
+ }
2268
2344
  const def = this.registry.get(kind3);
2269
2345
  if (!def)
2270
2346
  throw new Error(`No surface registered for kind: ${kind3}`);
2271
2347
  const promise = (async () => {
2272
2348
  const instance = await def.open(this.ctx);
2273
2349
  this.instances.set(kind3, instance);
2350
+ this.refs.set(kind3, 1);
2274
2351
  const unsub = instance.onData((payload) => this.emit({ surfaceId: instance.id, kind: instance.kind, payload }));
2275
2352
  this.unsubs.set(instance.id, unsub);
2276
- return {
2277
- surfaceId: instance.id,
2278
- kind: instance.kind,
2279
- ...instance.snapshot ? { snapshot: instance.snapshot() } : {}
2280
- };
2353
+ return this.describe(instance);
2281
2354
  })();
2282
2355
  this.opening.set(kind3, promise);
2283
2356
  try {
@@ -2302,9 +2375,16 @@ var init_host2 = __esm({
2302
2375
  const instance = this.byId(surfaceId);
2303
2376
  if (!instance)
2304
2377
  return;
2378
+ const kind3 = instance.kind;
2379
+ const remaining = (this.refs.get(kind3) ?? 1) - 1;
2380
+ if (remaining > 0) {
2381
+ this.refs.set(kind3, remaining);
2382
+ return;
2383
+ }
2384
+ this.refs.delete(kind3);
2305
2385
  this.unsubs.get(surfaceId)?.();
2306
2386
  this.unsubs.delete(surfaceId);
2307
- this.instances.delete(instance.kind);
2387
+ this.instances.delete(kind3);
2308
2388
  try {
2309
2389
  await instance.close();
2310
2390
  } catch (err) {
@@ -2314,11 +2394,24 @@ var init_host2 = __esm({
2314
2394
  });
2315
2395
  }
2316
2396
  }
2397
+ /** Bump the viewer attach count for an already-open kind. */
2398
+ retain(kind3) {
2399
+ this.refs.set(kind3, (this.refs.get(kind3) ?? 0) + 1);
2400
+ }
2401
+ describe(instance) {
2402
+ return {
2403
+ surfaceId: instance.id,
2404
+ kind: instance.kind,
2405
+ ...instance.snapshot ? { snapshot: instance.snapshot() } : {}
2406
+ };
2407
+ }
2317
2408
  onData(cb) {
2318
2409
  this.dataListeners.add(cb);
2319
2410
  return () => this.dataListeners.delete(cb);
2320
2411
  }
2321
2412
  async closeAll() {
2413
+ for (const kind3 of [...this.instances.keys()])
2414
+ this.refs.set(kind3, 1);
2322
2415
  const ids = [...this.unsubs.keys()];
2323
2416
  for (const id of ids)
2324
2417
  await this.close(id);
@@ -2474,8 +2567,8 @@ var init_tools2 = __esm({
2474
2567
  const parseResult = tool.inputSchema.safeParse(input);
2475
2568
  if (!parseResult.success) {
2476
2569
  const issues = parseResult.error.issues.map((iss) => {
2477
- const path60 = iss.path.length ? iss.path.join(".") : "(root)";
2478
- return `${path60}: ${iss.message}`;
2570
+ const path59 = iss.path.length ? iss.path.join(".") : "(root)";
2571
+ return `${path59}: ${iss.message}`;
2479
2572
  }).join("; ");
2480
2573
  throw new Error(`Invalid input for ${name}: ${issues}`);
2481
2574
  }
@@ -3447,8 +3540,6 @@ var init_session = __esm({
3447
3540
  activeSynthesizer: this.synthesizers.getActiveName()
3448
3541
  };
3449
3542
  }
3450
- registerHookOptions(_hooks) {
3451
- }
3452
3543
  };
3453
3544
  }
3454
3545
  });
@@ -3960,6 +4051,14 @@ var init_persistence = __esm({
3960
4051
  * can flush.
3961
4052
  */
3962
4053
  writeQueue = createMutex();
4054
+ /**
4055
+ * Memoized one-time setup: `mkdir -p` the sessions dir and create the empty
4056
+ * `.jsonl` (so resume lists the session before any event). Awaited by both
4057
+ * `attach` and `writeIndex` so an early debounced index flush can't race the
4058
+ * initial creation — but it runs the open+close syscalls ONCE, not on every
4059
+ * 250ms flush as before.
4060
+ */
4061
+ ready = null;
3963
4062
  closed = false;
3964
4063
  logger;
3965
4064
  /**
@@ -3997,7 +4096,7 @@ var init_persistence = __esm({
3997
4096
  * reuses the same Session object.
3998
4097
  */
3999
4098
  attach(log) {
4000
- void this.ensureDir().then(() => this.ensureLogFile()).then(() => this.scheduleIndexWrite()).catch(() => void 0);
4099
+ void this.ensureReady().then(() => this.scheduleIndexWrite()).catch(() => void 0);
4001
4100
  const unsub = log.subscribe((event) => {
4002
4101
  if (this.closed)
4003
4102
  return;
@@ -4112,19 +4211,27 @@ var init_persistence = __esm({
4112
4211
  async writeIndex() {
4113
4212
  try {
4114
4213
  if (!this.closed) {
4115
- await this.ensureDir();
4116
- await this.ensureLogFile();
4214
+ await this.ensureReady();
4117
4215
  }
4118
4216
  await writeJsonAtomic(metaPath(this.dir, this.meta.id), this.meta);
4119
4217
  } catch {
4120
4218
  }
4121
4219
  }
4122
- async ensureDir() {
4123
- await promises.mkdir(this.dir, { recursive: true });
4124
- }
4125
- async ensureLogFile() {
4126
- const handle2 = await promises.open(this.logPath, "a");
4127
- await handle2.close();
4220
+ /** One-time, memoized: `mkdir -p` the dir + create the empty `.jsonl`. On
4221
+ * failure the latch is cleared so a later flush retries (matching the old
4222
+ * per-write ensureDir/ensureLogFile recoverability). */
4223
+ ensureReady() {
4224
+ if (!this.ready) {
4225
+ this.ready = (async () => {
4226
+ await promises.mkdir(this.dir, { recursive: true });
4227
+ const handle2 = await promises.open(this.logPath, "a");
4228
+ await handle2.close();
4229
+ })().catch((err) => {
4230
+ this.ready = null;
4231
+ throw err;
4232
+ });
4233
+ }
4234
+ return this.ready;
4128
4235
  }
4129
4236
  };
4130
4237
  }
@@ -8297,17 +8404,17 @@ var require_visit = __commonJS({
8297
8404
  visit.BREAK = BREAK;
8298
8405
  visit.SKIP = SKIP;
8299
8406
  visit.REMOVE = REMOVE;
8300
- function visit_(key, node, visitor, path60) {
8301
- const ctrl = callVisitor(key, node, visitor, path60);
8407
+ function visit_(key, node, visitor, path59) {
8408
+ const ctrl = callVisitor(key, node, visitor, path59);
8302
8409
  if (identity.isNode(ctrl) || identity.isPair(ctrl)) {
8303
- replaceNode(key, path60, ctrl);
8304
- return visit_(key, ctrl, visitor, path60);
8410
+ replaceNode(key, path59, ctrl);
8411
+ return visit_(key, ctrl, visitor, path59);
8305
8412
  }
8306
8413
  if (typeof ctrl !== "symbol") {
8307
8414
  if (identity.isCollection(node)) {
8308
- path60 = Object.freeze(path60.concat(node));
8415
+ path59 = Object.freeze(path59.concat(node));
8309
8416
  for (let i2 = 0; i2 < node.items.length; ++i2) {
8310
- const ci = visit_(i2, node.items[i2], visitor, path60);
8417
+ const ci = visit_(i2, node.items[i2], visitor, path59);
8311
8418
  if (typeof ci === "number")
8312
8419
  i2 = ci - 1;
8313
8420
  else if (ci === BREAK)
@@ -8318,13 +8425,13 @@ var require_visit = __commonJS({
8318
8425
  }
8319
8426
  }
8320
8427
  } else if (identity.isPair(node)) {
8321
- path60 = Object.freeze(path60.concat(node));
8322
- const ck = visit_("key", node.key, visitor, path60);
8428
+ path59 = Object.freeze(path59.concat(node));
8429
+ const ck = visit_("key", node.key, visitor, path59);
8323
8430
  if (ck === BREAK)
8324
8431
  return BREAK;
8325
8432
  else if (ck === REMOVE)
8326
8433
  node.key = null;
8327
- const cv = visit_("value", node.value, visitor, path60);
8434
+ const cv = visit_("value", node.value, visitor, path59);
8328
8435
  if (cv === BREAK)
8329
8436
  return BREAK;
8330
8437
  else if (cv === REMOVE)
@@ -8345,17 +8452,17 @@ var require_visit = __commonJS({
8345
8452
  visitAsync.BREAK = BREAK;
8346
8453
  visitAsync.SKIP = SKIP;
8347
8454
  visitAsync.REMOVE = REMOVE;
8348
- async function visitAsync_(key, node, visitor, path60) {
8349
- const ctrl = await callVisitor(key, node, visitor, path60);
8455
+ async function visitAsync_(key, node, visitor, path59) {
8456
+ const ctrl = await callVisitor(key, node, visitor, path59);
8350
8457
  if (identity.isNode(ctrl) || identity.isPair(ctrl)) {
8351
- replaceNode(key, path60, ctrl);
8352
- return visitAsync_(key, ctrl, visitor, path60);
8458
+ replaceNode(key, path59, ctrl);
8459
+ return visitAsync_(key, ctrl, visitor, path59);
8353
8460
  }
8354
8461
  if (typeof ctrl !== "symbol") {
8355
8462
  if (identity.isCollection(node)) {
8356
- path60 = Object.freeze(path60.concat(node));
8463
+ path59 = Object.freeze(path59.concat(node));
8357
8464
  for (let i2 = 0; i2 < node.items.length; ++i2) {
8358
- const ci = await visitAsync_(i2, node.items[i2], visitor, path60);
8465
+ const ci = await visitAsync_(i2, node.items[i2], visitor, path59);
8359
8466
  if (typeof ci === "number")
8360
8467
  i2 = ci - 1;
8361
8468
  else if (ci === BREAK)
@@ -8366,13 +8473,13 @@ var require_visit = __commonJS({
8366
8473
  }
8367
8474
  }
8368
8475
  } else if (identity.isPair(node)) {
8369
- path60 = Object.freeze(path60.concat(node));
8370
- const ck = await visitAsync_("key", node.key, visitor, path60);
8476
+ path59 = Object.freeze(path59.concat(node));
8477
+ const ck = await visitAsync_("key", node.key, visitor, path59);
8371
8478
  if (ck === BREAK)
8372
8479
  return BREAK;
8373
8480
  else if (ck === REMOVE)
8374
8481
  node.key = null;
8375
- const cv = await visitAsync_("value", node.value, visitor, path60);
8482
+ const cv = await visitAsync_("value", node.value, visitor, path59);
8376
8483
  if (cv === BREAK)
8377
8484
  return BREAK;
8378
8485
  else if (cv === REMOVE)
@@ -8399,23 +8506,23 @@ var require_visit = __commonJS({
8399
8506
  }
8400
8507
  return visitor;
8401
8508
  }
8402
- function callVisitor(key, node, visitor, path60) {
8509
+ function callVisitor(key, node, visitor, path59) {
8403
8510
  if (typeof visitor === "function")
8404
- return visitor(key, node, path60);
8511
+ return visitor(key, node, path59);
8405
8512
  if (identity.isMap(node))
8406
- return visitor.Map?.(key, node, path60);
8513
+ return visitor.Map?.(key, node, path59);
8407
8514
  if (identity.isSeq(node))
8408
- return visitor.Seq?.(key, node, path60);
8515
+ return visitor.Seq?.(key, node, path59);
8409
8516
  if (identity.isPair(node))
8410
- return visitor.Pair?.(key, node, path60);
8517
+ return visitor.Pair?.(key, node, path59);
8411
8518
  if (identity.isScalar(node))
8412
- return visitor.Scalar?.(key, node, path60);
8519
+ return visitor.Scalar?.(key, node, path59);
8413
8520
  if (identity.isAlias(node))
8414
- return visitor.Alias?.(key, node, path60);
8521
+ return visitor.Alias?.(key, node, path59);
8415
8522
  return void 0;
8416
8523
  }
8417
- function replaceNode(key, path60, node) {
8418
- const parent = path60[path60.length - 1];
8524
+ function replaceNode(key, path59, node) {
8525
+ const parent = path59[path59.length - 1];
8419
8526
  if (identity.isCollection(parent)) {
8420
8527
  parent.items[key] = node;
8421
8528
  } else if (identity.isPair(parent)) {
@@ -9016,10 +9123,10 @@ var require_Collection = __commonJS({
9016
9123
  var createNode2 = require_createNode();
9017
9124
  var identity = require_identity();
9018
9125
  var Node = require_Node();
9019
- function collectionFromPath(schema, path60, value) {
9126
+ function collectionFromPath(schema, path59, value) {
9020
9127
  let v3 = value;
9021
- for (let i2 = path60.length - 1; i2 >= 0; --i2) {
9022
- const k3 = path60[i2];
9128
+ for (let i2 = path59.length - 1; i2 >= 0; --i2) {
9129
+ const k3 = path59[i2];
9023
9130
  if (typeof k3 === "number" && Number.isInteger(k3) && k3 >= 0) {
9024
9131
  const a2 = [];
9025
9132
  a2[k3] = v3;
@@ -9038,7 +9145,7 @@ var require_Collection = __commonJS({
9038
9145
  sourceObjects: /* @__PURE__ */ new Map()
9039
9146
  });
9040
9147
  }
9041
- var isEmptyPath = (path60) => path60 == null || typeof path60 === "object" && !!path60[Symbol.iterator]().next().done;
9148
+ var isEmptyPath = (path59) => path59 == null || typeof path59 === "object" && !!path59[Symbol.iterator]().next().done;
9042
9149
  var Collection = class extends Node.NodeBase {
9043
9150
  constructor(type, schema) {
9044
9151
  super(type);
@@ -9068,11 +9175,11 @@ var require_Collection = __commonJS({
9068
9175
  * be a Pair instance or a `{ key, value }` object, which may not have a key
9069
9176
  * that already exists in the map.
9070
9177
  */
9071
- addIn(path60, value) {
9072
- if (isEmptyPath(path60))
9178
+ addIn(path59, value) {
9179
+ if (isEmptyPath(path59))
9073
9180
  this.add(value);
9074
9181
  else {
9075
- const [key, ...rest] = path60;
9182
+ const [key, ...rest] = path59;
9076
9183
  const node = this.get(key, true);
9077
9184
  if (identity.isCollection(node))
9078
9185
  node.addIn(rest, value);
@@ -9086,8 +9193,8 @@ var require_Collection = __commonJS({
9086
9193
  * Removes a value from the collection.
9087
9194
  * @returns `true` if the item was found and removed.
9088
9195
  */
9089
- deleteIn(path60) {
9090
- const [key, ...rest] = path60;
9196
+ deleteIn(path59) {
9197
+ const [key, ...rest] = path59;
9091
9198
  if (rest.length === 0)
9092
9199
  return this.delete(key);
9093
9200
  const node = this.get(key, true);
@@ -9101,8 +9208,8 @@ var require_Collection = __commonJS({
9101
9208
  * scalar values from their surrounding node; to disable set `keepScalar` to
9102
9209
  * `true` (collections are always returned intact).
9103
9210
  */
9104
- getIn(path60, keepScalar) {
9105
- const [key, ...rest] = path60;
9211
+ getIn(path59, keepScalar) {
9212
+ const [key, ...rest] = path59;
9106
9213
  const node = this.get(key, true);
9107
9214
  if (rest.length === 0)
9108
9215
  return !keepScalar && identity.isScalar(node) ? node.value : node;
@@ -9120,8 +9227,8 @@ var require_Collection = __commonJS({
9120
9227
  /**
9121
9228
  * Checks if the collection includes a value with the key `key`.
9122
9229
  */
9123
- hasIn(path60) {
9124
- const [key, ...rest] = path60;
9230
+ hasIn(path59) {
9231
+ const [key, ...rest] = path59;
9125
9232
  if (rest.length === 0)
9126
9233
  return this.has(key);
9127
9234
  const node = this.get(key, true);
@@ -9131,8 +9238,8 @@ var require_Collection = __commonJS({
9131
9238
  * Sets a value in this collection. For `!!set`, `value` needs to be a
9132
9239
  * boolean to add/remove the item from the set.
9133
9240
  */
9134
- setIn(path60, value) {
9135
- const [key, ...rest] = path60;
9241
+ setIn(path59, value) {
9242
+ const [key, ...rest] = path59;
9136
9243
  if (rest.length === 0) {
9137
9244
  this.set(key, value);
9138
9245
  } else {
@@ -11612,9 +11719,9 @@ var require_Document = __commonJS({
11612
11719
  this.contents.add(value);
11613
11720
  }
11614
11721
  /** Adds a value to the document. */
11615
- addIn(path60, value) {
11722
+ addIn(path59, value) {
11616
11723
  if (assertCollection(this.contents))
11617
- this.contents.addIn(path60, value);
11724
+ this.contents.addIn(path59, value);
11618
11725
  }
11619
11726
  /**
11620
11727
  * Create a new `Alias` node, ensuring that the target `node` has the required anchor.
@@ -11689,14 +11796,14 @@ var require_Document = __commonJS({
11689
11796
  * Removes a value from the document.
11690
11797
  * @returns `true` if the item was found and removed.
11691
11798
  */
11692
- deleteIn(path60) {
11693
- if (Collection.isEmptyPath(path60)) {
11799
+ deleteIn(path59) {
11800
+ if (Collection.isEmptyPath(path59)) {
11694
11801
  if (this.contents == null)
11695
11802
  return false;
11696
11803
  this.contents = null;
11697
11804
  return true;
11698
11805
  }
11699
- return assertCollection(this.contents) ? this.contents.deleteIn(path60) : false;
11806
+ return assertCollection(this.contents) ? this.contents.deleteIn(path59) : false;
11700
11807
  }
11701
11808
  /**
11702
11809
  * Returns item at `key`, or `undefined` if not found. By default unwraps
@@ -11711,10 +11818,10 @@ var require_Document = __commonJS({
11711
11818
  * scalar values from their surrounding node; to disable set `keepScalar` to
11712
11819
  * `true` (collections are always returned intact).
11713
11820
  */
11714
- getIn(path60, keepScalar) {
11715
- if (Collection.isEmptyPath(path60))
11821
+ getIn(path59, keepScalar) {
11822
+ if (Collection.isEmptyPath(path59))
11716
11823
  return !keepScalar && identity.isScalar(this.contents) ? this.contents.value : this.contents;
11717
- return identity.isCollection(this.contents) ? this.contents.getIn(path60, keepScalar) : void 0;
11824
+ return identity.isCollection(this.contents) ? this.contents.getIn(path59, keepScalar) : void 0;
11718
11825
  }
11719
11826
  /**
11720
11827
  * Checks if the document includes a value with the key `key`.
@@ -11725,10 +11832,10 @@ var require_Document = __commonJS({
11725
11832
  /**
11726
11833
  * Checks if the document includes a value at `path`.
11727
11834
  */
11728
- hasIn(path60) {
11729
- if (Collection.isEmptyPath(path60))
11835
+ hasIn(path59) {
11836
+ if (Collection.isEmptyPath(path59))
11730
11837
  return this.contents !== void 0;
11731
- return identity.isCollection(this.contents) ? this.contents.hasIn(path60) : false;
11838
+ return identity.isCollection(this.contents) ? this.contents.hasIn(path59) : false;
11732
11839
  }
11733
11840
  /**
11734
11841
  * Sets a value in this document. For `!!set`, `value` needs to be a
@@ -11745,13 +11852,13 @@ var require_Document = __commonJS({
11745
11852
  * Sets a value in this document. For `!!set`, `value` needs to be a
11746
11853
  * boolean to add/remove the item from the set.
11747
11854
  */
11748
- setIn(path60, value) {
11749
- if (Collection.isEmptyPath(path60)) {
11855
+ setIn(path59, value) {
11856
+ if (Collection.isEmptyPath(path59)) {
11750
11857
  this.contents = value;
11751
11858
  } else if (this.contents == null) {
11752
- this.contents = Collection.collectionFromPath(this.schema, Array.from(path60), value);
11859
+ this.contents = Collection.collectionFromPath(this.schema, Array.from(path59), value);
11753
11860
  } else if (assertCollection(this.contents)) {
11754
- this.contents.setIn(path60, value);
11861
+ this.contents.setIn(path59, value);
11755
11862
  }
11756
11863
  }
11757
11864
  /**
@@ -13691,9 +13798,9 @@ var require_cst_visit = __commonJS({
13691
13798
  visit.BREAK = BREAK;
13692
13799
  visit.SKIP = SKIP;
13693
13800
  visit.REMOVE = REMOVE;
13694
- visit.itemAtPath = (cst, path60) => {
13801
+ visit.itemAtPath = (cst, path59) => {
13695
13802
  let item = cst;
13696
- for (const [field, index] of path60) {
13803
+ for (const [field, index] of path59) {
13697
13804
  const tok = item?.[field];
13698
13805
  if (tok && "items" in tok) {
13699
13806
  item = tok.items[index];
@@ -13702,23 +13809,23 @@ var require_cst_visit = __commonJS({
13702
13809
  }
13703
13810
  return item;
13704
13811
  };
13705
- visit.parentCollection = (cst, path60) => {
13706
- const parent = visit.itemAtPath(cst, path60.slice(0, -1));
13707
- const field = path60[path60.length - 1][0];
13812
+ visit.parentCollection = (cst, path59) => {
13813
+ const parent = visit.itemAtPath(cst, path59.slice(0, -1));
13814
+ const field = path59[path59.length - 1][0];
13708
13815
  const coll = parent?.[field];
13709
13816
  if (coll && "items" in coll)
13710
13817
  return coll;
13711
13818
  throw new Error("Parent collection not found");
13712
13819
  };
13713
- function _visit(path60, item, visitor) {
13714
- let ctrl = visitor(item, path60);
13820
+ function _visit(path59, item, visitor) {
13821
+ let ctrl = visitor(item, path59);
13715
13822
  if (typeof ctrl === "symbol")
13716
13823
  return ctrl;
13717
13824
  for (const field of ["key", "value"]) {
13718
13825
  const token = item[field];
13719
13826
  if (token && "items" in token) {
13720
13827
  for (let i2 = 0; i2 < token.items.length; ++i2) {
13721
- const ci = _visit(Object.freeze(path60.concat([[field, i2]])), token.items[i2], visitor);
13828
+ const ci = _visit(Object.freeze(path59.concat([[field, i2]])), token.items[i2], visitor);
13722
13829
  if (typeof ci === "number")
13723
13830
  i2 = ci - 1;
13724
13831
  else if (ci === BREAK)
@@ -13729,10 +13836,10 @@ var require_cst_visit = __commonJS({
13729
13836
  }
13730
13837
  }
13731
13838
  if (typeof ctrl === "function" && field === "key")
13732
- ctrl = ctrl(item, path60);
13839
+ ctrl = ctrl(item, path59);
13733
13840
  }
13734
13841
  }
13735
- return typeof ctrl === "function" ? ctrl(item, path60) : ctrl;
13842
+ return typeof ctrl === "function" ? ctrl(item, path59) : ctrl;
13736
13843
  }
13737
13844
  exports.visit = visit;
13738
13845
  }
@@ -16454,14 +16561,14 @@ var require_url_state_machine = __commonJS({
16454
16561
  return url2.replace(/\u0009|\u000A|\u000D/g, "");
16455
16562
  }
16456
16563
  function shortenPath(url2) {
16457
- const path60 = url2.path;
16458
- if (path60.length === 0) {
16564
+ const path59 = url2.path;
16565
+ if (path59.length === 0) {
16459
16566
  return;
16460
16567
  }
16461
- if (url2.scheme === "file" && path60.length === 1 && isNormalizedWindowsDriveLetter(path60[0])) {
16568
+ if (url2.scheme === "file" && path59.length === 1 && isNormalizedWindowsDriveLetter(path59[0])) {
16462
16569
  return;
16463
16570
  }
16464
- path60.pop();
16571
+ path59.pop();
16465
16572
  }
16466
16573
  function includesCredentials(url2) {
16467
16574
  return url2.username !== "" || url2.password !== "";
@@ -21228,7 +21335,7 @@ function consumeBody() {
21228
21335
  let accum = [];
21229
21336
  let accumBytes = 0;
21230
21337
  let abort = false;
21231
- return new Body.Promise(function(resolve13, reject) {
21338
+ return new Body.Promise(function(resolve12, reject) {
21232
21339
  let resTimeout;
21233
21340
  if (_this4.timeout) {
21234
21341
  resTimeout = setTimeout(function() {
@@ -21262,7 +21369,7 @@ function consumeBody() {
21262
21369
  }
21263
21370
  clearTimeout(resTimeout);
21264
21371
  try {
21265
- resolve13(Buffer.concat(accum, accumBytes));
21372
+ resolve12(Buffer.concat(accum, accumBytes));
21266
21373
  } catch (err) {
21267
21374
  reject(new FetchError(`Could not create Buffer from response body for ${_this4.url}: ${err.message}`, "system", err));
21268
21375
  }
@@ -21525,7 +21632,7 @@ function fetch3(url2, opts) {
21525
21632
  throw new Error("native promise missing, set fetch.Promise to your favorite alternative");
21526
21633
  }
21527
21634
  Body.Promise = fetch3.Promise;
21528
- return new fetch3.Promise(function(resolve13, reject) {
21635
+ return new fetch3.Promise(function(resolve12, reject) {
21529
21636
  const request = new Request2(url2, opts);
21530
21637
  const options = getNodeRequestOptions(request);
21531
21638
  const send = (options.protocol === "https:" ? https : http).request;
@@ -21658,7 +21765,7 @@ function fetch3(url2, opts) {
21658
21765
  requestOpts.body = void 0;
21659
21766
  requestOpts.headers.delete("content-length");
21660
21767
  }
21661
- resolve13(fetch3(new Request2(locationURL, requestOpts)));
21768
+ resolve12(fetch3(new Request2(locationURL, requestOpts)));
21662
21769
  finalize();
21663
21770
  return;
21664
21771
  }
@@ -21679,7 +21786,7 @@ function fetch3(url2, opts) {
21679
21786
  const codings = headers.get("Content-Encoding");
21680
21787
  if (!request.compress || request.method === "HEAD" || codings === null || res.statusCode === 204 || res.statusCode === 304) {
21681
21788
  response = new Response3(body, response_options);
21682
- resolve13(response);
21789
+ resolve12(response);
21683
21790
  return;
21684
21791
  }
21685
21792
  const zlibOptions = {
@@ -21689,7 +21796,7 @@ function fetch3(url2, opts) {
21689
21796
  if (codings == "gzip" || codings == "x-gzip") {
21690
21797
  body = body.pipe(zlib.createGunzip(zlibOptions));
21691
21798
  response = new Response3(body, response_options);
21692
- resolve13(response);
21799
+ resolve12(response);
21693
21800
  return;
21694
21801
  }
21695
21802
  if (codings == "deflate" || codings == "x-deflate") {
@@ -21701,12 +21808,12 @@ function fetch3(url2, opts) {
21701
21808
  body = body.pipe(zlib.createInflateRaw());
21702
21809
  }
21703
21810
  response = new Response3(body, response_options);
21704
- resolve13(response);
21811
+ resolve12(response);
21705
21812
  });
21706
21813
  raw.on("end", function() {
21707
21814
  if (!response) {
21708
21815
  response = new Response3(body, response_options);
21709
- resolve13(response);
21816
+ resolve12(response);
21710
21817
  }
21711
21818
  });
21712
21819
  return;
@@ -21714,11 +21821,11 @@ function fetch3(url2, opts) {
21714
21821
  if (codings == "br" && typeof zlib.createBrotliDecompress === "function") {
21715
21822
  body = body.pipe(zlib.createBrotliDecompress());
21716
21823
  response = new Response3(body, response_options);
21717
- resolve13(response);
21824
+ resolve12(response);
21718
21825
  return;
21719
21826
  }
21720
21827
  response = new Response3(body, response_options);
21721
- resolve13(response);
21828
+ resolve12(response);
21722
21829
  });
21723
21830
  writeToStream(req, request);
21724
21831
  });
@@ -25684,14 +25791,14 @@ __export(fileFromPath_exports, {
25684
25791
  fileFromPathSync: () => fileFromPathSync,
25685
25792
  isFile: () => isFile
25686
25793
  });
25687
- function createFileFromPath(path60, { mtimeMs, size }, filenameOrOptions, options = {}) {
25794
+ function createFileFromPath(path59, { mtimeMs, size }, filenameOrOptions, options = {}) {
25688
25795
  let filename;
25689
25796
  if (isPlainObject_default2(filenameOrOptions)) {
25690
25797
  [options, filename] = [filenameOrOptions, void 0];
25691
25798
  } else {
25692
25799
  filename = filenameOrOptions;
25693
25800
  }
25694
- const file = new FileFromPath({ path: path60, size, lastModified: mtimeMs });
25801
+ const file = new FileFromPath({ path: path59, size, lastModified: mtimeMs });
25695
25802
  if (!filename) {
25696
25803
  filename = file.name;
25697
25804
  }
@@ -25700,13 +25807,13 @@ function createFileFromPath(path60, { mtimeMs, size }, filenameOrOptions, option
25700
25807
  lastModified: file.lastModified
25701
25808
  });
25702
25809
  }
25703
- function fileFromPathSync(path60, filenameOrOptions, options = {}) {
25704
- const stats = statSync(path60);
25705
- return createFileFromPath(path60, stats, filenameOrOptions, options);
25810
+ function fileFromPathSync(path59, filenameOrOptions, options = {}) {
25811
+ const stats = statSync(path59);
25812
+ return createFileFromPath(path59, stats, filenameOrOptions, options);
25706
25813
  }
25707
- async function fileFromPath2(path60, filenameOrOptions, options) {
25708
- const stats = await promises.stat(path60);
25709
- return createFileFromPath(path60, stats, filenameOrOptions, options);
25814
+ async function fileFromPath2(path59, filenameOrOptions, options) {
25815
+ const stats = await promises.stat(path59);
25816
+ return createFileFromPath(path59, stats, filenameOrOptions, options);
25710
25817
  }
25711
25818
  var import_node_domexception, __classPrivateFieldSet4, __classPrivateFieldGet5, _FileFromPath_path, _FileFromPath_start, MESSAGE, FileFromPath;
25712
25819
  var init_fileFromPath = __esm({
@@ -35237,7 +35344,7 @@ var require_frameworks = __commonJS({
35237
35344
  end: () => resolveResponse({ status: 204 }),
35238
35345
  respond: (json) => resolveResponse({ jsonBody: json }),
35239
35346
  unauthorized: () => resolveResponse({ status: 401, body: WRONG_TOKEN_ERROR }),
35240
- handlerReturn: new Promise((resolve13) => resolveResponse = resolve13)
35347
+ handlerReturn: new Promise((resolve12) => resolveResponse = resolve12)
35241
35348
  };
35242
35349
  };
35243
35350
  var bun = (request) => {
@@ -35261,8 +35368,8 @@ var require_frameworks = __commonJS({
35261
35368
  };
35262
35369
  var cloudflare = (event) => {
35263
35370
  let resolveResponse;
35264
- event.respondWith(new Promise((resolve13) => {
35265
- resolveResponse = resolve13;
35371
+ event.respondWith(new Promise((resolve12) => {
35372
+ resolveResponse = resolve12;
35266
35373
  }));
35267
35374
  return {
35268
35375
  get update() {
@@ -35346,12 +35453,12 @@ var require_frameworks = __commonJS({
35346
35453
  const secretHeaderFromRequest = req.headers[SECRET_HEADER_LOWERCASE];
35347
35454
  return {
35348
35455
  get update() {
35349
- return new Promise((resolve13, reject) => {
35456
+ return new Promise((resolve12, reject) => {
35350
35457
  const chunks = [];
35351
35458
  req.on("data", (chunk) => chunks.push(chunk)).once("end", () => {
35352
35459
  const raw = Buffer.concat(chunks).toString("utf-8");
35353
35460
  try {
35354
- resolve13(JSON.parse(raw));
35461
+ resolve12(JSON.parse(raw));
35355
35462
  } catch (err) {
35356
35463
  reject(err);
35357
35464
  }
@@ -35601,7 +35708,7 @@ var require_webhook = __commonJS({
35601
35708
  function timeoutIfNecessary(task, onTimeout, timeout) {
35602
35709
  if (timeout === Infinity)
35603
35710
  return task;
35604
- return new Promise((resolve13, reject) => {
35711
+ return new Promise((resolve12, reject) => {
35605
35712
  const handle2 = setTimeout(() => {
35606
35713
  debugErr(`Request timed out after ${timeout} ms`);
35607
35714
  if (onTimeout === "throw") {
@@ -35609,7 +35716,7 @@ var require_webhook = __commonJS({
35609
35716
  } else {
35610
35717
  if (typeof onTimeout === "function")
35611
35718
  onTimeout();
35612
- resolve13();
35719
+ resolve12();
35613
35720
  }
35614
35721
  const now = Date.now();
35615
35722
  task.finally(() => {
@@ -35617,7 +35724,7 @@ var require_webhook = __commonJS({
35617
35724
  debugErr(`Request completed ${diff2} ms after timeout!`);
35618
35725
  });
35619
35726
  }, timeout);
35620
- task.then(resolve13).catch(reject).finally(() => clearTimeout(handle2));
35727
+ task.then(resolve12).catch(reject).finally(() => clearTimeout(handle2));
35621
35728
  });
35622
35729
  }
35623
35730
  }
@@ -38228,7 +38335,7 @@ var init_protocol = __esm({
38228
38335
  return;
38229
38336
  }
38230
38337
  const pollInterval = task2.pollInterval ?? this._options?.defaultTaskPollInterval ?? 1e3;
38231
- await new Promise((resolve13) => setTimeout(resolve13, pollInterval));
38338
+ await new Promise((resolve12) => setTimeout(resolve12, pollInterval));
38232
38339
  options?.signal?.throwIfAborted();
38233
38340
  }
38234
38341
  } catch (error2) {
@@ -38245,7 +38352,7 @@ var init_protocol = __esm({
38245
38352
  */
38246
38353
  request(request, resultSchema, options) {
38247
38354
  const { relatedRequestId, resumptionToken, onresumptiontoken, task, relatedTask } = options ?? {};
38248
- return new Promise((resolve13, reject) => {
38355
+ return new Promise((resolve12, reject) => {
38249
38356
  const earlyReject = (error2) => {
38250
38357
  reject(error2);
38251
38358
  };
@@ -38323,7 +38430,7 @@ var init_protocol = __esm({
38323
38430
  if (!parseResult.success) {
38324
38431
  reject(parseResult.error);
38325
38432
  } else {
38326
- resolve13(parseResult.data);
38433
+ resolve12(parseResult.data);
38327
38434
  }
38328
38435
  } catch (error2) {
38329
38436
  reject(error2);
@@ -38584,12 +38691,12 @@ var init_protocol = __esm({
38584
38691
  }
38585
38692
  } catch {
38586
38693
  }
38587
- return new Promise((resolve13, reject) => {
38694
+ return new Promise((resolve12, reject) => {
38588
38695
  if (signal.aborted) {
38589
38696
  reject(new McpError(ErrorCode.InvalidRequest, "Request cancelled"));
38590
38697
  return;
38591
38698
  }
38592
- const timeoutId = setTimeout(resolve13, interval);
38699
+ const timeoutId = setTimeout(resolve12, interval);
38593
38700
  signal.addEventListener("abort", () => {
38594
38701
  clearTimeout(timeoutId);
38595
38702
  reject(new McpError(ErrorCode.InvalidRequest, "Request cancelled"));
@@ -41594,7 +41701,7 @@ var require_compile = __commonJS({
41594
41701
  const schOrFunc = root.refs[ref];
41595
41702
  if (schOrFunc)
41596
41703
  return schOrFunc;
41597
- let _sch = resolve13.call(this, root, ref);
41704
+ let _sch = resolve12.call(this, root, ref);
41598
41705
  if (_sch === void 0) {
41599
41706
  const schema = (_a3 = root.localRefs) === null || _a3 === void 0 ? void 0 : _a3[ref];
41600
41707
  const { schemaId } = this.opts;
@@ -41621,7 +41728,7 @@ var require_compile = __commonJS({
41621
41728
  function sameSchemaEnv(s1, s2) {
41622
41729
  return s1.schema === s2.schema && s1.root === s2.root && s1.baseId === s2.baseId;
41623
41730
  }
41624
- function resolve13(root, ref) {
41731
+ function resolve12(root, ref) {
41625
41732
  let sch;
41626
41733
  while (typeof (sch = this.refs[ref]) == "string")
41627
41734
  ref = sch;
@@ -41838,8 +41945,8 @@ var require_utils2 = __commonJS({
41838
41945
  }
41839
41946
  return ind;
41840
41947
  }
41841
- function removeDotSegments(path60) {
41842
- let input = path60;
41948
+ function removeDotSegments(path59) {
41949
+ let input = path59;
41843
41950
  const output = [];
41844
41951
  let nextSlash = -1;
41845
41952
  let len = 0;
@@ -42090,8 +42197,8 @@ var require_schemes = __commonJS({
42090
42197
  wsComponent.secure = void 0;
42091
42198
  }
42092
42199
  if (wsComponent.resourceName) {
42093
- const [path60, query] = wsComponent.resourceName.split("?");
42094
- wsComponent.path = path60 && path60 !== "/" ? path60 : void 0;
42200
+ const [path59, query] = wsComponent.resourceName.split("?");
42201
+ wsComponent.path = path59 && path59 !== "/" ? path59 : void 0;
42095
42202
  wsComponent.query = query;
42096
42203
  wsComponent.resourceName = void 0;
42097
42204
  }
@@ -42249,7 +42356,7 @@ var require_fast_uri = __commonJS({
42249
42356
  }
42250
42357
  return uri;
42251
42358
  }
42252
- function resolve13(baseURI, relativeURI, options) {
42359
+ function resolve12(baseURI, relativeURI, options) {
42253
42360
  const schemelessOptions = options ? Object.assign({ scheme: "null" }, options) : { scheme: "null" };
42254
42361
  const resolved = resolveComponent(parse2(baseURI, schemelessOptions), parse2(relativeURI, schemelessOptions), schemelessOptions, true);
42255
42362
  schemelessOptions.skipEscape = true;
@@ -42507,7 +42614,7 @@ var require_fast_uri = __commonJS({
42507
42614
  var fastUri = {
42508
42615
  SCHEMES,
42509
42616
  normalize: normalize4,
42510
- resolve: resolve13,
42617
+ resolve: resolve12,
42511
42618
  resolveComponent,
42512
42619
  equal,
42513
42620
  serialize,
@@ -46249,7 +46356,7 @@ var require_windows = __commonJS({
46249
46356
  module.exports = isexe;
46250
46357
  isexe.sync = sync;
46251
46358
  var fs45 = __require("fs");
46252
- function checkPathExt(path60, options) {
46359
+ function checkPathExt(path59, options) {
46253
46360
  var pathext = options.pathExt !== void 0 ? options.pathExt : process.env.PATHEXT;
46254
46361
  if (!pathext) {
46255
46362
  return true;
@@ -46260,25 +46367,25 @@ var require_windows = __commonJS({
46260
46367
  }
46261
46368
  for (var i2 = 0; i2 < pathext.length; i2++) {
46262
46369
  var p3 = pathext[i2].toLowerCase();
46263
- if (p3 && path60.substr(-p3.length).toLowerCase() === p3) {
46370
+ if (p3 && path59.substr(-p3.length).toLowerCase() === p3) {
46264
46371
  return true;
46265
46372
  }
46266
46373
  }
46267
46374
  return false;
46268
46375
  }
46269
- function checkStat(stat2, path60, options) {
46376
+ function checkStat(stat2, path59, options) {
46270
46377
  if (!stat2.isSymbolicLink() && !stat2.isFile()) {
46271
46378
  return false;
46272
46379
  }
46273
- return checkPathExt(path60, options);
46380
+ return checkPathExt(path59, options);
46274
46381
  }
46275
- function isexe(path60, options, cb) {
46276
- fs45.stat(path60, function(er2, stat2) {
46277
- cb(er2, er2 ? false : checkStat(stat2, path60, options));
46382
+ function isexe(path59, options, cb) {
46383
+ fs45.stat(path59, function(er2, stat2) {
46384
+ cb(er2, er2 ? false : checkStat(stat2, path59, options));
46278
46385
  });
46279
46386
  }
46280
- function sync(path60, options) {
46281
- return checkStat(fs45.statSync(path60), path60, options);
46387
+ function sync(path59, options) {
46388
+ return checkStat(fs45.statSync(path59), path59, options);
46282
46389
  }
46283
46390
  }
46284
46391
  });
@@ -46289,13 +46396,13 @@ var require_mode = __commonJS({
46289
46396
  module.exports = isexe;
46290
46397
  isexe.sync = sync;
46291
46398
  var fs45 = __require("fs");
46292
- function isexe(path60, options, cb) {
46293
- fs45.stat(path60, function(er2, stat2) {
46399
+ function isexe(path59, options, cb) {
46400
+ fs45.stat(path59, function(er2, stat2) {
46294
46401
  cb(er2, er2 ? false : checkStat(stat2, options));
46295
46402
  });
46296
46403
  }
46297
- function sync(path60, options) {
46298
- return checkStat(fs45.statSync(path60), options);
46404
+ function sync(path59, options) {
46405
+ return checkStat(fs45.statSync(path59), options);
46299
46406
  }
46300
46407
  function checkStat(stat2, options) {
46301
46408
  return stat2.isFile() && checkMode(stat2, options);
@@ -46328,7 +46435,7 @@ var require_isexe = __commonJS({
46328
46435
  }
46329
46436
  module.exports = isexe;
46330
46437
  isexe.sync = sync;
46331
- function isexe(path60, options, cb) {
46438
+ function isexe(path59, options, cb) {
46332
46439
  if (typeof options === "function") {
46333
46440
  cb = options;
46334
46441
  options = {};
@@ -46337,17 +46444,17 @@ var require_isexe = __commonJS({
46337
46444
  if (typeof Promise !== "function") {
46338
46445
  throw new TypeError("callback not provided");
46339
46446
  }
46340
- return new Promise(function(resolve13, reject) {
46341
- isexe(path60, options || {}, function(er2, is) {
46447
+ return new Promise(function(resolve12, reject) {
46448
+ isexe(path59, options || {}, function(er2, is) {
46342
46449
  if (er2) {
46343
46450
  reject(er2);
46344
46451
  } else {
46345
- resolve13(is);
46452
+ resolve12(is);
46346
46453
  }
46347
46454
  });
46348
46455
  });
46349
46456
  }
46350
- core(path60, options || {}, function(er2, is) {
46457
+ core(path59, options || {}, function(er2, is) {
46351
46458
  if (er2) {
46352
46459
  if (er2.code === "EACCES" || options && options.ignoreErrors) {
46353
46460
  er2 = null;
@@ -46357,9 +46464,9 @@ var require_isexe = __commonJS({
46357
46464
  cb(er2, is);
46358
46465
  });
46359
46466
  }
46360
- function sync(path60, options) {
46467
+ function sync(path59, options) {
46361
46468
  try {
46362
- return core.sync(path60, options || {});
46469
+ return core.sync(path59, options || {});
46363
46470
  } catch (er2) {
46364
46471
  if (options && options.ignoreErrors || er2.code === "EACCES") {
46365
46472
  return false;
@@ -46375,7 +46482,7 @@ var require_isexe = __commonJS({
46375
46482
  var require_which = __commonJS({
46376
46483
  "../../node_modules/.pnpm/which@2.0.2/node_modules/which/which.js"(exports, module) {
46377
46484
  var isWindows3 = process.platform === "win32" || process.env.OSTYPE === "cygwin" || process.env.OSTYPE === "msys";
46378
- var path60 = __require("path");
46485
+ var path59 = __require("path");
46379
46486
  var COLON = isWindows3 ? ";" : ":";
46380
46487
  var isexe = require_isexe();
46381
46488
  var getNotFoundError = (cmd) => Object.assign(new Error(`not found: ${cmd}`), { code: "ENOENT" });
@@ -46408,27 +46515,27 @@ var require_which = __commonJS({
46408
46515
  opt = {};
46409
46516
  const { pathEnv, pathExt, pathExtExe } = getPathInfo(cmd, opt);
46410
46517
  const found = [];
46411
- const step = (i2) => new Promise((resolve13, reject) => {
46518
+ const step = (i2) => new Promise((resolve12, reject) => {
46412
46519
  if (i2 === pathEnv.length)
46413
- return opt.all && found.length ? resolve13(found) : reject(getNotFoundError(cmd));
46520
+ return opt.all && found.length ? resolve12(found) : reject(getNotFoundError(cmd));
46414
46521
  const ppRaw = pathEnv[i2];
46415
46522
  const pathPart = /^".*"$/.test(ppRaw) ? ppRaw.slice(1, -1) : ppRaw;
46416
- const pCmd = path60.join(pathPart, cmd);
46523
+ const pCmd = path59.join(pathPart, cmd);
46417
46524
  const p3 = !pathPart && /^\.[\\\/]/.test(cmd) ? cmd.slice(0, 2) + pCmd : pCmd;
46418
- resolve13(subStep(p3, i2, 0));
46525
+ resolve12(subStep(p3, i2, 0));
46419
46526
  });
46420
- const subStep = (p3, i2, ii) => new Promise((resolve13, reject) => {
46527
+ const subStep = (p3, i2, ii) => new Promise((resolve12, reject) => {
46421
46528
  if (ii === pathExt.length)
46422
- return resolve13(step(i2 + 1));
46529
+ return resolve12(step(i2 + 1));
46423
46530
  const ext = pathExt[ii];
46424
46531
  isexe(p3 + ext, { pathExt: pathExtExe }, (er2, is) => {
46425
46532
  if (!er2 && is) {
46426
46533
  if (opt.all)
46427
46534
  found.push(p3 + ext);
46428
46535
  else
46429
- return resolve13(p3 + ext);
46536
+ return resolve12(p3 + ext);
46430
46537
  }
46431
- return resolve13(subStep(p3, i2, ii + 1));
46538
+ return resolve12(subStep(p3, i2, ii + 1));
46432
46539
  });
46433
46540
  });
46434
46541
  return cb ? step(0).then((res) => cb(null, res), cb) : step(0);
@@ -46440,7 +46547,7 @@ var require_which = __commonJS({
46440
46547
  for (let i2 = 0; i2 < pathEnv.length; i2++) {
46441
46548
  const ppRaw = pathEnv[i2];
46442
46549
  const pathPart = /^".*"$/.test(ppRaw) ? ppRaw.slice(1, -1) : ppRaw;
46443
- const pCmd = path60.join(pathPart, cmd);
46550
+ const pCmd = path59.join(pathPart, cmd);
46444
46551
  const p3 = !pathPart && /^\.[\\\/]/.test(cmd) ? cmd.slice(0, 2) + pCmd : pCmd;
46445
46552
  for (let j3 = 0; j3 < pathExt.length; j3++) {
46446
46553
  const cur = p3 + pathExt[j3];
@@ -46486,7 +46593,7 @@ var require_path_key = __commonJS({
46486
46593
  // ../../node_modules/.pnpm/cross-spawn@7.0.6/node_modules/cross-spawn/lib/util/resolveCommand.js
46487
46594
  var require_resolveCommand = __commonJS({
46488
46595
  "../../node_modules/.pnpm/cross-spawn@7.0.6/node_modules/cross-spawn/lib/util/resolveCommand.js"(exports, module) {
46489
- var path60 = __require("path");
46596
+ var path59 = __require("path");
46490
46597
  var which = require_which();
46491
46598
  var getPathKey = require_path_key();
46492
46599
  function resolveCommandAttempt(parsed, withoutPathExt) {
@@ -46504,7 +46611,7 @@ var require_resolveCommand = __commonJS({
46504
46611
  try {
46505
46612
  resolved = which.sync(parsed.command, {
46506
46613
  path: env3[getPathKey({ env: env3 })],
46507
- pathExt: withoutPathExt ? path60.delimiter : void 0
46614
+ pathExt: withoutPathExt ? path59.delimiter : void 0
46508
46615
  });
46509
46616
  } catch (e3) {
46510
46617
  } finally {
@@ -46513,7 +46620,7 @@ var require_resolveCommand = __commonJS({
46513
46620
  }
46514
46621
  }
46515
46622
  if (resolved) {
46516
- resolved = path60.resolve(hasCustomCwd ? parsed.options.cwd : "", resolved);
46623
+ resolved = path59.resolve(hasCustomCwd ? parsed.options.cwd : "", resolved);
46517
46624
  }
46518
46625
  return resolved;
46519
46626
  }
@@ -46564,8 +46671,8 @@ var require_shebang_command = __commonJS({
46564
46671
  if (!match) {
46565
46672
  return null;
46566
46673
  }
46567
- const [path60, argument] = match[0].replace(/#! ?/, "").split(" ");
46568
- const binary = path60.split("/").pop();
46674
+ const [path59, argument] = match[0].replace(/#! ?/, "").split(" ");
46675
+ const binary = path59.split("/").pop();
46569
46676
  if (binary === "env") {
46570
46677
  return argument;
46571
46678
  }
@@ -46598,7 +46705,7 @@ var require_readShebang = __commonJS({
46598
46705
  // ../../node_modules/.pnpm/cross-spawn@7.0.6/node_modules/cross-spawn/lib/parse.js
46599
46706
  var require_parse = __commonJS({
46600
46707
  "../../node_modules/.pnpm/cross-spawn@7.0.6/node_modules/cross-spawn/lib/parse.js"(exports, module) {
46601
- var path60 = __require("path");
46708
+ var path59 = __require("path");
46602
46709
  var resolveCommand = require_resolveCommand();
46603
46710
  var escape4 = require_escape();
46604
46711
  var readShebang = require_readShebang();
@@ -46623,7 +46730,7 @@ var require_parse = __commonJS({
46623
46730
  const needsShell = !isExecutableRegExp.test(commandFile);
46624
46731
  if (parsed.options.forceShell || needsShell) {
46625
46732
  const needsDoubleEscapeMetaChars = isCmdShimRegExp.test(commandFile);
46626
- parsed.command = path60.normalize(parsed.command);
46733
+ parsed.command = path59.normalize(parsed.command);
46627
46734
  parsed.command = escape4.command(parsed.command);
46628
46735
  parsed.args = parsed.args.map((arg) => escape4.argument(arg, needsDoubleEscapeMetaChars));
46629
46736
  const shellCommand = [parsed.command].concat(parsed.args).join(" ");
@@ -46824,7 +46931,7 @@ var init_stdio2 = __esm({
46824
46931
  if (this._process) {
46825
46932
  throw new Error("StdioClientTransport already started! If using Client class, note that connect() calls start() automatically.");
46826
46933
  }
46827
- return new Promise((resolve13, reject) => {
46934
+ return new Promise((resolve12, reject) => {
46828
46935
  this._process = (0, import_cross_spawn.default)(this._serverParams.command, this._serverParams.args ?? [], {
46829
46936
  // merge default env with server env because mcp server needs some env vars
46830
46937
  env: {
@@ -46841,7 +46948,7 @@ var init_stdio2 = __esm({
46841
46948
  this.onerror?.(error2);
46842
46949
  });
46843
46950
  this._process.on("spawn", () => {
46844
- resolve13();
46951
+ resolve12();
46845
46952
  });
46846
46953
  this._process.on("close", (_code) => {
46847
46954
  this._process = void 0;
@@ -46900,22 +47007,22 @@ var init_stdio2 = __esm({
46900
47007
  if (this._process) {
46901
47008
  const processToClose = this._process;
46902
47009
  this._process = void 0;
46903
- const closePromise = new Promise((resolve13) => {
47010
+ const closePromise = new Promise((resolve12) => {
46904
47011
  processToClose.once("close", () => {
46905
- resolve13();
47012
+ resolve12();
46906
47013
  });
46907
47014
  });
46908
47015
  try {
46909
47016
  processToClose.stdin?.end();
46910
47017
  } catch {
46911
47018
  }
46912
- await Promise.race([closePromise, new Promise((resolve13) => setTimeout(resolve13, 2e3).unref())]);
47019
+ await Promise.race([closePromise, new Promise((resolve12) => setTimeout(resolve12, 2e3).unref())]);
46913
47020
  if (processToClose.exitCode === null) {
46914
47021
  try {
46915
47022
  processToClose.kill("SIGTERM");
46916
47023
  } catch {
46917
47024
  }
46918
- await Promise.race([closePromise, new Promise((resolve13) => setTimeout(resolve13, 2e3).unref())]);
47025
+ await Promise.race([closePromise, new Promise((resolve12) => setTimeout(resolve12, 2e3).unref())]);
46919
47026
  }
46920
47027
  if (processToClose.exitCode === null) {
46921
47028
  try {
@@ -46927,15 +47034,15 @@ var init_stdio2 = __esm({
46927
47034
  this._readBuffer.clear();
46928
47035
  }
46929
47036
  send(message) {
46930
- return new Promise((resolve13) => {
47037
+ return new Promise((resolve12) => {
46931
47038
  if (!this._process?.stdin) {
46932
47039
  throw new Error("Not connected");
46933
47040
  }
46934
47041
  const json = serializeMessage(message);
46935
47042
  if (this._process.stdin.write(json)) {
46936
- resolve13();
47043
+ resolve12();
46937
47044
  } else {
46938
- this._process.stdin.once("drain", resolve13);
47045
+ this._process.stdin.once("drain", resolve12);
46939
47046
  }
46940
47047
  });
46941
47048
  }
@@ -48364,7 +48471,7 @@ var init_sse = __esm({
48364
48471
  }
48365
48472
  _startOrAuth() {
48366
48473
  const fetchImpl2 = this?._eventSourceInit?.fetch ?? this._fetch ?? fetch;
48367
- return new Promise((resolve13, reject) => {
48474
+ return new Promise((resolve12, reject) => {
48368
48475
  this._eventSource = new EventSource(this._url.href, {
48369
48476
  ...this._eventSourceInit,
48370
48477
  fetch: async (url2, init3) => {
@@ -48385,7 +48492,7 @@ var init_sse = __esm({
48385
48492
  this._abortController = new AbortController();
48386
48493
  this._eventSource.onerror = (event) => {
48387
48494
  if (event.code === 401 && this._authProvider) {
48388
- this._authThenStart().then(resolve13, reject);
48495
+ this._authThenStart().then(resolve12, reject);
48389
48496
  return;
48390
48497
  }
48391
48498
  const error2 = new SseError(event.code, event.message, event);
@@ -48407,7 +48514,7 @@ var init_sse = __esm({
48407
48514
  void this.close();
48408
48515
  return;
48409
48516
  }
48410
- resolve13();
48517
+ resolve12();
48411
48518
  });
48412
48519
  this._eventSource.onmessage = (event) => {
48413
48520
  const messageEvent = event;
@@ -48947,20 +49054,27 @@ async function defaultClientFactory(server, options = { servers: [] }) {
48947
49054
  return {
48948
49055
  async listTools() {
48949
49056
  const result = await client.listTools();
48950
- return { tools: result.tools ?? [] };
49057
+ return { tools: (result.tools ?? []).map(toToolDescriptor) };
48951
49058
  },
48952
49059
  async callTool(args) {
48953
49060
  const result = await client.callTool(args);
48954
- return {
48955
- content: result.content,
49061
+ const out = {
49062
+ content: result.content?.map(toContentBlock),
48956
49063
  isError: result.isError
48957
49064
  };
49065
+ return out;
48958
49066
  },
48959
49067
  async close() {
48960
49068
  await client.close();
48961
49069
  }
48962
49070
  };
48963
49071
  }
49072
+ function toToolDescriptor(t2) {
49073
+ return t2;
49074
+ }
49075
+ function toContentBlock(block) {
49076
+ return block;
49077
+ }
48964
49078
  async function createTransport(server) {
48965
49079
  const kind3 = server.kind ?? "stdio";
48966
49080
  if (kind3 === "stdio") {
@@ -49001,7 +49115,7 @@ var init_types2 = __esm({
49001
49115
  }
49002
49116
  });
49003
49117
  async function runMcpCallWithFallback(callPromise, signal, toolName) {
49004
- return await new Promise((resolve13, reject) => {
49118
+ return await new Promise((resolve12, reject) => {
49005
49119
  let settled = false;
49006
49120
  const settle = (fn) => {
49007
49121
  if (settled)
@@ -49018,7 +49132,7 @@ async function runMcpCallWithFallback(callPromise, signal, toolName) {
49018
49132
  settle(() => reject(new Error(`MCP tool "${toolName}" timed out after ${MCP_CALL_TIMEOUT_MS}ms`)));
49019
49133
  }, MCP_CALL_TIMEOUT_MS);
49020
49134
  signal.addEventListener("abort", onAbort, { once: true });
49021
- callPromise.then((v3) => settle(() => resolve13(v3)), (err) => settle(() => reject(err instanceof Error ? err : new Error(String(err)))));
49135
+ callPromise.then((v3) => settle(() => resolve12(v3)), (err) => settle(() => reject(err instanceof Error ? err : new Error(String(err)))));
49022
49136
  });
49023
49137
  }
49024
49138
  async function wrapMcpServerTools(opts) {
@@ -51760,14 +51874,14 @@ var require_react_development = __commonJS({
51760
51874
  var thenableResult = result;
51761
51875
  var wasAwaited = false;
51762
51876
  var thenable = {
51763
- then: function(resolve13, reject) {
51877
+ then: function(resolve12, reject) {
51764
51878
  wasAwaited = true;
51765
51879
  thenableResult.then(function(returnValue2) {
51766
51880
  popActScope(prevActScopeDepth);
51767
51881
  if (actScopeDepth === 0) {
51768
- recursivelyFlushAsyncActWork(returnValue2, resolve13, reject);
51882
+ recursivelyFlushAsyncActWork(returnValue2, resolve12, reject);
51769
51883
  } else {
51770
- resolve13(returnValue2);
51884
+ resolve12(returnValue2);
51771
51885
  }
51772
51886
  }, function(error3) {
51773
51887
  popActScope(prevActScopeDepth);
@@ -51797,20 +51911,20 @@ var require_react_development = __commonJS({
51797
51911
  ReactCurrentActQueue.current = null;
51798
51912
  }
51799
51913
  var _thenable = {
51800
- then: function(resolve13, reject) {
51914
+ then: function(resolve12, reject) {
51801
51915
  if (ReactCurrentActQueue.current === null) {
51802
51916
  ReactCurrentActQueue.current = [];
51803
- recursivelyFlushAsyncActWork(returnValue, resolve13, reject);
51917
+ recursivelyFlushAsyncActWork(returnValue, resolve12, reject);
51804
51918
  } else {
51805
- resolve13(returnValue);
51919
+ resolve12(returnValue);
51806
51920
  }
51807
51921
  }
51808
51922
  };
51809
51923
  return _thenable;
51810
51924
  } else {
51811
51925
  var _thenable2 = {
51812
- then: function(resolve13, reject) {
51813
- resolve13(returnValue);
51926
+ then: function(resolve12, reject) {
51927
+ resolve12(returnValue);
51814
51928
  }
51815
51929
  };
51816
51930
  return _thenable2;
@@ -51826,7 +51940,7 @@ var require_react_development = __commonJS({
51826
51940
  actScopeDepth = prevActScopeDepth;
51827
51941
  }
51828
51942
  }
51829
- function recursivelyFlushAsyncActWork(returnValue, resolve13, reject) {
51943
+ function recursivelyFlushAsyncActWork(returnValue, resolve12, reject) {
51830
51944
  {
51831
51945
  var queue = ReactCurrentActQueue.current;
51832
51946
  if (queue !== null) {
@@ -51835,16 +51949,16 @@ var require_react_development = __commonJS({
51835
51949
  enqueueTask(function() {
51836
51950
  if (queue.length === 0) {
51837
51951
  ReactCurrentActQueue.current = null;
51838
- resolve13(returnValue);
51952
+ resolve12(returnValue);
51839
51953
  } else {
51840
- recursivelyFlushAsyncActWork(returnValue, resolve13, reject);
51954
+ recursivelyFlushAsyncActWork(returnValue, resolve12, reject);
51841
51955
  }
51842
51956
  });
51843
51957
  } catch (error3) {
51844
51958
  reject(error3);
51845
51959
  }
51846
51960
  } else {
51847
- resolve13(returnValue);
51961
+ resolve12(returnValue);
51848
51962
  }
51849
51963
  }
51850
51964
  }
@@ -74458,10 +74572,10 @@ var require_react_reconciler_development = __commonJS({
74458
74572
  var setErrorHandler = null;
74459
74573
  var setSuspenseHandler = null;
74460
74574
  {
74461
- var copyWithDeleteImpl = function(obj, path60, index2) {
74462
- var key = path60[index2];
74575
+ var copyWithDeleteImpl = function(obj, path59, index2) {
74576
+ var key = path59[index2];
74463
74577
  var updated = isArray(obj) ? obj.slice() : assign({}, obj);
74464
- if (index2 + 1 === path60.length) {
74578
+ if (index2 + 1 === path59.length) {
74465
74579
  if (isArray(updated)) {
74466
74580
  updated.splice(key, 1);
74467
74581
  } else {
@@ -74469,11 +74583,11 @@ var require_react_reconciler_development = __commonJS({
74469
74583
  }
74470
74584
  return updated;
74471
74585
  }
74472
- updated[key] = copyWithDeleteImpl(obj[key], path60, index2 + 1);
74586
+ updated[key] = copyWithDeleteImpl(obj[key], path59, index2 + 1);
74473
74587
  return updated;
74474
74588
  };
74475
- var copyWithDelete = function(obj, path60) {
74476
- return copyWithDeleteImpl(obj, path60, 0);
74589
+ var copyWithDelete = function(obj, path59) {
74590
+ return copyWithDeleteImpl(obj, path59, 0);
74477
74591
  };
74478
74592
  var copyWithRenameImpl = function(obj, oldPath, newPath, index2) {
74479
74593
  var oldKey = oldPath[index2];
@@ -74511,17 +74625,17 @@ var require_react_reconciler_development = __commonJS({
74511
74625
  }
74512
74626
  return copyWithRenameImpl(obj, oldPath, newPath, 0);
74513
74627
  };
74514
- var copyWithSetImpl = function(obj, path60, index2, value) {
74515
- if (index2 >= path60.length) {
74628
+ var copyWithSetImpl = function(obj, path59, index2, value) {
74629
+ if (index2 >= path59.length) {
74516
74630
  return value;
74517
74631
  }
74518
- var key = path60[index2];
74632
+ var key = path59[index2];
74519
74633
  var updated = isArray(obj) ? obj.slice() : assign({}, obj);
74520
- updated[key] = copyWithSetImpl(obj[key], path60, index2 + 1, value);
74634
+ updated[key] = copyWithSetImpl(obj[key], path59, index2 + 1, value);
74521
74635
  return updated;
74522
74636
  };
74523
- var copyWithSet = function(obj, path60, value) {
74524
- return copyWithSetImpl(obj, path60, 0, value);
74637
+ var copyWithSet = function(obj, path59, value) {
74638
+ return copyWithSetImpl(obj, path59, 0, value);
74525
74639
  };
74526
74640
  var findHook = function(fiber, id) {
74527
74641
  var currentHook2 = fiber.memoizedState;
@@ -74531,10 +74645,10 @@ var require_react_reconciler_development = __commonJS({
74531
74645
  }
74532
74646
  return currentHook2;
74533
74647
  };
74534
- overrideHookState = function(fiber, id, path60, value) {
74648
+ overrideHookState = function(fiber, id, path59, value) {
74535
74649
  var hook = findHook(fiber, id);
74536
74650
  if (hook !== null) {
74537
- var newState = copyWithSet(hook.memoizedState, path60, value);
74651
+ var newState = copyWithSet(hook.memoizedState, path59, value);
74538
74652
  hook.memoizedState = newState;
74539
74653
  hook.baseState = newState;
74540
74654
  fiber.memoizedProps = assign({}, fiber.memoizedProps);
@@ -74544,10 +74658,10 @@ var require_react_reconciler_development = __commonJS({
74544
74658
  }
74545
74659
  }
74546
74660
  };
74547
- overrideHookStateDeletePath = function(fiber, id, path60) {
74661
+ overrideHookStateDeletePath = function(fiber, id, path59) {
74548
74662
  var hook = findHook(fiber, id);
74549
74663
  if (hook !== null) {
74550
- var newState = copyWithDelete(hook.memoizedState, path60);
74664
+ var newState = copyWithDelete(hook.memoizedState, path59);
74551
74665
  hook.memoizedState = newState;
74552
74666
  hook.baseState = newState;
74553
74667
  fiber.memoizedProps = assign({}, fiber.memoizedProps);
@@ -74570,8 +74684,8 @@ var require_react_reconciler_development = __commonJS({
74570
74684
  }
74571
74685
  }
74572
74686
  };
74573
- overrideProps = function(fiber, path60, value) {
74574
- fiber.pendingProps = copyWithSet(fiber.memoizedProps, path60, value);
74687
+ overrideProps = function(fiber, path59, value) {
74688
+ fiber.pendingProps = copyWithSet(fiber.memoizedProps, path59, value);
74575
74689
  if (fiber.alternate) {
74576
74690
  fiber.alternate.pendingProps = fiber.pendingProps;
74577
74691
  }
@@ -74580,8 +74694,8 @@ var require_react_reconciler_development = __commonJS({
74580
74694
  scheduleUpdateOnFiber(root, fiber, SyncLane, NoTimestamp);
74581
74695
  }
74582
74696
  };
74583
- overridePropsDeletePath = function(fiber, path60) {
74584
- fiber.pendingProps = copyWithDelete(fiber.memoizedProps, path60);
74697
+ overridePropsDeletePath = function(fiber, path59) {
74698
+ fiber.pendingProps = copyWithDelete(fiber.memoizedProps, path59);
74585
74699
  if (fiber.alternate) {
74586
74700
  fiber.alternate.pendingProps = fiber.pendingProps;
74587
74701
  }
@@ -79676,11 +79790,11 @@ var init_devtools = __esm({
79676
79790
  devtools_stub_default.connectToDevTools();
79677
79791
  }
79678
79792
  });
79679
- var import_react_reconciler, import_constants18, diff, cleanupYogaNode, reconciler_default;
79793
+ var import_react_reconciler, import_constants17, diff, cleanupYogaNode, reconciler_default;
79680
79794
  var init_reconciler = __esm({
79681
79795
  async "../../node_modules/.pnpm/ink@5.2.1_@types+react@18.3.28_react@18.3.1/node_modules/ink/build/reconciler.js"() {
79682
79796
  import_react_reconciler = __toESM(require_react_reconciler());
79683
- import_constants18 = __toESM(require_constants3());
79797
+ import_constants17 = __toESM(require_constants3());
79684
79798
  await init_src();
79685
79799
  await init_dom();
79686
79800
  await init_styles();
@@ -79830,7 +79944,7 @@ $ npm install --save-dev react-devtools-core
79830
79944
  scheduleTimeout: setTimeout,
79831
79945
  cancelTimeout: clearTimeout,
79832
79946
  noTimeout: -1,
79833
- getCurrentEventPriority: () => import_constants18.DefaultEventPriority,
79947
+ getCurrentEventPriority: () => import_constants17.DefaultEventPriority,
79834
79948
  beforeActiveInstanceBlur() {
79835
79949
  },
79836
79950
  afterActiveInstanceBlur() {
@@ -82023,8 +82137,8 @@ var init_ErrorOverview = __esm({
82023
82137
  init_dist7();
82024
82138
  init_Box();
82025
82139
  init_Text();
82026
- cleanupPath = (path60) => {
82027
- return path60?.replace(`file://${cwd()}/`, "");
82140
+ cleanupPath = (path59) => {
82141
+ return path59?.replace(`file://${cwd()}/`, "");
82028
82142
  };
82029
82143
  stackUtils = new import_stack_utils.default({
82030
82144
  cwd: cwd(),
@@ -82519,8 +82633,8 @@ var init_ink = __esm({
82519
82633
  }
82520
82634
  }
82521
82635
  async waitUntilExit() {
82522
- this.exitPromise ||= new Promise((resolve13, reject) => {
82523
- this.resolveExitPromise = resolve13;
82636
+ this.exitPromise ||= new Promise((resolve12, reject) => {
82637
+ this.resolveExitPromise = resolve12;
82524
82638
  this.rejectExitPromise = reject;
82525
82639
  });
82526
82640
  return this.exitPromise;
@@ -85197,35 +85311,40 @@ function handleSubagentEvent(e3, subagents, root, groupRef) {
85197
85311
  return;
85198
85312
  }
85199
85313
  }
85200
- function pairToolEvents(events, compactByName = EMPTY_COMPACT_MAP) {
85201
- const root = [];
85202
- const callTargets = /* @__PURE__ */ new Map();
85203
- const suppressedCallIds = /* @__PURE__ */ new Set();
85204
- let pendingLoadSkillCallId = null;
85205
- let openScope = null;
85206
- let continuationSkillEvent = null;
85207
- let openLive = null;
85208
- const subagents = /* @__PURE__ */ new Map();
85209
- const subagentGroup = { current: null };
85314
+ function createFoldState(compactByName = EMPTY_COMPACT_MAP) {
85315
+ return {
85316
+ root: [],
85317
+ compactByName,
85318
+ callTargets: /* @__PURE__ */ new Map(),
85319
+ suppressedCallIds: /* @__PURE__ */ new Set(),
85320
+ pendingLoadSkillCallId: null,
85321
+ openScope: null,
85322
+ continuationSkillEvent: null,
85323
+ openLive: null,
85324
+ subagents: /* @__PURE__ */ new Map(),
85325
+ subagentGroup: { current: null }
85326
+ };
85327
+ }
85328
+ function stepFold(s2, e3) {
85210
85329
  const pushBlock = (block) => {
85211
- subagentGroup.current = null;
85212
- if (openScope) {
85213
- openScope.children.push(block);
85330
+ s2.subagentGroup.current = null;
85331
+ if (s2.openScope) {
85332
+ s2.openScope.children.push(block);
85214
85333
  } else {
85215
- root.push(block);
85334
+ s2.root.push(block);
85216
85335
  }
85217
85336
  };
85218
85337
  const closeOpenLive = () => {
85219
- if (openLive) {
85220
- openLive.closed = true;
85221
- openLive = null;
85338
+ if (s2.openLive) {
85339
+ s2.openLive.closed = true;
85340
+ s2.openLive = null;
85222
85341
  }
85223
85342
  };
85224
85343
  const closeOpenScope = () => {
85225
85344
  closeOpenLive();
85226
- if (openScope) {
85227
- openScope.closed = true;
85228
- openScope = null;
85345
+ if (s2.openScope) {
85346
+ s2.openScope.closed = true;
85347
+ s2.openScope = null;
85229
85348
  }
85230
85349
  };
85231
85350
  const removeBlockByCallId = (callId) => {
@@ -85237,12 +85356,12 @@ function pairToolEvents(events, compactByName = EMPTY_COMPACT_MAP) {
85237
85356
  }
85238
85357
  return false;
85239
85358
  };
85240
- if (openScope && removeFrom(openScope.children))
85359
+ if (s2.openScope && removeFrom(s2.openScope.children))
85241
85360
  return;
85242
- removeFrom(root);
85361
+ removeFrom(s2.root);
85243
85362
  };
85244
85363
  const markOrphansAtTurnBoundary = () => {
85245
- for (const target of callTargets.values()) {
85364
+ for (const target of s2.callTargets.values()) {
85246
85365
  if (target.outcome === null) {
85247
85366
  target.outcome = {
85248
85367
  type: "denied",
@@ -85250,116 +85369,119 @@ function pairToolEvents(events, compactByName = EMPTY_COMPACT_MAP) {
85250
85369
  };
85251
85370
  }
85252
85371
  }
85253
- callTargets.clear();
85372
+ s2.callTargets.clear();
85254
85373
  };
85255
- for (const e3 of events) {
85256
- if (e3.type === "user_prompt") {
85257
- closeOpenScope();
85258
- markOrphansAtTurnBoundary();
85259
- pendingLoadSkillCallId = null;
85260
- continuationSkillEvent = null;
85261
- suppressedCallIds.clear();
85262
- subagentGroup.current = null;
85263
- root.push({ kind: "event", id: e3.id, event: e3 });
85264
- continue;
85374
+ if (e3.type === "user_prompt") {
85375
+ closeOpenScope();
85376
+ markOrphansAtTurnBoundary();
85377
+ s2.pendingLoadSkillCallId = null;
85378
+ s2.continuationSkillEvent = null;
85379
+ s2.suppressedCallIds.clear();
85380
+ s2.subagentGroup.current = null;
85381
+ s2.root.push({ kind: "event", id: e3.id, event: e3 });
85382
+ return;
85383
+ }
85384
+ if (e3.type === "skill_invoked") {
85385
+ closeOpenScope();
85386
+ s2.continuationSkillEvent = null;
85387
+ if (s2.pendingLoadSkillCallId) {
85388
+ s2.suppressedCallIds.add(s2.pendingLoadSkillCallId);
85389
+ removeBlockByCallId(s2.pendingLoadSkillCallId);
85390
+ s2.pendingLoadSkillCallId = null;
85391
+ }
85392
+ s2.subagentGroup.current = null;
85393
+ s2.openScope = {
85394
+ kind: "skill-scope",
85395
+ id: e3.id,
85396
+ skillEvent: e3,
85397
+ children: [],
85398
+ closed: false
85399
+ };
85400
+ s2.root.push(s2.openScope);
85401
+ return;
85402
+ }
85403
+ if (e3.type === "tool_call_requested") {
85404
+ if (e3.name === "load_skill") {
85405
+ s2.pendingLoadSkillCallId = e3.callId;
85265
85406
  }
85266
- if (e3.type === "skill_invoked") {
85267
- closeOpenScope();
85268
- continuationSkillEvent = null;
85269
- if (pendingLoadSkillCallId) {
85270
- suppressedCallIds.add(pendingLoadSkillCallId);
85271
- removeBlockByCallId(pendingLoadSkillCallId);
85272
- pendingLoadSkillCallId = null;
85273
- }
85274
- subagentGroup.current = null;
85275
- openScope = {
85407
+ if (!s2.openScope && s2.continuationSkillEvent) {
85408
+ s2.openScope = {
85276
85409
  kind: "skill-scope",
85277
- id: e3.id,
85278
- skillEvent: e3,
85410
+ id: `${s2.continuationSkillEvent.id}:cont:${e3.id}`,
85411
+ skillEvent: s2.continuationSkillEvent,
85279
85412
  children: [],
85280
85413
  closed: false
85281
85414
  };
85282
- root.push(openScope);
85283
- continue;
85284
- }
85285
- if (e3.type === "tool_call_requested") {
85286
- if (e3.name === "load_skill") {
85287
- pendingLoadSkillCallId = e3.callId;
85288
- }
85289
- if (!openScope && continuationSkillEvent) {
85290
- openScope = {
85291
- kind: "skill-scope",
85292
- id: `${continuationSkillEvent.id}:cont:${e3.id}`,
85293
- skillEvent: continuationSkillEvent,
85294
- children: [],
85295
- closed: false
85296
- };
85297
- root.push(openScope);
85298
- continuationSkillEvent = null;
85299
- }
85300
- const compact = FILE_DIFF_TOOL_NAMES.has(e3.name) ? void 0 : compactByName.get(e3.name);
85301
- if (compact) {
85302
- if (!openLive) {
85303
- openLive = { kind: "live-tools", id: e3.id, calls: [], closed: false };
85304
- pushBlock(openLive);
85305
- }
85306
- const call = { id: e3.id, request: e3, compact, outcome: null };
85307
- openLive.calls.push(call);
85308
- callTargets.set(e3.callId, call);
85309
- continue;
85310
- }
85311
- closeOpenLive();
85312
- const block = {
85313
- kind: "tool-call",
85314
- id: e3.id,
85315
- request: e3,
85316
- outcome: null
85317
- };
85318
- callTargets.set(e3.callId, block);
85319
- pushBlock(block);
85320
- continue;
85321
- }
85322
- if (e3.type === "tool_result") {
85323
- if (suppressedCallIds.has(e3.callId))
85324
- continue;
85325
- const target = callTargets.get(e3.callId);
85326
- if (target) {
85327
- target.outcome = e3;
85328
- continue;
85329
- }
85330
- }
85331
- if (e3.type === "tool_call_denied") {
85332
- if (suppressedCallIds.has(e3.callId))
85333
- continue;
85334
- const target = callTargets.get(e3.callId);
85335
- if (target) {
85336
- target.outcome = { type: "denied", reason: e3.reason };
85337
- continue;
85338
- }
85415
+ s2.root.push(s2.openScope);
85416
+ s2.continuationSkillEvent = null;
85417
+ }
85418
+ const compact = FILE_DIFF_TOOL_NAMES.has(e3.name) ? void 0 : s2.compactByName.get(e3.name);
85419
+ if (compact) {
85420
+ if (!s2.openLive) {
85421
+ s2.openLive = { kind: "live-tools", id: e3.id, calls: [], closed: false };
85422
+ pushBlock(s2.openLive);
85423
+ }
85424
+ const call = { id: e3.id, request: e3, compact, outcome: null };
85425
+ s2.openLive.calls.push(call);
85426
+ s2.callTargets.set(e3.callId, call);
85427
+ return;
85339
85428
  }
85340
- if (e3.type === "tool_call_approved") {
85341
- continue;
85429
+ closeOpenLive();
85430
+ const block = {
85431
+ kind: "tool-call",
85432
+ id: e3.id,
85433
+ request: e3,
85434
+ outcome: null
85435
+ };
85436
+ s2.callTargets.set(e3.callId, block);
85437
+ pushBlock(block);
85438
+ return;
85439
+ }
85440
+ if (e3.type === "tool_result") {
85441
+ if (s2.suppressedCallIds.has(e3.callId))
85442
+ return;
85443
+ const target = s2.callTargets.get(e3.callId);
85444
+ if (target) {
85445
+ target.outcome = e3;
85446
+ return;
85342
85447
  }
85343
- if (e3.type === "assistant_message") {
85344
- closeOpenLive();
85345
- if (openScope) {
85346
- continuationSkillEvent = openScope.skillEvent;
85347
- openScope.closed = true;
85348
- openScope = null;
85349
- } else {
85350
- continuationSkillEvent = null;
85351
- }
85352
- subagentGroup.current = null;
85353
- root.push({ kind: "event", id: e3.id, event: e3 });
85354
- continue;
85448
+ }
85449
+ if (e3.type === "tool_call_denied") {
85450
+ if (s2.suppressedCallIds.has(e3.callId))
85451
+ return;
85452
+ const target = s2.callTargets.get(e3.callId);
85453
+ if (target) {
85454
+ target.outcome = { type: "denied", reason: e3.reason };
85455
+ return;
85355
85456
  }
85356
- if (e3.type === "plugin_event" && e3.pluginId === SUBAGENT_PLUGIN_ID2) {
85357
- handleSubagentEvent(e3, subagents, root, subagentGroup);
85358
- continue;
85457
+ }
85458
+ if (e3.type === "tool_call_approved") {
85459
+ return;
85460
+ }
85461
+ if (e3.type === "assistant_message") {
85462
+ closeOpenLive();
85463
+ if (s2.openScope) {
85464
+ s2.continuationSkillEvent = s2.openScope.skillEvent;
85465
+ s2.openScope.closed = true;
85466
+ s2.openScope = null;
85467
+ } else {
85468
+ s2.continuationSkillEvent = null;
85359
85469
  }
85360
- pushBlock({ kind: "event", id: e3.id, event: e3 });
85470
+ s2.subagentGroup.current = null;
85471
+ s2.root.push({ kind: "event", id: e3.id, event: e3 });
85472
+ return;
85473
+ }
85474
+ if (e3.type === "plugin_event" && e3.pluginId === SUBAGENT_PLUGIN_ID2) {
85475
+ handleSubagentEvent(e3, s2.subagents, s2.root, s2.subagentGroup);
85476
+ return;
85361
85477
  }
85362
- return root;
85478
+ pushBlock({ kind: "event", id: e3.id, event: e3 });
85479
+ }
85480
+ function pairToolEvents(events, compactByName = EMPTY_COMPACT_MAP) {
85481
+ const state = createFoldState(compactByName);
85482
+ for (const e3 of events)
85483
+ stepFold(state, e3);
85484
+ return state.root;
85363
85485
  }
85364
85486
  function isSettled(block) {
85365
85487
  if (block.kind === "event")
@@ -85445,13 +85567,97 @@ function countToolCalls(blocks) {
85445
85567
  }
85446
85568
  return n2;
85447
85569
  }
85448
- var SUBAGENT_PLUGIN_ID2, FILE_DIFF_TOOL_NAMES, EMPTY_COMPACT_MAP;
85570
+ var SUBAGENT_PLUGIN_ID2, FILE_DIFF_TOOL_NAMES, EMPTY_COMPACT_MAP, IncrementalFold;
85449
85571
  var init_pair_events = __esm({
85450
85572
  "../chat-model/dist/pair-events.js"() {
85451
85573
  init_format();
85452
85574
  SUBAGENT_PLUGIN_ID2 = "@moxxy/subagents";
85453
85575
  FILE_DIFF_TOOL_NAMES = /* @__PURE__ */ new Set(["Write", "Edit"]);
85454
85576
  EMPTY_COMPACT_MAP = /* @__PURE__ */ new Map();
85577
+ IncrementalFold = class {
85578
+ state;
85579
+ prefixLength = 0;
85580
+ rev = 0;
85581
+ /** `id` of the first / last event folded so far — used to detect when the
85582
+ * source array's prefix has shifted (a scroll-up prepend) or been replaced
85583
+ * (/clear, a fresh session), in which case the carried fold state is no
85584
+ * longer valid and we must rebuild from scratch. */
85585
+ headId = null;
85586
+ tailId = null;
85587
+ constructor(compactByName = EMPTY_COMPACT_MAP) {
85588
+ this.state = createFoldState(compactByName);
85589
+ }
85590
+ /** Number of events folded so far (the high-water mark). */
85591
+ get length() {
85592
+ return this.prefixLength;
85593
+ }
85594
+ /** Bumps whenever the folded tree may have changed (every `push`). Use as
85595
+ * a memo key instead of the (stable) `tree()` reference. */
85596
+ get version() {
85597
+ return this.rev;
85598
+ }
85599
+ /** Fold one freshly-committed event onto the existing tree. */
85600
+ push(event) {
85601
+ stepFold(this.state, event);
85602
+ if (this.prefixLength === 0)
85603
+ this.headId = event.id;
85604
+ this.tailId = event.id;
85605
+ this.prefixLength += 1;
85606
+ this.rev += 1;
85607
+ }
85608
+ /** Fold a batch of newly-committed events (e.g. a replayed page). */
85609
+ pushMany(events) {
85610
+ for (const e3 of events)
85611
+ this.push(e3);
85612
+ }
85613
+ /**
85614
+ * Re-sync to `events` when the source array is the authoritative log. Folds
85615
+ * only the tail past the current high-water mark when `events` extends the
85616
+ * already-folded prefix unchanged (the common live-append case), and
85617
+ * rebuilds from scratch only when that prefix shifted or was replaced (a
85618
+ * scroll-up prepend, /clear, a fresh session). Returns the (stable) root.
85619
+ *
85620
+ * Prefix-unchanged is detected by event `id`: the log never rewrites a
85621
+ * settled event in place (only its tool outcome, which the fold owns), so
85622
+ * matching head+tail ids over an unshrunk length proves the leading
85623
+ * `prefixLength` events are exactly the ones already folded.
85624
+ */
85625
+ syncTo(events) {
85626
+ if (this.canExtend(events)) {
85627
+ for (let i2 = this.prefixLength; i2 < events.length; i2 += 1)
85628
+ this.push(events[i2]);
85629
+ return this.state.root;
85630
+ }
85631
+ this.reset();
85632
+ this.pushMany(events);
85633
+ return this.state.root;
85634
+ }
85635
+ /** Discard all state — folds again from empty. */
85636
+ reset() {
85637
+ this.state = createFoldState(this.state.compactByName);
85638
+ this.prefixLength = 0;
85639
+ this.headId = null;
85640
+ this.tailId = null;
85641
+ this.rev += 1;
85642
+ }
85643
+ /** The folded block tree (stable reference, mutated in place). */
85644
+ tree() {
85645
+ return this.state.root;
85646
+ }
85647
+ /** True when `events` is the already-folded prefix plus zero or more new
85648
+ * tail events — i.e. a pure append. Requires the head id to still match
85649
+ * (no prepend) and the event at `prefixLength-1` to be the last one we
85650
+ * folded (no in-place rewrite or replacement of the prefix). */
85651
+ canExtend(events) {
85652
+ if (this.prefixLength === 0)
85653
+ return true;
85654
+ if (events.length < this.prefixLength)
85655
+ return false;
85656
+ if (events[0].id !== this.headId)
85657
+ return false;
85658
+ return events[this.prefixLength - 1].id === this.tailId;
85659
+ }
85660
+ };
85455
85661
  }
85456
85662
  });
85457
85663
 
@@ -86090,6 +86296,31 @@ var init_BlockLine = __esm({
86090
86296
  });
86091
86297
 
86092
86298
  // ../plugin-cli/dist/components/chat/StreamingPreview.js
86299
+ function lastNonEmptyLineShown(content, innerCols) {
86300
+ let end = content.length;
86301
+ let chosenStart = -1;
86302
+ let chosenEnd = -1;
86303
+ while (end > 0) {
86304
+ const nl = content.lastIndexOf("\n", end - 1);
86305
+ const start = nl + 1;
86306
+ if (content.slice(start, end).trim()) {
86307
+ chosenStart = start;
86308
+ chosenEnd = end;
86309
+ break;
86310
+ }
86311
+ if (start === 0)
86312
+ break;
86313
+ end = nl;
86314
+ }
86315
+ let line;
86316
+ if (chosenStart >= 0) {
86317
+ line = content.slice(chosenStart, chosenEnd);
86318
+ } else {
86319
+ const lastNl = content.lastIndexOf("\n");
86320
+ line = lastNl < 0 ? content : content.slice(lastNl + 1);
86321
+ }
86322
+ return line.length > innerCols ? `\u2026${line.slice(line.length - (innerCols - 1))}` : line;
86323
+ }
86093
86324
  function tailForViewport(content) {
86094
86325
  return content;
86095
86326
  }
@@ -86103,17 +86334,7 @@ var init_StreamingPreview = __esm({
86103
86334
  StreamingPreview = (0, import_react40.memo)(function StreamingPreview2({ content, dim: dim3 }) {
86104
86335
  const cols = process.stdout.columns ?? 80;
86105
86336
  const innerCols = Math.max(20, cols - 4);
86106
- const lines = content.split("\n");
86107
- let line = "";
86108
- for (let i2 = lines.length - 1; i2 >= 0; i2 -= 1) {
86109
- if (lines[i2].trim()) {
86110
- line = lines[i2];
86111
- break;
86112
- }
86113
- }
86114
- if (!line)
86115
- line = lines[lines.length - 1] ?? "";
86116
- const shown = line.length > innerCols ? `\u2026${line.slice(line.length - (innerCols - 1))}` : line;
86337
+ const shown = lastNonEmptyLineShown(content, innerCols);
86117
86338
  return (0, import_jsx_runtime19.jsxs)(Box_default, { flexDirection: "row", marginTop: 1, children: [(0, import_jsx_runtime19.jsx)(Box_default, { marginRight: 1, children: (0, import_jsx_runtime19.jsx)(Text, { dimColor: true, children: Glyphs.filled }) }), (0, import_jsx_runtime19.jsx)(Text, { dimColor: dim3, children: shown || " " })] });
86118
86339
  });
86119
86340
  }
@@ -86130,16 +86351,26 @@ var init_ChatView = __esm({
86130
86351
  init_dist8();
86131
86352
  await init_StreamingPreview();
86132
86353
  ChatView = ({ events, streamingDelta, reasoningDelta, expandToolOutputs, compactTools, hideLive }) => {
86133
- const blocks = (0, import_react41.useMemo)(() => pairToolEvents(events, compactTools), [events, compactTools]);
86354
+ const foldRef = (0, import_react41.useRef)(null);
86355
+ const compactRef = (0, import_react41.useRef)(void 0);
86356
+ const blocks = (0, import_react41.useMemo)(() => {
86357
+ if (typeof IncrementalFold !== "function")
86358
+ return pairToolEvents(events, compactTools);
86359
+ if (!foldRef.current || compactRef.current !== compactTools) {
86360
+ foldRef.current = new IncrementalFold(compactTools);
86361
+ compactRef.current = compactTools;
86362
+ }
86363
+ return foldRef.current.syncTo(events).slice();
86364
+ }, [events, compactTools]);
86134
86365
  const settledRef = (0, import_react41.useRef)([]);
86135
86366
  const clearGenerationRef = (0, import_react41.useRef)(0);
86136
86367
  if (blocks.length < settledRef.current.length) {
86137
86368
  settledRef.current = [];
86138
86369
  clearGenerationRef.current += 1;
86139
86370
  }
86140
- let settledCount = 0;
86141
- for (const b3 of blocks) {
86142
- if (isSettled(b3))
86371
+ let settledCount = settledRef.current.length;
86372
+ for (let i2 = settledRef.current.length; i2 < blocks.length; i2 += 1) {
86373
+ if (isSettled(blocks[i2]))
86143
86374
  settledCount += 1;
86144
86375
  else
86145
86376
  break;
@@ -86869,14 +87100,14 @@ function usePermissionQueue(session, registerInteractiveResolver) {
86869
87100
  if (yoloRef.current) {
86870
87101
  return { mode: "allow", reason: "yolo mode" };
86871
87102
  }
86872
- return new Promise((resolve13) => {
86873
- setPendingPermissions((prev) => [...prev, { call, ctx, resolve: resolve13 }]);
87103
+ return new Promise((resolve12) => {
87104
+ setPendingPermissions((prev) => [...prev, { call, ctx, resolve: resolve12 }]);
86874
87105
  });
86875
87106
  });
86876
87107
  session.setApprovalResolver({
86877
87108
  name: "tui-approval",
86878
- confirm: (request) => new Promise((resolve13) => {
86879
- setPendingApproval({ request, resolve: resolve13 });
87109
+ confirm: (request) => new Promise((resolve12) => {
87110
+ setPendingApproval({ request, resolve: resolve12 });
86880
87111
  })
86881
87112
  });
86882
87113
  return () => {
@@ -86959,14 +87190,14 @@ async function startVoiceRecording(opts = {}) {
86959
87190
  while (Buffer$1.concat(stderrChunks).byteLength > 16384)
86960
87191
  stderrChunks.shift();
86961
87192
  });
86962
- const closed = new Promise((resolve13) => {
87193
+ const closed = new Promise((resolve12) => {
86963
87194
  child.once("close", (code, signal) => {
86964
87195
  closeState = { code, signal };
86965
- resolve13();
87196
+ resolve12();
86966
87197
  });
86967
87198
  });
86968
- await new Promise((resolve13, reject) => {
86969
- child.once("spawn", resolve13);
87199
+ await new Promise((resolve12, reject) => {
87200
+ child.once("spawn", resolve12);
86970
87201
  child.once("error", (err) => reject(toSpawnError(command, err)));
86971
87202
  });
86972
87203
  let stopPromise = null;
@@ -86989,14 +87220,14 @@ async function checkVoiceCaptureAvailable(opts = {}) {
86989
87220
  const child = (opts.spawnImpl ?? spawn)(command, ["-version"], {
86990
87221
  stdio: ["ignore", "ignore", "ignore"]
86991
87222
  });
86992
- return new Promise((resolve13) => {
87223
+ return new Promise((resolve12) => {
86993
87224
  let settled = false;
86994
87225
  const done = (check) => {
86995
87226
  if (settled)
86996
87227
  return;
86997
87228
  settled = true;
86998
87229
  clearTimeout(timer);
86999
- resolve13(check);
87230
+ resolve12(check);
87000
87231
  };
87001
87232
  const timer = setTimeout(() => {
87002
87233
  if (!child.killed)
@@ -88213,6 +88444,13 @@ function modelBreakdownRows(file, liveByModel) {
88213
88444
  output: m3.outputTokens
88214
88445
  })).sort((a2, b3) => b3.prompt - a2.prompt);
88215
88446
  }
88447
+ function peak(series, seed = 0) {
88448
+ let m3 = seed;
88449
+ for (const v3 of series)
88450
+ if (v3 > m3)
88451
+ m3 = v3;
88452
+ return m3;
88453
+ }
88216
88454
  function perCallPrompt(events) {
88217
88455
  const out = [];
88218
88456
  for (const e3 of events) {
@@ -88297,7 +88535,7 @@ var init_UsagePanel = __esm({
88297
88535
  const subtitle = hasSession ? `${s2.calls} calls \xB7 ${fmt(s2.totalPrompt)} prompt \xB7 ${fmt(s2.totalOutput)} output` : "saved across sessions";
88298
88536
  const showSession = hasSession && (!tabs || activeTab === "session");
88299
88537
  const showLifetime = hasModels && (!tabs || activeTab === "lifetime");
88300
- return (0, import_jsx_runtime28.jsxs)(Modal, { title: "Usage", subtitle, ...tabs ? { tabs, activeTabId: activeTab, onTabChange: (id) => setActiveTab(id) } : {}, ...onClose ? { onClose } : {}, children: [showSession ? (0, import_jsx_runtime28.jsxs)(import_jsx_runtime28.Fragment, { children: [(0, import_jsx_runtime28.jsx)(Text, { bold: true, children: "Prompt composition" }), (0, import_jsx_runtime28.jsx)(CompRow, { label: "cache read", frac: readFrac, value: s2.totalCacheRead, color: Colors.active }), (0, import_jsx_runtime28.jsx)(CompRow, { label: "fresh input", frac: freshFrac, value: s2.totalInput }), (0, import_jsx_runtime28.jsx)(CompRow, { label: "cache write", frac: writeFrac, value: s2.totalCacheCreation, color: Colors.busy }), (0, import_jsx_runtime28.jsxs)(Box_default, { marginTop: 1, flexDirection: "column", children: [(0, import_jsx_runtime28.jsx)(MetricRow, { label: "Cache hit", frac: s2.cacheHitRate, color: s2.cacheHitRate >= 0.5 ? Colors.active : Colors.busy }), ctxFrac != null ? (0, import_jsx_runtime28.jsx)(MetricRow, { label: "Context fill", frac: ctxFrac, color: ctxColor, suffix: `${fmt(contextTokens ?? 0)} / ${fmt(contextWindow ?? 0)}` }) : null] }), (0, import_jsx_runtime28.jsxs)(Box_default, { marginTop: 1, children: [(0, import_jsx_runtime28.jsx)(Box_default, { width: LABEL_COL, children: (0, import_jsx_runtime28.jsx)(Text, { bold: true, children: "Input cost" }) }), (0, import_jsx_runtime28.jsxs)(Text, { children: [fmt(s2.billedInputEq), " billed-eq"] }), saved > 5e-3 ? (0, import_jsx_runtime28.jsx)(Text, { color: Colors.active, bold: true, children: ` saved ${pct(saved)}` }) : (0, import_jsx_runtime28.jsx)(Text, { dimColor: true, children: " no cache savings yet" })] }), (0, import_jsx_runtime28.jsxs)(Box_default, { marginTop: 1, flexDirection: "column", children: [(0, import_jsx_runtime28.jsxs)(Box_default, { children: [(0, import_jsx_runtime28.jsx)(Text, { bold: true, children: "Per-call prompt " }), (0, import_jsx_runtime28.jsx)(Text, { dimColor: true, children: `peak ${fmt(Math.max(...series, 0))}` })] }), (0, import_jsx_runtime28.jsxs)(Box_default, { children: [(0, import_jsx_runtime28.jsx)(Text, { children: sparkline(series) }), trend ? (0, import_jsx_runtime28.jsx)(Text, { color: trend === "growing" ? Colors.busy : Colors.active, children: trend === "growing" ? " \u2191 growing" : " \u2248 bounded" }) : null] })] }), !s2.cacheEffective ? (0, import_jsx_runtime28.jsx)(Box_default, { marginTop: 1, children: (0, import_jsx_runtime28.jsx)(Text, { color: Colors.danger, children: "\u26A0 cache ineffective \u2014 writing cache but not reading it back (prefix likely unstable)" }) }) : null] }) : null, showLifetime ? (0, import_jsx_runtime28.jsxs)(Box_default, { marginTop: showSession ? 1 : 0, flexDirection: "column", children: [(0, import_jsx_runtime28.jsxs)(Box_default, { children: [(0, import_jsx_runtime28.jsx)(Text, { bold: true, children: "By model " }), (0, import_jsx_runtime28.jsx)(Text, { dimColor: true, children: `(saved + this session \xB7 ${lifeRows.length} model${lifeRows.length === 1 ? "" : "s"})` })] }), lifeRows.slice(0, 8).map((r2) => (0, import_jsx_runtime28.jsx)(ModelRow, { name: r2.name, calls: r2.calls, prompt: r2.prompt, output: r2.output }, r2.name)), lifeRows.length > 1 ? (0, import_jsx_runtime28.jsx)(ModelRow, { name: "total", calls: lifeTotal.calls, prompt: lifeTotal.prompt, output: lifeTotal.output, dim: true }) : null, (0, import_jsx_runtime28.jsx)(Text, { dimColor: true, children: " /usage clear resets saved history" })] }) : null] });
88538
+ return (0, import_jsx_runtime28.jsxs)(Modal, { title: "Usage", subtitle, ...tabs ? { tabs, activeTabId: activeTab, onTabChange: (id) => setActiveTab(id) } : {}, ...onClose ? { onClose } : {}, children: [showSession ? (0, import_jsx_runtime28.jsxs)(import_jsx_runtime28.Fragment, { children: [(0, import_jsx_runtime28.jsx)(Text, { bold: true, children: "Prompt composition" }), (0, import_jsx_runtime28.jsx)(CompRow, { label: "cache read", frac: readFrac, value: s2.totalCacheRead, color: Colors.active }), (0, import_jsx_runtime28.jsx)(CompRow, { label: "fresh input", frac: freshFrac, value: s2.totalInput }), (0, import_jsx_runtime28.jsx)(CompRow, { label: "cache write", frac: writeFrac, value: s2.totalCacheCreation, color: Colors.busy }), (0, import_jsx_runtime28.jsxs)(Box_default, { marginTop: 1, flexDirection: "column", children: [(0, import_jsx_runtime28.jsx)(MetricRow, { label: "Cache hit", frac: s2.cacheHitRate, color: s2.cacheHitRate >= 0.5 ? Colors.active : Colors.busy }), ctxFrac != null ? (0, import_jsx_runtime28.jsx)(MetricRow, { label: "Context fill", frac: ctxFrac, color: ctxColor, suffix: `${fmt(contextTokens ?? 0)} / ${fmt(contextWindow ?? 0)}` }) : null] }), (0, import_jsx_runtime28.jsxs)(Box_default, { marginTop: 1, children: [(0, import_jsx_runtime28.jsx)(Box_default, { width: LABEL_COL, children: (0, import_jsx_runtime28.jsx)(Text, { bold: true, children: "Input cost" }) }), (0, import_jsx_runtime28.jsxs)(Text, { children: [fmt(s2.billedInputEq), " billed-eq"] }), saved > 5e-3 ? (0, import_jsx_runtime28.jsx)(Text, { color: Colors.active, bold: true, children: ` saved ${pct(saved)}` }) : (0, import_jsx_runtime28.jsx)(Text, { dimColor: true, children: " no cache savings yet" })] }), (0, import_jsx_runtime28.jsxs)(Box_default, { marginTop: 1, flexDirection: "column", children: [(0, import_jsx_runtime28.jsxs)(Box_default, { children: [(0, import_jsx_runtime28.jsx)(Text, { bold: true, children: "Per-call prompt " }), (0, import_jsx_runtime28.jsx)(Text, { dimColor: true, children: `peak ${fmt(peak(series))}` })] }), (0, import_jsx_runtime28.jsxs)(Box_default, { children: [(0, import_jsx_runtime28.jsx)(Text, { children: sparkline(series) }), trend ? (0, import_jsx_runtime28.jsx)(Text, { color: trend === "growing" ? Colors.busy : Colors.active, children: trend === "growing" ? " \u2191 growing" : " \u2248 bounded" }) : null] })] }), !s2.cacheEffective ? (0, import_jsx_runtime28.jsx)(Box_default, { marginTop: 1, children: (0, import_jsx_runtime28.jsx)(Text, { color: Colors.danger, children: "\u26A0 cache ineffective \u2014 writing cache but not reading it back (prefix likely unstable)" }) }) : null] }) : null, showLifetime ? (0, import_jsx_runtime28.jsxs)(Box_default, { marginTop: showSession ? 1 : 0, flexDirection: "column", children: [(0, import_jsx_runtime28.jsxs)(Box_default, { children: [(0, import_jsx_runtime28.jsx)(Text, { bold: true, children: "By model " }), (0, import_jsx_runtime28.jsx)(Text, { dimColor: true, children: `(saved + this session \xB7 ${lifeRows.length} model${lifeRows.length === 1 ? "" : "s"})` })] }), lifeRows.slice(0, 8).map((r2) => (0, import_jsx_runtime28.jsx)(ModelRow, { name: r2.name, calls: r2.calls, prompt: r2.prompt, output: r2.output }, r2.name)), lifeRows.length > 1 ? (0, import_jsx_runtime28.jsx)(ModelRow, { name: "total", calls: lifeTotal.calls, prompt: lifeTotal.prompt, output: lifeTotal.output, dim: true }) : null, (0, import_jsx_runtime28.jsx)(Text, { dimColor: true, children: " /usage clear resets saved history" })] }) : null] });
88301
88539
  };
88302
88540
  }
88303
88541
  });
@@ -89133,9 +89371,9 @@ var init_SessionView = __esm({
89133
89371
  }, onApprovalDecide: (decision) => {
89134
89372
  if (!pendingApproval)
89135
89373
  return;
89136
- const { resolve: resolve13 } = pendingApproval;
89374
+ const { resolve: resolve12 } = pendingApproval;
89137
89375
  permissions.setPendingApproval(null);
89138
- resolve13(decision);
89376
+ resolve12(decision);
89139
89377
  }, onPickerSelect: handlePickerSelect, onPickerCancel: () => setPicker(null), onSubmit: handleSubmit, onPasteText: images.handlePasteText }), (0, import_jsx_runtime36.jsx)(StatusLine, { busyStartedAt: turn.busy && !pendingPermission && !pendingApproval ? turn.busyStartedAt : null, queueCount: turn.queueCount, modeName, modeBadge, provider: providerName2, model: activeModel2, mcp: mcpStatus, contextUsed, ...contextWindow ? { contextWindow } : {}, ...version ? { version } : {}, ...updateAvailable ? { updateLatest: updateAvailable.latest } : {} })] });
89140
89378
  };
89141
89379
  }
@@ -91103,10 +91341,10 @@ var require_segments = __commonJS({
91103
91341
  const segs = getSegmentsFromString(data, Utils.isKanjiModeEnabled());
91104
91342
  const nodes = buildNodes(segs);
91105
91343
  const graph = buildGraph(nodes, version);
91106
- const path60 = dijkstra.find_path(graph.map, "start", "end");
91344
+ const path59 = dijkstra.find_path(graph.map, "start", "end");
91107
91345
  const optimizedSegs = [];
91108
- for (let i2 = 1; i2 < path60.length - 1; i2++) {
91109
- optimizedSegs.push(graph.table[path60[i2]].node);
91346
+ for (let i2 = 1; i2 < path59.length - 1; i2++) {
91347
+ optimizedSegs.push(graph.table[path59[i2]].node);
91110
91348
  }
91111
91349
  return exports.fromArray(mergeSegments(optimizedSegs));
91112
91350
  };
@@ -93558,7 +93796,7 @@ var require_png2 = __commonJS({
93558
93796
  });
93559
93797
  png.pack();
93560
93798
  };
93561
- exports.renderToFile = function renderToFile(path60, qrData, options, cb) {
93799
+ exports.renderToFile = function renderToFile(path59, qrData, options, cb) {
93562
93800
  if (typeof cb === "undefined") {
93563
93801
  cb = options;
93564
93802
  options = void 0;
@@ -93569,7 +93807,7 @@ var require_png2 = __commonJS({
93569
93807
  called = true;
93570
93808
  cb.apply(null, args);
93571
93809
  };
93572
- const stream = fs45.createWriteStream(path60);
93810
+ const stream = fs45.createWriteStream(path59);
93573
93811
  stream.on("error", done);
93574
93812
  stream.on("close", done);
93575
93813
  exports.renderToFileStream(stream, qrData, options);
@@ -93631,14 +93869,14 @@ var require_utf8 = __commonJS({
93631
93869
  }
93632
93870
  return output;
93633
93871
  };
93634
- exports.renderToFile = function renderToFile(path60, qrData, options, cb) {
93872
+ exports.renderToFile = function renderToFile(path59, qrData, options, cb) {
93635
93873
  if (typeof cb === "undefined") {
93636
93874
  cb = options;
93637
93875
  options = void 0;
93638
93876
  }
93639
93877
  const fs45 = __require("fs");
93640
93878
  const utf8 = exports.render(qrData, options);
93641
- fs45.writeFile(path60, utf8, cb);
93879
+ fs45.writeFile(path59, utf8, cb);
93642
93880
  };
93643
93881
  }
93644
93882
  });
@@ -93759,7 +93997,7 @@ var require_svg_tag = __commonJS({
93759
93997
  return str2;
93760
93998
  }
93761
93999
  function qrToPath(data, size, margin) {
93762
- let path60 = "";
94000
+ let path59 = "";
93763
94001
  let moveBy = 0;
93764
94002
  let newRow = false;
93765
94003
  let lineLength = 0;
@@ -93770,19 +94008,19 @@ var require_svg_tag = __commonJS({
93770
94008
  if (data[i2]) {
93771
94009
  lineLength++;
93772
94010
  if (!(i2 > 0 && col > 0 && data[i2 - 1])) {
93773
- path60 += newRow ? svgCmd("M", col + margin, 0.5 + row + margin) : svgCmd("m", moveBy, 0);
94011
+ path59 += newRow ? svgCmd("M", col + margin, 0.5 + row + margin) : svgCmd("m", moveBy, 0);
93774
94012
  moveBy = 0;
93775
94013
  newRow = false;
93776
94014
  }
93777
94015
  if (!(col + 1 < size && data[i2 + 1])) {
93778
- path60 += svgCmd("h", lineLength);
94016
+ path59 += svgCmd("h", lineLength);
93779
94017
  lineLength = 0;
93780
94018
  }
93781
94019
  } else {
93782
94020
  moveBy++;
93783
94021
  }
93784
94022
  }
93785
- return path60;
94023
+ return path59;
93786
94024
  }
93787
94025
  exports.render = function render2(qrData, options, cb) {
93788
94026
  const opts = Utils.getOptions(options);
@@ -93790,10 +94028,10 @@ var require_svg_tag = __commonJS({
93790
94028
  const data = qrData.modules.data;
93791
94029
  const qrcodesize = size + opts.margin * 2;
93792
94030
  const bg = !opts.color.light.a ? "" : "<path " + getColorAttrib(opts.color.light, "fill") + ' d="M0 0h' + qrcodesize + "v" + qrcodesize + 'H0z"/>';
93793
- const path60 = "<path " + getColorAttrib(opts.color.dark, "stroke") + ' d="' + qrToPath(data, size, opts.margin) + '"/>';
94031
+ const path59 = "<path " + getColorAttrib(opts.color.dark, "stroke") + ' d="' + qrToPath(data, size, opts.margin) + '"/>';
93794
94032
  const viewBox = 'viewBox="0 0 ' + qrcodesize + " " + qrcodesize + '"';
93795
94033
  const width = !opts.width ? "" : 'width="' + opts.width + '" height="' + opts.width + '" ';
93796
- const svgTag = '<svg xmlns="http://www.w3.org/2000/svg" ' + width + viewBox + ' shape-rendering="crispEdges">' + bg + path60 + "</svg>\n";
94034
+ const svgTag = '<svg xmlns="http://www.w3.org/2000/svg" ' + width + viewBox + ' shape-rendering="crispEdges">' + bg + path59 + "</svg>\n";
93797
94035
  if (typeof cb === "function") {
93798
94036
  cb(null, svgTag);
93799
94037
  }
@@ -93807,7 +94045,7 @@ var require_svg = __commonJS({
93807
94045
  "../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/renderer/svg.js"(exports) {
93808
94046
  var svgTagRenderer = require_svg_tag();
93809
94047
  exports.render = svgTagRenderer.render;
93810
- exports.renderToFile = function renderToFile(path60, qrData, options, cb) {
94048
+ exports.renderToFile = function renderToFile(path59, qrData, options, cb) {
93811
94049
  if (typeof cb === "undefined") {
93812
94050
  cb = options;
93813
94051
  options = void 0;
@@ -93815,7 +94053,7 @@ var require_svg = __commonJS({
93815
94053
  const fs45 = __require("fs");
93816
94054
  const svgTag = exports.render(qrData, options);
93817
94055
  const xmlStr = '<?xml version="1.0" encoding="utf-8"?><!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">' + svgTag;
93818
- fs45.writeFile(path60, xmlStr, cb);
94056
+ fs45.writeFile(path59, xmlStr, cb);
93819
94057
  };
93820
94058
  }
93821
94059
  });
@@ -93918,10 +94156,10 @@ var require_browser2 = __commonJS({
93918
94156
  text = canvas;
93919
94157
  canvas = void 0;
93920
94158
  }
93921
- return new Promise(function(resolve13, reject) {
94159
+ return new Promise(function(resolve12, reject) {
93922
94160
  try {
93923
94161
  const data = QRCode2.create(text, opts);
93924
- resolve13(renderFunc(data, canvas, opts));
94162
+ resolve12(renderFunc(data, canvas, opts));
93925
94163
  } catch (e3) {
93926
94164
  reject(e3);
93927
94165
  }
@@ -93973,8 +94211,8 @@ var require_server = __commonJS({
93973
94211
  cb
93974
94212
  };
93975
94213
  }
93976
- function getTypeFromFilename(path60) {
93977
- return path60.slice((path60.lastIndexOf(".") - 1 >>> 0) + 2).toLowerCase();
94214
+ function getTypeFromFilename(path59) {
94215
+ return path59.slice((path59.lastIndexOf(".") - 1 >>> 0) + 2).toLowerCase();
93978
94216
  }
93979
94217
  function getRendererFromType(type) {
93980
94218
  switch (type) {
@@ -94002,11 +94240,11 @@ var require_server = __commonJS({
94002
94240
  }
94003
94241
  function render2(renderFunc, text, params) {
94004
94242
  if (!params.cb) {
94005
- return new Promise(function(resolve13, reject) {
94243
+ return new Promise(function(resolve12, reject) {
94006
94244
  try {
94007
94245
  const data = QRCode2.create(text, params.opts);
94008
94246
  return renderFunc(data, params.opts, function(err, data2) {
94009
- return err ? reject(err) : resolve13(data2);
94247
+ return err ? reject(err) : resolve12(data2);
94010
94248
  });
94011
94249
  } catch (e3) {
94012
94250
  reject(e3);
@@ -94038,17 +94276,17 @@ var require_server = __commonJS({
94038
94276
  const renderer2 = getRendererFromType(params.opts.type);
94039
94277
  return render2(renderer2.renderToBuffer, text, params);
94040
94278
  };
94041
- exports.toFile = function toFile3(path60, text, opts, cb) {
94042
- if (typeof path60 !== "string" || !(typeof text === "string" || typeof text === "object")) {
94279
+ exports.toFile = function toFile3(path59, text, opts, cb) {
94280
+ if (typeof path59 !== "string" || !(typeof text === "string" || typeof text === "object")) {
94043
94281
  throw new Error("Invalid argument");
94044
94282
  }
94045
94283
  if (arguments.length < 3 && !canPromise()) {
94046
94284
  throw new Error("Too few arguments provided");
94047
94285
  }
94048
94286
  const params = checkParams(text, opts, cb);
94049
- const type = params.opts.type || getTypeFromFilename(path60);
94287
+ const type = params.opts.type || getTypeFromFilename(path59);
94050
94288
  const renderer2 = getRendererFromType(type);
94051
- const renderToFile = renderer2.renderToFile.bind(null, path60);
94289
+ const renderToFile = renderer2.renderToFile.bind(null, path59);
94052
94290
  return render2(renderToFile, text, params);
94053
94291
  };
94054
94292
  exports.toFileStream = function toFileStream(stream, text, opts) {
@@ -94868,14 +95106,14 @@ var require_util2 = __commonJS({
94868
95106
  }
94869
95107
  const port = url2.port != null ? url2.port : url2.protocol === "https:" ? 443 : 80;
94870
95108
  let origin = url2.origin != null ? url2.origin : `${url2.protocol || ""}//${url2.hostname || ""}:${port}`;
94871
- let path60 = url2.path != null ? url2.path : `${url2.pathname || ""}${url2.search || ""}`;
95109
+ let path59 = url2.path != null ? url2.path : `${url2.pathname || ""}${url2.search || ""}`;
94872
95110
  if (origin[origin.length - 1] === "/") {
94873
95111
  origin = origin.slice(0, origin.length - 1);
94874
95112
  }
94875
- if (path60 && path60[0] !== "/") {
94876
- path60 = `/${path60}`;
95113
+ if (path59 && path59[0] !== "/") {
95114
+ path59 = `/${path59}`;
94877
95115
  }
94878
- return new URL(`${origin}${path60}`);
95116
+ return new URL(`${origin}${path59}`);
94879
95117
  }
94880
95118
  if (!isHttpOrHttpsPrefixed(url2.origin || url2.protocol)) {
94881
95119
  throw new InvalidArgumentError("Invalid URL protocol: the URL must start with `http:` or `https:`.");
@@ -95325,39 +95563,39 @@ var require_diagnostics = __commonJS({
95325
95563
  });
95326
95564
  diagnosticsChannel.channel("undici:client:sendHeaders").subscribe((evt) => {
95327
95565
  const {
95328
- request: { method, path: path60, origin }
95566
+ request: { method, path: path59, origin }
95329
95567
  } = evt;
95330
- debuglog("sending request to %s %s/%s", method, origin, path60);
95568
+ debuglog("sending request to %s %s/%s", method, origin, path59);
95331
95569
  });
95332
95570
  diagnosticsChannel.channel("undici:request:headers").subscribe((evt) => {
95333
95571
  const {
95334
- request: { method, path: path60, origin },
95572
+ request: { method, path: path59, origin },
95335
95573
  response: { statusCode }
95336
95574
  } = evt;
95337
95575
  debuglog(
95338
95576
  "received response to %s %s/%s - HTTP %d",
95339
95577
  method,
95340
95578
  origin,
95341
- path60,
95579
+ path59,
95342
95580
  statusCode
95343
95581
  );
95344
95582
  });
95345
95583
  diagnosticsChannel.channel("undici:request:trailers").subscribe((evt) => {
95346
95584
  const {
95347
- request: { method, path: path60, origin }
95585
+ request: { method, path: path59, origin }
95348
95586
  } = evt;
95349
- debuglog("trailers received from %s %s/%s", method, origin, path60);
95587
+ debuglog("trailers received from %s %s/%s", method, origin, path59);
95350
95588
  });
95351
95589
  diagnosticsChannel.channel("undici:request:error").subscribe((evt) => {
95352
95590
  const {
95353
- request: { method, path: path60, origin },
95591
+ request: { method, path: path59, origin },
95354
95592
  error: error2
95355
95593
  } = evt;
95356
95594
  debuglog(
95357
95595
  "request to %s %s/%s errored - %s",
95358
95596
  method,
95359
95597
  origin,
95360
- path60,
95598
+ path59,
95361
95599
  error2.message
95362
95600
  );
95363
95601
  });
@@ -95406,9 +95644,9 @@ var require_diagnostics = __commonJS({
95406
95644
  });
95407
95645
  diagnosticsChannel.channel("undici:client:sendHeaders").subscribe((evt) => {
95408
95646
  const {
95409
- request: { method, path: path60, origin }
95647
+ request: { method, path: path59, origin }
95410
95648
  } = evt;
95411
- debuglog("sending request to %s %s/%s", method, origin, path60);
95649
+ debuglog("sending request to %s %s/%s", method, origin, path59);
95412
95650
  });
95413
95651
  }
95414
95652
  diagnosticsChannel.channel("undici:websocket:open").subscribe((evt) => {
@@ -95470,7 +95708,7 @@ var require_request = __commonJS({
95470
95708
  var kHandler = /* @__PURE__ */ Symbol("handler");
95471
95709
  var Request4 = class {
95472
95710
  constructor(origin, {
95473
- path: path60,
95711
+ path: path59,
95474
95712
  method,
95475
95713
  body,
95476
95714
  headers,
@@ -95485,11 +95723,11 @@ var require_request = __commonJS({
95485
95723
  expectContinue,
95486
95724
  servername
95487
95725
  }, handler) {
95488
- if (typeof path60 !== "string") {
95726
+ if (typeof path59 !== "string") {
95489
95727
  throw new InvalidArgumentError("path must be a string");
95490
- } else if (path60[0] !== "/" && !(path60.startsWith("http://") || path60.startsWith("https://")) && method !== "CONNECT") {
95728
+ } else if (path59[0] !== "/" && !(path59.startsWith("http://") || path59.startsWith("https://")) && method !== "CONNECT") {
95491
95729
  throw new InvalidArgumentError("path must be an absolute URL or start with a slash");
95492
- } else if (invalidPathRegex.test(path60)) {
95730
+ } else if (invalidPathRegex.test(path59)) {
95493
95731
  throw new InvalidArgumentError("invalid request path");
95494
95732
  }
95495
95733
  if (typeof method !== "string") {
@@ -95555,7 +95793,7 @@ var require_request = __commonJS({
95555
95793
  this.completed = false;
95556
95794
  this.aborted = false;
95557
95795
  this.upgrade = upgrade || null;
95558
- this.path = query ? buildURL(path60, query) : path60;
95796
+ this.path = query ? buildURL(path59, query) : path59;
95559
95797
  this.origin = origin;
95560
95798
  this.idempotent = idempotent == null ? method === "HEAD" || method === "GET" : idempotent;
95561
95799
  this.blocking = blocking == null ? false : blocking;
@@ -95878,9 +96116,9 @@ var require_dispatcher_base = __commonJS({
95878
96116
  }
95879
96117
  close(callback) {
95880
96118
  if (callback === void 0) {
95881
- return new Promise((resolve13, reject) => {
96119
+ return new Promise((resolve12, reject) => {
95882
96120
  this.close((err, data) => {
95883
- return err ? reject(err) : resolve13(data);
96121
+ return err ? reject(err) : resolve12(data);
95884
96122
  });
95885
96123
  });
95886
96124
  }
@@ -95918,12 +96156,12 @@ var require_dispatcher_base = __commonJS({
95918
96156
  err = null;
95919
96157
  }
95920
96158
  if (callback === void 0) {
95921
- return new Promise((resolve13, reject) => {
96159
+ return new Promise((resolve12, reject) => {
95922
96160
  this.destroy(err, (err2, data) => {
95923
96161
  return err2 ? (
95924
96162
  /* istanbul ignore next: should never error */
95925
96163
  reject(err2)
95926
- ) : resolve13(data);
96164
+ ) : resolve12(data);
95927
96165
  });
95928
96166
  });
95929
96167
  }
@@ -98173,8 +98411,8 @@ var require_util3 = __commonJS({
98173
98411
  function createDeferredPromise() {
98174
98412
  let res;
98175
98413
  let rej;
98176
- const promise = new Promise((resolve13, reject) => {
98177
- res = resolve13;
98414
+ const promise = new Promise((resolve12, reject) => {
98415
+ res = resolve12;
98178
98416
  rej = reject;
98179
98417
  });
98180
98418
  return { promise, resolve: res, reject: rej };
@@ -100093,7 +100331,7 @@ var require_client_h1 = __commonJS({
100093
100331
  return method !== "GET" && method !== "HEAD" && method !== "OPTIONS" && method !== "TRACE" && method !== "CONNECT";
100094
100332
  }
100095
100333
  function writeH1(client, request) {
100096
- const { method, path: path60, host, upgrade, blocking, reset } = request;
100334
+ const { method, path: path59, host, upgrade, blocking, reset } = request;
100097
100335
  let { body, headers, contentLength } = request;
100098
100336
  const expectsPayload = method === "PUT" || method === "POST" || method === "PATCH" || method === "QUERY" || method === "PROPFIND" || method === "PROPPATCH";
100099
100337
  if (util.isFormDataLike(body)) {
@@ -100159,7 +100397,7 @@ var require_client_h1 = __commonJS({
100159
100397
  if (blocking) {
100160
100398
  socket[kBlocking] = true;
100161
100399
  }
100162
- let header = `${method} ${path60} HTTP/1.1\r
100400
+ let header = `${method} ${path59} HTTP/1.1\r
100163
100401
  `;
100164
100402
  if (typeof host === "string") {
100165
100403
  header += `host: ${host}\r
@@ -100346,12 +100584,12 @@ upgrade: ${upgrade}\r
100346
100584
  cb();
100347
100585
  }
100348
100586
  }
100349
- const waitForDrain = () => new Promise((resolve13, reject) => {
100587
+ const waitForDrain = () => new Promise((resolve12, reject) => {
100350
100588
  assert(callback === null);
100351
100589
  if (socket[kError]) {
100352
100590
  reject(socket[kError]);
100353
100591
  } else {
100354
- callback = resolve13;
100592
+ callback = resolve12;
100355
100593
  }
100356
100594
  });
100357
100595
  socket.on("close", onDrain).on("drain", onDrain);
@@ -100684,7 +100922,7 @@ var require_client_h2 = __commonJS({
100684
100922
  }
100685
100923
  function writeH2(client, request) {
100686
100924
  const session = client[kHTTP2Session];
100687
- const { method, path: path60, host, upgrade, expectContinue, signal, headers: reqHeaders } = request;
100925
+ const { method, path: path59, host, upgrade, expectContinue, signal, headers: reqHeaders } = request;
100688
100926
  let { body } = request;
100689
100927
  if (upgrade) {
100690
100928
  util.errorRequest(client, request, new Error("Upgrade not supported for H2"));
@@ -100751,7 +100989,7 @@ var require_client_h2 = __commonJS({
100751
100989
  });
100752
100990
  return true;
100753
100991
  }
100754
- headers[HTTP2_HEADER_PATH] = path60;
100992
+ headers[HTTP2_HEADER_PATH] = path59;
100755
100993
  headers[HTTP2_HEADER_SCHEME] = "https";
100756
100994
  const expectsPayload = method === "PUT" || method === "POST" || method === "PATCH";
100757
100995
  if (body && typeof body.read === "function") {
@@ -100987,12 +101225,12 @@ var require_client_h2 = __commonJS({
100987
101225
  cb();
100988
101226
  }
100989
101227
  }
100990
- const waitForDrain = () => new Promise((resolve13, reject) => {
101228
+ const waitForDrain = () => new Promise((resolve12, reject) => {
100991
101229
  assert(callback === null);
100992
101230
  if (socket[kError]) {
100993
101231
  reject(socket[kError]);
100994
101232
  } else {
100995
- callback = resolve13;
101233
+ callback = resolve12;
100996
101234
  }
100997
101235
  });
100998
101236
  h2stream.on("close", onDrain).on("drain", onDrain);
@@ -101103,9 +101341,9 @@ var require_redirect_handler = __commonJS({
101103
101341
  return this.handler.onHeaders(statusCode, headers, resume, statusText);
101104
101342
  }
101105
101343
  const { origin, pathname, search } = util.parseURL(new URL(this.location, this.opts.origin && new URL(this.opts.path, this.opts.origin)));
101106
- const path60 = search ? `${pathname}${search}` : pathname;
101344
+ const path59 = search ? `${pathname}${search}` : pathname;
101107
101345
  this.opts.headers = cleanRequestHeaders(this.opts.headers, statusCode === 303, this.opts.origin !== origin);
101108
- this.opts.path = path60;
101346
+ this.opts.path = path59;
101109
101347
  this.opts.origin = origin;
101110
101348
  this.opts.maxRedirections = 0;
101111
101349
  this.opts.query = null;
@@ -101465,16 +101703,16 @@ var require_client2 = __commonJS({
101465
101703
  return this[kNeedDrain] < 2;
101466
101704
  }
101467
101705
  async [kClose]() {
101468
- return new Promise((resolve13) => {
101706
+ return new Promise((resolve12) => {
101469
101707
  if (this[kSize]) {
101470
- this[kClosedResolve] = resolve13;
101708
+ this[kClosedResolve] = resolve12;
101471
101709
  } else {
101472
- resolve13(null);
101710
+ resolve12(null);
101473
101711
  }
101474
101712
  });
101475
101713
  }
101476
101714
  async [kDestroy](err) {
101477
- return new Promise((resolve13) => {
101715
+ return new Promise((resolve12) => {
101478
101716
  const requests = this[kQueue].splice(this[kPendingIdx]);
101479
101717
  for (let i2 = 0; i2 < requests.length; i2++) {
101480
101718
  const request = requests[i2];
@@ -101485,7 +101723,7 @@ var require_client2 = __commonJS({
101485
101723
  this[kClosedResolve]();
101486
101724
  this[kClosedResolve] = null;
101487
101725
  }
101488
- resolve13(null);
101726
+ resolve12(null);
101489
101727
  };
101490
101728
  if (this[kHTTPContext]) {
101491
101729
  this[kHTTPContext].destroy(err, callback);
@@ -101536,7 +101774,7 @@ var require_client2 = __commonJS({
101536
101774
  });
101537
101775
  }
101538
101776
  try {
101539
- const socket = await new Promise((resolve13, reject) => {
101777
+ const socket = await new Promise((resolve12, reject) => {
101540
101778
  client[kConnector]({
101541
101779
  host,
101542
101780
  hostname,
@@ -101548,7 +101786,7 @@ var require_client2 = __commonJS({
101548
101786
  if (err) {
101549
101787
  reject(err);
101550
101788
  } else {
101551
- resolve13(socket2);
101789
+ resolve12(socket2);
101552
101790
  }
101553
101791
  });
101554
101792
  });
@@ -101882,8 +102120,8 @@ var require_pool_base = __commonJS({
101882
102120
  if (this[kQueue].isEmpty()) {
101883
102121
  await Promise.all(this[kClients].map((c2) => c2.close()));
101884
102122
  } else {
101885
- await new Promise((resolve13) => {
101886
- this[kClosedResolve] = resolve13;
102123
+ await new Promise((resolve12) => {
102124
+ this[kClosedResolve] = resolve12;
101887
102125
  });
101888
102126
  }
101889
102127
  }
@@ -102330,10 +102568,10 @@ var require_proxy_agent = __commonJS({
102330
102568
  };
102331
102569
  const {
102332
102570
  origin,
102333
- path: path60 = "/",
102571
+ path: path59 = "/",
102334
102572
  headers = {}
102335
102573
  } = opts;
102336
- opts.path = origin + path60;
102574
+ opts.path = origin + path59;
102337
102575
  if (!("host" in headers) && !("Host" in headers)) {
102338
102576
  const { host } = new URL3(origin);
102339
102577
  headers.host = host;
@@ -103090,7 +103328,7 @@ var require_readable = __commonJS({
103090
103328
  if (this._readableState.closeEmitted) {
103091
103329
  return null;
103092
103330
  }
103093
- return await new Promise((resolve13, reject) => {
103331
+ return await new Promise((resolve12, reject) => {
103094
103332
  if (this[kContentLength] > limit2) {
103095
103333
  this.destroy(new AbortError2());
103096
103334
  }
@@ -103103,7 +103341,7 @@ var require_readable = __commonJS({
103103
103341
  if (signal?.aborted) {
103104
103342
  reject(signal.reason ?? new AbortError2());
103105
103343
  } else {
103106
- resolve13(null);
103344
+ resolve12(null);
103107
103345
  }
103108
103346
  }).on("error", noop3).on("data", function(chunk) {
103109
103347
  limit2 -= chunk.length;
@@ -103122,7 +103360,7 @@ var require_readable = __commonJS({
103122
103360
  }
103123
103361
  async function consume(stream, type) {
103124
103362
  assert(!stream[kConsume]);
103125
- return new Promise((resolve13, reject) => {
103363
+ return new Promise((resolve12, reject) => {
103126
103364
  if (isUnusable(stream)) {
103127
103365
  const rState = stream._readableState;
103128
103366
  if (rState.destroyed && rState.closeEmitted === false) {
@@ -103139,7 +103377,7 @@ var require_readable = __commonJS({
103139
103377
  stream[kConsume] = {
103140
103378
  type,
103141
103379
  stream,
103142
- resolve: resolve13,
103380
+ resolve: resolve12,
103143
103381
  reject,
103144
103382
  length: 0,
103145
103383
  body: []
@@ -103209,18 +103447,18 @@ var require_readable = __commonJS({
103209
103447
  return buffer;
103210
103448
  }
103211
103449
  function consumeEnd(consume2) {
103212
- const { type, body, resolve: resolve13, stream, length } = consume2;
103450
+ const { type, body, resolve: resolve12, stream, length } = consume2;
103213
103451
  try {
103214
103452
  if (type === "text") {
103215
- resolve13(chunksDecode(body, length));
103453
+ resolve12(chunksDecode(body, length));
103216
103454
  } else if (type === "json") {
103217
- resolve13(JSON.parse(chunksDecode(body, length)));
103455
+ resolve12(JSON.parse(chunksDecode(body, length)));
103218
103456
  } else if (type === "arrayBuffer") {
103219
- resolve13(chunksConcat(body, length).buffer);
103457
+ resolve12(chunksConcat(body, length).buffer);
103220
103458
  } else if (type === "blob") {
103221
- resolve13(new Blob(body, { type: stream[kContentType] }));
103459
+ resolve12(new Blob(body, { type: stream[kContentType] }));
103222
103460
  } else if (type === "bytes") {
103223
- resolve13(chunksConcat(body, length));
103461
+ resolve12(chunksConcat(body, length));
103224
103462
  }
103225
103463
  consumeFinish(consume2);
103226
103464
  } catch (err) {
@@ -103476,9 +103714,9 @@ var require_api_request = __commonJS({
103476
103714
  };
103477
103715
  function request(opts, callback) {
103478
103716
  if (callback === void 0) {
103479
- return new Promise((resolve13, reject) => {
103717
+ return new Promise((resolve12, reject) => {
103480
103718
  request.call(this, opts, (err, data) => {
103481
- return err ? reject(err) : resolve13(data);
103719
+ return err ? reject(err) : resolve12(data);
103482
103720
  });
103483
103721
  });
103484
103722
  }
@@ -103700,9 +103938,9 @@ var require_api_stream = __commonJS({
103700
103938
  };
103701
103939
  function stream(opts, factory2, callback) {
103702
103940
  if (callback === void 0) {
103703
- return new Promise((resolve13, reject) => {
103941
+ return new Promise((resolve12, reject) => {
103704
103942
  stream.call(this, opts, factory2, (err, data) => {
103705
- return err ? reject(err) : resolve13(data);
103943
+ return err ? reject(err) : resolve12(data);
103706
103944
  });
103707
103945
  });
103708
103946
  }
@@ -103985,9 +104223,9 @@ var require_api_upgrade = __commonJS({
103985
104223
  };
103986
104224
  function upgrade(opts, callback) {
103987
104225
  if (callback === void 0) {
103988
- return new Promise((resolve13, reject) => {
104226
+ return new Promise((resolve12, reject) => {
103989
104227
  upgrade.call(this, opts, (err, data) => {
103990
- return err ? reject(err) : resolve13(data);
104228
+ return err ? reject(err) : resolve12(data);
103991
104229
  });
103992
104230
  });
103993
104231
  }
@@ -104078,9 +104316,9 @@ var require_api_connect = __commonJS({
104078
104316
  };
104079
104317
  function connect(opts, callback) {
104080
104318
  if (callback === void 0) {
104081
- return new Promise((resolve13, reject) => {
104319
+ return new Promise((resolve12, reject) => {
104082
104320
  connect.call(this, opts, (err, data) => {
104083
- return err ? reject(err) : resolve13(data);
104321
+ return err ? reject(err) : resolve12(data);
104084
104322
  });
104085
104323
  });
104086
104324
  }
@@ -104241,20 +104479,20 @@ var require_mock_utils = __commonJS({
104241
104479
  }
104242
104480
  return true;
104243
104481
  }
104244
- function safeUrl(path60) {
104245
- if (typeof path60 !== "string") {
104246
- return path60;
104482
+ function safeUrl(path59) {
104483
+ if (typeof path59 !== "string") {
104484
+ return path59;
104247
104485
  }
104248
- const pathSegments = path60.split("?");
104486
+ const pathSegments = path59.split("?");
104249
104487
  if (pathSegments.length !== 2) {
104250
- return path60;
104488
+ return path59;
104251
104489
  }
104252
104490
  const qp = new URLSearchParams(pathSegments.pop());
104253
104491
  qp.sort();
104254
104492
  return [...pathSegments, qp.toString()].join("?");
104255
104493
  }
104256
- function matchKey(mockDispatch2, { path: path60, method, body, headers }) {
104257
- const pathMatch = matchValue(mockDispatch2.path, path60);
104494
+ function matchKey(mockDispatch2, { path: path59, method, body, headers }) {
104495
+ const pathMatch = matchValue(mockDispatch2.path, path59);
104258
104496
  const methodMatch = matchValue(mockDispatch2.method, method);
104259
104497
  const bodyMatch = typeof mockDispatch2.body !== "undefined" ? matchValue(mockDispatch2.body, body) : true;
104260
104498
  const headersMatch = matchHeaders(mockDispatch2, headers);
@@ -104276,7 +104514,7 @@ var require_mock_utils = __commonJS({
104276
104514
  function getMockDispatch(mockDispatches, key) {
104277
104515
  const basePath = key.query ? buildURL(key.path, key.query) : key.path;
104278
104516
  const resolvedPath = typeof basePath === "string" ? safeUrl(basePath) : basePath;
104279
- let matchedMockDispatches = mockDispatches.filter(({ consumed }) => !consumed).filter(({ path: path60 }) => matchValue(safeUrl(path60), resolvedPath));
104517
+ let matchedMockDispatches = mockDispatches.filter(({ consumed }) => !consumed).filter(({ path: path59 }) => matchValue(safeUrl(path59), resolvedPath));
104280
104518
  if (matchedMockDispatches.length === 0) {
104281
104519
  throw new MockNotMatchedError(`Mock dispatch not matched for path '${resolvedPath}'`);
104282
104520
  }
@@ -104314,9 +104552,9 @@ var require_mock_utils = __commonJS({
104314
104552
  }
104315
104553
  }
104316
104554
  function buildKey(opts) {
104317
- const { path: path60, method, body, headers, query } = opts;
104555
+ const { path: path59, method, body, headers, query } = opts;
104318
104556
  return {
104319
- path: path60,
104557
+ path: path59,
104320
104558
  method,
104321
104559
  body,
104322
104560
  headers,
@@ -104774,10 +105012,10 @@ var require_pending_interceptors_formatter = __commonJS({
104774
105012
  }
104775
105013
  format(pendingInterceptors) {
104776
105014
  const withPrettyHeaders = pendingInterceptors.map(
104777
- ({ method, path: path60, data: { statusCode }, persist, times, timesInvoked, origin }) => ({
105015
+ ({ method, path: path59, data: { statusCode }, persist, times, timesInvoked, origin }) => ({
104778
105016
  Method: method,
104779
105017
  Origin: origin,
104780
- Path: path60,
105018
+ Path: path59,
104781
105019
  "Status code": statusCode,
104782
105020
  Persistent: persist ? PERSISTENT : NOT_PERSISTENT,
104783
105021
  Invocations: timesInvoked,
@@ -107902,7 +108140,7 @@ var require_fetch = __commonJS({
107902
108140
  function dispatch3({ body }) {
107903
108141
  const url2 = requestCurrentURL(request);
107904
108142
  const agent = fetchParams.controller.dispatcher;
107905
- return new Promise((resolve13, reject) => agent.dispatch(
108143
+ return new Promise((resolve12, reject) => agent.dispatch(
107906
108144
  {
107907
108145
  path: url2.pathname + url2.search,
107908
108146
  origin: url2.origin,
@@ -107978,7 +108216,7 @@ var require_fetch = __commonJS({
107978
108216
  }
107979
108217
  }
107980
108218
  const onError2 = this.onError.bind(this);
107981
- resolve13({
108219
+ resolve12({
107982
108220
  status,
107983
108221
  statusText,
107984
108222
  headersList,
@@ -108024,7 +108262,7 @@ var require_fetch = __commonJS({
108024
108262
  for (let i2 = 0; i2 < rawHeaders.length; i2 += 2) {
108025
108263
  headersList.append(bufferToLowerCasedHeaderName(rawHeaders[i2]), rawHeaders[i2 + 1].toString("latin1"), true);
108026
108264
  }
108027
- resolve13({
108265
+ resolve12({
108028
108266
  status,
108029
108267
  statusText: STATUS_CODES2[status],
108030
108268
  headersList,
@@ -109616,9 +109854,9 @@ var require_util7 = __commonJS({
109616
109854
  }
109617
109855
  }
109618
109856
  }
109619
- function validateCookiePath(path60) {
109620
- for (let i2 = 0; i2 < path60.length; ++i2) {
109621
- const code = path60.charCodeAt(i2);
109857
+ function validateCookiePath(path59) {
109858
+ for (let i2 = 0; i2 < path59.length; ++i2) {
109859
+ const code = path59.charCodeAt(i2);
109622
109860
  if (code < 32 || // exclude CTLs (0-31)
109623
109861
  code === 127 || // DEL
109624
109862
  code === 59) {
@@ -111675,8 +111913,8 @@ var require_util9 = __commonJS({
111675
111913
  return true;
111676
111914
  }
111677
111915
  function delay(ms) {
111678
- return new Promise((resolve13) => {
111679
- setTimeout(resolve13, ms).unref();
111916
+ return new Promise((resolve12) => {
111917
+ setTimeout(resolve12, ms).unref();
111680
111918
  });
111681
111919
  }
111682
111920
  module.exports = {
@@ -112278,11 +112516,11 @@ var require_undici = __commonJS({
112278
112516
  if (typeof opts.path !== "string") {
112279
112517
  throw new InvalidArgumentError("invalid opts.path");
112280
112518
  }
112281
- let path60 = opts.path;
112519
+ let path59 = opts.path;
112282
112520
  if (!opts.path.startsWith("/")) {
112283
- path60 = `/${path60}`;
112521
+ path59 = `/${path59}`;
112284
112522
  }
112285
- url2 = new URL(util.parseOrigin(url2).origin + path60);
112523
+ url2 = new URL(util.parseOrigin(url2).origin + path59);
112286
112524
  } else {
112287
112525
  if (!opts) {
112288
112526
  opts = typeof url2 === "object" ? url2 : {};
@@ -112624,7 +112862,7 @@ function classify(input, signals) {
112624
112862
  }
112625
112863
  var CMD_TIMEOUT_MS = 5 * 6e4;
112626
112864
  function runCmd(cmd, args, cwd2) {
112627
- return new Promise((resolve13) => {
112865
+ return new Promise((resolve12) => {
112628
112866
  const child = spawn(cmd, [...args], { cwd: cwd2, stdio: ["ignore", "pipe", "pipe"] });
112629
112867
  let output = "";
112630
112868
  const onData = (d2) => {
@@ -112635,11 +112873,11 @@ function runCmd(cmd, args, cwd2) {
112635
112873
  const timer = setTimeout(() => child.kill("SIGKILL"), CMD_TIMEOUT_MS);
112636
112874
  child.on("error", (err) => {
112637
112875
  clearTimeout(timer);
112638
- resolve13({ exitCode: -1, output: `${cmd} failed to start: ${err.message}` });
112876
+ resolve12({ exitCode: -1, output: `${cmd} failed to start: ${err.message}` });
112639
112877
  });
112640
112878
  child.on("close", (code) => {
112641
112879
  clearTimeout(timer);
112642
- resolve13({ exitCode: code ?? -1, output });
112880
+ resolve12({ exitCode: code ?? -1, output });
112643
112881
  });
112644
112882
  });
112645
112883
  }
@@ -112720,7 +112958,7 @@ function shortName(pkg) {
112720
112958
  return pkg.startsWith(SCOPE) ? pkg.slice(SCOPE.length) : pkg;
112721
112959
  }
112722
112960
  function run(cmd, args, cwd2, timeoutMs = BUILD_TIMEOUT_MS) {
112723
- return new Promise((resolve13) => {
112961
+ return new Promise((resolve12) => {
112724
112962
  const child = spawn(cmd, [...args], { cwd: cwd2, stdio: ["ignore", "pipe", "pipe"] });
112725
112963
  let output = "";
112726
112964
  const onData = (d2) => {
@@ -112731,11 +112969,11 @@ function run(cmd, args, cwd2, timeoutMs = BUILD_TIMEOUT_MS) {
112731
112969
  const timer = setTimeout(() => child.kill("SIGKILL"), timeoutMs);
112732
112970
  child.on("error", (err) => {
112733
112971
  clearTimeout(timer);
112734
- resolve13({ code: -1, output: `${cmd} failed to start: ${err.message}` });
112972
+ resolve12({ code: -1, output: `${cmd} failed to start: ${err.message}` });
112735
112973
  });
112736
112974
  child.on("close", (code) => {
112737
112975
  clearTimeout(timer);
112738
- resolve13({ code: code ?? -1, output });
112976
+ resolve12({ code: code ?? -1, output });
112739
112977
  });
112740
112978
  });
112741
112979
  }
@@ -113794,7 +114032,7 @@ async function findFile(dir, names) {
113794
114032
  var scopeSchema = z$1.enum(["user", "project"]);
113795
114033
  var scopeSchemaOptional = scopeSchema.optional().default("project");
113796
114034
  var USER_YAML = () => moxxyPath("config.yaml");
113797
- var MAX_CONFIG_SEARCH_DEPTH2 = 12;
114035
+ var PROJECT_YAML_NAMES = ["moxxy.config.yaml", "moxxy.config.yml"];
113798
114036
  async function findScopePath(scope, cwd2) {
113799
114037
  if (scope === "user") {
113800
114038
  const yaml = USER_YAML();
@@ -113805,22 +114043,7 @@ async function findScopePath(scope, cwd2) {
113805
114043
  return null;
113806
114044
  }
113807
114045
  }
113808
- let cursor = path3.resolve(cwd2);
113809
- for (let i2 = 0; i2 < MAX_CONFIG_SEARCH_DEPTH2; i2++) {
113810
- for (const name of ["moxxy.config.yaml", "moxxy.config.yml"]) {
113811
- const candidate = path3.join(cursor, name);
113812
- try {
113813
- await promises.access(candidate);
113814
- return candidate;
113815
- } catch {
113816
- }
113817
- }
113818
- const parent = path3.dirname(cursor);
113819
- if (parent === cursor)
113820
- break;
113821
- cursor = parent;
113822
- }
113823
- return null;
114046
+ return findUpward(cwd2, PROJECT_YAML_NAMES);
113824
114047
  }
113825
114048
  function scopeDefaultPath(scope, cwd2) {
113826
114049
  return scope === "user" ? USER_YAML() : path3.join(cwd2, "moxxy.config.yaml");
@@ -116149,13 +116372,13 @@ var MultipartBody = class {
116149
116372
  }
116150
116373
  };
116151
116374
  var fileFromPathWarned = false;
116152
- async function fileFromPath3(path60, ...args) {
116375
+ async function fileFromPath3(path59, ...args) {
116153
116376
  const { fileFromPath: _fileFromPath } = await Promise.resolve().then(() => (init_fileFromPath(), fileFromPath_exports));
116154
116377
  if (!fileFromPathWarned) {
116155
- console.warn(`fileFromPath is deprecated; use fs.createReadStream(${JSON.stringify(path60)}) instead`);
116378
+ console.warn(`fileFromPath is deprecated; use fs.createReadStream(${JSON.stringify(path59)}) instead`);
116156
116379
  fileFromPathWarned = true;
116157
116380
  }
116158
- return await _fileFromPath(path60, ...args);
116381
+ return await _fileFromPath(path59, ...args);
116159
116382
  }
116160
116383
  var defaultHttpAgent = new import_agentkeepalive.default({ keepAlive: true, timeout: 5 * 60 * 1e3 });
116161
116384
  var defaultHttpsAgent = new import_agentkeepalive.default.HttpsAgent({ keepAlive: true, timeout: 5 * 60 * 1e3 });
@@ -116776,8 +116999,8 @@ function _addRequestID(value, response) {
116776
116999
  }
116777
117000
  var APIPromise = class _APIPromise extends Promise {
116778
117001
  constructor(responsePromise, parseResponse2 = defaultParseResponse) {
116779
- super((resolve13) => {
116780
- resolve13(null);
117002
+ super((resolve12) => {
117003
+ resolve12(null);
116781
117004
  });
116782
117005
  this.responsePromise = responsePromise;
116783
117006
  this.parseResponse = parseResponse2;
@@ -116878,29 +117101,29 @@ var APIClient = class {
116878
117101
  defaultIdempotencyKey() {
116879
117102
  return `stainless-node-retry-${uuid4()}`;
116880
117103
  }
116881
- get(path60, opts) {
116882
- return this.methodRequest("get", path60, opts);
117104
+ get(path59, opts) {
117105
+ return this.methodRequest("get", path59, opts);
116883
117106
  }
116884
- post(path60, opts) {
116885
- return this.methodRequest("post", path60, opts);
117107
+ post(path59, opts) {
117108
+ return this.methodRequest("post", path59, opts);
116886
117109
  }
116887
- patch(path60, opts) {
116888
- return this.methodRequest("patch", path60, opts);
117110
+ patch(path59, opts) {
117111
+ return this.methodRequest("patch", path59, opts);
116889
117112
  }
116890
- put(path60, opts) {
116891
- return this.methodRequest("put", path60, opts);
117113
+ put(path59, opts) {
117114
+ return this.methodRequest("put", path59, opts);
116892
117115
  }
116893
- delete(path60, opts) {
116894
- return this.methodRequest("delete", path60, opts);
117116
+ delete(path59, opts) {
117117
+ return this.methodRequest("delete", path59, opts);
116895
117118
  }
116896
- methodRequest(method, path60, opts) {
117119
+ methodRequest(method, path59, opts) {
116897
117120
  return this.request(Promise.resolve(opts).then(async (opts2) => {
116898
117121
  const body = opts2 && isBlobLike(opts2?.body) ? new DataView(await opts2.body.arrayBuffer()) : opts2?.body instanceof DataView ? opts2.body : opts2?.body instanceof ArrayBuffer ? new DataView(opts2.body) : opts2 && ArrayBuffer.isView(opts2?.body) ? new DataView(opts2.body.buffer) : opts2?.body;
116899
- return { method, path: path60, ...opts2, body };
117122
+ return { method, path: path59, ...opts2, body };
116900
117123
  }));
116901
117124
  }
116902
- getAPIList(path60, Page3, opts) {
116903
- return this.requestAPIList(Page3, { method: "get", path: path60, ...opts });
117125
+ getAPIList(path59, Page3, opts) {
117126
+ return this.requestAPIList(Page3, { method: "get", path: path59, ...opts });
116904
117127
  }
116905
117128
  calculateContentLength(body) {
116906
117129
  if (typeof body === "string") {
@@ -116919,10 +117142,10 @@ var APIClient = class {
116919
117142
  }
116920
117143
  buildRequest(inputOptions, { retryCount = 0 } = {}) {
116921
117144
  const options = { ...inputOptions };
116922
- const { method, path: path60, query, headers = {} } = options;
117145
+ const { method, path: path59, query, headers = {} } = options;
116923
117146
  const body = ArrayBuffer.isView(options.body) || options.__binaryRequest && typeof options.body === "string" ? options.body : isMultipartBody(options.body) ? options.body.body : options.body ? JSON.stringify(options.body, null, 2) : null;
116924
117147
  const contentLength = this.calculateContentLength(body);
116925
- const url2 = this.buildURL(path60, query);
117148
+ const url2 = this.buildURL(path59, query);
116926
117149
  if ("timeout" in options)
116927
117150
  validatePositiveInteger("timeout", options.timeout);
116928
117151
  options.timeout = options.timeout ?? this.timeout;
@@ -117046,8 +117269,8 @@ var APIClient = class {
117046
117269
  const request = this.makeRequest(options, null);
117047
117270
  return new PagePromise(this, request, Page3);
117048
117271
  }
117049
- buildURL(path60, query) {
117050
- const url2 = isAbsoluteURL(path60) ? new URL(path60) : new URL(this.baseURL + (this.baseURL.endsWith("/") && path60.startsWith("/") ? path60.slice(1) : path60));
117272
+ buildURL(path59, query) {
117273
+ const url2 = isAbsoluteURL(path59) ? new URL(path59) : new URL(this.baseURL + (this.baseURL.endsWith("/") && path59.startsWith("/") ? path59.slice(1) : path59));
117051
117274
  const defaultQuery = this.defaultQuery();
117052
117275
  if (!isEmptyObj(defaultQuery)) {
117053
117276
  query = { ...defaultQuery, ...query };
@@ -117369,7 +117592,7 @@ var startsWithSchemeRegexp = /^[a-z][a-z0-9+.-]*:/i;
117369
117592
  var isAbsoluteURL = (url2) => {
117370
117593
  return startsWithSchemeRegexp.test(url2);
117371
117594
  };
117372
- var sleep = (ms) => new Promise((resolve13) => setTimeout(resolve13, ms));
117595
+ var sleep = (ms) => new Promise((resolve12) => setTimeout(resolve12, ms));
117373
117596
  var validatePositiveInteger = (name, n2) => {
117374
117597
  if (typeof n2 !== "number" || !Number.isInteger(n2)) {
117375
117598
  throw new AnthropicError(`${name} must be an integer`);
@@ -117979,12 +118202,12 @@ var BetaMessageStream = class _BetaMessageStream {
117979
118202
  }
117980
118203
  return this._emit("error", new AnthropicError(String(error2)));
117981
118204
  });
117982
- __classPrivateFieldSet7(this, _BetaMessageStream_connectedPromise, new Promise((resolve13, reject) => {
117983
- __classPrivateFieldSet7(this, _BetaMessageStream_resolveConnectedPromise, resolve13, "f");
118205
+ __classPrivateFieldSet7(this, _BetaMessageStream_connectedPromise, new Promise((resolve12, reject) => {
118206
+ __classPrivateFieldSet7(this, _BetaMessageStream_resolveConnectedPromise, resolve12, "f");
117984
118207
  __classPrivateFieldSet7(this, _BetaMessageStream_rejectConnectedPromise, reject, "f");
117985
118208
  }));
117986
- __classPrivateFieldSet7(this, _BetaMessageStream_endPromise, new Promise((resolve13, reject) => {
117987
- __classPrivateFieldSet7(this, _BetaMessageStream_resolveEndPromise, resolve13, "f");
118209
+ __classPrivateFieldSet7(this, _BetaMessageStream_endPromise, new Promise((resolve12, reject) => {
118210
+ __classPrivateFieldSet7(this, _BetaMessageStream_resolveEndPromise, resolve12, "f");
117988
118211
  __classPrivateFieldSet7(this, _BetaMessageStream_rejectEndPromise, reject, "f");
117989
118212
  }));
117990
118213
  __classPrivateFieldGet8(this, _BetaMessageStream_connectedPromise, "f").catch(() => {
@@ -118142,11 +118365,11 @@ var BetaMessageStream = class _BetaMessageStream {
118142
118365
  * const message = await stream.emitted('message') // rejects if the stream errors
118143
118366
  */
118144
118367
  emitted(event) {
118145
- return new Promise((resolve13, reject) => {
118368
+ return new Promise((resolve12, reject) => {
118146
118369
  __classPrivateFieldSet7(this, _BetaMessageStream_catchingPromiseCreated, true);
118147
118370
  if (event !== "error")
118148
118371
  this.once("error", reject);
118149
- this.once(event, resolve13);
118372
+ this.once(event, resolve12);
118150
118373
  });
118151
118374
  }
118152
118375
  async done() {
@@ -118427,7 +118650,7 @@ var BetaMessageStream = class _BetaMessageStream {
118427
118650
  if (done) {
118428
118651
  return { value: void 0, done: true };
118429
118652
  }
118430
- return new Promise((resolve13, reject) => readQueue.push({ resolve: resolve13, reject })).then((chunk2) => chunk2 ? { value: chunk2, done: false } : { value: void 0, done: true });
118653
+ return new Promise((resolve12, reject) => readQueue.push({ resolve: resolve12, reject })).then((chunk2) => chunk2 ? { value: chunk2, done: false } : { value: void 0, done: true });
118431
118654
  }
118432
118655
  const chunk = pushQueue.shift();
118433
118656
  return { value: chunk, done: false };
@@ -118699,12 +118922,12 @@ var MessageStream = class _MessageStream {
118699
118922
  }
118700
118923
  return this._emit("error", new AnthropicError(String(error2)));
118701
118924
  });
118702
- __classPrivateFieldSet8(this, _MessageStream_connectedPromise, new Promise((resolve13, reject) => {
118703
- __classPrivateFieldSet8(this, _MessageStream_resolveConnectedPromise, resolve13, "f");
118925
+ __classPrivateFieldSet8(this, _MessageStream_connectedPromise, new Promise((resolve12, reject) => {
118926
+ __classPrivateFieldSet8(this, _MessageStream_resolveConnectedPromise, resolve12, "f");
118704
118927
  __classPrivateFieldSet8(this, _MessageStream_rejectConnectedPromise, reject, "f");
118705
118928
  }));
118706
- __classPrivateFieldSet8(this, _MessageStream_endPromise, new Promise((resolve13, reject) => {
118707
- __classPrivateFieldSet8(this, _MessageStream_resolveEndPromise, resolve13, "f");
118929
+ __classPrivateFieldSet8(this, _MessageStream_endPromise, new Promise((resolve12, reject) => {
118930
+ __classPrivateFieldSet8(this, _MessageStream_resolveEndPromise, resolve12, "f");
118708
118931
  __classPrivateFieldSet8(this, _MessageStream_rejectEndPromise, reject, "f");
118709
118932
  }));
118710
118933
  __classPrivateFieldGet9(this, _MessageStream_connectedPromise, "f").catch(() => {
@@ -118862,11 +119085,11 @@ var MessageStream = class _MessageStream {
118862
119085
  * const message = await stream.emitted('message') // rejects if the stream errors
118863
119086
  */
118864
119087
  emitted(event) {
118865
- return new Promise((resolve13, reject) => {
119088
+ return new Promise((resolve12, reject) => {
118866
119089
  __classPrivateFieldSet8(this, _MessageStream_catchingPromiseCreated, true);
118867
119090
  if (event !== "error")
118868
119091
  this.once("error", reject);
118869
- this.once(event, resolve13);
119092
+ this.once(event, resolve12);
118870
119093
  });
118871
119094
  }
118872
119095
  async done() {
@@ -119147,7 +119370,7 @@ var MessageStream = class _MessageStream {
119147
119370
  if (done) {
119148
119371
  return { value: void 0, done: true };
119149
119372
  }
119150
- return new Promise((resolve13, reject) => readQueue.push({ resolve: resolve13, reject })).then((chunk2) => chunk2 ? { value: chunk2, done: false } : { value: void 0, done: true });
119373
+ return new Promise((resolve12, reject) => readQueue.push({ resolve: resolve12, reject })).then((chunk2) => chunk2 ? { value: chunk2, done: false } : { value: void 0, done: true });
119151
119374
  }
119152
119375
  const chunk = pushQueue.shift();
119153
119376
  return { value: chunk, done: false };
@@ -120249,13 +120472,13 @@ var MultipartBody2 = class {
120249
120472
  }
120250
120473
  };
120251
120474
  var fileFromPathWarned2 = false;
120252
- async function fileFromPath5(path60, ...args) {
120475
+ async function fileFromPath5(path59, ...args) {
120253
120476
  const { fileFromPath: _fileFromPath } = await Promise.resolve().then(() => (init_fileFromPath(), fileFromPath_exports));
120254
120477
  if (!fileFromPathWarned2) {
120255
- console.warn(`fileFromPath is deprecated; use fs.createReadStream(${JSON.stringify(path60)}) instead`);
120478
+ console.warn(`fileFromPath is deprecated; use fs.createReadStream(${JSON.stringify(path59)}) instead`);
120256
120479
  fileFromPathWarned2 = true;
120257
120480
  }
120258
- return await _fileFromPath(path60, ...args);
120481
+ return await _fileFromPath(path59, ...args);
120259
120482
  }
120260
120483
  var defaultHttpAgent2 = new import_agentkeepalive2.default({ keepAlive: true, timeout: 5 * 60 * 1e3 });
120261
120484
  var defaultHttpsAgent2 = new import_agentkeepalive2.default.HttpsAgent({ keepAlive: true, timeout: 5 * 60 * 1e3 });
@@ -120930,8 +121153,8 @@ function _addRequestID2(value, response) {
120930
121153
  }
120931
121154
  var APIPromise2 = class _APIPromise extends Promise {
120932
121155
  constructor(responsePromise, parseResponse2 = defaultParseResponse2) {
120933
- super((resolve13) => {
120934
- resolve13(null);
121156
+ super((resolve12) => {
121157
+ resolve12(null);
120935
121158
  });
120936
121159
  this.responsePromise = responsePromise;
120937
121160
  this.parseResponse = parseResponse2;
@@ -121033,29 +121256,29 @@ var APIClient2 = class {
121033
121256
  defaultIdempotencyKey() {
121034
121257
  return `stainless-node-retry-${uuid42()}`;
121035
121258
  }
121036
- get(path60, opts) {
121037
- return this.methodRequest("get", path60, opts);
121259
+ get(path59, opts) {
121260
+ return this.methodRequest("get", path59, opts);
121038
121261
  }
121039
- post(path60, opts) {
121040
- return this.methodRequest("post", path60, opts);
121262
+ post(path59, opts) {
121263
+ return this.methodRequest("post", path59, opts);
121041
121264
  }
121042
- patch(path60, opts) {
121043
- return this.methodRequest("patch", path60, opts);
121265
+ patch(path59, opts) {
121266
+ return this.methodRequest("patch", path59, opts);
121044
121267
  }
121045
- put(path60, opts) {
121046
- return this.methodRequest("put", path60, opts);
121268
+ put(path59, opts) {
121269
+ return this.methodRequest("put", path59, opts);
121047
121270
  }
121048
- delete(path60, opts) {
121049
- return this.methodRequest("delete", path60, opts);
121271
+ delete(path59, opts) {
121272
+ return this.methodRequest("delete", path59, opts);
121050
121273
  }
121051
- methodRequest(method, path60, opts) {
121274
+ methodRequest(method, path59, opts) {
121052
121275
  return this.request(Promise.resolve(opts).then(async (opts2) => {
121053
121276
  const body = opts2 && isBlobLike2(opts2?.body) ? new DataView(await opts2.body.arrayBuffer()) : opts2?.body instanceof DataView ? opts2.body : opts2?.body instanceof ArrayBuffer ? new DataView(opts2.body) : opts2 && ArrayBuffer.isView(opts2?.body) ? new DataView(opts2.body.buffer) : opts2?.body;
121054
- return { method, path: path60, ...opts2, body };
121277
+ return { method, path: path59, ...opts2, body };
121055
121278
  }));
121056
121279
  }
121057
- getAPIList(path60, Page3, opts) {
121058
- return this.requestAPIList(Page3, { method: "get", path: path60, ...opts });
121280
+ getAPIList(path59, Page3, opts) {
121281
+ return this.requestAPIList(Page3, { method: "get", path: path59, ...opts });
121059
121282
  }
121060
121283
  calculateContentLength(body) {
121061
121284
  if (typeof body === "string") {
@@ -121074,10 +121297,10 @@ var APIClient2 = class {
121074
121297
  }
121075
121298
  buildRequest(inputOptions, { retryCount = 0 } = {}) {
121076
121299
  const options = { ...inputOptions };
121077
- const { method, path: path60, query, headers = {} } = options;
121300
+ const { method, path: path59, query, headers = {} } = options;
121078
121301
  const body = ArrayBuffer.isView(options.body) || options.__binaryRequest && typeof options.body === "string" ? options.body : isMultipartBody2(options.body) ? options.body.body : options.body ? JSON.stringify(options.body, null, 2) : null;
121079
121302
  const contentLength = this.calculateContentLength(body);
121080
- const url2 = this.buildURL(path60, query);
121303
+ const url2 = this.buildURL(path59, query);
121081
121304
  if ("timeout" in options)
121082
121305
  validatePositiveInteger2("timeout", options.timeout);
121083
121306
  options.timeout = options.timeout ?? this.timeout;
@@ -121193,8 +121416,8 @@ var APIClient2 = class {
121193
121416
  const request = this.makeRequest(options, null);
121194
121417
  return new PagePromise2(this, request, Page3);
121195
121418
  }
121196
- buildURL(path60, query) {
121197
- const url2 = isAbsoluteURL2(path60) ? new URL(path60) : new URL(this.baseURL + (this.baseURL.endsWith("/") && path60.startsWith("/") ? path60.slice(1) : path60));
121419
+ buildURL(path59, query) {
121420
+ const url2 = isAbsoluteURL2(path59) ? new URL(path59) : new URL(this.baseURL + (this.baseURL.endsWith("/") && path59.startsWith("/") ? path59.slice(1) : path59));
121198
121421
  const defaultQuery = this.defaultQuery();
121199
121422
  if (!isEmptyObj2(defaultQuery)) {
121200
121423
  query = { ...defaultQuery, ...query };
@@ -121506,7 +121729,7 @@ var startsWithSchemeRegexp2 = /^[a-z][a-z0-9+.-]*:/i;
121506
121729
  var isAbsoluteURL2 = (url2) => {
121507
121730
  return startsWithSchemeRegexp2.test(url2);
121508
121731
  };
121509
- var sleep2 = (ms) => new Promise((resolve13) => setTimeout(resolve13, ms));
121732
+ var sleep2 = (ms) => new Promise((resolve12) => setTimeout(resolve12, ms));
121510
121733
  var validatePositiveInteger2 = (name, n2) => {
121511
121734
  if (typeof n2 !== "number" || !Number.isInteger(n2)) {
121512
121735
  throw new OpenAIError(`${name} must be an integer`);
@@ -121937,12 +122160,12 @@ var EventStream = class {
121937
122160
  _EventStream_errored.set(this, false);
121938
122161
  _EventStream_aborted.set(this, false);
121939
122162
  _EventStream_catchingPromiseCreated.set(this, false);
121940
- __classPrivateFieldSet11(this, _EventStream_connectedPromise, new Promise((resolve13, reject) => {
121941
- __classPrivateFieldSet11(this, _EventStream_resolveConnectedPromise, resolve13, "f");
122163
+ __classPrivateFieldSet11(this, _EventStream_connectedPromise, new Promise((resolve12, reject) => {
122164
+ __classPrivateFieldSet11(this, _EventStream_resolveConnectedPromise, resolve12, "f");
121942
122165
  __classPrivateFieldSet11(this, _EventStream_rejectConnectedPromise, reject, "f");
121943
122166
  }));
121944
- __classPrivateFieldSet11(this, _EventStream_endPromise, new Promise((resolve13, reject) => {
121945
- __classPrivateFieldSet11(this, _EventStream_resolveEndPromise, resolve13, "f");
122167
+ __classPrivateFieldSet11(this, _EventStream_endPromise, new Promise((resolve12, reject) => {
122168
+ __classPrivateFieldSet11(this, _EventStream_resolveEndPromise, resolve12, "f");
121946
122169
  __classPrivateFieldSet11(this, _EventStream_rejectEndPromise, reject, "f");
121947
122170
  }));
121948
122171
  __classPrivateFieldGet12(this, _EventStream_connectedPromise, "f").catch(() => {
@@ -122026,11 +122249,11 @@ var EventStream = class {
122026
122249
  * const message = await stream.emitted('message') // rejects if the stream errors
122027
122250
  */
122028
122251
  emitted(event) {
122029
- return new Promise((resolve13, reject) => {
122252
+ return new Promise((resolve12, reject) => {
122030
122253
  __classPrivateFieldSet11(this, _EventStream_catchingPromiseCreated, true);
122031
122254
  if (event !== "error")
122032
122255
  this.once("error", reject);
122033
- this.once(event, resolve13);
122256
+ this.once(event, resolve12);
122034
122257
  });
122035
122258
  }
122036
122259
  async done() {
@@ -122181,7 +122404,7 @@ var AssistantStream = class _AssistantStream extends EventStream {
122181
122404
  if (done) {
122182
122405
  return { value: void 0, done: true };
122183
122406
  }
122184
- return new Promise((resolve13, reject) => readQueue.push({ resolve: resolve13, reject })).then((chunk2) => chunk2 ? { value: chunk2, done: false } : { value: void 0, done: true });
122407
+ return new Promise((resolve12, reject) => readQueue.push({ resolve: resolve12, reject })).then((chunk2) => chunk2 ? { value: chunk2, done: false } : { value: void 0, done: true });
122185
122408
  }
122186
122409
  const chunk = pushQueue.shift();
122187
122410
  return { value: chunk, done: false };
@@ -123786,7 +124009,7 @@ var ChatCompletionStream = class _ChatCompletionStream extends AbstractChatCompl
123786
124009
  if (done) {
123787
124010
  return { value: void 0, done: true };
123788
124011
  }
123789
- return new Promise((resolve13, reject) => readQueue.push({ resolve: resolve13, reject })).then((chunk2) => chunk2 ? { value: chunk2, done: false } : { value: void 0, done: true });
124012
+ return new Promise((resolve12, reject) => readQueue.push({ resolve: resolve12, reject })).then((chunk2) => chunk2 ? { value: chunk2, done: false } : { value: void 0, done: true });
123790
124013
  }
123791
124014
  const chunk = pushQueue.shift();
123792
124015
  return { value: chunk, done: false };
@@ -125432,7 +125655,7 @@ var ResponseStream = class _ResponseStream extends EventStream {
125432
125655
  if (done) {
125433
125656
  return { value: void 0, done: true };
125434
125657
  }
125435
- return new Promise((resolve13, reject) => readQueue.push({ resolve: resolve13, reject })).then((event2) => event2 ? { value: event2, done: false } : { value: void 0, done: true });
125658
+ return new Promise((resolve12, reject) => readQueue.push({ resolve: resolve12, reject })).then((event2) => event2 ? { value: event2, done: false } : { value: void 0, done: true });
125436
125659
  }
125437
125660
  const event = pushQueue.shift();
125438
125661
  return { value: event, done: false };
@@ -126198,22 +126421,23 @@ var OpenAIProvider = class {
126198
126421
  const tokenLimitKey = usesCompletionTokens ? "max_completion_tokens" : "max_tokens";
126199
126422
  const emitReasoning = req.reasoning != null && req.reasoning !== false;
126200
126423
  const reasoningEffort = typeof req.reasoning === "object" ? req.reasoning.effort : void 0;
126424
+ const params = {
126425
+ model,
126426
+ messages,
126427
+ ...tools ? { tools } : {},
126428
+ ...req.temperature !== void 0 ? { temperature: req.temperature } : {},
126429
+ ...req.maxTokens ? { [tokenLimitKey]: req.maxTokens } : {},
126430
+ ...emitReasoning && usesCompletionTokens && reasoningEffort ? { reasoning_effort: reasoningEffort } : {},
126431
+ stream: true,
126432
+ // OpenAI only emits the final `usage` chunk when this is set;
126433
+ // without it `raw.usage` is null on every chunk and token usage
126434
+ // (and cache-read counts) are silently lost for every streamed turn.
126435
+ stream_options: { include_usage: true }
126436
+ };
126201
126437
  let stream;
126202
126438
  try {
126203
126439
  stream = await this.client.chat.completions.create(
126204
- {
126205
- model,
126206
- messages,
126207
- ...tools ? { tools } : {},
126208
- ...req.temperature !== void 0 ? { temperature: req.temperature } : {},
126209
- ...req.maxTokens ? { [tokenLimitKey]: req.maxTokens } : {},
126210
- ...emitReasoning && usesCompletionTokens && reasoningEffort ? { reasoning_effort: reasoningEffort } : {},
126211
- stream: true,
126212
- // OpenAI only emits the final `usage` chunk when this is set;
126213
- // without it `raw.usage` is null on every chunk and token usage
126214
- // (and cache-read counts) are silently lost for every streamed turn.
126215
- stream_options: { include_usage: true }
126216
- },
126440
+ params,
126217
126441
  // Pass the AbortSignal into the SDK request options so cancelling
126218
126442
  // mid-stream tears down the underlying HTTP request instead of just
126219
126443
  // stopping our consumption loop. Without this, Esc / Ctrl+C felt
@@ -126392,7 +126616,7 @@ var openaiPlugin = definePlugin({
126392
126616
  init_pkce();
126393
126617
  async function openInBrowser(url2) {
126394
126618
  const { cmd, args, verbatim } = browserOpenCommand(url2);
126395
- await new Promise((resolve13, reject) => {
126619
+ await new Promise((resolve12, reject) => {
126396
126620
  const child = spawn(cmd, args, {
126397
126621
  stdio: "ignore",
126398
126622
  detached: true,
@@ -126402,7 +126626,7 @@ async function openInBrowser(url2) {
126402
126626
  });
126403
126627
  child.once("error", reject);
126404
126628
  child.unref();
126405
- setTimeout(resolve13, 50);
126629
+ setTimeout(resolve12, 50);
126406
126630
  });
126407
126631
  }
126408
126632
  function browserOpenCommand(url2, platform2 = process.platform) {
@@ -126418,7 +126642,7 @@ function browserOpenCommand(url2, platform2 = process.platform) {
126418
126642
  return { cmd: "xdg-open", args: [url2] };
126419
126643
  }
126420
126644
  function waitForCallback(opts) {
126421
- return new Promise((resolve13, reject) => {
126645
+ return new Promise((resolve12, reject) => {
126422
126646
  const servers = [];
126423
126647
  let settled = false;
126424
126648
  const settle = (fn) => {
@@ -126495,7 +126719,7 @@ function waitForCallback(opts) {
126495
126719
  }
126496
126720
  res.writeHead(200, { "Content-Type": "text/html; charset=utf-8" });
126497
126721
  res.end(htmlPage("Authorized", "You can close this window \u2014 moxxy received the token."));
126498
- settle(() => resolve13(code));
126722
+ settle(() => resolve12(code));
126499
126723
  };
126500
126724
  const onFatalError = (e3) => {
126501
126725
  if (e3.code === "EADDRINUSE") {
@@ -126619,11 +126843,11 @@ function buildAuthUrl(input) {
126619
126843
  }
126620
126844
  async function runAuthorizationCodeFlow(opts) {
126621
126845
  const port = opts.redirectPort ?? 8765;
126622
- const path60 = opts.redirectPath ?? "/callback";
126846
+ const path59 = opts.redirectPath ?? "/callback";
126623
126847
  const codeVerifier = generateCodeVerifier();
126624
126848
  const codeChallenge = computeCodeChallenge(codeVerifier);
126625
126849
  const state = generateState();
126626
- const redirectUri = `http://localhost:${port}${path60}`;
126850
+ const redirectUri = `http://localhost:${port}${path59}`;
126627
126851
  const authUrl = buildAuthUrl({
126628
126852
  authUrl: opts.authUrl,
126629
126853
  clientId: opts.clientId,
@@ -126635,7 +126859,7 @@ async function runAuthorizationCodeFlow(opts) {
126635
126859
  });
126636
126860
  const codePromise = waitForCallback({
126637
126861
  port,
126638
- path: path60,
126862
+ path: path59,
126639
126863
  expectedState: state,
126640
126864
  timeoutMs: opts.timeoutMs ?? 3e5,
126641
126865
  ...opts.signal ? { signal: opts.signal } : {}
@@ -126692,10 +126916,10 @@ function abortedError(label3) {
126692
126916
  });
126693
126917
  }
126694
126918
  function sleep3(ms, signal, label3) {
126695
- return new Promise((resolve13, reject) => {
126919
+ return new Promise((resolve12, reject) => {
126696
126920
  if (signal?.aborted)
126697
126921
  return reject(abortedError(label3));
126698
- const t2 = setTimeout(resolve13, ms);
126922
+ const t2 = setTimeout(resolve12, ms);
126699
126923
  const onAbort = () => {
126700
126924
  clearTimeout(t2);
126701
126925
  reject(abortedError(label3));
@@ -126777,7 +127001,6 @@ function classifyDeviceTokenResponse(res, json, state) {
126777
127001
  }
126778
127002
 
126779
127003
  // ../plugin-oauth/dist/oauth/device-flow.js
126780
- var DEVICE_POLL_SAFETY_MARGIN_MS = 0;
126781
127004
  async function runDeviceCodeFlow(opts) {
126782
127005
  const auth2 = await requestDeviceAuthorization({
126783
127006
  deviceUrl: opts.deviceUrl,
@@ -126793,7 +127016,7 @@ async function runDeviceCodeFlow(opts) {
126793
127016
  interval: auth2.intervalSec
126794
127017
  });
126795
127018
  return pollUntil((state) => pollOnce(opts, auth2.deviceCode, state), {
126796
- intervalMs: auth2.intervalSec * 1e3 + DEVICE_POLL_SAFETY_MARGIN_MS,
127019
+ intervalMs: auth2.intervalSec * 1e3,
126797
127020
  timeoutMs: Math.min(opts.timeoutMs ?? auth2.expiresInSec * 1e3, auth2.expiresInSec * 1e3),
126798
127021
  label: "OAuth device flow",
126799
127022
  leadingWait: true,
@@ -127000,7 +127223,7 @@ async function acquireFileLock(lockPath, staleMs, pollMs, waitMs) {
127000
127223
  }
127001
127224
  }
127002
127225
  function sleep4(ms) {
127003
- return new Promise((resolve13) => setTimeout(resolve13, ms));
127226
+ return new Promise((resolve12) => setTimeout(resolve12, ms));
127004
127227
  }
127005
127228
  async function refreshAndStore(vault, spec, stored, retried = false) {
127006
127229
  if (!stored.tokenSet.refreshToken) {
@@ -127155,11 +127378,11 @@ function buildOauthAuthorizeTool(deps) {
127155
127378
  const { computeCodeChallenge: computeCodeChallenge2 } = await Promise.resolve().then(() => (init_pkce(), pkce_exports));
127156
127379
  const challenge = computeCodeChallenge2(verifier);
127157
127380
  const port = input.redirectPort ?? 8765;
127158
- const path60 = input.redirectPath ?? "/callback";
127381
+ const path59 = input.redirectPath ?? "/callback";
127159
127382
  const url2 = buildAuthUrl({
127160
127383
  authUrl: input.authUrl,
127161
127384
  clientId: input.clientId,
127162
- redirectUri: `http://localhost:${port}${path60}`,
127385
+ redirectUri: `http://localhost:${port}${path59}`,
127163
127386
  scopes: input.scopes,
127164
127387
  codeChallenge: challenge,
127165
127388
  state,
@@ -127281,7 +127504,7 @@ function summarizeTokens(provider, tokens, opts = {}) {
127281
127504
  init_pkce();
127282
127505
  var DEFAULT_BROWSER_TIMEOUT_MS = 5 * 60 * 1e3;
127283
127506
  var DEFAULT_DEVICE_TIMEOUT_MS = 10 * 60 * 1e3;
127284
- var DEVICE_POLL_SAFETY_MARGIN_MS2 = 3e3;
127507
+ var DEVICE_POLL_SAFETY_MARGIN_MS = 3e3;
127285
127508
  async function runOauthLogin(profile, ctx) {
127286
127509
  const tokens = ctx.headless ? await runDeviceFlow(profile, ctx) : await runBrowserFlow(profile, ctx);
127287
127510
  const accountId = profile.extractAccountId?.(tokens);
@@ -127303,7 +127526,7 @@ async function runOauthLogin(profile, ctx) {
127303
127526
  }
127304
127527
  async function runBrowserFlow(profile, ctx) {
127305
127528
  const port = profile.redirect?.port ?? 8765;
127306
- const path60 = profile.redirect?.path ?? "/callback";
127529
+ const path59 = profile.redirect?.path ?? "/callback";
127307
127530
  const serviceName = profile.displayName ?? profile.id;
127308
127531
  return runAuthorizationCodeFlow({
127309
127532
  authUrl: profile.authUrl,
@@ -127312,7 +127535,7 @@ async function runBrowserFlow(profile, ctx) {
127312
127535
  ...profile.clientSecret ? { clientSecret: profile.clientSecret } : {},
127313
127536
  scopes: profile.scopes,
127314
127537
  redirectPort: port,
127315
- redirectPath: path60,
127538
+ redirectPath: path59,
127316
127539
  ...profile.extraAuthParams ? { extraAuthParams: profile.extraAuthParams } : {},
127317
127540
  timeoutMs: DEFAULT_BROWSER_TIMEOUT_MS,
127318
127541
  ...ctx.signal ? { signal: ctx.signal } : {},
@@ -127324,7 +127547,7 @@ If your browser doesn't open automatically, paste this URL:
127324
127547
 
127325
127548
  ${url2}
127326
127549
 
127327
- Waiting for callback on http://localhost:${port}${path60} (5 min timeout)\u2026
127550
+ Waiting for callback on http://localhost:${port}${path59} (5 min timeout)\u2026
127328
127551
 
127329
127552
  `);
127330
127553
  }
@@ -127361,7 +127584,7 @@ Polling every ${Math.round(init3.intervalMs / 1e3)}s (${Math.round(init3.expires
127361
127584
  `);
127362
127585
  const timeoutMs = Math.min(init3.expiresInMs, DEFAULT_DEVICE_TIMEOUT_MS);
127363
127586
  return pollUntil((state) => adapter.poll(init3, state), {
127364
- intervalMs: init3.intervalMs + DEVICE_POLL_SAFETY_MARGIN_MS2,
127587
+ intervalMs: init3.intervalMs + DEVICE_POLL_SAFETY_MARGIN_MS,
127365
127588
  timeoutMs,
127366
127589
  label: `${profile.id} device flow`,
127367
127590
  leadingWait: true,
@@ -128301,7 +128524,7 @@ async function refreshClaudeUnderLock(vault, baseline) {
128301
128524
  }
128302
128525
  var fetchImpl = fetch;
128303
128526
  var openBrowserImpl = openInBrowser;
128304
- var sleepImpl = (ms) => new Promise((resolve13) => setTimeout(resolve13, ms));
128527
+ var sleepImpl = (ms) => new Promise((resolve12) => setTimeout(resolve12, ms));
128305
128528
  var TOKEN_POST_MAX_ATTEMPTS = 3;
128306
128529
  var TOKEN_POST_BACKOFF_MS = [600, 1800];
128307
128530
  async function exchangeClaudeCode(code, state, verifier) {
@@ -128645,14 +128868,15 @@ var WhisperTranscriber = class {
128645
128868
  ...language ? { language } : {},
128646
128869
  ...opts.prompt ? { prompt: opts.prompt } : {}
128647
128870
  }, { signal: opts.signal }));
128648
- const r2 = response2;
128871
+ const r2 = requireTextResponse(response2);
128649
128872
  const result = { text: r2.text };
128650
- if (r2.language)
128873
+ if (typeof r2.language === "string")
128651
128874
  result.language = r2.language;
128652
128875
  if (typeof r2.duration === "number")
128653
128876
  result.durationSec = r2.duration;
128654
- if (r2.segments)
128877
+ if (Array.isArray(r2.segments)) {
128655
128878
  result.segments = r2.segments.map((s2) => ({ start: s2.start, end: s2.end, text: s2.text }));
128879
+ }
128656
128880
  return result;
128657
128881
  }
128658
128882
  const response = await this.run(() => this.client.audio.transcriptions.create({
@@ -128661,7 +128885,7 @@ var WhisperTranscriber = class {
128661
128885
  ...language ? { language } : {},
128662
128886
  ...opts.prompt ? { prompt: opts.prompt } : {}
128663
128887
  }, { signal: opts.signal }));
128664
- return { text: response.text };
128888
+ return { text: requireTextResponse(response).text };
128665
128889
  }
128666
128890
  /**
128667
128891
  * Run an SDK transcription call, translating failures into structured
@@ -128698,6 +128922,16 @@ var WhisperTranscriber = class {
128698
128922
  }
128699
128923
  }
128700
128924
  };
128925
+ function requireTextResponse(response) {
128926
+ if (!response || typeof response !== "object" || typeof response.text !== "string") {
128927
+ throw new MoxxyError({
128928
+ code: "PROVIDER_UNKNOWN_RESPONSE",
128929
+ message: "OpenAI transcription response was missing a text field.",
128930
+ context: { provider: WHISPER_PROVIDER_ID }
128931
+ });
128932
+ }
128933
+ return response;
128934
+ }
128701
128935
 
128702
128936
  // ../plugin-stt-whisper/dist/index.js
128703
128937
  function buildWhisperPlugin(opts = {}) {
@@ -128792,7 +129026,18 @@ var CodexOAuthTranscriber = class {
128792
129026
  context: { provider: CODEX_PROVIDER_ID, url: this.endpoint }
128793
129027
  });
128794
129028
  }
128795
- return { text: payload.text.trim() };
129029
+ const obj = payload;
129030
+ const result = { text: obj.text.trim() };
129031
+ if (typeof obj.language === "string")
129032
+ result.language = obj.language;
129033
+ if (typeof obj.duration === "number")
129034
+ result.durationSec = obj.duration;
129035
+ if (Array.isArray(obj.segments)) {
129036
+ const segments = obj.segments.filter((s2) => !!s2 && typeof s2 === "object" && typeof s2.start === "number" && typeof s2.end === "number" && typeof s2.text === "string").map((s2) => ({ start: s2.start, end: s2.end, text: s2.text }));
129037
+ if (segments.length > 0)
129038
+ result.segments = segments;
129039
+ }
129040
+ return result;
128796
129041
  }
128797
129042
  async loadTokens() {
128798
129043
  try {
@@ -128861,12 +129106,16 @@ function buildWhisperCodexPlugin(opts) {
128861
129106
  name: OPENAI_CODEX_TRANSCRIBER_NAME,
128862
129107
  displayName: "OpenAI Codex transcription (OAuth)",
128863
129108
  createClient: (config) => {
129109
+ const cfg = config ?? {};
129110
+ const configBaseUrl = typeof cfg.baseUrl === "string" ? cfg.baseUrl : void 0;
129111
+ const configSessionIdProvider = typeof cfg.sessionIdProvider === "function" ? cfg.sessionIdProvider : void 0;
129112
+ const baseUrl = configBaseUrl ?? opts.baseUrl;
129113
+ const sessionIdProvider = configSessionIdProvider ?? opts.sessionIdProvider;
128864
129114
  const merged = {
128865
129115
  vault: opts.vault,
128866
- ...opts.baseUrl ? { baseUrl: opts.baseUrl } : {},
129116
+ ...baseUrl ? { baseUrl } : {},
128867
129117
  ...opts.fetch ? { fetch: opts.fetch } : {},
128868
- ...opts.sessionIdProvider ? { sessionIdProvider: opts.sessionIdProvider } : {},
128869
- ...config
129118
+ ...sessionIdProvider ? { sessionIdProvider } : {}
128870
129119
  };
128871
129120
  return new CodexOAuthTranscriber(merged);
128872
129121
  }
@@ -128967,7 +129216,7 @@ var bashTool = defineTool({
128967
129216
  if (ctx.signal.aborted) {
128968
129217
  throw new MoxxyError({ code: "ABORTED", message: `Bash aborted before start: ${command}` });
128969
129218
  }
128970
- return await new Promise((resolve13, reject) => {
129219
+ return await new Promise((resolve12, reject) => {
128971
129220
  const child = spawn("/bin/sh", ["-lc", command], {
128972
129221
  cwd: cwd2 ?? ctx.cwd,
128973
129222
  env: env3 ? { ...process.env, ...env3 } : process.env,
@@ -129020,9 +129269,9 @@ ${err.text.trimEnd()}
129020
129269
  ` : "") + `[exit ${code ?? "null"}]`;
129021
129270
  const dropped = out.dropped + err.dropped;
129022
129271
  if (dropped === 0) {
129023
- resolve13(clampString(combined, OUTPUT_LIMIT));
129272
+ resolve12(clampString(combined, OUTPUT_LIMIT));
129024
129273
  } else {
129025
- resolve13(combined.slice(0, OUTPUT_LIMIT) + `
129274
+ resolve12(combined.slice(0, OUTPUT_LIMIT) + `
129026
129275
  ... [truncated ${combined.length + dropped - OUTPUT_LIMIT} chars]`);
129027
129276
  }
129028
129277
  });
@@ -129343,6 +129592,15 @@ async function* walk(root, regex2, cursor, signal, visited) {
129343
129592
  }
129344
129593
  }
129345
129594
  }
129595
+ var MAX_FILE_BYTES = 10 * 1024 * 1024;
129596
+ function looksBinary(content) {
129597
+ const limit2 = Math.min(content.length, 8192);
129598
+ for (let i2 = 0; i2 < limit2; i2 += 1) {
129599
+ if (content.charCodeAt(i2) === 0)
129600
+ return true;
129601
+ }
129602
+ return false;
129603
+ }
129346
129604
  var grepTool = defineTool({
129347
129605
  name: "Grep",
129348
129606
  description: "Recursively search files for a regex pattern. Returns lines as `path:line:text`.",
@@ -129406,12 +129664,21 @@ async function walk2(root, cursor, re2, fileRe, matches, max, signal) {
129406
129664
  continue;
129407
129665
  if (fileRe && !fileRe.test(entry.name))
129408
129666
  continue;
129667
+ try {
129668
+ const st3 = await promises.stat(full);
129669
+ if (st3.size > MAX_FILE_BYTES)
129670
+ continue;
129671
+ } catch {
129672
+ continue;
129673
+ }
129409
129674
  let content;
129410
129675
  try {
129411
129676
  content = await promises.readFile(full, "utf8");
129412
129677
  } catch {
129413
129678
  continue;
129414
129679
  }
129680
+ if (looksBinary(content))
129681
+ continue;
129415
129682
  const lines = content.split("\n");
129416
129683
  for (let i2 = 0; i2 < lines.length; i2++) {
129417
129684
  if (re2.test(lines[i2])) {
@@ -129603,10 +129870,10 @@ var sleepTool = defineTool({
129603
129870
  if (ctx.signal.aborted) {
129604
129871
  throw new MoxxyError({ code: "ABORTED", message: "Sleep aborted before start" });
129605
129872
  }
129606
- await new Promise((resolve13, reject) => {
129873
+ await new Promise((resolve12, reject) => {
129607
129874
  const timer = setTimeout(() => {
129608
129875
  ctx.signal.removeEventListener("abort", onAbort);
129609
- resolve13();
129876
+ resolve12();
129610
129877
  }, totalMs);
129611
129878
  const onAbort = () => {
129612
129879
  clearTimeout(timer);
@@ -129679,16 +129946,16 @@ function retryBackoffMs(attempt) {
129679
129946
  const cap = 3e4;
129680
129947
  return Math.min(cap, base2 * 2 ** Math.max(0, attempt - 1));
129681
129948
  }
129682
- var sleepImpl2 = (ms, signal) => new Promise((resolve13) => {
129949
+ var sleepImpl2 = (ms, signal) => new Promise((resolve12) => {
129683
129950
  if (signal.aborted)
129684
- return resolve13();
129951
+ return resolve12();
129685
129952
  const timer = setTimeout(() => {
129686
129953
  signal.removeEventListener("abort", onAbort);
129687
- resolve13();
129954
+ resolve12();
129688
129955
  }, ms);
129689
129956
  const onAbort = () => {
129690
129957
  clearTimeout(timer);
129691
- resolve13();
129958
+ resolve12();
129692
129959
  };
129693
129960
  signal.addEventListener("abort", onAbort, { once: true });
129694
129961
  });
@@ -130527,20 +130794,17 @@ function parseFollowups(text) {
130527
130794
  function parseNumberedBlock(text, headerRegex) {
130528
130795
  const lines = text.split("\n");
130529
130796
  const items = [];
130530
- let inBlock = false;
130531
130797
  for (const raw of lines) {
130532
130798
  const line = raw.trim();
130533
130799
  if (!line)
130534
130800
  continue;
130535
130801
  if (headerRegex.test(line)) {
130536
- inBlock = true;
130537
130802
  continue;
130538
130803
  }
130539
130804
  const m3 = /^(?:\d+[.)]|[-*•])\s*(.+)$/.exec(line);
130540
130805
  if (m3) {
130541
130806
  items.push(m3[1].trim());
130542
- inBlock = true;
130543
- } else if (inBlock && items.length > 0 && !/^[A-Z]/.test(line)) ;
130807
+ }
130544
130808
  }
130545
130809
  return items;
130546
130810
  }
@@ -131137,11 +131401,11 @@ var TelegramPermissionResolver = class {
131137
131401
  if (!this.deciderFn) {
131138
131402
  return { mode: "deny", reason: "no decider attached (bot not running)" };
131139
131403
  }
131140
- const decision = await new Promise((resolve13) => {
131141
- this.pending.set(call.callId, { callId: call.callId, call, ctx, resolve: resolve13 });
131404
+ const decision = await new Promise((resolve12) => {
131405
+ this.pending.set(call.callId, { callId: call.callId, call, ctx, resolve: resolve12 });
131142
131406
  this.deciderFn(call, ctx).catch((err) => {
131143
131407
  this.pending.delete(call.callId);
131144
- resolve13({ mode: "deny", reason: err instanceof Error ? err.message : String(err) });
131408
+ resolve12({ mode: "deny", reason: err instanceof Error ? err.message : String(err) });
131145
131409
  });
131146
131410
  });
131147
131411
  if (decision.mode === "allow_session")
@@ -131179,11 +131443,11 @@ var TelegramApprovalResolver = class {
131179
131443
  return { optionId: request.defaultOptionId ?? request.options[0]?.id ?? "approve" };
131180
131444
  }
131181
131445
  const id = `appr_${this.nextId++}`;
131182
- return new Promise((resolve13) => {
131183
- this.pending.set(id, { id, request, resolve: resolve13 });
131446
+ return new Promise((resolve12) => {
131447
+ this.pending.set(id, { id, request, resolve: resolve12 });
131184
131448
  this.deciderFn(id, request).catch((err) => {
131185
131449
  this.pending.delete(id);
131186
- resolve13({
131450
+ resolve12({
131187
131451
  optionId: request.defaultOptionId ?? request.options[0]?.id ?? "cancel",
131188
131452
  text: `decider failed: ${err instanceof Error ? err.message : String(err)}`
131189
131453
  });
@@ -132649,17 +132913,9 @@ var TelegramChannel = class {
132649
132913
  handleVoice(ctx, token) {
132650
132914
  return handleVoiceMessage(ctx, {
132651
132915
  session: this.session,
132652
- model: this.model,
132653
- activeModelOverride: this.activeModelOverride,
132654
- yolo: this.yolo,
132655
- busy: this.busy,
132656
- turnController: this.turnController,
132657
- handle: this.handle
132916
+ busy: this.busy
132658
132917
  }, {
132659
132918
  pairing: this.pairing,
132660
- approvalResolver: this.approvalResolver,
132661
- permissionResolver: this.permissionResolver,
132662
- framePump: this.framePump,
132663
132919
  token,
132664
132920
  ...this.opts.logger ? { logger: this.opts.logger } : {}
132665
132921
  }, {
@@ -133732,8 +133988,8 @@ async function runPairFlow(ctx) {
133732
133988
  });
133733
133989
  session.setPermissionResolver(channel.permissionResolver);
133734
133990
  let issuedResolve = null;
133735
- const issued = new Promise((resolve13) => {
133736
- issuedResolve = resolve13;
133991
+ const issued = new Promise((resolve12) => {
133992
+ issuedResolve = resolve12;
133737
133993
  });
133738
133994
  const unsubscribe = channel.onPairingIssued((e3) => {
133739
133995
  issuedResolve?.(e3);
@@ -134109,6 +134365,22 @@ function reply(res, status, body) {
134109
134365
  res.writeHead(status, { "content-type": "application/json" });
134110
134366
  res.end(JSON.stringify(body));
134111
134367
  }
134368
+ async function driveTurn(session, prompt, runOptions, res) {
134369
+ const controller = new AbortController();
134370
+ const onClose = () => controller.abort();
134371
+ res.on("close", onClose);
134372
+ const events = [];
134373
+ try {
134374
+ for await (const event of session.runTurn(prompt, { ...runOptions, signal: controller.signal })) {
134375
+ events.push(event);
134376
+ }
134377
+ } finally {
134378
+ res.off("close", onClose);
134379
+ }
134380
+ const finalAssistant = events.findLast?.((e3) => e3.type === "assistant_message");
134381
+ const assistant = finalAssistant && finalAssistant.type === "assistant_message" ? finalAssistant.content : "";
134382
+ return { events, assistant };
134383
+ }
134112
134384
  async function handleTurn(req, res, ctx) {
134113
134385
  if (!checkAuth(req, ctx.authToken)) {
134114
134386
  reply(res, 401, { error: "unauthorized" });
@@ -134122,27 +134394,17 @@ async function handleTurn(req, res, ctx) {
134122
134394
  reply(res, 400, { error: "bad_request", message: err instanceof Error ? err.message : String(err) });
134123
134395
  return;
134124
134396
  }
134125
- const controller = new AbortController();
134126
- const onClose = () => controller.abort();
134127
- res.on("close", onClose);
134128
- const events = [];
134397
+ let result;
134129
134398
  try {
134130
- for await (const event of ctx.session.runTurn(body.prompt, {
134399
+ result = await driveTurn(ctx.session, body.prompt, {
134131
134400
  ...body.model ? { model: body.model } : {},
134132
- ...body.systemPrompt ? { systemPrompt: body.systemPrompt } : {},
134133
- signal: controller.signal
134134
- })) {
134135
- events.push(event);
134136
- }
134401
+ ...body.systemPrompt ? { systemPrompt: body.systemPrompt } : {}
134402
+ }, res);
134137
134403
  } catch (err) {
134138
134404
  reply(res, 500, { error: "turn_failed", message: err instanceof Error ? err.message : String(err) });
134139
134405
  return;
134140
- } finally {
134141
- res.off("close", onClose);
134142
134406
  }
134143
- const finalAssistant = events.findLast?.((e3) => e3.type === "assistant_message");
134144
- const assistant = finalAssistant && finalAssistant.type === "assistant_message" ? finalAssistant.content : "";
134145
- reply(res, 200, { events, assistant });
134407
+ reply(res, 200, { events: result.events, assistant: result.assistant });
134146
134408
  }
134147
134409
  async function handleTurnAudio(req, res, ctx) {
134148
134410
  if (!checkAuth(req, ctx.authToken)) {
@@ -134183,12 +134445,12 @@ async function handleTurnAudio(req, res, ctx) {
134183
134445
  const systemPrompt = url2.searchParams.get("systemPrompt") ?? void 0;
134184
134446
  let transcript;
134185
134447
  try {
134186
- const result = await transcriber.transcribe(new Uint8Array(bytes), {
134448
+ const result2 = await transcriber.transcribe(new Uint8Array(bytes), {
134187
134449
  mimeType: contentType,
134188
134450
  ...language ? { language } : {},
134189
134451
  ...promptHint ? { prompt: promptHint } : {}
134190
134452
  });
134191
- transcript = result.text.trim();
134453
+ transcript = result2.text.trim();
134192
134454
  } catch (err) {
134193
134455
  ctx.logger?.warn("http audio transcription failed", { err: err instanceof Error ? err.message : String(err) });
134194
134456
  reply(res, 502, { error: "transcription_failed", message: err instanceof Error ? err.message : String(err) });
@@ -134198,27 +134460,17 @@ async function handleTurnAudio(req, res, ctx) {
134198
134460
  reply(res, 422, { error: "empty_transcript", message: "transcriber returned empty text" });
134199
134461
  return;
134200
134462
  }
134201
- const controller = new AbortController();
134202
- const onClose = () => controller.abort();
134203
- res.on("close", onClose);
134204
- const events = [];
134463
+ let result;
134205
134464
  try {
134206
- for await (const event of ctx.session.runTurn(transcript, {
134465
+ result = await driveTurn(ctx.session, transcript, {
134207
134466
  ...model ? { model } : {},
134208
- ...systemPrompt ? { systemPrompt } : {},
134209
- signal: controller.signal
134210
- })) {
134211
- events.push(event);
134212
- }
134467
+ ...systemPrompt ? { systemPrompt } : {}
134468
+ }, res);
134213
134469
  } catch (err) {
134214
134470
  reply(res, 500, { error: "turn_failed", message: err instanceof Error ? err.message : String(err) });
134215
134471
  return;
134216
- } finally {
134217
- res.off("close", onClose);
134218
134472
  }
134219
- const finalAssistant = events.findLast?.((e3) => e3.type === "assistant_message");
134220
- const assistant = finalAssistant && finalAssistant.type === "assistant_message" ? finalAssistant.content : "";
134221
- reply(res, 200, { transcript, events, assistant });
134473
+ reply(res, 200, { transcript, events: result.events, assistant: result.assistant });
134222
134474
  }
134223
134475
  async function handleTurnStream(req, res, ctx) {
134224
134476
  if (!checkAuth(req, ctx.authToken)) {
@@ -134320,11 +134572,11 @@ var HttpChannel = class {
134320
134572
  this.server = server;
134321
134573
  let rejectRunning;
134322
134574
  let resolveRunning;
134323
- const running = new Promise((resolve13, reject) => {
134324
- resolveRunning = resolve13;
134575
+ const running = new Promise((resolve12, reject) => {
134576
+ resolveRunning = resolve12;
134325
134577
  rejectRunning = reject;
134326
134578
  });
134327
- const listening = new Promise((resolve13, reject) => {
134579
+ const listening = new Promise((resolve12, reject) => {
134328
134580
  const onListenError = (err) => reject(err);
134329
134581
  server.once("error", onListenError);
134330
134582
  server.listen(this.port, this.host, () => {
@@ -134340,7 +134592,7 @@ var HttpChannel = class {
134340
134592
  port: this.boundPortValue,
134341
134593
  authEnabled: this.authToken !== null
134342
134594
  });
134343
- resolve13();
134595
+ resolve12();
134344
134596
  });
134345
134597
  });
134346
134598
  await listening;
@@ -134348,10 +134600,10 @@ var HttpChannel = class {
134348
134600
  return {
134349
134601
  running,
134350
134602
  stop: async () => {
134351
- await new Promise((resolve13) => {
134603
+ await new Promise((resolve12) => {
134352
134604
  if (!this.server)
134353
- return resolve13();
134354
- this.server.close(() => resolve13());
134605
+ return resolve12();
134606
+ this.server.close(() => resolve12());
134355
134607
  });
134356
134608
  }
134357
134609
  };
@@ -134494,17 +134746,17 @@ function isAddrInUse(err) {
134494
134746
  }
134495
134747
  async function captureStdout(cmd, args) {
134496
134748
  const { spawn: spawn15 } = await import('child_process');
134497
- return await new Promise((resolve13) => {
134749
+ return await new Promise((resolve12) => {
134498
134750
  let out = "";
134499
134751
  try {
134500
134752
  const child = spawn15(cmd, [...args], { stdio: ["ignore", "pipe", "ignore"] });
134501
134753
  child.stdout.on("data", (b3) => {
134502
134754
  out += b3.toString();
134503
134755
  });
134504
- child.on("error", () => resolve13(""));
134505
- child.on("close", () => resolve13(out));
134756
+ child.on("error", () => resolve12(""));
134757
+ child.on("close", () => resolve12(out));
134506
134758
  } catch {
134507
- resolve13("");
134759
+ resolve12("");
134508
134760
  }
134509
134761
  });
134510
134762
  }
@@ -134631,7 +134883,7 @@ var WebChannel = class {
134631
134883
  await this.openTunnel();
134632
134884
  this.publishSurface?.({ url: this.shareUrl, nextViewId: () => `v_srv_${++this.viewSeq}` });
134633
134885
  this.publishControls?.({ retunnel: () => this.retunnel() });
134634
- const running = new Promise((resolve13) => server.once("close", () => resolve13()));
134886
+ const running = new Promise((resolve12) => server.once("close", () => resolve12()));
134635
134887
  return { running, stop: () => this.stop() };
134636
134888
  }
134637
134889
  /**
@@ -134644,7 +134896,7 @@ var WebChannel = class {
134644
134896
  * surface actually got (the share URL embeds the real port either way).
134645
134897
  */
134646
134898
  async bindServerWithRetry(server) {
134647
- const tryListen = () => new Promise((resolve13, reject) => {
134899
+ const tryListen = () => new Promise((resolve12, reject) => {
134648
134900
  const onError2 = (err) => {
134649
134901
  server.off("listening", onListening);
134650
134902
  reject(err);
@@ -134655,7 +134907,7 @@ var WebChannel = class {
134655
134907
  if (addr && typeof addr === "object")
134656
134908
  this.port = addr.port;
134657
134909
  this.logger?.info?.("web channel listening", { url: this.url });
134658
- resolve13();
134910
+ resolve12();
134659
134911
  };
134660
134912
  server.once("error", onError2);
134661
134913
  server.once("listening", onListening);
@@ -134736,8 +134988,8 @@ var WebChannel = class {
134736
134988
  }
134737
134989
  }
134738
134990
  this.clients.clear();
134739
- await new Promise((resolve13) => this.wss ? this.wss.close(() => resolve13()) : resolve13());
134740
- await new Promise((resolve13) => this.server ? this.server.close(() => resolve13()) : resolve13());
134991
+ await new Promise((resolve12) => this.wss ? this.wss.close(() => resolve12()) : resolve12());
134992
+ await new Promise((resolve12) => this.server ? this.server.close(() => resolve12()) : resolve12());
134741
134993
  }
134742
134994
  validToken(reqUrl) {
134743
134995
  try {
@@ -135137,9 +135389,9 @@ async function createWebSocketTransportServer(opts) {
135137
135389
  for (const handler of connectionHandlers)
135138
135390
  handler(transport);
135139
135391
  });
135140
- await new Promise((resolve13, reject) => {
135392
+ await new Promise((resolve12, reject) => {
135141
135393
  wss.once("error", reject);
135142
- wss.once("listening", resolve13);
135394
+ wss.once("listening", resolve12);
135143
135395
  });
135144
135396
  const bound = wss.address();
135145
135397
  const boundPort = typeof bound === "object" && bound !== null ? bound.port : opts.port;
@@ -135160,10 +135412,10 @@ async function createWebSocketTransportServer(opts) {
135160
135412
  return connections;
135161
135413
  },
135162
135414
  close() {
135163
- return new Promise((resolve13) => {
135415
+ return new Promise((resolve12) => {
135164
135416
  for (const client of wss.clients)
135165
135417
  client.terminate();
135166
- wss.close(() => resolve13());
135418
+ wss.close(() => resolve12());
135167
135419
  });
135168
135420
  }
135169
135421
  };
@@ -135215,8 +135467,8 @@ var JsonRpcPeer = class {
135215
135467
  if (this.closed)
135216
135468
  return Promise.reject(new RpcError("rpc peer is closed"));
135217
135469
  const id = this.nextId++;
135218
- return new Promise((resolve13, reject) => {
135219
- this.pending.set(id, { resolve: resolve13, reject });
135470
+ return new Promise((resolve12, reject) => {
135471
+ this.pending.set(id, { resolve: resolve12, reject });
135220
135472
  const frame = { id, method, ...params !== void 0 ? { params } : {} };
135221
135473
  this.transport.send(frame);
135222
135474
  });
@@ -135368,11 +135620,11 @@ async function createUnixSocketServer(socketPath, logger = stderrLogger) {
135368
135620
  for (const handler of connectionHandlers)
135369
135621
  handler(transport);
135370
135622
  });
135371
- await new Promise((resolve13, reject) => {
135623
+ await new Promise((resolve12, reject) => {
135372
135624
  server.once("error", reject);
135373
135625
  server.listen(socketPath, () => {
135374
135626
  server.removeListener("error", reject);
135375
- resolve13();
135627
+ resolve12();
135376
135628
  });
135377
135629
  });
135378
135630
  if (process.platform !== "win32") {
@@ -135391,7 +135643,7 @@ async function createUnixSocketServer(socketPath, logger = stderrLogger) {
135391
135643
  connectionHandlers.push(handler);
135392
135644
  },
135393
135645
  close() {
135394
- return new Promise((resolve13) => {
135646
+ return new Promise((resolve12) => {
135395
135647
  server.close(() => {
135396
135648
  if (process.platform !== "win32") {
135397
135649
  try {
@@ -135399,7 +135651,7 @@ async function createUnixSocketServer(socketPath, logger = stderrLogger) {
135399
135651
  } catch {
135400
135652
  }
135401
135653
  }
135402
- resolve13();
135654
+ resolve12();
135403
135655
  });
135404
135656
  });
135405
135657
  }
@@ -135408,7 +135660,7 @@ async function createUnixSocketServer(socketPath, logger = stderrLogger) {
135408
135660
  var DEFAULT_CONNECT_TIMEOUT_MS = 1e4;
135409
135661
  function connectUnixSocket(socketPath, opts = {}) {
135410
135662
  const timeoutMs = opts.timeoutMs ?? DEFAULT_CONNECT_TIMEOUT_MS;
135411
- return new Promise((resolve13, reject) => {
135663
+ return new Promise((resolve12, reject) => {
135412
135664
  const socket = net.connect(socketPath);
135413
135665
  let settled = false;
135414
135666
  const timer = setTimeout(() => {
@@ -135433,7 +135685,7 @@ function connectUnixSocket(socketPath, opts = {}) {
135433
135685
  settled = true;
135434
135686
  clearTimeout(timer);
135435
135687
  socket.removeListener("error", onError2);
135436
- resolve13(new NdjsonTransport(socket));
135688
+ resolve12(new NdjsonTransport(socket));
135437
135689
  });
135438
135690
  });
135439
135691
  }
@@ -135465,11 +135717,11 @@ function warnWindowsPipeAclOnce(logger, pipePath) {
135465
135717
  async function reclaimStaleSocket(socketPath) {
135466
135718
  if (!fs28__default.existsSync(socketPath))
135467
135719
  return;
135468
- const alive = await new Promise((resolve13) => {
135720
+ const alive = await new Promise((resolve12) => {
135469
135721
  const probe = net.connect(socketPath);
135470
135722
  const finish = (up) => {
135471
135723
  probe.destroy();
135472
- resolve13(up);
135724
+ resolve12(up);
135473
135725
  };
135474
135726
  probe.once("connect", () => finish(true));
135475
135727
  probe.once("error", () => finish(false));
@@ -135494,11 +135746,11 @@ function runnerSocketPath() {
135494
135746
  return platformSocket("serve", path3__default.join(os5__default.homedir(), ".moxxy", "serve.sock"));
135495
135747
  }
135496
135748
  function isRunnerUp(socketPath = runnerSocketPath()) {
135497
- return new Promise((resolve13) => {
135749
+ return new Promise((resolve12) => {
135498
135750
  const socket = net.connect(socketPath);
135499
135751
  const finish = (up) => {
135500
135752
  socket.destroy();
135501
- resolve13(up);
135753
+ resolve12(up);
135502
135754
  };
135503
135755
  socket.once("connect", () => finish(true));
135504
135756
  socket.once("error", () => finish(false));
@@ -135706,9 +135958,38 @@ var workflowResumeParamsSchema = z.object({
135706
135958
  var surfaceOpenParamsSchema = z.object({
135707
135959
  kind: z.string().min(1).max(64)
135708
135960
  });
135961
+ var MAX_SURFACE_INPUT_BYTES = 1e6;
135962
+ function surfaceInputWithinCap(m3) {
135963
+ let upper = 2;
135964
+ let primitiveOnly = true;
135965
+ for (const key in m3) {
135966
+ if (!Object.prototype.hasOwnProperty.call(m3, key))
135967
+ continue;
135968
+ const v3 = m3[key];
135969
+ const t2 = typeof v3;
135970
+ if (v3 === void 0 || t2 === "function")
135971
+ continue;
135972
+ upper += key.length * 6 + 2 + 1 + 1;
135973
+ if (t2 === "string") {
135974
+ upper += v3.length * 6 + 2;
135975
+ } else if (t2 === "number") {
135976
+ upper += 25;
135977
+ } else if (t2 === "boolean" || v3 === null) {
135978
+ upper += 5;
135979
+ } else {
135980
+ primitiveOnly = false;
135981
+ break;
135982
+ }
135983
+ if (upper > MAX_SURFACE_INPUT_BYTES)
135984
+ break;
135985
+ }
135986
+ if (primitiveOnly && upper <= MAX_SURFACE_INPUT_BYTES)
135987
+ return true;
135988
+ return JSON.stringify(m3).length <= MAX_SURFACE_INPUT_BYTES;
135989
+ }
135709
135990
  var surfaceInputParamsSchema = z.object({
135710
135991
  surfaceId: z.string().min(1).max(120),
135711
- message: z.object({ type: z.string().min(1).max(64) }).passthrough().refine((m3) => JSON.stringify(m3).length <= 1e6, {
135992
+ message: z.object({ type: z.string().min(1).max(64) }).passthrough().refine((m3) => surfaceInputWithinCap(m3), {
135712
135993
  message: "surface input message too large"
135713
135994
  })
135714
135995
  });
@@ -136285,7 +136566,7 @@ var TurnStream = class {
136285
136566
  yield this.queue.shift();
136286
136567
  if (this.done)
136287
136568
  break;
136288
- await new Promise((resolve13) => this.waiters.push(resolve13));
136569
+ await new Promise((resolve12) => this.waiters.push(resolve12));
136289
136570
  }
136290
136571
  if (this.error)
136291
136572
  throw new Error(this.error);
@@ -136920,7 +137201,7 @@ async function isMoxxyProcess(pid) {
136920
137201
  }
136921
137202
  async function pidCommand2(pid) {
136922
137203
  const { spawn: spawn15 } = await import('child_process');
136923
- return await new Promise((resolve13) => {
137204
+ return await new Promise((resolve12) => {
136924
137205
  let out = "";
136925
137206
  try {
136926
137207
  const child = spawn15("ps", ["-p", String(pid), "-o", "command="], {
@@ -136929,10 +137210,10 @@ async function pidCommand2(pid) {
136929
137210
  child.stdout.on("data", (b3) => {
136930
137211
  out += b3.toString();
136931
137212
  });
136932
- child.on("error", () => resolve13(""));
136933
- child.on("close", () => resolve13(out.trim()));
137213
+ child.on("error", () => resolve12(""));
137214
+ child.on("close", () => resolve12(out.trim()));
136934
137215
  } catch {
136935
- resolve13("");
137216
+ resolve12("");
136936
137217
  }
136937
137218
  });
136938
137219
  }
@@ -136962,7 +137243,7 @@ async function pidsListeningOnPort(port) {
136962
137243
  }
136963
137244
  async function runLsof(args) {
136964
137245
  const { spawn: spawn15 } = await import('child_process');
136965
- return await new Promise((resolve13) => {
137246
+ return await new Promise((resolve12) => {
136966
137247
  let out = "";
136967
137248
  try {
136968
137249
  const child = spawn15("lsof", [...args], {
@@ -136971,10 +137252,10 @@ async function runLsof(args) {
136971
137252
  child.stdout.on("data", (b3) => {
136972
137253
  out += b3.toString();
136973
137254
  });
136974
- child.on("error", () => resolve13([]));
136975
- child.on("close", () => resolve13(parsePids(out)));
137255
+ child.on("error", () => resolve12([]));
137256
+ child.on("close", () => resolve12(parsePids(out)));
136976
137257
  } catch {
136977
- resolve13([]);
137258
+ resolve12([]);
136978
137259
  }
136979
137260
  });
136980
137261
  }
@@ -137514,8 +137795,8 @@ var MobileSessionHost = class {
137514
137795
  for (const controller of this.turns.values())
137515
137796
  controller.abort();
137516
137797
  this.turns.clear();
137517
- for (const resolve13 of this.pendingAsks.values())
137518
- resolve13({ mode: "deny" });
137798
+ for (const resolve12 of this.pendingAsks.values())
137799
+ resolve12({ mode: "deny" });
137519
137800
  this.pendingAsks.clear();
137520
137801
  this.session.setApprovalResolver(null);
137521
137802
  }
@@ -137565,17 +137846,17 @@ var MobileSessionHost = class {
137565
137846
  }
137566
137847
  openAsk(req) {
137567
137848
  const requestId = `ask-${++this.askCounter}`;
137568
- return new Promise((resolve13) => {
137569
- this.pendingAsks.set(requestId, resolve13);
137849
+ return new Promise((resolve12) => {
137850
+ this.pendingAsks.set(requestId, resolve12);
137570
137851
  this.bus.broadcast("ask.request", { ...req, requestId });
137571
137852
  });
137572
137853
  }
137573
137854
  answerAsk(requestId, response) {
137574
- const resolve13 = this.pendingAsks.get(requestId);
137575
- if (!resolve13)
137855
+ const resolve12 = this.pendingAsks.get(requestId);
137856
+ if (!resolve12)
137576
137857
  return;
137577
137858
  this.pendingAsks.delete(requestId);
137578
- resolve13(response);
137859
+ resolve12(response);
137579
137860
  }
137580
137861
  };
137581
137862
  var TOKEN_FILE = "mobile-token";
@@ -137799,8 +138080,8 @@ var MobileChannel = class {
137799
138080
  throw err;
137800
138081
  }
137801
138082
  let resolveRunning;
137802
- const running = new Promise((resolve13) => {
137803
- resolveRunning = resolve13;
138083
+ const running = new Promise((resolve12) => {
138084
+ resolveRunning = resolve12;
137804
138085
  });
137805
138086
  return {
137806
138087
  running,
@@ -138360,7 +138641,7 @@ ${tail}` : " (no stderr captured)")
138360
138641
  throw new MoxxyError({ code: "NETWORK_ABORTED", message: "browser_session aborted" });
138361
138642
  const id = randomUUID();
138362
138643
  const req = { id, method, params };
138363
- return new Promise((resolve13, reject) => {
138644
+ return new Promise((resolve12, reject) => {
138364
138645
  const onAbort = () => {
138365
138646
  if (this.pending.delete(id))
138366
138647
  reject(new MoxxyError({ code: "NETWORK_ABORTED", message: "browser_session aborted" }));
@@ -138369,7 +138650,7 @@ ${tail}` : " (no stderr captured)")
138369
138650
  this.pending.set(id, {
138370
138651
  resolve: (v3) => {
138371
138652
  cleanup();
138372
- resolve13(v3);
138653
+ resolve12(v3);
138373
138654
  },
138374
138655
  reject: (e3) => {
138375
138656
  cleanup();
@@ -138522,9 +138803,12 @@ function buildBrowserSurface(deps) {
138522
138803
  fails = 0;
138523
138804
  emit2({ type: "frame", base64: frame.base64, mime: frame.mediaType, url: frame.url });
138524
138805
  } catch (err) {
138525
- if (++fails === FAIL_GRACE && !last) {
138806
+ if (++fails === FAIL_GRACE) {
138526
138807
  const message = err instanceof Error ? err.message : String(err);
138527
- emit2({ type: "status", text: `Browser unavailable: ${message}` });
138808
+ emit2({
138809
+ type: "status",
138810
+ text: last ? `Browser disconnected: ${message}` : `Browser unavailable: ${message}`
138811
+ });
138528
138812
  }
138529
138813
  } finally {
138530
138814
  inFlight = false;
@@ -138600,6 +138884,8 @@ function defaultShell() {
138600
138884
  return process.env["COMSPEC"] ?? "powershell.exe";
138601
138885
  return process.env["SHELL"] ?? "/bin/bash";
138602
138886
  }
138887
+ var MAX_SCROLLBACK = 2e5;
138888
+ var SCROLLBACK_SLACK = 1e5;
138603
138889
  var TerminalProcessImpl = class {
138604
138890
  backend;
138605
138891
  pty;
@@ -138623,7 +138909,10 @@ var TerminalProcessImpl = class {
138623
138909
  }
138624
138910
  }
138625
138911
  emitData(d2) {
138626
- this.buffer = (this.buffer + d2).slice(-2e5);
138912
+ this.buffer += d2;
138913
+ if (this.buffer.length > MAX_SCROLLBACK + SCROLLBACK_SLACK) {
138914
+ this.buffer = this.buffer.slice(-MAX_SCROLLBACK);
138915
+ }
138627
138916
  for (const cb of this.dataListeners) {
138628
138917
  try {
138629
138918
  cb(d2);
@@ -138651,7 +138940,7 @@ var TerminalProcessImpl = class {
138651
138940
  return () => this.exitListeners.delete(cb);
138652
138941
  }
138653
138942
  scrollback() {
138654
- return this.buffer;
138943
+ return this.buffer.length > MAX_SCROLLBACK ? this.buffer.slice(-MAX_SCROLLBACK) : this.buffer;
138655
138944
  }
138656
138945
  write(data) {
138657
138946
  if (!this.alive)
@@ -138787,7 +139076,7 @@ function buildTerminalTool() {
138787
139076
  });
138788
139077
  }
138789
139078
  function runCommand(proc, command, marker, timeoutMs) {
138790
- return new Promise((resolve13) => {
139079
+ return new Promise((resolve12) => {
138791
139080
  let acc = "";
138792
139081
  let settled = false;
138793
139082
  const finish = (exitCode, timedOut) => {
@@ -138796,13 +139085,19 @@ function runCommand(proc, command, marker, timeoutMs) {
138796
139085
  settled = true;
138797
139086
  unsub();
138798
139087
  clearTimeout(timer);
138799
- resolve13({ output: cleanOutput(acc, command, marker), exitCode, timedOut });
139088
+ resolve12({ output: cleanOutput(acc, command, marker), exitCode, timedOut });
138800
139089
  };
139090
+ const sentinel2 = new RegExp(`${marker} (\\d+)`);
139091
+ const carry = marker.length + 32;
139092
+ let scanFrom = 0;
138801
139093
  const unsub = proc.onData((d2) => {
139094
+ const from = Math.max(scanFrom, acc.length - carry, 0);
138802
139095
  acc += d2;
138803
- const m3 = new RegExp(`${marker} (\\d+)`).exec(acc);
139096
+ sentinel2.lastIndex = 0;
139097
+ const m3 = sentinel2.exec(from > 0 ? acc.slice(from) : acc);
138804
139098
  if (m3)
138805
139099
  finish(Number(m3[1]), false);
139100
+ scanFrom = Math.max(0, acc.length - carry);
138806
139101
  });
138807
139102
  const timer = setTimeout(() => finish(null, true), timeoutMs);
138808
139103
  proc.write(`${command}
@@ -138873,26 +139168,21 @@ function buildDispatchAgentTool(deps) {
138873
139168
  function resolveSpec(input, deps) {
138874
139169
  const requested = input.agentType ?? "default";
138875
139170
  const def = deps.getAgent(requested) ?? DEFAULT_AGENT;
139171
+ const systemPrompt = input.systemPrompt ?? def.systemPrompt;
139172
+ const model = input.model ?? def.model;
139173
+ const mode = input.mode ?? def.mode;
139174
+ const allowedTools = input.allowedTools ?? def.allowedTools;
138876
139175
  const merged = {
138877
139176
  prompt: input.prompt,
138878
139177
  label: input.label ?? def.name,
138879
139178
  // The requested kind, surfaced in subagent_* payloads for group rendering.
138880
- agentType: requested
139179
+ agentType: requested,
139180
+ ...systemPrompt !== void 0 && { systemPrompt },
139181
+ ...model !== void 0 && { model },
139182
+ ...mode !== void 0 && { mode },
139183
+ ...def.maxIterations !== void 0 && { maxIterations: def.maxIterations },
139184
+ ...allowedTools !== void 0 && { allowedTools }
138881
139185
  };
138882
- const systemPrompt = input.systemPrompt ?? def.systemPrompt;
138883
- if (systemPrompt !== void 0)
138884
- merged.systemPrompt = systemPrompt;
138885
- const model = input.model ?? def.model;
138886
- if (model !== void 0)
138887
- merged.model = model;
138888
- const mode = input.mode ?? def.mode;
138889
- if (mode !== void 0)
138890
- merged.mode = mode;
138891
- if (def.maxIterations !== void 0)
138892
- merged.maxIterations = def.maxIterations;
138893
- const allowedTools = input.allowedTools ?? def.allowedTools;
138894
- if (allowedTools !== void 0)
138895
- merged.allowedTools = allowedTools;
138896
139186
  return merged;
138897
139187
  }
138898
139188
 
@@ -139042,7 +139332,7 @@ async function ensurePackageJson(dir) {
139042
139332
  }
139043
139333
  }
139044
139334
  function runNpm(args, signal) {
139045
- return new Promise((resolve13, reject) => {
139335
+ return new Promise((resolve12, reject) => {
139046
139336
  if (signal?.aborted) {
139047
139337
  reject(new Error("npm aborted before start"));
139048
139338
  return;
@@ -139068,7 +139358,7 @@ function runNpm(args, signal) {
139068
139358
  });
139069
139359
  child.on("close", (code) => {
139070
139360
  signal?.removeEventListener("abort", onAbort);
139071
- resolve13({ exitCode: code ?? -1, stdout, stderr });
139361
+ resolve12({ exitCode: code ?? -1, stdout, stderr });
139072
139362
  });
139073
139363
  });
139074
139364
  }
@@ -139857,9 +140147,9 @@ function buildViewPlugin(opts) {
139857
140147
  }
139858
140148
  var IS_DARWIN = process.platform === "darwin";
139859
140149
  function runProcess(cmd, args, opts = {}) {
139860
- return new Promise((resolve13, reject) => {
140150
+ return new Promise((resolve12, reject) => {
139861
140151
  const child = spawn(cmd, [...args], { stdio: ["pipe", "pipe", "pipe"] });
139862
- let stdout = Buffer.alloc(0);
140152
+ const stdoutChunks = [];
139863
140153
  let stderr = "";
139864
140154
  let settled = false;
139865
140155
  const onAbort = () => {
@@ -139880,7 +140170,7 @@ function runProcess(cmd, args, opts = {}) {
139880
140170
  }
139881
140171
  }, opts.timeoutMs) : null;
139882
140172
  child.stdout.on("data", (chunk) => {
139883
- stdout = Buffer.concat([stdout, chunk]);
140173
+ stdoutChunks.push(chunk);
139884
140174
  });
139885
140175
  child.stderr.on("data", (chunk) => {
139886
140176
  stderr += chunk.toString("utf8");
@@ -139901,9 +140191,9 @@ function runProcess(cmd, args, opts = {}) {
139901
140191
  if (timer)
139902
140192
  clearTimeout(timer);
139903
140193
  opts.signal?.removeEventListener("abort", onAbort);
139904
- resolve13({
140194
+ resolve12({
139905
140195
  exitCode: code ?? -1,
139906
- stdout: stdout.toString("utf8"),
140196
+ stdout: Buffer.concat(stdoutChunks).toString("utf8"),
139907
140197
  stderr
139908
140198
  });
139909
140199
  });
@@ -140552,43 +140842,7 @@ async function syncSkillSchedules(registry, store) {
140552
140842
  if (draft)
140553
140843
  wanted.set(skill.frontmatter.name, draft);
140554
140844
  }
140555
- const existing = await store.list();
140556
- const existingSkill = /* @__PURE__ */ new Map();
140557
- for (const e3 of existing) {
140558
- if (e3.source === "skill" && e3.skillName)
140559
- existingSkill.set(e3.skillName, e3);
140560
- }
140561
- let added = 0;
140562
- let removed = 0;
140563
- let updated = 0;
140564
- for (const [skillName2, entry] of existingSkill) {
140565
- if (!wanted.has(skillName2)) {
140566
- const ok = await store.delete(entry.id);
140567
- if (ok)
140568
- removed += 1;
140569
- }
140570
- }
140571
- for (const [skillName2, draft] of wanted) {
140572
- const current = existingSkill.get(skillName2);
140573
- if (!current) {
140574
- await store.create(draft);
140575
- added += 1;
140576
- continue;
140577
- }
140578
- const changed = current.prompt !== draft.prompt || current.cron !== draft.cron || current.runAt !== draft.runAt || current.timeZone !== draft.timeZone || current.channel !== draft.channel || current.enabled !== draft.enabled;
140579
- if (changed) {
140580
- await store.update(current.id, {
140581
- prompt: draft.prompt,
140582
- ...draft.cron ? { cron: draft.cron } : { cron: void 0 },
140583
- ...draft.runAt !== void 0 ? { runAt: draft.runAt } : { runAt: void 0 },
140584
- ...draft.timeZone ? { timeZone: draft.timeZone } : { timeZone: void 0 },
140585
- ...draft.channel ? { channel: draft.channel } : { channel: void 0 },
140586
- enabled: draft.enabled
140587
- });
140588
- updated += 1;
140589
- }
140590
- }
140591
- return { added, removed, updated };
140845
+ return store.reconcileSkillSchedules(wanted);
140592
140846
  }
140593
140847
 
140594
140848
  // ../plugin-scheduler/dist/poller.js
@@ -140820,6 +141074,79 @@ var ScheduleStore = class {
140820
141074
  });
140821
141075
  return removed;
140822
141076
  }
141077
+ /**
141078
+ * Batch-reconcile every `source='skill'` row against `wanted` (skillName →
141079
+ * desired draft) in a SINGLE atomic write, instead of one whole-file
141080
+ * serialization + fsync per changed row. The diff (and the resulting array)
141081
+ * is byte-identical to running the equivalent sequence of
141082
+ * create/update/delete calls:
141083
+ * - skill rows whose skillName is absent from `wanted` are removed;
141084
+ * - present skillNames with no existing row are created (fresh id +
141085
+ * createdAt), appended in `wanted` iteration order;
141086
+ * - present skillNames with an existing row are updated IN PLACE (id,
141087
+ * createdAt, position preserved) only when a field actually changed.
141088
+ * Returns the add/remove/update counts so the caller's telemetry is
141089
+ * unchanged. Manual/workflow rows are never touched.
141090
+ */
141091
+ async reconcileSkillSchedules(wanted) {
141092
+ let added = 0;
141093
+ let removed = 0;
141094
+ let updated = 0;
141095
+ await this.store.mutate((schedules) => {
141096
+ const existingByName = /* @__PURE__ */ new Map();
141097
+ for (let i2 = 0; i2 < schedules.length; i2 += 1) {
141098
+ const s2 = schedules[i2];
141099
+ if (s2.source === "skill" && s2.skillName && !existingByName.has(s2.skillName)) {
141100
+ existingByName.set(s2.skillName, i2);
141101
+ }
141102
+ }
141103
+ const next = [];
141104
+ for (const s2 of schedules) {
141105
+ if (s2.source === "skill" && s2.skillName && !wanted.has(s2.skillName)) {
141106
+ removed += 1;
141107
+ continue;
141108
+ }
141109
+ next.push(s2);
141110
+ }
141111
+ const posInNext = /* @__PURE__ */ new Map();
141112
+ for (let i2 = 0; i2 < next.length; i2 += 1) {
141113
+ const s2 = next[i2];
141114
+ if (s2.source === "skill" && s2.skillName && !posInNext.has(s2.skillName)) {
141115
+ posInNext.set(s2.skillName, i2);
141116
+ }
141117
+ }
141118
+ for (const [skillName2, draft] of wanted) {
141119
+ const idx = posInNext.get(skillName2);
141120
+ if (idx === void 0) {
141121
+ next.push(scheduleEntrySchema.parse({
141122
+ ...draft,
141123
+ id: ulid(),
141124
+ createdAt: Date.now(),
141125
+ enabled: draft.enabled ?? true,
141126
+ source: draft.source ?? "skill"
141127
+ }));
141128
+ added += 1;
141129
+ continue;
141130
+ }
141131
+ const current = next[idx];
141132
+ const patch = {
141133
+ prompt: draft.prompt,
141134
+ ...draft.cron ? { cron: draft.cron } : { cron: void 0 },
141135
+ ...draft.runAt !== void 0 ? { runAt: draft.runAt } : { runAt: void 0 },
141136
+ ...draft.timeZone ? { timeZone: draft.timeZone } : { timeZone: void 0 },
141137
+ ...draft.channel ? { channel: draft.channel } : { channel: void 0 },
141138
+ enabled: draft.enabled ?? true
141139
+ };
141140
+ const changed = current.prompt !== patch.prompt || current.cron !== patch.cron || current.runAt !== patch.runAt || current.timeZone !== patch.timeZone || current.channel !== patch.channel || current.enabled !== patch.enabled;
141141
+ if (changed) {
141142
+ next[idx] = scheduleEntrySchema.parse({ ...current, ...patch });
141143
+ updated += 1;
141144
+ }
141145
+ }
141146
+ return next;
141147
+ });
141148
+ return { added, removed, updated };
141149
+ }
140823
141150
  /**
140824
141151
  * Replace every `source='skill'` schedule for the given `skillName`
140825
141152
  * with the supplied entry, OR remove all of them if `entry` is null.
@@ -141106,12 +141433,8 @@ var WebhookConfigStore = class {
141106
141433
  const raw = await readFile(this.file, "utf8");
141107
141434
  const parsed = fileSchema2.safeParse(JSON.parse(raw));
141108
141435
  this.cache = parsed.success ? parsed.data.config : webhookConfigSchema.parse({});
141109
- } catch (err) {
141110
- if (err.code === "ENOENT") {
141111
- this.cache = webhookConfigSchema.parse({});
141112
- } else {
141113
- this.cache = webhookConfigSchema.parse({});
141114
- }
141436
+ } catch {
141437
+ this.cache = webhookConfigSchema.parse({});
141115
141438
  }
141116
141439
  }
141117
141440
  async persist(config) {
@@ -141259,23 +141582,26 @@ function readHeader(headers, name) {
141259
141582
  return v3[0] ?? null;
141260
141583
  return v3 ?? null;
141261
141584
  }
141262
- function readJsonPath(body, path60) {
141263
- let parsed;
141585
+ function parseBody(body) {
141264
141586
  try {
141265
- parsed = JSON.parse(body.toString("utf8"));
141587
+ return { ok: true, value: JSON.parse(body.toString("utf8")) };
141266
141588
  } catch {
141267
- return null;
141589
+ return { ok: false, value: null };
141268
141590
  }
141269
- let cur = parsed;
141270
- for (const seg of path60.split(".")) {
141591
+ }
141592
+ function readJsonPath(parsed, path59) {
141593
+ if (!parsed.ok)
141594
+ return null;
141595
+ let cur = parsed.value;
141596
+ for (const seg of path59.split(".")) {
141271
141597
  if (cur === null || cur === void 0 || typeof cur !== "object")
141272
141598
  return null;
141273
141599
  cur = cur[seg];
141274
141600
  }
141275
141601
  return asString2(cur);
141276
141602
  }
141277
- function ruleMatches(rule, input) {
141278
- const value = rule.source === "header" ? readHeader(input.headers, rule.name) : readJsonPath(input.body, rule.path);
141603
+ function ruleMatches(rule, input, parsed) {
141604
+ const value = rule.source === "header" ? readHeader(input.headers, rule.name) : readJsonPath(parsed, rule.path);
141279
141605
  if (value === null)
141280
141606
  return false;
141281
141607
  if (rule.equals && rule.equals.includes(value))
@@ -141291,11 +141617,12 @@ function ruleMatches(rule, input) {
141291
141617
  return false;
141292
141618
  }
141293
141619
  function shouldFire(filter, input) {
141294
- if (filter.exclude.some((r2) => ruleMatches(r2, input)))
141620
+ const parsed = parseBody(input.body);
141621
+ if (filter.exclude.some((r2) => ruleMatches(r2, input, parsed)))
141295
141622
  return false;
141296
141623
  if (filter.include.length === 0)
141297
141624
  return true;
141298
- return filter.include.some((r2) => ruleMatches(r2, input));
141625
+ return filter.include.some((r2) => ruleMatches(r2, input, parsed));
141299
141626
  }
141300
141627
 
141301
141628
  // ../plugin-webhooks/dist/template.js
@@ -141455,14 +141782,14 @@ var WebhookServer = class {
141455
141782
  });
141456
141783
  });
141457
141784
  this.server = server;
141458
- await new Promise((resolve13, reject) => {
141785
+ await new Promise((resolve12, reject) => {
141459
141786
  server.once("error", reject);
141460
141787
  server.listen(this.opts.port, this.opts.host, () => {
141461
141788
  this.opts.logger?.info?.("webhooks: listening", {
141462
141789
  host: this.opts.host,
141463
141790
  port: this.opts.port
141464
141791
  });
141465
- resolve13();
141792
+ resolve12();
141466
141793
  });
141467
141794
  });
141468
141795
  return {
@@ -141476,7 +141803,7 @@ var WebhookServer = class {
141476
141803
  return;
141477
141804
  const s2 = this.server;
141478
141805
  this.server = null;
141479
- await new Promise((resolve13) => s2.close(() => resolve13()));
141806
+ await new Promise((resolve12) => s2.close(() => resolve12()));
141480
141807
  }
141481
141808
  async handle(req, res) {
141482
141809
  const url2 = req.url ?? "/";
@@ -142670,7 +142997,7 @@ var inprocIsolator = {
142670
142997
  internal.abort(signal.reason ?? new Error(`[security:inproc] tool '${call.toolName}' aborted`));
142671
142998
  }
142672
142999
  };
142673
- return new Promise((resolve13, reject) => {
143000
+ return new Promise((resolve12, reject) => {
142674
143001
  if (signal.aborted) {
142675
143002
  onExternalAbort();
142676
143003
  reject(new Error(`[security:inproc] tool '${call.toolName}' aborted`));
@@ -142690,7 +143017,7 @@ var inprocIsolator = {
142690
143017
  runHandler(handler, call.input, handlerSignal).then((out) => {
142691
143018
  clearTimeout(timer);
142692
143019
  signal.removeEventListener("abort", onAbort);
142693
- resolve13(out);
143020
+ resolve12(out);
142694
143021
  }, (err) => {
142695
143022
  clearTimeout(timer);
142696
143023
  signal.removeEventListener("abort", onAbort);
@@ -143001,7 +143328,7 @@ async function brokerExec(args, { caps, cwd: cwd2, signal }) {
143001
143328
  throw new Error(`[broker:exec] command '${command}' is outside the tool's declared commands allowlist`);
143002
143329
  }
143003
143330
  }
143004
- return await new Promise((resolve13, reject) => {
143331
+ return await new Promise((resolve12, reject) => {
143005
143332
  const child = spawn(command, [...argv], {
143006
143333
  cwd: opts.cwd ?? cwd2,
143007
143334
  // Filter the parent env through the tool's `caps.env` allowlist (or a
@@ -143049,7 +143376,7 @@ async function brokerExec(args, { caps, cwd: cwd2, signal }) {
143049
143376
  finish(() => reject(e3));
143050
143377
  });
143051
143378
  child.on("close", (exitCode) => {
143052
- finish(() => resolve13({
143379
+ finish(() => resolve12({
143053
143380
  stdout: Buffer.concat(outChunks).toString("utf8"),
143054
143381
  stderr: Buffer.concat(errChunks).toString("utf8"),
143055
143382
  exitCode
@@ -143319,7 +143646,7 @@ function createWorkerIsolator(opts = {}) {
143319
143646
  maxYoungGenerationSizeMb: Math.max(16, Math.floor(memMb / 4))
143320
143647
  }
143321
143648
  });
143322
- return new Promise((resolve13, reject) => {
143649
+ return new Promise((resolve12, reject) => {
143323
143650
  const cleanup = /* @__PURE__ */ new Set();
143324
143651
  let settled = false;
143325
143652
  let terminated = false;
@@ -143375,7 +143702,7 @@ function createWorkerIsolator(opts = {}) {
143375
143702
  if (settled)
143376
143703
  return;
143377
143704
  if (msg.ok) {
143378
- finish(() => resolve13(msg.value));
143705
+ finish(() => resolve12(msg.value));
143379
143706
  } else {
143380
143707
  const e3 = new Error(msg.errorMessage);
143381
143708
  e3.name = msg.errorName;
@@ -143524,7 +143851,7 @@ function createSubprocessIsolator(opts = {}) {
143524
143851
  env: env3,
143525
143852
  stdio: ["pipe", "pipe", "pipe"]
143526
143853
  });
143527
- return new Promise((resolve13, reject) => {
143854
+ return new Promise((resolve12, reject) => {
143528
143855
  let stderr = "";
143529
143856
  let stdoutBuffer = "";
143530
143857
  let settled = false;
@@ -143598,7 +143925,7 @@ function createSubprocessIsolator(opts = {}) {
143598
143925
  return;
143599
143926
  }
143600
143927
  if (msg.ok) {
143601
- finish(() => resolve13(msg.value));
143928
+ finish(() => resolve12(msg.value));
143602
143929
  } else {
143603
143930
  const e3 = new Error(msg.errorMessage);
143604
143931
  e3.name = msg.errorName;
@@ -143705,6 +144032,9 @@ async function invoke(call, caps, _signal) {
143705
144032
  const inputPtr = exports.alloc(inputBytes.length);
143706
144033
  new Uint8Array(exports.memory.buffer, inputPtr, inputBytes.length).set(inputBytes);
143707
144034
  const packed = handler(inputPtr, inputBytes.length);
144035
+ if (typeof packed !== "bigint") {
144036
+ throw new Error(`[security:wasm] handler must return i64 (got ${typeof packed}); check the (i32,i32)->i64 calling convention`);
144037
+ }
143708
144038
  const outputPtr = Number(packed >> 32n & 0xffffffffn);
143709
144039
  const outputLen = Number(packed & 0xffffffffn);
143710
144040
  if (outputLen === 0)
@@ -144460,8 +144790,8 @@ function formatIssues(error2, raw) {
144460
144790
  const field = rest.join(".");
144461
144791
  return field ? `${where}: ${field} ${msg}` : `${where} ${msg}`;
144462
144792
  }
144463
- const path60 = iss.path.join(".");
144464
- return path60 ? `${path60} ${msg}` : `workflow ${msg}`;
144793
+ const path59 = iss.path.join(".");
144794
+ return path59 ? `${path59} ${msg}` : `workflow ${msg}`;
144465
144795
  });
144466
144796
  }
144467
144797
  function validateWorkflow(raw) {
@@ -145461,7 +145791,7 @@ function buildSubagentSpecWithDeps(step, scope, deps, opts) {
145461
145791
  }
145462
145792
  var dagExecutor = defineWorkflowExecutor({
145463
145793
  name: DAG_EXECUTOR_NAME,
145464
- description: "Parallel DAG runner: steps with settled dependencies run in waves up to `concurrency`.",
145794
+ description: "DAG runner: steps with settled dependencies are scheduled in waves of up to `concurrency` ready steps, then executed sequentially within each wave (no overlap yet \u2014 `concurrency` caps the batch size, not wall-clock latency).",
145465
145795
  run: runExecutor
145466
145796
  });
145467
145797
 
@@ -147164,60 +147494,23 @@ function scopedSessionView(session, allowedTools, triggerName) {
147164
147494
  return parent.execute(name, input, signal, opts);
147165
147495
  }
147166
147496
  };
147167
- return {
147168
- get id() {
147169
- return session.id;
147170
- },
147171
- get log() {
147172
- return session.log;
147173
- },
147174
- get signal() {
147175
- return session.signal;
147176
- },
147177
- tools,
147178
- get skills() {
147179
- return session.skills;
147180
- },
147181
- get providers() {
147182
- return session.providers;
147183
- },
147184
- get modes() {
147185
- return session.modes;
147186
- },
147187
- get compactors() {
147188
- return session.compactors;
147189
- },
147190
- get cacheStrategies() {
147191
- return session.cacheStrategies;
147192
- },
147193
- resolver: resolver2,
147194
- get approvalResolver() {
147195
- return session.approvalResolver;
147196
- },
147197
- get elisionSettings() {
147198
- return session.elisionSettings;
147199
- },
147200
- get lazyTools() {
147201
- return session.lazyTools;
147202
- },
147203
- get dispatcher() {
147204
- return session.dispatcher;
147205
- },
147206
- get pluginHost() {
147207
- return session.pluginHost;
147208
- },
147209
- // Read-through AND write-through: runTurn records the resolved model on
147210
- // the session it was handed, and that must land on the real session, not
147211
- // this per-fire view.
147212
- get lastResolvedModel() {
147213
- return session.lastResolvedModel;
147214
- },
147215
- set lastResolvedModel(model) {
147216
- session.lastResolvedModel = model;
147217
- },
147218
- startTurn: () => session.startTurn(),
147219
- appContext: () => session.appContext()
147220
- };
147497
+ const view = Object.create(session);
147498
+ Object.defineProperties(view, {
147499
+ tools: { value: tools, enumerable: true },
147500
+ resolver: { value: resolver2, enumerable: true },
147501
+ // Write-through: `runTurn` records the resolved model on the session it
147502
+ // was handed; that must land on the real session, not this per-fire view.
147503
+ // An own data property on the prototype-chained view would otherwise
147504
+ // shadow the real one on write, so install an explicit accessor.
147505
+ lastResolvedModel: {
147506
+ get: () => session.lastResolvedModel,
147507
+ set: (model) => {
147508
+ session.lastResolvedModel = model;
147509
+ },
147510
+ enumerable: true
147511
+ }
147512
+ });
147513
+ return view;
147221
147514
  }
147222
147515
 
147223
147516
  // src/setup/register-plugins.ts
@@ -147856,7 +148149,11 @@ async function runPromptCommand(argv) {
147856
148149
  ${stdinBuf}` : prompt;
147857
148150
  const allowTools = parseList(argv.flags["allow-tools"]);
147858
148151
  const allowAll = hasBoolFlag(argv, "allow-all");
147859
- const outputFormat = stringFlag(argv, "output-format") ?? "text";
148152
+ const outputFormat = parseOutputFormat(stringFlag(argv, "output-format"));
148153
+ if (outputFormat === null) {
148154
+ printError(`--output-format must be one of: ${OUTPUT_FORMATS.join(", ")}`);
148155
+ return 2;
148156
+ }
147860
148157
  const model = stringFlag(argv, "model");
147861
148158
  const resolver2 = allowAll ? denyByDefaultResolver : allowTools.length > 0 ? createAllowListResolver(allowTools) : denyByDefaultResolver;
147862
148159
  const session = await setupSession({
@@ -147898,6 +148195,11 @@ ${stdinBuf}` : prompt;
147898
148195
  }
147899
148196
  return exitCode;
147900
148197
  }
148198
+ var OUTPUT_FORMATS = ["text", "json", "stream-json"];
148199
+ function parseOutputFormat(raw) {
148200
+ if (raw === void 0) return "text";
148201
+ return OUTPUT_FORMATS.includes(raw) ? raw : null;
148202
+ }
147901
148203
  function parseList(v3) {
147902
148204
  if (typeof v3 !== "string" || !v3) return [];
147903
148205
  return v3.split(",").map((s2) => s2.trim()).filter(Boolean);
@@ -148338,7 +148640,7 @@ function makeStdinLinePrompt(input) {
148338
148640
  const queued = lineQueue.shift();
148339
148641
  if (queued !== void 0) return Promise.resolve(queued);
148340
148642
  if (stdinEnded) return Promise.resolve("");
148341
- return new Promise((resolve13) => lineWaiters.push(resolve13));
148643
+ return new Promise((resolve12) => lineWaiters.push(resolve12));
148342
148644
  };
148343
148645
  return async (question, promptOpts) => {
148344
148646
  process.stdout.write(encodeLoginPrompt({ question, mask: promptOpts?.mask === true }));
@@ -148495,8 +148797,8 @@ function titleCase(s2) {
148495
148797
  // src/commands/run-tui.ts
148496
148798
  async function killStaleRunnerAt(socketPath) {
148497
148799
  if (!existsSync(socketPath)) return;
148498
- const pid = await new Promise((resolve13) => {
148499
- if (process.platform === "win32") return resolve13(null);
148800
+ const pid = await new Promise((resolve12) => {
148801
+ if (process.platform === "win32") return resolve12(null);
148500
148802
  let out = "";
148501
148803
  try {
148502
148804
  const child = spawn("lsof", ["-t", socketPath], {
@@ -148505,13 +148807,13 @@ async function killStaleRunnerAt(socketPath) {
148505
148807
  child.stdout.on("data", (b3) => {
148506
148808
  out += b3.toString();
148507
148809
  });
148508
- child.on("error", () => resolve13(null));
148810
+ child.on("error", () => resolve12(null));
148509
148811
  child.on("close", () => {
148510
148812
  const parsed = parseInt(out.trim().split("\n")[0] ?? "", 10);
148511
- resolve13(Number.isFinite(parsed) && parsed > 0 ? parsed : null);
148813
+ resolve12(Number.isFinite(parsed) && parsed > 0 ? parsed : null);
148512
148814
  });
148513
148815
  } catch {
148514
- resolve13(null);
148816
+ resolve12(null);
148515
148817
  }
148516
148818
  });
148517
148819
  if (pid && pid !== process.pid) {
@@ -148964,19 +149266,25 @@ async function removeAuditEntry(slug) {
148964
149266
  }
148965
149267
  function groupSimilarPrompts(entries) {
148966
149268
  const groups = [];
149269
+ const groupTokenSets = [];
148967
149270
  for (const entry of entries) {
148968
149271
  const tokens = tokenize8(entry.originatingPrompt);
148969
149272
  let placed = false;
148970
- for (const group of groups) {
148971
- const groupTokens = new Set(group.flatMap((e3) => tokenize8(e3.originatingPrompt)));
148972
- const overlap = tokens.filter((t2) => groupTokens.has(t2)).length;
149273
+ for (let i2 = 0; i2 < groups.length; i2 += 1) {
149274
+ const groupTokens = groupTokenSets[i2];
149275
+ let overlap = 0;
149276
+ for (const t2 of tokens) if (groupTokens.has(t2)) overlap += 1;
148973
149277
  if (overlap >= 2) {
148974
- group.push(entry);
149278
+ groups[i2].push(entry);
149279
+ for (const t2 of tokens) groupTokens.add(t2);
148975
149280
  placed = true;
148976
149281
  break;
148977
149282
  }
148978
149283
  }
148979
- if (!placed) groups.push([entry]);
149284
+ if (!placed) {
149285
+ groups.push([entry]);
149286
+ groupTokenSets.push(new Set(tokens));
149287
+ }
148980
149288
  }
148981
149289
  return groups;
148982
149290
  }
@@ -152305,14 +152613,14 @@ var HELP14 = formatHelp({
152305
152613
  async function runCommand2(cmd) {
152306
152614
  const [bin, ...args] = cmd;
152307
152615
  if (!bin) return 1;
152308
- return new Promise((resolve13) => {
152616
+ return new Promise((resolve12) => {
152309
152617
  const proc = spawn(bin, args, {
152310
152618
  stdio: "inherit",
152311
152619
  // npm/pnpm/yarn/bun are `.cmd` shims on Windows — needs a shell to launch.
152312
152620
  shell: process.platform === "win32"
152313
152621
  });
152314
- proc.on("error", () => resolve13(127));
152315
- proc.on("exit", (code) => resolve13(code ?? 1));
152622
+ proc.on("error", () => resolve12(127));
152623
+ proc.on("exit", (code) => resolve12(code ?? 1));
152316
152624
  });
152317
152625
  }
152318
152626
  async function runUpdateCommand(argv, deps = {}) {