chatroom-cli 1.135.0 → 1.137.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -2140,7 +2140,156 @@ var require_commander = __commonJS((exports) => {
2140
2140
  exports.InvalidOptionArgumentError = InvalidArgumentError;
2141
2141
  });
2142
2142
 
2143
+ // src/commands/generate/model-capabilities.ts
2144
+ function getModelCapability(id) {
2145
+ return Object.prototype.hasOwnProperty.call(MODEL_CAPABILITIES, id) ? MODEL_CAPABILITIES[id] : undefined;
2146
+ }
2147
+ function describeKey(capability, key, source) {
2148
+ const support = capability.params[key];
2149
+ if (support === undefined) {
2150
+ return [
2151
+ {
2152
+ kind: "unknown",
2153
+ key,
2154
+ message: `not in the CLI's capability data for ${capability.id}; not checked.`
2155
+ }
2156
+ ];
2157
+ }
2158
+ if (support.support === "unsupported") {
2159
+ return [{ kind: "unsupported", key, source, message: support.reason }];
2160
+ }
2161
+ return [];
2162
+ }
2163
+ function describeInputKeys(capability, input) {
2164
+ const disclosures = [];
2165
+ for (const key of Object.keys(input)) {
2166
+ if (key === "aspect_ratio")
2167
+ continue;
2168
+ disclosures.push(...describeKey(capability, key, "input"));
2169
+ }
2170
+ return disclosures;
2171
+ }
2172
+ function describeFlagKeys(capability, flags) {
2173
+ return flags.aspectRatio === undefined ? [] : describeKey(capability, "aspect_ratio", "flag");
2174
+ }
2175
+ function describeDefaults(capability, input) {
2176
+ return Object.entries(capability.params).flatMap(([key, support]) => {
2177
+ if (support.support !== "supported" || support.default === undefined)
2178
+ return [];
2179
+ if (input[key] !== undefined)
2180
+ return [];
2181
+ return [
2182
+ {
2183
+ kind: "default",
2184
+ key,
2185
+ message: `${key} is not set; the model default ${support.default} applies. Set one explicit value for every call of a set.`
2186
+ }
2187
+ ];
2188
+ });
2189
+ }
2190
+ function describeNotes(capability) {
2191
+ return capability.notes.map((message) => ({ kind: "note", message }));
2192
+ }
2193
+ function describeConstraints(model, input, flags) {
2194
+ const capability = getModelCapability(model);
2195
+ if (capability === undefined) {
2196
+ return [
2197
+ {
2198
+ kind: "note",
2199
+ message: `The CLI has no capability data for ${model}; no constraints were checked.`
2200
+ }
2201
+ ];
2202
+ }
2203
+ return [
2204
+ ...describeInputKeys(capability, input),
2205
+ ...describeFlagKeys(capability, flags),
2206
+ ...describeDefaults(capability, input),
2207
+ ...describeNotes(capability)
2208
+ ];
2209
+ }
2210
+ var FLUX_2_FLASH_MODEL = "fal-ai/flux-2/flash", FLUX_2_FLASH_EDIT_MODEL = "fal-ai/flux-2/flash/edit", FLASH_SOURCE = "https://fal.ai/api/openapi/queue/openapi.json?endpoint_id=fal-ai/flux-2/flash (read 2026-10-24); no negative prompt: https://help.bfl.ai/articles/7734566352-does-flux-2-support-negative-prompting (read 2026-10-24)", EDIT_SOURCE = "https://fal.ai/api/openapi/queue/openapi.json?endpoint_id=fal-ai/flux-2/flash/edit (read 2026-10-24); no negative prompt: https://help.bfl.ai/articles/7734566352-does-flux-2-support-negative-prompting (read 2026-10-24)", MODEL_CAPABILITIES;
2211
+ var init_model_capabilities = __esm(() => {
2212
+ MODEL_CAPABILITIES = {
2213
+ [FLUX_2_FLASH_MODEL]: {
2214
+ id: FLUX_2_FLASH_MODEL,
2215
+ name: "FLUX 2 Flash",
2216
+ task: "text-to-image",
2217
+ params: {
2218
+ prompt: { support: "supported" },
2219
+ seed: { support: "supported" },
2220
+ output_format: { support: "supported" },
2221
+ image_size: {
2222
+ support: "supported",
2223
+ default: "landscape_4_3",
2224
+ note: "set one explicit value for every call of a set"
2225
+ },
2226
+ aspect_ratio: {
2227
+ support: "unsupported",
2228
+ reason: `FLUX 2 Flash sizes output with image_size. Pass --input '{"image_size":"landscape_4_3"}' instead.`
2229
+ },
2230
+ negative_prompt: {
2231
+ support: "unsupported",
2232
+ reason: "FLUX 2 Flash has no negative prompt; describe what you want in --prompt instead."
2233
+ },
2234
+ image_urls: {
2235
+ support: "unsupported",
2236
+ reason: "Text-to-image only; use --model fal-ai/flux-2/flash/edit with --input-image."
2237
+ }
2238
+ },
2239
+ notes: [
2240
+ "FLUX 2 Flash has no camera or perspective parameter; perspective comes only from the prompt.",
2241
+ "Same-seed reproducibility is not documented by fal.",
2242
+ "Returns PNG without an alpha channel by default."
2243
+ ],
2244
+ source: FLASH_SOURCE
2245
+ },
2246
+ [FLUX_2_FLASH_EDIT_MODEL]: {
2247
+ id: FLUX_2_FLASH_EDIT_MODEL,
2248
+ name: "FLUX 2 Flash (edit)",
2249
+ task: "image-edit",
2250
+ params: {
2251
+ prompt: { support: "supported" },
2252
+ seed: { support: "supported" },
2253
+ image_urls: {
2254
+ support: "supported",
2255
+ note: "set by --input-image; the CLI sends one image"
2256
+ },
2257
+ image_size: {
2258
+ support: "supported",
2259
+ default: "square_hd",
2260
+ note: "set one explicit value for every call of a set"
2261
+ },
2262
+ aspect_ratio: {
2263
+ support: "unsupported",
2264
+ reason: `FLUX 2 Flash (edit) sizes output with image_size. Pass --input '{"image_size":"square_hd"}' instead.`
2265
+ },
2266
+ negative_prompt: {
2267
+ support: "unsupported",
2268
+ reason: "FLUX 2 Flash has no negative prompt; describe what you want in --prompt instead."
2269
+ }
2270
+ },
2271
+ notes: [
2272
+ "FLUX 2 Flash has no camera or perspective parameter; perspective comes only from the prompt.",
2273
+ "Not documented to carry a reference image's perspective over to new content; it may return a modified copy of the input.",
2274
+ "Same-seed reproducibility is not documented by fal."
2275
+ ],
2276
+ source: EDIT_SOURCE
2277
+ }
2278
+ };
2279
+ });
2280
+
2143
2281
  // src/commands/generate/image.ts
2282
+ var exports_image = {};
2283
+ __export(exports_image, {
2284
+ planGenerateImage: () => planGenerateImage,
2285
+ parseInputJson: () => parseInputJson,
2286
+ generateImage: () => generateImage,
2287
+ formatGenerateImagePlan: () => formatGenerateImagePlan,
2288
+ GenerateImageError: () => GenerateImageError,
2289
+ GENERATE_IMAGE_PLATFORMS: () => GENERATE_IMAGE_PLATFORMS,
2290
+ FAL_API_KEY_MISSING_MESSAGE: () => FAL_API_KEY_MISSING_MESSAGE,
2291
+ DEFAULT_GENERATE_IMAGE_PLATFORM: () => DEFAULT_GENERATE_IMAGE_PLATFORM
2292
+ });
2144
2293
  import { createHash } from "node:crypto";
2145
2294
  import { extname, resolve } from "node:path";
2146
2295
  function resolvePlatform(platform) {
@@ -2163,6 +2312,14 @@ function requireNonEmpty(value, message) {
2163
2312
  }
2164
2313
  return trimmed;
2165
2314
  }
2315
+ function inputImageContentType(path) {
2316
+ const extension = extname(path).toLowerCase();
2317
+ const contentType = INPUT_IMAGE_CONTENT_TYPES[extension];
2318
+ if (contentType === undefined) {
2319
+ throw new GenerateImageError(`Unsupported --input-image extension ${extension || "(none)"}. Use one of: ${Object.keys(INPUT_IMAGE_CONTENT_TYPES).join(", ")}.`);
2320
+ }
2321
+ return contentType;
2322
+ }
2166
2323
  function validateInputObject(input) {
2167
2324
  if ("sync_mode" in input && input.sync_mode !== undefined) {
2168
2325
  throw new GenerateImageError('--input must not contain "sync_mode": it returns data URIs that this command cannot download. Omit it.');
@@ -2176,6 +2333,9 @@ function validateInputObject(input) {
2176
2333
  }
2177
2334
  }
2178
2335
  }
