spine-parts 2.29.0 → 2.30.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/cli.ts CHANGED
@@ -25,7 +25,7 @@ import { parseAltArg } from './tools/alternate-cli.ts';
25
25
  import { type AlternateCliInput, assembleStage, build, checkStage, ERROR_MAP_FILE, loopStage, readRuns, readSource, rigStage, suppliedCheckFlag } from './src/build.ts';
26
26
  import { ACCEPTABLE_BARS, DEFAULT_PACK_SHAPE, DEFAULT_PAGE_EDGES, findRigc, PACK_SHAPES, rigcRunnerAt, type PackShape, PAGE_EDGES, type PageEdges, PARTS_HOME_SENTENCE, RIGC_GEOMETRY_VERSION, rigcRanClause, type RigcRunner, NO_PARTS_SENTENCE, SEAM_MEAN_BAR, SOURCE_SENTENCE, SEAM_PX_BAR, SEAM_PX_LEVEL, SPINEBOY_YARDSTICK, TEXTURE_STRETCH_CEILING } from './src/check.ts';
27
27
  import { ComfyClient, resolveHost, runBackground, runMatte, runPainting, runSeeThrough } from './src/comfy/index.ts';
28
- import { DEFAULT_GROW_PX, runForeground } from './src/plate.ts';
28
+ import { coreCfg, DEFAULT_GROW_PX, runForeground } from './src/plate.ts';
29
29
  import { type CharacterConfig, loadClothConfig, loadConfig, loadEarlyConfig, loadPaintConfig } from './src/config.ts';
30
30
  import { configWriteLines, readConfigWriteTarget, separateConfigWriteTarget, stageConfigWrite, type StagedConfigWrite } from './tools/configwrite.ts';
31
31
  import { failLine, guidePointer, PartsError } from './src/errors.ts';
@@ -880,7 +880,7 @@ usage:
880
880
  rig-parts comfy plate --mode background|foreground --painting <png>
881
881
  --mask-from seethrough:<dir>|figure-mask:<dir>|matte:<dir> --out <dir>
882
882
  [--graph lama|core] [--model <name>] [--checkpoint-sha256 <hex>]
883
- [--seed 0] [--grow 8] [--steps 30] [--prompt <text>] [--negative <text>]
883
+ [--seed 0] [--grow 8] [--steps 30] [--cfg 6] [--prompt <text>] [--negative <text>]
884
884
  [--host <url>] [--wait 1800] [--timeout 3600] [--poll 3]
885
885
  A step-4 plate with a receipt: <out>/plate.png, mask.png and receipt.json
886
886
  (spec rig-parts-plate-receipt/1). The mask comes from a source only — the
