chatroom-cli 1.135.0 → 1.136.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/client/build/assets/index-qldg7Ymb.css +1 -0
- package/dist/client/build/index.html +2 -2
- package/dist/index.js +723 -411
- package/dist/index.js.map +14 -11
- package/package.json +1 -1
- package/dist/client/build/assets/index-B36KD9q3.css +0 -1
- /package/dist/client/build/assets/{index-Cco8Tl6X.js → index-BLuk19NB.js} +0 -0
package/dist/index.js
CHANGED
|
@@ -2243,6 +2243,12 @@ async function saveImage(deps, outPath, bytes, requestId, url) {
|
|
|
2243
2243
|
throw new GenerateImageError(recoveryMessage("save", err, requestId, url));
|
|
2244
2244
|
}
|
|
2245
2245
|
}
|
|
2246
|
+
function requireSupportedExtension(outPath) {
|
|
2247
|
+
const extension = extname(outPath).toLowerCase();
|
|
2248
|
+
if (!UNSUPPORTED_OUTPUT_EXTENSIONS.has(extension))
|
|
2249
|
+
return;
|
|
2250
|
+
throw new GenerateImageError(`Unsupported output extension ${extension}. Use .png or .webp (transparency-capable).`);
|
|
2251
|
+
}
|
|
2246
2252
|
function requireFormatMatchesExtension(outPath, format) {
|
|
2247
2253
|
const extension = extname(outPath).toLowerCase();
|
|
2248
2254
|
const expected = EXTENSION_FORMATS[extension];
|
|
@@ -2278,6 +2284,7 @@ async function generateImage(opts, deps) {
|
|
|
2278
2284
|
requireFalKey(deps);
|
|
2279
2285
|
const prompt = requireNonEmpty(opts.prompt, "--prompt must not be empty.");
|
|
2280
2286
|
const outPath = resolve(requireNonEmpty(opts.out, "--out must not be empty."));
|
|
2287
|
+
requireSupportedExtension(outPath);
|
|
2281
2288
|
if (opts.outputFormat !== undefined) {
|
|
2282
2289
|
requireFormatMatchesExtension(outPath, opts.outputFormat);
|
|
2283
2290
|
}
|
|
@@ -2310,7 +2317,7 @@ async function generateImage(opts, deps) {
|
|
|
2310
2317
|
}));
|
|
2311
2318
|
return { outPath, manifestPath, sha256 };
|
|
2312
2319
|
}
|
|
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;
|
|
2320
|
+
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, UNSUPPORTED_OUTPUT_EXTENSIONS, INPUT_DEDICATED_FLAGS;
|
|
2314
2321
|
var init_image = __esm(() => {
|
|
2315
2322
|
GENERATE_IMAGE_PLATFORMS = ["fal"];
|
|
2316
2323
|
GenerateImageError = class GenerateImageError extends Error {
|
|
@@ -2321,10 +2328,9 @@ var init_image = __esm(() => {
|
|
|
2321
2328
|
};
|
|
2322
2329
|
EXTENSION_FORMATS = {
|
|
2323
2330
|
".png": "png",
|
|
2324
|
-
".jpg": "jpeg",
|
|
2325
|
-
".jpeg": "jpeg",
|
|
2326
2331
|
".webp": "webp"
|
|
2327
2332
|
};
|
|
2333
|
+
UNSUPPORTED_OUTPUT_EXTENSIONS = new Set([".jpg", ".jpeg"]);
|
|
2328
2334
|
INPUT_DEDICATED_FLAGS = {
|
|
2329
2335
|
prompt: "--prompt",
|
|
2330
2336
|
seed: "--seed",
|
|
@@ -2333,6 +2339,78 @@ var init_image = __esm(() => {
|
|
|
2333
2339
|
};
|
|
2334
2340
|
});
|
|
2335
2341
|
|
|
2342
|
+
// src/commands/generate/local-image-common.ts
|
|
2343
|
+
import { createHash as createHash2 } from "node:crypto";
|
|
2344
|
+
function isRecord(value) {
|
|
2345
|
+
return typeof value === "object" && value !== null;
|
|
2346
|
+
}
|
|
2347
|
+
function sha256(bytes) {
|
|
2348
|
+
return createHash2("sha256").update(bytes).digest("hex");
|
|
2349
|
+
}
|
|
2350
|
+
function errorMessage(err) {
|
|
2351
|
+
return err instanceof Error ? err.message : String(err);
|
|
2352
|
+
}
|
|
2353
|
+
function hasPngMagic(bytes) {
|
|
2354
|
+
if (bytes.length < PNG_MAGIC.length)
|
|
2355
|
+
return false;
|
|
2356
|
+
return PNG_MAGIC.every((byte, index) => bytes[index] === byte);
|
|
2357
|
+
}
|
|
2358
|
+
function readPngDimensions(bytes) {
|
|
2359
|
+
if (bytes.length < 24)
|
|
2360
|
+
return null;
|
|
2361
|
+
if (bytes[12] !== 73 || bytes[13] !== 72 || bytes[14] !== 68 || bytes[15] !== 82) {
|
|
2362
|
+
return null;
|
|
2363
|
+
}
|
|
2364
|
+
const view = new DataView(bytes.buffer, bytes.byteOffset, bytes.byteLength);
|
|
2365
|
+
return { width: view.getUint32(16), height: view.getUint32(20) };
|
|
2366
|
+
}
|
|
2367
|
+
function formatConflicts(conflicts) {
|
|
2368
|
+
const shown = conflicts.slice(0, 10);
|
|
2369
|
+
const lines = shown.map((conflict) => `- ${conflict.path}: ${conflict.reason}`);
|
|
2370
|
+
if (conflicts.length > shown.length) {
|
|
2371
|
+
lines.push(`- and ${conflicts.length - shown.length} more`);
|
|
2372
|
+
}
|
|
2373
|
+
return `Refusing to write ${conflicts.length} output file(s):
|
|
2374
|
+
${lines.join(`
|
|
2375
|
+
`)}
|
|
2376
|
+
Pass --force to overwrite.`;
|
|
2377
|
+
}
|
|
2378
|
+
async function findOutputConflicts(deps, paths, sourcePaths, sourceIdentities, force) {
|
|
2379
|
+
const matchesSourceIdentity = (identity) => sourceIdentities.some((source) => source !== null && source.dev === identity.dev && source.ino === identity.ino);
|
|
2380
|
+
const conflicts = [];
|
|
2381
|
+
for (const path of paths) {
|
|
2382
|
+
if (sourcePaths.has(path)) {
|
|
2383
|
+
conflicts.push({ path, reason: "this is the source sheet or its manifest" });
|
|
2384
|
+
continue;
|
|
2385
|
+
}
|
|
2386
|
+
if (await deps.isSymlink(path)) {
|
|
2387
|
+
conflicts.push({ path, reason: "this is a symbolic link" });
|
|
2388
|
+
continue;
|
|
2389
|
+
}
|
|
2390
|
+
const status = await deps.pathStatus(path);
|
|
2391
|
+
if (status === "directory") {
|
|
2392
|
+
conflicts.push({ path, reason: "a directory is in the way" });
|
|
2393
|
+
continue;
|
|
2394
|
+
}
|
|
2395
|
+
const identity = await deps.fileIdentity(path);
|
|
2396
|
+
if (identity !== null && matchesSourceIdentity(identity)) {
|
|
2397
|
+
conflicts.push({ path, reason: "this resolves to the source sheet or its manifest" });
|
|
2398
|
+
continue;
|
|
2399
|
+
}
|
|
2400
|
+
if (status === "file" && !force) {
|
|
2401
|
+
conflicts.push({ path, reason: "already exists" });
|
|
2402
|
+
}
|
|
2403
|
+
}
|
|
2404
|
+
return conflicts;
|
|
2405
|
+
}
|
|
2406
|
+
var SAFE_NAME, MAX_SOURCE_PIXELS = 1e8, MAX_SOURCE_BYTES, MAX_SIDECAR_BYTES, PNG_MAGIC;
|
|
2407
|
+
var init_local_image_common = __esm(() => {
|
|
2408
|
+
SAFE_NAME = /^[A-Za-z0-9_][A-Za-z0-9_-]{0,63}$/;
|
|
2409
|
+
MAX_SOURCE_BYTES = 64 * 1024 * 1024;
|
|
2410
|
+
MAX_SIDECAR_BYTES = 1024 * 1024;
|
|
2411
|
+
PNG_MAGIC = new Uint8Array([137, 80, 78, 71, 13, 10, 26, 10]);
|
|
2412
|
+
});
|
|
2413
|
+
|
|
2336
2414
|
// ../../node_modules/.pnpm/@fal-ai+client@1.10.1/node_modules/@fal-ai/client/src/middleware.js
|
|
2337
2415
|
var require_middleware = __commonJS((exports) => {
|
|
2338
2416
|
var __awaiter = exports && exports.__awaiter || function(thisArg, _arguments, P, generator) {
|
|
@@ -6413,6 +6491,8 @@ var init_package_version = () => {};
|
|
|
6413
6491
|
// src/commands/generate/deps.ts
|
|
6414
6492
|
var exports_deps = {};
|
|
6415
6493
|
__export(exports_deps, {
|
|
6494
|
+
fetchBytes: () => fetchBytes,
|
|
6495
|
+
createFalRawSubscribe: () => createFalRawSubscribe,
|
|
6416
6496
|
createDefaultGenerateImageDeps: () => createDefaultGenerateImageDeps
|
|
6417
6497
|
});
|
|
6418
6498
|
import { mkdir } from "node:fs/promises";
|
|
@@ -6518,16 +6598,15 @@ function describeFalError(err) {
|
|
|
6518
6598
|
return formatApiError(err);
|
|
6519
6599
|
return err instanceof Error ? err.message : String(err);
|
|
6520
6600
|
}
|
|
6521
|
-
function
|
|
6601
|
+
function createFalRawSubscribe(env) {
|
|
6522
6602
|
return async (model, input) => {
|
|
6523
6603
|
const credentials = env.FAL_API_KEY;
|
|
6524
6604
|
if (!credentials) {
|
|
6525
6605
|
throw new GenerateImageError(FAL_API_KEY_MISSING_MESSAGE);
|
|
6526
6606
|
}
|
|
6527
6607
|
import_client.fal.config({ credentials });
|
|
6528
|
-
let raw;
|
|
6529
6608
|
try {
|
|
6530
|
-
|
|
6609
|
+
return await import_client.fal.subscribe(model, {
|
|
6531
6610
|
input,
|
|
6532
6611
|
logs: false,
|
|
6533
6612
|
startTimeout: SUBSCRIBE_TIMEOUT_SECONDS
|
|
@@ -6535,9 +6614,12 @@ function createFalSubscribe(env) {
|
|
|
6535
6614
|
} catch (err) {
|
|
6536
6615
|
throw new GenerateImageError(describeFalError(err));
|
|
6537
6616
|
}
|
|
6538
|
-
return validateFalResult(raw);
|
|
6539
6617
|
};
|
|
6540
6618
|
}
|
|
6619
|
+
function createFalSubscribe(env) {
|
|
6620
|
+
const subscribe = createFalRawSubscribe(env);
|
|
6621
|
+
return async (model, input) => validateFalResult(await subscribe(model, input));
|
|
6622
|
+
}
|
|
6541
6623
|
async function ensureParentDir(path) {
|
|
6542
6624
|
await mkdir(dirname2(path), { recursive: true });
|
|
6543
6625
|
}
|
|
@@ -8574,15 +8656,254 @@ var init_remove_background_deps = __esm(() => {
|
|
|
8574
8656
|
init_slice_deps();
|
|
8575
8657
|
});
|
|
8576
8658
|
|
|
8659
|
+
// src/commands/generate/remove-background-fal.ts
|
|
8660
|
+
import { basename as basename2, resolve as resolve3 } from "node:path";
|
|
8661
|
+
function validateBackgroundResult(raw, model) {
|
|
8662
|
+
const unexpected = new RemoveBackgroundFalError(`fal returned no image for ${model}`);
|
|
8663
|
+
if (!isRecord(raw))
|
|
8664
|
+
throw unexpected;
|
|
8665
|
+
const { requestId, data } = raw;
|
|
8666
|
+
if (typeof requestId !== "string" || requestId.length === 0)
|
|
8667
|
+
throw unexpected;
|
|
8668
|
+
if (!isRecord(data) || !isRecord(data.image))
|
|
8669
|
+
throw unexpected;
|
|
8670
|
+
const { url } = data.image;
|
|
8671
|
+
if (typeof url !== "string" || !url.startsWith("https://"))
|
|
8672
|
+
throw unexpected;
|
|
8673
|
+
return { requestId, data: { image: { url } } };
|
|
8674
|
+
}
|
|
8675
|
+
async function requireSource(path, deps) {
|
|
8676
|
+
const stats = await deps.statInput(path);
|
|
8677
|
+
if (stats.kind === "missing")
|
|
8678
|
+
throw new RemoveBackgroundFalError(`Input not found: ${path}`);
|
|
8679
|
+
if (stats.kind === "directory") {
|
|
8680
|
+
throw new RemoveBackgroundFalError(`Input is a directory: ${path}. Pass a PNG file path.`);
|
|
8681
|
+
}
|
|
8682
|
+
if (stats.kind !== "file") {
|
|
8683
|
+
throw new RemoveBackgroundFalError(`Input is not a regular file: ${path}.`);
|
|
8684
|
+
}
|
|
8685
|
+
if (stats.size > MAX_FAL_INPUT_BYTES) {
|
|
8686
|
+
throw new RemoveBackgroundFalError(`${path} is ${stats.size} bytes; the maximum fal input is ${MAX_FAL_INPUT_BYTES} bytes (8 MiB).`);
|
|
8687
|
+
}
|
|
8688
|
+
const bytes = await deps.readInput(path);
|
|
8689
|
+
if (bytes.byteLength > MAX_FAL_INPUT_BYTES) {
|
|
8690
|
+
throw new RemoveBackgroundFalError(`${path} is ${bytes.byteLength} bytes; the maximum fal input is ${MAX_FAL_INPUT_BYTES} bytes (8 MiB).`);
|
|
8691
|
+
}
|
|
8692
|
+
if (!hasPngMagic(bytes))
|
|
8693
|
+
throw new RemoveBackgroundFalError(`${path} is not a PNG.`);
|
|
8694
|
+
const dimensions = readPngDimensions(bytes);
|
|
8695
|
+
if (dimensions === null || dimensions.width === 0 || dimensions.height === 0) {
|
|
8696
|
+
throw new RemoveBackgroundFalError(`Could not decode ${path}: missing or invalid IHDR.`);
|
|
8697
|
+
}
|
|
8698
|
+
if (dimensions.width * dimensions.height > MAX_SOURCE_PIXELS) {
|
|
8699
|
+
throw new RemoveBackgroundFalError(`${path} is ${dimensions.width}x${dimensions.height}; the maximum is ${MAX_SOURCE_PIXELS} pixels.`);
|
|
8700
|
+
}
|
|
8701
|
+
return { bytes, width: dimensions.width, height: dimensions.height };
|
|
8702
|
+
}
|
|
8703
|
+
function requireMatchingDimensions(args) {
|
|
8704
|
+
const result = readPngDimensions(args.bytes);
|
|
8705
|
+
const recovery = `The result can still be recovered from that URL.`;
|
|
8706
|
+
const hint = `Re-run with --engine birefnet, or resize the sheet so the engine accepts it.`;
|
|
8707
|
+
if (result === null) {
|
|
8708
|
+
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}`);
|
|
8709
|
+
}
|
|
8710
|
+
if (result.width !== args.input.width || result.height !== args.input.height) {
|
|
8711
|
+
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}`);
|
|
8712
|
+
}
|
|
8713
|
+
return result;
|
|
8714
|
+
}
|
|
8715
|
+
async function requireWritablePath2(path, label, force, deps) {
|
|
8716
|
+
const status = await deps.pathStatus(path);
|
|
8717
|
+
if (status === "directory") {
|
|
8718
|
+
throw new RemoveBackgroundFalError(`${label} is a directory: ${path}. Pass a file path.`);
|
|
8719
|
+
}
|
|
8720
|
+
if (status === "file" && !force) {
|
|
8721
|
+
throw new RemoveBackgroundFalError(`${label} already exists: ${path}. Pass --force to overwrite.`);
|
|
8722
|
+
}
|
|
8723
|
+
}
|
|
8724
|
+
async function requireWritableOutputs(outPath, manifestPath, force, deps) {
|
|
8725
|
+
await requireWritablePath2(outPath, "--out", force, deps);
|
|
8726
|
+
await requireWritablePath2(manifestPath, "Manifest", force, deps);
|
|
8727
|
+
}
|
|
8728
|
+
function manifestSaveMessage(err, requestId, outPath, manifestPath) {
|
|
8729
|
+
const detail = err instanceof Error ? err.message : String(err);
|
|
8730
|
+
return `Failed to save manifest ${manifestPath} for request ${requestId} (output ${outPath}): ${detail}. The image was written but its manifest is missing.`;
|
|
8731
|
+
}
|
|
8732
|
+
function recoveryMessage2(action, err, requestId, url) {
|
|
8733
|
+
const detail = err instanceof Error ? err.message : String(err);
|
|
8734
|
+
return `Failed to ${action} image for request ${requestId} (${url}): ${detail}. The result can still be recovered from that URL.`;
|
|
8735
|
+
}
|
|
8736
|
+
async function removeBackgroundFal(options, deps) {
|
|
8737
|
+
if (!deps.env.FAL_API_KEY) {
|
|
8738
|
+
throw new RemoveBackgroundFalError(FAL_API_KEY_MISSING_MESSAGE);
|
|
8739
|
+
}
|
|
8740
|
+
const engine = options.engine ?? DEFAULT_BACKGROUND_ENGINE;
|
|
8741
|
+
const spec = BACKGROUND_ENGINES[engine];
|
|
8742
|
+
const inPath = resolve3(options.in);
|
|
8743
|
+
const outPath = resolve3(options.out);
|
|
8744
|
+
const manifestPath = `${outPath}.json`;
|
|
8745
|
+
if (inPath === outPath) {
|
|
8746
|
+
throw new RemoveBackgroundFalError(`--in and --out are the same file: ${inPath}. Choose a different output path.`);
|
|
8747
|
+
}
|
|
8748
|
+
const source = await requireSource(inPath, deps);
|
|
8749
|
+
await requireWritableOutputs(outPath, manifestPath, options.force === true, deps);
|
|
8750
|
+
const dataUri = `data:image/png;base64,${Buffer.from(source.bytes).toString("base64")}`;
|
|
8751
|
+
const raw = await deps.falSubscribe(spec.model, spec.buildInput(dataUri));
|
|
8752
|
+
const result = validateBackgroundResult(raw, spec.model);
|
|
8753
|
+
const imageUrl = result.data.image.url;
|
|
8754
|
+
let bytes;
|
|
8755
|
+
try {
|
|
8756
|
+
bytes = await deps.fetchBytes(imageUrl);
|
|
8757
|
+
} catch (err) {
|
|
8758
|
+
throw new RemoveBackgroundFalError(recoveryMessage2("download", err, result.requestId, imageUrl));
|
|
8759
|
+
}
|
|
8760
|
+
if (bytes.byteLength > MAX_FAL_RESULT_BYTES) {
|
|
8761
|
+
throw new RemoveBackgroundFalError(`Downloaded image is ${bytes.byteLength} bytes; the maximum is ${MAX_FAL_RESULT_BYTES} bytes (32 MiB).`);
|
|
8762
|
+
}
|
|
8763
|
+
if (!hasPngMagic(bytes)) {
|
|
8764
|
+
throw new RemoveBackgroundFalError(`Downloaded file is not a PNG (request ${result.requestId}, ${imageUrl}).`);
|
|
8765
|
+
}
|
|
8766
|
+
const outputDimensions = requireMatchingDimensions({
|
|
8767
|
+
bytes,
|
|
8768
|
+
input: source,
|
|
8769
|
+
requestId: result.requestId,
|
|
8770
|
+
imageUrl,
|
|
8771
|
+
outPath
|
|
8772
|
+
});
|
|
8773
|
+
const outputSha256 = sha256(bytes);
|
|
8774
|
+
const manifest = {
|
|
8775
|
+
platform: "fal",
|
|
8776
|
+
tool: TOOL2,
|
|
8777
|
+
sdk: `@fal-ai/client@${deps.sdkVersion}`,
|
|
8778
|
+
engine,
|
|
8779
|
+
model: spec.model,
|
|
8780
|
+
input: {
|
|
8781
|
+
...engine === "birefnet" ? { mode: "Matting", output_format: "png" } : {},
|
|
8782
|
+
source: basename2(inPath),
|
|
8783
|
+
sourceBytes: source.bytes.byteLength,
|
|
8784
|
+
sourceSha256: sha256(source.bytes),
|
|
8785
|
+
width: source.width,
|
|
8786
|
+
height: source.height
|
|
8787
|
+
},
|
|
8788
|
+
requestId: result.requestId,
|
|
8789
|
+
output: {
|
|
8790
|
+
path: outPath,
|
|
8791
|
+
sha256: outputSha256,
|
|
8792
|
+
bytes: bytes.byteLength,
|
|
8793
|
+
contentType: "image/png",
|
|
8794
|
+
width: outputDimensions.width,
|
|
8795
|
+
height: outputDimensions.height
|
|
8796
|
+
},
|
|
8797
|
+
generatedAt: deps.now().toISOString(),
|
|
8798
|
+
licensing: LICENSING2
|
|
8799
|
+
};
|
|
8800
|
+
try {
|
|
8801
|
+
await deps.ensureParentDir(outPath);
|
|
8802
|
+
await deps.writeFile(outPath, bytes);
|
|
8803
|
+
} catch (err) {
|
|
8804
|
+
throw new RemoveBackgroundFalError(recoveryMessage2("save", err, result.requestId, imageUrl));
|
|
8805
|
+
}
|
|
8806
|
+
try {
|
|
8807
|
+
await deps.writeJson(manifestPath, manifest);
|
|
8808
|
+
} catch (err) {
|
|
8809
|
+
throw new RemoveBackgroundFalError(manifestSaveMessage(err, result.requestId, outPath, manifestPath));
|
|
8810
|
+
}
|
|
8811
|
+
return {
|
|
8812
|
+
outPath,
|
|
8813
|
+
manifestPath,
|
|
8814
|
+
requestId: result.requestId,
|
|
8815
|
+
bytes: bytes.byteLength,
|
|
8816
|
+
sha256: outputSha256
|
|
8817
|
+
};
|
|
8818
|
+
}
|
|
8819
|
+
var DEFAULT_BACKGROUND_ENGINE = "bria", BACKGROUND_ENGINES, MAX_FAL_INPUT_BYTES, MAX_FAL_RESULT_BYTES, TOOL2 = "chatroom remove-image-background-fal", LICENSING2 = "unverified", RemoveBackgroundFalError;
|
|
8820
|
+
var init_remove_background_fal = __esm(() => {
|
|
8821
|
+
init_image();
|
|
8822
|
+
init_local_image_common();
|
|
8823
|
+
BACKGROUND_ENGINES = {
|
|
8824
|
+
bria: {
|
|
8825
|
+
model: "fal-ai/bria/background/remove",
|
|
8826
|
+
buildInput: (image_url) => ({ image_url })
|
|
8827
|
+
},
|
|
8828
|
+
birefnet: {
|
|
8829
|
+
model: "fal-ai/birefnet/v2",
|
|
8830
|
+
buildInput: (image_url) => ({ image_url, model: "Matting", output_format: "png" })
|
|
8831
|
+
}
|
|
8832
|
+
};
|
|
8833
|
+
MAX_FAL_INPUT_BYTES = 8 * 1024 * 1024;
|
|
8834
|
+
MAX_FAL_RESULT_BYTES = 32 * 1024 * 1024;
|
|
8835
|
+
RemoveBackgroundFalError = class RemoveBackgroundFalError extends Error {
|
|
8836
|
+
constructor(message) {
|
|
8837
|
+
super(message);
|
|
8838
|
+
this.name = "RemoveBackgroundFalError";
|
|
8839
|
+
}
|
|
8840
|
+
};
|
|
8841
|
+
});
|
|
8842
|
+
|
|
8843
|
+
// src/commands/generate/remove-background-fal-deps.ts
|
|
8844
|
+
var exports_remove_background_fal_deps = {};
|
|
8845
|
+
__export(exports_remove_background_fal_deps, {
|
|
8846
|
+
createDefaultRemoveBackgroundFalDeps: () => createDefaultRemoveBackgroundFalDeps
|
|
8847
|
+
});
|
|
8848
|
+
import { dirname as dirname4 } from "node:path";
|
|
8849
|
+
function mebibytes(bytes) {
|
|
8850
|
+
return Math.round(bytes / (1024 * 1024));
|
|
8851
|
+
}
|
|
8852
|
+
function requireDeclaredSize(declared, maxBytes) {
|
|
8853
|
+
if (declared === null)
|
|
8854
|
+
return;
|
|
8855
|
+
const size = Number(declared);
|
|
8856
|
+
if (!Number.isFinite(size) || size <= maxBytes)
|
|
8857
|
+
return;
|
|
8858
|
+
throw new Error(`Downloaded image is ${size} bytes; the maximum is ${maxBytes} bytes (${mebibytes(maxBytes)} MiB).`);
|
|
8859
|
+
}
|
|
8860
|
+
function requireImageContentType2(response) {
|
|
8861
|
+
const contentType = response.headers.get("content-type") ?? "";
|
|
8862
|
+
if (contentType.toLowerCase().startsWith("image/"))
|
|
8863
|
+
return;
|
|
8864
|
+
throw new Error(`Downloaded file is not an image (HTTP ${response.status}, content-type: ${contentType || "missing"})`);
|
|
8865
|
+
}
|
|
8866
|
+
async function fetchCappedBytes(url, maxBytes) {
|
|
8867
|
+
const response = await fetch(url);
|
|
8868
|
+
if (!response.ok) {
|
|
8869
|
+
throw new Error(`Failed to download image (HTTP ${response.status} ${response.statusText})`);
|
|
8870
|
+
}
|
|
8871
|
+
requireDeclaredSize(response.headers.get("content-length"), maxBytes);
|
|
8872
|
+
requireImageContentType2(response);
|
|
8873
|
+
return new Uint8Array(await response.arrayBuffer());
|
|
8874
|
+
}
|
|
8875
|
+
function createDefaultRemoveBackgroundFalDeps() {
|
|
8876
|
+
const slice = createDefaultSliceImageDeps();
|
|
8877
|
+
return {
|
|
8878
|
+
env: process.env,
|
|
8879
|
+
falSubscribe: createFalRawSubscribe(process.env),
|
|
8880
|
+
fetchBytes: (url) => fetchCappedBytes(url, MAX_FAL_RESULT_BYTES),
|
|
8881
|
+
readInput: slice.readFile,
|
|
8882
|
+
statInput: slice.statInput,
|
|
8883
|
+
pathStatus: slice.pathStatus,
|
|
8884
|
+
writeFile: slice.writeFile,
|
|
8885
|
+
writeJson: slice.writeJson,
|
|
8886
|
+
ensureParentDir: (path) => slice.ensureDir(dirname4(path)),
|
|
8887
|
+
now: () => new Date,
|
|
8888
|
+
sdkVersion: readInstalledPackageVersion("@fal-ai/client")
|
|
8889
|
+
};
|
|
8890
|
+
}
|
|
8891
|
+
var init_remove_background_fal_deps = __esm(() => {
|
|
8892
|
+
init_deps();
|
|
8893
|
+
init_package_version();
|
|
8894
|
+
init_remove_background_fal();
|
|
8895
|
+
init_slice_deps();
|
|
8896
|
+
});
|
|
8897
|
+
|
|
8577
8898
|
// src/utils/file-content.ts
|
|
8578
8899
|
var exports_file_content = {};
|
|
8579
8900
|
__export(exports_file_content, {
|
|
8580
8901
|
readFileContent: () => readFileContent
|
|
8581
8902
|
});
|
|
8582
8903
|
import { readFileSync as readFileSync2 } from "node:fs";
|
|
8583
|
-
import { resolve as
|
|
8904
|
+
import { resolve as resolve5 } from "node:path";
|
|
8584
8905
|
function readFileContent(filePath, optionName) {
|
|
8585
|
-
const absolutePath =
|
|
8906
|
+
const absolutePath = resolve5(process.cwd(), filePath);
|
|
8586
8907
|
try {
|
|
8587
8908
|
return readFileSync2(absolutePath, "utf-8");
|
|
8588
8909
|
} catch (err) {
|
|
@@ -8663,12 +8984,12 @@ var init_stdin_heredoc = __esm(() => {
|
|
|
8663
8984
|
|
|
8664
8985
|
// src/version.ts
|
|
8665
8986
|
import { readFileSync as readFileSync3 } from "node:fs";
|
|
8666
|
-
import { dirname as
|
|
8987
|
+
import { dirname as dirname5, join as join4 } from "node:path";
|
|
8667
8988
|
import { fileURLToPath } from "node:url";
|
|
8668
8989
|
function getVersion() {
|
|
8669
8990
|
try {
|
|
8670
8991
|
const __filename2 = fileURLToPath(import.meta.url);
|
|
8671
|
-
const __dirname2 =
|
|
8992
|
+
const __dirname2 = dirname5(__filename2);
|
|
8672
8993
|
const possiblePaths = [
|
|
8673
8994
|
join4(__dirname2, "..", "package.json"),
|
|
8674
8995
|
join4(__dirname2, "..", "..", "package.json")
|
|
@@ -10094,11 +10415,11 @@ class RequestManager {
|
|
|
10094
10415
|
this.requestsOlderThanRestart = /* @__PURE__ */ new Set;
|
|
10095
10416
|
}
|
|
10096
10417
|
request(message, sent) {
|
|
10097
|
-
const result = new Promise((
|
|
10418
|
+
const result = new Promise((resolve6) => {
|
|
10098
10419
|
const status = sent ? "Requested" : "NotSent";
|
|
10099
10420
|
this.inflightRequests.set(message.requestId, {
|
|
10100
10421
|
message,
|
|
10101
|
-
status: { status, requestedAt: /* @__PURE__ */ new Date, onResult:
|
|
10422
|
+
status: { status, requestedAt: /* @__PURE__ */ new Date, onResult: resolve6 }
|
|
10102
10423
|
});
|
|
10103
10424
|
if (message.type === "Mutation") {
|
|
10104
10425
|
this.inflightMutationsCount++;
|
|
@@ -12603,10 +12924,10 @@ class ConvexClient {
|
|
|
12603
12924
|
const value = this.client.localQueryResult(getFunctionName(query), args);
|
|
12604
12925
|
if (value !== undefined)
|
|
12605
12926
|
return Promise.resolve(value);
|
|
12606
|
-
return new Promise((
|
|
12927
|
+
return new Promise((resolve6, reject) => {
|
|
12607
12928
|
const { unsubscribe } = this.onUpdate(query, args, (value2) => {
|
|
12608
12929
|
unsubscribe();
|
|
12609
|
-
|
|
12930
|
+
resolve6(value2);
|
|
12610
12931
|
}, (e) => {
|
|
12611
12932
|
unsubscribe();
|
|
12612
12933
|
reject(e);
|
|
@@ -12716,10 +13037,10 @@ var init_simple_client_node = __esm(() => {
|
|
|
12716
13037
|
if (debug)
|
|
12717
13038
|
return debug;
|
|
12718
13039
|
}
|
|
12719
|
-
var prebuild =
|
|
13040
|
+
var prebuild = resolve6(dir);
|
|
12720
13041
|
if (prebuild)
|
|
12721
13042
|
return prebuild;
|
|
12722
|
-
var nearby =
|
|
13043
|
+
var nearby = resolve6(path.dirname(process.execPath));
|
|
12723
13044
|
if (nearby)
|
|
12724
13045
|
return nearby;
|
|
12725
13046
|
var target = [
|
|
@@ -12737,7 +13058,7 @@ var init_simple_client_node = __esm(() => {
|
|
|
12737
13058
|
throw new Error("No native build was found for " + target + `
|
|
12738
13059
|
loaded from: ` + dir + `
|
|
12739
13060
|
`);
|
|
12740
|
-
function
|
|
13061
|
+
function resolve6(dir2) {
|
|
12741
13062
|
var tuples = readdirSync(path.join(dir2, "prebuilds")).map(parseTuple);
|
|
12742
13063
|
var tuple = tuples.filter(matchTuple(platform, arch)).sort(compareTuples)[0];
|
|
12743
13064
|
if (!tuple)
|
|
@@ -15962,10 +16283,10 @@ class ConvexHttpClient {
|
|
|
15962
16283
|
}
|
|
15963
16284
|
this.isProcessingQueue = true;
|
|
15964
16285
|
while (this.mutationQueue.length > 0) {
|
|
15965
|
-
const { mutation, args, resolve:
|
|
16286
|
+
const { mutation, args, resolve: resolve6, reject } = this.mutationQueue.shift();
|
|
15966
16287
|
try {
|
|
15967
16288
|
const result = await this.mutationInner(mutation, args);
|
|
15968
|
-
|
|
16289
|
+
resolve6(result);
|
|
15969
16290
|
} catch (error) {
|
|
15970
16291
|
reject(error);
|
|
15971
16292
|
}
|
|
@@ -15973,8 +16294,8 @@ class ConvexHttpClient {
|
|
|
15973
16294
|
this.isProcessingQueue = false;
|
|
15974
16295
|
}
|
|
15975
16296
|
enqueueMutation(mutation, args) {
|
|
15976
|
-
return new Promise((
|
|
15977
|
-
this.mutationQueue.push({ mutation, args, resolve:
|
|
16297
|
+
return new Promise((resolve6, reject) => {
|
|
16298
|
+
this.mutationQueue.push({ mutation, args, resolve: resolve6, reject });
|
|
15978
16299
|
this.processMutationQueue();
|
|
15979
16300
|
});
|
|
15980
16301
|
}
|
|
@@ -16606,7 +16927,7 @@ async function retryValidation(sessionId, convexUrl, retryIntervalMs) {
|
|
|
16606
16927
|
} else {
|
|
16607
16928
|
console.log(`❌ Backend still unreachable (attempt ${consecutiveNetworkFailures}, retrying in ${retrySec}s)`);
|
|
16608
16929
|
}
|
|
16609
|
-
await new Promise((
|
|
16930
|
+
await new Promise((resolve6) => setTimeout(resolve6, retryIntervalMs));
|
|
16610
16931
|
}
|
|
16611
16932
|
}
|
|
16612
16933
|
}
|
|
@@ -20369,8 +20690,8 @@ ${prefix}}`;
|
|
|
20369
20690
|
const runFork2 = runForkWith(context2);
|
|
20370
20691
|
return (effect, options) => {
|
|
20371
20692
|
const fiber2 = runFork2(effect, options);
|
|
20372
|
-
return new Promise((
|
|
20373
|
-
fiber2.addObserver((exit2) =>
|
|
20693
|
+
return new Promise((resolve6) => {
|
|
20694
|
+
fiber2.addObserver((exit2) => resolve6(exit2));
|
|
20374
20695
|
});
|
|
20375
20696
|
};
|
|
20376
20697
|
}, runPromiseExit, runPromiseWith = (context2) => {
|
|
@@ -25261,7 +25582,7 @@ var init_clock = __esm(() => {
|
|
|
25261
25582
|
};
|
|
25262
25583
|
ClockServiceLive = exports_Layer.succeed(ClockService, {
|
|
25263
25584
|
now: () => exports_Effect.sync(() => Date.now()),
|
|
25264
|
-
delay: (ms) => exports_Effect.promise(() => new Promise((
|
|
25585
|
+
delay: (ms) => exports_Effect.promise(() => new Promise((resolve6) => setTimeout(resolve6, ms)))
|
|
25265
25586
|
});
|
|
25266
25587
|
});
|
|
25267
25588
|
|
|
@@ -25368,7 +25689,7 @@ function createDefaultDeps() {
|
|
|
25368
25689
|
},
|
|
25369
25690
|
clock: {
|
|
25370
25691
|
now: () => Date.now(),
|
|
25371
|
-
delay: (ms) => new Promise((
|
|
25692
|
+
delay: (ms) => new Promise((resolve6) => setTimeout(resolve6, ms))
|
|
25372
25693
|
},
|
|
25373
25694
|
process: {
|
|
25374
25695
|
env: process.env,
|
|
@@ -25933,7 +26254,7 @@ class BaseCLIAgentService {
|
|
|
25933
26254
|
} catch {
|
|
25934
26255
|
return;
|
|
25935
26256
|
}
|
|
25936
|
-
await new Promise((
|
|
26257
|
+
await new Promise((resolve6) => setTimeout(resolve6, POLL_INTERVAL_MS));
|
|
25937
26258
|
}
|
|
25938
26259
|
try {
|
|
25939
26260
|
this.deps.kill(-pid, "SIGKILL");
|
|
@@ -25969,7 +26290,7 @@ class BaseCLIAgentService {
|
|
|
25969
26290
|
return buildAgentSpawnEnv(resolvedConvexUrl);
|
|
25970
26291
|
}
|
|
25971
26292
|
async assertChildProcessStarted(childProcess) {
|
|
25972
|
-
await new Promise((
|
|
26293
|
+
await new Promise((resolve6) => setTimeout(resolve6, SPAWN_READY_DELAY_MS));
|
|
25973
26294
|
if (childProcess.killed || childProcess.exitCode !== null) {
|
|
25974
26295
|
throw new Error(`Agent process exited immediately (exit code: ${childProcess.exitCode})`);
|
|
25975
26296
|
}
|
|
@@ -26411,7 +26732,7 @@ function applyAgentConfigOverrides(input) {
|
|
|
26411
26732
|
};
|
|
26412
26733
|
}
|
|
26413
26734
|
function waitForSlotChange(execution, input, remainingMs) {
|
|
26414
|
-
return new Promise((
|
|
26735
|
+
return new Promise((resolve6, reject) => {
|
|
26415
26736
|
let settled = false;
|
|
26416
26737
|
const finish = (error) => {
|
|
26417
26738
|
if (settled)
|
|
@@ -26425,7 +26746,7 @@ function waitForSlotChange(execution, input, remainingMs) {
|
|
|
26425
26746
|
if (error !== undefined)
|
|
26426
26747
|
reject(error);
|
|
26427
26748
|
else
|
|
26428
|
-
|
|
26749
|
+
resolve6();
|
|
26429
26750
|
};
|
|
26430
26751
|
const matches = (event) => event.chatroomId === input.chatroomId && event.role.toLowerCase() === input.role.toLowerCase();
|
|
26431
26752
|
const onStarted = async (event) => {
|
|
@@ -26513,8 +26834,8 @@ function createAgentProcessManagerService(deps) {
|
|
|
26513
26834
|
});
|
|
26514
26835
|
const submit = (commandFactory) => {
|
|
26515
26836
|
const operationId = randomUUID();
|
|
26516
|
-
const completion = new Promise((
|
|
26517
|
-
pendingOperations.set(operationId, { resolve:
|
|
26837
|
+
const completion = new Promise((resolve6, reject) => {
|
|
26838
|
+
pendingOperations.set(operationId, { resolve: resolve6, reject });
|
|
26518
26839
|
});
|
|
26519
26840
|
const command = commandFactory(operationId);
|
|
26520
26841
|
const message = commandMessage(command);
|
|
@@ -42954,7 +43275,7 @@ var init_parse_session_augmentation = __esm(() => {
|
|
|
42954
43275
|
|
|
42955
43276
|
// src/daemon/services/task-service/service/native-cold-session-before-inject.ts
|
|
42956
43277
|
function sleep3(ms) {
|
|
42957
|
-
return new Promise((
|
|
43278
|
+
return new Promise((resolve6) => setTimeout(resolve6, ms));
|
|
42958
43279
|
}
|
|
42959
43280
|
async function waitForHarnessSessionId(agentMgr, chatroomId, role, signal) {
|
|
42960
43281
|
const deadline = Date.now() + HARNESS_SESSION_READY_TIMEOUT_MS;
|
|
@@ -43485,8 +43806,8 @@ class AgentWorkManager {
|
|
|
43485
43806
|
if (existing)
|
|
43486
43807
|
return existing.drainPromise;
|
|
43487
43808
|
let resolveCompletion;
|
|
43488
|
-
const completion = new Promise((
|
|
43489
|
-
resolveCompletion =
|
|
43809
|
+
const completion = new Promise((resolve6) => {
|
|
43810
|
+
resolveCompletion = resolve6;
|
|
43490
43811
|
});
|
|
43491
43812
|
getRoleDeliveryState().resetDeliveryState(args2.chatroomId, args2.role);
|
|
43492
43813
|
const drainPromise = this.nativeTaskDeliveryQueue.invalidateRole(args2.chatroomId, args2.role);
|
|
@@ -44478,7 +44799,7 @@ class InMemoryCommandQueueStore {
|
|
|
44478
44799
|
// src/daemon/services/agent-process-service/infrastructure/components/command-queue/consumer/command-queue-consumer.ts
|
|
44479
44800
|
import { randomUUID as randomUUID2 } from "node:crypto";
|
|
44480
44801
|
function defaultSleep(milliseconds) {
|
|
44481
|
-
return new Promise((
|
|
44802
|
+
return new Promise((resolve6) => setTimeout(resolve6, milliseconds));
|
|
44482
44803
|
}
|
|
44483
44804
|
|
|
44484
44805
|
class CommandQueueConsumer {
|
|
@@ -48083,7 +48404,7 @@ var init_task_service = __esm(() => {
|
|
|
48083
48404
|
|
|
48084
48405
|
// src/daemon/services/task-service/infrastructure/repository/task-handoff-repository.ts
|
|
48085
48406
|
import { mkdirSync as mkdirSync2 } from "node:fs";
|
|
48086
|
-
import { dirname as
|
|
48407
|
+
import { dirname as dirname6 } from "node:path";
|
|
48087
48408
|
import { DatabaseSync } from "node:sqlite";
|
|
48088
48409
|
function normalizeRole(role) {
|
|
48089
48410
|
return role.toLowerCase();
|
|
@@ -48103,7 +48424,7 @@ function mapRow(row) {
|
|
|
48103
48424
|
};
|
|
48104
48425
|
}
|
|
48105
48426
|
function createTaskHandoffRepository(dbPath) {
|
|
48106
|
-
mkdirSync2(
|
|
48427
|
+
mkdirSync2(dirname6(dbPath), { recursive: true });
|
|
48107
48428
|
const db = new DatabaseSync(dbPath);
|
|
48108
48429
|
db.exec(`
|
|
48109
48430
|
CREATE TABLE IF NOT EXISTS task_handoffs (
|
|
@@ -50032,7 +50353,7 @@ function isCatalogueStable(state, key, now) {
|
|
|
50032
50353
|
return now - state.stableSince >= WARMUP_STABLE_WINDOW_MS;
|
|
50033
50354
|
}
|
|
50034
50355
|
function sleep4(ms) {
|
|
50035
|
-
return new Promise((
|
|
50356
|
+
return new Promise((resolve6) => setTimeout(resolve6, Math.max(0, ms)));
|
|
50036
50357
|
}
|
|
50037
50358
|
async function readCatalogueKey(client2, directory, timeoutMs) {
|
|
50038
50359
|
let timer;
|
|
@@ -50067,7 +50388,7 @@ function serverAuthHeaders(password) {
|
|
|
50067
50388
|
};
|
|
50068
50389
|
}
|
|
50069
50390
|
async function waitForListeningUrl(child, options) {
|
|
50070
|
-
return new Promise((
|
|
50391
|
+
return new Promise((resolve6, reject) => {
|
|
50071
50392
|
const buffers = { stdout: "", stderr: "" };
|
|
50072
50393
|
let url2;
|
|
50073
50394
|
let password;
|
|
@@ -50084,7 +50405,7 @@ async function waitForListeningUrl(child, options) {
|
|
|
50084
50405
|
if (url2 === undefined)
|
|
50085
50406
|
return;
|
|
50086
50407
|
cleanup();
|
|
50087
|
-
|
|
50408
|
+
resolve6({ url: url2, ...password !== undefined ? { password } : {} });
|
|
50088
50409
|
};
|
|
50089
50410
|
const tryMatch = (key, chunk) => {
|
|
50090
50411
|
buffers[key] += typeof chunk === "string" ? chunk : chunk.toString("utf8");
|
|
@@ -50217,7 +50538,7 @@ async function stopServeProcess(deps, child) {
|
|
|
50217
50538
|
} catch {
|
|
50218
50539
|
return;
|
|
50219
50540
|
}
|
|
50220
|
-
await new Promise((
|
|
50541
|
+
await new Promise((resolve6) => setTimeout(resolve6, SERVE_KILL_POLL_INTERVAL_MS));
|
|
50221
50542
|
}
|
|
50222
50543
|
try {
|
|
50223
50544
|
deps.kill(-pid, "SIGKILL");
|
|
@@ -50762,27 +51083,27 @@ var init_pi_agent_service = __esm(() => {
|
|
|
50762
51083
|
return childProcess;
|
|
50763
51084
|
}
|
|
50764
51085
|
writePrompt(child, prompt) {
|
|
50765
|
-
return new Promise((
|
|
51086
|
+
return new Promise((resolve6, reject) => {
|
|
50766
51087
|
if (!child.stdin) {
|
|
50767
51088
|
reject(new Error("Pi RPC process has no stdin"));
|
|
50768
51089
|
return;
|
|
50769
51090
|
}
|
|
50770
51091
|
const message = JSON.stringify({ type: "prompt", message: prompt }) + `
|
|
50771
51092
|
`;
|
|
50772
|
-
child.stdin.write(message, (err) => err ? reject(err) :
|
|
51093
|
+
child.stdin.write(message, (err) => err ? reject(err) : resolve6());
|
|
50773
51094
|
});
|
|
50774
51095
|
}
|
|
50775
51096
|
async querySessionId(reader, stdin) {
|
|
50776
51097
|
if (!stdin) {
|
|
50777
51098
|
throw new Error("Pi RPC process has no stdin");
|
|
50778
51099
|
}
|
|
50779
|
-
return new Promise((
|
|
51100
|
+
return new Promise((resolve6, reject) => {
|
|
50780
51101
|
const timer = setTimeout(() => {
|
|
50781
51102
|
reject(new Error(`get_state timed out after ${GET_STATE_TIMEOUT_MS}ms`));
|
|
50782
51103
|
}, GET_STATE_TIMEOUT_MS);
|
|
50783
51104
|
reader.onStateResponse((sessionId) => {
|
|
50784
51105
|
clearTimeout(timer);
|
|
50785
|
-
|
|
51106
|
+
resolve6(sessionId);
|
|
50786
51107
|
});
|
|
50787
51108
|
stdin.write(JSON.stringify({ type: "get_state" }) + `
|
|
50788
51109
|
`);
|
|
@@ -51128,12 +51449,12 @@ var init_model_provider = () => {};
|
|
|
51128
51449
|
// src/daemon/infrastructure/local/harness/services/cursor-sdk/cursor-sdk-package.ts
|
|
51129
51450
|
import { existsSync as existsSync2, readFileSync as readFileSync5 } from "node:fs";
|
|
51130
51451
|
import { createRequire as createRequire4 } from "node:module";
|
|
51131
|
-
import { dirname as
|
|
51452
|
+
import { dirname as dirname7, join as join9 } from "node:path";
|
|
51132
51453
|
import { fileURLToPath as fileURLToPath2, pathToFileURL } from "node:url";
|
|
51133
51454
|
function resolveChatroomCliRoot(moduleRef = import.meta.url) {
|
|
51134
51455
|
const filePath = moduleRef.startsWith("file:") ? fileURLToPath2(moduleRef) : moduleRef;
|
|
51135
|
-
let dir =
|
|
51136
|
-
while (dir !==
|
|
51456
|
+
let dir = dirname7(filePath);
|
|
51457
|
+
while (dir !== dirname7(dir)) {
|
|
51137
51458
|
const packageJsonPath = join9(dir, "package.json");
|
|
51138
51459
|
if (existsSync2(packageJsonPath)) {
|
|
51139
51460
|
const pkg = JSON.parse(readFileSync5(packageJsonPath, "utf8"));
|
|
@@ -51141,7 +51462,7 @@ function resolveChatroomCliRoot(moduleRef = import.meta.url) {
|
|
|
51141
51462
|
return dir;
|
|
51142
51463
|
}
|
|
51143
51464
|
}
|
|
51144
|
-
dir =
|
|
51465
|
+
dir = dirname7(dir);
|
|
51145
51466
|
}
|
|
51146
51467
|
throw new CursorSdkPackageError(`Could not locate chatroom-cli package root while resolving @cursor/sdk. ${REINSTALL_HINT}`);
|
|
51147
51468
|
}
|
|
@@ -51156,7 +51477,7 @@ function readPinnedSdkVersion(chatroomCliRoot) {
|
|
|
51156
51477
|
return match5[1];
|
|
51157
51478
|
}
|
|
51158
51479
|
function readInstalledSdkVersion(entryPath) {
|
|
51159
|
-
const packageJsonPath = join9(
|
|
51480
|
+
const packageJsonPath = join9(dirname7(entryPath), "..", "..", "package.json");
|
|
51160
51481
|
const pkg = JSON.parse(readFileSync5(packageJsonPath, "utf8"));
|
|
51161
51482
|
return pkg.version;
|
|
51162
51483
|
}
|
|
@@ -52077,12 +52398,12 @@ import {
|
|
|
52077
52398
|
} from "node:fs";
|
|
52078
52399
|
import { createRequire as createRequire5 } from "node:module";
|
|
52079
52400
|
import { homedir as homedir3 } from "node:os";
|
|
52080
|
-
import { basename as
|
|
52401
|
+
import { basename as basename4, dirname as dirname8, join as join10 } from "node:path";
|
|
52081
52402
|
import { fileURLToPath as fileURLToPath3, pathToFileURL as pathToFileURL2 } from "node:url";
|
|
52082
52403
|
function resolveChatroomCliRoot2(moduleRef = import.meta.url) {
|
|
52083
52404
|
const filePath = moduleRef.startsWith("file:") ? fileURLToPath3(moduleRef) : moduleRef;
|
|
52084
|
-
let dir =
|
|
52085
|
-
while (dir !==
|
|
52405
|
+
let dir = dirname8(filePath);
|
|
52406
|
+
while (dir !== dirname8(dir)) {
|
|
52086
52407
|
const packageJsonPath = join10(dir, "package.json");
|
|
52087
52408
|
if (existsSync3(packageJsonPath)) {
|
|
52088
52409
|
const pkg = JSON.parse(readFileSync6(packageJsonPath, "utf8"));
|
|
@@ -52090,7 +52411,7 @@ function resolveChatroomCliRoot2(moduleRef = import.meta.url) {
|
|
|
52090
52411
|
return realpathSync(dir);
|
|
52091
52412
|
}
|
|
52092
52413
|
}
|
|
52093
|
-
dir =
|
|
52414
|
+
dir = dirname8(dir);
|
|
52094
52415
|
}
|
|
52095
52416
|
throw new ClaudeSdkPackageError(`Could not locate chatroom-cli package root while resolving ${CLAUDE_AGENT_SDK_PKG}. ${REINSTALL_HINT2}`);
|
|
52096
52417
|
}
|
|
@@ -52105,7 +52426,7 @@ function readPinnedSdkVersion2(chatroomCliRoot) {
|
|
|
52105
52426
|
return match5[1];
|
|
52106
52427
|
}
|
|
52107
52428
|
function readInstalledSdkVersion2(entryPath) {
|
|
52108
|
-
const packageJsonPath = join10(
|
|
52429
|
+
const packageJsonPath = join10(dirname8(entryPath), "package.json");
|
|
52109
52430
|
const pkg = JSON.parse(readFileSync6(packageJsonPath, "utf8"));
|
|
52110
52431
|
return pkg.version;
|
|
52111
52432
|
}
|
|
@@ -52131,7 +52452,7 @@ function resolveNativeCliBinaryPath(sdkEntryPath) {
|
|
|
52131
52452
|
const binaryName = process.platform === "win32" ? "claude.exe" : "claude";
|
|
52132
52453
|
let pkgDir;
|
|
52133
52454
|
try {
|
|
52134
|
-
pkgDir =
|
|
52455
|
+
pkgDir = dirname8(require3.resolve(`${platformPkg}/package.json`));
|
|
52135
52456
|
} catch {
|
|
52136
52457
|
throw new ClaudeSdkPackageError(`Native CLI binary package ${platformPkg} is not installed. ${REINSTALL_HINT2}`);
|
|
52137
52458
|
}
|
|
@@ -52143,7 +52464,7 @@ function resolveNativeCliBinaryPath(sdkEntryPath) {
|
|
|
52143
52464
|
}
|
|
52144
52465
|
function pinNativeBinary(sourcePath, sdkVersion, pinRoot) {
|
|
52145
52466
|
const dir = join10(pinRoot, sdkVersion);
|
|
52146
|
-
const pinnedPath = join10(dir,
|
|
52467
|
+
const pinnedPath = join10(dir, basename4(sourcePath));
|
|
52147
52468
|
if (existsSync3(pinnedPath))
|
|
52148
52469
|
return pinnedPath;
|
|
52149
52470
|
mkdirSync3(dir, { recursive: true, mode: 448 });
|
|
@@ -52226,8 +52547,8 @@ function createTurnCompletion(turnId = randomUUID3()) {
|
|
|
52226
52547
|
let resolveResult;
|
|
52227
52548
|
let value;
|
|
52228
52549
|
const listeners = new Set;
|
|
52229
|
-
const result3 = new Promise((
|
|
52230
|
-
resolveResult =
|
|
52550
|
+
const result3 = new Promise((resolve6) => {
|
|
52551
|
+
resolveResult = resolve6;
|
|
52231
52552
|
});
|
|
52232
52553
|
return {
|
|
52233
52554
|
turnId,
|
|
@@ -52599,18 +52920,18 @@ function waitForResumeOrAbort(session2) {
|
|
|
52599
52920
|
return Promise.resolve(queued);
|
|
52600
52921
|
}
|
|
52601
52922
|
return Promise.race([
|
|
52602
|
-
new Promise((
|
|
52923
|
+
new Promise((resolve6) => {
|
|
52603
52924
|
session2.resumeResolve = (prompt) => {
|
|
52604
52925
|
session2.resumeResolve = undefined;
|
|
52605
52926
|
session2.abortResolve = undefined;
|
|
52606
|
-
|
|
52927
|
+
resolve6(prompt);
|
|
52607
52928
|
};
|
|
52608
52929
|
}),
|
|
52609
|
-
new Promise((
|
|
52930
|
+
new Promise((resolve6) => {
|
|
52610
52931
|
session2.abortResolve = () => {
|
|
52611
52932
|
session2.resumeResolve = undefined;
|
|
52612
52933
|
session2.abortResolve = undefined;
|
|
52613
|
-
|
|
52934
|
+
resolve6(null);
|
|
52614
52935
|
};
|
|
52615
52936
|
})
|
|
52616
52937
|
]);
|
|
@@ -52694,10 +53015,10 @@ var init_claude_sdk_agent_service = __esm(() => {
|
|
|
52694
53015
|
throw new Error(`No claude-sdk session for pid=${pid}`);
|
|
52695
53016
|
}
|
|
52696
53017
|
if (session2.resumeResolve) {
|
|
52697
|
-
const
|
|
53018
|
+
const resolve6 = session2.resumeResolve;
|
|
52698
53019
|
session2.resumeResolve = undefined;
|
|
52699
53020
|
session2.abortResolve = undefined;
|
|
52700
|
-
|
|
53021
|
+
resolve6(prompt);
|
|
52701
53022
|
return;
|
|
52702
53023
|
}
|
|
52703
53024
|
session2.pendingResumePrompt = prompt;
|
|
@@ -53065,12 +53386,12 @@ var init_codex_sdk_model_variants = __esm(() => {
|
|
|
53065
53386
|
// src/daemon/infrastructure/local/harness/services/codex-sdk/codex-sdk-package.ts
|
|
53066
53387
|
import { existsSync as existsSync4, readFileSync as readFileSync7, realpathSync as realpathSync2, statSync } from "node:fs";
|
|
53067
53388
|
import { createRequire as createRequire6 } from "node:module";
|
|
53068
|
-
import { dirname as
|
|
53389
|
+
import { dirname as dirname9, join as join11 } from "node:path";
|
|
53069
53390
|
import { fileURLToPath as fileURLToPath4, pathToFileURL as pathToFileURL3 } from "node:url";
|
|
53070
53391
|
function resolveChatroomCliRoot3(moduleRef = import.meta.url) {
|
|
53071
53392
|
const filePath = moduleRef.startsWith("file:") ? fileURLToPath4(moduleRef) : moduleRef;
|
|
53072
|
-
let dir =
|
|
53073
|
-
while (dir !==
|
|
53393
|
+
let dir = dirname9(filePath);
|
|
53394
|
+
while (dir !== dirname9(dir)) {
|
|
53074
53395
|
const packageJsonPath = join11(dir, "package.json");
|
|
53075
53396
|
if (existsSync4(packageJsonPath)) {
|
|
53076
53397
|
const pkg = JSON.parse(readFileSync7(packageJsonPath, "utf8"));
|
|
@@ -53078,7 +53399,7 @@ function resolveChatroomCliRoot3(moduleRef = import.meta.url) {
|
|
|
53078
53399
|
return dir;
|
|
53079
53400
|
}
|
|
53080
53401
|
}
|
|
53081
|
-
dir =
|
|
53402
|
+
dir = dirname9(dir);
|
|
53082
53403
|
}
|
|
53083
53404
|
throw new CodexSdkPackageError(`Could not locate chatroom-cli package root while resolving @openai/codex-sdk. ${REINSTALL_HINT3}`);
|
|
53084
53405
|
}
|
|
@@ -53145,7 +53466,7 @@ function addPlatformPackageJsonCandidate(candidates, candidate) {
|
|
|
53145
53466
|
}
|
|
53146
53467
|
function resolvePlatformPackageJsonCandidates(platformPkg, chatroomCliRoot, codexPackageJson, chatroomRequire, codexRequire) {
|
|
53147
53468
|
const candidates = [];
|
|
53148
|
-
const codexPackageDir = realpathSync2(
|
|
53469
|
+
const codexPackageDir = realpathSync2(dirname9(codexPackageJson));
|
|
53149
53470
|
const platformPkgBaseName = platformPkg.includes("/") ? platformPkg.slice(platformPkg.indexOf("/") + 1) : platformPkg;
|
|
53150
53471
|
try {
|
|
53151
53472
|
addPlatformPackageJsonCandidate(candidates, codexRequire.resolve(`${platformPkg}/package.json`));
|
|
@@ -53189,7 +53510,7 @@ function resolveCodexExecutablePath(moduleRef = import.meta.url) {
|
|
|
53189
53510
|
throw new CodexSdkPackageError(`Native Codex CLI package ${platformPkg} is not installed. Ensure ${CODEX_NPM_NAME} is installed with optional dependencies. ${REINSTALL_HINT3}`);
|
|
53190
53511
|
}
|
|
53191
53512
|
for (const platformPackageJson of platformPackageJsonCandidates) {
|
|
53192
|
-
const vendorRoot = join11(
|
|
53513
|
+
const vendorRoot = join11(dirname9(platformPackageJson), "vendor");
|
|
53193
53514
|
const binaryPath = resolveNativeCodexBinary(vendorRoot, targetTriple, codexBinaryName);
|
|
53194
53515
|
if (binaryPath) {
|
|
53195
53516
|
return binaryPath;
|
|
@@ -53205,7 +53526,7 @@ async function importBundledCodexSdk(moduleRef = import.meta.url) {
|
|
|
53205
53526
|
if (installedVersion !== pinnedVersion) {
|
|
53206
53527
|
throw new CodexSdkPackageError(`@openai/codex-sdk@${installedVersion} does not match chatroom-cli pin (${pinnedVersion}). ${REINSTALL_HINT3}`);
|
|
53207
53528
|
}
|
|
53208
|
-
const distEntryPath = join11(
|
|
53529
|
+
const distEntryPath = join11(dirname9(packageJsonPath), "dist", "index.js");
|
|
53209
53530
|
if (!existsSync4(distEntryPath)) {
|
|
53210
53531
|
throw new CodexSdkPackageError(`@openai/codex-sdk entry file is missing: ${distEntryPath}. ${REINSTALL_HINT3}`);
|
|
53211
53532
|
}
|
|
@@ -53497,18 +53818,18 @@ function waitForResumeOrAbort2(session2) {
|
|
|
53497
53818
|
return Promise.resolve(queued);
|
|
53498
53819
|
}
|
|
53499
53820
|
return Promise.race([
|
|
53500
|
-
new Promise((
|
|
53821
|
+
new Promise((resolve6) => {
|
|
53501
53822
|
session2.resumeResolve = (prompt) => {
|
|
53502
53823
|
session2.resumeResolve = undefined;
|
|
53503
53824
|
session2.abortResolve = undefined;
|
|
53504
|
-
|
|
53825
|
+
resolve6(prompt);
|
|
53505
53826
|
};
|
|
53506
53827
|
}),
|
|
53507
|
-
new Promise((
|
|
53828
|
+
new Promise((resolve6) => {
|
|
53508
53829
|
session2.abortResolve = () => {
|
|
53509
53830
|
session2.resumeResolve = undefined;
|
|
53510
53831
|
session2.abortResolve = undefined;
|
|
53511
|
-
|
|
53832
|
+
resolve6(null);
|
|
53512
53833
|
};
|
|
53513
53834
|
})
|
|
53514
53835
|
]);
|
|
@@ -53589,10 +53910,10 @@ var init_codex_sdk_agent_service = __esm(() => {
|
|
|
53589
53910
|
throw new Error(`No codex-sdk session for pid=${pid}`);
|
|
53590
53911
|
}
|
|
53591
53912
|
if (session2.resumeResolve) {
|
|
53592
|
-
const
|
|
53913
|
+
const resolve6 = session2.resumeResolve;
|
|
53593
53914
|
session2.resumeResolve = undefined;
|
|
53594
53915
|
session2.abortResolve = undefined;
|
|
53595
|
-
|
|
53916
|
+
resolve6(prompt);
|
|
53596
53917
|
return;
|
|
53597
53918
|
}
|
|
53598
53919
|
session2.pendingResumePrompt = prompt;
|
|
@@ -54468,18 +54789,18 @@ function waitForResumeOrAbort3(session2) {
|
|
|
54468
54789
|
return Promise.resolve(queued);
|
|
54469
54790
|
}
|
|
54470
54791
|
return Promise.race([
|
|
54471
|
-
new Promise((
|
|
54792
|
+
new Promise((resolve6) => {
|
|
54472
54793
|
session2.resumeResolve = (prompt) => {
|
|
54473
54794
|
session2.resumeResolve = undefined;
|
|
54474
54795
|
session2.abortResolve = undefined;
|
|
54475
|
-
|
|
54796
|
+
resolve6(prompt);
|
|
54476
54797
|
};
|
|
54477
54798
|
}),
|
|
54478
|
-
new Promise((
|
|
54799
|
+
new Promise((resolve6) => {
|
|
54479
54800
|
session2.abortResolve = () => {
|
|
54480
54801
|
session2.resumeResolve = undefined;
|
|
54481
54802
|
session2.abortResolve = undefined;
|
|
54482
|
-
|
|
54803
|
+
resolve6(null);
|
|
54483
54804
|
};
|
|
54484
54805
|
})
|
|
54485
54806
|
]);
|
|
@@ -54552,10 +54873,10 @@ var init_cursor_sdk_agent_service = __esm(() => {
|
|
|
54552
54873
|
throw new Error(`No cursor-sdk session for pid=${pid}`);
|
|
54553
54874
|
}
|
|
54554
54875
|
if (session2.resumeResolve) {
|
|
54555
|
-
const
|
|
54876
|
+
const resolve6 = session2.resumeResolve;
|
|
54556
54877
|
session2.resumeResolve = undefined;
|
|
54557
54878
|
session2.abortResolve = undefined;
|
|
54558
|
-
|
|
54879
|
+
resolve6(prompt);
|
|
54559
54880
|
return;
|
|
54560
54881
|
}
|
|
54561
54882
|
session2.pendingResumePrompt = prompt;
|
|
@@ -54955,8 +55276,8 @@ function startSessionEventForwarder(client2, options) {
|
|
|
54955
55276
|
const agentEndCallbacks = [];
|
|
54956
55277
|
const recentLogLines = [];
|
|
54957
55278
|
let retryIdleTimeout;
|
|
54958
|
-
const donePromise = new Promise((
|
|
54959
|
-
doneResolve =
|
|
55279
|
+
const donePromise = new Promise((resolve6) => {
|
|
55280
|
+
doneResolve = resolve6;
|
|
54960
55281
|
});
|
|
54961
55282
|
function recordRecentLogLine(line) {
|
|
54962
55283
|
recentLogLines.push(line);
|
|
@@ -55298,7 +55619,7 @@ var init_session_event_forwarder = __esm(() => {
|
|
|
55298
55619
|
// src/daemon/infrastructure/local/harness/services/opencode-sdk/session-metadata-store.ts
|
|
55299
55620
|
import { chmodSync as chmodSync2, existsSync as existsSync5, mkdirSync as mkdirSync4, readFileSync as readFileSync8, writeFileSync as writeFileSync2 } from "node:fs";
|
|
55300
55621
|
import { homedir as homedir4 } from "node:os";
|
|
55301
|
-
import { dirname as
|
|
55622
|
+
import { dirname as dirname10, join as join12 } from "node:path";
|
|
55302
55623
|
|
|
55303
55624
|
class FileSessionMetadataStore {
|
|
55304
55625
|
filePath;
|
|
@@ -55315,7 +55636,7 @@ class FileSessionMetadataStore {
|
|
|
55315
55636
|
}
|
|
55316
55637
|
save(sessions) {
|
|
55317
55638
|
try {
|
|
55318
|
-
const dir =
|
|
55639
|
+
const dir = dirname10(this.filePath);
|
|
55319
55640
|
if (!existsSync5(dir)) {
|
|
55320
55641
|
mkdirSync4(dir, { recursive: true, mode: 448 });
|
|
55321
55642
|
}
|
|
@@ -55898,12 +56219,12 @@ var init_opencode_sdk = __esm(() => {
|
|
|
55898
56219
|
|
|
55899
56220
|
// src/daemon/infrastructure/local/harness/services/pi-sdk/pi-sdk-package.ts
|
|
55900
56221
|
import { existsSync as existsSync6, readFileSync as readFileSync9 } from "node:fs";
|
|
55901
|
-
import { dirname as
|
|
56222
|
+
import { dirname as dirname11, join as join13 } from "node:path";
|
|
55902
56223
|
import { fileURLToPath as fileURLToPath5, pathToFileURL as pathToFileURL4 } from "node:url";
|
|
55903
56224
|
function resolveChatroomCliRoot4(moduleRef = import.meta.url) {
|
|
55904
56225
|
const filePath = moduleRef.startsWith("file:") ? fileURLToPath5(moduleRef) : moduleRef;
|
|
55905
|
-
let dir =
|
|
55906
|
-
while (dir !==
|
|
56226
|
+
let dir = dirname11(filePath);
|
|
56227
|
+
while (dir !== dirname11(dir)) {
|
|
55907
56228
|
const packageJsonPath = join13(dir, "package.json");
|
|
55908
56229
|
if (existsSync6(packageJsonPath)) {
|
|
55909
56230
|
const pkg = JSON.parse(readFileSync9(packageJsonPath, "utf8"));
|
|
@@ -55911,7 +56232,7 @@ function resolveChatroomCliRoot4(moduleRef = import.meta.url) {
|
|
|
55911
56232
|
return dir;
|
|
55912
56233
|
}
|
|
55913
56234
|
}
|
|
55914
|
-
dir =
|
|
56235
|
+
dir = dirname11(dir);
|
|
55915
56236
|
}
|
|
55916
56237
|
throw new PiSdkPackageError(`Could not locate chatroom-cli package root while resolving ${PI_CODING_AGENT_PKG}. ${REINSTALL_HINT4}`);
|
|
55917
56238
|
}
|
|
@@ -55926,18 +56247,18 @@ function readPinnedSdkVersion4(chatroomCliRoot) {
|
|
|
55926
56247
|
return match5[1];
|
|
55927
56248
|
}
|
|
55928
56249
|
function readInstalledSdkVersion4(entryPath) {
|
|
55929
|
-
const packageJsonPath = join13(
|
|
56250
|
+
const packageJsonPath = join13(dirname11(entryPath), "..", "package.json");
|
|
55930
56251
|
const pkg = JSON.parse(readFileSync9(packageJsonPath, "utf8"));
|
|
55931
56252
|
return pkg.version;
|
|
55932
56253
|
}
|
|
55933
56254
|
function resolvePiSdkEntryPathFromNodeModules(chatroomCliRoot) {
|
|
55934
56255
|
let dir = chatroomCliRoot;
|
|
55935
|
-
while (dir !==
|
|
56256
|
+
while (dir !== dirname11(dir)) {
|
|
55936
56257
|
const entryPath = join13(dir, "node_modules", PI_CODING_AGENT_PKG, "dist", "index.js");
|
|
55937
56258
|
if (existsSync6(entryPath)) {
|
|
55938
56259
|
return entryPath;
|
|
55939
56260
|
}
|
|
55940
|
-
dir =
|
|
56261
|
+
dir = dirname11(dir);
|
|
55941
56262
|
}
|
|
55942
56263
|
return;
|
|
55943
56264
|
}
|
|
@@ -56156,18 +56477,18 @@ function waitForResumeOrAbort4(session2) {
|
|
|
56156
56477
|
return Promise.resolve(queued);
|
|
56157
56478
|
}
|
|
56158
56479
|
return Promise.race([
|
|
56159
|
-
new Promise((
|
|
56480
|
+
new Promise((resolve6) => {
|
|
56160
56481
|
session2.resumeResolve = (prompt) => {
|
|
56161
56482
|
session2.resumeResolve = undefined;
|
|
56162
56483
|
session2.abortResolve = undefined;
|
|
56163
|
-
|
|
56484
|
+
resolve6(prompt);
|
|
56164
56485
|
};
|
|
56165
56486
|
}),
|
|
56166
|
-
new Promise((
|
|
56487
|
+
new Promise((resolve6) => {
|
|
56167
56488
|
session2.abortResolve = () => {
|
|
56168
56489
|
session2.resumeResolve = undefined;
|
|
56169
56490
|
session2.abortResolve = undefined;
|
|
56170
|
-
|
|
56491
|
+
resolve6(null);
|
|
56171
56492
|
};
|
|
56172
56493
|
})
|
|
56173
56494
|
]);
|
|
@@ -56271,10 +56592,10 @@ var init_pi_sdk_agent_service = __esm(() => {
|
|
|
56271
56592
|
throw new Error(`No pi-sdk session for pid=${pid}`);
|
|
56272
56593
|
}
|
|
56273
56594
|
if (session2.resumeResolve) {
|
|
56274
|
-
const
|
|
56595
|
+
const resolve6 = session2.resumeResolve;
|
|
56275
56596
|
session2.resumeResolve = undefined;
|
|
56276
56597
|
session2.abortResolve = undefined;
|
|
56277
|
-
|
|
56598
|
+
resolve6(prompt);
|
|
56278
56599
|
return;
|
|
56279
56600
|
}
|
|
56280
56601
|
session2.pendingResumePrompt = prompt;
|
|
@@ -63399,9 +63720,9 @@ var init_socket2 = __esm(() => {
|
|
|
63399
63720
|
this.acks[id] = fn3;
|
|
63400
63721
|
}
|
|
63401
63722
|
emitWithAck(ev, ...args2) {
|
|
63402
|
-
return new Promise((
|
|
63723
|
+
return new Promise((resolve6, reject) => {
|
|
63403
63724
|
const fn3 = (arg1, arg2) => {
|
|
63404
|
-
return arg1 ? reject(arg1) :
|
|
63725
|
+
return arg1 ? reject(arg1) : resolve6(arg2);
|
|
63405
63726
|
};
|
|
63406
63727
|
fn3.withError = true;
|
|
63407
63728
|
args2.push(fn3);
|
|
@@ -64080,10 +64401,10 @@ async function requestLocalDaemon(port, event, payload) {
|
|
|
64080
64401
|
timeout: 2000
|
|
64081
64402
|
});
|
|
64082
64403
|
try {
|
|
64083
|
-
await new Promise((
|
|
64404
|
+
await new Promise((resolve6, reject) => {
|
|
64084
64405
|
const onConnect = () => {
|
|
64085
64406
|
cleanup();
|
|
64086
|
-
|
|
64407
|
+
resolve6();
|
|
64087
64408
|
};
|
|
64088
64409
|
const onError3 = (error51) => {
|
|
64089
64410
|
cleanup();
|
|
@@ -64339,10 +64660,10 @@ var init_log_schema = __esm(() => {
|
|
|
64339
64660
|
|
|
64340
64661
|
// src/infrastructure/log-server/open-log-database.ts
|
|
64341
64662
|
import { mkdirSync as mkdirSync5 } from "node:fs";
|
|
64342
|
-
import { dirname as
|
|
64663
|
+
import { dirname as dirname12 } from "node:path";
|
|
64343
64664
|
import { DatabaseSync as DatabaseSync2 } from "node:sqlite";
|
|
64344
64665
|
function openLogDatabase(dbPath) {
|
|
64345
|
-
mkdirSync5(
|
|
64666
|
+
mkdirSync5(dirname12(dbPath), { recursive: true });
|
|
64346
64667
|
const db = new DatabaseSync2(dbPath);
|
|
64347
64668
|
db.exec("PRAGMA journal_mode = WAL");
|
|
64348
64669
|
db.exec("PRAGMA busy_timeout = 5000");
|
|
@@ -64612,7 +64933,7 @@ function signalBestEffort(pid, signal, send) {
|
|
|
64612
64933
|
async function stopExistingDaemons(options) {
|
|
64613
64934
|
const isRunning = options?.isRunning ?? isProcessRunning;
|
|
64614
64935
|
const send = options?.signal ?? defaultSignal;
|
|
64615
|
-
const sleep5 = options?.sleep ?? ((ms) => new Promise((
|
|
64936
|
+
const sleep5 = options?.sleep ?? ((ms) => new Promise((resolve6) => setTimeout(resolve6, ms)));
|
|
64616
64937
|
const log3 = options?.log ?? ((message) => console.error(message));
|
|
64617
64938
|
const waitMs = options?.waitMs ?? STOP_EXISTING_WAIT_MS;
|
|
64618
64939
|
const listPids = options?.listMatchingDaemonPids ?? listMatchingDaemonPids;
|
|
@@ -64671,7 +64992,7 @@ async function waitForLockOrTimeout(deadline, intervalMs, sleep5) {
|
|
|
64671
64992
|
async function acquireLockWithRetry(options) {
|
|
64672
64993
|
const intervalMs = options?.intervalMs ?? LOCK_RETRY_INTERVAL_MS;
|
|
64673
64994
|
const maxWaitMs = options?.maxWaitMs ?? LOCK_RETRY_MAX_WAIT_MS;
|
|
64674
|
-
const sleep5 = options?.sleep ?? ((ms) => new Promise((
|
|
64995
|
+
const sleep5 = options?.sleep ?? ((ms) => new Promise((resolve6) => setTimeout(resolve6, ms)));
|
|
64675
64996
|
await stopExistingDaemons({
|
|
64676
64997
|
listMatchingDaemonPids: options?.listMatchingDaemonPids,
|
|
64677
64998
|
isRunning: options?.isRunning,
|
|
@@ -65176,26 +65497,26 @@ function pLimit(concurrency) {
|
|
|
65176
65497
|
activeCount--;
|
|
65177
65498
|
resumeNext();
|
|
65178
65499
|
};
|
|
65179
|
-
const run = async (function_,
|
|
65500
|
+
const run = async (function_, resolve6, arguments_) => {
|
|
65180
65501
|
const result3 = (async () => function_(...arguments_))();
|
|
65181
|
-
|
|
65502
|
+
resolve6(result3);
|
|
65182
65503
|
try {
|
|
65183
65504
|
await result3;
|
|
65184
65505
|
} catch {}
|
|
65185
65506
|
next2();
|
|
65186
65507
|
};
|
|
65187
|
-
const enqueue = (function_,
|
|
65508
|
+
const enqueue = (function_, resolve6, reject, arguments_) => {
|
|
65188
65509
|
const queueItem = { reject };
|
|
65189
65510
|
new Promise((internalResolve) => {
|
|
65190
65511
|
queueItem.run = internalResolve;
|
|
65191
65512
|
queue.enqueue(queueItem);
|
|
65192
|
-
}).then(run.bind(undefined, function_,
|
|
65513
|
+
}).then(run.bind(undefined, function_, resolve6, arguments_));
|
|
65193
65514
|
if (activeCount < concurrency) {
|
|
65194
65515
|
resumeNext();
|
|
65195
65516
|
}
|
|
65196
65517
|
};
|
|
65197
|
-
const generator = (function_, ...arguments_) => new Promise((
|
|
65198
|
-
enqueue(function_,
|
|
65518
|
+
const generator = (function_, ...arguments_) => new Promise((resolve6, reject) => {
|
|
65519
|
+
enqueue(function_, resolve6, reject, arguments_);
|
|
65199
65520
|
});
|
|
65200
65521
|
Object.defineProperties(generator, {
|
|
65201
65522
|
activeCount: {
|
|
@@ -65274,11 +65595,11 @@ var init_config2 = __esm(() => {
|
|
|
65274
65595
|
// ../../node_modules/.pnpm/@hyzyla+pdfium@2.1.13/node_modules/@hyzyla/pdfium/dist/index.esm.js
|
|
65275
65596
|
function __awaiter(thisArg, _arguments, P, generator) {
|
|
65276
65597
|
function adopt(value2) {
|
|
65277
|
-
return value2 instanceof P ? value2 : new P(function(
|
|
65278
|
-
|
|
65598
|
+
return value2 instanceof P ? value2 : new P(function(resolve6) {
|
|
65599
|
+
resolve6(value2);
|
|
65279
65600
|
});
|
|
65280
65601
|
}
|
|
65281
|
-
return new (P || (P = Promise))(function(
|
|
65602
|
+
return new (P || (P = Promise))(function(resolve6, reject) {
|
|
65282
65603
|
function fulfilled(value2) {
|
|
65283
65604
|
try {
|
|
65284
65605
|
step(generator.next(value2));
|
|
@@ -65294,7 +65615,7 @@ function __awaiter(thisArg, _arguments, P, generator) {
|
|
|
65294
65615
|
}
|
|
65295
65616
|
}
|
|
65296
65617
|
function step(result3) {
|
|
65297
|
-
result3.done ?
|
|
65618
|
+
result3.done ? resolve6(result3.value) : adopt(result3.value).then(fulfilled, rejected);
|
|
65298
65619
|
}
|
|
65299
65620
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
65300
65621
|
});
|
|
@@ -65954,13 +66275,13 @@ var init_index_esm = __esm(() => {
|
|
|
65954
66275
|
}
|
|
65955
66276
|
readAsync = async (url3) => {
|
|
65956
66277
|
if (isFileURI(url3)) {
|
|
65957
|
-
return new Promise((
|
|
66278
|
+
return new Promise((resolve6, reject) => {
|
|
65958
66279
|
var xhr = new XMLHttpRequest;
|
|
65959
66280
|
xhr.open("GET", url3, true);
|
|
65960
66281
|
xhr.responseType = "arraybuffer";
|
|
65961
66282
|
xhr.onload = () => {
|
|
65962
66283
|
if (xhr.status == 200 || xhr.status == 0 && xhr.response) {
|
|
65963
|
-
|
|
66284
|
+
resolve6(xhr.response);
|
|
65964
66285
|
return;
|
|
65965
66286
|
}
|
|
65966
66287
|
reject(xhr.status);
|
|
@@ -66294,10 +66615,10 @@ var init_index_esm = __esm(() => {
|
|
|
66294
66615
|
}
|
|
66295
66616
|
var info = getWasmImports();
|
|
66296
66617
|
if (Module["instantiateWasm"]) {
|
|
66297
|
-
return new Promise((
|
|
66618
|
+
return new Promise((resolve6, reject) => {
|
|
66298
66619
|
try {
|
|
66299
66620
|
Module["instantiateWasm"](info, (mod, inst) => {
|
|
66300
|
-
|
|
66621
|
+
resolve6(receiveInstance(mod, inst));
|
|
66301
66622
|
});
|
|
66302
66623
|
} catch (e) {
|
|
66303
66624
|
err(`Module.instantiateWasm callback failed with error: ${e}`);
|
|
@@ -70979,8 +71300,8 @@ var init_index_esm = __esm(() => {
|
|
|
70979
71300
|
if (runtimeInitialized) {
|
|
70980
71301
|
moduleRtn = Module;
|
|
70981
71302
|
} else {
|
|
70982
|
-
moduleRtn = new Promise((
|
|
70983
|
-
readyPromiseResolve =
|
|
71303
|
+
moduleRtn = new Promise((resolve6, reject) => {
|
|
71304
|
+
readyPromiseResolve = resolve6;
|
|
70984
71305
|
readyPromiseReject = reject;
|
|
70985
71306
|
});
|
|
70986
71307
|
}
|
|
@@ -71103,14 +71424,14 @@ var require_filesystem = __commonJS((exports, module) => {
|
|
|
71103
71424
|
fs6.close(fd, () => {});
|
|
71104
71425
|
return buffer.subarray(0, bytesRead);
|
|
71105
71426
|
};
|
|
71106
|
-
var readFile6 = (path2) => new Promise((
|
|
71427
|
+
var readFile6 = (path2) => new Promise((resolve6, reject) => {
|
|
71107
71428
|
fs6.open(path2, "r", (err, fd) => {
|
|
71108
71429
|
if (err) {
|
|
71109
71430
|
reject(err);
|
|
71110
71431
|
} else {
|
|
71111
71432
|
const buffer = Buffer.alloc(MAX_LENGTH);
|
|
71112
71433
|
fs6.read(fd, buffer, 0, MAX_LENGTH, 0, (_, bytesRead) => {
|
|
71113
|
-
|
|
71434
|
+
resolve6(buffer.subarray(0, bytesRead));
|
|
71114
71435
|
fs6.close(fd, () => {});
|
|
71115
71436
|
});
|
|
71116
71437
|
}
|
|
@@ -71171,10 +71492,10 @@ var require_detect_libc = __commonJS((exports, module) => {
|
|
|
71171
71492
|
var commandOut = "";
|
|
71172
71493
|
var safeCommand = () => {
|
|
71173
71494
|
if (!commandOut) {
|
|
71174
|
-
return new Promise((
|
|
71495
|
+
return new Promise((resolve6) => {
|
|
71175
71496
|
childProcess.exec(command, (err, out) => {
|
|
71176
71497
|
commandOut = err ? " " : out;
|
|
71177
|
-
|
|
71498
|
+
resolve6(commandOut);
|
|
71178
71499
|
});
|
|
71179
71500
|
});
|
|
71180
71501
|
}
|
|
@@ -73752,14 +74073,14 @@ var require_input = __commonJS((exports, module) => {
|
|
|
73752
74073
|
return this;
|
|
73753
74074
|
} else {
|
|
73754
74075
|
if (this._isStreamInput()) {
|
|
73755
|
-
return new Promise((
|
|
74076
|
+
return new Promise((resolve6, reject) => {
|
|
73756
74077
|
const finished = () => {
|
|
73757
74078
|
this._flattenBufferIn();
|
|
73758
74079
|
sharp.metadata(this.options, (err, metadata2) => {
|
|
73759
74080
|
if (err) {
|
|
73760
74081
|
reject(is.nativeError(err, stack));
|
|
73761
74082
|
} else {
|
|
73762
|
-
|
|
74083
|
+
resolve6(metadata2);
|
|
73763
74084
|
}
|
|
73764
74085
|
});
|
|
73765
74086
|
};
|
|
@@ -73770,12 +74091,12 @@ var require_input = __commonJS((exports, module) => {
|
|
|
73770
74091
|
}
|
|
73771
74092
|
});
|
|
73772
74093
|
} else {
|
|
73773
|
-
return new Promise((
|
|
74094
|
+
return new Promise((resolve6, reject) => {
|
|
73774
74095
|
sharp.metadata(this.options, (err, metadata2) => {
|
|
73775
74096
|
if (err) {
|
|
73776
74097
|
reject(is.nativeError(err, stack));
|
|
73777
74098
|
} else {
|
|
73778
|
-
|
|
74099
|
+
resolve6(metadata2);
|
|
73779
74100
|
}
|
|
73780
74101
|
});
|
|
73781
74102
|
});
|
|
@@ -73808,25 +74129,25 @@ var require_input = __commonJS((exports, module) => {
|
|
|
73808
74129
|
return this;
|
|
73809
74130
|
} else {
|
|
73810
74131
|
if (this._isStreamInput()) {
|
|
73811
|
-
return new Promise((
|
|
74132
|
+
return new Promise((resolve6, reject) => {
|
|
73812
74133
|
this.on("finish", function() {
|
|
73813
74134
|
this._flattenBufferIn();
|
|
73814
74135
|
sharp.stats(this.options, (err, stats2) => {
|
|
73815
74136
|
if (err) {
|
|
73816
74137
|
reject(is.nativeError(err, stack));
|
|
73817
74138
|
} else {
|
|
73818
|
-
|
|
74139
|
+
resolve6(stats2);
|
|
73819
74140
|
}
|
|
73820
74141
|
});
|
|
73821
74142
|
});
|
|
73822
74143
|
});
|
|
73823
74144
|
} else {
|
|
73824
|
-
return new Promise((
|
|
74145
|
+
return new Promise((resolve6, reject) => {
|
|
73825
74146
|
sharp.stats(this.options, (err, stats2) => {
|
|
73826
74147
|
if (err) {
|
|
73827
74148
|
reject(is.nativeError(err, stack));
|
|
73828
74149
|
} else {
|
|
73829
|
-
|
|
74150
|
+
resolve6(stats2);
|
|
73830
74151
|
}
|
|
73831
74152
|
});
|
|
73832
74153
|
});
|
|
@@ -77228,7 +77549,7 @@ var require_output = __commonJS((exports, module) => {
|
|
|
77228
77549
|
return this;
|
|
77229
77550
|
} else {
|
|
77230
77551
|
if (this._isStreamInput()) {
|
|
77231
|
-
return new Promise((
|
|
77552
|
+
return new Promise((resolve6, reject) => {
|
|
77232
77553
|
this.once("finish", () => {
|
|
77233
77554
|
this._flattenBufferIn();
|
|
77234
77555
|
sharp.pipeline(this.options, (err, data, info) => {
|
|
@@ -77236,24 +77557,24 @@ var require_output = __commonJS((exports, module) => {
|
|
|
77236
77557
|
reject(is.nativeError(err, stack));
|
|
77237
77558
|
} else {
|
|
77238
77559
|
if (this.options.resolveWithObject) {
|
|
77239
|
-
|
|
77560
|
+
resolve6({ data, info });
|
|
77240
77561
|
} else {
|
|
77241
|
-
|
|
77562
|
+
resolve6(data);
|
|
77242
77563
|
}
|
|
77243
77564
|
}
|
|
77244
77565
|
});
|
|
77245
77566
|
});
|
|
77246
77567
|
});
|
|
77247
77568
|
} else {
|
|
77248
|
-
return new Promise((
|
|
77569
|
+
return new Promise((resolve6, reject) => {
|
|
77249
77570
|
sharp.pipeline(this.options, (err, data, info) => {
|
|
77250
77571
|
if (err) {
|
|
77251
77572
|
reject(is.nativeError(err, stack));
|
|
77252
77573
|
} else {
|
|
77253
77574
|
if (this.options.resolveWithObject) {
|
|
77254
|
-
|
|
77575
|
+
resolve6({ data, info });
|
|
77255
77576
|
} else {
|
|
77256
|
-
|
|
77577
|
+
resolve6(data);
|
|
77257
77578
|
}
|
|
77258
77579
|
}
|
|
77259
77580
|
});
|
|
@@ -77555,11 +77876,11 @@ var init_pdfium_renderer = __esm(() => {
|
|
|
77555
77876
|
|
|
77556
77877
|
// ../../node_modules/.pnpm/@llamaindex+liteparse@1.5.3/node_modules/@llamaindex/liteparse/dist/src/engines/pdf/pdfjsImporter.js
|
|
77557
77878
|
import { fileURLToPath as fileURLToPath6 } from "node:url";
|
|
77558
|
-
import { dirname as
|
|
77879
|
+
import { dirname as dirname13 } from "node:path";
|
|
77559
77880
|
async function importPdfJs() {
|
|
77560
77881
|
const pdfUrl = new URL("../../vendor/pdfjs/pdf.mjs", import.meta.url);
|
|
77561
77882
|
const pdfjs = await import(pdfUrl.href);
|
|
77562
|
-
const dirPath =
|
|
77883
|
+
const dirPath = dirname13(fileURLToPath6(pdfUrl));
|
|
77563
77884
|
return {
|
|
77564
77885
|
fn: pdfjs.getDocument,
|
|
77565
77886
|
dir: dirPath
|
|
@@ -78327,7 +78648,7 @@ var require_runtime2 = __commonJS((exports, module) => {
|
|
|
78327
78648
|
return { __await: arg };
|
|
78328
78649
|
};
|
|
78329
78650
|
function AsyncIterator(generator, PromiseImpl) {
|
|
78330
|
-
function invoke(method, arg,
|
|
78651
|
+
function invoke(method, arg, resolve6, reject) {
|
|
78331
78652
|
var record2 = tryCatch(generator[method], generator, arg);
|
|
78332
78653
|
if (record2.type === "throw") {
|
|
78333
78654
|
reject(record2.arg);
|
|
@@ -78336,24 +78657,24 @@ var require_runtime2 = __commonJS((exports, module) => {
|
|
|
78336
78657
|
var value2 = result3.value;
|
|
78337
78658
|
if (value2 && typeof value2 === "object" && hasOwn.call(value2, "__await")) {
|
|
78338
78659
|
return PromiseImpl.resolve(value2.__await).then(function(value3) {
|
|
78339
|
-
invoke("next", value3,
|
|
78660
|
+
invoke("next", value3, resolve6, reject);
|
|
78340
78661
|
}, function(err) {
|
|
78341
|
-
invoke("throw", err,
|
|
78662
|
+
invoke("throw", err, resolve6, reject);
|
|
78342
78663
|
});
|
|
78343
78664
|
}
|
|
78344
78665
|
return PromiseImpl.resolve(value2).then(function(unwrapped) {
|
|
78345
78666
|
result3.value = unwrapped;
|
|
78346
|
-
|
|
78667
|
+
resolve6(result3);
|
|
78347
78668
|
}, function(error51) {
|
|
78348
|
-
return invoke("throw", error51,
|
|
78669
|
+
return invoke("throw", error51, resolve6, reject);
|
|
78349
78670
|
});
|
|
78350
78671
|
}
|
|
78351
78672
|
}
|
|
78352
78673
|
var previousPromise;
|
|
78353
78674
|
function enqueue(method, arg) {
|
|
78354
78675
|
function callInvokeWithMethodAndArg() {
|
|
78355
|
-
return new PromiseImpl(function(
|
|
78356
|
-
invoke(method, arg,
|
|
78676
|
+
return new PromiseImpl(function(resolve6, reject) {
|
|
78677
|
+
invoke(method, arg, resolve6, reject);
|
|
78357
78678
|
});
|
|
78358
78679
|
}
|
|
78359
78680
|
return previousPromise = previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg();
|
|
@@ -78773,13 +79094,13 @@ var require_createScheduler = __commonJS((exports, module) => {
|
|
|
78773
79094
|
}
|
|
78774
79095
|
}
|
|
78775
79096
|
};
|
|
78776
|
-
const queue = (action, payload) => new Promise((
|
|
79097
|
+
const queue = (action, payload) => new Promise((resolve6, reject) => {
|
|
78777
79098
|
const job = createJob({ action, payload });
|
|
78778
79099
|
jobQueue.push(async (w) => {
|
|
78779
79100
|
jobQueue.shift();
|
|
78780
79101
|
runningWorkers[w.id] = job;
|
|
78781
79102
|
try {
|
|
78782
|
-
|
|
79103
|
+
resolve6(await w[action].apply(exports, [...payload, job.id]));
|
|
78783
79104
|
} catch (err) {
|
|
78784
79105
|
reject(err);
|
|
78785
79106
|
} finally {
|
|
@@ -80913,7 +81234,7 @@ var require_lib3 = __commonJS((exports, module) => {
|
|
|
80913
81234
|
let accum = [];
|
|
80914
81235
|
let accumBytes = 0;
|
|
80915
81236
|
let abort = false;
|
|
80916
|
-
return new Body.Promise(function(
|
|
81237
|
+
return new Body.Promise(function(resolve6, reject) {
|
|
80917
81238
|
let resTimeout;
|
|
80918
81239
|
if (_this4.timeout) {
|
|
80919
81240
|
resTimeout = setTimeout(function() {
|
|
@@ -80947,7 +81268,7 @@ var require_lib3 = __commonJS((exports, module) => {
|
|
|
80947
81268
|
}
|
|
80948
81269
|
clearTimeout(resTimeout);
|
|
80949
81270
|
try {
|
|
80950
|
-
|
|
81271
|
+
resolve6(Buffer.concat(accum, accumBytes));
|
|
80951
81272
|
} catch (err) {
|
|
80952
81273
|
reject(new FetchError(`Could not create Buffer from response body for ${_this4.url}: ${err.message}`, "system", err));
|
|
80953
81274
|
}
|
|
@@ -81546,7 +81867,7 @@ var require_lib3 = __commonJS((exports, module) => {
|
|
|
81546
81867
|
throw new Error("native promise missing, set fetch.Promise to your favorite alternative");
|
|
81547
81868
|
}
|
|
81548
81869
|
Body.Promise = fetch2.Promise;
|
|
81549
|
-
return new fetch2.Promise(function(
|
|
81870
|
+
return new fetch2.Promise(function(resolve6, reject) {
|
|
81550
81871
|
const request3 = new Request3(url3, opts);
|
|
81551
81872
|
const options = getNodeRequestOptions(request3);
|
|
81552
81873
|
const send = (options.protocol === "https:" ? https : http).request;
|
|
@@ -81681,7 +82002,7 @@ var require_lib3 = __commonJS((exports, module) => {
|
|
|
81681
82002
|
requestOpts.body = undefined;
|
|
81682
82003
|
requestOpts.headers.delete("content-length");
|
|
81683
82004
|
}
|
|
81684
|
-
|
|
82005
|
+
resolve6(fetch2(new Request3(locationURL, requestOpts)));
|
|
81685
82006
|
finalize2();
|
|
81686
82007
|
return;
|
|
81687
82008
|
}
|
|
@@ -81703,7 +82024,7 @@ var require_lib3 = __commonJS((exports, module) => {
|
|
|
81703
82024
|
const codings = headers.get("Content-Encoding");
|
|
81704
82025
|
if (!request3.compress || request3.method === "HEAD" || codings === null || res.statusCode === 204 || res.statusCode === 304) {
|
|
81705
82026
|
response = new Response2(body, response_options);
|
|
81706
|
-
|
|
82027
|
+
resolve6(response);
|
|
81707
82028
|
return;
|
|
81708
82029
|
}
|
|
81709
82030
|
const zlibOptions = {
|
|
@@ -81713,7 +82034,7 @@ var require_lib3 = __commonJS((exports, module) => {
|
|
|
81713
82034
|
if (codings == "gzip" || codings == "x-gzip") {
|
|
81714
82035
|
body = body.pipe(zlib.createGunzip(zlibOptions));
|
|
81715
82036
|
response = new Response2(body, response_options);
|
|
81716
|
-
|
|
82037
|
+
resolve6(response);
|
|
81717
82038
|
return;
|
|
81718
82039
|
}
|
|
81719
82040
|
if (codings == "deflate" || codings == "x-deflate") {
|
|
@@ -81725,12 +82046,12 @@ var require_lib3 = __commonJS((exports, module) => {
|
|
|
81725
82046
|
body = body.pipe(zlib.createInflateRaw());
|
|
81726
82047
|
}
|
|
81727
82048
|
response = new Response2(body, response_options);
|
|
81728
|
-
|
|
82049
|
+
resolve6(response);
|
|
81729
82050
|
});
|
|
81730
82051
|
raw.on("end", function() {
|
|
81731
82052
|
if (!response) {
|
|
81732
82053
|
response = new Response2(body, response_options);
|
|
81733
|
-
|
|
82054
|
+
resolve6(response);
|
|
81734
82055
|
}
|
|
81735
82056
|
});
|
|
81736
82057
|
return;
|
|
@@ -81738,11 +82059,11 @@ var require_lib3 = __commonJS((exports, module) => {
|
|
|
81738
82059
|
if (codings == "br" && typeof zlib.createBrotliDecompress === "function") {
|
|
81739
82060
|
body = body.pipe(zlib.createBrotliDecompress());
|
|
81740
82061
|
response = new Response2(body, response_options);
|
|
81741
|
-
|
|
82062
|
+
resolve6(response);
|
|
81742
82063
|
return;
|
|
81743
82064
|
}
|
|
81744
82065
|
response = new Response2(body, response_options);
|
|
81745
|
-
|
|
82066
|
+
resolve6(response);
|
|
81746
82067
|
});
|
|
81747
82068
|
writeToStream(req, request3);
|
|
81748
82069
|
});
|
|
@@ -81892,8 +82213,8 @@ var require_createWorker = __commonJS((exports, module) => {
|
|
|
81892
82213
|
const lstmOnlyCore = [OEM.DEFAULT, OEM.LSTM_ONLY].includes(oem) && !options.legacyCore;
|
|
81893
82214
|
let workerResReject;
|
|
81894
82215
|
let workerResResolve;
|
|
81895
|
-
const workerRes = new Promise((
|
|
81896
|
-
workerResResolve =
|
|
82216
|
+
const workerRes = new Promise((resolve6, reject) => {
|
|
82217
|
+
workerResResolve = resolve6;
|
|
81897
82218
|
workerResReject = reject;
|
|
81898
82219
|
});
|
|
81899
82220
|
const workerError = (event) => {
|
|
@@ -81902,10 +82223,10 @@ var require_createWorker = __commonJS((exports, module) => {
|
|
|
81902
82223
|
let worker = spawnWorker(options);
|
|
81903
82224
|
worker.onerror = workerError;
|
|
81904
82225
|
workerCounter += 1;
|
|
81905
|
-
const startJob = ({ id: jobId, action, payload }) => new Promise((
|
|
82226
|
+
const startJob = ({ id: jobId, action, payload }) => new Promise((resolve6, reject) => {
|
|
81906
82227
|
log3(`[${id}]: Start ${jobId}, action=${action}`);
|
|
81907
82228
|
const promiseId = `${action}-${jobId}`;
|
|
81908
|
-
promises[promiseId] = { resolve:
|
|
82229
|
+
promises[promiseId] = { resolve: resolve6, reject };
|
|
81909
82230
|
send(worker, {
|
|
81910
82231
|
workerId: id,
|
|
81911
82232
|
jobId,
|
|
@@ -94264,10 +94585,10 @@ var init_CanceledError = __esm(() => {
|
|
|
94264
94585
|
});
|
|
94265
94586
|
|
|
94266
94587
|
// ../../node_modules/.pnpm/axios@1.20.0/node_modules/axios/lib/core/settle.js
|
|
94267
|
-
function settle(
|
|
94588
|
+
function settle(resolve6, reject, response) {
|
|
94268
94589
|
const validateStatus2 = response.config.validateStatus;
|
|
94269
94590
|
if (!response.status || !validateStatus2 || validateStatus2(response.status)) {
|
|
94270
|
-
|
|
94591
|
+
resolve6(response);
|
|
94271
94592
|
} else {
|
|
94272
94593
|
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
94594
|
}
|
|
@@ -94430,12 +94751,12 @@ var require_promisify = __commonJS((exports) => {
|
|
|
94430
94751
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
94431
94752
|
function promisify2(fn3) {
|
|
94432
94753
|
return function(req, opts) {
|
|
94433
|
-
return new Promise((
|
|
94754
|
+
return new Promise((resolve6, reject) => {
|
|
94434
94755
|
fn3.call(this, req, opts, (err, rtn) => {
|
|
94435
94756
|
if (err) {
|
|
94436
94757
|
reject(err);
|
|
94437
94758
|
} else {
|
|
94438
|
-
|
|
94759
|
+
resolve6(rtn);
|
|
94439
94760
|
}
|
|
94440
94761
|
});
|
|
94441
94762
|
});
|
|
@@ -94629,7 +94950,7 @@ var require_parse_proxy_response = __commonJS((exports) => {
|
|
|
94629
94950
|
var debug_1 = __importDefault(require_src2());
|
|
94630
94951
|
var debug12 = debug_1.default("https-proxy-agent:parse-proxy-response");
|
|
94631
94952
|
function parseProxyResponse(socket) {
|
|
94632
|
-
return new Promise((
|
|
94953
|
+
return new Promise((resolve6, reject) => {
|
|
94633
94954
|
let buffersLength = 0;
|
|
94634
94955
|
const buffers = [];
|
|
94635
94956
|
function read() {
|
|
@@ -94672,7 +94993,7 @@ var require_parse_proxy_response = __commonJS((exports) => {
|
|
|
94672
94993
|
`));
|
|
94673
94994
|
const statusCode = +firstLine.split(" ")[1];
|
|
94674
94995
|
debug12("got proxy server response: %o", firstLine);
|
|
94675
|
-
|
|
94996
|
+
resolve6({
|
|
94676
94997
|
statusCode,
|
|
94677
94998
|
buffered
|
|
94678
94999
|
});
|
|
@@ -94690,11 +95011,11 @@ var require_parse_proxy_response = __commonJS((exports) => {
|
|
|
94690
95011
|
var require_agent = __commonJS((exports) => {
|
|
94691
95012
|
var __awaiter2 = exports && exports.__awaiter || function(thisArg, _arguments, P, generator) {
|
|
94692
95013
|
function adopt(value2) {
|
|
94693
|
-
return value2 instanceof P ? value2 : new P(function(
|
|
94694
|
-
|
|
95014
|
+
return value2 instanceof P ? value2 : new P(function(resolve6) {
|
|
95015
|
+
resolve6(value2);
|
|
94695
95016
|
});
|
|
94696
95017
|
}
|
|
94697
|
-
return new (P || (P = Promise))(function(
|
|
95018
|
+
return new (P || (P = Promise))(function(resolve6, reject) {
|
|
94698
95019
|
function fulfilled(value2) {
|
|
94699
95020
|
try {
|
|
94700
95021
|
step(generator.next(value2));
|
|
@@ -94710,7 +95031,7 @@ var require_agent = __commonJS((exports) => {
|
|
|
94710
95031
|
}
|
|
94711
95032
|
}
|
|
94712
95033
|
function step(result3) {
|
|
94713
|
-
result3.done ?
|
|
95034
|
+
result3.done ? resolve6(result3.value) : adopt(result3.value).then(fulfilled, rejected);
|
|
94714
95035
|
}
|
|
94715
95036
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
94716
95037
|
});
|
|
@@ -96509,7 +96830,7 @@ var import_https_proxy_agent, import_follow_redirects, zlibOptions, brotliOption
|
|
|
96509
96830
|
stream4.on("end", flush).on("error", flush);
|
|
96510
96831
|
return throttled;
|
|
96511
96832
|
}, http2Sessions, isHttpAdapterSupported, wrapAsync = (asyncExecutor) => {
|
|
96512
|
-
return new Promise((
|
|
96833
|
+
return new Promise((resolve6, reject) => {
|
|
96513
96834
|
let onDone;
|
|
96514
96835
|
let isDone3;
|
|
96515
96836
|
const done3 = (value2, isRejected) => {
|
|
@@ -96520,7 +96841,7 @@ var import_https_proxy_agent, import_follow_redirects, zlibOptions, brotliOption
|
|
|
96520
96841
|
};
|
|
96521
96842
|
const _resolve = (value2) => {
|
|
96522
96843
|
done3(value2);
|
|
96523
|
-
|
|
96844
|
+
resolve6(value2);
|
|
96524
96845
|
};
|
|
96525
96846
|
const _reject = (reason) => {
|
|
96526
96847
|
done3(reason, true);
|
|
@@ -96645,7 +96966,7 @@ var init_http = __esm(() => {
|
|
|
96645
96966
|
}
|
|
96646
96967
|
};
|
|
96647
96968
|
http_default = isHttpAdapterSupported && function httpAdapter(config3) {
|
|
96648
|
-
return wrapAsync(async function dispatchHttpRequest(
|
|
96969
|
+
return wrapAsync(async function dispatchHttpRequest(resolve6, reject, onDone) {
|
|
96649
96970
|
const own2 = (key) => utils_default.getSafeProp(config3, key);
|
|
96650
96971
|
const transitional = own2("transitional") || transitional_default;
|
|
96651
96972
|
let data = own2("data");
|
|
@@ -96756,7 +97077,7 @@ var init_http = __esm(() => {
|
|
|
96756
97077
|
}
|
|
96757
97078
|
let convertedData;
|
|
96758
97079
|
if (method !== "GET") {
|
|
96759
|
-
return settle(
|
|
97080
|
+
return settle(resolve6, reject, {
|
|
96760
97081
|
status: 405,
|
|
96761
97082
|
statusText: "method not allowed",
|
|
96762
97083
|
headers: {},
|
|
@@ -96778,7 +97099,7 @@ var init_http = __esm(() => {
|
|
|
96778
97099
|
} else if (responseType === "stream") {
|
|
96779
97100
|
convertedData = stream3.Readable.from(convertedData);
|
|
96780
97101
|
}
|
|
96781
|
-
return settle(
|
|
97102
|
+
return settle(resolve6, reject, {
|
|
96782
97103
|
data: convertedData,
|
|
96783
97104
|
status: 200,
|
|
96784
97105
|
statusText: "OK",
|
|
@@ -97050,7 +97371,7 @@ var init_http = __esm(() => {
|
|
|
97050
97371
|
});
|
|
97051
97372
|
}
|
|
97052
97373
|
response.data = responseStream;
|
|
97053
|
-
settle(
|
|
97374
|
+
settle(resolve6, reject, response);
|
|
97054
97375
|
} else {
|
|
97055
97376
|
const responseBuffer = [];
|
|
97056
97377
|
let totalResponseBytes = 0;
|
|
@@ -97089,7 +97410,7 @@ var init_http = __esm(() => {
|
|
|
97089
97410
|
} catch (err) {
|
|
97090
97411
|
return reject(AxiosError_default.from(err, null, config3, response.request, response));
|
|
97091
97412
|
}
|
|
97092
|
-
settle(
|
|
97413
|
+
settle(resolve6, reject, response);
|
|
97093
97414
|
});
|
|
97094
97415
|
}
|
|
97095
97416
|
abortEmitter.once("abort", (err) => {
|
|
@@ -97462,7 +97783,7 @@ var init_xhr = __esm(() => {
|
|
|
97462
97783
|
init_sanitizeHeaderValue();
|
|
97463
97784
|
isXHRAdapterSupported = typeof XMLHttpRequest !== "undefined";
|
|
97464
97785
|
xhr_default = isXHRAdapterSupported && function(config3) {
|
|
97465
|
-
return new Promise(function dispatchXhrRequest(
|
|
97786
|
+
return new Promise(function dispatchXhrRequest(resolve6, reject) {
|
|
97466
97787
|
const _config = resolveConfig_default(config3);
|
|
97467
97788
|
let requestData = _config.data;
|
|
97468
97789
|
const requestHeaders = AxiosHeaders_default.from(_config.headers).normalize();
|
|
@@ -97514,7 +97835,7 @@ var init_xhr = __esm(() => {
|
|
|
97514
97835
|
request: request3
|
|
97515
97836
|
};
|
|
97516
97837
|
settle(function _resolve(value2) {
|
|
97517
|
-
|
|
97838
|
+
resolve6(value2);
|
|
97518
97839
|
done3();
|
|
97519
97840
|
}, function _reject(err) {
|
|
97520
97841
|
reject(err);
|
|
@@ -98037,8 +98358,8 @@ var DEFAULT_CHUNK_SIZE, DEFAULT_REQUEST_OPTIONS, isFunction3, encodeUTF82 = (str
|
|
|
98037
98358
|
}
|
|
98038
98359
|
}
|
|
98039
98360
|
!isStreamResponse && unsubscribe && unsubscribe();
|
|
98040
|
-
return await new Promise((
|
|
98041
|
-
settle(
|
|
98361
|
+
return await new Promise((resolve6, reject) => {
|
|
98362
|
+
settle(resolve6, reject, {
|
|
98042
98363
|
data: responseData,
|
|
98043
98364
|
headers: AxiosHeaders_default.from(response.headers),
|
|
98044
98365
|
status: response.status,
|
|
@@ -98512,8 +98833,8 @@ class CancelToken {
|
|
|
98512
98833
|
throw new TypeError("executor must be a function.");
|
|
98513
98834
|
}
|
|
98514
98835
|
let resolvePromise;
|
|
98515
|
-
this.promise = new Promise(function promiseExecutor(
|
|
98516
|
-
resolvePromise =
|
|
98836
|
+
this.promise = new Promise(function promiseExecutor(resolve6) {
|
|
98837
|
+
resolvePromise = resolve6;
|
|
98517
98838
|
});
|
|
98518
98839
|
const token = this;
|
|
98519
98840
|
this.promise.then((cancel) => {
|
|
@@ -98527,9 +98848,9 @@ class CancelToken {
|
|
|
98527
98848
|
});
|
|
98528
98849
|
this.promise.then = (onfulfilled) => {
|
|
98529
98850
|
let _resolve;
|
|
98530
|
-
const promise4 = new Promise((
|
|
98531
|
-
token.subscribe(
|
|
98532
|
-
_resolve =
|
|
98851
|
+
const promise4 = new Promise((resolve6) => {
|
|
98852
|
+
token.subscribe(resolve6);
|
|
98853
|
+
_resolve = resolve6;
|
|
98533
98854
|
}).then(onfulfilled);
|
|
98534
98855
|
promise4.cancel = function reject() {
|
|
98535
98856
|
token.unsubscribe(_resolve);
|
|
@@ -99210,7 +99531,7 @@ function applyMarkupTags(markup, text) {
|
|
|
99210
99531
|
// ../../node_modules/.pnpm/@llamaindex+liteparse@1.5.3/node_modules/@llamaindex/liteparse/dist/src/processing/gridDebugLogger.js
|
|
99211
99532
|
import { mkdirSync as mkdirSync7, writeFileSync as writeFileSync4 } from "fs";
|
|
99212
99533
|
import { mkdir as mkdir6, writeFile as writeFile6 } from "fs/promises";
|
|
99213
|
-
import { dirname as
|
|
99534
|
+
import { dirname as dirname14 } from "path";
|
|
99214
99535
|
|
|
99215
99536
|
class GridDebugLogger {
|
|
99216
99537
|
config;
|
|
@@ -99537,14 +99858,14 @@ class GridDebugLogger {
|
|
|
99537
99858
|
flushSync() {
|
|
99538
99859
|
if (!this.config.outputPath || this.entries.length === 0)
|
|
99539
99860
|
return;
|
|
99540
|
-
mkdirSync7(
|
|
99861
|
+
mkdirSync7(dirname14(this.config.outputPath), { recursive: true });
|
|
99541
99862
|
writeFileSync4(this.config.outputPath, this.formatEntries(), "utf-8");
|
|
99542
99863
|
this.entries = [];
|
|
99543
99864
|
}
|
|
99544
99865
|
async flush() {
|
|
99545
99866
|
if (!this.config.outputPath || this.entries.length === 0)
|
|
99546
99867
|
return;
|
|
99547
|
-
await mkdir6(
|
|
99868
|
+
await mkdir6(dirname14(this.config.outputPath), { recursive: true });
|
|
99548
99869
|
await writeFile6(this.config.outputPath, this.formatEntries(), "utf-8");
|
|
99549
99870
|
this.entries = [];
|
|
99550
99871
|
}
|
|
@@ -101269,9 +101590,9 @@ class Deferred2 {
|
|
|
101269
101590
|
constructor() {
|
|
101270
101591
|
this.resolve = () => null;
|
|
101271
101592
|
this.reject = () => null;
|
|
101272
|
-
this.promise = new Promise((
|
|
101593
|
+
this.promise = new Promise((resolve6, reject) => {
|
|
101273
101594
|
this.reject = reject;
|
|
101274
|
-
this.resolve =
|
|
101595
|
+
this.resolve = resolve6;
|
|
101275
101596
|
});
|
|
101276
101597
|
}
|
|
101277
101598
|
}
|
|
@@ -103335,7 +103656,7 @@ function readByobReaderWithSignal(reader, buffer, signal) {
|
|
|
103335
103656
|
return reader.read(buffer);
|
|
103336
103657
|
}
|
|
103337
103658
|
signal.throwIfAborted();
|
|
103338
|
-
return new Promise((
|
|
103659
|
+
return new Promise((resolve6, reject) => {
|
|
103339
103660
|
const cleanup = () => {
|
|
103340
103661
|
signal.removeEventListener("abort", onAbort);
|
|
103341
103662
|
};
|
|
@@ -103354,7 +103675,7 @@ function readByobReaderWithSignal(reader, buffer, signal) {
|
|
|
103354
103675
|
try {
|
|
103355
103676
|
const result3 = await reader.read(buffer);
|
|
103356
103677
|
cleanup();
|
|
103357
|
-
|
|
103678
|
+
resolve6(result3);
|
|
103358
103679
|
} catch (error51) {
|
|
103359
103680
|
cleanup();
|
|
103360
103681
|
reject(error51);
|
|
@@ -105225,7 +105546,7 @@ var init_file_type = __esm(() => {
|
|
|
105225
105546
|
const { signal } = this.options;
|
|
105226
105547
|
const normalizedSampleSize = normalizeSampleSize(sampleSize);
|
|
105227
105548
|
signal?.throwIfAborted();
|
|
105228
|
-
return new Promise((
|
|
105549
|
+
return new Promise((resolve6, reject) => {
|
|
105229
105550
|
let isSettled = false;
|
|
105230
105551
|
const cleanup = () => {
|
|
105231
105552
|
readableStream.off("error", onError3);
|
|
@@ -105264,7 +105585,7 @@ var init_file_type = __esm(() => {
|
|
|
105264
105585
|
settle2(reject, error51);
|
|
105265
105586
|
}
|
|
105266
105587
|
}
|
|
105267
|
-
settle2(
|
|
105588
|
+
settle2(resolve6, outputStream);
|
|
105268
105589
|
} catch (error51) {
|
|
105269
105590
|
settle2(reject, error51);
|
|
105270
105591
|
}
|
|
@@ -105298,7 +105619,7 @@ async function guessFileExtension(filePath) {
|
|
|
105298
105619
|
return null;
|
|
105299
105620
|
}
|
|
105300
105621
|
async function executeCommand(command, args2, timeoutMs = 60000) {
|
|
105301
|
-
return new Promise((
|
|
105622
|
+
return new Promise((resolve6, reject) => {
|
|
105302
105623
|
const proc = spawn2(command, args2, {
|
|
105303
105624
|
stdio: ["ignore", "pipe", "pipe"]
|
|
105304
105625
|
});
|
|
@@ -105317,7 +105638,7 @@ async function executeCommand(command, args2, timeoutMs = 60000) {
|
|
|
105317
105638
|
proc.on("close", (code2) => {
|
|
105318
105639
|
clearTimeout(timeout3);
|
|
105319
105640
|
if (code2 === 0) {
|
|
105320
|
-
|
|
105641
|
+
resolve6(stdout);
|
|
105321
105642
|
} else {
|
|
105322
105643
|
reject(new Error(`Command failed with code ${code2}: ${stderr}`));
|
|
105323
105644
|
}
|
|
@@ -105954,7 +106275,7 @@ __export(exports_parse_pdf, {
|
|
|
105954
106275
|
parsePdf: () => parsePdf
|
|
105955
106276
|
});
|
|
105956
106277
|
import { access, readFile as readFile6, writeFile as writeFile7, mkdir as mkdir7, appendFile } from "node:fs/promises";
|
|
105957
|
-
import { resolve as
|
|
106278
|
+
import { resolve as resolve6 } from "node:path";
|
|
105958
106279
|
function isUrl(input) {
|
|
105959
106280
|
return input.startsWith("http://") || input.startsWith("https://");
|
|
105960
106281
|
}
|
|
@@ -106011,7 +106332,7 @@ function createDefaultDeps6() {
|
|
|
106011
106332
|
};
|
|
106012
106333
|
}
|
|
106013
106334
|
async function resolvePdfPath(input, workingDir, d) {
|
|
106014
|
-
const absolutePath =
|
|
106335
|
+
const absolutePath = resolve6(workingDir, input);
|
|
106015
106336
|
try {
|
|
106016
106337
|
await d.fs.access(absolutePath);
|
|
106017
106338
|
} catch {
|
|
@@ -107593,7 +107914,7 @@ function formatProofOfPrinciples() {
|
|
|
107593
107914
|
var GAME_ASSET_RULES;
|
|
107594
107915
|
var init_game_asset_designer_workflow = __esm(() => {
|
|
107595
107916
|
GAME_ASSET_RULES = [
|
|
107596
|
-
"Generate only with `chatroom generate-image --platform=fal`, using the CLI default model unless the brief names one.",
|
|
107917
|
+
"Generate only with `chatroom generate-image --platform=fal`, using the CLI default model `fal-ai/flux-2/flash` unless the brief names one.",
|
|
107597
107918
|
"Process images only with `chatroom slice-image` and `chatroom remove-image-background`; no other tool, script, or remote service.",
|
|
107598
107919
|
"A sheet is at most the brief's `Sheet grid` (default 2x2); a larger grid needs a user request quoted in the brief.",
|
|
107599
107920
|
"Names come from looking at each tile, never from cell order or prompt order.",
|
|
@@ -107602,7 +107923,6 @@ var init_game_asset_designer_workflow = __esm(() => {
|
|
|
107602
107923
|
"Mark `pass` or `fail` only with `measured` or `inspected` evidence (labels below).",
|
|
107603
107924
|
"Run `<command> --help` before first use of `slice-image` or `remove-image-background`.",
|
|
107604
107925
|
"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
107926
|
"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
107927
|
"Do not install or run any remote tool, script, or skill, and do not fetch generator code.",
|
|
107608
107928
|
"Never switch generators.",
|
|
@@ -107633,7 +107953,7 @@ function getEntryPointToGameAssetDesignerHandoffTemplate(query) {
|
|
|
107633
107953
|
<repository paths, URLs, or a written style sheet; or \`Not specified.\`>
|
|
107634
107954
|
|
|
107635
107955
|
## Model
|
|
107636
|
-
<the CLI default \`fal-ai/flux-2/flash
|
|
107956
|
+
<the CLI default \`fal-ai/flux-2/flash\`>
|
|
107637
107957
|
|
|
107638
107958
|
## Model parameters
|
|
107639
107959
|
<a JSON object as text passed to \`generate-image --input\`; \`Not specified.\` if none>
|
|
@@ -109660,7 +109980,7 @@ P1 Recover the brief. IF engine, tier, style, or budgets are missing and the rep
|
|
|
109660
109980
|
P2 Inspect assets, names, folders, engine config; cite paths.
|
|
109661
109981
|
P3 Classify each asset; one manifest entry per ID (\`A01\`…).
|
|
109662
109982
|
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\`.
|
|
109983
|
+
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\`.
|
|
109664
109984
|
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
109985
|
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
109986
|
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.
|
|
@@ -120637,10 +120957,10 @@ var init_durable_fifo_queue_schema = __esm(() => {
|
|
|
120637
120957
|
|
|
120638
120958
|
// src/daemon/infrastructure/outbox/lib/durable-fifo-queue-store.ts
|
|
120639
120959
|
import { mkdirSync as mkdirSync9 } from "node:fs";
|
|
120640
|
-
import { dirname as
|
|
120960
|
+
import { dirname as dirname15 } from "node:path";
|
|
120641
120961
|
import { DatabaseSync as DatabaseSync3 } from "node:sqlite";
|
|
120642
120962
|
function openDurableFifoQueueStore(dbPath) {
|
|
120643
|
-
mkdirSync9(
|
|
120963
|
+
mkdirSync9(dirname15(dbPath), { recursive: true });
|
|
120644
120964
|
const db = new DatabaseSync3(dbPath);
|
|
120645
120965
|
for (const sql of DURABLE_FIFO_QUEUE_MIGRATIONS)
|
|
120646
120966
|
db.exec(sql);
|
|
@@ -120841,9 +121161,9 @@ function createFifoBatchedOutbox(o) {
|
|
|
120841
121161
|
const enqueue = async (item) => {
|
|
120842
121162
|
persist(item);
|
|
120843
121163
|
};
|
|
120844
|
-
const enqueueAndWait = (item) => new Promise((
|
|
121164
|
+
const enqueueAndWait = (item) => new Promise((resolve8, reject) => {
|
|
120845
121165
|
const id = persist(item);
|
|
120846
|
-
waiters.set(id, { resolve:
|
|
121166
|
+
waiters.set(id, { resolve: resolve8, reject });
|
|
120847
121167
|
});
|
|
120848
121168
|
const flushNow = async () => {
|
|
120849
121169
|
if (stopped)
|
|
@@ -121471,10 +121791,10 @@ var init_durable_coalescing_state_schema = __esm(() => {
|
|
|
121471
121791
|
|
|
121472
121792
|
// src/daemon/infrastructure/outbox/lib/durable-coalescing-state-store.ts
|
|
121473
121793
|
import { mkdirSync as mkdirSync10 } from "node:fs";
|
|
121474
|
-
import { dirname as
|
|
121794
|
+
import { dirname as dirname16 } from "node:path";
|
|
121475
121795
|
import { DatabaseSync as DatabaseSync4 } from "node:sqlite";
|
|
121476
121796
|
function openDurableCoalescingStateStore(path3) {
|
|
121477
|
-
mkdirSync10(
|
|
121797
|
+
mkdirSync10(dirname16(path3), { recursive: true });
|
|
121478
121798
|
const db = new DatabaseSync4(path3);
|
|
121479
121799
|
for (const sql of DURABLE_COALESCING_STATE_MIGRATIONS)
|
|
121480
121800
|
db.exec(sql);
|
|
@@ -121624,8 +121944,8 @@ function createCoalescingStateOutbox(options) {
|
|
|
121624
121944
|
const enqueue = async (state) => {
|
|
121625
121945
|
accept(state);
|
|
121626
121946
|
};
|
|
121627
|
-
const enqueueAndWait = (state) => new Promise((
|
|
121628
|
-
accept(state, { resolve:
|
|
121947
|
+
const enqueueAndWait = (state) => new Promise((resolve8, reject) => {
|
|
121948
|
+
accept(state, { resolve: resolve8, reject });
|
|
121629
121949
|
});
|
|
121630
121950
|
const flushNow = async () => {
|
|
121631
121951
|
if (stopped)
|
|
@@ -123250,7 +123570,7 @@ function enqueueGit(cwd, task) {
|
|
|
123250
123570
|
}
|
|
123251
123571
|
function runCommandSpawn(command, args2, cwd, options) {
|
|
123252
123572
|
const successExitCodes = options?.successExitCodes ?? [0];
|
|
123253
|
-
return new Promise((
|
|
123573
|
+
return new Promise((resolve8) => {
|
|
123254
123574
|
const child = spawn3(command, args2, {
|
|
123255
123575
|
cwd,
|
|
123256
123576
|
env: options?.env ?? DEFAULT_GIT_ENV,
|
|
@@ -123276,9 +123596,9 @@ function runCommandSpawn(command, args2, cwd, options) {
|
|
|
123276
123596
|
if (timer)
|
|
123277
123597
|
clearTimeout(timer);
|
|
123278
123598
|
if (successExitCodes.includes(code2 ?? -1))
|
|
123279
|
-
|
|
123599
|
+
resolve8({ stdout, stderr });
|
|
123280
123600
|
else {
|
|
123281
|
-
|
|
123601
|
+
resolve8({
|
|
123282
123602
|
error: Object.assign(new Error(stderr || stdout || `exit ${code2}`), {
|
|
123283
123603
|
code: code2 ?? undefined
|
|
123284
123604
|
})
|
|
@@ -123288,7 +123608,7 @@ function runCommandSpawn(command, args2, cwd, options) {
|
|
|
123288
123608
|
child.on("error", (err) => {
|
|
123289
123609
|
if (timer)
|
|
123290
123610
|
clearTimeout(timer);
|
|
123291
|
-
|
|
123611
|
+
resolve8({ error: err });
|
|
123292
123612
|
});
|
|
123293
123613
|
});
|
|
123294
123614
|
}
|
|
@@ -124170,9 +124490,9 @@ var init_readdirp = __esm(() => {
|
|
|
124170
124490
|
return { files, depth, path: path6 };
|
|
124171
124491
|
}
|
|
124172
124492
|
_formatEntry(dirent, path6) {
|
|
124173
|
-
const
|
|
124174
|
-
const fullPath = pjoin(path6,
|
|
124175
|
-
const entry = { path: fullPath.slice(this._relStart), fullPath, basename:
|
|
124493
|
+
const basename5 = this._isDirent ? dirent.name : dirent;
|
|
124494
|
+
const fullPath = pjoin(path6, basename5);
|
|
124495
|
+
const entry = { path: fullPath.slice(this._relStart), fullPath, basename: basename5 };
|
|
124176
124496
|
if (this._isDirent) {
|
|
124177
124497
|
entry.dirent = dirent;
|
|
124178
124498
|
return entry;
|
|
@@ -124268,9 +124588,9 @@ class NodeFsHandler {
|
|
|
124268
124588
|
_watchWithNodeFs(path6, listener) {
|
|
124269
124589
|
const opts = this.fsw.options;
|
|
124270
124590
|
const directory = sp.dirname(path6);
|
|
124271
|
-
const
|
|
124591
|
+
const basename6 = sp.basename(path6);
|
|
124272
124592
|
const parent = this.fsw._getWatchedDir(directory);
|
|
124273
|
-
parent.add(
|
|
124593
|
+
parent.add(basename6);
|
|
124274
124594
|
const absolutePath = sp.resolve(path6);
|
|
124275
124595
|
const options = {
|
|
124276
124596
|
persistent: opts.persistent
|
|
@@ -124280,7 +124600,7 @@ class NodeFsHandler {
|
|
|
124280
124600
|
let closer;
|
|
124281
124601
|
if (opts.usePolling) {
|
|
124282
124602
|
const enableBin = opts.interval !== opts.binaryInterval;
|
|
124283
|
-
options.interval = enableBin && isBinaryPath(
|
|
124603
|
+
options.interval = enableBin && isBinaryPath(basename6) ? opts.binaryInterval : opts.interval;
|
|
124284
124604
|
closer = setFsWatchFileListener(path6, absolutePath, options, {
|
|
124285
124605
|
listener,
|
|
124286
124606
|
rawEmitter: this.fsw._emitRaw
|
|
@@ -124298,11 +124618,11 @@ class NodeFsHandler {
|
|
|
124298
124618
|
if (this.fsw.closed) {
|
|
124299
124619
|
return;
|
|
124300
124620
|
}
|
|
124301
|
-
const
|
|
124302
|
-
const
|
|
124303
|
-
const parent = this.fsw._getWatchedDir(
|
|
124621
|
+
const dirname18 = sp.dirname(file2);
|
|
124622
|
+
const basename6 = sp.basename(file2);
|
|
124623
|
+
const parent = this.fsw._getWatchedDir(dirname18);
|
|
124304
124624
|
let prevStats = stats;
|
|
124305
|
-
if (parent.has(
|
|
124625
|
+
if (parent.has(basename6))
|
|
124306
124626
|
return;
|
|
124307
124627
|
const listener = async (path6, newStats) => {
|
|
124308
124628
|
if (!this.fsw._throttle(THROTTLE_MODE_WATCH, file2, 5))
|
|
@@ -124327,9 +124647,9 @@ class NodeFsHandler {
|
|
|
124327
124647
|
prevStats = newStats2;
|
|
124328
124648
|
}
|
|
124329
124649
|
} catch (error51) {
|
|
124330
|
-
this.fsw._remove(
|
|
124650
|
+
this.fsw._remove(dirname18, basename6);
|
|
124331
124651
|
}
|
|
124332
|
-
} else if (parent.has(
|
|
124652
|
+
} else if (parent.has(basename6)) {
|
|
124333
124653
|
const at = newStats.atimeMs;
|
|
124334
124654
|
const mt = newStats.mtimeMs;
|
|
124335
124655
|
if (!at || at <= mt || mt !== prevStats.mtimeMs) {
|
|
@@ -124416,7 +124736,7 @@ class NodeFsHandler {
|
|
|
124416
124736
|
this._addToNodeFs(path6, initialAdd, wh, depth + 1);
|
|
124417
124737
|
}
|
|
124418
124738
|
}).on(EV.ERROR, this._boundHandleError);
|
|
124419
|
-
return new Promise((
|
|
124739
|
+
return new Promise((resolve9, reject) => {
|
|
124420
124740
|
if (!stream4)
|
|
124421
124741
|
return reject();
|
|
124422
124742
|
stream4.once(STR_END, () => {
|
|
@@ -124425,7 +124745,7 @@ class NodeFsHandler {
|
|
|
124425
124745
|
return;
|
|
124426
124746
|
}
|
|
124427
124747
|
const wasThrottled = throttler ? throttler.clear() : false;
|
|
124428
|
-
|
|
124748
|
+
resolve9(undefined);
|
|
124429
124749
|
previous.getChildren().filter((item) => {
|
|
124430
124750
|
return item !== directory && !current.has(item);
|
|
124431
124751
|
}).forEach((item) => {
|
|
@@ -125643,8 +125963,8 @@ function createWorkspaceFsWatcher(options) {
|
|
|
125643
125963
|
awaitWriteFinish: { stabilityThreshold: 150, pollInterval: 25 }
|
|
125644
125964
|
});
|
|
125645
125965
|
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((
|
|
125647
|
-
watcher.once("ready",
|
|
125966
|
+
const ready = new Promise((resolve10) => {
|
|
125967
|
+
watcher.once("ready", resolve10);
|
|
125648
125968
|
});
|
|
125649
125969
|
return {
|
|
125650
125970
|
ready,
|
|
@@ -127609,7 +127929,7 @@ var MAX_NAME_LENGTH2 = 256;
|
|
|
127609
127929
|
|
|
127610
127930
|
// src/infrastructure/services/workspace/workspace-resolver.ts
|
|
127611
127931
|
import { readFile as readFile12, readdir as readdir5, stat as stat10 } from "node:fs/promises";
|
|
127612
|
-
import { join as join28, basename as
|
|
127932
|
+
import { join as join28, basename as basename7, resolve as resolve10 } from "node:path";
|
|
127613
127933
|
async function resolveGlobPatternStar(rootDir, cleaned) {
|
|
127614
127934
|
const parentDir2 = join28(rootDir, cleaned.slice(0, -2));
|
|
127615
127935
|
try {
|
|
@@ -127619,7 +127939,7 @@ async function resolveGlobPatternStar(rootDir, cleaned) {
|
|
|
127619
127939
|
if (!entry.isDirectory())
|
|
127620
127940
|
continue;
|
|
127621
127941
|
const dirPath = join28(parentDir2, entry.name);
|
|
127622
|
-
if (
|
|
127942
|
+
if (resolve10(dirPath).startsWith(resolve10(rootDir))) {
|
|
127623
127943
|
dirs.push(dirPath);
|
|
127624
127944
|
}
|
|
127625
127945
|
}
|
|
@@ -127631,7 +127951,7 @@ async function resolveGlobPatternStar(rootDir, cleaned) {
|
|
|
127631
127951
|
async function resolveLiteralPath(rootDir, cleaned) {
|
|
127632
127952
|
const dir = join28(rootDir, cleaned);
|
|
127633
127953
|
try {
|
|
127634
|
-
if (!
|
|
127954
|
+
if (!resolve10(dir).startsWith(resolve10(rootDir)))
|
|
127635
127955
|
return [];
|
|
127636
127956
|
const s = await stat10(dir);
|
|
127637
127957
|
if (s.isDirectory())
|
|
@@ -127652,7 +127972,7 @@ async function readPackageJson(dir) {
|
|
|
127652
127972
|
const content = await readFile12(join28(dir, "package.json"), "utf-8");
|
|
127653
127973
|
const pkg = JSON.parse(content);
|
|
127654
127974
|
return {
|
|
127655
|
-
name: pkg.name ||
|
|
127975
|
+
name: pkg.name || basename7(dir),
|
|
127656
127976
|
scripts: pkg.scripts && typeof pkg.scripts === "object" ? pkg.scripts : {}
|
|
127657
127977
|
};
|
|
127658
127978
|
} catch {
|
|
@@ -127737,7 +128057,7 @@ var init_workspace_resolver = () => {};
|
|
|
127737
128057
|
|
|
127738
128058
|
// src/infrastructure/services/workspace/command-discovery.ts
|
|
127739
128059
|
import { access as access2, readFile as readFile13 } from "node:fs/promises";
|
|
127740
|
-
import { join as join29, relative as relative3, basename as
|
|
128060
|
+
import { join as join29, relative as relative3, basename as basename8 } from "node:path";
|
|
127741
128061
|
async function detectPackageManager(workingDir) {
|
|
127742
128062
|
for (const { file: file2, manager } of LOCKFILE_MAP) {
|
|
127743
128063
|
try {
|
|
@@ -127809,7 +128129,7 @@ function collectRootScriptCommands(scripts, pm, scriptPrefix, rootSw) {
|
|
|
127809
128129
|
return commands;
|
|
127810
128130
|
}
|
|
127811
128131
|
async function readRootPackageJson(workingDir, pm, scriptPrefix) {
|
|
127812
|
-
let rootPackageName =
|
|
128132
|
+
let rootPackageName = basename8(workingDir);
|
|
127813
128133
|
const pkg = await readJsonFile(join29(workingDir, "package.json"), "root package.json");
|
|
127814
128134
|
if (!pkg)
|
|
127815
128135
|
return { commands: [], rootPackageName };
|
|
@@ -127842,7 +128162,7 @@ async function readDenoJson(workingDir) {
|
|
|
127842
128162
|
const deno = await readJsonFile(join29(workingDir, fileName), fileName);
|
|
127843
128163
|
if (!deno?.tasks || typeof deno.tasks !== "object")
|
|
127844
128164
|
continue;
|
|
127845
|
-
const pkgName = deno.name ??
|
|
128165
|
+
const pkgName = deno.name ?? basename8(workingDir);
|
|
127846
128166
|
const subWorkspace = { type: "deno", path: ".", name: pkgName };
|
|
127847
128167
|
for (const [taskName, taskCommand] of Object.entries(deno.tasks)) {
|
|
127848
128168
|
if (!isValidScriptEntry(taskName, taskCommand))
|
|
@@ -127869,7 +128189,7 @@ async function readMakefile(workingDir) {
|
|
|
127869
128189
|
const subWorkspace = {
|
|
127870
128190
|
type: "make",
|
|
127871
128191
|
path: ".",
|
|
127872
|
-
name:
|
|
128192
|
+
name: basename8(workingDir)
|
|
127873
128193
|
};
|
|
127874
128194
|
for (const target of targets) {
|
|
127875
128195
|
commands.push({
|
|
@@ -129455,7 +129775,7 @@ function createDefaultDeps22() {
|
|
|
129455
129775
|
},
|
|
129456
129776
|
clock: {
|
|
129457
129777
|
now: () => Date.now(),
|
|
129458
|
-
delay: (ms) => new Promise((
|
|
129778
|
+
delay: (ms) => new Promise((resolve11) => setTimeout(resolve11, ms))
|
|
129459
129779
|
},
|
|
129460
129780
|
spawning: new HarnessSpawningService({ rateLimiter: new SpawnRateLimiter }),
|
|
129461
129781
|
agentProcessManager: null
|
|
@@ -130952,14 +131272,14 @@ var init_sse_event_buffer = __esm(() => {
|
|
|
130952
131272
|
}
|
|
130953
131273
|
_wake() {
|
|
130954
131274
|
if (this._waiter) {
|
|
130955
|
-
const
|
|
131275
|
+
const resolve11 = this._waiter;
|
|
130956
131276
|
this._waiter = null;
|
|
130957
|
-
|
|
131277
|
+
resolve11();
|
|
130958
131278
|
}
|
|
130959
131279
|
}
|
|
130960
131280
|
_waitForData() {
|
|
130961
|
-
return new Promise((
|
|
130962
|
-
this._waiter =
|
|
131281
|
+
return new Promise((resolve11) => {
|
|
131282
|
+
this._waiter = resolve11;
|
|
130963
131283
|
});
|
|
130964
131284
|
}
|
|
130965
131285
|
[Symbol.asyncIterator]() {
|
|
@@ -131030,8 +131350,8 @@ class OpencodeSdkSession {
|
|
|
131030
131350
|
async prompt(input) {
|
|
131031
131351
|
if (this.closed)
|
|
131032
131352
|
throw new Error("Session is closed");
|
|
131033
|
-
const turnPromise = new Promise((
|
|
131034
|
-
this._turnDoneResolve =
|
|
131353
|
+
const turnPromise = new Promise((resolve11, reject) => {
|
|
131354
|
+
this._turnDoneResolve = resolve11;
|
|
131035
131355
|
this._turnDoneReject = reject;
|
|
131036
131356
|
});
|
|
131037
131357
|
turnPromise.catch(() => {});
|
|
@@ -131379,14 +131699,14 @@ class OpencodeSdkHarness {
|
|
|
131379
131699
|
}
|
|
131380
131700
|
this.sessionListeners.clear();
|
|
131381
131701
|
this.childProcess.kill("SIGTERM");
|
|
131382
|
-
await new Promise((
|
|
131702
|
+
await new Promise((resolve11) => {
|
|
131383
131703
|
const timeout3 = setTimeout(() => {
|
|
131384
131704
|
this.childProcess.kill("SIGKILL");
|
|
131385
|
-
|
|
131705
|
+
resolve11();
|
|
131386
131706
|
}, 5000);
|
|
131387
131707
|
this.childProcess.once("exit", () => {
|
|
131388
131708
|
clearTimeout(timeout3);
|
|
131389
|
-
|
|
131709
|
+
resolve11();
|
|
131390
131710
|
});
|
|
131391
131711
|
});
|
|
131392
131712
|
}
|
|
@@ -132278,10 +132598,10 @@ class BufferedJournalFactory {
|
|
|
132278
132598
|
const waitForInProgress = () => {
|
|
132279
132599
|
if (!flushInProgress)
|
|
132280
132600
|
return Promise.resolve();
|
|
132281
|
-
return new Promise((
|
|
132601
|
+
return new Promise((resolve11) => {
|
|
132282
132602
|
const check2 = () => {
|
|
132283
132603
|
if (!flushInProgress)
|
|
132284
|
-
|
|
132604
|
+
resolve11();
|
|
132285
132605
|
else
|
|
132286
132606
|
setTimeout(check2, 10);
|
|
132287
132607
|
};
|
|
@@ -132507,7 +132827,7 @@ async function emitPhase(deps, event, phase, detail) {
|
|
|
132507
132827
|
}, now));
|
|
132508
132828
|
}
|
|
132509
132829
|
function sleep5(ms) {
|
|
132510
|
-
return new Promise((
|
|
132830
|
+
return new Promise((resolve11) => setTimeout(resolve11, ms));
|
|
132511
132831
|
}
|
|
132512
132832
|
async function waitForHarnessSessionId2(deps, event) {
|
|
132513
132833
|
const initial = deps.agentMgr.getSlot(event.chatroomId, event.role, event.workingDir);
|
|
@@ -132876,19 +133196,19 @@ class ProcessManager {
|
|
|
132876
133196
|
this.pendingStops.clear();
|
|
132877
133197
|
}
|
|
132878
133198
|
waitForExit(runId, ms) {
|
|
132879
|
-
return new Promise((
|
|
133199
|
+
return new Promise((resolve11) => {
|
|
132880
133200
|
const interval = 100;
|
|
132881
133201
|
let elapsed = 0;
|
|
132882
133202
|
const timer = setInterval(() => {
|
|
132883
133203
|
if (!this.runningProcesses.has(runId)) {
|
|
132884
133204
|
clearInterval(timer);
|
|
132885
|
-
|
|
133205
|
+
resolve11(true);
|
|
132886
133206
|
return;
|
|
132887
133207
|
}
|
|
132888
133208
|
elapsed += interval;
|
|
132889
133209
|
if (elapsed >= ms) {
|
|
132890
133210
|
clearInterval(timer);
|
|
132891
|
-
|
|
133211
|
+
resolve11(false);
|
|
132892
133212
|
}
|
|
132893
133213
|
}, interval);
|
|
132894
133214
|
});
|
|
@@ -133019,10 +133339,10 @@ function resolveWhichCommand(name) {
|
|
|
133019
133339
|
return process.platform === "win32" ? `where ${name}` : `which ${name}`;
|
|
133020
133340
|
}
|
|
133021
133341
|
function isCliAvailable(cliName) {
|
|
133022
|
-
return new Promise((
|
|
133342
|
+
return new Promise((resolve11) => {
|
|
133023
133343
|
const child = spawn5(resolveWhichCommand(cliName), [], DETACHED_SHELL_SPAWN_OPTIONS);
|
|
133024
|
-
child.on("error", () =>
|
|
133025
|
-
child.on("close", (code2) =>
|
|
133344
|
+
child.on("error", () => resolve11(false));
|
|
133345
|
+
child.on("close", (code2) => resolve11(code2 === 0));
|
|
133026
133346
|
child.unref();
|
|
133027
133347
|
});
|
|
133028
133348
|
}
|
|
@@ -133354,7 +133674,7 @@ function gitCloneEnv() {
|
|
|
133354
133674
|
function spawnGitClone(repoUrl, cloneTarget, opts) {
|
|
133355
133675
|
const spawnFn = opts.spawnFn ?? spawn6;
|
|
133356
133676
|
const timeoutMs = opts.timeoutMs ?? DEFAULT_TIMEOUT_MS;
|
|
133357
|
-
return new Promise((
|
|
133677
|
+
return new Promise((resolve11) => {
|
|
133358
133678
|
let settled = false;
|
|
133359
133679
|
const stderr = createStderrReader(opts.onProgress);
|
|
133360
133680
|
const child = spawnFn("git", ["clone", "--progress", "--", repoUrl, cloneTarget], {
|
|
@@ -133370,7 +133690,7 @@ function spawnGitClone(repoUrl, cloneTarget, opts) {
|
|
|
133370
133690
|
return;
|
|
133371
133691
|
settled = true;
|
|
133372
133692
|
clearTimeout(timer);
|
|
133373
|
-
|
|
133693
|
+
resolve11(outcome);
|
|
133374
133694
|
};
|
|
133375
133695
|
child.stderr?.setEncoding("utf8");
|
|
133376
133696
|
child.stderr?.on("data", (text) => stderr.push(text));
|
|
@@ -133455,7 +133775,7 @@ async function reportResultWithRetry(deps, result3) {
|
|
|
133455
133775
|
warn(`Git clone result report failed after retries: ${getErrorMessage(error51)}`);
|
|
133456
133776
|
return;
|
|
133457
133777
|
}
|
|
133458
|
-
await new Promise((
|
|
133778
|
+
await new Promise((resolve11) => setTimeout(resolve11, delayMs));
|
|
133459
133779
|
}
|
|
133460
133780
|
}
|
|
133461
133781
|
}
|
|
@@ -133877,7 +134197,7 @@ var init_assert_registered_working_dir = () => {};
|
|
|
133877
134197
|
|
|
133878
134198
|
// src/infrastructure/services/workspace/workspace-path-security.ts
|
|
133879
134199
|
import { realpath as realpath3 } from "node:fs/promises";
|
|
133880
|
-
import { dirname as
|
|
134200
|
+
import { dirname as dirname19, isAbsolute as isAbsolute2, relative as relative4, resolve as resolve11, sep } from "node:path";
|
|
133881
134201
|
import { gunzipSync } from "node:zlib";
|
|
133882
134202
|
function validateRelativePathSegments(filePath) {
|
|
133883
134203
|
if (filePath.includes("\x00"))
|
|
@@ -133905,7 +134225,7 @@ function assertContained(workspaceRoot, targetPath) {
|
|
|
133905
134225
|
return { ok: true };
|
|
133906
134226
|
}
|
|
133907
134227
|
async function resolveNonExistentTarget(workspaceRoot, candidate) {
|
|
133908
|
-
let current =
|
|
134228
|
+
let current = dirname19(candidate);
|
|
133909
134229
|
for (;; ) {
|
|
133910
134230
|
try {
|
|
133911
134231
|
const ancestorReal = await realpath3(current);
|
|
@@ -133913,7 +134233,7 @@ async function resolveNonExistentTarget(workspaceRoot, candidate) {
|
|
|
133913
134233
|
if (!ancestorCheck.ok)
|
|
133914
134234
|
return ancestorCheck;
|
|
133915
134235
|
const suffix = relative4(current, candidate);
|
|
133916
|
-
const resolved =
|
|
134236
|
+
const resolved = resolve11(ancestorReal, suffix);
|
|
133917
134237
|
const resolvedCheck = assertContained(workspaceRoot, resolved);
|
|
133918
134238
|
if (!resolvedCheck.ok)
|
|
133919
134239
|
return resolvedCheck;
|
|
@@ -133923,7 +134243,7 @@ async function resolveNonExistentTarget(workspaceRoot, candidate) {
|
|
|
133923
134243
|
if (code2 !== "ENOENT") {
|
|
133924
134244
|
return { ok: false, error: "Invalid file path" };
|
|
133925
134245
|
}
|
|
133926
|
-
const parent =
|
|
134246
|
+
const parent = dirname19(current);
|
|
133927
134247
|
if (parent === current) {
|
|
133928
134248
|
return { ok: false, error: "Path escapes workspace" };
|
|
133929
134249
|
}
|
|
@@ -133937,11 +134257,11 @@ async function resolvePathWithinWorkspace(workingDir, filePath) {
|
|
|
133937
134257
|
return basic;
|
|
133938
134258
|
let workspaceRoot;
|
|
133939
134259
|
try {
|
|
133940
|
-
workspaceRoot = await realpath3(
|
|
134260
|
+
workspaceRoot = await realpath3(resolve11(workingDir));
|
|
133941
134261
|
} catch {
|
|
133942
134262
|
return { ok: false, error: "Working directory not found" };
|
|
133943
134263
|
}
|
|
133944
|
-
const candidate =
|
|
134264
|
+
const candidate = resolve11(workspaceRoot, filePath);
|
|
133945
134265
|
if (!isPathInsideRoot(workspaceRoot, candidate)) {
|
|
133946
134266
|
return { ok: false, error: "Path escapes workspace" };
|
|
133947
134267
|
}
|
|
@@ -134122,7 +134442,7 @@ function getOrCreateState(key) {
|
|
|
134122
134442
|
return state;
|
|
134123
134443
|
}
|
|
134124
134444
|
function sleep6(ms) {
|
|
134125
|
-
return new Promise((
|
|
134445
|
+
return new Promise((resolve12) => setTimeout(resolve12, ms));
|
|
134126
134446
|
}
|
|
134127
134447
|
async function drainQueue(state, key, debounceMs) {
|
|
134128
134448
|
try {
|
|
@@ -134154,9 +134474,9 @@ function kickDrain(state, key, debounceMs) {
|
|
|
134154
134474
|
if (state.scheduled || state.drainPromise)
|
|
134155
134475
|
return;
|
|
134156
134476
|
state.scheduled = true;
|
|
134157
|
-
state.drainPromise = new Promise((
|
|
134477
|
+
state.drainPromise = new Promise((resolve12, reject) => {
|
|
134158
134478
|
queueMicrotask(() => {
|
|
134159
|
-
drainQueue(state, key, debounceMs).then(
|
|
134479
|
+
drainQueue(state, key, debounceMs).then(resolve12, reject);
|
|
134160
134480
|
});
|
|
134161
134481
|
});
|
|
134162
134482
|
}
|
|
@@ -134302,10 +134622,10 @@ function parseAttachmentFileName(remainder) {
|
|
|
134302
134622
|
if (underscore <= 0)
|
|
134303
134623
|
return false;
|
|
134304
134624
|
const uuid3 = remainder.slice(0, underscore);
|
|
134305
|
-
const
|
|
134306
|
-
if (!UUID_V4_RE.test(uuid3) || !
|
|
134625
|
+
const basename9 = remainder.slice(underscore + 1);
|
|
134626
|
+
if (!UUID_V4_RE.test(uuid3) || !basename9)
|
|
134307
134627
|
return false;
|
|
134308
|
-
return sanitizeChatAttachmentFileName(
|
|
134628
|
+
return sanitizeChatAttachmentFileName(basename9) === basename9;
|
|
134309
134629
|
}
|
|
134310
134630
|
function getInvalidChatAttachmentUploadPathReason(relativePath) {
|
|
134311
134631
|
if (relativePath.includes("\\"))
|
|
@@ -134334,14 +134654,14 @@ function normalizeSegments(relativePath) {
|
|
|
134334
134654
|
function hasBlockedSegment(lowerSegments) {
|
|
134335
134655
|
return lowerSegments.some((segment) => BLOCKED_SEGMENT_NAMES.has(segment));
|
|
134336
134656
|
}
|
|
134337
|
-
function hasBlockedBasename(
|
|
134338
|
-
return /^\.env(?:\.|$)/.test(
|
|
134657
|
+
function hasBlockedBasename(basename9) {
|
|
134658
|
+
return /^\.env(?:\.|$)/.test(basename9) || /\.(?:pem|key)$/.test(basename9) || basename9 === "id_rsa" || basename9 === "credentials.json";
|
|
134339
134659
|
}
|
|
134340
134660
|
function isBlockedUploadTargetPath(relativePath) {
|
|
134341
134661
|
if (!relativePath)
|
|
134342
134662
|
return false;
|
|
134343
|
-
const { lowerSegments, basename:
|
|
134344
|
-
return hasBlockedSegment(lowerSegments) || hasBlockedBasename(
|
|
134663
|
+
const { lowerSegments, basename: basename9 } = normalizeSegments(relativePath);
|
|
134664
|
+
return hasBlockedSegment(lowerSegments) || hasBlockedBasename(basename9);
|
|
134345
134665
|
}
|
|
134346
134666
|
function getBlockedUploadTargetReason(relativePath) {
|
|
134347
134667
|
if (!isBlockedUploadTargetPath(relativePath))
|
|
@@ -134392,7 +134712,7 @@ var init_file_write_request_priority = __esm(() => {
|
|
|
134392
134712
|
|
|
134393
134713
|
// src/daemon/entry/files/file-write-fulfillment.ts
|
|
134394
134714
|
import { access as access4, mkdir as mkdir12, rename as rename4, rm as rm4, writeFile as writeFile11 } from "node:fs/promises";
|
|
134395
|
-
import { dirname as
|
|
134715
|
+
import { dirname as dirname20 } from "node:path";
|
|
134396
134716
|
function isTerminalFileWriteError(errorMessage3) {
|
|
134397
134717
|
const terminalMessages = new Set([
|
|
134398
134718
|
"Invalid file path",
|
|
@@ -134491,7 +134811,7 @@ async function validateWriteOperation(operation, absolutePath) {
|
|
|
134491
134811
|
}
|
|
134492
134812
|
async function writePayloadToDisk(absolutePath, operation, content) {
|
|
134493
134813
|
if (operation === "create") {
|
|
134494
|
-
await mkdir12(
|
|
134814
|
+
await mkdir12(dirname20(absolutePath), { recursive: true });
|
|
134495
134815
|
await writeFile11(absolutePath, content, { flag: "wx" });
|
|
134496
134816
|
return;
|
|
134497
134817
|
}
|
|
@@ -134569,7 +134889,7 @@ async function fulfillOneFileWriteRequest(session2, request3) {
|
|
|
134569
134889
|
});
|
|
134570
134890
|
return;
|
|
134571
134891
|
}
|
|
134572
|
-
await mkdir12(
|
|
134892
|
+
await mkdir12(dirname20(targetResolved.absolutePath), { recursive: true });
|
|
134573
134893
|
await rename4(resolved.absolutePath, targetResolved.absolutePath);
|
|
134574
134894
|
await completeWriteRequest(session2, claimed._id, claimed.revision, { status: "done" });
|
|
134575
134895
|
const elapsed2 = Date.now() - startTime;
|
|
@@ -135178,8 +135498,8 @@ var init_command_runner = __esm(() => {
|
|
|
135178
135498
|
}).catch((err) => {
|
|
135179
135499
|
console.warn(`[${formatTimestamp()}] ⚠️ Failed to mark run as killed on shutdown: ${getErrorMessage(err)}`);
|
|
135180
135500
|
})));
|
|
135181
|
-
yield* exports_Effect.promise(() => new Promise((
|
|
135182
|
-
const t = setTimeout(
|
|
135501
|
+
yield* exports_Effect.promise(() => new Promise((resolve12) => {
|
|
135502
|
+
const t = setTimeout(resolve12, 3000);
|
|
135183
135503
|
t.unref?.();
|
|
135184
135504
|
}));
|
|
135185
135505
|
for (const [, tracked] of trackedEntries) {
|
|
@@ -135191,8 +135511,8 @@ var init_command_runner = __esm(() => {
|
|
|
135191
135511
|
clearTrackedPids();
|
|
135192
135512
|
yield* exports_Effect.promise(() => Promise.race([
|
|
135193
135513
|
statusUpdates,
|
|
135194
|
-
new Promise((
|
|
135195
|
-
const t = setTimeout(
|
|
135514
|
+
new Promise((resolve12) => {
|
|
135515
|
+
const t = setTimeout(resolve12, 2000);
|
|
135196
135516
|
t.unref?.();
|
|
135197
135517
|
})
|
|
135198
135518
|
]));
|
|
@@ -135723,8 +136043,8 @@ function createDaemonRuntime(deps) {
|
|
|
135723
136043
|
const withTimeout2 = async (p, ms) => {
|
|
135724
136044
|
await Promise.race([
|
|
135725
136045
|
Promise.resolve(p).catch(() => {}),
|
|
135726
|
-
new Promise((
|
|
135727
|
-
const t = setTimeout(
|
|
136046
|
+
new Promise((resolve12) => {
|
|
136047
|
+
const t = setTimeout(resolve12, ms);
|
|
135728
136048
|
t.unref?.();
|
|
135729
136049
|
})
|
|
135730
136050
|
]);
|
|
@@ -135895,8 +136215,8 @@ Listening for commands...`);
|
|
|
135895
136215
|
return {
|
|
135896
136216
|
async run() {
|
|
135897
136217
|
await exports_Effect.runPromise(startRuntimeEffect.pipe(exports_Effect.provide(deps.layers)));
|
|
135898
|
-
await new Promise((
|
|
135899
|
-
runResolve =
|
|
136218
|
+
await new Promise((resolve12) => {
|
|
136219
|
+
runResolve = resolve12;
|
|
135900
136220
|
});
|
|
135901
136221
|
},
|
|
135902
136222
|
shutdown
|
|
@@ -136861,10 +137181,10 @@ var init_schema = __esm(() => {
|
|
|
136861
137181
|
|
|
136862
137182
|
// src/daemon/infrastructure/persistence/open-database.ts
|
|
136863
137183
|
import { mkdirSync as mkdirSync11 } from "node:fs";
|
|
136864
|
-
import { dirname as
|
|
137184
|
+
import { dirname as dirname21 } from "node:path";
|
|
136865
137185
|
import { DatabaseSync as DatabaseSync5 } from "node:sqlite";
|
|
136866
137186
|
function openDatabase(dbPath) {
|
|
136867
|
-
mkdirSync11(
|
|
137187
|
+
mkdirSync11(dirname21(dbPath), { recursive: true });
|
|
136868
137188
|
const db = new DatabaseSync5(dbPath);
|
|
136869
137189
|
for (const sql of MIGRATIONS2) {
|
|
136870
137190
|
db.exec(sql);
|
|
@@ -136928,10 +137248,10 @@ var init_persistence = __esm(() => {
|
|
|
136928
137248
|
// src/daemon/local-web/client/lib/socket.ts
|
|
136929
137249
|
async function ensureConnected(s) {
|
|
136930
137250
|
if (!s.connected) {
|
|
136931
|
-
await new Promise((
|
|
137251
|
+
await new Promise((resolve12, reject) => {
|
|
136932
137252
|
const onConnect = () => {
|
|
136933
137253
|
cleanup();
|
|
136934
|
-
|
|
137254
|
+
resolve12();
|
|
136935
137255
|
};
|
|
136936
137256
|
const onError3 = (err) => {
|
|
136937
137257
|
cleanup();
|
|
@@ -141913,13 +142233,13 @@ var require_broadcast_operator = __commonJS((exports) => {
|
|
|
141913
142233
|
return true;
|
|
141914
142234
|
}
|
|
141915
142235
|
emitWithAck(ev, ...args2) {
|
|
141916
|
-
return new Promise((
|
|
142236
|
+
return new Promise((resolve12, reject) => {
|
|
141917
142237
|
args2.push((err, responses) => {
|
|
141918
142238
|
if (err) {
|
|
141919
142239
|
err.responses = responses;
|
|
141920
142240
|
return reject(err);
|
|
141921
142241
|
} else {
|
|
141922
|
-
return
|
|
142242
|
+
return resolve12(responses);
|
|
141923
142243
|
}
|
|
141924
142244
|
});
|
|
141925
142245
|
this.emit(ev, ...args2);
|
|
@@ -142107,12 +142427,12 @@ var require_socket2 = __commonJS((exports) => {
|
|
|
142107
142427
|
}
|
|
142108
142428
|
emitWithAck(ev, ...args2) {
|
|
142109
142429
|
const withErr = this.flags.timeout !== undefined;
|
|
142110
|
-
return new Promise((
|
|
142430
|
+
return new Promise((resolve12, reject) => {
|
|
142111
142431
|
args2.push((arg1, arg2) => {
|
|
142112
142432
|
if (withErr) {
|
|
142113
|
-
return arg1 ? reject(arg1) :
|
|
142433
|
+
return arg1 ? reject(arg1) : resolve12(arg2);
|
|
142114
142434
|
} else {
|
|
142115
|
-
return
|
|
142435
|
+
return resolve12(arg1);
|
|
142116
142436
|
}
|
|
142117
142437
|
});
|
|
142118
142438
|
this.emit(ev, ...args2);
|
|
@@ -142567,13 +142887,13 @@ var require_namespace = __commonJS((exports) => {
|
|
|
142567
142887
|
return true;
|
|
142568
142888
|
}
|
|
142569
142889
|
serverSideEmitWithAck(ev, ...args2) {
|
|
142570
|
-
return new Promise((
|
|
142890
|
+
return new Promise((resolve12, reject) => {
|
|
142571
142891
|
args2.push((err, responses) => {
|
|
142572
142892
|
if (err) {
|
|
142573
142893
|
err.responses = responses;
|
|
142574
142894
|
return reject(err);
|
|
142575
142895
|
} else {
|
|
142576
|
-
return
|
|
142896
|
+
return resolve12(responses);
|
|
142577
142897
|
}
|
|
142578
142898
|
});
|
|
142579
142899
|
this.serverSideEmit(ev, ...args2);
|
|
@@ -143257,7 +143577,7 @@ var require_cluster_adapter = __commonJS((exports) => {
|
|
|
143257
143577
|
return localSockets;
|
|
143258
143578
|
}
|
|
143259
143579
|
const requestId3 = randomId();
|
|
143260
|
-
return new Promise((
|
|
143580
|
+
return new Promise((resolve12, reject) => {
|
|
143261
143581
|
const timeout3 = setTimeout(() => {
|
|
143262
143582
|
const storedRequest2 = this.requests.get(requestId3);
|
|
143263
143583
|
if (storedRequest2) {
|
|
@@ -143267,7 +143587,7 @@ var require_cluster_adapter = __commonJS((exports) => {
|
|
|
143267
143587
|
}, opts.flags.timeout || DEFAULT_TIMEOUT);
|
|
143268
143588
|
const storedRequest = {
|
|
143269
143589
|
type: MessageType.FETCH_SOCKETS,
|
|
143270
|
-
resolve:
|
|
143590
|
+
resolve: resolve12,
|
|
143271
143591
|
timeout: timeout3,
|
|
143272
143592
|
current: 0,
|
|
143273
143593
|
expected: expectedResponseCount,
|
|
@@ -143477,7 +143797,7 @@ var require_cluster_adapter = __commonJS((exports) => {
|
|
|
143477
143797
|
return localSockets;
|
|
143478
143798
|
}
|
|
143479
143799
|
const requestId3 = randomId();
|
|
143480
|
-
return new Promise((
|
|
143800
|
+
return new Promise((resolve12, reject) => {
|
|
143481
143801
|
const timeout3 = setTimeout(() => {
|
|
143482
143802
|
const storedRequest2 = this.customRequests.get(requestId3);
|
|
143483
143803
|
if (storedRequest2) {
|
|
@@ -143487,7 +143807,7 @@ var require_cluster_adapter = __commonJS((exports) => {
|
|
|
143487
143807
|
}, opts.flags.timeout || DEFAULT_TIMEOUT);
|
|
143488
143808
|
const storedRequest = {
|
|
143489
143809
|
type: MessageType.FETCH_SOCKETS,
|
|
143490
|
-
resolve:
|
|
143810
|
+
resolve: resolve12,
|
|
143491
143811
|
timeout: timeout3,
|
|
143492
143812
|
missingUids: new Set([...this.nodesMap.keys()]),
|
|
143493
143813
|
responses: localSockets
|
|
@@ -144216,13 +144536,13 @@ var require_dist5 = __commonJS((exports, module) => {
|
|
|
144216
144536
|
this.engine.close();
|
|
144217
144537
|
(0, uws_1.restoreAdapter)();
|
|
144218
144538
|
if (this.httpServer) {
|
|
144219
|
-
return new Promise((
|
|
144539
|
+
return new Promise((resolve12) => {
|
|
144220
144540
|
this.httpServer.close((err) => {
|
|
144221
144541
|
fn3 && fn3(err);
|
|
144222
144542
|
if (err) {
|
|
144223
144543
|
debug13("server was not running");
|
|
144224
144544
|
}
|
|
144225
|
-
|
|
144545
|
+
resolve12();
|
|
144226
144546
|
});
|
|
144227
144547
|
});
|
|
144228
144548
|
} else {
|
|
@@ -144360,7 +144680,7 @@ function routeRequest(req, res, deps) {
|
|
|
144360
144680
|
|
|
144361
144681
|
// src/daemon/local-web/server/serve-static.ts
|
|
144362
144682
|
import { existsSync as existsSync10, readFileSync as readFileSync12 } from "node:fs";
|
|
144363
|
-
import { dirname as
|
|
144683
|
+
import { dirname as dirname22, join as join31 } from "node:path";
|
|
144364
144684
|
import { fileURLToPath as fileURLToPath7 } from "node:url";
|
|
144365
144685
|
function clientDistCandidates(here) {
|
|
144366
144686
|
return [
|
|
@@ -144369,7 +144689,7 @@ function clientDistCandidates(here) {
|
|
|
144369
144689
|
join31(here, "../src/daemon/local-web/client/build")
|
|
144370
144690
|
];
|
|
144371
144691
|
}
|
|
144372
|
-
function resolveClientDistDir(here =
|
|
144692
|
+
function resolveClientDistDir(here = dirname22(fileURLToPath7(import.meta.url))) {
|
|
144373
144693
|
const candidates = clientDistCandidates(here);
|
|
144374
144694
|
for (const dir of candidates) {
|
|
144375
144695
|
if (existsSync10(join31(dir, "index.html")))
|
|
@@ -144805,9 +145125,9 @@ async function startLocalWebServer(config4, deps = {}) {
|
|
|
144805
145125
|
routeRequest(req, res, { persistence: deps.persistence, streamHub });
|
|
144806
145126
|
});
|
|
144807
145127
|
const port = config4.port ?? 0;
|
|
144808
|
-
await new Promise((
|
|
145128
|
+
await new Promise((resolve12, reject) => {
|
|
144809
145129
|
server.once("error", reject);
|
|
144810
|
-
server.listen(port, config4.host, () =>
|
|
145130
|
+
server.listen(port, config4.host, () => resolve12());
|
|
144811
145131
|
});
|
|
144812
145132
|
const address = server.address();
|
|
144813
145133
|
if (!address || typeof address === "string") {
|
|
@@ -144835,13 +145155,13 @@ async function startLocalWebServer(config4, deps = {}) {
|
|
|
144835
145155
|
port: boundPort,
|
|
144836
145156
|
streamHub,
|
|
144837
145157
|
stop() {
|
|
144838
|
-
return new Promise((
|
|
145158
|
+
return new Promise((resolve12, reject) => {
|
|
144839
145159
|
io2.close((err) => {
|
|
144840
145160
|
if (err) {
|
|
144841
145161
|
reject(err);
|
|
144842
145162
|
return;
|
|
144843
145163
|
}
|
|
144844
|
-
|
|
145164
|
+
resolve12();
|
|
144845
145165
|
});
|
|
144846
145166
|
server.closeAllConnections();
|
|
144847
145167
|
});
|
|
@@ -144962,8 +145282,8 @@ var init_cli_gateway_service = __esm(() => {
|
|
|
144962
145282
|
// src/daemon/entry/start-daemon.ts
|
|
144963
145283
|
async function startDaemon() {
|
|
144964
145284
|
let resolveBoundPort;
|
|
144965
|
-
const localWebPortReady = new Promise((
|
|
144966
|
-
resolveBoundPort =
|
|
145285
|
+
const localWebPortReady = new Promise((resolve12) => {
|
|
145286
|
+
resolveBoundPort = resolve12;
|
|
144967
145287
|
});
|
|
144968
145288
|
const logStreamHub = createLogStreamHub();
|
|
144969
145289
|
const eventStreamHub = createEventStreamHub();
|
|
@@ -145714,7 +146034,7 @@ async function withRetry(fn3, opts) {
|
|
|
145714
146034
|
return;
|
|
145715
146035
|
}
|
|
145716
146036
|
const delay3 = Math.min(baseDelayMs * 2 ** attempt, maxDelayMs);
|
|
145717
|
-
await new Promise((
|
|
146037
|
+
await new Promise((resolve12) => setTimeout(resolve12, delay3));
|
|
145718
146038
|
}
|
|
145719
146039
|
}
|
|
145720
146040
|
return;
|
|
@@ -145768,79 +146088,8 @@ var {
|
|
|
145768
146088
|
// src/commands/generate/index.ts
|
|
145769
146089
|
import { readFile, stat as stat2 } from "node:fs/promises";
|
|
145770
146090
|
init_image();
|
|
145771
|
-
|
|
145772
|
-
|
|
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"];
|
|
146091
|
+
init_local_image_common();
|
|
146092
|
+
var OUTPUT_FORMATS = ["png", "webp"];
|
|
145844
146093
|
function parsePlatform(value) {
|
|
145845
146094
|
if (!GENERATE_IMAGE_PLATFORMS.includes(value)) {
|
|
145846
146095
|
throw new InvalidArgumentError(`must be one of ${GENERATE_IMAGE_PLATFORMS.join(", ")}`);
|
|
@@ -145877,10 +146126,10 @@ function parseSeed(value) {
|
|
|
145877
146126
|
var HELP_AFTER = `
|
|
145878
146127
|
Examples:
|
|
145879
146128
|
chatroom generate-image --platform=fal --prompt "a hero" --out hero.png
|
|
145880
|
-
chatroom generate-image --platform=fal --
|
|
146129
|
+
chatroom generate-image --platform=fal --prompt 'pixel-art potion, transparent-friendly flat background' --output-format png --out potion.png
|
|
145881
146130
|
`;
|
|
145882
146131
|
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
|
|
146132
|
+
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 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
146133
|
try {
|
|
145885
146134
|
const input = options.input === undefined ? undefined : await readInputOption(options.input);
|
|
145886
146135
|
const { createDefaultGenerateImageDeps: createDefaultGenerateImageDeps2 } = await Promise.resolve().then(() => (init_deps(), exports_deps));
|
|
@@ -146229,6 +146478,9 @@ function keyBackground(image, opts) {
|
|
|
146229
146478
|
});
|
|
146230
146479
|
}
|
|
146231
146480
|
|
|
146481
|
+
// src/commands/generate/remove-background.ts
|
|
146482
|
+
init_local_image_common();
|
|
146483
|
+
|
|
146232
146484
|
// src/commands/generate/trim-crop.ts
|
|
146233
146485
|
var MAX_TRIM_PADDING = 64;
|
|
146234
146486
|
function trimRect(contentBox, canvasWidth, canvasHeight, padding) {
|
|
@@ -146812,12 +147064,71 @@ function registerRemoveImageBackgroundCommand(program2) {
|
|
|
146812
147064
|
});
|
|
146813
147065
|
}
|
|
146814
147066
|
|
|
147067
|
+
// src/commands/generate/remove-background-fal-command.ts
|
|
147068
|
+
init_remove_background_fal();
|
|
147069
|
+
var ENGINES = ["bria", "birefnet"];
|
|
147070
|
+
function parseEngine(value) {
|
|
147071
|
+
if (!ENGINES.includes(value)) {
|
|
147072
|
+
throw new InvalidArgumentError(`must be one of ${ENGINES.join(", ")}`);
|
|
147073
|
+
}
|
|
147074
|
+
return value;
|
|
147075
|
+
}
|
|
147076
|
+
var HELP_AFTER3 = `
|
|
147077
|
+
Usage:
|
|
147078
|
+
chatroom remove-image-background-fal --in <png> --out <png>
|
|
147079
|
+
[--engine <bria|birefnet>] [--force]
|
|
147080
|
+
|
|
147081
|
+
Purpose:
|
|
147082
|
+
Cut the subject out of one PNG with fal.ai and write a PNG with alpha. For
|
|
147083
|
+
the offline colour-key pass, use chatroom remove-image-background.
|
|
147084
|
+
|
|
147085
|
+
Model:
|
|
147086
|
+
Background model: bria (default, fal-ai/bria/background/remove) or birefnet
|
|
147087
|
+
(previous BiRefNet Matting backend, fal-ai/birefnet/v2). The input is sent as
|
|
147088
|
+
a base64 data URI, so no separate upload step is needed. Both engines return
|
|
147089
|
+
a PNG with alpha.
|
|
147090
|
+
|
|
147091
|
+
Billing:
|
|
147092
|
+
bria is billed per call (about $0.018 at the time of writing). birefnet is
|
|
147093
|
+
billed per compute-second.
|
|
147094
|
+
|
|
147095
|
+
Refusals:
|
|
147096
|
+
A missing FAL_API_KEY, a missing or non-PNG input, an input over 8 MiB, an
|
|
147097
|
+
image over 100,000,000 pixels, and an existing output or manifest without
|
|
147098
|
+
--force are all refused before the paid fal call.
|
|
147099
|
+
|
|
147100
|
+
Limits:
|
|
147101
|
+
One image per invocation; there is no directory mode and no --model switch.
|
|
147102
|
+
The downloaded result must be a PNG no larger than 32 MiB.
|
|
147103
|
+
The output PNG must match the input's width and height. A mismatch fails
|
|
147104
|
+
without writing anything.
|
|
147105
|
+
|
|
147106
|
+
Examples:
|
|
147107
|
+
chatroom remove-image-background-fal --in tiles/potion.png --out assets/potion.png
|
|
147108
|
+
chatroom remove-image-background-fal --in tiles/potion.png --out assets/potion.png --engine birefnet
|
|
147109
|
+
`;
|
|
147110
|
+
function registerRemoveImageBackgroundFalCommand(program2) {
|
|
147111
|
+
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) => {
|
|
147112
|
+
try {
|
|
147113
|
+
const { createDefaultRemoveBackgroundFalDeps: createDefaultRemoveBackgroundFalDeps2 } = await Promise.resolve().then(() => (init_remove_background_fal_deps(), exports_remove_background_fal_deps));
|
|
147114
|
+
const result = await removeBackgroundFal({ in: options.in, out: options.out, engine: options.engine, force: options.force }, createDefaultRemoveBackgroundFalDeps2());
|
|
147115
|
+
console.log(`Removed background ${result.outPath} (${result.bytes} bytes)`);
|
|
147116
|
+
console.log(`Manifest ${result.manifestPath}`);
|
|
147117
|
+
console.log(`Request ${result.requestId}`);
|
|
147118
|
+
} catch (err) {
|
|
147119
|
+
console.error(`❌ ${err instanceof Error ? err.message : String(err)}`);
|
|
147120
|
+
process.exitCode = 1;
|
|
147121
|
+
}
|
|
147122
|
+
});
|
|
147123
|
+
}
|
|
147124
|
+
|
|
146815
147125
|
// src/commands/generate/slice.ts
|
|
146816
|
-
|
|
147126
|
+
init_local_image_common();
|
|
147127
|
+
import { basename as basename3, extname as extname3, join as join3, resolve as resolve4 } from "node:path";
|
|
146817
147128
|
var SLICE_TOOL = "chatroom slice-image";
|
|
146818
147129
|
var MAX_TILES = 256;
|
|
146819
147130
|
var MAX_GRID_DIMENSION = 64;
|
|
146820
|
-
var
|
|
147131
|
+
var LICENSING3 = "unverified";
|
|
146821
147132
|
|
|
146822
147133
|
class SliceImageError extends Error {
|
|
146823
147134
|
constructor(message) {
|
|
@@ -147075,8 +147386,8 @@ async function sliceImage(opts, deps) {
|
|
|
147075
147386
|
if (opts.names !== undefined && opts.prefix !== undefined) {
|
|
147076
147387
|
throw new SliceImageError("--names and --prefix are mutually exclusive.");
|
|
147077
147388
|
}
|
|
147078
|
-
const inPath =
|
|
147079
|
-
const outDir =
|
|
147389
|
+
const inPath = resolve4(requireNonEmptyPath(opts.in, "--in"));
|
|
147390
|
+
const outDir = resolve4(requireNonEmptyPath(opts.outDir, "--out-dir"));
|
|
147080
147391
|
const force = opts.force === true;
|
|
147081
147392
|
const dryRun = opts.dryRun === true;
|
|
147082
147393
|
const inputStat = await deps.statInput(inPath);
|
|
@@ -147131,7 +147442,7 @@ async function sliceImage(opts, deps) {
|
|
|
147131
147442
|
gutter,
|
|
147132
147443
|
allowRemainder: opts.allowRemainder === true
|
|
147133
147444
|
});
|
|
147134
|
-
const sheetStem =
|
|
147445
|
+
const sheetStem = basename3(inPath, extname3(inPath));
|
|
147135
147446
|
const names = resolveTileNames({
|
|
147136
147447
|
cols,
|
|
147137
147448
|
rows,
|
|
@@ -147279,7 +147590,7 @@ async function sliceImage(opts, deps) {
|
|
|
147279
147590
|
hasAlpha: tile.hasAlpha
|
|
147280
147591
|
},
|
|
147281
147592
|
slicedAt,
|
|
147282
|
-
licensing:
|
|
147593
|
+
licensing: LICENSING3
|
|
147283
147594
|
};
|
|
147284
147595
|
await write(tile.path, () => deps.writeFile(tile.path, tile.encodedBytes, writeOptions));
|
|
147285
147596
|
await write(tile.manifestPath, () => deps.writeJson(tile.manifestPath, manifest, writeOptions));
|
|
@@ -147309,7 +147620,7 @@ async function sliceImage(opts, deps) {
|
|
|
147309
147620
|
})),
|
|
147310
147621
|
skipped,
|
|
147311
147622
|
slicedAt,
|
|
147312
|
-
licensing:
|
|
147623
|
+
licensing: LICENSING3
|
|
147313
147624
|
};
|
|
147314
147625
|
await write(indexPath, () => deps.writeJson(indexPath, index, writeOptions));
|
|
147315
147626
|
return result;
|
|
@@ -147317,7 +147628,7 @@ async function sliceImage(opts, deps) {
|
|
|
147317
147628
|
|
|
147318
147629
|
// src/commands/generate/slice-command.ts
|
|
147319
147630
|
var DECIMAL_INTEGER2 = /^\d+$/;
|
|
147320
|
-
var
|
|
147631
|
+
var HELP_AFTER4 = `
|
|
147321
147632
|
Usage:
|
|
147322
147633
|
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
147634
|
|
|
@@ -147389,7 +147700,7 @@ function printResult2(result, options) {
|
|
|
147389
147700
|
}
|
|
147390
147701
|
}
|
|
147391
147702
|
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",
|
|
147703
|
+
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
147704
|
try {
|
|
147394
147705
|
const { createDefaultSliceImageDeps: createDefaultSliceImageDeps2 } = await Promise.resolve().then(() => (init_slice_deps(), exports_slice_deps));
|
|
147395
147706
|
const sliceOptions = {
|
|
@@ -147430,13 +147741,13 @@ function collectMultiValueOption(value, previous) {
|
|
|
147430
147741
|
|
|
147431
147742
|
// src/utils/stdin.ts
|
|
147432
147743
|
async function readStdin() {
|
|
147433
|
-
return new Promise((
|
|
147744
|
+
return new Promise((resolve5, reject) => {
|
|
147434
147745
|
const chunks = [];
|
|
147435
147746
|
process.stdin.on("data", (chunk) => {
|
|
147436
147747
|
chunks.push(Buffer.from(chunk));
|
|
147437
147748
|
});
|
|
147438
147749
|
process.stdin.on("end", () => {
|
|
147439
|
-
|
|
147750
|
+
resolve5(Buffer.concat(chunks).toString("utf8"));
|
|
147440
147751
|
});
|
|
147441
147752
|
process.stdin.on("error", (err) => {
|
|
147442
147753
|
reject(new Error(`Failed to read stdin: ${err.message}`));
|
|
@@ -147539,6 +147850,7 @@ toolCommand.command("parse-pdf").description("Parse a PDF file and extract text
|
|
|
147539
147850
|
registerGenerateImageCommand(program2);
|
|
147540
147851
|
registerSliceImageCommand(program2);
|
|
147541
147852
|
registerRemoveImageBackgroundCommand(program2);
|
|
147853
|
+
registerRemoveImageBackgroundFalCommand(program2);
|
|
147542
147854
|
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
147855
|
await maybeRequireAuth();
|
|
147544
147856
|
if (options.type !== "remote" && options.type !== "custom") {
|
|
@@ -148057,4 +148369,4 @@ program2.hook("preAction", async (_thisCommand, actionCommand) => {
|
|
|
148057
148369
|
});
|
|
148058
148370
|
program2.parse();
|
|
148059
148371
|
|
|
148060
|
-
//# debugId=
|
|
148372
|
+
//# debugId=CBBD6308FFB368C664756E2164756E21
|