2336
+ function isPlainObject(value) {
2337
+ return typeof value === "object" && value !== null && !Array.isArray(value);
2338
+ }
2179
2339
  function parseInputJson(text) {
2180
2340
  let parsed;
2181
2341
  try {
@@ -2183,28 +2343,30 @@ function parseInputJson(text) {
2183
2343
  } catch {
2184
2344
  throw new GenerateImageError("--input must be valid JSON.");
2185
2345
  }
2186
- if (typeof parsed !== "object" || parsed === null || Array.isArray(parsed)) {
2346
+ if (!isPlainObject(parsed)) {
2187
2347
  throw new GenerateImageError("--input must be a JSON object.");
2188
2348
  }
2189
- const input = parsed;
2190
- validateInputObject(input);
2191
- return input;
2349
+ validateInputObject(parsed);
2350
+ return parsed;
2192
2351
  }
2193
- function buildInput(prompt, opts) {
2194
- if (opts.input !== undefined) {
2195
- if (typeof opts.input !== "object" || opts.input === null || Array.isArray(opts.input)) {
2196
- throw new GenerateImageError("--input must be a JSON object.");
2197
- }
2198
- validateInputObject(opts.input);
2199
- }
2352
+ function buildInput(prompt, opts, imageUrl) {
2200
2353
  return {
2201
2354
  prompt,
2202
2355
  ...opts.input ?? {},
2203
2356
  ...opts.aspectRatio !== undefined ? { aspect_ratio: opts.aspectRatio } : {},
2204
2357
  ...opts.outputFormat !== undefined ? { output_format: opts.outputFormat } : {},
2205
- ...opts.seed !== undefined ? { seed: opts.seed } : {}
2358
+ ...opts.seed !== undefined ? { seed: opts.seed } : {},
2359
+ ...imageUrl !== undefined ? { image_urls: [imageUrl] } : {}
2206
2360
  };
2207
2361
  }
2362
+ function validateInputOption(opts) {
2363
+ if (opts.input === undefined)
2364
+ return;
2365
+ if (!isPlainObject(opts.input)) {
2366
+ throw new GenerateImageError("--input must be a JSON object.");
2367
+ }
2368
+ validateInputObject(opts.input);
2369
+ }
2208
2370
  function requireImage(images, model) {
2209
2371
  const image = images[0];
2210
2372
  if (!image?.url) {
@@ -2243,6 +2405,12 @@ async function saveImage(deps, outPath, bytes, requestId, url) {
2243
2405
  throw new GenerateImageError(recoveryMessage("save", err, requestId, url));
2244
2406
  }
2245
2407
  }
2408
+ function requireSupportedExtension(outPath) {
2409
+ const extension = extname(outPath).toLowerCase();
2410
+ if (!UNSUPPORTED_OUTPUT_EXTENSIONS.has(extension))
2411
+ return;
2412
+ throw new GenerateImageError(`Unsupported output extension ${extension}. Use .png or .webp (transparency-capable).`);
2413
+ }
2246
2414
  function requireFormatMatchesExtension(outPath, format) {
2247
2415
  const extension = extname(outPath).toLowerCase();
2248
2416
  const expected = EXTENSION_FORMATS[extension];
@@ -2260,6 +2428,7 @@ function buildManifest(args) {
2260
2428
  sdk: `@fal-ai/client@${args.sdkVersion}`,
2261
2429
  model: args.model,
2262
2430
  input: args.input,
2431
+ inputImage: args.inputImage,
2263
2432
  requestId: args.requestId ?? null,
2264
2433
  seed: resolveSeed(args.resultSeed, args.requestedSeed),
2265
2434
  output: {
@@ -2272,20 +2441,118 @@ function buildManifest(args) {
2272
2441
  licensing: LICENSING
2273
2442
  };
2274
2443
  }
2275
- async function generateImage(opts, deps) {
2444
+ function requireTaskPairing(capability, model, inputImage) {
2445
+ if (capability.task === "image-edit" && inputImage === undefined) {
2446
+ throw new GenerateImageError(`${model} edits an image; pass --input-image <path-or-url>.`);
2447
+ }
2448
+ if (capability.task === "text-to-image" && inputImage !== undefined) {
2449
+ throw new GenerateImageError(`${model} does not take an input image; use --model ${FLUX_2_FLASH_EDIT_MODEL} with --input-image.`);
2450
+ }
2451
+ }
2452
+ function requireAspectRatioSupport(capability, model, aspectRatio) {
2453
+ if (aspectRatio === undefined)
2454
+ return;
2455
+ const support = capability.params.aspect_ratio;
2456
+ if (support?.support !== "unsupported")
2457
+ return;
2458
+ throw new GenerateImageError(`--aspect-ratio is not supported by ${model}. ${support.reason}`);
2459
+ }
2460
+ function requireModelPairing(model, inputImage, aspectRatio) {
2461
+ const capability = getModelCapability(model);
2462
+ if (capability === undefined)
2463
+ return;
2464
+ requireTaskPairing(capability, model, inputImage);
2465
+ requireAspectRatioSupport(capability, model, aspectRatio);
2466
+ }
2467
+ function resolveInputImageOption(opts) {
2468
+ return opts.inputImage === undefined ? undefined : requireNonEmpty(opts.inputImage, "--input-image must not be empty.");
2469
+ }
2470
+ async function validateInputImage(deps, inputImage) {
2471
+ if (inputImage === undefined)
2472
+ return;
2473
+ if (HTTP_URL_PATTERN.test(inputImage))
2474
+ return { kind: "url", url: inputImage };
2475
+ const localPath = resolve(inputImage);
2476
+ const contentType = inputImageContentType(localPath);
2477
+ const status = await deps.pathStatus(localPath);
2478
+ if (status !== "file") {
2479
+ throw new GenerateImageError(`--input-image is not a file: ${localPath}`);
2480
+ }
2481
+ return { kind: "file", path: localPath, contentType };
2482
+ }
2483
+ function planInputImageUrl(target) {
2484
+ if (target === undefined)
2485
+ return;
2486
+ return target.kind === "url" ? target.url : `<fal storage URL for ${target.path}>`;
2487
+ }
2488
+ async function uploadInputImage(deps, target) {
2489
+ if (target === undefined)
2490
+ return { url: undefined, record: null };
2491
+ if (target.kind === "url") {
2492
+ return { url: target.url, record: { source: target.url, url: target.url } };
2493
+ }
2494
+ const url = await deps.uploadFile(target.path, target.contentType);
2495
+ return { url, record: { source: target.path, url } };
2496
+ }
2497
+ async function planGenerateImage(opts, deps) {
2276
2498
  const platform = resolvePlatform(opts.platform);
2277
2499
  requireSupportedPlatform(platform);
2278
- requireFalKey(deps);
2500
+ const model = requireNonEmpty(opts.model, "--model must not be empty.");
2279
2501
  const prompt = requireNonEmpty(opts.prompt, "--prompt must not be empty.");
2280
2502
  const outPath = resolve(requireNonEmpty(opts.out, "--out must not be empty."));
2503
+ requireSupportedExtension(outPath);
2281
2504
  if (opts.outputFormat !== undefined) {
2282
2505
  requireFormatMatchesExtension(outPath, opts.outputFormat);
2283
2506
  }
2507
+ const inputImage = resolveInputImageOption(opts);
2508
+ requireModelPairing(model, inputImage, opts.aspectRatio);
2509
+ validateInputOption(opts);
2510
+ const inputTarget = await validateInputImage(deps, inputImage);
2284
2511
  const manifestPath = `${outPath}.json`;
2285
2512
  await requireWritableOutput(deps, outPath, manifestPath, opts.force === true);
2286
- await deps.ensureParentDir(outPath);
2287
- const model = opts.model ?? DEFAULT_IMAGE_MODEL;
2288
- const input = buildInput(prompt, opts);
2513
+ const input = buildInput(prompt, opts, planInputImageUrl(inputTarget));
2514
+ return {
2515
+ platform,
2516
+ model,
2517
+ outPath,
2518
+ manifestPath,
2519
+ input,
2520
+ inputTarget,
2521
+ disclosures: describeConstraints(model, input, { aspectRatio: opts.aspectRatio })
2522
+ };
2523
+ }
2524
+ function disclosureFlag(key) {
2525
+ return key === "aspect_ratio" ? "--aspect-ratio" : "--input";
2526
+ }
2527
+ function formatDisclosure(disclosure) {
2528
+ if (disclosure.kind === "unsupported" || disclosure.kind === "unknown") {
2529
+ return `- ${disclosure.kind}: ${disclosure.key} (${disclosureFlag(disclosure.key)}) — ${disclosure.message}`;
2530
+ }
2531
+ return `- ${disclosure.kind}: ${disclosure.message}`;
2532
+ }
2533
+ function formatInputImageLine(target) {
2534
+ if (target === undefined)
2535
+ return;
2536
+ return target.kind === "url" ? `Input image ${target.url} (passed through)` : `Input image ${target.path} (would be uploaded to fal storage, 1-day lifetime)`;
2537
+ }
2538
+ function formatGenerateImagePlan(plan) {
2539
+ const capability = getModelCapability(plan.model);
2540
+ const lines = [
2541
+ `Would generate ${plan.outPath}`,
2542
+ `Manifest ${plan.manifestPath}`,
2543
+ capability === undefined ? `Model ${plan.model} (no capability data)` : `Model ${plan.model} (${capability.name}, ${capability.task})`
2544
+ ];
2545
+ const inputLine = formatInputImageLine(plan.inputTarget);
2546
+ if (inputLine !== undefined)
2547
+ lines.push(inputLine);
2548
+ lines.push("Request:", JSON.stringify(plan.input, null, 2), "Constraints:");
2549
+ for (const disclosure of plan.disclosures)
2550
+ lines.push(formatDisclosure(disclosure));
2551
+ lines.push("No upload or fal call was made.");
2552
+ return lines.join(`
2553
+ `);
2554
+ }
2555
+ async function generateAndSave(deps, model, input, outPath) {
2289
2556
  const result = await deps.falSubscribe(model, input);
2290
2557
  if (result.data.images.length > 1) {
2291
2558
  deps.warn(`⚠️ fal returned ${result.data.images.length} images; only the first is saved.`);
@@ -2293,25 +2560,46 @@ async function generateImage(opts, deps) {
2293
2560
  const image = requireImage(result.data.images, model);
2294
2561
  const bytes = await downloadImage(deps, result.requestId, image.url);
2295
2562
  await saveImage(deps, outPath, bytes, result.requestId, image.url);
2296
- const sha256 = createHash("sha256").update(bytes).digest("hex");
2297
- await deps.writeJson(manifestPath, buildManifest({
2298
- platform,
2299
- model,
2300
- input,
2563
+ return {
2564
+ image,
2565
+ bytes,
2566
+ sha256: createHash("sha256").update(bytes).digest("hex"),
2301
2567
  requestId: result.requestId,
2302
- resultSeed: result.data.seed,
2568
+ seed: result.data.seed
2569
+ };
2570
+ }
2571
+ async function generateImage(opts, deps) {
2572
+ requireFalKey(deps);
2573
+ const plan = await planGenerateImage(opts, deps);
2574
+ for (const disclosure of plan.disclosures) {
2575
+ if (disclosure.kind === "unsupported") {
2576
+ deps.warn(`⚠️ ${disclosure.key}: ${disclosure.message}`);
2577
+ }
2578
+ }
2579
+ await deps.ensureParentDir(plan.outPath);
2580
+ const preparedInput = await uploadInputImage(deps, plan.inputTarget);
2581
+ const input = preparedInput.url === undefined ? plan.input : { ...plan.input, image_urls: [preparedInput.url] };
2582
+ const saved = await generateAndSave(deps, plan.model, input, plan.outPath);
2583
+ await deps.writeJson(plan.manifestPath, buildManifest({
2584
+ platform: plan.platform,
2585
+ model: plan.model,
2586
+ input,
2587
+ inputImage: preparedInput.record,
2588
+ requestId: saved.requestId,
2589
+ resultSeed: saved.seed,
2303
2590
  requestedSeed: opts.seed,
2304
- outPath,
2305
- sha256,
2306
- contentType: image.content_type,
2307
- byteLength: bytes.byteLength,
2591
+ outPath: plan.outPath,
2592
+ sha256: saved.sha256,
2593
+ contentType: saved.image.content_type,
2594
+ byteLength: saved.bytes.byteLength,
2308
2595
  generatedAt: deps.now().toISOString(),
2309
2596
  sdkVersion: deps.sdkVersion
2310
2597
  }));
2311
- return { outPath, manifestPath, sha256 };
2598
+ return { outPath: plan.outPath, manifestPath: plan.manifestPath, sha256: saved.sha256 };
2312
2599
  }
2313
- var DEFAULT_IMAGE_MODEL = "fal-ai/flux-2/flash", GENERATE_IMAGE_PLATFORMS, DEFAULT_GENERATE_IMAGE_PLATFORM = "fal", GenerateImageError, LICENSING = "unverified", FAL_API_KEY_MISSING_MESSAGE = "FAL_API_KEY is not set. Set FAL_API_KEY in your environment to generate images with fal. (FAL_KEY_ID/FAL_KEY_SECRET are not supported by this command.)", EXTENSION_FORMATS, INPUT_DEDICATED_FLAGS;
2600
+ var GENERATE_IMAGE_PLATFORMS, DEFAULT_GENERATE_IMAGE_PLATFORM = "fal", GenerateImageError, LICENSING = "unverified", FAL_API_KEY_MISSING_MESSAGE = "FAL_API_KEY is not set. Set FAL_API_KEY in your environment to generate images with fal. (FAL_KEY_ID/FAL_KEY_SECRET are not supported by this command.)", EXTENSION_FORMATS, UNSUPPORTED_OUTPUT_EXTENSIONS, INPUT_DEDICATED_FLAGS, INPUT_IMAGE_CONTENT_TYPES, HTTP_URL_PATTERN;
2314
2601
  var init_image = __esm(() => {
2602
+ init_model_capabilities();
2315
2603
  GENERATE_IMAGE_PLATFORMS = ["fal"];
2316
2604
  GenerateImageError = class GenerateImageError extends Error {
2317
2605
  constructor(message) {
@@ -2321,16 +2609,103 @@ var init_image = __esm(() => {
2321
2609
  };
2322
2610
  EXTENSION_FORMATS = {
2323
2611
  ".png": "png",
2324
- ".jpg": "jpeg",
2325
- ".jpeg": "jpeg",
2326
2612
  ".webp": "webp"
2327
2613
  };
2614
+ UNSUPPORTED_OUTPUT_EXTENSIONS = new Set([".jpg", ".jpeg"]);
2328
2615
  INPUT_DEDICATED_FLAGS = {
2329
2616
  prompt: "--prompt",
2330
2617
  seed: "--seed",
2331
2618
  output_format: "--output-format",
2332
- aspect_ratio: "--aspect-ratio"
2619
+ aspect_ratio: "--aspect-ratio",
2620
+ image_urls: "--input-image"
2333
2621
  };
2622
+ INPUT_IMAGE_CONTENT_TYPES = {
2623
+ ".png": "image/png",
2624
+ ".jpg": "image/jpeg",
2625
+ ".jpeg": "image/jpeg",
2626
+ ".webp": "image/webp",
2627
+ ".gif": "image/gif"
2628
+ };
2629
+ HTTP_URL_PATTERN = /^https?:\/\//i;
2630
+ });
2631
+
2632
+ // src/commands/generate/local-image-common.ts
2633
+ import { createHash as createHash2 } from "node:crypto";
2634
+ function isRecord(value) {
2635
+ return typeof value === "object" && value !== null;
2636
+ }
2637
+ function sha256(bytes) {
2638
+ return createHash2("sha256").update(bytes).digest("hex");
2639
+ }
2640
+ function errorMessage(err) {
2641
+ return err instanceof Error ? err.message : String(err);
2642
+ }
2643
+ function median(values) {
2644
+ const sorted = [...values].sort((a, b) => a - b);
2645
+ const middle = Math.floor(sorted.length / 2);
2646
+ if (sorted.length % 2 === 1)
2647
+ return sorted[middle] ?? 0;
2648
+ return Math.round(((sorted[middle - 1] ?? 0) + (sorted[middle] ?? 0)) / 2);
2649
+ }
2650
+ function hasPngMagic(bytes) {
2651
+ if (bytes.length < PNG_MAGIC.length)
2652
+ return false;
2653
+ return PNG_MAGIC.every((byte, index) => bytes[index] === byte);
2654
+ }
2655
+ function readPngDimensions(bytes) {
2656
+ if (bytes.length < 24)
2657
+ return null;
2658
+ if (bytes[12] !== 73 || bytes[13] !== 72 || bytes[14] !== 68 || bytes[15] !== 82) {
2659
+ return null;
2660
+ }
2661
+ const view = new DataView(bytes.buffer, bytes.byteOffset, bytes.byteLength);
2662
+ return { width: view.getUint32(16), height: view.getUint32(20) };
2663
+ }
2664
+ function formatConflicts(conflicts) {
2665
+ const shown = conflicts.slice(0, 10);
2666
+ const lines = shown.map((conflict) => `- ${conflict.path}: ${conflict.reason}`);
2667
+ if (conflicts.length > shown.length) {
2668
+ lines.push(`- and ${conflicts.length - shown.length} more`);
2669
+ }
2670
+ return `Refusing to write ${conflicts.length} output file(s):
2671
+ ${lines.join(`
2672
+ `)}
2673
+ Pass --force to overwrite.`;
2674
+ }
2675
+ async function findOutputConflicts(deps, paths, sourcePaths, sourceIdentities, force) {
2676
+ const matchesSourceIdentity = (identity) => sourceIdentities.some((source) => source !== null && source.dev === identity.dev && source.ino === identity.ino);
2677
+ const conflicts = [];
2678
+ for (const path of paths) {
2679
+ if (sourcePaths.has(path)) {
2680
+ conflicts.push({ path, reason: "this is the source sheet or its manifest" });
2681
+ continue;
2682
+ }
2683
+ if (await deps.isSymlink(path)) {
2684
+ conflicts.push({ path, reason: "this is a symbolic link" });
2685
+ continue;
2686
+ }
2687
+ const status = await deps.pathStatus(path);
2688
+ if (status === "directory") {
2689
+ conflicts.push({ path, reason: "a directory is in the way" });
2690
+ continue;
2691
+ }
2692
+ const identity = await deps.fileIdentity(path);
2693
+ if (identity !== null && matchesSourceIdentity(identity)) {
2694
+ conflicts.push({ path, reason: "this resolves to the source sheet or its manifest" });
2695
+ continue;
2696
+ }
2697
+ if (status === "file" && !force) {
2698
+ conflicts.push({ path, reason: "already exists" });
2699
+ }
2700
+ }
2701
+ return conflicts;
2702
+ }
2703
+ var SAFE_NAME, MAX_SOURCE_PIXELS = 1e8, MAX_SOURCE_BYTES, MAX_SIDECAR_BYTES, PNG_MAGIC;
2704
+ var init_local_image_common = __esm(() => {
2705
+ SAFE_NAME = /^[A-Za-z0-9_][A-Za-z0-9_-]{0,63}$/;
2706
+ MAX_SOURCE_BYTES = 64 * 1024 * 1024;
2707
+ MAX_SIDECAR_BYTES = 1024 * 1024;
2708
+ PNG_MAGIC = new Uint8Array([137, 80, 78, 71, 13, 10, 26, 10]);
2334
2709
  });
2335
2710
 
2336
2711
  // ../../node_modules/.pnpm/@fal-ai+client@1.10.1/node_modules/@fal-ai/client/src/middleware.js
@@ -2590,7 +2965,7 @@ var require_utils = __commonJS((exports) => {
2590
2965
  exports.isValidUrl = isValidUrl;
2591
2966
  exports.throttle = throttle;
2592
2967
  exports.isReact = isReact;
2593
- exports.isPlainObject = isPlainObject;
2968
+ exports.isPlainObject = isPlainObject2;
2594
2969
  exports.sleep = sleep;
2595
2970
  function ensureEndpointIdFormat(id) {
2596
2971
  const parts = id.split("/");
@@ -2666,7 +3041,7 @@ var require_utils = __commonJS((exports) => {
2666
3041
  }
2667
3042
  return isRunningInReact;
2668
3043
  }
2669
- function isPlainObject(value) {
3044
+ function isPlainObject2(value) {
2670
3045
  return !!value && Object.getPrototypeOf(value) === Object.prototype;
2671
3046
  }
2672
3047
  function sleep(ms) {
@@ -6413,9 +6788,11 @@ var init_package_version = () => {};
6413
6788
  // src/commands/generate/deps.ts
6414
6789
  var exports_deps = {};
6415
6790
  __export(exports_deps, {
6791
+ fetchBytes: () => fetchBytes,
6792
+ createFalRawSubscribe: () => createFalRawSubscribe,
6416
6793
  createDefaultGenerateImageDeps: () => createDefaultGenerateImageDeps
6417
6794
  });
6418
- import { mkdir } from "node:fs/promises";
6795
+ import { mkdir, readFile } from "node:fs/promises";
6419
6796
  import { dirname as dirname2 } from "node:path";
6420
6797
  function isRecord2(value) {
6421
6798
  return typeof value === "object" && value !== null;
@@ -6518,16 +6895,18 @@ function describeFalError(err) {
6518
6895
  return formatApiError(err);
6519
6896
  return err instanceof Error ? err.message : String(err);
6520
6897
  }
6521
- function createFalSubscribe(env) {
6898
+ function configureFal(env) {
6899
+ const credentials = env.FAL_API_KEY;
6900
+ if (!credentials) {
6901
+ throw new GenerateImageError(FAL_API_KEY_MISSING_MESSAGE);
6902
+ }
6903
+ import_client.fal.config({ credentials });
6904
+ }
6905
+ function createFalRawSubscribe(env) {
6522
6906
  return async (model, input) => {
6523
- const credentials = env.FAL_API_KEY;
6524
- if (!credentials) {
6525
- throw new GenerateImageError(FAL_API_KEY_MISSING_MESSAGE);
6526
- }
6527
- import_client.fal.config({ credentials });
6528
- let raw;
6907
+ configureFal(env);
6529
6908
  try {
6530
- raw = await import_client.fal.subscribe(model, {
6909
+ return await import_client.fal.subscribe(model, {
6531
6910
  input,
6532
6911
  logs: false,
6533
6912
  startTimeout: SUBSCRIBE_TIMEOUT_SECONDS
@@ -6535,7 +6914,22 @@ function createFalSubscribe(env) {
6535
6914
  } catch (err) {
6536
6915
  throw new GenerateImageError(describeFalError(err));
6537
6916
  }
6538
- return validateFalResult(raw);
6917
+ };
6918
+ }
6919
+ function createFalSubscribe(env) {
6920
+ const subscribe = createFalRawSubscribe(env);
6921
+ return async (model, input) => validateFalResult(await subscribe(model, input));
6922
+ }
6923
+ function createFalUploadFile(env) {
6924
+ return async (path, contentType) => {
6925
+ configureFal(env);
6926
+ try {
6927
+ const bytes = await readFile(path);
6928
+ const blob = new Blob([new Uint8Array(bytes)], { type: contentType });
6929
+ return await import_client.fal.storage.upload(blob, { lifecycle: { expiresIn: "1d" } });
6930
+ } catch (err) {
6931
+ throw new GenerateImageError(`Failed to upload input image ${path}: ${describeFalError(err)}`);
6932
+ }
6539
6933
  };
6540
6934
  }
6541
6935
  async function ensureParentDir(path) {
@@ -6560,6 +6954,7 @@ function createDefaultGenerateImageDeps() {
6560
6954
  return {
6561
6955
  env,
6562
6956
  falSubscribe: createFalSubscribe(env),
6957
+ uploadFile: createFalUploadFile(env),
6563
6958
  fetchBytes,
6564
6959
  writeFile: writeFileBytes,
6565
6960
  writeJson: writeJsonFile,
@@ -8470,7 +8865,7 @@ var exports_slice_deps = {};
8470
8865
  __export(exports_slice_deps, {
8471
8866
  createDefaultSliceImageDeps: () => createDefaultSliceImageDeps
8472
8867
  });
8473
- import { lstat, mkdir as mkdir2, readFile as readFile2, stat as stat3 } from "node:fs/promises";
8868
+ import { lstat, mkdir as mkdir2, readFile as readFile3, stat as stat3 } from "node:fs/promises";
8474
8869
  function decodePng(bytes) {
8475
8870
  const png = PNG.sync.read(Buffer.from(bytes));
8476
8871
  return { width: png.width, height: png.height, data: png.data };
@@ -8500,7 +8895,7 @@ async function statInput(path) {
8500
8895
  async function readJsonIfExists(path) {
8501
8896
  let text;
8502
8897
  try {
8503
- text = await readFile2(path, "utf8");
8898
+ text = await readFile3(path, "utf8");
8504
8899
  } catch (err) {
8505
8900
  if (err.code === "ENOENT") {
8506
8901
  return;
@@ -8537,7 +8932,7 @@ function createDefaultSliceImageDeps() {
8537
8932
  return {
8538
8933
  pathStatus,
8539
8934
  statInput,
8540
- readFile: readFile2,
8935
+ readFile: readFile3,
8541
8936
  readJsonIfExists,
8542
8937
  decodePng,
8543
8938
  encodePng,
@@ -8574,15 +8969,254 @@ var init_remove_background_deps = __esm(() => {
8574
8969
  init_slice_deps();
8575
8970
  });
8576
8971
 
8972
+ // src/commands/generate/remove-background-fal.ts
8973
+ import { basename as basename2, resolve as resolve3 } from "node:path";
8974
+ function validateBackgroundResult(raw, model) {
8975
+ const unexpected = new RemoveBackgroundFalError(`fal returned no image for ${model}`);
8976
+ if (!isRecord(raw))
8977
+ throw unexpected;
8978
+ const { requestId, data } = raw;
8979
+ if (typeof requestId !== "string" || requestId.length === 0)
8980
+ throw unexpected;
8981
+ if (!isRecord(data) || !isRecord(data.image))
8982
+ throw unexpected;
8983
+ const { url } = data.image;
8984
+ if (typeof url !== "string" || !url.startsWith("https://"))
8985
+ throw unexpected;
8986
+ return { requestId, data: { image: { url } } };
8987
+ }
8988
+ async function requireSource(path, deps) {
8989
+ const stats = await deps.statInput(path);
8990
+ if (stats.kind === "missing")
8991
+ throw new RemoveBackgroundFalError(`Input not found: ${path}`);
8992
+ if (stats.kind === "directory") {
8993
+ throw new RemoveBackgroundFalError(`Input is a directory: ${path}. Pass a PNG file path.`);
8994
+ }
8995
+ if (stats.kind !== "file") {
8996
+ throw new RemoveBackgroundFalError(`Input is not a regular file: ${path}.`);
8997
+ }
8998
+ if (stats.size > MAX_FAL_INPUT_BYTES) {
8999
+ throw new RemoveBackgroundFalError(`${path} is ${stats.size} bytes; the maximum fal input is ${MAX_FAL_INPUT_BYTES} bytes (8 MiB).`);
9000
+ }
9001
+ const bytes = await deps.readInput(path);
9002
+ if (bytes.byteLength > MAX_FAL_INPUT_BYTES) {
9003
+ throw new RemoveBackgroundFalError(`${path} is ${bytes.byteLength} bytes; the maximum fal input is ${MAX_FAL_INPUT_BYTES} bytes (8 MiB).`);
9004
+ }
9005
+ if (!hasPngMagic(bytes))
9006
+ throw new RemoveBackgroundFalError(`${path} is not a PNG.`);
9007
+ const dimensions = readPngDimensions(bytes);
9008
+ if (dimensions === null || dimensions.width === 0 || dimensions.height === 0) {
9009
+ throw new RemoveBackgroundFalError(`Could not decode ${path}: missing or invalid IHDR.`);
9010
+ }
9011
+ if (dimensions.width * dimensions.height > MAX_SOURCE_PIXELS) {
9012
+ throw new RemoveBackgroundFalError(`${path} is ${dimensions.width}x${dimensions.height}; the maximum is ${MAX_SOURCE_PIXELS} pixels.`);
9013
+ }
9014
+ return { bytes, width: dimensions.width, height: dimensions.height };
9015
+ }
9016
+ function requireMatchingDimensions(args) {
9017
+ const result = readPngDimensions(args.bytes);
9018
+ const recovery = `The result can still be recovered from that URL.`;
9019
+ const hint = `Re-run with --engine birefnet, or resize the sheet so the engine accepts it.`;
9020
+ if (result === null) {
9021
+ throw new RemoveBackgroundFalError(`Failed to use image for request ${args.requestId} (${args.imageUrl}): could not read the result PNG dimensions; the input is ${args.input.width}x${args.input.height} and ${args.outPath} was not written. ${hint} ${recovery}`);
9022
+ }
9023
+ if (result.width !== args.input.width || result.height !== args.input.height) {
9024
+ throw new RemoveBackgroundFalError(`Failed to use image for request ${args.requestId} (${args.imageUrl}): result is ${result.width}x${result.height}, but the input is ${args.input.width}x${args.input.height}; ${args.outPath} was not written. ${hint} ${recovery}`);
9025
+ }
9026
+ return result;
9027
+ }
9028
+ async function requireWritablePath2(path, label, force, deps) {
9029
+ const status = await deps.pathStatus(path);
9030
+ if (status === "directory") {
9031
+ throw new RemoveBackgroundFalError(`${label} is a directory: ${path}. Pass a file path.`);
9032
+ }
9033
+ if (status === "file" && !force) {
9034
+ throw new RemoveBackgroundFalError(`${label} already exists: ${path}. Pass --force to overwrite.`);
9035
+ }
9036
+ }
9037
+ async function requireWritableOutputs(outPath, manifestPath, force, deps) {
9038
+ await requireWritablePath2(outPath, "--out", force, deps);
9039
+ await requireWritablePath2(manifestPath, "Manifest", force, deps);
9040
+ }
9041
+ function manifestSaveMessage(err, requestId, outPath, manifestPath) {
9042
+ const detail = err instanceof Error ? err.message : String(err);
9043
+ return `Failed to save manifest ${manifestPath} for request ${requestId} (output ${outPath}): ${detail}. The image was written but its manifest is missing.`;
9044
+ }
9045
+ function recoveryMessage2(action, err, requestId, url) {
9046
+ const detail = err instanceof Error ? err.message : String(err);
9047
+ return `Failed to ${action} image for request ${requestId} (${url}): ${detail}. The result can still be recovered from that URL.`;
9048
+ }
9049
+ async function removeBackgroundFal(options, deps) {
9050
+ if (!deps.env.FAL_API_KEY) {
9051
+ throw new RemoveBackgroundFalError(FAL_API_KEY_MISSING_MESSAGE);
9052
+ }
9053
+ const engine = options.engine ?? DEFAULT_BACKGROUND_ENGINE;
9054
+ const spec = BACKGROUND_ENGINES[engine];
9055
+ const inPath = resolve3(options.in);
9056
+ const outPath = resolve3(options.out);
9057
+ const manifestPath = `${outPath}.json`;
9058
+ if (inPath === outPath) {
9059
+ throw new RemoveBackgroundFalError(`--in and --out are the same file: ${inPath}. Choose a different output path.`);
9060
+ }
9061
+ const source = await requireSource(inPath, deps);
9062
+ await requireWritableOutputs(outPath, manifestPath, options.force === true, deps);
9063
+ const dataUri = `data:image/png;base64,${Buffer.from(source.bytes).toString("base64")}`;
9064
+ const raw = await deps.falSubscribe(spec.model, spec.buildInput(dataUri));
9065
+ const result = validateBackgroundResult(raw, spec.model);
9066
+ const imageUrl = result.data.image.url;
9067
+ let bytes;
9068
+ try {
9069
+ bytes = await deps.fetchBytes(imageUrl);
9070
+ } catch (err) {
9071
+ throw new RemoveBackgroundFalError(recoveryMessage2("download", err, result.requestId, imageUrl));
9072
+ }
9073
+ if (bytes.byteLength > MAX_FAL_RESULT_BYTES) {
9074
+ throw new RemoveBackgroundFalError(`Downloaded image is ${bytes.byteLength} bytes; the maximum is ${MAX_FAL_RESULT_BYTES} bytes (32 MiB).`);
9075
+ }
9076
+ if (!hasPngMagic(bytes)) {
9077
+ throw new RemoveBackgroundFalError(`Downloaded file is not a PNG (request ${result.requestId}, ${imageUrl}).`);
9078
+ }
9079
+ const outputDimensions = requireMatchingDimensions({
9080
+ bytes,
9081
+ input: source,
9082
+ requestId: result.requestId,
9083
+ imageUrl,
9084
+ outPath
9085
+ });
9086
+ const outputSha256 = sha256(bytes);
9087
+ const manifest = {
9088
+ platform: "fal",
9089
+ tool: TOOL2,
9090
+ sdk: `@fal-ai/client@${deps.sdkVersion}`,
9091
+ engine,
9092
+ model: spec.model,
9093
+ input: {
9094
+ ...engine === "birefnet" ? { mode: "Matting", output_format: "png" } : {},
9095
+ source: basename2(inPath),
9096
+ sourceBytes: source.bytes.byteLength,
9097
+ sourceSha256: sha256(source.bytes),
9098
+ width: source.width,
9099
+ height: source.height
9100
+ },
9101
+ requestId: result.requestId,
9102
+ output: {
9103
+ path: outPath,
9104
+ sha256: outputSha256,
9105
+ bytes: bytes.byteLength,
9106
+ contentType: "image/png",
9107
+ width: outputDimensions.width,
9108
+ height: outputDimensions.height
9109
+ },
9110
+ generatedAt: deps.now().toISOString(),
9111
+ licensing: LICENSING2
9112
+ };
9113
+ try {
9114
+ await deps.ensureParentDir(outPath);
9115
+ await deps.writeFile(outPath, bytes);
9116
+ } catch (err) {
9117
+ throw new RemoveBackgroundFalError(recoveryMessage2("save", err, result.requestId, imageUrl));
9118
+ }
9119
+ try {
9120
+ await deps.writeJson(manifestPath, manifest);
9121
+ } catch (err) {
9122
+ throw new RemoveBackgroundFalError(manifestSaveMessage(err, result.requestId, outPath, manifestPath));
9123
+ }
9124
+ return {
9125
+ outPath,
9126
+ manifestPath,
9127
+ requestId: result.requestId,
9128
+ bytes: bytes.byteLength,
9129
+ sha256: outputSha256
9130
+ };
9131
+ }
9132
+ var DEFAULT_BACKGROUND_ENGINE = "bria", BACKGROUND_ENGINES, MAX_FAL_INPUT_BYTES, MAX_FAL_RESULT_BYTES, TOOL2 = "chatroom remove-image-background-fal", LICENSING2 = "unverified", RemoveBackgroundFalError;
9133
+ var init_remove_background_fal = __esm(() => {
9134
+ init_image();
9135
+ init_local_image_common();
9136
+ BACKGROUND_ENGINES = {
9137
+ bria: {
9138
+ model: "fal-ai/bria/background/remove",
9139
+ buildInput: (image_url) => ({ image_url })
9140
+ },
9141
+ birefnet: {
9142
+ model: "fal-ai/birefnet/v2",
9143
+ buildInput: (image_url) => ({ image_url, model: "Matting", output_format: "png" })
9144
+ }
9145
+ };
9146
+ MAX_FAL_INPUT_BYTES = 8 * 1024 * 1024;
9147
+ MAX_FAL_RESULT_BYTES = 32 * 1024 * 1024;
9148
+ RemoveBackgroundFalError = class RemoveBackgroundFalError extends Error {
9149
+ constructor(message) {
9150
+ super(message);
9151
+ this.name = "RemoveBackgroundFalError";
9152
+ }
9153
+ };
9154
+ });
9155
+
9156
+ // src/commands/generate/remove-background-fal-deps.ts
9157
+ var exports_remove_background_fal_deps = {};
9158
+ __export(exports_remove_background_fal_deps, {
9159
+ createDefaultRemoveBackgroundFalDeps: () => createDefaultRemoveBackgroundFalDeps
9160
+ });
9161
+ import { dirname as dirname4 } from "node:path";
9162
+ function mebibytes(bytes) {
9163
+ return Math.round(bytes / (1024 * 1024));
9164
+ }
9165
+ function requireDeclaredSize(declared, maxBytes) {
9166
+ if (declared === null)
9167
+ return;
9168
+ const size = Number(declared);
9169
+ if (!Number.isFinite(size) || size <= maxBytes)
9170
+ return;
9171
+ throw new Error(`Downloaded image is ${size} bytes; the maximum is ${maxBytes} bytes (${mebibytes(maxBytes)} MiB).`);
9172
+ }
9173
+ function requireImageContentType2(response) {
9174
+ const contentType = response.headers.get("content-type") ?? "";
9175
+ if (contentType.toLowerCase().startsWith("image/"))
9176
+ return;
9177
+ throw new Error(`Downloaded file is not an image (HTTP ${response.status}, content-type: ${contentType || "missing"})`);
9178
+ }
9179
+ async function fetchCappedBytes(url, maxBytes) {
9180
+ const response = await fetch(url);
9181
+ if (!response.ok) {
9182
+ throw new Error(`Failed to download image (HTTP ${response.status} ${response.statusText})`);
9183
+ }
9184
+ requireDeclaredSize(response.headers.get("content-length"), maxBytes);
9185
+ requireImageContentType2(response);
9186
+ return new Uint8Array(await response.arrayBuffer());
9187
+ }
9188
+ function createDefaultRemoveBackgroundFalDeps() {
9189
+ const slice = createDefaultSliceImageDeps();
9190
+ return {
9191
+ env: process.env,
9192
+ falSubscribe: createFalRawSubscribe(process.env),
9193
+ fetchBytes: (url) => fetchCappedBytes(url, MAX_FAL_RESULT_BYTES),
9194
+ readInput: slice.readFile,
9195
+ statInput: slice.statInput,
9196
+ pathStatus: slice.pathStatus,
9197
+ writeFile: slice.writeFile,
9198
+ writeJson: slice.writeJson,
9199
+ ensureParentDir: (path) => slice.ensureDir(dirname4(path)),
9200
+ now: () => new Date,
9201
+ sdkVersion: readInstalledPackageVersion("@fal-ai/client")
9202
+ };
9203
+ }
9204
+ var init_remove_background_fal_deps = __esm(() => {
9205
+ init_deps();
9206
+ init_package_version();
9207
+ init_remove_background_fal();
9208
+ init_slice_deps();
9209
+ });
9210
+
8577
9211
  // src/utils/file-content.ts
8578
9212
  var exports_file_content = {};
8579
9213
  __export(exports_file_content, {
8580
9214
  readFileContent: () => readFileContent
8581
9215
  });
8582
9216
  import { readFileSync as readFileSync2 } from "node:fs";
8583
- import { resolve as resolve4 } from "node:path";
9217
+ import { resolve as resolve5 } from "node:path";
8584
9218
  function readFileContent(filePath, optionName) {
8585
- const absolutePath = resolve4(process.cwd(), filePath);
9219
+ const absolutePath = resolve5(process.cwd(), filePath);
8586
9220
  try {
8587
9221
  return readFileSync2(absolutePath, "utf-8");
8588
9222
  } catch (err) {
@@ -8663,12 +9297,12 @@ var init_stdin_heredoc = __esm(() => {
8663
9297
 
8664
9298
  // src/version.ts
8665
9299
  import { readFileSync as readFileSync3 } from "node:fs";
8666
- import { dirname as dirname4, join as join4 } from "node:path";
9300
+ import { dirname as dirname5, join as join4 } from "node:path";
8667
9301
  import { fileURLToPath } from "node:url";
8668
9302
  function getVersion() {
8669
9303
  try {
8670
9304
  const __filename2 = fileURLToPath(import.meta.url);
8671
- const __dirname2 = dirname4(__filename2);
9305
+ const __dirname2 = dirname5(__filename2);
8672
9306
  const possiblePaths = [
8673
9307
  join4(__dirname2, "..", "package.json"),
8674
9308
  join4(__dirname2, "..", "..", "package.json")
@@ -10094,11 +10728,11 @@ class RequestManager {
10094
10728
  this.requestsOlderThanRestart = /* @__PURE__ */ new Set;
10095
10729
  }
10096
10730
  request(message, sent) {
10097
- const result = new Promise((resolve5) => {
10731
+ const result = new Promise((resolve6) => {
10098
10732
  const status = sent ? "Requested" : "NotSent";
10099
10733
  this.inflightRequests.set(message.requestId, {
10100
10734
  message,
10101
- status: { status, requestedAt: /* @__PURE__ */ new Date, onResult: resolve5 }
10735
+ status: { status, requestedAt: /* @__PURE__ */ new Date, onResult: resolve6 }
10102
10736
  });
10103
10737
  if (message.type === "Mutation") {
10104
10738
  this.inflightMutationsCount++;
@@ -12603,10 +13237,10 @@ class ConvexClient {
12603
13237
  const value = this.client.localQueryResult(getFunctionName(query), args);
12604
13238
  if (value !== undefined)
12605
13239
  return Promise.resolve(value);
12606
- return new Promise((resolve5, reject) => {
13240
+ return new Promise((resolve6, reject) => {
12607
13241
  const { unsubscribe } = this.onUpdate(query, args, (value2) => {
12608
13242
  unsubscribe();
12609
- resolve5(value2);
13243
+ resolve6(value2);
12610
13244
  }, (e) => {
12611
13245
  unsubscribe();
12612
13246
  reject(e);
@@ -12716,10 +13350,10 @@ var init_simple_client_node = __esm(() => {
12716
13350
  if (debug)
12717
13351
  return debug;
12718
13352
  }
12719
- var prebuild = resolve5(dir);
13353
+ var prebuild = resolve6(dir);
12720
13354
  if (prebuild)
12721
13355
  return prebuild;
12722
- var nearby = resolve5(path.dirname(process.execPath));
13356
+ var nearby = resolve6(path.dirname(process.execPath));
12723
13357
  if (nearby)
12724
13358
  return nearby;
12725
13359
  var target = [
@@ -12737,7 +13371,7 @@ var init_simple_client_node = __esm(() => {
12737
13371
  throw new Error("No native build was found for " + target + `
12738
13372
  loaded from: ` + dir + `
12739
13373
  `);
12740
- function resolve5(dir2) {
13374
+ function resolve6(dir2) {
12741
13375
  var tuples = readdirSync(path.join(dir2, "prebuilds")).map(parseTuple);
12742
13376
  var tuple = tuples.filter(matchTuple(platform, arch)).sort(compareTuples)[0];
12743
13377
  if (!tuple)
@@ -15962,10 +16596,10 @@ class ConvexHttpClient {
15962
16596
  }
15963
16597
  this.isProcessingQueue = true;
15964
16598
  while (this.mutationQueue.length > 0) {
15965
- const { mutation, args, resolve: resolve5, reject } = this.mutationQueue.shift();
16599
+ const { mutation, args, resolve: resolve6, reject } = this.mutationQueue.shift();
15966
16600
  try {
15967
16601
  const result = await this.mutationInner(mutation, args);
15968
- resolve5(result);
16602
+ resolve6(result);
15969
16603
  } catch (error) {
15970
16604
  reject(error);
15971
16605
  }
@@ -15973,8 +16607,8 @@ class ConvexHttpClient {
15973
16607
  this.isProcessingQueue = false;
15974
16608
  }
15975
16609
  enqueueMutation(mutation, args) {
15976
- return new Promise((resolve5, reject) => {
15977
- this.mutationQueue.push({ mutation, args, resolve: resolve5, reject });
16610
+ return new Promise((resolve6, reject) => {
16611
+ this.mutationQueue.push({ mutation, args, resolve: resolve6, reject });
15978
16612
  this.processMutationQueue();
15979
16613
  });
15980
16614
  }
@@ -16606,7 +17240,7 @@ async function retryValidation(sessionId, convexUrl, retryIntervalMs) {
16606
17240
  } else {
16607
17241
  console.log(`❌ Backend still unreachable (attempt ${consecutiveNetworkFailures}, retrying in ${retrySec}s)`);
16608
17242
  }
16609
- await new Promise((resolve5) => setTimeout(resolve5, retryIntervalMs));
17243
+ await new Promise((resolve6) => setTimeout(resolve6, retryIntervalMs));
16610
17244
  }
16611
17245
  }
16612
17246
  }
@@ -20369,8 +21003,8 @@ ${prefix}}`;
20369
21003
  const runFork2 = runForkWith(context2);
20370
21004
  return (effect, options) => {
20371
21005
  const fiber2 = runFork2(effect, options);
20372
- return new Promise((resolve5) => {
20373
- fiber2.addObserver((exit2) => resolve5(exit2));
21006
+ return new Promise((resolve6) => {
21007
+ fiber2.addObserver((exit2) => resolve6(exit2));
20374
21008
  });
20375
21009
  };
20376
21010
  }, runPromiseExit, runPromiseWith = (context2) => {
@@ -25261,7 +25895,7 @@ var init_clock = __esm(() => {
25261
25895
  };
25262
25896
  ClockServiceLive = exports_Layer.succeed(ClockService, {
25263
25897
  now: () => exports_Effect.sync(() => Date.now()),
25264
- delay: (ms) => exports_Effect.promise(() => new Promise((resolve5) => setTimeout(resolve5, ms)))
25898
+ delay: (ms) => exports_Effect.promise(() => new Promise((resolve6) => setTimeout(resolve6, ms)))
25265
25899
  });
25266
25900
  });
25267
25901
 
@@ -25368,7 +26002,7 @@ function createDefaultDeps() {
25368
26002
  },
25369
26003
  clock: {
25370
26004
  now: () => Date.now(),
25371
- delay: (ms) => new Promise((resolve5) => setTimeout(resolve5, ms))
26005
+ delay: (ms) => new Promise((resolve6) => setTimeout(resolve6, ms))
25372
26006
  },
25373
26007
  process: {
25374
26008
  env: process.env,
@@ -25933,7 +26567,7 @@ class BaseCLIAgentService {
25933
26567
  } catch {
25934
26568
  return;
25935
26569
  }
25936
- await new Promise((resolve5) => setTimeout(resolve5, POLL_INTERVAL_MS));
26570
+ await new Promise((resolve6) => setTimeout(resolve6, POLL_INTERVAL_MS));
25937
26571
  }
25938
26572
  try {
25939
26573
  this.deps.kill(-pid, "SIGKILL");
@@ -25969,7 +26603,7 @@ class BaseCLIAgentService {
25969
26603
  return buildAgentSpawnEnv(resolvedConvexUrl);
25970
26604
  }
25971
26605
  async assertChildProcessStarted(childProcess) {
25972
- await new Promise((resolve5) => setTimeout(resolve5, SPAWN_READY_DELAY_MS));
26606
+ await new Promise((resolve6) => setTimeout(resolve6, SPAWN_READY_DELAY_MS));
25973
26607
  if (childProcess.killed || childProcess.exitCode !== null) {
25974
26608
  throw new Error(`Agent process exited immediately (exit code: ${childProcess.exitCode})`);
25975
26609
  }
@@ -26411,7 +27045,7 @@ function applyAgentConfigOverrides(input) {
26411
27045
  };
26412
27046
  }
26413
27047
  function waitForSlotChange(execution, input, remainingMs) {
26414
- return new Promise((resolve5, reject) => {
27048
+ return new Promise((resolve6, reject) => {
26415
27049
  let settled = false;
26416
27050
  const finish = (error) => {
26417
27051
  if (settled)
@@ -26425,7 +27059,7 @@ function waitForSlotChange(execution, input, remainingMs) {
26425
27059
  if (error !== undefined)
26426
27060
  reject(error);
26427
27061
  else
26428
- resolve5();
27062
+ resolve6();
26429
27063
  };
26430
27064
  const matches = (event) => event.chatroomId === input.chatroomId && event.role.toLowerCase() === input.role.toLowerCase();
26431
27065
  const onStarted = async (event) => {
@@ -26513,8 +27147,8 @@ function createAgentProcessManagerService(deps) {
26513
27147
  });
26514
27148
  const submit = (commandFactory) => {
26515
27149
  const operationId = randomUUID();
26516
- const completion = new Promise((resolve5, reject) => {
26517
- pendingOperations.set(operationId, { resolve: resolve5, reject });
27150
+ const completion = new Promise((resolve6, reject) => {
27151
+ pendingOperations.set(operationId, { resolve: resolve6, reject });
26518
27152
  });
26519
27153
  const command = commandFactory(operationId);
26520
27154
  const message = commandMessage(command);
@@ -27058,7 +27692,7 @@ __export(exports_util, {
27058
27692
  jsonStringifyReplacer: () => jsonStringifyReplacer,
27059
27693
  joinValues: () => joinValues,
27060
27694
  issue: () => issue,
27061
- isPlainObject: () => isPlainObject,
27695
+ isPlainObject: () => isPlainObject2,
27062
27696
  isObject: () => isObject,
27063
27697
  hexToUint8Array: () => hexToUint8Array,
27064
27698
  getSizableOrigin: () => getSizableOrigin,
@@ -27223,7 +27857,7 @@ function slugify(input) {
27223
27857
  function isObject(data) {
27224
27858
  return typeof data === "object" && data !== null && !Array.isArray(data);
27225
27859
  }
27226
- function isPlainObject(o) {
27860
+ function isPlainObject2(o) {
27227
27861
  if (isObject(o) === false)
27228
27862
  return false;
27229
27863
  const ctor = o.constructor;
@@ -27240,7 +27874,7 @@ function isPlainObject(o) {
27240
27874
  return true;
27241
27875
  }
27242
27876
  function shallowClone(o) {
27243
- if (isPlainObject(o))
27877
+ if (isPlainObject2(o))
27244
27878
  return { ...o };
27245
27879
  if (Array.isArray(o))
27246
27880
  return [...o];
@@ -27380,7 +28014,7 @@ function omit2(schema, mask) {
27380
28014
  return clone(schema, def);
27381
28015
  }
27382
28016
  function extend(schema, shape) {
27383
- if (!isPlainObject(shape)) {
28017
+ if (!isPlainObject2(shape)) {
27384
28018
  throw new Error("Invalid input to extend: expected a plain object");
27385
28019
  }
27386
28020
  const checks = schema._zod.def.checks;
@@ -27403,7 +28037,7 @@ function extend(schema, shape) {
27403
28037
  return clone(schema, def);
27404
28038
  }
27405
28039
  function safeExtend(schema, shape) {
27406
- if (!isPlainObject(shape)) {
28040
+ if (!isPlainObject2(shape)) {
27407
28041
  throw new Error("Invalid input to safeExtend: expected a plain object");
27408
28042
  }
27409
28043
  const def = mergeDefs(schema._zod.def, {
@@ -28886,7 +29520,7 @@ function mergeValues(a, b) {
28886
29520
  if (a instanceof Date && b instanceof Date && +a === +b) {
28887
29521
  return { valid: true, data: a };
28888
29522
  }
28889
- if (isPlainObject(a) && isPlainObject(b)) {
29523
+ if (isPlainObject2(a) && isPlainObject2(b)) {
28890
29524
  const bKeys = Object.keys(b);
28891
29525
  const sharedKeys = Object.keys(a).filter((key) => bKeys.indexOf(key) !== -1);
28892
29526
  const newObj = { ...a, ...b };
@@ -30143,7 +30777,7 @@ var init_schemas = __esm(() => {
30143
30777
  $ZodType.init(inst, def);
30144
30778
  inst._zod.parse = (payload, ctx) => {
30145
30779
  const input = payload.value;
30146
- if (!isPlainObject(input)) {
30780
+ if (!isPlainObject2(input)) {
30147
30781
  payload.issues.push({
30148
30782
  expected: "record",
30149
30783
  code: "invalid_type",
@@ -42954,7 +43588,7 @@ var init_parse_session_augmentation = __esm(() => {
42954
43588
 
42955
43589
  // src/daemon/services/task-service/service/native-cold-session-before-inject.ts
42956
43590
  function sleep3(ms) {
42957
- return new Promise((resolve5) => setTimeout(resolve5, ms));
43591
+ return new Promise((resolve6) => setTimeout(resolve6, ms));
42958
43592
  }
42959
43593
  async function waitForHarnessSessionId(agentMgr, chatroomId, role, signal) {
42960
43594
  const deadline = Date.now() + HARNESS_SESSION_READY_TIMEOUT_MS;
@@ -43485,8 +44119,8 @@ class AgentWorkManager {
43485
44119
  if (existing)
43486
44120
  return existing.drainPromise;
43487
44121
  let resolveCompletion;
43488
- const completion = new Promise((resolve5) => {
43489
- resolveCompletion = resolve5;
44122
+ const completion = new Promise((resolve6) => {
44123
+ resolveCompletion = resolve6;
43490
44124
  });
43491
44125
  getRoleDeliveryState().resetDeliveryState(args2.chatroomId, args2.role);
43492
44126
  const drainPromise = this.nativeTaskDeliveryQueue.invalidateRole(args2.chatroomId, args2.role);
@@ -44478,7 +45112,7 @@ class InMemoryCommandQueueStore {
44478
45112
  // src/daemon/services/agent-process-service/infrastructure/components/command-queue/consumer/command-queue-consumer.ts
44479
45113
  import { randomUUID as randomUUID2 } from "node:crypto";
44480
45114
  function defaultSleep(milliseconds) {
44481
- return new Promise((resolve5) => setTimeout(resolve5, milliseconds));
45115
+ return new Promise((resolve6) => setTimeout(resolve6, milliseconds));
44482
45116
  }
44483
45117
 
44484
45118
  class CommandQueueConsumer {
@@ -48083,7 +48717,7 @@ var init_task_service = __esm(() => {
48083
48717
 
48084
48718
  // src/daemon/services/task-service/infrastructure/repository/task-handoff-repository.ts
48085
48719
  import { mkdirSync as mkdirSync2 } from "node:fs";
48086
- import { dirname as dirname5 } from "node:path";
48720
+ import { dirname as dirname6 } from "node:path";
48087
48721
  import { DatabaseSync } from "node:sqlite";
48088
48722
  function normalizeRole(role) {
48089
48723
  return role.toLowerCase();
@@ -48103,7 +48737,7 @@ function mapRow(row) {
48103
48737
  };
48104
48738
  }
48105
48739
  function createTaskHandoffRepository(dbPath) {
48106
- mkdirSync2(dirname5(dbPath), { recursive: true });
48740
+ mkdirSync2(dirname6(dbPath), { recursive: true });
48107
48741
  const db = new DatabaseSync(dbPath);
48108
48742
  db.exec(`
48109
48743
  CREATE TABLE IF NOT EXISTS task_handoffs (
@@ -50032,7 +50666,7 @@ function isCatalogueStable(state, key, now) {
50032
50666
  return now - state.stableSince >= WARMUP_STABLE_WINDOW_MS;
50033
50667
  }
50034
50668
  function sleep4(ms) {
50035
- return new Promise((resolve5) => setTimeout(resolve5, Math.max(0, ms)));
50669
+ return new Promise((resolve6) => setTimeout(resolve6, Math.max(0, ms)));
50036
50670
  }
50037
50671
  async function readCatalogueKey(client2, directory, timeoutMs) {
50038
50672
  let timer;
@@ -50067,7 +50701,7 @@ function serverAuthHeaders(password) {
50067
50701
  };
50068
50702
  }
50069
50703
  async function waitForListeningUrl(child, options) {
50070
- return new Promise((resolve5, reject) => {
50704
+ return new Promise((resolve6, reject) => {
50071
50705
  const buffers = { stdout: "", stderr: "" };
50072
50706
  let url2;
50073
50707
  let password;
@@ -50084,7 +50718,7 @@ async function waitForListeningUrl(child, options) {
50084
50718
  if (url2 === undefined)
50085
50719
  return;
50086
50720
  cleanup();
50087
- resolve5({ url: url2, ...password !== undefined ? { password } : {} });
50721
+ resolve6({ url: url2, ...password !== undefined ? { password } : {} });
50088
50722
  };
50089
50723
  const tryMatch = (key, chunk) => {
50090
50724
  buffers[key] += typeof chunk === "string" ? chunk : chunk.toString("utf8");
@@ -50217,7 +50851,7 @@ async function stopServeProcess(deps, child) {
50217
50851
  } catch {
50218
50852
  return;
50219
50853
  }
50220
- await new Promise((resolve5) => setTimeout(resolve5, SERVE_KILL_POLL_INTERVAL_MS));
50854
+ await new Promise((resolve6) => setTimeout(resolve6, SERVE_KILL_POLL_INTERVAL_MS));
50221
50855
  }
50222
50856
  try {
50223
50857
  deps.kill(-pid, "SIGKILL");
@@ -50762,27 +51396,27 @@ var init_pi_agent_service = __esm(() => {
50762
51396
  return childProcess;
50763
51397
  }
50764
51398
  writePrompt(child, prompt) {
50765
- return new Promise((resolve5, reject) => {
51399
+ return new Promise((resolve6, reject) => {
50766
51400
  if (!child.stdin) {
50767
51401
  reject(new Error("Pi RPC process has no stdin"));
50768
51402
  return;
50769
51403
  }
50770
51404
  const message = JSON.stringify({ type: "prompt", message: prompt }) + `
50771
51405
  `;
50772
- child.stdin.write(message, (err) => err ? reject(err) : resolve5());
51406
+ child.stdin.write(message, (err) => err ? reject(err) : resolve6());
50773
51407
  });
50774
51408
  }
50775
51409
  async querySessionId(reader, stdin) {
50776
51410
  if (!stdin) {
50777
51411
  throw new Error("Pi RPC process has no stdin");
50778
51412
  }
50779
- return new Promise((resolve5, reject) => {
51413
+ return new Promise((resolve6, reject) => {
50780
51414
  const timer = setTimeout(() => {
50781
51415
  reject(new Error(`get_state timed out after ${GET_STATE_TIMEOUT_MS}ms`));
50782
51416
  }, GET_STATE_TIMEOUT_MS);
50783
51417
  reader.onStateResponse((sessionId) => {
50784
51418
  clearTimeout(timer);
50785
- resolve5(sessionId);
51419
+ resolve6(sessionId);
50786
51420
  });
50787
51421
  stdin.write(JSON.stringify({ type: "get_state" }) + `
50788
51422
  `);
@@ -51128,12 +51762,12 @@ var init_model_provider = () => {};
51128
51762
  // src/daemon/infrastructure/local/harness/services/cursor-sdk/cursor-sdk-package.ts
51129
51763
  import { existsSync as existsSync2, readFileSync as readFileSync5 } from "node:fs";
51130
51764
  import { createRequire as createRequire4 } from "node:module";
51131
- import { dirname as dirname6, join as join9 } from "node:path";
51765
+ import { dirname as dirname7, join as join9 } from "node:path";
51132
51766
  import { fileURLToPath as fileURLToPath2, pathToFileURL } from "node:url";
51133
51767
  function resolveChatroomCliRoot(moduleRef = import.meta.url) {
51134
51768
  const filePath = moduleRef.startsWith("file:") ? fileURLToPath2(moduleRef) : moduleRef;
51135
- let dir = dirname6(filePath);
51136
- while (dir !== dirname6(dir)) {
51769
+ let dir = dirname7(filePath);
51770
+ while (dir !== dirname7(dir)) {
51137
51771
  const packageJsonPath = join9(dir, "package.json");
51138
51772
  if (existsSync2(packageJsonPath)) {
51139
51773
  const pkg = JSON.parse(readFileSync5(packageJsonPath, "utf8"));
@@ -51141,7 +51775,7 @@ function resolveChatroomCliRoot(moduleRef = import.meta.url) {
51141
51775
  return dir;
51142
51776
  }
51143
51777
  }
51144
- dir = dirname6(dir);
51778
+ dir = dirname7(dir);
51145
51779
  }
51146
51780
  throw new CursorSdkPackageError(`Could not locate chatroom-cli package root while resolving @cursor/sdk. ${REINSTALL_HINT}`);
51147
51781
  }
@@ -51156,7 +51790,7 @@ function readPinnedSdkVersion(chatroomCliRoot) {
51156
51790
  return match5[1];
51157
51791
  }
51158
51792
  function readInstalledSdkVersion(entryPath) {
51159
- const packageJsonPath = join9(dirname6(entryPath), "..", "..", "package.json");
51793
+ const packageJsonPath = join9(dirname7(entryPath), "..", "..", "package.json");
51160
51794
  const pkg = JSON.parse(readFileSync5(packageJsonPath, "utf8"));
51161
51795
  return pkg.version;
51162
51796
  }
@@ -52077,12 +52711,12 @@ import {
52077
52711
  } from "node:fs";
52078
52712
  import { createRequire as createRequire5 } from "node:module";
52079
52713
  import { homedir as homedir3 } from "node:os";
52080
- import { basename as basename3, dirname as dirname7, join as join10 } from "node:path";
52714
+ import { basename as basename4, dirname as dirname8, join as join10 } from "node:path";
52081
52715
  import { fileURLToPath as fileURLToPath3, pathToFileURL as pathToFileURL2 } from "node:url";
52082
52716
  function resolveChatroomCliRoot2(moduleRef = import.meta.url) {
52083
52717
  const filePath = moduleRef.startsWith("file:") ? fileURLToPath3(moduleRef) : moduleRef;
52084
- let dir = dirname7(filePath);
52085
- while (dir !== dirname7(dir)) {
52718
+ let dir = dirname8(filePath);
52719
+ while (dir !== dirname8(dir)) {
52086
52720
  const packageJsonPath = join10(dir, "package.json");
52087
52721
  if (existsSync3(packageJsonPath)) {
52088
52722
  const pkg = JSON.parse(readFileSync6(packageJsonPath, "utf8"));
@@ -52090,7 +52724,7 @@ function resolveChatroomCliRoot2(moduleRef = import.meta.url) {
52090
52724
  return realpathSync(dir);
52091
52725
  }
52092
52726
  }
52093
- dir = dirname7(dir);
52727
+ dir = dirname8(dir);
52094
52728
  }
52095
52729
  throw new ClaudeSdkPackageError(`Could not locate chatroom-cli package root while resolving ${CLAUDE_AGENT_SDK_PKG}. ${REINSTALL_HINT2}`);
52096
52730
  }
@@ -52105,7 +52739,7 @@ function readPinnedSdkVersion2(chatroomCliRoot) {
52105
52739
  return match5[1];
52106
52740
  }
52107
52741
  function readInstalledSdkVersion2(entryPath) {
52108
- const packageJsonPath = join10(dirname7(entryPath), "package.json");
52742
+ const packageJsonPath = join10(dirname8(entryPath), "package.json");
52109
52743
  const pkg = JSON.parse(readFileSync6(packageJsonPath, "utf8"));
52110
52744
  return pkg.version;
52111
52745
  }
@@ -52131,7 +52765,7 @@ function resolveNativeCliBinaryPath(sdkEntryPath) {
52131
52765
  const binaryName = process.platform === "win32" ? "claude.exe" : "claude";
52132
52766
  let pkgDir;
52133
52767
  try {
52134
- pkgDir = dirname7(require3.resolve(`${platformPkg}/package.json`));
52768
+ pkgDir = dirname8(require3.resolve(`${platformPkg}/package.json`));
52135
52769
  } catch {
52136
52770
  throw new ClaudeSdkPackageError(`Native CLI binary package ${platformPkg} is not installed. ${REINSTALL_HINT2}`);
52137
52771
  }
@@ -52143,7 +52777,7 @@ function resolveNativeCliBinaryPath(sdkEntryPath) {
52143
52777
  }
52144
52778
  function pinNativeBinary(sourcePath, sdkVersion, pinRoot) {
52145
52779
  const dir = join10(pinRoot, sdkVersion);
52146
- const pinnedPath = join10(dir, basename3(sourcePath));
52780
+ const pinnedPath = join10(dir, basename4(sourcePath));
52147
52781
  if (existsSync3(pinnedPath))
52148
52782
  return pinnedPath;
52149
52783
  mkdirSync3(dir, { recursive: true, mode: 448 });
@@ -52226,8 +52860,8 @@ function createTurnCompletion(turnId = randomUUID3()) {
52226
52860
  let resolveResult;
52227
52861
  let value;
52228
52862
  const listeners = new Set;
52229
- const result3 = new Promise((resolve5) => {
52230
- resolveResult = resolve5;
52863
+ const result3 = new Promise((resolve6) => {
52864
+ resolveResult = resolve6;
52231
52865
  });
52232
52866
  return {
52233
52867
  turnId,
@@ -52599,18 +53233,18 @@ function waitForResumeOrAbort(session2) {
52599
53233
  return Promise.resolve(queued);
52600
53234
  }
52601
53235
  return Promise.race([
52602
- new Promise((resolve5) => {
53236
+ new Promise((resolve6) => {
52603
53237
  session2.resumeResolve = (prompt) => {
52604
53238
  session2.resumeResolve = undefined;
52605
53239
  session2.abortResolve = undefined;
52606
- resolve5(prompt);
53240
+ resolve6(prompt);
52607
53241
  };
52608
53242
  }),
52609
- new Promise((resolve5) => {
53243
+ new Promise((resolve6) => {
52610
53244
  session2.abortResolve = () => {
52611
53245
  session2.resumeResolve = undefined;
52612
53246
  session2.abortResolve = undefined;
52613
- resolve5(null);
53247
+ resolve6(null);
52614
53248
  };
52615
53249
  })
52616
53250
  ]);
@@ -52694,10 +53328,10 @@ var init_claude_sdk_agent_service = __esm(() => {
52694
53328
  throw new Error(`No claude-sdk session for pid=${pid}`);
52695
53329
  }
52696
53330
  if (session2.resumeResolve) {
52697
- const resolve5 = session2.resumeResolve;
53331
+ const resolve6 = session2.resumeResolve;
52698
53332
  session2.resumeResolve = undefined;
52699
53333
  session2.abortResolve = undefined;
52700
- resolve5(prompt);
53334
+ resolve6(prompt);
52701
53335
  return;
52702
53336
  }
52703
53337
  session2.pendingResumePrompt = prompt;
@@ -53065,12 +53699,12 @@ var init_codex_sdk_model_variants = __esm(() => {
53065
53699
  // src/daemon/infrastructure/local/harness/services/codex-sdk/codex-sdk-package.ts
53066
53700
  import { existsSync as existsSync4, readFileSync as readFileSync7, realpathSync as realpathSync2, statSync } from "node:fs";
53067
53701
  import { createRequire as createRequire6 } from "node:module";
53068
- import { dirname as dirname8, join as join11 } from "node:path";
53702
+ import { dirname as dirname9, join as join11 } from "node:path";
53069
53703
  import { fileURLToPath as fileURLToPath4, pathToFileURL as pathToFileURL3 } from "node:url";
53070
53704
  function resolveChatroomCliRoot3(moduleRef = import.meta.url) {
53071
53705
  const filePath = moduleRef.startsWith("file:") ? fileURLToPath4(moduleRef) : moduleRef;
53072
- let dir = dirname8(filePath);
53073
- while (dir !== dirname8(dir)) {
53706
+ let dir = dirname9(filePath);
53707
+ while (dir !== dirname9(dir)) {
53074
53708
  const packageJsonPath = join11(dir, "package.json");
53075
53709
  if (existsSync4(packageJsonPath)) {
53076
53710
  const pkg = JSON.parse(readFileSync7(packageJsonPath, "utf8"));
@@ -53078,7 +53712,7 @@ function resolveChatroomCliRoot3(moduleRef = import.meta.url) {
53078
53712
  return dir;
53079
53713
  }
53080
53714
  }
53081
- dir = dirname8(dir);
53715
+ dir = dirname9(dir);
53082
53716
  }
53083
53717
  throw new CodexSdkPackageError(`Could not locate chatroom-cli package root while resolving @openai/codex-sdk. ${REINSTALL_HINT3}`);
53084
53718
  }
@@ -53145,7 +53779,7 @@ function addPlatformPackageJsonCandidate(candidates, candidate) {
53145
53779
  }
53146
53780
  function resolvePlatformPackageJsonCandidates(platformPkg, chatroomCliRoot, codexPackageJson, chatroomRequire, codexRequire) {
53147
53781
  const candidates = [];
53148
- const codexPackageDir = realpathSync2(dirname8(codexPackageJson));
53782
+ const codexPackageDir = realpathSync2(dirname9(codexPackageJson));
53149
53783
  const platformPkgBaseName = platformPkg.includes("/") ? platformPkg.slice(platformPkg.indexOf("/") + 1) : platformPkg;
53150
53784
  try {
53151
53785
  addPlatformPackageJsonCandidate(candidates, codexRequire.resolve(`${platformPkg}/package.json`));
@@ -53189,7 +53823,7 @@ function resolveCodexExecutablePath(moduleRef = import.meta.url) {
53189
53823
  throw new CodexSdkPackageError(`Native Codex CLI package ${platformPkg} is not installed. Ensure ${CODEX_NPM_NAME} is installed with optional dependencies. ${REINSTALL_HINT3}`);
53190
53824
  }
53191
53825
  for (const platformPackageJson of platformPackageJsonCandidates) {
53192
- const vendorRoot = join11(dirname8(platformPackageJson), "vendor");
53826
+ const vendorRoot = join11(dirname9(platformPackageJson), "vendor");
53193
53827
  const binaryPath = resolveNativeCodexBinary(vendorRoot, targetTriple, codexBinaryName);
53194
53828
  if (binaryPath) {
53195
53829
  return binaryPath;
@@ -53205,7 +53839,7 @@ async function importBundledCodexSdk(moduleRef = import.meta.url) {
53205
53839
  if (installedVersion !== pinnedVersion) {
53206
53840
  throw new CodexSdkPackageError(`@openai/codex-sdk@${installedVersion} does not match chatroom-cli pin (${pinnedVersion}). ${REINSTALL_HINT3}`);
53207
53841
  }
53208
- const distEntryPath = join11(dirname8(packageJsonPath), "dist", "index.js");
53842
+ const distEntryPath = join11(dirname9(packageJsonPath), "dist", "index.js");
53209
53843
  if (!existsSync4(distEntryPath)) {
53210
53844
  throw new CodexSdkPackageError(`@openai/codex-sdk entry file is missing: ${distEntryPath}. ${REINSTALL_HINT3}`);
53211
53845
  }
@@ -53497,18 +54131,18 @@ function waitForResumeOrAbort2(session2) {
53497
54131
  return Promise.resolve(queued);
53498
54132
  }
53499
54133
  return Promise.race([
53500
- new Promise((resolve5) => {
54134
+ new Promise((resolve6) => {
53501
54135
  session2.resumeResolve = (prompt) => {
53502
54136
  session2.resumeResolve = undefined;
53503
54137
  session2.abortResolve = undefined;
53504
- resolve5(prompt);
54138
+ resolve6(prompt);
53505
54139
  };
53506
54140
  }),
53507
- new Promise((resolve5) => {
54141
+ new Promise((resolve6) => {
53508
54142
  session2.abortResolve = () => {
53509
54143
  session2.resumeResolve = undefined;
53510
54144
  session2.abortResolve = undefined;
53511
- resolve5(null);
54145
+ resolve6(null);
53512
54146
  };
53513
54147
  })
53514
54148
  ]);
@@ -53589,10 +54223,10 @@ var init_codex_sdk_agent_service = __esm(() => {
53589
54223
  throw new Error(`No codex-sdk session for pid=${pid}`);
53590
54224
  }
53591
54225
  if (session2.resumeResolve) {
53592
- const resolve5 = session2.resumeResolve;
54226
+ const resolve6 = session2.resumeResolve;
53593
54227
  session2.resumeResolve = undefined;
53594
54228
  session2.abortResolve = undefined;
53595
- resolve5(prompt);
54229
+ resolve6(prompt);
53596
54230
  return;
53597
54231
  }
53598
54232
  session2.pendingResumePrompt = prompt;
@@ -54468,18 +55102,18 @@ function waitForResumeOrAbort3(session2) {
54468
55102
  return Promise.resolve(queued);
54469
55103
  }
54470
55104
  return Promise.race([
54471
- new Promise((resolve5) => {
55105
+ new Promise((resolve6) => {
54472
55106
  session2.resumeResolve = (prompt) => {
54473
55107
  session2.resumeResolve = undefined;
54474
55108
  session2.abortResolve = undefined;
54475
- resolve5(prompt);
55109
+ resolve6(prompt);
54476
55110
  };
54477
55111
  }),
54478
- new Promise((resolve5) => {
55112
+ new Promise((resolve6) => {
54479
55113
  session2.abortResolve = () => {
54480
55114
  session2.resumeResolve = undefined;
54481
55115
  session2.abortResolve = undefined;
54482
- resolve5(null);
55116
+ resolve6(null);
54483
55117
  };
54484
55118
  })
54485
55119
  ]);
@@ -54552,10 +55186,10 @@ var init_cursor_sdk_agent_service = __esm(() => {
54552
55186
  throw new Error(`No cursor-sdk session for pid=${pid}`);
54553
55187
  }
54554
55188
  if (session2.resumeResolve) {
54555
- const resolve5 = session2.resumeResolve;
55189
+ const resolve6 = session2.resumeResolve;
54556
55190
  session2.resumeResolve = undefined;
54557
55191
  session2.abortResolve = undefined;
54558
- resolve5(prompt);
55192
+ resolve6(prompt);
54559
55193
  return;
54560
55194
  }
54561
55195
  session2.pendingResumePrompt = prompt;
@@ -54955,8 +55589,8 @@ function startSessionEventForwarder(client2, options) {
54955
55589
  const agentEndCallbacks = [];
54956
55590
  const recentLogLines = [];
54957
55591
  let retryIdleTimeout;
54958
- const donePromise = new Promise((resolve5) => {
54959
- doneResolve = resolve5;
55592
+ const donePromise = new Promise((resolve6) => {
55593
+ doneResolve = resolve6;
54960
55594
  });
54961
55595
  function recordRecentLogLine(line) {
54962
55596
  recentLogLines.push(line);
@@ -55298,7 +55932,7 @@ var init_session_event_forwarder = __esm(() => {
55298
55932
  // src/daemon/infrastructure/local/harness/services/opencode-sdk/session-metadata-store.ts
55299
55933
  import { chmodSync as chmodSync2, existsSync as existsSync5, mkdirSync as mkdirSync4, readFileSync as readFileSync8, writeFileSync as writeFileSync2 } from "node:fs";
55300
55934
  import { homedir as homedir4 } from "node:os";
55301
- import { dirname as dirname9, join as join12 } from "node:path";
55935
+ import { dirname as dirname10, join as join12 } from "node:path";
55302
55936
 
55303
55937
  class FileSessionMetadataStore {
55304
55938
  filePath;
@@ -55315,7 +55949,7 @@ class FileSessionMetadataStore {
55315
55949
  }
55316
55950
  save(sessions) {
55317
55951
  try {
55318
- const dir = dirname9(this.filePath);
55952
+ const dir = dirname10(this.filePath);
55319
55953
  if (!existsSync5(dir)) {
55320
55954
  mkdirSync4(dir, { recursive: true, mode: 448 });
55321
55955
  }
@@ -55898,12 +56532,12 @@ var init_opencode_sdk = __esm(() => {
55898
56532
 
55899
56533
  // src/daemon/infrastructure/local/harness/services/pi-sdk/pi-sdk-package.ts
55900
56534
  import { existsSync as existsSync6, readFileSync as readFileSync9 } from "node:fs";
55901
- import { dirname as dirname10, join as join13 } from "node:path";
56535
+ import { dirname as dirname11, join as join13 } from "node:path";
55902
56536
  import { fileURLToPath as fileURLToPath5, pathToFileURL as pathToFileURL4 } from "node:url";
55903
56537
  function resolveChatroomCliRoot4(moduleRef = import.meta.url) {
55904
56538
  const filePath = moduleRef.startsWith("file:") ? fileURLToPath5(moduleRef) : moduleRef;
55905
- let dir = dirname10(filePath);
55906
- while (dir !== dirname10(dir)) {
56539
+ let dir = dirname11(filePath);
56540
+ while (dir !== dirname11(dir)) {
55907
56541
  const packageJsonPath = join13(dir, "package.json");
55908
56542
  if (existsSync6(packageJsonPath)) {
55909
56543
  const pkg = JSON.parse(readFileSync9(packageJsonPath, "utf8"));
@@ -55911,7 +56545,7 @@ function resolveChatroomCliRoot4(moduleRef = import.meta.url) {
55911
56545
  return dir;
55912
56546
  }
55913
56547
  }
55914
- dir = dirname10(dir);
56548
+ dir = dirname11(dir);
55915
56549
  }
55916
56550
  throw new PiSdkPackageError(`Could not locate chatroom-cli package root while resolving ${PI_CODING_AGENT_PKG}. ${REINSTALL_HINT4}`);
55917
56551
  }
@@ -55926,18 +56560,18 @@ function readPinnedSdkVersion4(chatroomCliRoot) {
55926
56560
  return match5[1];
55927
56561
  }
55928
56562
  function readInstalledSdkVersion4(entryPath) {
55929
- const packageJsonPath = join13(dirname10(entryPath), "..", "package.json");
56563
+ const packageJsonPath = join13(dirname11(entryPath), "..", "package.json");
55930
56564
  const pkg = JSON.parse(readFileSync9(packageJsonPath, "utf8"));
55931
56565
  return pkg.version;
55932
56566
  }
55933
56567
  function resolvePiSdkEntryPathFromNodeModules(chatroomCliRoot) {
55934
56568
  let dir = chatroomCliRoot;
55935
- while (dir !== dirname10(dir)) {
56569
+ while (dir !== dirname11(dir)) {
55936
56570
  const entryPath = join13(dir, "node_modules", PI_CODING_AGENT_PKG, "dist", "index.js");
55937
56571
  if (existsSync6(entryPath)) {
55938
56572
  return entryPath;
55939
56573
  }
55940
- dir = dirname10(dir);
56574
+ dir = dirname11(dir);
55941
56575
  }
55942
56576
  return;
55943
56577
  }
@@ -56156,18 +56790,18 @@ function waitForResumeOrAbort4(session2) {
56156
56790
  return Promise.resolve(queued);
56157
56791
  }
56158
56792
  return Promise.race([
56159
- new Promise((resolve5) => {
56793
+ new Promise((resolve6) => {
56160
56794
  session2.resumeResolve = (prompt) => {
56161
56795
  session2.resumeResolve = undefined;
56162
56796
  session2.abortResolve = undefined;
56163
- resolve5(prompt);
56797
+ resolve6(prompt);
56164
56798
  };
56165
56799
  }),
56166
- new Promise((resolve5) => {
56800
+ new Promise((resolve6) => {
56167
56801
  session2.abortResolve = () => {
56168
56802
  session2.resumeResolve = undefined;
56169
56803
  session2.abortResolve = undefined;
56170
- resolve5(null);
56804
+ resolve6(null);
56171
56805
  };
56172
56806
  })
56173
56807
  ]);
@@ -56271,10 +56905,10 @@ var init_pi_sdk_agent_service = __esm(() => {
56271
56905
  throw new Error(`No pi-sdk session for pid=${pid}`);
56272
56906
  }
56273
56907
  if (session2.resumeResolve) {
56274
- const resolve5 = session2.resumeResolve;
56908
+ const resolve6 = session2.resumeResolve;
56275
56909
  session2.resumeResolve = undefined;
56276
56910
  session2.abortResolve = undefined;
56277
- resolve5(prompt);
56911
+ resolve6(prompt);
56278
56912
  return;
56279
56913
  }
56280
56914
  session2.pendingResumePrompt = prompt;
@@ -63399,9 +64033,9 @@ var init_socket2 = __esm(() => {
63399
64033
  this.acks[id] = fn3;
63400
64034
  }
63401
64035
  emitWithAck(ev, ...args2) {
63402
- return new Promise((resolve5, reject) => {
64036
+ return new Promise((resolve6, reject) => {
63403
64037
  const fn3 = (arg1, arg2) => {
63404
- return arg1 ? reject(arg1) : resolve5(arg2);
64038
+ return arg1 ? reject(arg1) : resolve6(arg2);
63405
64039
  };
63406
64040
  fn3.withError = true;
63407
64041
  args2.push(fn3);
@@ -64080,10 +64714,10 @@ async function requestLocalDaemon(port, event, payload) {
64080
64714
  timeout: 2000
64081
64715
  });
64082
64716
  try {
64083
- await new Promise((resolve5, reject) => {
64717
+ await new Promise((resolve6, reject) => {
64084
64718
  const onConnect = () => {
64085
64719
  cleanup();
64086
- resolve5();
64720
+ resolve6();
64087
64721
  };
64088
64722
  const onError3 = (error51) => {
64089
64723
  cleanup();
@@ -64339,10 +64973,10 @@ var init_log_schema = __esm(() => {
64339
64973
 
64340
64974
  // src/infrastructure/log-server/open-log-database.ts
64341
64975
  import { mkdirSync as mkdirSync5 } from "node:fs";
64342
- import { dirname as dirname11 } from "node:path";
64976
+ import { dirname as dirname12 } from "node:path";
64343
64977
  import { DatabaseSync as DatabaseSync2 } from "node:sqlite";
64344
64978
  function openLogDatabase(dbPath) {
64345
- mkdirSync5(dirname11(dbPath), { recursive: true });
64979
+ mkdirSync5(dirname12(dbPath), { recursive: true });
64346
64980
  const db = new DatabaseSync2(dbPath);
64347
64981
  db.exec("PRAGMA journal_mode = WAL");
64348
64982
  db.exec("PRAGMA busy_timeout = 5000");
@@ -64612,7 +65246,7 @@ function signalBestEffort(pid, signal, send) {
64612
65246
  async function stopExistingDaemons(options) {
64613
65247
  const isRunning = options?.isRunning ?? isProcessRunning;
64614
65248
  const send = options?.signal ?? defaultSignal;
64615
- const sleep5 = options?.sleep ?? ((ms) => new Promise((resolve5) => setTimeout(resolve5, ms)));
65249
+ const sleep5 = options?.sleep ?? ((ms) => new Promise((resolve6) => setTimeout(resolve6, ms)));
64616
65250
  const log3 = options?.log ?? ((message) => console.error(message));
64617
65251
  const waitMs = options?.waitMs ?? STOP_EXISTING_WAIT_MS;
64618
65252
  const listPids = options?.listMatchingDaemonPids ?? listMatchingDaemonPids;
@@ -64671,7 +65305,7 @@ async function waitForLockOrTimeout(deadline, intervalMs, sleep5) {
64671
65305
  async function acquireLockWithRetry(options) {
64672
65306
  const intervalMs = options?.intervalMs ?? LOCK_RETRY_INTERVAL_MS;
64673
65307
  const maxWaitMs = options?.maxWaitMs ?? LOCK_RETRY_MAX_WAIT_MS;
64674
- const sleep5 = options?.sleep ?? ((ms) => new Promise((resolve5) => setTimeout(resolve5, ms)));
65308
+ const sleep5 = options?.sleep ?? ((ms) => new Promise((resolve6) => setTimeout(resolve6, ms)));
64675
65309
  await stopExistingDaemons({
64676
65310
  listMatchingDaemonPids: options?.listMatchingDaemonPids,
64677
65311
  isRunning: options?.isRunning,
@@ -65176,26 +65810,26 @@ function pLimit(concurrency) {
65176
65810
  activeCount--;
65177
65811
  resumeNext();
65178
65812
  };
65179
- const run = async (function_, resolve5, arguments_) => {
65813
+ const run = async (function_, resolve6, arguments_) => {
65180
65814
  const result3 = (async () => function_(...arguments_))();
65181
- resolve5(result3);
65815
+ resolve6(result3);
65182
65816
  try {
65183
65817
  await result3;
65184
65818
  } catch {}
65185
65819
  next2();
65186
65820
  };
65187
- const enqueue = (function_, resolve5, reject, arguments_) => {
65821
+ const enqueue = (function_, resolve6, reject, arguments_) => {
65188
65822
  const queueItem = { reject };
65189
65823
  new Promise((internalResolve) => {
65190
65824
  queueItem.run = internalResolve;
65191
65825
  queue.enqueue(queueItem);
65192
- }).then(run.bind(undefined, function_, resolve5, arguments_));
65826
+ }).then(run.bind(undefined, function_, resolve6, arguments_));
65193
65827
  if (activeCount < concurrency) {
65194
65828
  resumeNext();
65195
65829
  }
65196
65830
  };
65197
- const generator = (function_, ...arguments_) => new Promise((resolve5, reject) => {
65198
- enqueue(function_, resolve5, reject, arguments_);
65831
+ const generator = (function_, ...arguments_) => new Promise((resolve6, reject) => {
65832
+ enqueue(function_, resolve6, reject, arguments_);
65199
65833
  });
65200
65834
  Object.defineProperties(generator, {
65201
65835
  activeCount: {
@@ -65274,11 +65908,11 @@ var init_config2 = __esm(() => {
65274
65908
  // ../../node_modules/.pnpm/@hyzyla+pdfium@2.1.13/node_modules/@hyzyla/pdfium/dist/index.esm.js
65275
65909
  function __awaiter(thisArg, _arguments, P, generator) {
65276
65910
  function adopt(value2) {
65277
- return value2 instanceof P ? value2 : new P(function(resolve5) {
65278
- resolve5(value2);
65911
+ return value2 instanceof P ? value2 : new P(function(resolve6) {
65912
+ resolve6(value2);
65279
65913
  });
65280
65914
  }
65281
- return new (P || (P = Promise))(function(resolve5, reject) {
65915
+ return new (P || (P = Promise))(function(resolve6, reject) {
65282
65916
  function fulfilled(value2) {
65283
65917
  try {
65284
65918
  step(generator.next(value2));
@@ -65294,7 +65928,7 @@ function __awaiter(thisArg, _arguments, P, generator) {
65294
65928
  }
65295
65929
  }
65296
65930
  function step(result3) {
65297
- result3.done ? resolve5(result3.value) : adopt(result3.value).then(fulfilled, rejected);
65931
+ result3.done ? resolve6(result3.value) : adopt(result3.value).then(fulfilled, rejected);
65298
65932
  }
65299
65933
  step((generator = generator.apply(thisArg, _arguments || [])).next());
65300
65934
  });
@@ -65954,13 +66588,13 @@ var init_index_esm = __esm(() => {
65954
66588
  }
65955
66589
  readAsync = async (url3) => {
65956
66590
  if (isFileURI(url3)) {
65957
- return new Promise((resolve5, reject) => {
66591
+ return new Promise((resolve6, reject) => {
65958
66592
  var xhr = new XMLHttpRequest;
65959
66593
  xhr.open("GET", url3, true);
65960
66594
  xhr.responseType = "arraybuffer";
65961
66595
  xhr.onload = () => {
65962
66596
  if (xhr.status == 200 || xhr.status == 0 && xhr.response) {
65963
- resolve5(xhr.response);
66597
+ resolve6(xhr.response);
65964
66598
  return;
65965
66599
  }
65966
66600
  reject(xhr.status);
@@ -66294,10 +66928,10 @@ var init_index_esm = __esm(() => {
66294
66928
  }
66295
66929
  var info = getWasmImports();
66296
66930
  if (Module["instantiateWasm"]) {
66297
- return new Promise((resolve5, reject) => {
66931
+ return new Promise((resolve6, reject) => {
66298
66932
  try {
66299
66933
  Module["instantiateWasm"](info, (mod, inst) => {
66300
- resolve5(receiveInstance(mod, inst));
66934
+ resolve6(receiveInstance(mod, inst));
66301
66935
  });
66302
66936
  } catch (e) {
66303
66937
  err(`Module.instantiateWasm callback failed with error: ${e}`);
@@ -70979,8 +71613,8 @@ var init_index_esm = __esm(() => {
70979
71613
  if (runtimeInitialized) {
70980
71614
  moduleRtn = Module;
70981
71615
  } else {
70982
- moduleRtn = new Promise((resolve5, reject) => {
70983
- readyPromiseResolve = resolve5;
71616
+ moduleRtn = new Promise((resolve6, reject) => {
71617
+ readyPromiseResolve = resolve6;
70984
71618
  readyPromiseReject = reject;
70985
71619
  });
70986
71620
  }
@@ -71103,14 +71737,14 @@ var require_filesystem = __commonJS((exports, module) => {
71103
71737
  fs6.close(fd, () => {});
71104
71738
  return buffer.subarray(0, bytesRead);
71105
71739
  };
71106
- var readFile6 = (path2) => new Promise((resolve5, reject) => {
71740
+ var readFile7 = (path2) => new Promise((resolve6, reject) => {
71107
71741
  fs6.open(path2, "r", (err, fd) => {
71108
71742
  if (err) {
71109
71743
  reject(err);
71110
71744
  } else {
71111
71745
  const buffer = Buffer.alloc(MAX_LENGTH);
71112
71746
  fs6.read(fd, buffer, 0, MAX_LENGTH, 0, (_, bytesRead) => {
71113
- resolve5(buffer.subarray(0, bytesRead));
71747
+ resolve6(buffer.subarray(0, bytesRead));
71114
71748
  fs6.close(fd, () => {});
71115
71749
  });
71116
71750
  }
@@ -71120,7 +71754,7 @@ var require_filesystem = __commonJS((exports, module) => {
71120
71754
  LDD_PATH,
71121
71755
  SELF_PATH,
71122
71756
  readFileSync: readFileSync12,
71123
- readFile: readFile6
71757
+ readFile: readFile7
71124
71758
  };
71125
71759
  });
71126
71760
 
@@ -71162,7 +71796,7 @@ var require_elf = __commonJS((exports, module) => {
71162
71796
  var require_detect_libc = __commonJS((exports, module) => {
71163
71797
  var childProcess = __require("child_process");
71164
71798
  var { isLinux, getReport } = require_process();
71165
- var { LDD_PATH, SELF_PATH, readFile: readFile6, readFileSync: readFileSync12 } = require_filesystem();
71799
+ var { LDD_PATH, SELF_PATH, readFile: readFile7, readFileSync: readFileSync12 } = require_filesystem();
71166
71800
  var { interpreterPath } = require_elf();
71167
71801
  var cachedFamilyInterpreter;
71168
71802
  var cachedFamilyFilesystem;
@@ -71171,10 +71805,10 @@ var require_detect_libc = __commonJS((exports, module) => {
71171
71805
  var commandOut = "";
71172
71806
  var safeCommand = () => {
71173
71807
  if (!commandOut) {
71174
- return new Promise((resolve5) => {
71808
+ return new Promise((resolve6) => {
71175
71809
  childProcess.exec(command, (err, out) => {
71176
71810
  commandOut = err ? " " : out;
71177
- resolve5(commandOut);
71811
+ resolve6(commandOut);
71178
71812
  });
71179
71813
  });
71180
71814
  }
@@ -71242,7 +71876,7 @@ var require_detect_libc = __commonJS((exports, module) => {
71242
71876
  }
71243
71877
  cachedFamilyFilesystem = null;
71244
71878
  try {
71245
- const lddContent = await readFile6(LDD_PATH);
71879
+ const lddContent = await readFile7(LDD_PATH);
71246
71880
  cachedFamilyFilesystem = getFamilyFromLddContent(lddContent);
71247
71881
  } catch (e) {}
71248
71882
  return cachedFamilyFilesystem;
@@ -71264,7 +71898,7 @@ var require_detect_libc = __commonJS((exports, module) => {
71264
71898
  }
71265
71899
  cachedFamilyInterpreter = null;
71266
71900
  try {
71267
- const selfContent = await readFile6(SELF_PATH);
71901
+ const selfContent = await readFile7(SELF_PATH);
71268
71902
  const path2 = interpreterPath(selfContent);
71269
71903
  cachedFamilyInterpreter = familyFromInterpreterPath(path2);
71270
71904
  } catch (e) {}
@@ -71324,7 +71958,7 @@ var require_detect_libc = __commonJS((exports, module) => {
71324
71958
  }
71325
71959
  cachedVersionFilesystem = null;
71326
71960
  try {
71327
- const lddContent = await readFile6(LDD_PATH);
71961
+ const lddContent = await readFile7(LDD_PATH);
71328
71962
  const versionMatch = lddContent.match(RE_GLIBC_VERSION);
71329
71963
  if (versionMatch) {
71330
71964
  cachedVersionFilesystem = versionMatch[1];
@@ -73752,14 +74386,14 @@ var require_input = __commonJS((exports, module) => {
73752
74386
  return this;
73753
74387
  } else {
73754
74388
  if (this._isStreamInput()) {
73755
- return new Promise((resolve5, reject) => {
74389
+ return new Promise((resolve6, reject) => {
73756
74390
  const finished = () => {
73757
74391
  this._flattenBufferIn();
73758
74392
  sharp.metadata(this.options, (err, metadata2) => {
73759
74393
  if (err) {
73760
74394
  reject(is.nativeError(err, stack));
73761
74395
  } else {
73762
- resolve5(metadata2);
74396
+ resolve6(metadata2);
73763
74397
  }
73764
74398
  });
73765
74399
  };
@@ -73770,12 +74404,12 @@ var require_input = __commonJS((exports, module) => {
73770
74404
  }
73771
74405
  });
73772
74406
  } else {
73773
- return new Promise((resolve5, reject) => {
74407
+ return new Promise((resolve6, reject) => {
73774
74408
  sharp.metadata(this.options, (err, metadata2) => {
73775
74409
  if (err) {
73776
74410
  reject(is.nativeError(err, stack));
73777
74411
  } else {
73778
- resolve5(metadata2);
74412
+ resolve6(metadata2);
73779
74413
  }
73780
74414
  });
73781
74415
  });
@@ -73808,25 +74442,25 @@ var require_input = __commonJS((exports, module) => {
73808
74442
  return this;
73809
74443
  } else {
73810
74444
  if (this._isStreamInput()) {
73811
- return new Promise((resolve5, reject) => {
74445
+ return new Promise((resolve6, reject) => {
73812
74446
  this.on("finish", function() {
73813
74447
  this._flattenBufferIn();
73814
74448
  sharp.stats(this.options, (err, stats2) => {
73815
74449
  if (err) {
73816
74450
  reject(is.nativeError(err, stack));
73817
74451
  } else {
73818
- resolve5(stats2);
74452
+ resolve6(stats2);
73819
74453
  }
73820
74454
  });
73821
74455
  });
73822
74456
  });
73823
74457
  } else {
73824
- return new Promise((resolve5, reject) => {
74458
+ return new Promise((resolve6, reject) => {
73825
74459
  sharp.stats(this.options, (err, stats2) => {
73826
74460
  if (err) {
73827
74461
  reject(is.nativeError(err, stack));
73828
74462
  } else {
73829
- resolve5(stats2);
74463
+ resolve6(stats2);
73830
74464
  }
73831
74465
  });
73832
74466
  });
@@ -77228,7 +77862,7 @@ var require_output = __commonJS((exports, module) => {
77228
77862
  return this;
77229
77863
  } else {
77230
77864
  if (this._isStreamInput()) {
77231
- return new Promise((resolve5, reject) => {
77865
+ return new Promise((resolve6, reject) => {
77232
77866
  this.once("finish", () => {
77233
77867
  this._flattenBufferIn();
77234
77868
  sharp.pipeline(this.options, (err, data, info) => {
@@ -77236,24 +77870,24 @@ var require_output = __commonJS((exports, module) => {
77236
77870
  reject(is.nativeError(err, stack));
77237
77871
  } else {
77238
77872
  if (this.options.resolveWithObject) {
77239
- resolve5({ data, info });
77873
+ resolve6({ data, info });
77240
77874
  } else {
77241
- resolve5(data);
77875
+ resolve6(data);
77242
77876
  }
77243
77877
  }
77244
77878
  });
77245
77879
  });
77246
77880
  });
77247
77881
  } else {
77248
- return new Promise((resolve5, reject) => {
77882
+ return new Promise((resolve6, reject) => {
77249
77883
  sharp.pipeline(this.options, (err, data, info) => {
77250
77884
  if (err) {
77251
77885
  reject(is.nativeError(err, stack));
77252
77886
  } else {
77253
77887
  if (this.options.resolveWithObject) {
77254
- resolve5({ data, info });
77888
+ resolve6({ data, info });
77255
77889
  } else {
77256
- resolve5(data);
77890
+ resolve6(data);
77257
77891
  }
77258
77892
  }
77259
77893
  });
@@ -77555,11 +78189,11 @@ var init_pdfium_renderer = __esm(() => {
77555
78189
 
77556
78190
  // ../../node_modules/.pnpm/@llamaindex+liteparse@1.5.3/node_modules/@llamaindex/liteparse/dist/src/engines/pdf/pdfjsImporter.js
77557
78191
  import { fileURLToPath as fileURLToPath6 } from "node:url";
77558
- import { dirname as dirname12 } from "node:path";
78192
+ import { dirname as dirname13 } from "node:path";
77559
78193
  async function importPdfJs() {
77560
78194
  const pdfUrl = new URL("../../vendor/pdfjs/pdf.mjs", import.meta.url);
77561
78195
  const pdfjs = await import(pdfUrl.href);
77562
- const dirPath = dirname12(fileURLToPath6(pdfUrl));
78196
+ const dirPath = dirname13(fileURLToPath6(pdfUrl));
77563
78197
  return {
77564
78198
  fn: pdfjs.getDocument,
77565
78199
  dir: dirPath
@@ -78327,7 +78961,7 @@ var require_runtime2 = __commonJS((exports, module) => {
78327
78961
  return { __await: arg };
78328
78962
  };
78329
78963
  function AsyncIterator(generator, PromiseImpl) {
78330
- function invoke(method, arg, resolve5, reject) {
78964
+ function invoke(method, arg, resolve6, reject) {
78331
78965
  var record2 = tryCatch(generator[method], generator, arg);
78332
78966
  if (record2.type === "throw") {
78333
78967
  reject(record2.arg);
@@ -78336,24 +78970,24 @@ var require_runtime2 = __commonJS((exports, module) => {
78336
78970
  var value2 = result3.value;
78337
78971
  if (value2 && typeof value2 === "object" && hasOwn.call(value2, "__await")) {
78338
78972
  return PromiseImpl.resolve(value2.__await).then(function(value3) {
78339
- invoke("next", value3, resolve5, reject);
78973
+ invoke("next", value3, resolve6, reject);
78340
78974
  }, function(err) {
78341
- invoke("throw", err, resolve5, reject);
78975
+ invoke("throw", err, resolve6, reject);
78342
78976
  });
78343
78977
  }
78344
78978
  return PromiseImpl.resolve(value2).then(function(unwrapped) {
78345
78979
  result3.value = unwrapped;
78346
- resolve5(result3);
78980
+ resolve6(result3);
78347
78981
  }, function(error51) {
78348
- return invoke("throw", error51, resolve5, reject);
78982
+ return invoke("throw", error51, resolve6, reject);
78349
78983
  });
78350
78984
  }
78351
78985
  }
78352
78986
  var previousPromise;
78353
78987
  function enqueue(method, arg) {
78354
78988
  function callInvokeWithMethodAndArg() {
78355
- return new PromiseImpl(function(resolve5, reject) {
78356
- invoke(method, arg, resolve5, reject);
78989
+ return new PromiseImpl(function(resolve6, reject) {
78990
+ invoke(method, arg, resolve6, reject);
78357
78991
  });
78358
78992
  }
78359
78993
  return previousPromise = previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg();
@@ -78773,13 +79407,13 @@ var require_createScheduler = __commonJS((exports, module) => {
78773
79407
  }
78774
79408
  }
78775
79409
  };
78776
- const queue = (action, payload) => new Promise((resolve5, reject) => {
79410
+ const queue = (action, payload) => new Promise((resolve6, reject) => {
78777
79411
  const job = createJob({ action, payload });
78778
79412
  jobQueue.push(async (w) => {
78779
79413
  jobQueue.shift();
78780
79414
  runningWorkers[w.id] = job;
78781
79415
  try {
78782
- resolve5(await w[action].apply(exports, [...payload, job.id]));
79416
+ resolve6(await w[action].apply(exports, [...payload, job.id]));
78783
79417
  } catch (err) {
78784
79418
  reject(err);
78785
79419
  } finally {
@@ -80913,7 +81547,7 @@ var require_lib3 = __commonJS((exports, module) => {
80913
81547
  let accum = [];
80914
81548
  let accumBytes = 0;
80915
81549
  let abort = false;
80916
- return new Body.Promise(function(resolve5, reject) {
81550
+ return new Body.Promise(function(resolve6, reject) {
80917
81551
  let resTimeout;
80918
81552
  if (_this4.timeout) {
80919
81553
  resTimeout = setTimeout(function() {
@@ -80947,7 +81581,7 @@ var require_lib3 = __commonJS((exports, module) => {
80947
81581
  }
80948
81582
  clearTimeout(resTimeout);
80949
81583
  try {
80950
- resolve5(Buffer.concat(accum, accumBytes));
81584
+ resolve6(Buffer.concat(accum, accumBytes));
80951
81585
  } catch (err) {
80952
81586
  reject(new FetchError(`Could not create Buffer from response body for ${_this4.url}: ${err.message}`, "system", err));
80953
81587
  }
@@ -81546,7 +82180,7 @@ var require_lib3 = __commonJS((exports, module) => {
81546
82180
  throw new Error("native promise missing, set fetch.Promise to your favorite alternative");
81547
82181
  }
81548
82182
  Body.Promise = fetch2.Promise;
81549
- return new fetch2.Promise(function(resolve5, reject) {
82183
+ return new fetch2.Promise(function(resolve6, reject) {
81550
82184
  const request3 = new Request3(url3, opts);
81551
82185
  const options = getNodeRequestOptions(request3);
81552
82186
  const send = (options.protocol === "https:" ? https : http).request;
@@ -81681,7 +82315,7 @@ var require_lib3 = __commonJS((exports, module) => {
81681
82315
  requestOpts.body = undefined;
81682
82316
  requestOpts.headers.delete("content-length");
81683
82317
  }
81684
- resolve5(fetch2(new Request3(locationURL, requestOpts)));
82318
+ resolve6(fetch2(new Request3(locationURL, requestOpts)));
81685
82319
  finalize2();
81686
82320
  return;
81687
82321
  }
@@ -81703,7 +82337,7 @@ var require_lib3 = __commonJS((exports, module) => {
81703
82337
  const codings = headers.get("Content-Encoding");
81704
82338
  if (!request3.compress || request3.method === "HEAD" || codings === null || res.statusCode === 204 || res.statusCode === 304) {
81705
82339
  response = new Response2(body, response_options);
81706
- resolve5(response);
82340
+ resolve6(response);
81707
82341
  return;
81708
82342
  }
81709
82343
  const zlibOptions = {
@@ -81713,7 +82347,7 @@ var require_lib3 = __commonJS((exports, module) => {
81713
82347
  if (codings == "gzip" || codings == "x-gzip") {
81714
82348
  body = body.pipe(zlib.createGunzip(zlibOptions));
81715
82349
  response = new Response2(body, response_options);
81716
- resolve5(response);
82350
+ resolve6(response);
81717
82351
  return;
81718
82352
  }
81719
82353
  if (codings == "deflate" || codings == "x-deflate") {
@@ -81725,12 +82359,12 @@ var require_lib3 = __commonJS((exports, module) => {
81725
82359
  body = body.pipe(zlib.createInflateRaw());
81726
82360
  }
81727
82361
  response = new Response2(body, response_options);
81728
- resolve5(response);
82362
+ resolve6(response);
81729
82363
  });
81730
82364
  raw.on("end", function() {
81731
82365
  if (!response) {
81732
82366
  response = new Response2(body, response_options);
81733
- resolve5(response);
82367
+ resolve6(response);
81734
82368
  }
81735
82369
  });
81736
82370
  return;
@@ -81738,11 +82372,11 @@ var require_lib3 = __commonJS((exports, module) => {
81738
82372
  if (codings == "br" && typeof zlib.createBrotliDecompress === "function") {
81739
82373
  body = body.pipe(zlib.createBrotliDecompress());
81740
82374
  response = new Response2(body, response_options);
81741
- resolve5(response);
82375
+ resolve6(response);
81742
82376
  return;
81743
82377
  }
81744
82378
  response = new Response2(body, response_options);
81745
- resolve5(response);
82379
+ resolve6(response);
81746
82380
  });
81747
82381
  writeToStream(req, request3);
81748
82382
  });
@@ -81819,7 +82453,7 @@ var require_loadImage = __commonJS((exports, module) => {
81819
82453
  var fs8 = __require("fs");
81820
82454
  var fetch2 = global.fetch || require_lib3();
81821
82455
  var isURL = require_is_url();
81822
- var readFile6 = util.promisify(fs8.readFile);
82456
+ var readFile7 = util.promisify(fs8.readFile);
81823
82457
  module.exports = async (image) => {
81824
82458
  let data = image;
81825
82459
  if (typeof image === "undefined") {
@@ -81832,7 +82466,7 @@ var require_loadImage = __commonJS((exports, module) => {
81832
82466
  } else if (/data:image\/([a-zA-Z]*);base64,([^"]*)/.test(image)) {
81833
82467
  data = Buffer.from(image.split(",")[1], "base64");
81834
82468
  } else {
81835
- data = await readFile6(image);
82469
+ data = await readFile7(image);
81836
82470
  }
81837
82471
  } else if (Buffer.isBuffer(image)) {
81838
82472
  data = image;
@@ -81892,8 +82526,8 @@ var require_createWorker = __commonJS((exports, module) => {
81892
82526
  const lstmOnlyCore = [OEM.DEFAULT, OEM.LSTM_ONLY].includes(oem) && !options.legacyCore;
81893
82527
  let workerResReject;
81894
82528
  let workerResResolve;
81895
- const workerRes = new Promise((resolve5, reject) => {
81896
- workerResResolve = resolve5;
82529
+ const workerRes = new Promise((resolve6, reject) => {
82530
+ workerResResolve = resolve6;
81897
82531
  workerResReject = reject;
81898
82532
  });
81899
82533
  const workerError = (event) => {
@@ -81902,10 +82536,10 @@ var require_createWorker = __commonJS((exports, module) => {
81902
82536
  let worker = spawnWorker(options);
81903
82537
  worker.onerror = workerError;
81904
82538
  workerCounter += 1;
81905
- const startJob = ({ id: jobId, action, payload }) => new Promise((resolve5, reject) => {
82539
+ const startJob = ({ id: jobId, action, payload }) => new Promise((resolve6, reject) => {
81906
82540
  log3(`[${id}]: Start ${jobId}, action=${action}`);
81907
82541
  const promiseId = `${action}-${jobId}`;
81908
- promises[promiseId] = { resolve: resolve5, reject };
82542
+ promises[promiseId] = { resolve: resolve6, reject };
81909
82543
  send(worker, {
81910
82544
  workerId: id,
81911
82545
  jobId,
@@ -82432,9 +83066,9 @@ function merge5(...objs) {
82432
83066
  }
82433
83067
  const targetKey = caseless && typeof key === "string" && findKey(result3, key) || key;
82434
83068
  const existing = hasOwnProperty(result3, targetKey) ? result3[targetKey] : undefined;
82435
- if (isPlainObject2(existing) && isPlainObject2(val)) {
83069
+ if (isPlainObject3(existing) && isPlainObject3(val)) {
82436
83070
  result3[targetKey] = merge5(existing, val);
82437
- } else if (isPlainObject2(val)) {
83071
+ } else if (isPlainObject3(val)) {
82438
83072
  result3[targetKey] = merge5({}, val);
82439
83073
  } else if (isArray2(val)) {
82440
83074
  result3[targetKey] = val.slice();
@@ -82537,7 +83171,7 @@ var toString2, getPrototypeOf, iterator, toStringTag, hasOwnProperty, isUnsafeOb
82537
83171
  }, kindOf, kindOfTest = (type) => {
82538
83172
  type = type.toLowerCase();
82539
83173
  return (thing) => kindOf(thing) === type;
82540
- }, typeOfTest = (type) => (thing) => typeof thing === type, isArray2, isUndefined2, isArrayBuffer, isString2, isFunction2, isNumber2, isObject3 = (thing) => thing !== null && typeof thing === "object", isBoolean = (thing) => thing === true || thing === false, isPlainObject2 = (val) => {
83174
+ }, typeOfTest = (type) => (thing) => typeof thing === type, isArray2, isUndefined2, isArrayBuffer, isString2, isFunction2, isNumber2, isObject3 = (thing) => thing !== null && typeof thing === "object", isBoolean = (thing) => thing === true || thing === false, isPlainObject3 = (val) => {
82541
83175
  if (!isObject3(val)) {
82542
83176
  return false;
82543
83177
  }
@@ -82813,7 +83447,7 @@ var init_utils = __esm(() => {
82813
83447
  isNumber: isNumber2,
82814
83448
  isBoolean,
82815
83449
  isObject: isObject3,
82816
- isPlainObject: isPlainObject2,
83450
+ isPlainObject: isPlainObject3,
82817
83451
  isEmptyObject,
82818
83452
  isReadableStream,
82819
83453
  isRequest,
@@ -94264,10 +94898,10 @@ var init_CanceledError = __esm(() => {
94264
94898
  });
94265
94899
 
94266
94900
  // ../../node_modules/.pnpm/axios@1.20.0/node_modules/axios/lib/core/settle.js
94267
- function settle(resolve5, reject, response) {
94901
+ function settle(resolve6, reject, response) {
94268
94902
  const validateStatus2 = response.config.validateStatus;
94269
94903
  if (!response.status || !validateStatus2 || validateStatus2(response.status)) {
94270
- resolve5(response);
94904
+ resolve6(response);
94271
94905
  } else {
94272
94906
  reject(new AxiosError_default("Request failed with status code " + response.status, response.status >= 400 && response.status < 500 ? AxiosError_default.ERR_BAD_REQUEST : AxiosError_default.ERR_BAD_RESPONSE, response.config, response.request, response));
94273
94907
  }
@@ -94430,12 +95064,12 @@ var require_promisify = __commonJS((exports) => {
94430
95064
  Object.defineProperty(exports, "__esModule", { value: true });
94431
95065
  function promisify2(fn3) {
94432
95066
  return function(req, opts) {
94433
- return new Promise((resolve5, reject) => {
95067
+ return new Promise((resolve6, reject) => {
94434
95068
  fn3.call(this, req, opts, (err, rtn) => {
94435
95069
  if (err) {
94436
95070
  reject(err);
94437
95071
  } else {
94438
- resolve5(rtn);
95072
+ resolve6(rtn);
94439
95073
  }
94440
95074
  });
94441
95075
  });
@@ -94629,7 +95263,7 @@ var require_parse_proxy_response = __commonJS((exports) => {
94629
95263
  var debug_1 = __importDefault(require_src2());
94630
95264
  var debug12 = debug_1.default("https-proxy-agent:parse-proxy-response");
94631
95265
  function parseProxyResponse(socket) {
94632
- return new Promise((resolve5, reject) => {
95266
+ return new Promise((resolve6, reject) => {
94633
95267
  let buffersLength = 0;
94634
95268
  const buffers = [];
94635
95269
  function read() {
@@ -94672,7 +95306,7 @@ var require_parse_proxy_response = __commonJS((exports) => {
94672
95306
  `));
94673
95307
  const statusCode = +firstLine.split(" ")[1];
94674
95308
  debug12("got proxy server response: %o", firstLine);
94675
- resolve5({
95309
+ resolve6({
94676
95310
  statusCode,
94677
95311
  buffered
94678
95312
  });
@@ -94690,11 +95324,11 @@ var require_parse_proxy_response = __commonJS((exports) => {
94690
95324
  var require_agent = __commonJS((exports) => {
94691
95325
  var __awaiter2 = exports && exports.__awaiter || function(thisArg, _arguments, P, generator) {
94692
95326
  function adopt(value2) {
94693
- return value2 instanceof P ? value2 : new P(function(resolve5) {
94694
- resolve5(value2);
95327
+ return value2 instanceof P ? value2 : new P(function(resolve6) {
95328
+ resolve6(value2);
94695
95329
  });
94696
95330
  }
94697
- return new (P || (P = Promise))(function(resolve5, reject) {
95331
+ return new (P || (P = Promise))(function(resolve6, reject) {
94698
95332
  function fulfilled(value2) {
94699
95333
  try {
94700
95334
  step(generator.next(value2));
@@ -94710,7 +95344,7 @@ var require_agent = __commonJS((exports) => {
94710
95344
  }
94711
95345
  }
94712
95346
  function step(result3) {
94713
- result3.done ? resolve5(result3.value) : adopt(result3.value).then(fulfilled, rejected);
95347
+ result3.done ? resolve6(result3.value) : adopt(result3.value).then(fulfilled, rejected);
94714
95348
  }
94715
95349
  step((generator = generator.apply(thisArg, _arguments || [])).next());
94716
95350
  });
@@ -96509,7 +97143,7 @@ var import_https_proxy_agent, import_follow_redirects, zlibOptions, brotliOption
96509
97143
  stream4.on("end", flush).on("error", flush);
96510
97144
  return throttled;
96511
97145
  }, http2Sessions, isHttpAdapterSupported, wrapAsync = (asyncExecutor) => {
96512
- return new Promise((resolve5, reject) => {
97146
+ return new Promise((resolve6, reject) => {
96513
97147
  let onDone;
96514
97148
  let isDone3;
96515
97149
  const done3 = (value2, isRejected) => {
@@ -96520,7 +97154,7 @@ var import_https_proxy_agent, import_follow_redirects, zlibOptions, brotliOption
96520
97154
  };
96521
97155
  const _resolve = (value2) => {
96522
97156
  done3(value2);
96523
- resolve5(value2);
97157
+ resolve6(value2);
96524
97158
  };
96525
97159
  const _reject = (reason) => {
96526
97160
  done3(reason, true);
@@ -96645,7 +97279,7 @@ var init_http = __esm(() => {
96645
97279
  }
96646
97280
  };
96647
97281
  http_default = isHttpAdapterSupported && function httpAdapter(config3) {
96648
- return wrapAsync(async function dispatchHttpRequest(resolve5, reject, onDone) {
97282
+ return wrapAsync(async function dispatchHttpRequest(resolve6, reject, onDone) {
96649
97283
  const own2 = (key) => utils_default.getSafeProp(config3, key);
96650
97284
  const transitional = own2("transitional") || transitional_default;
96651
97285
  let data = own2("data");
@@ -96756,7 +97390,7 @@ var init_http = __esm(() => {
96756
97390
  }
96757
97391
  let convertedData;
96758
97392
  if (method !== "GET") {
96759
- return settle(resolve5, reject, {
97393
+ return settle(resolve6, reject, {
96760
97394
  status: 405,
96761
97395
  statusText: "method not allowed",
96762
97396
  headers: {},
@@ -96778,7 +97412,7 @@ var init_http = __esm(() => {
96778
97412
  } else if (responseType === "stream") {
96779
97413
  convertedData = stream3.Readable.from(convertedData);
96780
97414
  }
96781
- return settle(resolve5, reject, {
97415
+ return settle(resolve6, reject, {
96782
97416
  data: convertedData,
96783
97417
  status: 200,
96784
97418
  statusText: "OK",
@@ -97050,7 +97684,7 @@ var init_http = __esm(() => {
97050
97684
  });
97051
97685
  }
97052
97686
  response.data = responseStream;
97053
- settle(resolve5, reject, response);
97687
+ settle(resolve6, reject, response);
97054
97688
  } else {
97055
97689
  const responseBuffer = [];
97056
97690
  let totalResponseBytes = 0;
@@ -97089,7 +97723,7 @@ var init_http = __esm(() => {
97089
97723
  } catch (err) {
97090
97724
  return reject(AxiosError_default.from(err, null, config3, response.request, response));
97091
97725
  }
97092
- settle(resolve5, reject, response);
97726
+ settle(resolve6, reject, response);
97093
97727
  });
97094
97728
  }
97095
97729
  abortEmitter.once("abort", (err) => {
@@ -97462,7 +98096,7 @@ var init_xhr = __esm(() => {
97462
98096
  init_sanitizeHeaderValue();
97463
98097
  isXHRAdapterSupported = typeof XMLHttpRequest !== "undefined";
97464
98098
  xhr_default = isXHRAdapterSupported && function(config3) {
97465
- return new Promise(function dispatchXhrRequest(resolve5, reject) {
98099
+ return new Promise(function dispatchXhrRequest(resolve6, reject) {
97466
98100
  const _config = resolveConfig_default(config3);
97467
98101
  let requestData = _config.data;
97468
98102
  const requestHeaders = AxiosHeaders_default.from(_config.headers).normalize();
@@ -97514,7 +98148,7 @@ var init_xhr = __esm(() => {
97514
98148
  request: request3
97515
98149
  };
97516
98150
  settle(function _resolve(value2) {
97517
- resolve5(value2);
98151
+ resolve6(value2);
97518
98152
  done3();
97519
98153
  }, function _reject(err) {
97520
98154
  reject(err);
@@ -98037,8 +98671,8 @@ var DEFAULT_CHUNK_SIZE, DEFAULT_REQUEST_OPTIONS, isFunction3, encodeUTF82 = (str
98037
98671
  }
98038
98672
  }
98039
98673
  !isStreamResponse && unsubscribe && unsubscribe();
98040
- return await new Promise((resolve5, reject) => {
98041
- settle(resolve5, reject, {
98674
+ return await new Promise((resolve6, reject) => {
98675
+ settle(resolve6, reject, {
98042
98676
  data: responseData,
98043
98677
  headers: AxiosHeaders_default.from(response.headers),
98044
98678
  status: response.status,
@@ -98512,8 +99146,8 @@ class CancelToken {
98512
99146
  throw new TypeError("executor must be a function.");
98513
99147
  }
98514
99148
  let resolvePromise;
98515
- this.promise = new Promise(function promiseExecutor(resolve5) {
98516
- resolvePromise = resolve5;
99149
+ this.promise = new Promise(function promiseExecutor(resolve6) {
99150
+ resolvePromise = resolve6;
98517
99151
  });
98518
99152
  const token = this;
98519
99153
  this.promise.then((cancel) => {
@@ -98527,9 +99161,9 @@ class CancelToken {
98527
99161
  });
98528
99162
  this.promise.then = (onfulfilled) => {
98529
99163
  let _resolve;
98530
- const promise4 = new Promise((resolve5) => {
98531
- token.subscribe(resolve5);
98532
- _resolve = resolve5;
99164
+ const promise4 = new Promise((resolve6) => {
99165
+ token.subscribe(resolve6);
99166
+ _resolve = resolve6;
98533
99167
  }).then(onfulfilled);
98534
99168
  promise4.cancel = function reject() {
98535
99169
  token.unsubscribe(_resolve);
@@ -99210,7 +99844,7 @@ function applyMarkupTags(markup, text) {
99210
99844
  // ../../node_modules/.pnpm/@llamaindex+liteparse@1.5.3/node_modules/@llamaindex/liteparse/dist/src/processing/gridDebugLogger.js
99211
99845
  import { mkdirSync as mkdirSync7, writeFileSync as writeFileSync4 } from "fs";
99212
99846
  import { mkdir as mkdir6, writeFile as writeFile6 } from "fs/promises";
99213
- import { dirname as dirname13 } from "path";
99847
+ import { dirname as dirname14 } from "path";
99214
99848
 
99215
99849
  class GridDebugLogger {
99216
99850
  config;
@@ -99537,14 +100171,14 @@ class GridDebugLogger {
99537
100171
  flushSync() {
99538
100172
  if (!this.config.outputPath || this.entries.length === 0)
99539
100173
  return;
99540
- mkdirSync7(dirname13(this.config.outputPath), { recursive: true });
100174
+ mkdirSync7(dirname14(this.config.outputPath), { recursive: true });
99541
100175
  writeFileSync4(this.config.outputPath, this.formatEntries(), "utf-8");
99542
100176
  this.entries = [];
99543
100177
  }
99544
100178
  async flush() {
99545
100179
  if (!this.config.outputPath || this.entries.length === 0)
99546
100180
  return;
99547
- await mkdir6(dirname13(this.config.outputPath), { recursive: true });
100181
+ await mkdir6(dirname14(this.config.outputPath), { recursive: true });
99548
100182
  await writeFile6(this.config.outputPath, this.formatEntries(), "utf-8");
99549
100183
  this.entries = [];
99550
100184
  }
@@ -101269,9 +101903,9 @@ class Deferred2 {
101269
101903
  constructor() {
101270
101904
  this.resolve = () => null;
101271
101905
  this.reject = () => null;
101272
- this.promise = new Promise((resolve5, reject) => {
101906
+ this.promise = new Promise((resolve6, reject) => {
101273
101907
  this.reject = reject;
101274
- this.resolve = resolve5;
101908
+ this.resolve = resolve6;
101275
101909
  });
101276
101910
  }
101277
101911
  }
@@ -103335,7 +103969,7 @@ function readByobReaderWithSignal(reader, buffer, signal) {
103335
103969
  return reader.read(buffer);
103336
103970
  }
103337
103971
  signal.throwIfAborted();
103338
- return new Promise((resolve5, reject) => {
103972
+ return new Promise((resolve6, reject) => {
103339
103973
  const cleanup = () => {
103340
103974
  signal.removeEventListener("abort", onAbort);
103341
103975
  };
@@ -103354,7 +103988,7 @@ function readByobReaderWithSignal(reader, buffer, signal) {
103354
103988
  try {
103355
103989
  const result3 = await reader.read(buffer);
103356
103990
  cleanup();
103357
- resolve5(result3);
103991
+ resolve6(result3);
103358
103992
  } catch (error51) {
103359
103993
  cleanup();
103360
103994
  reject(error51);
@@ -105225,7 +105859,7 @@ var init_file_type = __esm(() => {
105225
105859
  const { signal } = this.options;
105226
105860
  const normalizedSampleSize = normalizeSampleSize(sampleSize);
105227
105861
  signal?.throwIfAborted();
105228
- return new Promise((resolve5, reject) => {
105862
+ return new Promise((resolve6, reject) => {
105229
105863
  let isSettled = false;
105230
105864
  const cleanup = () => {
105231
105865
  readableStream.off("error", onError3);
@@ -105264,7 +105898,7 @@ var init_file_type = __esm(() => {
105264
105898
  settle2(reject, error51);
105265
105899
  }
105266
105900
  }
105267
- settle2(resolve5, outputStream);
105901
+ settle2(resolve6, outputStream);
105268
105902
  } catch (error51) {
105269
105903
  settle2(reject, error51);
105270
105904
  }
@@ -105298,7 +105932,7 @@ async function guessFileExtension(filePath) {
105298
105932
  return null;
105299
105933
  }
105300
105934
  async function executeCommand(command, args2, timeoutMs = 60000) {
105301
- return new Promise((resolve5, reject) => {
105935
+ return new Promise((resolve6, reject) => {
105302
105936
  const proc = spawn2(command, args2, {
105303
105937
  stdio: ["ignore", "pipe", "pipe"]
105304
105938
  });
@@ -105317,7 +105951,7 @@ async function executeCommand(command, args2, timeoutMs = 60000) {
105317
105951
  proc.on("close", (code2) => {
105318
105952
  clearTimeout(timeout3);
105319
105953
  if (code2 === 0) {
105320
- resolve5(stdout);
105954
+ resolve6(stdout);
105321
105955
  } else {
105322
105956
  reject(new Error(`Command failed with code ${code2}: ${stderr}`));
105323
105957
  }
@@ -105953,8 +106587,8 @@ var exports_parse_pdf = {};
105953
106587
  __export(exports_parse_pdf, {
105954
106588
  parsePdf: () => parsePdf
105955
106589
  });
105956
- import { access, readFile as readFile6, writeFile as writeFile7, mkdir as mkdir7, appendFile } from "node:fs/promises";
105957
- import { resolve as resolve5 } from "node:path";
106590
+ import { access, readFile as readFile7, writeFile as writeFile7, mkdir as mkdir7, appendFile } from "node:fs/promises";
106591
+ import { resolve as resolve6 } from "node:path";
105958
106592
  function isUrl(input) {
105959
106593
  return input.startsWith("http://") || input.startsWith("https://");
105960
106594
  }
@@ -105963,9 +106597,9 @@ function createDefaultDeps6() {
105963
106597
  fs: {
105964
106598
  access: (p) => access(p),
105965
106599
  mkdir: (p, opts) => mkdir7(p, opts).then(() => {}),
105966
- readFile: (p, enc) => readFile6(p, { encoding: enc }).then((b) => b.toString()),
106600
+ readFile: (p, enc) => readFile7(p, { encoding: enc }).then((b) => b.toString()),
105967
106601
  appendFile: (p, content) => appendFile(p, content),
105968
- readFileAsBuffer: (p) => readFile6(p),
106602
+ readFileAsBuffer: (p) => readFile7(p),
105969
106603
  writeFile: (p, content, enc) => writeFile7(p, content, enc)
105970
106604
  },
105971
106605
  parser: {
@@ -106011,7 +106645,7 @@ function createDefaultDeps6() {
106011
106645
  };
106012
106646
  }
106013
106647
  async function resolvePdfPath(input, workingDir, d) {
106014
- const absolutePath = resolve5(workingDir, input);
106648
+ const absolutePath = resolve6(workingDir, input);
106015
106649
  try {
106016
106650
  await d.fs.access(absolutePath);
106017
106651
  } catch {
@@ -107593,7 +108227,7 @@ function formatProofOfPrinciples() {
107593
108227
  var GAME_ASSET_RULES;
107594
108228
  var init_game_asset_designer_workflow = __esm(() => {
107595
108229
  GAME_ASSET_RULES = [
107596
- "Generate only with `chatroom generate-image --platform=fal`, using the CLI default model unless the brief names one.",
108230
+ "Generate only with `chatroom generate-image --platform=fal --model <Model>`, where <Model> is the brief's Model: `fal-ai/flux-2/flash` (FLUX 2 Flash), or `fal-ai/flux-2/flash/edit` with --input-image for reference edits.",
107597
108231
  "Process images only with `chatroom slice-image` and `chatroom remove-image-background`; no other tool, script, or remote service.",
107598
108232
  "A sheet is at most the brief's `Sheet grid` (default 2x2); a larger grid needs a user request quoted in the brief.",
107599
108233
  "Names come from looking at each tile, never from cell order or prompt order.",
@@ -107602,20 +108236,20 @@ var init_game_asset_designer_workflow = __esm(() => {
107602
108236
  "Mark `pass` or `fail` only with `measured` or `inspected` evidence (labels below).",
107603
108237
  "Run `<command> --help` before first use of `slice-image` or `remove-image-background`.",
107604
108238
  "Always pass `--trim` to `chatroom remove-image-background`; use `--trim-padding` only when the brief names a padding.",
107605
- "Positioned sheets use exact layout JSON for the model that supports it (currently `fal-ai/moss-image`): the layout goes in `--prompt`, and `image_size` must equal the canvas the coordinates use. Bboxes are `[y_min,x_min,y_max,x_max]` in pixels from the canvas centre, y down, x right. `enable_prompt_expansion` is false for positioned layouts. Use `--output-format png`. Never pass `--aspect-ratio` to moss. Do not add model-specific values that the brief does not name.",
107606
108239
  "If `generate-image` is missing, `FAL_API_KEY` is not set, or it fails, stop generation, deliver `spec only`, quote the exact error in Summary, and list it under Open questions. Do not retry in a loop.",
107607
108240
  "Do not install or run any remote tool, script, or skill, and do not fetch generator code.",
107608
108241
  "Never switch generators.",
107609
108242
  "Describe generated output as production-ready only when every checklist item for it passes with `measured` or `inspected` evidence.",
107610
108243
  "Commit only when the brief names the paths and the commit message.",
107611
- "Generate only when the brief names an output location and allowed tools."
108244
+ "Generate only when the brief names an output location and allowed tools.",
108245
+ "Before the first real call of each command shape (sheet, per-asset, or reference edit), run the same command with --dry-run and apply every constraint it prints; take model-specific constraints only from the dry run, never from memory."
107612
108246
  ];
107613
108247
  });
107614
108248
 
107615
108249
  // ../../services/backend/prompts/teams/game-asset-designer-handoff-templates.ts
107616
108250
  function getEntryPointToGameAssetDesignerHandoffTemplate(query) {
107617
108251
  const entryPoint = query.fromRole;
107618
- return `Instructions (not part of the message): Pass the asset request as a brief the designer can act on without guessing. Provide every field below; write \`Not specified.\` for a field you cannot fill and the designer will ask or apply a stated default. Give each asset a stable ID (\`A01\`, \`A02\`…). Use \`spec only\` only when you want a specification with no files; the default is \`spec and generate\`. The \`## Allowed tools\` value is fixed: \`chatroom generate-image --platform=fal (default model), chatroom slice-image, chatroom remove-image-background\`. Do not name any other generator.
108252
+ return `Instructions (not part of the message): Pass the asset request as a brief the designer can act on without guessing. Provide every field below; write \`Not specified.\` for a field you cannot fill and the designer will ask or apply a stated default. Give each asset a stable ID (\`A01\`, \`A02\`…). Use \`spec only\` only when you want a specification with no files; the default is \`spec and generate\`. The \`## Allowed tools\` value is fixed: \`chatroom generate-image --platform=fal --model <Model> (dry run first), chatroom slice-image, chatroom remove-image-background\`. Do not name any other generator.
107619
108253
 
107620
108254
  ## Asset request
107621
108255
  <one to three sentences: what the assets are for and the user-visible goal>
@@ -107632,11 +108266,14 @@ function getEntryPointToGameAssetDesignerHandoffTemplate(query) {
107632
108266
  ## Style reference
107633
108267
  <repository paths, URLs, or a written style sheet; or \`Not specified.\`>
107634
108268
 
108269
+ ## Perspective
108270
+ <one camera perspective shared by every asset in the set, for example \`orthographic front view\`, \`orthographic isometric\`, \`dimetric 2:1\`, or \`side view\`; optionally \`reference: <repository path>\` of an existing asset to match (requires \`## Model\` = \`fal-ai/flux-2/flash/edit\`); a reference makes every asset an individual edit, with no sheets; \`Not applicable.\` for 3D models and audio; or \`Not specified.\`>
108271
+
107635
108272
  ## Model
107636
- <the CLI default \`fal-ai/flux-2/flash\`, or \`fal-ai/moss-image\` when the brief names it>
108273
+ <\`fal-ai/flux-2/flash\` (FLUX 2 Flash), passed as --model; \`fal-ai/flux-2/flash/edit\` only when \`## Perspective\` names a reference asset>
107637
108274
 
107638
108275
  ## Model parameters
107639
- <a JSON object as text passed to \`generate-image --input\`; \`Not specified.\` if none>
108276
+ <a JSON object as text passed to \`generate-image --input\`; one object for every call of a set; its keys must pass the model's --dry-run check; \`Not specified.\` if none>
107640
108277
 
107641
108278
  ## Spec consumer
107642
108279
  <who integrates these assets from the spec: \`builder\` (application code) or \`user\`; asset files themselves are generated only by \`game-asset-designer\`>
@@ -107648,7 +108285,7 @@ function getEntryPointToGameAssetDesignerHandoffTemplate(query) {
107648
108285
  <\`spec and generate\` (default when you name an output location and allowed tools) or \`spec only\`>
107649
108286
 
107650
108287
  ## Allowed tools
107651
- \`chatroom generate-image --platform=fal (default model), chatroom slice-image, chatroom remove-image-background\`
108288
+ \`chatroom generate-image --platform=fal --model <Model> (dry run first), chatroom slice-image, chatroom remove-image-background\`
107652
108289
 
107653
108290
  ## Allowed edit paths
107654
108291
  <repository-relative paths the designer may edit; \`None.\` for none>
@@ -107708,7 +108345,7 @@ ${PROOF_OF_PRINCIPLES_REPORT}
107708
108345
  <each assumption you made and why; each deviation from the planner's target or budgets; or \`None.\`>
107709
108346
 
107710
108347
  ## Asset manifest
107711
- <one entry per asset, keyed by the planner's stable ID (\`A01\`…): name, category, file format, path (or \`Specified only.\`), dimensions/units/scale, pivot, naming, LOD list with triangle budgets, texture set with resolution, color space and channel packing, atlas/pixel grid/frame data, audio format and loudness target, import settings, dependencies and variants; for each budget, the acceptance check (exact command and expected value); for each generated file, the generator command line (\`chatroom generate-image\` with its \`--platform\`, \`--model\`, and \`--seed\` values), the sheet and tile manifests, and the isolated asset manifest path>
108348
+ <one entry per asset, keyed by the planner's stable ID (\`A01\`…): name, category, file format, path (or \`Specified only.\`), dimensions/units/scale, pivot, naming, LOD list with triangle budgets, texture set with resolution, color space and channel packing, atlas/pixel grid/frame data, audio format and loudness target, import settings, dependencies and variants; for each budget, the acceptance check (exact command and expected value); for each generated file, the generator command line (\`chatroom generate-image\` with its \`--platform\`, \`--model\`, \`--seed\`, \`--input\`, and \`--input-image\` values), the sheet and tile manifests, and the isolated asset manifest path>
107712
108349
 
107713
108350
  ## Quality checklist results
107714
108351
  <per asset: each applicable checklist item as \`pass\`, \`fail\`, \`n/a\`, or \`not checked\`, with its evidence label and, for \`measured\`, the command and value; write exactly \`None failed.\` after the list if no item failed>
@@ -109660,7 +110297,7 @@ P1 Recover the brief. IF engine, tier, style, or budgets are missing and the rep
109660
110297
  P2 Inspect assets, names, folders, engine config; cite paths.
109661
110298
  P3 Classify each asset; one manifest entry per ID (\`A01\`…).
109662
110299
  P4 IF \`Deliverable mode\` = \`spec only\` OR \`Output location\`/\`Allowed tools\` missing/ambiguous THEN no files, deliver \`Specified only.\`, GOTO P10.
109663
- P5 Count N. IF N=1 or styles differ THEN per-asset \`generate-image\`, GOTO P8. ELSE use ceil(N / (C×R)) sheets of ≤(C×R) items per \`Sheet grid\` (2x2 default). Prompt: one item per cell, CxR grid, no lines/borders/frames/duplicates. Generate \`generate-image --platform=fal --prompt "<prompt>" --out <Output location>/_work/<sheet>.png\`. IF \`## Model\` = \`fal-ai/moss-image\` THEN follow R10: layout JSON in \`--prompt\`, \`--input\` \`{image_size:{width:W,height:H},enable_prompt_expansion:false}\` plus \`## Model parameters\`, \`--model fal-ai/moss-image --output-format png\`; ELSE default.
110300
+ P5 Count N. IF N=1 or styles differ THEN per-asset \`generate-image\`, GOTO P8. ELSE use ceil(N / (C×R)) sheets of ≤(C×R) items per \`Sheet grid\` (2x2 default). Prompt: one item per cell, CxR grid, no lines/borders/frames/duplicates. Generate \`generate-image --platform=fal --model <Model> --prompt "<prompt>" --out <Output location>/_work/<sheet>.png\`.
109664
110301
  P6 \`chatroom slice-image --in <sheet> --out-dir <Output location>/_work/tiles --cols C --rows R\`. IF refused regenerate once; IF still refused one \`generate-image\` per asset (P5).
109665
110302
  P7 View each tile. IF any tile has 0/2+ items, a cut item, or count differs from the brief's requested count (extra cells OK) THEN regenerate once; IF still bad THEN one \`generate-image\` per asset (P5). Name from sight.
109666
110303
  P8 IF \`remove-image-background --help\` succeeds THEN run \`remove-image-background --in-dir <tiles> --out-dir <Output location> --map <stem>=<name>,... --trim\` (single: \`--in <image> --out <Output location>/<name>.png --trim\`); view results. IF warnings/halo THEN rerun with \`--tolerance\`/\`--force\` max twice, ELSE accept. ELSE rerun \`slice-image --names\`; record trimming not delivered as a failed item/open question.
@@ -109699,11 +110336,20 @@ P11 Hand off to \`{ENTRY_POINT_ROLE}\`, then stop.
109699
110336
  - Animation: uniform frame size per clip, frame count, frame rate, loop flag, and pivot per clip.
109700
110337
  - Atlas: padding of at least the engine default (Unity default 4 px), atlas size within the platform max, filter mode Point for pixel art and no mip maps.
109701
110338
  - Export PNG (lossless with alpha); name states size and frame count where relevant.
110339
+ - Camera perspective matches the perspective chosen for the set (the brief's \`Perspective\`, or the one recorded under assumptions) and every other asset in the set (compare them side by side); \`n/a\` for a single asset.
109702
110340
 
109703
110341
  **Audio**
109704
110342
  - Loudness measured against the platform target stated in the request (for example console -24 LUFS, mobile -18 LUFS, true peak at or below -1 dBTP); no clipping. Measure with a tool: \`ffmpeg -i <file> -af ebur128=peak=true -f null -\` for integrated loudness and true peak; \`ffprobe <file>\` for sample rate, bit depth and channels; for glTF, \`gltf-transform inspect <file>\` (quote the command's actual output). Cite the platform source. If the request does not state the target, mark the loudness target \`unverified\` and name the source. Mobile targets vary (-18 vs -16 LUFS).
109705
110343
  - Sample rate, bit depth, channel count, loop points, and format stated; short noisy SFX use PCM or ADPCM, long audio uses compressed or streamed formats, per the engine's guidance.
109706
110344
 
110345
+ ### Perspective consistency (generated 2D sets)
110346
+ Assets used together must share one camera perspective. The model's constraints (unsupported parameters, size defaults, what it does not guarantee) come only from \`generate-image --dry-run\` (R16); apply them, and never add a parameter the dry run reports as unsupported.
110347
+ - Repeat the perspective term from the brief's \`Perspective\` word for word in every prompt of the set (never the \`reference:\` path), and add the same flattening terms to every prompt: \`flat 2D game asset, orthographic, centered, plain background, even lighting\`. Suggested perspective terms (\`unverified\`): side view, front view, orthographic top-down, orthographic isometric, dimetric 2:1, three-quarter view. If the field names only a reference, describe that reference's view in words and record the description under assumptions. If \`Perspective\` is \`Not specified.\`, pick one, record it under assumptions, and use it for the whole set. If the \`Style reference\` asks for a lighting style these terms contradict (for example dramatic lighting), keep the perspective term and drop only the conflicting flattening term.
110348
+ - Use one \`--input\` JSON (from \`Model parameters\`) on every call of the set; if the dry run reports a size parameter as defaulted, set it once in that JSON and reuse it. Add \`--input '<JSON>'\` and the seed to every P5 command.
110349
+ - Use one shared \`--seed\` for the first call of each item or sheet. For every regeneration (P6, P7, or a perspective mismatch), use a new seed and record it (P9). A shared seed does not keep perspective across different prompts.
110350
+ - Pass \`--input-image <path>\` with \`--model fal-ai/flux-2/flash/edit\` only when the brief's \`Model\` is \`fal-ai/flux-2/flash/edit\` and \`Perspective\` names a reference path. In this mode generate every asset individually (the P5 per-asset path, one \`--input-image\` per asset); never use a sheet.
110351
+ - Inspect the set side by side. A mismatched item is regenerated individually (the P5 per-asset path, with a new seed), at most twice per item, separately from the sheet regenerations of P6 and P7. If it still differs, mark the perspective checklist item \`fail\` with \`inspected\` evidence.
110352
+
109707
110353
  ### Scope boundary
109708
110354
  You may specify, name, organize, generate, validate, and integrate assets within the paths the brief allows. You must not claim fidelity you did not establish. If you cannot open or measure a file, write \`unverified\`. Do not present alternative art directions beyond what the request needs; recommend one.
109709
110355
 
@@ -118639,7 +119285,7 @@ function parseYaml(text) {
118639
119285
  }
118640
119286
  }
118641
119287
  function validateFields(data, body) {
118642
- if (!isPlainObject3(data))
119288
+ if (!isPlainObject4(data))
118643
119289
  return fail6("invalid-frontmatter", "frontmatter is not a mapping");
118644
119290
  const name = data.name;
118645
119291
  if (!isValidName(name))
@@ -118649,7 +119295,7 @@ function validateFields(data, body) {
118649
119295
  return fail6("invalid-description");
118650
119296
  return { ok: true, name, description, body };
118651
119297
  }
118652
- function isPlainObject3(value2) {
119298
+ function isPlainObject4(value2) {
118653
119299
  return typeof value2 === "object" && value2 !== null && !Array.isArray(value2);
118654
119300
  }
118655
119301
  function isValidName(value2) {
@@ -118669,7 +119315,7 @@ var init_parse_skill_file = __esm(() => {
118669
119315
  });
118670
119316
 
118671
119317
  // src/infrastructure/external-skills/discover-external-skills.ts
118672
- import { lstat as lstat2, readdir as readdir2, readFile as readFile8, realpath, stat as stat6 } from "node:fs/promises";
119318
+ import { lstat as lstat2, readdir as readdir2, readFile as readFile9, realpath, stat as stat6 } from "node:fs/promises";
118673
119319
  import os2 from "node:os";
118674
119320
  import { join as join20 } from "node:path";
118675
119321
  function errorCode(err) {
@@ -118777,7 +119423,7 @@ async function isSymlink2(path3) {
118777
119423
  }
118778
119424
  async function readSkillFile(sourcePath, issues) {
118779
119425
  try {
118780
- return await readFile8(join20(sourcePath, SKILL_FILE_NAME), "utf8");
119426
+ return await readFile9(join20(sourcePath, SKILL_FILE_NAME), "utf8");
118781
119427
  } catch (err) {
118782
119428
  issues.push(issue2(sourcePath, "unreadable", errorCode(err)));
118783
119429
  return;
@@ -120637,10 +121283,10 @@ var init_durable_fifo_queue_schema = __esm(() => {
120637
121283
 
120638
121284
  // src/daemon/infrastructure/outbox/lib/durable-fifo-queue-store.ts
120639
121285
  import { mkdirSync as mkdirSync9 } from "node:fs";
120640
- import { dirname as dirname14 } from "node:path";
121286
+ import { dirname as dirname15 } from "node:path";
120641
121287
  import { DatabaseSync as DatabaseSync3 } from "node:sqlite";
120642
121288
  function openDurableFifoQueueStore(dbPath) {
120643
- mkdirSync9(dirname14(dbPath), { recursive: true });
121289
+ mkdirSync9(dirname15(dbPath), { recursive: true });
120644
121290
  const db = new DatabaseSync3(dbPath);
120645
121291
  for (const sql of DURABLE_FIFO_QUEUE_MIGRATIONS)
120646
121292
  db.exec(sql);
@@ -120841,9 +121487,9 @@ function createFifoBatchedOutbox(o) {
120841
121487
  const enqueue = async (item) => {
120842
121488
  persist(item);
120843
121489
  };
120844
- const enqueueAndWait = (item) => new Promise((resolve7, reject) => {
121490
+ const enqueueAndWait = (item) => new Promise((resolve8, reject) => {
120845
121491
  const id = persist(item);
120846
- waiters.set(id, { resolve: resolve7, reject });
121492
+ waiters.set(id, { resolve: resolve8, reject });
120847
121493
  });
120848
121494
  const flushNow = async () => {
120849
121495
  if (stopped)
@@ -121268,7 +121914,7 @@ var init_orphan_tracker = __esm(() => {
121268
121914
  });
121269
121915
 
121270
121916
  // src/daemon/entry/handlers/process/output-store.ts
121271
- import { appendFile as appendFile2, mkdir as mkdir10, readFile as readFile9, rm as rm2 } from "node:fs/promises";
121917
+ import { appendFile as appendFile2, mkdir as mkdir10, readFile as readFile10, rm as rm2 } from "node:fs/promises";
121272
121918
  import { tmpdir } from "node:os";
121273
121919
  import { join as join23 } from "node:path";
121274
121920
 
@@ -121301,7 +121947,7 @@ class TempFileOutputStore {
121301
121947
  async getLastNLines(maxLines) {
121302
121948
  let source;
121303
121949
  try {
121304
- source = await readFile9(this.state.filePath, "utf-8");
121950
+ source = await readFile10(this.state.filePath, "utf-8");
121305
121951
  } catch {
121306
121952
  source = this.state.inMemory;
121307
121953
  }
@@ -121318,7 +121964,7 @@ class TempFileOutputStore {
121318
121964
  }
121319
121965
  async getFullOutput() {
121320
121966
  try {
121321
- return await readFile9(this.state.filePath, "utf-8");
121967
+ return await readFile10(this.state.filePath, "utf-8");
121322
121968
  } catch {
121323
121969
  return this.state.inMemory;
121324
121970
  }
@@ -121471,10 +122117,10 @@ var init_durable_coalescing_state_schema = __esm(() => {
121471
122117
 
121472
122118
  // src/daemon/infrastructure/outbox/lib/durable-coalescing-state-store.ts
121473
122119
  import { mkdirSync as mkdirSync10 } from "node:fs";
121474
- import { dirname as dirname15 } from "node:path";
122120
+ import { dirname as dirname16 } from "node:path";
121475
122121
  import { DatabaseSync as DatabaseSync4 } from "node:sqlite";
121476
122122
  function openDurableCoalescingStateStore(path3) {
121477
- mkdirSync10(dirname15(path3), { recursive: true });
122123
+ mkdirSync10(dirname16(path3), { recursive: true });
121478
122124
  const db = new DatabaseSync4(path3);
121479
122125
  for (const sql of DURABLE_COALESCING_STATE_MIGRATIONS)
121480
122126
  db.exec(sql);
@@ -121624,8 +122270,8 @@ function createCoalescingStateOutbox(options) {
121624
122270
  const enqueue = async (state) => {
121625
122271
  accept(state);
121626
122272
  };
121627
- const enqueueAndWait = (state) => new Promise((resolve7, reject) => {
121628
- accept(state, { resolve: resolve7, reject });
122273
+ const enqueueAndWait = (state) => new Promise((resolve8, reject) => {
122274
+ accept(state, { resolve: resolve8, reject });
121629
122275
  });
121630
122276
  const flushNow = async () => {
121631
122277
  if (stopped)
@@ -122948,7 +123594,7 @@ var init_workspace_visibility_policy = __esm(() => {
122948
123594
 
122949
123595
  // src/infrastructure/services/workspace/workspace-ignore.ts
122950
123596
  import { promises as fsPromises } from "node:fs";
122951
- import { readFile as readFile10 } from "node:fs/promises";
123597
+ import { readFile as readFile11 } from "node:fs/promises";
122952
123598
  import { homedir as homedir11 } from "node:os";
122953
123599
  import path3 from "node:path";
122954
123600
  function normalizeRelativePath(relativePath) {
@@ -123013,7 +123659,7 @@ async function loadGitExtraExcludeRuleSets(rootDir) {
123013
123659
  }
123014
123660
  async function readIgnoreFile(filePath) {
123015
123661
  try {
123016
- return await readFile10(filePath, "utf-8");
123662
+ return await readFile11(filePath, "utf-8");
123017
123663
  } catch {
123018
123664
  return null;
123019
123665
  }
@@ -123250,7 +123896,7 @@ function enqueueGit(cwd, task) {
123250
123896
  }
123251
123897
  function runCommandSpawn(command, args2, cwd, options) {
123252
123898
  const successExitCodes = options?.successExitCodes ?? [0];
123253
- return new Promise((resolve7) => {
123899
+ return new Promise((resolve8) => {
123254
123900
  const child = spawn3(command, args2, {
123255
123901
  cwd,
123256
123902
  env: options?.env ?? DEFAULT_GIT_ENV,
@@ -123276,9 +123922,9 @@ function runCommandSpawn(command, args2, cwd, options) {
123276
123922
  if (timer)
123277
123923
  clearTimeout(timer);
123278
123924
  if (successExitCodes.includes(code2 ?? -1))
123279
- resolve7({ stdout, stderr });
123925
+ resolve8({ stdout, stderr });
123280
123926
  else {
123281
- resolve7({
123927
+ resolve8({
123282
123928
  error: Object.assign(new Error(stderr || stdout || `exit ${code2}`), {
123283
123929
  code: code2 ?? undefined
123284
123930
  })
@@ -123288,7 +123934,7 @@ function runCommandSpawn(command, args2, cwd, options) {
123288
123934
  child.on("error", (err) => {
123289
123935
  if (timer)
123290
123936
  clearTimeout(timer);
123291
- resolve7({ error: err });
123937
+ resolve8({ error: err });
123292
123938
  });
123293
123939
  });
123294
123940
  }
@@ -124170,9 +124816,9 @@ var init_readdirp = __esm(() => {
124170
124816
  return { files, depth, path: path6 };
124171
124817
  }
124172
124818
  _formatEntry(dirent, path6) {
124173
- const basename4 = this._isDirent ? dirent.name : dirent;
124174
- const fullPath = pjoin(path6, basename4);
124175
- const entry = { path: fullPath.slice(this._relStart), fullPath, basename: basename4 };
124819
+ const basename5 = this._isDirent ? dirent.name : dirent;
124820
+ const fullPath = pjoin(path6, basename5);
124821
+ const entry = { path: fullPath.slice(this._relStart), fullPath, basename: basename5 };
124176
124822
  if (this._isDirent) {
124177
124823
  entry.dirent = dirent;
124178
124824
  return entry;
@@ -124268,9 +124914,9 @@ class NodeFsHandler {
124268
124914
  _watchWithNodeFs(path6, listener) {
124269
124915
  const opts = this.fsw.options;
124270
124916
  const directory = sp.dirname(path6);
124271
- const basename5 = sp.basename(path6);
124917
+ const basename6 = sp.basename(path6);
124272
124918
  const parent = this.fsw._getWatchedDir(directory);
124273
- parent.add(basename5);
124919
+ parent.add(basename6);
124274
124920
  const absolutePath = sp.resolve(path6);
124275
124921
  const options = {
124276
124922
  persistent: opts.persistent
@@ -124280,7 +124926,7 @@ class NodeFsHandler {
124280
124926
  let closer;
124281
124927
  if (opts.usePolling) {
124282
124928
  const enableBin = opts.interval !== opts.binaryInterval;
124283
- options.interval = enableBin && isBinaryPath(basename5) ? opts.binaryInterval : opts.interval;
124929
+ options.interval = enableBin && isBinaryPath(basename6) ? opts.binaryInterval : opts.interval;
124284
124930
  closer = setFsWatchFileListener(path6, absolutePath, options, {
124285
124931
  listener,
124286
124932
  rawEmitter: this.fsw._emitRaw
@@ -124298,11 +124944,11 @@ class NodeFsHandler {
124298
124944
  if (this.fsw.closed) {
124299
124945
  return;
124300
124946
  }
124301
- const dirname17 = sp.dirname(file2);
124302
- const basename5 = sp.basename(file2);
124303
- const parent = this.fsw._getWatchedDir(dirname17);
124947
+ const dirname18 = sp.dirname(file2);
124948
+ const basename6 = sp.basename(file2);
124949
+ const parent = this.fsw._getWatchedDir(dirname18);
124304
124950
  let prevStats = stats;
124305
- if (parent.has(basename5))
124951
+ if (parent.has(basename6))
124306
124952
  return;
124307
124953
  const listener = async (path6, newStats) => {
124308
124954
  if (!this.fsw._throttle(THROTTLE_MODE_WATCH, file2, 5))
@@ -124327,9 +124973,9 @@ class NodeFsHandler {
124327
124973
  prevStats = newStats2;
124328
124974
  }
124329
124975
  } catch (error51) {
124330
- this.fsw._remove(dirname17, basename5);
124976
+ this.fsw._remove(dirname18, basename6);
124331
124977
  }
124332
- } else if (parent.has(basename5)) {
124978
+ } else if (parent.has(basename6)) {
124333
124979
  const at = newStats.atimeMs;
124334
124980
  const mt = newStats.mtimeMs;
124335
124981
  if (!at || at <= mt || mt !== prevStats.mtimeMs) {
@@ -124416,7 +125062,7 @@ class NodeFsHandler {
124416
125062
  this._addToNodeFs(path6, initialAdd, wh, depth + 1);
124417
125063
  }
124418
125064
  }).on(EV.ERROR, this._boundHandleError);
124419
- return new Promise((resolve8, reject) => {
125065
+ return new Promise((resolve9, reject) => {
124420
125066
  if (!stream4)
124421
125067
  return reject();
124422
125068
  stream4.once(STR_END, () => {
@@ -124425,7 +125071,7 @@ class NodeFsHandler {
124425
125071
  return;
124426
125072
  }
124427
125073
  const wasThrottled = throttler ? throttler.clear() : false;
124428
- resolve8(undefined);
125074
+ resolve9(undefined);
124429
125075
  previous.getChildren().filter((item) => {
124430
125076
  return item !== directory && !current.has(item);
124431
125077
  }).forEach((item) => {
@@ -125643,8 +126289,8 @@ function createWorkspaceFsWatcher(options) {
125643
126289
  awaitWriteFinish: { stabilityThreshold: 150, pollInterval: 25 }
125644
126290
  });
125645
126291
  watcher.on("add", (filePath) => enqueue("add", filePath)).on("addDir", (filePath) => enqueue("addDir", filePath)).on("change", (filePath) => enqueue("change", filePath)).on("unlink", (filePath) => enqueue("unlink", filePath)).on("unlinkDir", (filePath) => enqueue("unlinkDir", filePath)).on("error", (error51) => options.onError?.(error51));
125646
- const ready = new Promise((resolve9) => {
125647
- watcher.once("ready", resolve9);
126292
+ const ready = new Promise((resolve10) => {
126293
+ watcher.once("ready", resolve10);
125648
126294
  });
125649
126295
  return {
125650
126296
  ready,
@@ -127608,8 +128254,8 @@ function parseMakefileTargets(content) {
127608
128254
  var MAX_NAME_LENGTH2 = 256;
127609
128255
 
127610
128256
  // src/infrastructure/services/workspace/workspace-resolver.ts
127611
- import { readFile as readFile12, readdir as readdir5, stat as stat10 } from "node:fs/promises";
127612
- import { join as join28, basename as basename6, resolve as resolve9 } from "node:path";
128257
+ import { readFile as readFile13, readdir as readdir5, stat as stat10 } from "node:fs/promises";
128258
+ import { join as join28, basename as basename7, resolve as resolve10 } from "node:path";
127613
128259
  async function resolveGlobPatternStar(rootDir, cleaned) {
127614
128260
  const parentDir2 = join28(rootDir, cleaned.slice(0, -2));
127615
128261
  try {
@@ -127619,7 +128265,7 @@ async function resolveGlobPatternStar(rootDir, cleaned) {
127619
128265
  if (!entry.isDirectory())
127620
128266
  continue;
127621
128267
  const dirPath = join28(parentDir2, entry.name);
127622
- if (resolve9(dirPath).startsWith(resolve9(rootDir))) {
128268
+ if (resolve10(dirPath).startsWith(resolve10(rootDir))) {
127623
128269
  dirs.push(dirPath);
127624
128270
  }
127625
128271
  }
@@ -127631,7 +128277,7 @@ async function resolveGlobPatternStar(rootDir, cleaned) {
127631
128277
  async function resolveLiteralPath(rootDir, cleaned) {
127632
128278
  const dir = join28(rootDir, cleaned);
127633
128279
  try {
127634
- if (!resolve9(dir).startsWith(resolve9(rootDir)))
128280
+ if (!resolve10(dir).startsWith(resolve10(rootDir)))
127635
128281
  return [];
127636
128282
  const s = await stat10(dir);
127637
128283
  if (s.isDirectory())
@@ -127649,10 +128295,10 @@ async function resolveGlobPattern(rootDir, pattern) {
127649
128295
  }
127650
128296
  async function readPackageJson(dir) {
127651
128297
  try {
127652
- const content = await readFile12(join28(dir, "package.json"), "utf-8");
128298
+ const content = await readFile13(join28(dir, "package.json"), "utf-8");
127653
128299
  const pkg = JSON.parse(content);
127654
128300
  return {
127655
- name: pkg.name || basename6(dir),
128301
+ name: pkg.name || basename7(dir),
127656
128302
  scripts: pkg.scripts && typeof pkg.scripts === "object" ? pkg.scripts : {}
127657
128303
  };
127658
128304
  } catch {
@@ -127661,7 +128307,7 @@ async function readPackageJson(dir) {
127661
128307
  }
127662
128308
  async function readPnpmWorkspacePatterns(rootDir) {
127663
128309
  try {
127664
- const content = await readFile12(join28(rootDir, "pnpm-workspace.yaml"), "utf-8");
128310
+ const content = await readFile13(join28(rootDir, "pnpm-workspace.yaml"), "utf-8");
127665
128311
  const patterns = [];
127666
128312
  let inPackages = false;
127667
128313
  for (const line of content.split(`
@@ -127688,7 +128334,7 @@ async function readPnpmWorkspacePatterns(rootDir) {
127688
128334
  }
127689
128335
  async function readPackageJsonWorkspacePatterns(rootDir) {
127690
128336
  try {
127691
- const content = await readFile12(join28(rootDir, "package.json"), "utf-8");
128337
+ const content = await readFile13(join28(rootDir, "package.json"), "utf-8");
127692
128338
  const pkg = JSON.parse(content);
127693
128339
  if (!pkg.workspaces)
127694
128340
  return [];
@@ -127736,8 +128382,8 @@ async function resolveSubWorkspaces(rootDir, pm) {
127736
128382
  var init_workspace_resolver = () => {};
127737
128383
 
127738
128384
  // src/infrastructure/services/workspace/command-discovery.ts
127739
- import { access as access2, readFile as readFile13 } from "node:fs/promises";
127740
- import { join as join29, relative as relative3, basename as basename7 } from "node:path";
128385
+ import { access as access2, readFile as readFile14 } from "node:fs/promises";
128386
+ import { join as join29, relative as relative3, basename as basename8 } from "node:path";
127741
128387
  async function detectPackageManager(workingDir) {
127742
128388
  for (const { file: file2, manager } of LOCKFILE_MAP) {
127743
128389
  try {
@@ -127785,7 +128431,7 @@ function isValidScriptEntry(name, script) {
127785
128431
  }
127786
128432
  async function readJsonFile(filePath, label) {
127787
128433
  try {
127788
- const content = await readFile13(filePath, "utf-8");
128434
+ const content = await readFile14(filePath, "utf-8");
127789
128435
  return parseJsonc2(content);
127790
128436
  } catch (error51) {
127791
128437
  if (error51.code !== "ENOENT") {
@@ -127809,7 +128455,7 @@ function collectRootScriptCommands(scripts, pm, scriptPrefix, rootSw) {
127809
128455
  return commands;
127810
128456
  }
127811
128457
  async function readRootPackageJson(workingDir, pm, scriptPrefix) {
127812
- let rootPackageName = basename7(workingDir);
128458
+ let rootPackageName = basename8(workingDir);
127813
128459
  const pkg = await readJsonFile(join29(workingDir, "package.json"), "root package.json");
127814
128460
  if (!pkg)
127815
128461
  return { commands: [], rootPackageName };
@@ -127842,7 +128488,7 @@ async function readDenoJson(workingDir) {
127842
128488
  const deno = await readJsonFile(join29(workingDir, fileName), fileName);
127843
128489
  if (!deno?.tasks || typeof deno.tasks !== "object")
127844
128490
  continue;
127845
- const pkgName = deno.name ?? basename7(workingDir);
128491
+ const pkgName = deno.name ?? basename8(workingDir);
127846
128492
  const subWorkspace = { type: "deno", path: ".", name: pkgName };
127847
128493
  for (const [taskName, taskCommand] of Object.entries(deno.tasks)) {
127848
128494
  if (!isValidScriptEntry(taskName, taskCommand))
@@ -127862,14 +128508,14 @@ async function readMakefile(workingDir) {
127862
128508
  const commands = [];
127863
128509
  for (const fileName of ["Makefile", "makefile"]) {
127864
128510
  try {
127865
- const content = await readFile13(join29(workingDir, fileName), "utf-8");
128511
+ const content = await readFile14(join29(workingDir, fileName), "utf-8");
127866
128512
  const targets = parseMakefileTargets(content);
127867
128513
  if (targets.length === 0)
127868
128514
  continue;
127869
128515
  const subWorkspace = {
127870
128516
  type: "make",
127871
128517
  path: ".",
127872
- name: basename7(workingDir)
128518
+ name: basename8(workingDir)
127873
128519
  };
127874
128520
  for (const target of targets) {
127875
128521
  commands.push({
@@ -129455,7 +130101,7 @@ function createDefaultDeps22() {
129455
130101
  },
129456
130102
  clock: {
129457
130103
  now: () => Date.now(),
129458
- delay: (ms) => new Promise((resolve10) => setTimeout(resolve10, ms))
130104
+ delay: (ms) => new Promise((resolve11) => setTimeout(resolve11, ms))
129459
130105
  },
129460
130106
  spawning: new HarnessSpawningService({ rateLimiter: new SpawnRateLimiter }),
129461
130107
  agentProcessManager: null
@@ -130952,14 +131598,14 @@ var init_sse_event_buffer = __esm(() => {
130952
131598
  }
130953
131599
  _wake() {
130954
131600
  if (this._waiter) {
130955
- const resolve10 = this._waiter;
131601
+ const resolve11 = this._waiter;
130956
131602
  this._waiter = null;
130957
- resolve10();
131603
+ resolve11();
130958
131604
  }
130959
131605
  }
130960
131606
  _waitForData() {
130961
- return new Promise((resolve10) => {
130962
- this._waiter = resolve10;
131607
+ return new Promise((resolve11) => {
131608
+ this._waiter = resolve11;
130963
131609
  });
130964
131610
  }
130965
131611
  [Symbol.asyncIterator]() {
@@ -131030,8 +131676,8 @@ class OpencodeSdkSession {
131030
131676
  async prompt(input) {
131031
131677
  if (this.closed)
131032
131678
  throw new Error("Session is closed");
131033
- const turnPromise = new Promise((resolve10, reject) => {
131034
- this._turnDoneResolve = resolve10;
131679
+ const turnPromise = new Promise((resolve11, reject) => {
131680
+ this._turnDoneResolve = resolve11;
131035
131681
  this._turnDoneReject = reject;
131036
131682
  });
131037
131683
  turnPromise.catch(() => {});
@@ -131379,14 +132025,14 @@ class OpencodeSdkHarness {
131379
132025
  }
131380
132026
  this.sessionListeners.clear();
131381
132027
  this.childProcess.kill("SIGTERM");
131382
- await new Promise((resolve10) => {
132028
+ await new Promise((resolve11) => {
131383
132029
  const timeout3 = setTimeout(() => {
131384
132030
  this.childProcess.kill("SIGKILL");
131385
- resolve10();
132031
+ resolve11();
131386
132032
  }, 5000);
131387
132033
  this.childProcess.once("exit", () => {
131388
132034
  clearTimeout(timeout3);
131389
- resolve10();
132035
+ resolve11();
131390
132036
  });
131391
132037
  });
131392
132038
  }
@@ -132278,10 +132924,10 @@ class BufferedJournalFactory {
132278
132924
  const waitForInProgress = () => {
132279
132925
  if (!flushInProgress)
132280
132926
  return Promise.resolve();
132281
- return new Promise((resolve10) => {
132927
+ return new Promise((resolve11) => {
132282
132928
  const check2 = () => {
132283
132929
  if (!flushInProgress)
132284
- resolve10();
132930
+ resolve11();
132285
132931
  else
132286
132932
  setTimeout(check2, 10);
132287
132933
  };
@@ -132507,7 +133153,7 @@ async function emitPhase(deps, event, phase, detail) {
132507
133153
  }, now));
132508
133154
  }
132509
133155
  function sleep5(ms) {
132510
- return new Promise((resolve10) => setTimeout(resolve10, ms));
133156
+ return new Promise((resolve11) => setTimeout(resolve11, ms));
132511
133157
  }
132512
133158
  async function waitForHarnessSessionId2(deps, event) {
132513
133159
  const initial = deps.agentMgr.getSlot(event.chatroomId, event.role, event.workingDir);
@@ -132876,19 +133522,19 @@ class ProcessManager {
132876
133522
  this.pendingStops.clear();
132877
133523
  }
132878
133524
  waitForExit(runId, ms) {
132879
- return new Promise((resolve10) => {
133525
+ return new Promise((resolve11) => {
132880
133526
  const interval = 100;
132881
133527
  let elapsed = 0;
132882
133528
  const timer = setInterval(() => {
132883
133529
  if (!this.runningProcesses.has(runId)) {
132884
133530
  clearInterval(timer);
132885
- resolve10(true);
133531
+ resolve11(true);
132886
133532
  return;
132887
133533
  }
132888
133534
  elapsed += interval;
132889
133535
  if (elapsed >= ms) {
132890
133536
  clearInterval(timer);
132891
- resolve10(false);
133537
+ resolve11(false);
132892
133538
  }
132893
133539
  }, interval);
132894
133540
  });
@@ -133019,10 +133665,10 @@ function resolveWhichCommand(name) {
133019
133665
  return process.platform === "win32" ? `where ${name}` : `which ${name}`;
133020
133666
  }
133021
133667
  function isCliAvailable(cliName) {
133022
- return new Promise((resolve10) => {
133668
+ return new Promise((resolve11) => {
133023
133669
  const child = spawn5(resolveWhichCommand(cliName), [], DETACHED_SHELL_SPAWN_OPTIONS);
133024
- child.on("error", () => resolve10(false));
133025
- child.on("close", (code2) => resolve10(code2 === 0));
133670
+ child.on("error", () => resolve11(false));
133671
+ child.on("close", (code2) => resolve11(code2 === 0));
133026
133672
  child.unref();
133027
133673
  });
133028
133674
  }
@@ -133354,7 +134000,7 @@ function gitCloneEnv() {
133354
134000
  function spawnGitClone(repoUrl, cloneTarget, opts) {
133355
134001
  const spawnFn = opts.spawnFn ?? spawn6;
133356
134002
  const timeoutMs = opts.timeoutMs ?? DEFAULT_TIMEOUT_MS;
133357
- return new Promise((resolve10) => {
134003
+ return new Promise((resolve11) => {
133358
134004
  let settled = false;
133359
134005
  const stderr = createStderrReader(opts.onProgress);
133360
134006
  const child = spawnFn("git", ["clone", "--progress", "--", repoUrl, cloneTarget], {
@@ -133370,7 +134016,7 @@ function spawnGitClone(repoUrl, cloneTarget, opts) {
133370
134016
  return;
133371
134017
  settled = true;
133372
134018
  clearTimeout(timer);
133373
- resolve10(outcome);
134019
+ resolve11(outcome);
133374
134020
  };
133375
134021
  child.stderr?.setEncoding("utf8");
133376
134022
  child.stderr?.on("data", (text) => stderr.push(text));
@@ -133455,7 +134101,7 @@ async function reportResultWithRetry(deps, result3) {
133455
134101
  warn(`Git clone result report failed after retries: ${getErrorMessage(error51)}`);
133456
134102
  return;
133457
134103
  }
133458
- await new Promise((resolve10) => setTimeout(resolve10, delayMs));
134104
+ await new Promise((resolve11) => setTimeout(resolve11, delayMs));
133459
134105
  }
133460
134106
  }
133461
134107
  }
@@ -133877,7 +134523,7 @@ var init_assert_registered_working_dir = () => {};
133877
134523
 
133878
134524
  // src/infrastructure/services/workspace/workspace-path-security.ts
133879
134525
  import { realpath as realpath3 } from "node:fs/promises";
133880
- import { dirname as dirname18, isAbsolute as isAbsolute2, relative as relative4, resolve as resolve10, sep } from "node:path";
134526
+ import { dirname as dirname19, isAbsolute as isAbsolute2, relative as relative4, resolve as resolve11, sep } from "node:path";
133881
134527
  import { gunzipSync } from "node:zlib";
133882
134528
  function validateRelativePathSegments(filePath) {
133883
134529
  if (filePath.includes("\x00"))
@@ -133905,7 +134551,7 @@ function assertContained(workspaceRoot, targetPath) {
133905
134551
  return { ok: true };
133906
134552
  }
133907
134553
  async function resolveNonExistentTarget(workspaceRoot, candidate) {
133908
- let current = dirname18(candidate);
134554
+ let current = dirname19(candidate);
133909
134555
  for (;; ) {
133910
134556
  try {
133911
134557
  const ancestorReal = await realpath3(current);
@@ -133913,7 +134559,7 @@ async function resolveNonExistentTarget(workspaceRoot, candidate) {
133913
134559
  if (!ancestorCheck.ok)
133914
134560
  return ancestorCheck;
133915
134561
  const suffix = relative4(current, candidate);
133916
- const resolved = resolve10(ancestorReal, suffix);
134562
+ const resolved = resolve11(ancestorReal, suffix);
133917
134563
  const resolvedCheck = assertContained(workspaceRoot, resolved);
133918
134564
  if (!resolvedCheck.ok)
133919
134565
  return resolvedCheck;
@@ -133923,7 +134569,7 @@ async function resolveNonExistentTarget(workspaceRoot, candidate) {
133923
134569
  if (code2 !== "ENOENT") {
133924
134570
  return { ok: false, error: "Invalid file path" };
133925
134571
  }
133926
- const parent = dirname18(current);
134572
+ const parent = dirname19(current);
133927
134573
  if (parent === current) {
133928
134574
  return { ok: false, error: "Path escapes workspace" };
133929
134575
  }
@@ -133937,11 +134583,11 @@ async function resolvePathWithinWorkspace(workingDir, filePath) {
133937
134583
  return basic;
133938
134584
  let workspaceRoot;
133939
134585
  try {
133940
- workspaceRoot = await realpath3(resolve10(workingDir));
134586
+ workspaceRoot = await realpath3(resolve11(workingDir));
133941
134587
  } catch {
133942
134588
  return { ok: false, error: "Working directory not found" };
133943
134589
  }
133944
- const candidate = resolve10(workspaceRoot, filePath);
134590
+ const candidate = resolve11(workspaceRoot, filePath);
133945
134591
  if (!isPathInsideRoot(workspaceRoot, candidate)) {
133946
134592
  return { ok: false, error: "Path escapes workspace" };
133947
134593
  }
@@ -133982,7 +134628,7 @@ function gunzipBase64Payload(base643, maxBytes) {
133982
134628
  var init_workspace_path_security = () => {};
133983
134629
 
133984
134630
  // src/daemon/entry/files/file-content-fulfillment.ts
133985
- import { readFile as readFile14 } from "node:fs/promises";
134631
+ import { readFile as readFile15 } from "node:fs/promises";
133986
134632
  import { gzipSync as gzipSync3 } from "node:zlib";
133987
134633
  function getErrorCause(error51) {
133988
134634
  if (typeof error51 === "object" && error51 !== null && "cause" in error51 && error51.cause !== undefined) {
@@ -134057,7 +134703,7 @@ var init_file_content_fulfillment = __esm(() => {
134057
134703
  continue;
134058
134704
  }
134059
134705
  let fileNotFound = false;
134060
- const buffer = yield* exports_Effect.catch(exports_Effect.tryPromise(() => readFile14(absolutePath)), (error51) => {
134706
+ const buffer = yield* exports_Effect.catch(exports_Effect.tryPromise(() => readFile15(absolutePath)), (error51) => {
134061
134707
  if (isENOENT(error51)) {
134062
134708
  fileNotFound = true;
134063
134709
  return exports_Effect.succeed(Buffer.alloc(0));
@@ -134122,7 +134768,7 @@ function getOrCreateState(key) {
134122
134768
  return state;
134123
134769
  }
134124
134770
  function sleep6(ms) {
134125
- return new Promise((resolve11) => setTimeout(resolve11, ms));
134771
+ return new Promise((resolve12) => setTimeout(resolve12, ms));
134126
134772
  }
134127
134773
  async function drainQueue(state, key, debounceMs) {
134128
134774
  try {
@@ -134154,9 +134800,9 @@ function kickDrain(state, key, debounceMs) {
134154
134800
  if (state.scheduled || state.drainPromise)
134155
134801
  return;
134156
134802
  state.scheduled = true;
134157
- state.drainPromise = new Promise((resolve11, reject) => {
134803
+ state.drainPromise = new Promise((resolve12, reject) => {
134158
134804
  queueMicrotask(() => {
134159
- drainQueue(state, key, debounceMs).then(resolve11, reject);
134805
+ drainQueue(state, key, debounceMs).then(resolve12, reject);
134160
134806
  });
134161
134807
  });
134162
134808
  }
@@ -134302,10 +134948,10 @@ function parseAttachmentFileName(remainder) {
134302
134948
  if (underscore <= 0)
134303
134949
  return false;
134304
134950
  const uuid3 = remainder.slice(0, underscore);
134305
- const basename8 = remainder.slice(underscore + 1);
134306
- if (!UUID_V4_RE.test(uuid3) || !basename8)
134951
+ const basename9 = remainder.slice(underscore + 1);
134952
+ if (!UUID_V4_RE.test(uuid3) || !basename9)
134307
134953
  return false;
134308
- return sanitizeChatAttachmentFileName(basename8) === basename8;
134954
+ return sanitizeChatAttachmentFileName(basename9) === basename9;
134309
134955
  }
134310
134956
  function getInvalidChatAttachmentUploadPathReason(relativePath) {
134311
134957
  if (relativePath.includes("\\"))
@@ -134334,14 +134980,14 @@ function normalizeSegments(relativePath) {
134334
134980
  function hasBlockedSegment(lowerSegments) {
134335
134981
  return lowerSegments.some((segment) => BLOCKED_SEGMENT_NAMES.has(segment));
134336
134982
  }
134337
- function hasBlockedBasename(basename8) {
134338
- return /^\.env(?:\.|$)/.test(basename8) || /\.(?:pem|key)$/.test(basename8) || basename8 === "id_rsa" || basename8 === "credentials.json";
134983
+ function hasBlockedBasename(basename9) {
134984
+ return /^\.env(?:\.|$)/.test(basename9) || /\.(?:pem|key)$/.test(basename9) || basename9 === "id_rsa" || basename9 === "credentials.json";
134339
134985
  }
134340
134986
  function isBlockedUploadTargetPath(relativePath) {
134341
134987
  if (!relativePath)
134342
134988
  return false;
134343
- const { lowerSegments, basename: basename8 } = normalizeSegments(relativePath);
134344
- return hasBlockedSegment(lowerSegments) || hasBlockedBasename(basename8);
134989
+ const { lowerSegments, basename: basename9 } = normalizeSegments(relativePath);
134990
+ return hasBlockedSegment(lowerSegments) || hasBlockedBasename(basename9);
134345
134991
  }
134346
134992
  function getBlockedUploadTargetReason(relativePath) {
134347
134993
  if (!isBlockedUploadTargetPath(relativePath))
@@ -134392,7 +135038,7 @@ var init_file_write_request_priority = __esm(() => {
134392
135038
 
134393
135039
  // src/daemon/entry/files/file-write-fulfillment.ts
134394
135040
  import { access as access4, mkdir as mkdir12, rename as rename4, rm as rm4, writeFile as writeFile11 } from "node:fs/promises";
134395
- import { dirname as dirname19 } from "node:path";
135041
+ import { dirname as dirname20 } from "node:path";
134396
135042
  function isTerminalFileWriteError(errorMessage3) {
134397
135043
  const terminalMessages = new Set([
134398
135044
  "Invalid file path",
@@ -134491,7 +135137,7 @@ async function validateWriteOperation(operation, absolutePath) {
134491
135137
  }
134492
135138
  async function writePayloadToDisk(absolutePath, operation, content) {
134493
135139
  if (operation === "create") {
134494
- await mkdir12(dirname19(absolutePath), { recursive: true });
135140
+ await mkdir12(dirname20(absolutePath), { recursive: true });
134495
135141
  await writeFile11(absolutePath, content, { flag: "wx" });
134496
135142
  return;
134497
135143
  }
@@ -134569,7 +135215,7 @@ async function fulfillOneFileWriteRequest(session2, request3) {
134569
135215
  });
134570
135216
  return;
134571
135217
  }
134572
- await mkdir12(dirname19(targetResolved.absolutePath), { recursive: true });
135218
+ await mkdir12(dirname20(targetResolved.absolutePath), { recursive: true });
134573
135219
  await rename4(resolved.absolutePath, targetResolved.absolutePath);
134574
135220
  await completeWriteRequest(session2, claimed._id, claimed.revision, { status: "done" });
134575
135221
  const elapsed2 = Date.now() - startTime;
@@ -135178,8 +135824,8 @@ var init_command_runner = __esm(() => {
135178
135824
  }).catch((err) => {
135179
135825
  console.warn(`[${formatTimestamp()}] ⚠️ Failed to mark run as killed on shutdown: ${getErrorMessage(err)}`);
135180
135826
  })));
135181
- yield* exports_Effect.promise(() => new Promise((resolve11) => {
135182
- const t = setTimeout(resolve11, 3000);
135827
+ yield* exports_Effect.promise(() => new Promise((resolve12) => {
135828
+ const t = setTimeout(resolve12, 3000);
135183
135829
  t.unref?.();
135184
135830
  }));
135185
135831
  for (const [, tracked] of trackedEntries) {
@@ -135191,8 +135837,8 @@ var init_command_runner = __esm(() => {
135191
135837
  clearTrackedPids();
135192
135838
  yield* exports_Effect.promise(() => Promise.race([
135193
135839
  statusUpdates,
135194
- new Promise((resolve11) => {
135195
- const t = setTimeout(resolve11, 2000);
135840
+ new Promise((resolve12) => {
135841
+ const t = setTimeout(resolve12, 2000);
135196
135842
  t.unref?.();
135197
135843
  })
135198
135844
  ]));
@@ -135723,8 +136369,8 @@ function createDaemonRuntime(deps) {
135723
136369
  const withTimeout2 = async (p, ms) => {
135724
136370
  await Promise.race([
135725
136371
  Promise.resolve(p).catch(() => {}),
135726
- new Promise((resolve11) => {
135727
- const t = setTimeout(resolve11, ms);
136372
+ new Promise((resolve12) => {
136373
+ const t = setTimeout(resolve12, ms);
135728
136374
  t.unref?.();
135729
136375
  })
135730
136376
  ]);
@@ -135895,8 +136541,8 @@ Listening for commands...`);
135895
136541
  return {
135896
136542
  async run() {
135897
136543
  await exports_Effect.runPromise(startRuntimeEffect.pipe(exports_Effect.provide(deps.layers)));
135898
- await new Promise((resolve11) => {
135899
- runResolve = resolve11;
136544
+ await new Promise((resolve12) => {
136545
+ runResolve = resolve12;
135900
136546
  });
135901
136547
  },
135902
136548
  shutdown
@@ -136861,10 +137507,10 @@ var init_schema = __esm(() => {
136861
137507
 
136862
137508
  // src/daemon/infrastructure/persistence/open-database.ts
136863
137509
  import { mkdirSync as mkdirSync11 } from "node:fs";
136864
- import { dirname as dirname20 } from "node:path";
137510
+ import { dirname as dirname21 } from "node:path";
136865
137511
  import { DatabaseSync as DatabaseSync5 } from "node:sqlite";
136866
137512
  function openDatabase(dbPath) {
136867
- mkdirSync11(dirname20(dbPath), { recursive: true });
137513
+ mkdirSync11(dirname21(dbPath), { recursive: true });
136868
137514
  const db = new DatabaseSync5(dbPath);
136869
137515
  for (const sql of MIGRATIONS2) {
136870
137516
  db.exec(sql);
@@ -136928,10 +137574,10 @@ var init_persistence = __esm(() => {
136928
137574
  // src/daemon/local-web/client/lib/socket.ts
136929
137575
  async function ensureConnected(s) {
136930
137576
  if (!s.connected) {
136931
- await new Promise((resolve11, reject) => {
137577
+ await new Promise((resolve12, reject) => {
136932
137578
  const onConnect = () => {
136933
137579
  cleanup();
136934
- resolve11();
137580
+ resolve12();
136935
137581
  };
136936
137582
  const onError3 = (err) => {
136937
137583
  cleanup();
@@ -141913,13 +142559,13 @@ var require_broadcast_operator = __commonJS((exports) => {
141913
142559
  return true;
141914
142560
  }
141915
142561
  emitWithAck(ev, ...args2) {
141916
- return new Promise((resolve11, reject) => {
142562
+ return new Promise((resolve12, reject) => {
141917
142563
  args2.push((err, responses) => {
141918
142564
  if (err) {
141919
142565
  err.responses = responses;
141920
142566
  return reject(err);
141921
142567
  } else {
141922
- return resolve11(responses);
142568
+ return resolve12(responses);
141923
142569
  }
141924
142570
  });
141925
142571
  this.emit(ev, ...args2);
@@ -142107,12 +142753,12 @@ var require_socket2 = __commonJS((exports) => {
142107
142753
  }
142108
142754
  emitWithAck(ev, ...args2) {
142109
142755
  const withErr = this.flags.timeout !== undefined;
142110
- return new Promise((resolve11, reject) => {
142756
+ return new Promise((resolve12, reject) => {
142111
142757
  args2.push((arg1, arg2) => {
142112
142758
  if (withErr) {
142113
- return arg1 ? reject(arg1) : resolve11(arg2);
142759
+ return arg1 ? reject(arg1) : resolve12(arg2);
142114
142760
  } else {
142115
- return resolve11(arg1);
142761
+ return resolve12(arg1);
142116
142762
  }
142117
142763
  });
142118
142764
  this.emit(ev, ...args2);
@@ -142567,13 +143213,13 @@ var require_namespace = __commonJS((exports) => {
142567
143213
  return true;
142568
143214
  }
142569
143215
  serverSideEmitWithAck(ev, ...args2) {
142570
- return new Promise((resolve11, reject) => {
143216
+ return new Promise((resolve12, reject) => {
142571
143217
  args2.push((err, responses) => {
142572
143218
  if (err) {
142573
143219
  err.responses = responses;
142574
143220
  return reject(err);
142575
143221
  } else {
142576
- return resolve11(responses);
143222
+ return resolve12(responses);
142577
143223
  }
142578
143224
  });
142579
143225
  this.serverSideEmit(ev, ...args2);
@@ -143257,7 +143903,7 @@ var require_cluster_adapter = __commonJS((exports) => {
143257
143903
  return localSockets;
143258
143904
  }
143259
143905
  const requestId3 = randomId();
143260
- return new Promise((resolve11, reject) => {
143906
+ return new Promise((resolve12, reject) => {
143261
143907
  const timeout3 = setTimeout(() => {
143262
143908
  const storedRequest2 = this.requests.get(requestId3);
143263
143909
  if (storedRequest2) {
@@ -143267,7 +143913,7 @@ var require_cluster_adapter = __commonJS((exports) => {
143267
143913
  }, opts.flags.timeout || DEFAULT_TIMEOUT);
143268
143914
  const storedRequest = {
143269
143915
  type: MessageType.FETCH_SOCKETS,
143270
- resolve: resolve11,
143916
+ resolve: resolve12,
143271
143917
  timeout: timeout3,
143272
143918
  current: 0,
143273
143919
  expected: expectedResponseCount,
@@ -143477,7 +144123,7 @@ var require_cluster_adapter = __commonJS((exports) => {
143477
144123
  return localSockets;
143478
144124
  }
143479
144125
  const requestId3 = randomId();
143480
- return new Promise((resolve11, reject) => {
144126
+ return new Promise((resolve12, reject) => {
143481
144127
  const timeout3 = setTimeout(() => {
143482
144128
  const storedRequest2 = this.customRequests.get(requestId3);
143483
144129
  if (storedRequest2) {
@@ -143487,7 +144133,7 @@ var require_cluster_adapter = __commonJS((exports) => {
143487
144133
  }, opts.flags.timeout || DEFAULT_TIMEOUT);
143488
144134
  const storedRequest = {
143489
144135
  type: MessageType.FETCH_SOCKETS,
143490
- resolve: resolve11,
144136
+ resolve: resolve12,
143491
144137
  timeout: timeout3,
143492
144138
  missingUids: new Set([...this.nodesMap.keys()]),
143493
144139
  responses: localSockets
@@ -144216,13 +144862,13 @@ var require_dist5 = __commonJS((exports, module) => {
144216
144862
  this.engine.close();
144217
144863
  (0, uws_1.restoreAdapter)();
144218
144864
  if (this.httpServer) {
144219
- return new Promise((resolve11) => {
144865
+ return new Promise((resolve12) => {
144220
144866
  this.httpServer.close((err) => {
144221
144867
  fn3 && fn3(err);
144222
144868
  if (err) {
144223
144869
  debug13("server was not running");
144224
144870
  }
144225
- resolve11();
144871
+ resolve12();
144226
144872
  });
144227
144873
  });
144228
144874
  } else {
@@ -144360,7 +145006,7 @@ function routeRequest(req, res, deps) {
144360
145006
 
144361
145007
  // src/daemon/local-web/server/serve-static.ts
144362
145008
  import { existsSync as existsSync10, readFileSync as readFileSync12 } from "node:fs";
144363
- import { dirname as dirname21, join as join31 } from "node:path";
145009
+ import { dirname as dirname22, join as join31 } from "node:path";
144364
145010
  import { fileURLToPath as fileURLToPath7 } from "node:url";
144365
145011
  function clientDistCandidates(here) {
144366
145012
  return [
@@ -144369,7 +145015,7 @@ function clientDistCandidates(here) {
144369
145015
  join31(here, "../src/daemon/local-web/client/build")
144370
145016
  ];
144371
145017
  }
144372
- function resolveClientDistDir(here = dirname21(fileURLToPath7(import.meta.url))) {
145018
+ function resolveClientDistDir(here = dirname22(fileURLToPath7(import.meta.url))) {
144373
145019
  const candidates = clientDistCandidates(here);
144374
145020
  for (const dir of candidates) {
144375
145021
  if (existsSync10(join31(dir, "index.html")))
@@ -144805,9 +145451,9 @@ async function startLocalWebServer(config4, deps = {}) {
144805
145451
  routeRequest(req, res, { persistence: deps.persistence, streamHub });
144806
145452
  });
144807
145453
  const port = config4.port ?? 0;
144808
- await new Promise((resolve11, reject) => {
145454
+ await new Promise((resolve12, reject) => {
144809
145455
  server.once("error", reject);
144810
- server.listen(port, config4.host, () => resolve11());
145456
+ server.listen(port, config4.host, () => resolve12());
144811
145457
  });
144812
145458
  const address = server.address();
144813
145459
  if (!address || typeof address === "string") {
@@ -144835,13 +145481,13 @@ async function startLocalWebServer(config4, deps = {}) {
144835
145481
  port: boundPort,
144836
145482
  streamHub,
144837
145483
  stop() {
144838
- return new Promise((resolve11, reject) => {
145484
+ return new Promise((resolve12, reject) => {
144839
145485
  io2.close((err) => {
144840
145486
  if (err) {
144841
145487
  reject(err);
144842
145488
  return;
144843
145489
  }
144844
- resolve11();
145490
+ resolve12();
144845
145491
  });
144846
145492
  server.closeAllConnections();
144847
145493
  });
@@ -144962,8 +145608,8 @@ var init_cli_gateway_service = __esm(() => {
144962
145608
  // src/daemon/entry/start-daemon.ts
144963
145609
  async function startDaemon() {
144964
145610
  let resolveBoundPort;
144965
- const localWebPortReady = new Promise((resolve11) => {
144966
- resolveBoundPort = resolve11;
145611
+ const localWebPortReady = new Promise((resolve12) => {
145612
+ resolveBoundPort = resolve12;
144967
145613
  });
144968
145614
  const logStreamHub = createLogStreamHub();
144969
145615
  const eventStreamHub = createEventStreamHub();
@@ -145714,7 +146360,7 @@ async function withRetry(fn3, opts) {
145714
146360
  return;
145715
146361
  }
145716
146362
  const delay3 = Math.min(baseDelayMs * 2 ** attempt, maxDelayMs);
145717
- await new Promise((resolve11) => setTimeout(resolve11, delay3));
146363
+ await new Promise((resolve12) => setTimeout(resolve12, delay3));
145718
146364
  }
145719
146365
  }
145720
146366
  return;
@@ -145766,81 +146412,11 @@ var {
145766
146412
  } = import__.default;
145767
146413
 
145768
146414
  // src/commands/generate/index.ts
145769
- import { readFile, stat as stat2 } from "node:fs/promises";
146415
+ import { readFile as readFile2, stat as stat2 } from "node:fs/promises";
145770
146416
  init_image();
145771
-
145772
- // src/commands/generate/local-image-common.ts
145773
- import { createHash as createHash2 } from "node:crypto";
145774
- var SAFE_NAME = /^[A-Za-z0-9_][A-Za-z0-9_-]{0,63}$/;
145775
- var MAX_SOURCE_PIXELS = 1e8;
145776
- var MAX_SOURCE_BYTES = 64 * 1024 * 1024;
145777
- var MAX_SIDECAR_BYTES = 1024 * 1024;
145778
- var PNG_MAGIC = new Uint8Array([137, 80, 78, 71, 13, 10, 26, 10]);
145779
- function isRecord(value) {
145780
- return typeof value === "object" && value !== null;
145781
- }
145782
- function sha256(bytes) {
145783
- return createHash2("sha256").update(bytes).digest("hex");
145784
- }
145785
- function errorMessage(err) {
145786
- return err instanceof Error ? err.message : String(err);
145787
- }
145788
- function hasPngMagic(bytes) {
145789
- if (bytes.length < PNG_MAGIC.length)
145790
- return false;
145791
- return PNG_MAGIC.every((byte, index) => bytes[index] === byte);
145792
- }
145793
- function readPngDimensions(bytes) {
145794
- if (bytes.length < 24)
145795
- return null;
145796
- if (bytes[12] !== 73 || bytes[13] !== 72 || bytes[14] !== 68 || bytes[15] !== 82) {
145797
- return null;
145798
- }
145799
- const view = new DataView(bytes.buffer, bytes.byteOffset, bytes.byteLength);
145800
- return { width: view.getUint32(16), height: view.getUint32(20) };
145801
- }
145802
- function formatConflicts(conflicts) {
145803
- const shown = conflicts.slice(0, 10);
145804
- const lines = shown.map((conflict) => `- ${conflict.path}: ${conflict.reason}`);
145805
- if (conflicts.length > shown.length) {
145806
- lines.push(`- and ${conflicts.length - shown.length} more`);
145807
- }
145808
- return `Refusing to write ${conflicts.length} output file(s):
145809
- ${lines.join(`
145810
- `)}
145811
- Pass --force to overwrite.`;
145812
- }
145813
- async function findOutputConflicts(deps, paths, sourcePaths, sourceIdentities, force) {
145814
- const matchesSourceIdentity = (identity) => sourceIdentities.some((source) => source !== null && source.dev === identity.dev && source.ino === identity.ino);
145815
- const conflicts = [];
145816
- for (const path of paths) {
145817
- if (sourcePaths.has(path)) {
145818
- conflicts.push({ path, reason: "this is the source sheet or its manifest" });
145819
- continue;
145820
- }
145821
- if (await deps.isSymlink(path)) {
145822
- conflicts.push({ path, reason: "this is a symbolic link" });
145823
- continue;
145824
- }
145825
- const status = await deps.pathStatus(path);
145826
- if (status === "directory") {
145827
- conflicts.push({ path, reason: "a directory is in the way" });
145828
- continue;
145829
- }
145830
- const identity = await deps.fileIdentity(path);
145831
- if (identity !== null && matchesSourceIdentity(identity)) {
145832
- conflicts.push({ path, reason: "this resolves to the source sheet or its manifest" });
145833
- continue;
145834
- }
145835
- if (status === "file" && !force) {
145836
- conflicts.push({ path, reason: "already exists" });
145837
- }
145838
- }
145839
- return conflicts;
145840
- }
145841
-
145842
- // src/commands/generate/index.ts
145843
- var OUTPUT_FORMATS = ["png", "jpeg", "webp"];
146417
+ init_local_image_common();
146418
+ init_model_capabilities();
146419
+ var OUTPUT_FORMATS = ["png", "webp"];
145844
146420
  function parsePlatform(value) {
145845
146421
  if (!GENERATE_IMAGE_PLATFORMS.includes(value)) {
145846
146422
  throw new InvalidArgumentError(`must be one of ${GENERATE_IMAGE_PLATFORMS.join(", ")}`);
@@ -145865,7 +146441,7 @@ async function readInputOption(value) {
145865
146441
  if (stats.size > MAX_SIDECAR_BYTES) {
145866
146442
  throw new Error(`--input file is ${stats.size} bytes; the maximum is ${MAX_SIDECAR_BYTES} bytes (1 MiB).`);
145867
146443
  }
145868
- return parseInputJson(await readFile(path, "utf8"));
146444
+ return parseInputJson(await readFile2(path, "utf8"));
145869
146445
  }
145870
146446
  function parseSeed(value) {
145871
146447
  const seed = Number(value);
@@ -145876,38 +146452,49 @@ function parseSeed(value) {
145876
146452
  }
145877
146453
  var HELP_AFTER = `
145878
146454
  Examples:
145879
- chatroom generate-image --platform=fal --prompt "a hero" --out hero.png
145880
- chatroom generate-image --platform=fal --model fal-ai/moss-image --prompt '{"summary":{"canvas":"single"},"items":[]}' --input '{"image_size":{"width":1024,"height":768},"enable_prompt_expansion":false}' --output-format png --out sheet.png
146455
+ chatroom generate-image --platform=fal --model ${FLUX_2_FLASH_MODEL} --prompt "a hero" --out hero.png
146456
+ chatroom generate-image --platform=fal --model ${FLUX_2_FLASH_MODEL} --prompt 'pixel-art potion, transparent-friendly flat background' --output-format png --out potion.png
146457
+ chatroom generate-image --platform=fal --model ${FLUX_2_FLASH_EDIT_MODEL} --prompt "make the sky stormy" --input-image ./hero.png --out hero-stormy.png
145881
146458
  `;
145882
- function registerGenerateImageCommand(program2) {
145883
- program2.command("generate-image").description("Generate one image with a fal model and write a JSON manifest next to it").requiredOption("--prompt <text>", "Text prompt describing the image").requiredOption("--out <path>", "Output image path (manifest is written to <path>.json)").option("--platform <name>", "Generation platform: fal", parsePlatform, DEFAULT_GENERATE_IMAGE_PLATFORM).option("--model <id>", `fal model id. Recommended and default: ${DEFAULT_IMAGE_MODEL}`, DEFAULT_IMAGE_MODEL).option("--aspect-ratio <ratio>", `Aspect ratio, e.g. 1:1, 4:3, 16:9, 9:16 (omitted = model default). Not supported by the default model ${DEFAULT_IMAGE_MODEL}, which uses its own image size`).option("--output-format <format>", "Output format: png, jpeg, or webp (omitted = model default)", parseOutputFormat).option("--seed <n>", "Seed for the random number generator", parseSeed).option("--input <json|@file>", "Model-specific JSON input object merged into the fal request; @file reads JSON from a file").option("--force", "Overwrite existing output and manifest files").addHelpText("after", HELP_AFTER).action(async (options) => {
145884
- try {
145885
- const input = options.input === undefined ? undefined : await readInputOption(options.input);
145886
- const { createDefaultGenerateImageDeps: createDefaultGenerateImageDeps2 } = await Promise.resolve().then(() => (init_deps(), exports_deps));
145887
- const result = await generateImage({
145888
- prompt: options.prompt,
145889
- out: options.out,
145890
- platform: options.platform,
145891
- model: options.model,
145892
- aspectRatio: options.aspectRatio,
145893
- outputFormat: options.outputFormat,
145894
- seed: options.seed,
145895
- input,
145896
- force: options.force
145897
- }, createDefaultGenerateImageDeps2());
145898
- console.log(`Generated ${result.outPath}`);
145899
- console.log(`Manifest ${result.manifestPath}`);
145900
- } catch (err) {
145901
- console.error(`❌ ${err instanceof Error ? err.message : String(err)}`);
145902
- process.exitCode = 1;
146459
+ async function runGenerateImage(options) {
146460
+ try {
146461
+ const input = options.input === undefined ? undefined : await readInputOption(options.input);
146462
+ const { createDefaultGenerateImageDeps: createDefaultGenerateImageDeps2 } = await Promise.resolve().then(() => (init_deps(), exports_deps));
146463
+ const deps = createDefaultGenerateImageDeps2();
146464
+ const generateOptions = {
146465
+ prompt: options.prompt,
146466
+ out: options.out,
146467
+ platform: options.platform,
146468
+ model: options.model,
146469
+ aspectRatio: options.aspectRatio,
146470
+ outputFormat: options.outputFormat,
146471
+ seed: options.seed,
146472
+ input,
146473
+ inputImage: options.inputImage,
146474
+ force: options.force
146475
+ };
146476
+ if (options.dryRun === true) {
146477
+ const { formatGenerateImagePlan: formatGenerateImagePlan2, planGenerateImage: planGenerateImage2 } = await Promise.resolve().then(() => (init_image(), exports_image));
146478
+ console.log(formatGenerateImagePlan2(await planGenerateImage2(generateOptions, deps)));
146479
+ return;
145903
146480
  }
145904
- });
146481
+ const result = await generateImage(generateOptions, deps);
146482
+ console.log(`Generated ${result.outPath}`);
146483
+ console.log(`Manifest ${result.manifestPath}`);
146484
+ } catch (err) {
146485
+ console.error(`❌ ${err instanceof Error ? err.message : String(err)}`);
146486
+ process.exitCode = 1;
146487
+ }
146488
+ }
146489
+ function registerGenerateImageCommand(program2) {
146490
+ program2.command("generate-image").description("Generate one image with a fal model and write a JSON manifest next to it").requiredOption("--prompt <text>", "Text prompt describing the image").requiredOption("--out <path>", "Output image path (manifest is written to <path>.json)").option("--platform <name>", "Generation platform: fal", parsePlatform, DEFAULT_GENERATE_IMAGE_PLATFORM).requiredOption("--model <id>", `fal model id (required), for example ${FLUX_2_FLASH_MODEL}, or ${FLUX_2_FLASH_EDIT_MODEL} with --input-image`).option("--aspect-ratio <ratio>", "Aspect ratio for models that take one, e.g. 1:1, 16:9 (omitted = model default). Rejected for models the CLI knows do not support it").option("--output-format <format>", "Output format: png or webp (omitted = model default)", parseOutputFormat).option("--seed <n>", "Seed for the random number generator", parseSeed).option("--input <json|@file>", "Model-specific JSON input object merged into the fal request; @file reads JSON from a file").option("--input-image <path-or-url>", `Image to edit: a local .png, .jpg, .jpeg, .webp, or .gif (uploaded to fal) or an http(s) URL. Requires an edit model such as ${FLUX_2_FLASH_EDIT_MODEL}`).option("--force", "Overwrite existing output and manifest files").option("--dry-run", "Validate and print the request and the model constraints the CLI knows, without uploading or calling fal (FAL_API_KEY not needed)").addHelpText("after", HELP_AFTER).action(runGenerateImage);
145905
146491
  }
145906
146492
 
145907
146493
  // src/commands/generate/remove-background.ts
145908
146494
  import { basename, dirname as dirname3, extname as extname2, join as join2, resolve as resolve2 } from "node:path";
145909
146495
 
145910
146496
  // src/commands/generate/background-key.ts
146497
+ init_local_image_common();
145911
146498
  var DEFAULT_TOLERANCE = 24;
145912
146499
  var DEFAULT_MIN_AREA_PERCENT = 0.5;
145913
146500
  var BORDER_NOISE_REFUSAL_RATIO = 0.02;
@@ -145925,13 +146512,6 @@ function borderCoordinates(width, height) {
145925
146512
  }
145926
146513
  return coordinates;
145927
146514
  }
145928
- function median(values) {
145929
- const sorted = [...values].sort((a, b) => a - b);
145930
- const middle = Math.floor(sorted.length / 2);
145931
- if (sorted.length % 2 === 1)
145932
- return sorted[middle] ?? 0;
145933
- return Math.round(((sorted[middle - 1] ?? 0) + (sorted[middle] ?? 0)) / 2);
145934
- }
145935
146515
  function forEachNeighbour(index, width, height, visit) {
145936
146516
  const x = index % width;
145937
146517
  const y = Math.floor(index / width);
@@ -146229,6 +146809,9 @@ function keyBackground(image, opts) {
146229
146809
  });
146230
146810
  }
146231
146811
 
146812
+ // src/commands/generate/remove-background.ts
146813
+ init_local_image_common();
146814
+
146232
146815
  // src/commands/generate/trim-crop.ts
146233
146816
  var MAX_TRIM_PADDING = 64;
146234
146817
  function trimRect(contentBox, canvasWidth, canvasHeight, padding) {
@@ -146812,12 +147395,71 @@ function registerRemoveImageBackgroundCommand(program2) {
146812
147395
  });
146813
147396
  }
146814
147397
 
147398
+ // src/commands/generate/remove-background-fal-command.ts
147399
+ init_remove_background_fal();
147400
+ var ENGINES = ["bria", "birefnet"];
147401
+ function parseEngine(value) {
147402
+ if (!ENGINES.includes(value)) {
147403
+ throw new InvalidArgumentError(`must be one of ${ENGINES.join(", ")}`);
147404
+ }
147405
+ return value;
147406
+ }
147407
+ var HELP_AFTER3 = `
147408
+ Usage:
147409
+ chatroom remove-image-background-fal --in <png> --out <png>
147410
+ [--engine <bria|birefnet>] [--force]
147411
+
147412
+ Purpose:
147413
+ Cut the subject out of one PNG with fal.ai and write a PNG with alpha. For
147414
+ the offline colour-key pass, use chatroom remove-image-background.
147415
+
147416
+ Model:
147417
+ Background model: bria (default, fal-ai/bria/background/remove) or birefnet
147418
+ (previous BiRefNet Matting backend, fal-ai/birefnet/v2). The input is sent as
147419
+ a base64 data URI, so no separate upload step is needed. Both engines return
147420
+ a PNG with alpha.
147421
+
147422
+ Billing:
147423
+ bria is billed per call (about $0.018 at the time of writing). birefnet is
147424
+ billed per compute-second.
147425
+
147426
+ Refusals:
147427
+ A missing FAL_API_KEY, a missing or non-PNG input, an input over 8 MiB, an
147428
+ image over 100,000,000 pixels, and an existing output or manifest without
147429
+ --force are all refused before the paid fal call.
147430
+
147431
+ Limits:
147432
+ One image per invocation; there is no directory mode and no --model switch.
147433
+ The downloaded result must be a PNG no larger than 32 MiB.
147434
+ The output PNG must match the input's width and height. A mismatch fails
147435
+ without writing anything.
147436
+
147437
+ Examples:
147438
+ chatroom remove-image-background-fal --in tiles/potion.png --out assets/potion.png
147439
+ chatroom remove-image-background-fal --in tiles/potion.png --out assets/potion.png --engine birefnet
147440
+ `;
147441
+ function registerRemoveImageBackgroundFalCommand(program2) {
147442
+ program2.command("remove-image-background-fal").description("Remove an image background with fal.ai and write a transparent PNG").requiredOption("--in <png>", "Input PNG to cut out").requiredOption("--out <png>", "Output PNG path for the image with alpha").option("--engine <engine>", "Background model: bria (default, fal-ai/bria/background/remove) or birefnet (previous BiRefNet Matting backend, fal-ai/birefnet/v2)", parseEngine, DEFAULT_BACKGROUND_ENGINE).option("--force", "Overwrite an existing output and manifest").addHelpText("after", HELP_AFTER3).action(async (options) => {
147443
+ try {
147444
+ const { createDefaultRemoveBackgroundFalDeps: createDefaultRemoveBackgroundFalDeps2 } = await Promise.resolve().then(() => (init_remove_background_fal_deps(), exports_remove_background_fal_deps));
147445
+ const result = await removeBackgroundFal({ in: options.in, out: options.out, engine: options.engine, force: options.force }, createDefaultRemoveBackgroundFalDeps2());
147446
+ console.log(`Removed background ${result.outPath} (${result.bytes} bytes)`);
147447
+ console.log(`Manifest ${result.manifestPath}`);
147448
+ console.log(`Request ${result.requestId}`);
147449
+ } catch (err) {
147450
+ console.error(`❌ ${err instanceof Error ? err.message : String(err)}`);
147451
+ process.exitCode = 1;
147452
+ }
147453
+ });
147454
+ }
147455
+
146815
147456
  // src/commands/generate/slice.ts
146816
- import { basename as basename2, extname as extname3, join as join3, resolve as resolve3 } from "node:path";
147457
+ init_local_image_common();
147458
+ import { basename as basename3, extname as extname3, join as join3, resolve as resolve4 } from "node:path";
146817
147459
  var SLICE_TOOL = "chatroom slice-image";
146818
147460
  var MAX_TILES = 256;
146819
147461
  var MAX_GRID_DIMENSION = 64;
146820
- var LICENSING2 = "unverified";
147462
+ var LICENSING3 = "unverified";
146821
147463
 
146822
147464
  class SliceImageError extends Error {
146823
147465
  constructor(message) {
@@ -147002,14 +147644,7 @@ function mostFrequentBorderColor(image) {
147002
147644
  }
147003
147645
  if (red.length === 0)
147004
147646
  return null;
147005
- const median2 = (values) => {
147006
- const sorted = [...values].sort((a, b) => a - b);
147007
- const middle = Math.floor(sorted.length / 2);
147008
- if (sorted.length % 2 === 1)
147009
- return sorted[middle] ?? 0;
147010
- return Math.round(((sorted[middle - 1] ?? 0) + (sorted[middle] ?? 0)) / 2);
147011
- };
147012
- return [median2(red), median2(green), median2(blue)];
147647
+ return [median(red), median(green), median(blue)];
147013
147648
  }
147014
147649
  function countCellEdgeForeground(image, cell, background) {
147015
147650
  const { width, height, data } = image;
@@ -147075,8 +147710,8 @@ async function sliceImage(opts, deps) {
147075
147710
  if (opts.names !== undefined && opts.prefix !== undefined) {
147076
147711
  throw new SliceImageError("--names and --prefix are mutually exclusive.");
147077
147712
  }
147078
- const inPath = resolve3(requireNonEmptyPath(opts.in, "--in"));
147079
- const outDir = resolve3(requireNonEmptyPath(opts.outDir, "--out-dir"));
147713
+ const inPath = resolve4(requireNonEmptyPath(opts.in, "--in"));
147714
+ const outDir = resolve4(requireNonEmptyPath(opts.outDir, "--out-dir"));
147080
147715
  const force = opts.force === true;
147081
147716
  const dryRun = opts.dryRun === true;
147082
147717
  const inputStat = await deps.statInput(inPath);
@@ -147097,7 +147732,7 @@ async function sliceImage(opts, deps) {
147097
147732
  throw new SliceImageError(`--in is ${bytes.byteLength} bytes; the maximum is ${MAX_SOURCE_BYTES} bytes (64 MiB).`);
147098
147733
  }
147099
147734
  if (!hasPngMagic(bytes)) {
147100
- throw new SliceImageError("--in is not a PNG. slice-image only reads PNG sheets; regenerate with 'chatroom generate-image --output-format png' (the default model returns PNG).");
147735
+ throw new SliceImageError("--in is not a PNG. slice-image only reads PNG sheets; regenerate with 'chatroom generate-image --model <id> --output-format png'.");
147101
147736
  }
147102
147737
  const dimensions = readPngDimensions(bytes);
147103
147738
  if (dimensions === null) {
@@ -147131,7 +147766,7 @@ async function sliceImage(opts, deps) {
147131
147766
  gutter,
147132
147767
  allowRemainder: opts.allowRemainder === true
147133
147768
  });
147134
- const sheetStem = basename2(inPath, extname3(inPath));
147769
+ const sheetStem = basename3(inPath, extname3(inPath));
147135
147770
  const names = resolveTileNames({
147136
147771
  cols,
147137
147772
  rows,
@@ -147279,7 +147914,7 @@ async function sliceImage(opts, deps) {
147279
147914
  hasAlpha: tile.hasAlpha
147280
147915
  },
147281
147916
  slicedAt,
147282
- licensing: LICENSING2
147917
+ licensing: LICENSING3
147283
147918
  };
147284
147919
  await write(tile.path, () => deps.writeFile(tile.path, tile.encodedBytes, writeOptions));
147285
147920
  await write(tile.manifestPath, () => deps.writeJson(tile.manifestPath, manifest, writeOptions));
@@ -147309,7 +147944,7 @@ async function sliceImage(opts, deps) {
147309
147944
  })),
147310
147945
  skipped,
147311
147946
  slicedAt,
147312
- licensing: LICENSING2
147947
+ licensing: LICENSING3
147313
147948
  };
147314
147949
  await write(indexPath, () => deps.writeJson(indexPath, index, writeOptions));
147315
147950
  return result;
@@ -147317,7 +147952,7 @@ async function sliceImage(opts, deps) {
147317
147952
 
147318
147953
  // src/commands/generate/slice-command.ts
147319
147954
  var DECIMAL_INTEGER2 = /^\d+$/;
147320
- var HELP_AFTER3 = `
147955
+ var HELP_AFTER4 = `
147321
147956
  Usage:
147322
147957
  chatroom slice-image --in <path> --out-dir <dir> --cols <n> --rows <n> [--margin <px>] [--gutter <px>] [--names <a,b,,c,...> | --prefix <text>] [--allow-remainder] [--allow-edge-content] [--force] [--dry-run]
147323
147958
 
@@ -147389,7 +148024,7 @@ function printResult2(result, options) {
147389
148024
  }
147390
148025
  }
147391
148026
  function registerSliceImageCommand(program2) {
147392
- program2.command("slice-image").description("Cut a PNG sprite sheet into a grid of named PNG tiles with manifests").requiredOption("--in <path>", "Source PNG sprite sheet").requiredOption("--out-dir <dir>", "Directory for tile images and manifests").requiredOption("--cols <n>", "Grid columns (1-64)", parsePositiveInt).requiredOption("--rows <n>", "Grid rows (1-64)", parsePositiveInt).option("--margin <px>", "Pixels skipped on all four sides", parseNonNegativeInt, 0).option("--gutter <px>", "Pixels between adjacent cells on both axes", parseNonNegativeInt, 0).option("--names <a,b,...>", "Comma-separated row-major tile names; an empty entry skips that cell", parseNames).option("--prefix <text>", "Prefix for default names (default: sheet file stem)").option("--allow-remainder", "Drop leftover pixels on the right/bottom instead of refusing").option("--allow-edge-content", "Skip the check that refuses sheets whose artwork crosses cell borders (for full-bleed or tileable art)").option("--force", "Overwrite existing tile images and manifests").option("--dry-run", "Report the tiles without writing anything").addHelpText("after", HELP_AFTER3).action(async (options) => {
148027
+ program2.command("slice-image").description("Cut a PNG sprite sheet into a grid of named PNG tiles with manifests").requiredOption("--in <path>", "Source PNG sprite sheet").requiredOption("--out-dir <dir>", "Directory for tile images and manifests").requiredOption("--cols <n>", "Grid columns (1-64)", parsePositiveInt).requiredOption("--rows <n>", "Grid rows (1-64)", parsePositiveInt).option("--margin <px>", "Pixels skipped on all four sides", parseNonNegativeInt, 0).option("--gutter <px>", "Pixels between adjacent cells on both axes", parseNonNegativeInt, 0).option("--names <a,b,...>", "Comma-separated row-major tile names; an empty entry skips that cell", parseNames).option("--prefix <text>", "Prefix for default names (default: sheet file stem)").option("--allow-remainder", "Drop leftover pixels on the right/bottom instead of refusing").option("--allow-edge-content", "Skip the check that refuses sheets whose artwork crosses cell borders (for full-bleed or tileable art)").option("--force", "Overwrite existing tile images and manifests").option("--dry-run", "Report the tiles without writing anything").addHelpText("after", HELP_AFTER4).action(async (options) => {
147393
148028
  try {
147394
148029
  const { createDefaultSliceImageDeps: createDefaultSliceImageDeps2 } = await Promise.resolve().then(() => (init_slice_deps(), exports_slice_deps));
147395
148030
  const sliceOptions = {
@@ -147430,13 +148065,13 @@ function collectMultiValueOption(value, previous) {
147430
148065
 
147431
148066
  // src/utils/stdin.ts
147432
148067
  async function readStdin() {
147433
- return new Promise((resolve4, reject) => {
148068
+ return new Promise((resolve5, reject) => {
147434
148069
  const chunks = [];
147435
148070
  process.stdin.on("data", (chunk) => {
147436
148071
  chunks.push(Buffer.from(chunk));
147437
148072
  });
147438
148073
  process.stdin.on("end", () => {
147439
- resolve4(Buffer.concat(chunks).toString("utf8"));
148074
+ resolve5(Buffer.concat(chunks).toString("utf8"));
147440
148075
  });
147441
148076
  process.stdin.on("error", (err) => {
147442
148077
  reject(new Error(`Failed to read stdin: ${err.message}`));
@@ -147539,6 +148174,7 @@ toolCommand.command("parse-pdf").description("Parse a PDF file and extract text
147539
148174
  registerGenerateImageCommand(program2);
147540
148175
  registerSliceImageCommand(program2);
147541
148176
  registerRemoveImageBackgroundCommand(program2);
148177
+ registerRemoveImageBackgroundFalCommand(program2);
147542
148178
  program2.command("register-agent").description("Register agent type for a chatroom role").requiredOption("--chatroom-id <id>", "Chatroom identifier").requiredOption("--role <role>", "Role to register as (e.g., builder, planner)").requiredOption("--type <type>", "Agent type: remote or custom").option("--allow-type-change", "Required for --type=custom when the role is currently bound to a remote machine; explicitly opts into clearing the existing binding.").action(async (options) => {
147543
148179
  await maybeRequireAuth();
147544
148180
  if (options.type !== "remote" && options.type !== "custom") {
@@ -148057,4 +148693,4 @@ program2.hook("preAction", async (_thisCommand, actionCommand) => {
148057
148693
  });
148058
148694
  program2.parse();
148059
148695
 
148060
- //# debugId=6A6B81E7BB204BFD64756E2164756E21
148696
+ //# debugId=0C6C6A8595C191FE64756E2164756E21