@@ -1181,7 +1181,7 @@ const TAKES = {
1181
1181
  'comfy seethrough': { valued: ['--image', '--out', '--resolution', '--steps', '--seed', '--prefix', '--host', '--wait', '--timeout', '--poll', '--config', '--depth-run'], switches: ['--offload', '--no-offload', '--lama', '--nf4'] },
1182
1182
  'comfy paint': { valued: ['--config', '--out', '--seeds', '--seed0', '--host', '--wait', '--timeout', '--poll'], switches: [] },
1183
1183
  'comfy matte': { valued: ['--painting', '--out', '--node', '--model', '--checkpoint-sha256', '--resolution', '--threshold', '--host', '--wait', '--timeout', '--poll'], switches: [] },
1184
- 'comfy plate': { valued: ['--mode', '--painting', '--mask-from', '--out', '--graph', '--model', '--checkpoint-sha256', '--seed', '--grow', '--steps', '--prompt', '--negative', '--host', '--wait', '--timeout', '--poll'], switches: [] },
1184
+ 'comfy plate': { valued: ['--mode', '--painting', '--mask-from', '--out', '--graph', '--model', '--checkpoint-sha256', '--seed', '--grow', '--steps', '--cfg', '--prompt', '--negative', '--host', '--wait', '--timeout', '--poll'], switches: [] },
1185
1185
  inputs: { valued: ['--source', '--config', '--out'], switches: [] },
1186
1186
  build: { valued: ['--config', '--source', '--full', '--head', '--out', '--seam', '--project', '--page-edges', '--pack-shape', '--requirements', '--idle-keys', '--lead-in', '--alt', '--set', '--environment', '--wind-band'], switches: ['--loop', '--seam-pairs', '--keep-stills', '--all-sets', '--no-extremes'] },
1187
1187
  compose: { valued: ['--scene', '--out', '--requirements', '--accept'], switches: [] },
@@ -1342,7 +1342,23 @@ function isPackShape(v: PackShape | string): v is PackShape {
1342
1342
  return (PACK_SHAPES as readonly string[]).includes(v);
1343
1343
  }
1344
1344
 
1345
+ /** Resolve the optional stamp clock before either command touches output. */
1346
+ function runStampClock(): string | undefined {
1347
+ const value = process.env.SOURCE_DATE_EPOCH;
1348
+ if (value === undefined) return undefined;
1349
+ const millis = Number(value) * 1000;
1350
+ if (!/^(0|[1-9][0-9]*)$/.test(value) || !Number.isSafeInteger(millis) || Number(value) > 253402300799) {
1351
+ throw new PartsError([{
1352
+ code: 'RUN_STAMP_EPOCH', object: 'environment variable SOURCE_DATE_EPOCH',
1353
+ detail: `${JSON.stringify(value)} found; canonical non-negative integer seconds <= 253402300799 (9999-12-31T23:59:59Z) are required`,
1354
+ }]);
1355
+ }
1356
+ return new Date(millis).toISOString();
1357
+ }
1358
+
1345
1359
  function cmdRig(args: string[]): number {
1360
+ let fixedClock: string | undefined;
1361
+ try { fixedClock = runStampClock(); } catch (err) { return printRefusal(err); }
1346
1362
  let config: string | null = null;
1347
1363
  let partsDir: string | null = null;
1348
1364
  let out: string | null = null;
@@ -1385,11 +1401,11 @@ function cmdRig(args: string[]): number {
1385
1401
  return printRefusal(err);
1386
1402
  }
1387
1403
  const scratch = mkdtempSync(join(tmpdir(), 'rig-parts-rig-'));
1388
- const startedAt = new Date().toISOString();
1404
+ const startedAt = fixedClock ?? new Date().toISOString();
1389
1405
  try {
1390
1406
  const pkg = readPackageIdentity(join(import.meta.dir, 'package.json'));
1391
1407
  const rig = rigStage({ config, parts: partsDir, out, idleKeys: keys, pageEdges: edges, packShape: shape }, rigcRunner(bin), scratch, console.log);
1392
- const finishedAt = new Date().toISOString();
1408
+ const finishedAt = fixedClock ?? new Date().toISOString();
1393
1409
  writeRunStamp({ pkg, command: 'rig', startedAt, finishedAt, outDir: out, configPath: config, outputPaths: rigOutputFiles(rig) });
1394
1410
  return EXIT_OK;
1395
1411
  } catch (err) {
@@ -1846,6 +1862,8 @@ function cmdLoop(args: string[]): number {
1846
1862
  }
1847
1863
 
1848
1864
  function cmdAssemble(args: string[]): number {
1865
+ let fixedClock: string | undefined;
1866
+ try { fixedClock = runStampClock(); } catch (err) { return printRefusal(err); }
1849
1867
  const flags = new Map<string, string>();
1850
1868
  const alts: AlternateCliInput[] = [];
1851
1869
  let propose = false;
@@ -1912,13 +1930,13 @@ function cmdAssemble(args: string[]): number {
1912
1930
  const out = flags.get('--out') as string;
1913
1931
  clearRunStamp(out);
1914
1932
  const pkg = readPackageIdentity(join(import.meta.dir, 'package.json'));
1915
- const startedAt = new Date().toISOString();
1933
+ const startedAt = fixedClock ?? new Date().toISOString();
1916
1934
  const result = assembleStage(
1917
1935
  { source, full, head, config, ...(flags.has('--requirements') ? { requirements: flags.get('--requirements') as string } : {}), ...(seam === undefined ? {} : { seam: seam as SeamRule }), ...(project === undefined ? {} : { project: project as ProjectRule }), ...(alts.length === 0 ? {} : { alts }) },
1918
1936
  { partsJson: join(out, 'rig', 'parts.json'), partsDir: join(out, 'rig', 'parts'), recomposite: join(out, 'render', 'recomposite_rig.png'), errorMap: join(out, 'render', ERROR_MAP_FILE) },
1919
1937
  console.log,
1920
1938
  );
1921
- const finishedAt = new Date().toISOString();
1939
+ const finishedAt = fixedClock ?? new Date().toISOString();
1922
1940
  writeRunStamp({ pkg, command: 'assemble', startedAt, finishedAt, outDir: out, configPath: config, outputPaths: assembleOutputFiles(out, result) });
1923
1941
  return EXIT_OK;
1924
1942
  } catch (err) {
@@ -1969,7 +1987,7 @@ function secondsFlag(v: Map<string, string>, flag: string, fallback: number): nu
1969
1987
  }
1970
1988
 
1971
1989
  /** Flags `comfy plate --mode foreground` does not take: it runs no box and no model. */
1972
- const PLATE_BOX_FLAGS = ['--graph', '--model', '--checkpoint-sha256', '--seed', '--grow', '--steps', '--prompt', '--negative', '--host', '--wait', '--timeout', '--poll'];
1990
+ const PLATE_BOX_FLAGS = ['--graph', '--model', '--checkpoint-sha256', '--seed', '--grow', '--steps', '--cfg', '--prompt', '--negative', '--host', '--wait', '--timeout', '--poll'];
1973
1991
 
1974
1992
  async function cmdComfyPlate(v: Map<string, string>): Promise<number> {
1975
1993
  const mode = v.get('--mode');
@@ -1999,11 +2017,12 @@ async function cmdComfyPlate(v: Map<string, string>): Promise<number> {
1999
2017
  const steps = intFlag(v, '--steps', 30, 1);
2000
2018
  for (const x of [seed, grow, steps]) if (typeof x === 'string') return usage(x);
2001
2019
  if (graph === 'lama') for (const x of ['--steps', '--prompt', '--negative']) if (v.has(x)) return usage(`${x} is for --graph core; the lama graph takes no prompt and no steps`);
2020
+ const cfg = coreCfg(v.get('--cfg'), graph);
2002
2021
  console.log(`rig-parts comfy plate: background (${graph}) ${painting} -> ${out}`);
2003
2022
  // Every local refusal (no source mask, the checksum, the grid) comes before the host is resolved.
2004
2023
  const r = await runBackground(
2005
2024
  () => new ComfyClient(resolveHost(v.get('--host'), process.env.COMFY_HOST), { poll: poll as number, request: 30 }),
2006
- { painting, maskFrom: v.get('--mask-from'), out, graph, model: v.get('--model'), checkpointSha256: v.get('--checkpoint-sha256'), seed: seed as number, growPx: grow as number, steps: steps as number, prompt: v.get('--prompt'), negative: v.get('--negative'), wait: wait as number, timeout: timeout as number },
2025
+ { painting, maskFrom: v.get('--mask-from'), out, graph, model: v.get('--model'), checkpointSha256: v.get('--checkpoint-sha256'), seed: seed as number, growPx: grow as number, steps: steps as number, ...(v.has('--cfg') ? { cfg } : {}), prompt: v.get('--prompt'), negative: v.get('--negative'), wait: wait as number, timeout: timeout as number },
2007
2026
  (l) => console.log(l),
2008
2027
  );
2009
2028
  console.log(` wrote ${join(out, r.output.path)} (sha256 ${r.output.sha256}), ${r.mask.path} and receipt.json; model ${r.model?.name} (checkpoint sha256 declared), GPU ${r.gpu}`);
package/docs/AUTHORING.md CHANGED
@@ -5133,6 +5133,7 @@ row in this page's `rule` and `line` tables; the selftest holds that (`TY16`).
5133
5133
 
5134
5134
  | rule | means | change |
5135
5135
  | --- | --- | --- |
5136
+ | <a id="RUN_STAMP_EPOCH"></a>`RUN_STAMP_EPOCH` | SOURCE_DATE_EPOCH is not canonical non-negative integer seconds at most 253402300799 (9999-12-31T23:59:59Z) | unset the variable for wall-clock stamps or supply integer seconds at most 253402300799 for four-digit-year ISO stamps; 253402300800 and above, empty, signs, fractions, whitespace and leading zeroes are refused before any output is touched |
5136
5137
  | <a id="CONFIG_HYBRID_SOURCE"></a>`CONFIG_HYBRID_SOURCE` | the two hybrid neighbours name different source parts | use a single continuous source layer for the joint band |
5137
5138
  | <a id="CONFIG_HYBRID_CUT"></a>`CONFIG_HYBRID_CUT` | a hybrid joint also declares a cut-cap option | remove cap, cap_shape, edge and cut_band at that joint |
5138
5139
  | <a id="ASSEMBLE_HYBRID_SOURCE"></a>`ASSEMBLE_HYBRID_SOURCE` | effective alternate layer selection gives a band different upper and lower source layers | select the same continuous layer for both rigid neighbours |
@@ -5355,7 +5356,7 @@ or a joint.
5355
5356
  inpaints it on a ComfyUI box. `--graph lama` (the default) uses the
5356
5357
  comfyui-inpaint-nodes pack and its LaMa model (`--model`, default
5357
5358
  `big-lama.pt`). `--graph core` uses ComfyUI's own nodes and the checkpoint
5358
- `--model` names, with `--steps`, `--prompt` and `--negative`; when a painting's
5359
+ `--model` names, with `--steps`, `--cfg` (default 6), `--prompt` and `--negative`; when a painting's
5359
5360
  width or height is not a multiple of 8, it pads the uploaded painting (`edge-replicate`)
5360
5361
  and grown mask (`zero`, kept as context) on the right and bottom (`pad: [0, 0]`)
5361
5362
  to the next multiple of 8, crops the box's output back at `[0, 0]` before
@@ -5405,6 +5406,7 @@ recorded transform. The record fields and sampling formula are specified in
5405
5406
  | <a id="PLATE_MASK_RUN"></a>`PLATE_MASK_RUN` | the figure source has no readable `rig-run/1` assemble `run.json`, or its `figure_rig.png`, `parts.json` or declared `painting_in_rig.png` lacks exactly one matching output hash; or the See-through source has no readable `meta.json` with `image_sha256` and `layers` hashes, or a layer PNG on disk lacks a matching `layers` entry | re-run `assemble` with the source config to regenerate `run.json` and its `rig/` files together, or re-run `comfy seethrough` on the painting to regenerate `meta.json` and `parts/` together |
5406
5407
  | <a id="PLATE_MASK_PAINTING"></a>`PLATE_MASK_PAINTING` | `parts.json` has an invalid `painting_in_rig` declaration, its recorded painting is missing, undecodable or differs from its declared hash, or the supplied painting differs from the recorded opaque RGB; or the supplied painting's SHA-256 differs from a See-through source's `meta.json` `image_sha256` | use the original `--painting` file for this source, or re-run `assemble` or `comfy seethrough` on this painting |
5407
5408
  | <a id="PLATE_CHECKPOINT_SHA256"></a><a id="PLATE_MODEL_GIVEN"></a>`PLATE_CHECKPOINT_SHA256`, `PLATE_MODEL_GIVEN` | `--checkpoint-sha256` absent or not 64 hex characters; `--graph core` without `--model` | the flag |
5409
+ | <a id="PLATE_CORE_CFG"></a>`PLATE_CORE_CFG` | `--cfg` given with `--graph lama`, or not a finite number above 0 | `--cfg`, `--graph` |
5408
5410
  | <a id="PLATE_CORE_GRID"></a>PLATE_CORE_GRID *(retired)* | retired in 2.x: off-grid `core` now pads to the next multiple of 8 and records `grid_transform`; see [STABILITY](STABILITY.md#plate-receipt) | none |
5409
5411
  | <a id="PLATE_PAINTING_PRESENT"></a><a id="PLATE_OUT_EMPTY"></a>`PLATE_PAINTING_PRESENT`, `PLATE_OUT_EMPTY` | no `--painting` file, or an `--out` that already holds entries | `--painting`, `--out` |
5410
5412
  | <a id="COMFY_GPU_NAMED"></a><a id="COMFY_PLATE_SIZE"></a>`COMFY_GPU_NAMED`, `COMFY_PLATE_SIZE` | `/system_stats` does not name exactly one device; the box's image is not the painting's size (or, for off-grid `core`, the padded size) | the box |
package/docs/STABILITY.md CHANGED
@@ -214,7 +214,7 @@ defaults are the help's too, and none is guessed from the art.
214
214
  | `inputs` | `--source`, `--config`, `--out` |
215
215
  | `comfy` | `paint`: `--config`, `--out`; optional `--seeds`, `--seed0`, `--host`, `--wait`, `--timeout`, `--poll` |
216
216
  | `comfy` | `matte`: `--painting`, `--out`, `--node` (`BiRefNetRMBG`), `--model` (`BiRefNet-HR-matting`), `--checkpoint-sha256` (declared, required); optional `--resolution`, `--threshold`, `--host`, `--wait`, `--timeout`, `--poll` (issue #1204) |
217
- | `comfy` | `plate`: `--mode` (`background` or `foreground`), `--painting`, `--mask-from` (`seethrough:<dir>`, `figure-mask:<dir>` or `matte:<dir>`), `--out`; with `--mode background` also `--checkpoint-sha256` (required) and optional `--graph` (`lama` or `core`), `--model` (required with `core`), `--seed`, `--grow`, `--steps`, `--prompt`, `--negative` (the last three with `core` only), `--host`, `--wait`, `--timeout`, `--poll` (issue #1183, additive) |
217
+ | `comfy` | `plate`: `--mode` (`background` or `foreground`), `--painting`, `--mask-from` (`seethrough:<dir>`, `figure-mask:<dir>` or `matte:<dir>`), `--out`; with `--mode background` also `--checkpoint-sha256` (required) and optional `--graph` (`lama` or `core`), `--model` (required with `core`), `--seed`, `--grow`, `--steps`, `--cfg`, `--prompt`, `--negative` (the last four with `core` only), `--host`, `--wait`, `--timeout`, `--poll` (issue #1183, additive) |
218
218
  | `comfy` | `seethrough`: `--image`, `--out`; optional `--resolution`, `--steps`, `--seed`, `--prefix`, `--offload`, `--no-offload`, `--lama`, `--nf4`, `--host`, `--wait`, `--timeout`, `--poll`, `--config` (See-through settings and optional depth block), `--depth-run` (`full` or `head`, required with the block) |
219
219
  | `assemble` | `--propose-plan` with `--source`, `--full`, `--config`, optional `--head`, `--write-config` (must name `--config` itself, issue #356); or `--source`, `--full`, `--config`, `--out`, optional `--head` (without it, one run: issue #359), `--seam` (near-white, silhouette), `--project` (core, visible), `--alt` (repeatable `<name>=<source>:<full>[:<head>]`, issue #454), `--requirements` (source-bound cut-material evidence only when the file declares `cut_material`, issue #888) |
220
220
  | `head-crop-preflight` | `--full`, `--canvas`, `--head-box` (JSON coordinate array); read-only advice before the head run, original alpha > 8 samples (issue #1082) |
@@ -448,7 +448,7 @@ new spec version. Every path in it is relative to the receipt's directory.
448
448
  | `painting` | `{ path, sha256 }` of the painting read |
449
449
  | `mask` | `{ source, from, path, sha256 }`: `source` is `"seethrough"`, `"figure-mask"` or `"matte"`, `from` the source directory, `path` the mask actually used (`mask.png`, opaque white inside) |
450
450
  | `model` | `{ name, checkpoint_sha256, checkpoint_sha256_from }`, or null for `foreground`. `checkpoint_sha256` is the `--checkpoint-sha256` value, lower-cased; `checkpoint_sha256_from` is `"declared"`: the box reports no hash, so this field is **declared, not measured** |
451
- | `params` | every parameter of the run, the seed included, in a fixed order per graph: `lama` — `seed`, `grow_px`, `mask_alpha_above`; `core` — `seed`, `grow_px`, `steps`, `cfg`, `sampler`, `scheduler`, `denoise`, `prompt`, `negative`, `mask_alpha_above`; `foreground` — `mask_alpha_above` |
451
+ | `params` | every parameter of the run, the seed included, in a fixed order per graph: `lama` — `seed`, `grow_px`, `mask_alpha_above`; `core` — `seed`, `grow_px`, `steps`, `cfg` (`--cfg`, default `6`), `sampler`, `scheduler`, `denoise`, `prompt`, `negative`, `mask_alpha_above`; `foreground` — `mask_alpha_above` |
452
452
  | `graph` | `"rig-parts/plate-background-lama/1"`, `"rig-parts/plate-background-core/1"`, or the fixed local id `"rig-parts/plate-foreground/1"` |
453
453
  | `gpu` | the device `/system_stats` names (the same seed gives other pixels on another GPU), or null for `foreground` |
454
454
  | `grid_transform` | present only when `mode` is `"background"`, `graph` is `"rig-parts/plate-background-core/1"`, and the painting's width or height is not a multiple of 8 (issue #1209, additive): `{ source: [width, height], padded: [ceil(width/8)*8, ceil(height/8)*8], pad: [0, 0], pad_fill: "edge-replicate", mask_pad_fill: "zero", inverse: "crop" }` in that key order. Omitted for on-grid `core`, `lama`, and `foreground` |
@@ -688,12 +688,24 @@ Key order is fixed as shown; `outputs` is sorted by `/`-separated `path` in UTF-
688
688
  code-unit order. Every `path` in `config` and `outputs` is relative to the `--out`
689
689
  directory (`../`-prefixed when `--config` sits outside `--out`; never an absolute or
690
690
  home path). Every `sha256` is computed from the bytes on disk after writing. A refused
691
- run writes no `run.json`. Because `started_at` and `finished_at` record wall-clock
692
- time read in `cli.ts` (`src/` remains pure), `run.json` is outside the byte-for-byte
691
+ run writes no `run.json`. By default, `started_at` and `finished_at` record wall-clock
692
+ time read in `cli.ts` (`src/` remains pure). With that default, `run.json` is outside
693
+ the byte-for-byte
693
694
  determinism comparisons (`RG03`, `RG19`, `AS07`); for the same input at the same
694
695
  relative `--config` layout, two `run.json` files differ only in `started_at` and
695
696
  `finished_at`.
696
697
 
698
+ Set `SOURCE_DATE_EPOCH` to opt into a fixed clock: both timestamps equal that
699
+ instant in UTC ISO format, without adding a stamp field. The value must match
700
+ `^(0|[1-9][0-9]*)$` and be at most 253402300799 seconds
701
+ (9999-12-31T23:59:59Z), preserving the four-digit-year ISO form.
702
+ 253402300800 and above are refused. Empty, negative,
703
+ fractional, non-numeric, noncanonical and out-of-range values refuse
704
+ `RUN_STAMP_EPOCH`, naming the variable, found value and requirement before any
705
+ output is written or an existing stamp is removed. Unset preserves the existing
706
+ wall-clock path and stamp format. Fixed clocks make stamps byte-identical for
707
+ identical inputs and the same relative config layout.
708
+
697
709
  `outputs` lists exactly the files the stage wrote in this run, derived from what the
698
710
  stage returns, not from a walk of `--out`: a stray or earlier file under `--out` is
699
711
  neither hashed nor listed. Before the stage starts, the command removes an earlier
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "spine-parts",
3
- "version": "2.29.0",
3
+ "version": "2.30.0",
4
4
  "description": "AI-authored 2D character parts from one anime painting and its See-through layer decomposition: measured parts, weighted-mesh rig specs, verified through rig-c before anything is written. A CLI for agents that cannot see the image.",
5
5
  "type": "module",
6
6
  "bin": {
@@ -28,6 +28,7 @@ import { checkGraph, type Graph } from '../graphs.ts';
28
28
  import {
29
29
  assertPlateOutFree,
30
30
  CORE_DEFAULTS,
31
+ coreCfg,
31
32
  type CoreParams,
32
33
  corePlateGraph,
33
34
  cropCoreGrid,
@@ -63,6 +64,7 @@ export interface BackgroundRun {
63
64
  seed: number;
64
65
  growPx: number;
65
66
  steps: number;
67
+ cfg?: number | string | undefined;
66
68
  prompt: string | undefined;
67
69
  negative: string | undefined;
68
70
  wait: number;
@@ -82,6 +84,7 @@ export function gpuName(stats: Record<string, unknown>, host: string): string {
82
84
  /** `connect` is called only after every local check has passed, so a refused run never resolves a host or reaches a box. */
83
85
  export async function runBackground(connect: () => ComfyClient, run: BackgroundRun, say: (line: string) => void): Promise<PlateReceipt> {
84
86
  // Local first: no source mask, a bad checksum or a missing checkpoint is refused before the box is reached.
87
+ const cfg = coreCfg(run.cfg, run.graph);
85
88
  const from = parseMaskFrom(run.maskFrom);
86
89
  const painting = readPlatePainting(run.painting);
87
90
  const { width: W, height: H } = painting.raster;
@@ -97,7 +100,7 @@ export async function runBackground(connect: () => ComfyClient, run: BackgroundR
97
100
  const uploadMaskBytes = encodePngBytes(maskImage(prepared.mask));
98
101
  const model = run.model ?? LAMA_MODEL;
99
102
  const lama: LamaParams = { seed: run.seed, grow_px: run.growPx };
100
- const core: CoreParams = { seed: run.seed, grow_px: run.growPx, steps: run.steps, cfg: CORE_DEFAULTS.cfg, sampler: CORE_DEFAULTS.sampler, scheduler: CORE_DEFAULTS.scheduler, denoise: CORE_DEFAULTS.denoise, prompt: run.prompt ?? CORE_DEFAULTS.prompt, negative: run.negative ?? CORE_DEFAULTS.negative };
103
+ const core: CoreParams = { seed: run.seed, grow_px: run.growPx, steps: run.steps, cfg, sampler: CORE_DEFAULTS.sampler, scheduler: CORE_DEFAULTS.scheduler, denoise: CORE_DEFAULTS.denoise, prompt: run.prompt ?? CORE_DEFAULTS.prompt, negative: run.negative ?? CORE_DEFAULTS.negative };
101
104
  const prefix = `rig_parts_plate_${crypto.randomUUID().slice(0, 8)}`;
102
105
  const build = (p: string, m: string): Graph => (run.graph === 'lama' ? lamaPlateGraph(p, m, model, lama, prefix) : corePlateGraph(p, m, model, core, prefix));
103
106
 
package/src/plate.ts CHANGED
@@ -106,6 +106,21 @@ export function declaredChecksum(value: string | undefined): string {
106
106
  return value.toLowerCase();
107
107
  }
108
108
 
109
+ /** `--cfg <number>` for `--graph core`: a finite number above 0, or `CORE_DEFAULTS.cfg` when absent; refused on `lama`. */
110
+ export function coreCfg(value: number | string | undefined, graph: PlateGraph): number {
111
+ if (graph !== 'core') {
112
+ if (value !== undefined) fail('PLATE_CORE_CFG', '--cfg', 'is for --graph core; the lama graph takes no CFG parameter');
113
+ return CORE_DEFAULTS.cfg;
114
+ }
115
+ if (value === undefined) return CORE_DEFAULTS.cfg;
116
+ const trimmed = typeof value === 'string' ? value.trim() : '';
117
+ const n = typeof value === 'number' ? value : /^[+-]?(?:\d+\.?\d*|\.\d+)(?:[eE][+-]?\d+)?$/.test(trimmed) ? Number(trimmed) : NaN;
118
+ if (!Number.isFinite(n) || n <= 0) {
119
+ fail('PLATE_CORE_CFG', '--cfg', `is ${typeof value === 'number' ? String(value) : JSON.stringify(value)}; a finite number above 0 is required`);
120
+ }
121
+ return n;
122
+ }
123
+
109
124
  /** `--mask-from <source>:<dir>`, parsed; an absent or unknown source is refused by name. */
110
125
  export function parseMaskFrom(value: string | undefined): { source: MaskSource; dir: string } {
111
126
  if (value === undefined) {