@12ui/design 0.2.11 → 0.2.13
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/README.md +9 -0
- package/dist/cli-arguments.d.ts.map +1 -1
- package/dist/cli-arguments.js +2 -0
- package/dist/cli-arguments.js.map +1 -1
- package/dist/cli-capabilities.d.ts +13 -0
- package/dist/cli-capabilities.d.ts.map +1 -1
- package/dist/cli-capabilities.js +16 -0
- package/dist/cli-capabilities.js.map +1 -1
- package/dist/cli-image-batch-command.d.ts.map +1 -1
- package/dist/cli-image-batch-command.js +104 -53
- package/dist/cli-image-batch-command.js.map +1 -1
- package/dist/cli-image-batch-materialize.d.ts +27 -0
- package/dist/cli-image-batch-materialize.d.ts.map +1 -0
- package/dist/cli-image-batch-materialize.js +41 -0
- package/dist/cli-image-batch-materialize.js.map +1 -0
- package/dist/cli-image-batch-resume.d.ts +27 -0
- package/dist/cli-image-batch-resume.d.ts.map +1 -0
- package/dist/cli-image-batch-resume.js +158 -0
- package/dist/cli-image-batch-resume.js.map +1 -0
- package/dist/cli-image-command.d.ts.map +1 -1
- package/dist/cli-image-command.js +14 -2
- package/dist/cli-image-command.js.map +1 -1
- package/dist/cli-progress.d.ts +44 -0
- package/dist/cli-progress.d.ts.map +1 -0
- package/dist/cli-progress.js +83 -0
- package/dist/cli-progress.js.map +1 -0
- package/dist/cli.js +92 -6
- package/dist/cli.js.map +1 -1
- package/dist/conversion-client.d.ts +32 -12
- package/dist/conversion-client.d.ts.map +1 -1
- package/dist/conversion-client.js +14 -0
- package/dist/conversion-client.js.map +1 -1
- package/dist/image-generation-batch-attempt.d.ts +28 -0
- package/dist/image-generation-batch-attempt.d.ts.map +1 -0
- package/dist/image-generation-batch-attempt.js +48 -0
- package/dist/image-generation-batch-attempt.js.map +1 -0
- package/dist/image-generation-completion.d.ts +43 -0
- package/dist/image-generation-completion.d.ts.map +1 -0
- package/dist/image-generation-completion.js +54 -0
- package/dist/image-generation-completion.js.map +1 -0
- package/dist/image-generation-fs.d.ts +3 -0
- package/dist/image-generation-fs.d.ts.map +1 -0
- package/dist/image-generation-fs.js +23 -0
- package/dist/image-generation-fs.js.map +1 -0
- package/dist/image-generation-request.d.ts +13 -3
- package/dist/image-generation-request.d.ts.map +1 -1
- package/dist/image-generation-request.js +21 -19
- package/dist/image-generation-request.js.map +1 -1
- package/dist/image-generation-resume.d.ts +36 -0
- package/dist/image-generation-resume.d.ts.map +1 -0
- package/dist/image-generation-resume.js +83 -0
- package/dist/image-generation-resume.js.map +1 -0
- package/dist/image-generation-run.d.ts +11 -0
- package/dist/image-generation-run.d.ts.map +1 -1
- package/dist/image-generation-run.js +23 -9
- package/dist/image-generation-run.js.map +1 -1
- package/dist/image-generation-staging.d.ts +25 -0
- package/dist/image-generation-staging.d.ts.map +1 -0
- package/dist/image-generation-staging.js +80 -0
- package/dist/image-generation-staging.js.map +1 -0
- package/dist/legacy-skill-catalog.d.ts.map +1 -1
- package/dist/legacy-skill-catalog.js +34 -0
- package/dist/legacy-skill-catalog.js.map +1 -1
- package/package.json +1 -1
- package/skills/design/SKILL.md +54 -7
- package/skills/design/references/selection-contract.md +16 -0
- package/skills/design-convert/SKILL.md +55 -2
package/README.md
CHANGED
|
@@ -99,6 +99,15 @@ PNG output, and one stable idempotency key. Per-candidate and batch evidence
|
|
|
99
99
|
records provider-start and completion times. It never retries a candidate or
|
|
100
100
|
switches providers after dispatch.
|
|
101
101
|
|
|
102
|
+
Candidates are written into a hidden staging directory and moved into place only
|
|
103
|
+
once the batch is terminal, so a caller listing the output directory can never
|
|
104
|
+
observe a half-written batch. Completion is published as a
|
|
105
|
+
`generation.complete.json` sentinel beside the candidates, carrying each
|
|
106
|
+
candidate's status, sha256, and byte count. `--resume` recovers an interrupted
|
|
107
|
+
batch: it delivers candidates that were already generated and re-requests only
|
|
108
|
+
those the provider provably never billed, so it can never buy a candidate twice,
|
|
109
|
+
and it refuses a batch that already completed.
|
|
110
|
+
|
|
102
111
|
The single-candidate `image generate` command remains available. Both commands
|
|
103
112
|
resolve authenticated Codex first, then `OPENAI_API_KEY` from the process or
|
|
104
113
|
exactly `<project-root>/.env`. They refuse a Git-tracked `.env`, never store or
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli-arguments.d.ts","sourceRoot":"","sources":["../src/cli-arguments.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,QAAQ,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC,CAAC;
|
|
1
|
+
{"version":3,"file":"cli-arguments.d.ts","sourceRoot":"","sources":["../src/cli-arguments.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,QAAQ,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC,CAAC;AAarD,eAAO,MAAM,iBAAiB,GAC5B,MAAM,MAAM,EAAE,KACb;IAAE,OAAO,EAAE,MAAM,EAAE,CAAC;IAAC,KAAK,EAAE,QAAQ,CAAA;CAqBtC,CAAC;AAEF,eAAO,MAAM,UAAU,GAAI,OAAO,QAAQ,EAAE,MAAM,MAAM,KAAG,MAAM,GAAG,SAGnE,CAAC;AAEF,eAAO,MAAM,WAAW,GAAI,OAAO,QAAQ,EAAE,MAAM,MAAM,KAAG,OAA+B,CAAC"}
|
package/dist/cli-arguments.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli-arguments.js","sourceRoot":"","sources":["../src/cli-arguments.ts"],"names":[],"mappings":"AAEA,MAAM,YAAY,GAAG,IAAI,GAAG,CAAC;IAC3B,QAAQ;IACR,OAAO;IACP,MAAM;IACN,MAAM;IACN,WAAW;IACX,SAAS;CACV,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAC/B,IAAc,EAC0B,EAAE;IAC1C,MAAM,OAAO,GAAa,EAAE,CAAC;IAC7B,MAAM,KAAK,GAAa,EAAE,CAAC;IAC3B,KAAK,IAAI,KAAK,GAAG,CAAC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,GAAG,IAAI,CAAC;QACnB,KAAK,IAAI,CAAC,CAAC;IACb,CAAC;IACD,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC;AAC5B,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,UAAU,GAAG,CAAC,KAAe,EAAE,IAAY,EAAsB,EAAE;IAC9E,MAAM,KAAK,GAAG,KAAK,CAAC,IAAI,CAAC,CAAC;IAC1B,OAAO,OAAO,KAAK,KAAK,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,SAAS,CAAC;AACvD,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,WAAW,GAAG,CAAC,KAAe,EAAE,IAAY,EAAW,EAAE,CAAC,KAAK,CAAC,IAAI,CAAC,KAAK,IAAI,CAAC"}
|
|
@@ -9,6 +9,19 @@ export declare const CLI_CAPABILITIES: {
|
|
|
9
9
|
readonly description: "Set the native output canvas width by proportionally resizing image input up or down.";
|
|
10
10
|
};
|
|
11
11
|
readonly responsiveQualities: readonly ["standard", "pro"];
|
|
12
|
+
readonly fusedExport: {
|
|
13
|
+
readonly flag: "--export";
|
|
14
|
+
readonly values: readonly ["html"];
|
|
15
|
+
readonly qualityFlag: "--export-quality";
|
|
16
|
+
readonly outFlag: "--export-out";
|
|
17
|
+
readonly description: string;
|
|
18
|
+
readonly expectedSeconds: 300;
|
|
19
|
+
};
|
|
20
|
+
readonly expectedSeconds: {
|
|
21
|
+
readonly convert: 240;
|
|
22
|
+
readonly export: 240;
|
|
23
|
+
readonly convertWithExport: 300;
|
|
24
|
+
};
|
|
12
25
|
readonly projectProfileSchema: {
|
|
13
26
|
readonly required: readonly ["version", "framework", "styling", "language", "packaging"];
|
|
14
27
|
readonly additionalProperties: false;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli-capabilities.d.ts","sourceRoot":"","sources":["../src/cli-capabilities.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"cli-capabilities.d.ts","sourceRoot":"","sources":["../src/cli-capabilities.ts"],"names":[],"mappings":"AAcA,eAAO,MAAM,gBAAgB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAqCnB,CAAC"}
|
package/dist/cli-capabilities.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { CONVERSION_DURATION_HINTS } from './cli-progress.js';
|
|
1
2
|
import { CONVERSION_MODELS } from './conversion-models.js';
|
|
2
3
|
import { CONVERSION_OUTPUT_MEDIA_TYPES, CONVERSION_OUTPUTS, } from './conversion-outputs.js';
|
|
3
4
|
import { MAX_IMAGE_OUTPUT_WIDTH } from './image-output-width.js';
|
|
@@ -19,6 +20,21 @@ export const CLI_CAPABILITIES = {
|
|
|
19
20
|
description: 'Set the native output canvas width by proportionally resizing image input up or down.',
|
|
20
21
|
},
|
|
21
22
|
responsiveQualities: RESPONSIVE_CONVERSION_QUALITIES,
|
|
23
|
+
fusedExport: {
|
|
24
|
+
flag: '--export',
|
|
25
|
+
values: ['html'],
|
|
26
|
+
qualityFlag: '--export-quality',
|
|
27
|
+
outFlag: '--export-out',
|
|
28
|
+
description: 'Convert to LayerDoc and export responsive HTML in one blocking command. The export runs'
|
|
29
|
+
+ ' alongside the conversion instead of after it, so the pair costs about the conversion'
|
|
30
|
+
+ ' alone rather than the sum. Requires --output layerdoc and image input.',
|
|
31
|
+
expectedSeconds: CONVERSION_DURATION_HINTS.fused,
|
|
32
|
+
},
|
|
33
|
+
expectedSeconds: {
|
|
34
|
+
convert: CONVERSION_DURATION_HINTS.convert,
|
|
35
|
+
export: CONVERSION_DURATION_HINTS.export,
|
|
36
|
+
convertWithExport: CONVERSION_DURATION_HINTS.fused,
|
|
37
|
+
},
|
|
22
38
|
projectProfileSchema: PROJECT_PROFILE_SCHEMA,
|
|
23
39
|
projectProfiles: {
|
|
24
40
|
web_project: WEB_PROJECT_CAPABILITIES,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli-capabilities.js","sourceRoot":"","sources":["../src/cli-capabilities.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAC3D,OAAO,EACL,6BAA6B,EAC7B,kBAAkB,GACnB,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAAE,sBAAsB,EAAE,MAAM,yBAAyB,CAAC;AACjE,OAAO,EACL,wBAAwB,EACxB,sBAAsB,EACtB,wBAAwB,GACzB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,+BAA+B,EAAE,MAAM,yBAAyB,CAAC;AAE1E,MAAM,CAAC,MAAM,gBAAgB,GAAG;IAC9B,MAAM,EAAE;QACN,WAAW;QACX,YAAY;QACZ,YAAY;QACZ,6BAA6B,CAAC,QAAQ;KACvC;IACD,OAAO,EAAE,kBAAkB;IAC3B,WAAW,EAAE,iBAAiB;IAC9B,gBAAgB,EAAE;QAChB,IAAI,EAAE,SAAS;QACf,OAAO,EAAE,CAAC;QACV,OAAO,EAAE,sBAAsB;QAC/B,WAAW,EAAE,uFAAuF;KACrG;IACD,mBAAmB,EAAE,+BAA+B;IACpD,oBAAoB,EAAE,sBAAsB;IAC5C,eAAe,EAAE;QACf,WAAW,EAAE,wBAAwB;QACrC,WAAW,EAAE,wBAAwB;KACtC;CACO,CAAC"}
|
|
1
|
+
{"version":3,"file":"cli-capabilities.js","sourceRoot":"","sources":["../src/cli-capabilities.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,yBAAyB,EAAE,MAAM,mBAAmB,CAAC;AAC9D,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAC3D,OAAO,EACL,6BAA6B,EAC7B,kBAAkB,GACnB,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAAE,sBAAsB,EAAE,MAAM,yBAAyB,CAAC;AACjE,OAAO,EACL,wBAAwB,EACxB,sBAAsB,EACtB,wBAAwB,GACzB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,+BAA+B,EAAE,MAAM,yBAAyB,CAAC;AAE1E,MAAM,CAAC,MAAM,gBAAgB,GAAG;IAC9B,MAAM,EAAE;QACN,WAAW;QACX,YAAY;QACZ,YAAY;QACZ,6BAA6B,CAAC,QAAQ;KACvC;IACD,OAAO,EAAE,kBAAkB;IAC3B,WAAW,EAAE,iBAAiB;IAC9B,gBAAgB,EAAE;QAChB,IAAI,EAAE,SAAS;QACf,OAAO,EAAE,CAAC;QACV,OAAO,EAAE,sBAAsB;QAC/B,WAAW,EAAE,uFAAuF;KACrG;IACD,mBAAmB,EAAE,+BAA+B;IACpD,WAAW,EAAE;QACX,IAAI,EAAE,UAAU;QAChB,MAAM,EAAE,CAAC,MAAM,CAAC;QAChB,WAAW,EAAE,kBAAkB;QAC/B,OAAO,EAAE,cAAc;QACvB,WAAW,EACT,yFAAyF;cACvF,uFAAuF;cACvF,yEAAyE;QAC7E,eAAe,EAAE,yBAAyB,CAAC,KAAK;KACjD;IACD,eAAe,EAAE;QACf,OAAO,EAAE,yBAAyB,CAAC,OAAO;QAC1C,MAAM,EAAE,yBAAyB,CAAC,MAAM;QACxC,iBAAiB,EAAE,yBAAyB,CAAC,KAAK;KACnD;IACD,oBAAoB,EAAE,sBAAsB;IAC5C,eAAe,EAAE;QACf,WAAW,EAAE,wBAAwB;QACrC,WAAW,EAAE,wBAAwB;KACtC;CACO,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli-image-batch-command.d.ts","sourceRoot":"","sources":["../src/cli-image-batch-command.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"cli-image-batch-command.d.ts","sourceRoot":"","sources":["../src/cli-image-batch-command.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAErD,OAAO,EAA2B,KAAK,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAoC5E,OAAO,EAAE,sBAAsB,EAAE,MAAM,+BAA+B,CAAC;AA+CvE,eAAO,MAAM,oBAAoB,GAC/B,OAAO,QAAQ,EACf,eAAc;IACZ,QAAQ,CAAC,EAAE,OAAO,aAAa,CAAC;IAChC,SAAS,CAAC,EAAE,OAAO,sBAAsB,CAAC;CACtC,KACL,OAAO,CAAC,IAAI,CA8Kd,CAAC"}
|
|
@@ -1,57 +1,86 @@
|
|
|
1
|
-
import { randomUUID } from 'node:crypto';
|
|
2
|
-
import { mkdir, rename, rm, writeFile } from 'node:fs/promises';
|
|
3
1
|
import path from 'node:path';
|
|
4
|
-
import { stringFlag } from './cli-arguments.js';
|
|
2
|
+
import { booleanFlag, stringFlag } from './cli-arguments.js';
|
|
3
|
+
import { materializeImageBatch, publishImageBatchCompletion, } from './cli-image-batch-materialize.js';
|
|
4
|
+
import { describeBatchRecovery, resumeImageBatchCommand } from './cli-image-batch-resume.js';
|
|
5
|
+
import { imageBatchAttemptPath, readBatchAttempt, writeBatchAttempt, } from './image-generation-batch-attempt.js';
|
|
5
6
|
import { readImageGenerationBatchManifest, resolveImageGenerationBatchRequests, } from './image-generation-batch-manifest.js';
|
|
7
|
+
import { imageGenerationPathExists } from './image-generation-fs.js';
|
|
8
|
+
import { classifyImageGenerationResume, resumeStateSummary, } from './image-generation-resume.js';
|
|
6
9
|
import { dispatchImageGeneration, failImageGenerationBeforeDispatch, markImageGenerationDispatched, reserveImageGeneration, } from './image-generation-run.js';
|
|
7
|
-
import {
|
|
8
|
-
import { summarizeImageGenerationUsage
|
|
9
|
-
import { preflightImageProvider
|
|
10
|
-
const writeBatchAttempt = async (file, attempt, exclusive = false) => {
|
|
11
|
-
await mkdir(path.dirname(file), { recursive: true });
|
|
12
|
-
if (exclusive) {
|
|
13
|
-
await writeFile(file, `${JSON.stringify(attempt, null, 2)}\n`, {
|
|
14
|
-
encoding: 'utf8',
|
|
15
|
-
flag: 'wx',
|
|
16
|
-
mode: 0o600,
|
|
17
|
-
});
|
|
18
|
-
return;
|
|
19
|
-
}
|
|
20
|
-
const temporary = `${file}.${randomUUID()}.tmp`;
|
|
21
|
-
try {
|
|
22
|
-
await writeFile(temporary, `${JSON.stringify(attempt, null, 2)}\n`, {
|
|
23
|
-
encoding: 'utf8',
|
|
24
|
-
flag: 'wx',
|
|
25
|
-
mode: 0o600,
|
|
26
|
-
});
|
|
27
|
-
await rename(temporary, file);
|
|
28
|
-
}
|
|
29
|
-
finally {
|
|
30
|
-
await rm(temporary, { force: true });
|
|
31
|
-
}
|
|
32
|
-
};
|
|
10
|
+
import { imageGenerationSha256, prepareImageGenerationRequest, } from './image-generation-request.js';
|
|
11
|
+
import { summarizeImageGenerationUsage } from './image-generation-usage.js';
|
|
12
|
+
import { preflightImageProvider } from './image-provider-preflight.js';
|
|
33
13
|
const errorMessage = (error) => (error instanceof Error ? error.message : String(error));
|
|
34
14
|
const failReserved = async (reserved, message) => {
|
|
35
15
|
await Promise.allSettled(reserved.map((item) => failImageGenerationBeforeDispatch(item, message)));
|
|
36
16
|
};
|
|
17
|
+
const identities = (requests) => requests.map((request) => ({
|
|
18
|
+
...(request.candidateId ? { candidateId: request.candidateId } : {}),
|
|
19
|
+
outputPath: request.outputPath,
|
|
20
|
+
idempotencyKey: request.idempotencyKey,
|
|
21
|
+
}));
|
|
22
|
+
/**
|
|
23
|
+
* Explain what the existing evidence permits instead of stopping at "evidence
|
|
24
|
+
* exists". A refusal that names no recovery is what turned a finished batch
|
|
25
|
+
* into a dead end for eleven benchmark runs.
|
|
26
|
+
*/
|
|
27
|
+
const existingEvidenceRefusal = async (args) => {
|
|
28
|
+
const states = await Promise.all(args.requests.map((request) => classifyImageGenerationResume({
|
|
29
|
+
outputPath: request.outputPath,
|
|
30
|
+
...(request.candidateId ? { candidateId: request.candidateId } : {}),
|
|
31
|
+
})));
|
|
32
|
+
const summary = resumeStateSummary(states);
|
|
33
|
+
const recoverable = summary.stageable + summary.redispatchable;
|
|
34
|
+
const guidance = recoverable > 0
|
|
35
|
+
? `Re-run the same command with --resume to recover ${recoverable} candidate(s) with no new`
|
|
36
|
+
+ ' spend; it never re-buys a candidate.'
|
|
37
|
+
: summary.unrecoverable > 0
|
|
38
|
+
? 'Nothing can be recovered without new spend; give the affected candidates a new output'
|
|
39
|
+
+ ' path and idempotency key if you accept buying them again.'
|
|
40
|
+
: 'Every candidate is already on disk — read them rather than generating again.';
|
|
41
|
+
return `Image batch attempt evidence already exists at ${args.batchAttemptFile}.`
|
|
42
|
+
+ ` ${describeBatchRecovery(states)}. ${guidance}`;
|
|
43
|
+
};
|
|
37
44
|
export const runImageBatchCommand = async (flags, dependencies = {}) => {
|
|
38
45
|
const manifestFlag = stringFlag(flags, 'manifest')?.trim();
|
|
39
46
|
if (!manifestFlag) {
|
|
40
|
-
throw new Error('Usage: 12ui image generate-batch --manifest <batch.json>');
|
|
47
|
+
throw new Error('Usage: 12ui image generate-batch --manifest <batch.json> [--resume]');
|
|
41
48
|
}
|
|
42
49
|
const manifestPath = path.resolve(manifestFlag);
|
|
43
|
-
const batchAttemptFile =
|
|
44
|
-
|
|
45
|
-
throw new Error(`Image batch attempt evidence already exists at ${batchAttemptFile}`);
|
|
46
|
-
}
|
|
50
|
+
const batchAttemptFile = imageBatchAttemptPath(manifestPath);
|
|
51
|
+
const resumeRequested = booleanFlag(flags, 'resume');
|
|
47
52
|
const { manifest, source } = await readImageGenerationBatchManifest(manifestPath);
|
|
48
53
|
const requests = resolveImageGenerationBatchRequests({ manifest, manifestPath });
|
|
49
|
-
const
|
|
54
|
+
const manifestSha256 = imageGenerationSha256(source);
|
|
55
|
+
const existingBatchAttempt = await readBatchAttempt(batchAttemptFile);
|
|
56
|
+
if (await imageGenerationPathExists(batchAttemptFile)) {
|
|
57
|
+
if (!resumeRequested) {
|
|
58
|
+
throw new Error(await existingEvidenceRefusal({ batchAttemptFile, requests }));
|
|
59
|
+
}
|
|
60
|
+
if (!existingBatchAttempt) {
|
|
61
|
+
throw new Error(`Image batch attempt evidence at ${batchAttemptFile} is unreadable, so no candidate can be`
|
|
62
|
+
+ ' proved unbilled. Inspect it before resuming.');
|
|
63
|
+
}
|
|
64
|
+
if (existingBatchAttempt.manifestSha256 !== manifestSha256) {
|
|
65
|
+
throw new Error(`Refusing to resume: ${manifestPath} has changed since the batch was dispatched`
|
|
66
|
+
+ ` (${existingBatchAttempt.manifestSha256} then, ${manifestSha256} now). A resume must`
|
|
67
|
+
+ ' replay the same candidate identities.');
|
|
68
|
+
}
|
|
69
|
+
await resumeImageBatchCommand({
|
|
70
|
+
manifestPath,
|
|
71
|
+
manifestSha256,
|
|
72
|
+
batchAttemptFile,
|
|
73
|
+
batchAttempt: existingBatchAttempt,
|
|
74
|
+
requests,
|
|
75
|
+
dependencies,
|
|
76
|
+
});
|
|
77
|
+
return;
|
|
78
|
+
}
|
|
79
|
+
const prepared = await Promise.all(requests.map((request) => (prepareImageGenerationRequest(request))));
|
|
50
80
|
const preflight = await (dependencies.preflight ?? preflightImageProvider)({
|
|
51
81
|
provider: manifest.provider,
|
|
52
82
|
projectRoot: prepared[0].projectRoot,
|
|
53
83
|
});
|
|
54
|
-
const manifestSha256 = imageGenerationSha256(source);
|
|
55
84
|
const attempt = {
|
|
56
85
|
version: 2,
|
|
57
86
|
status: 'prepared',
|
|
@@ -67,6 +96,28 @@ export const runImageBatchCommand = async (flags, dependencies = {}) => {
|
|
|
67
96
|
preparedAt: new Date().toISOString(),
|
|
68
97
|
};
|
|
69
98
|
await writeBatchAttempt(batchAttemptFile, attempt, true);
|
|
99
|
+
const candidates = identities(prepared);
|
|
100
|
+
const terminate = async (args) => {
|
|
101
|
+
if (args.materialize)
|
|
102
|
+
await materializeImageBatch(candidates);
|
|
103
|
+
const { completionPath } = await publishImageBatchCompletion({
|
|
104
|
+
manifestPath,
|
|
105
|
+
manifestSha256,
|
|
106
|
+
batchAttemptFile,
|
|
107
|
+
provider: attempt.provider,
|
|
108
|
+
model: attempt.model,
|
|
109
|
+
resumed: false,
|
|
110
|
+
status: args.status,
|
|
111
|
+
candidates,
|
|
112
|
+
});
|
|
113
|
+
attempt.status = args.status;
|
|
114
|
+
attempt.completedAt = new Date().toISOString();
|
|
115
|
+
attempt.completionPath = completionPath;
|
|
116
|
+
if (args.errors)
|
|
117
|
+
attempt.errors = args.errors;
|
|
118
|
+
await writeBatchAttempt(batchAttemptFile, attempt);
|
|
119
|
+
return completionPath;
|
|
120
|
+
};
|
|
70
121
|
const reservations = await Promise.allSettled(prepared.map((request) => (reserveImageGeneration({
|
|
71
122
|
request,
|
|
72
123
|
preflight,
|
|
@@ -81,11 +132,12 @@ export const runImageBatchCommand = async (flags, dependencies = {}) => {
|
|
|
81
132
|
if (reservationErrors.length > 0) {
|
|
82
133
|
const message = 'Batch reservation failed before any provider request was started';
|
|
83
134
|
await failReserved(reserved, message);
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
135
|
+
const completionPath = await terminate({
|
|
136
|
+
status: 'failed',
|
|
137
|
+
errors: reservationErrors,
|
|
138
|
+
materialize: false,
|
|
139
|
+
});
|
|
140
|
+
throw new AggregateError(reservationErrors, `${message}. Evidence: ${batchAttemptFile}. Completion sentinel: ${completionPath}`);
|
|
89
141
|
}
|
|
90
142
|
attempt.status = 'dispatched';
|
|
91
143
|
attempt.dispatchedAt = new Date().toISOString();
|
|
@@ -95,32 +147,31 @@ export const runImageBatchCommand = async (flags, dependencies = {}) => {
|
|
|
95
147
|
if (markErrors.length > 0) {
|
|
96
148
|
const message = 'Batch evidence preparation failed before any provider request was started';
|
|
97
149
|
await failReserved(reserved, message);
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
150
|
+
const completionPath = await terminate({
|
|
151
|
+
status: 'failed',
|
|
152
|
+
errors: markErrors,
|
|
153
|
+
materialize: false,
|
|
154
|
+
});
|
|
155
|
+
throw new AggregateError(markErrors, `${message}. Evidence: ${batchAttemptFile}. Completion sentinel: ${completionPath}`);
|
|
103
156
|
}
|
|
104
157
|
const settled = await Promise.allSettled(reserved.map((item) => (dispatchImageGeneration(item, { generate: dependencies.generate }))));
|
|
105
158
|
const results = settled.flatMap((result) => (result.status === 'fulfilled' ? [result.value] : []));
|
|
106
159
|
const errors = settled.flatMap((result) => (result.status === 'rejected' ? [errorMessage(result.reason)] : []));
|
|
107
|
-
attempt.completedAt = new Date().toISOString();
|
|
108
160
|
attempt.results = results;
|
|
109
161
|
attempt.accounting = summarizeImageGenerationUsage(reserved.map((item) => item.attempt.usage), preflight.provider);
|
|
110
162
|
if (errors.length > 0) {
|
|
111
|
-
|
|
112
|
-
attempt.errors = errors;
|
|
113
|
-
await writeBatchAttempt(batchAttemptFile, attempt);
|
|
163
|
+
const completionPath = await terminate({ status: 'failed', errors, materialize: true });
|
|
114
164
|
throw new AggregateError(errors, `Image batch finished with ${errors.length} failed candidate(s); no retries or provider`
|
|
115
|
-
+ ` fallback were attempted. Evidence: ${batchAttemptFile}
|
|
165
|
+
+ ` fallback were attempted. Evidence: ${batchAttemptFile}.`
|
|
166
|
+
+ ` Completion sentinel: ${completionPath}`);
|
|
116
167
|
}
|
|
117
|
-
|
|
118
|
-
await writeBatchAttempt(batchAttemptFile, attempt);
|
|
168
|
+
const completionPath = await terminate({ status: 'succeeded', materialize: true });
|
|
119
169
|
console.log(JSON.stringify({
|
|
120
170
|
provider: attempt.provider,
|
|
121
171
|
model: attempt.model,
|
|
122
172
|
manifestPath,
|
|
123
173
|
batchAttemptFile,
|
|
174
|
+
completionPath,
|
|
124
175
|
accounting: attempt.accounting,
|
|
125
176
|
candidates: results,
|
|
126
177
|
}, null, 2));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli-image-batch-command.js","sourceRoot":"","sources":["../src/cli-image-batch-command.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"cli-image-batch-command.js","sourceRoot":"","sources":["../src/cli-image-batch-command.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,WAAW,CAAC;AAI7B,OA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AAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,WAAW,EAAE,IAAI,EAAE,CAAC,CAAC;QACxF,MAAM,IAAI,cAAc,CACtB,MAAM,EACN,6BAA6B,MAAM,CAAC,MAAM,8CAA8C;cACtF,uCAAuC,gBAAgB,GAAG;cAC1D,yBAAyB,cAAc,EAAE,CAC5C,CAAC;IACJ,CAAC;IACD,MAAM,cAAc,GAAG,MAAM,SAAS,CAAC,EAAE,MAAM,EAAE,WAAW,EAAE,WAAW,EAAE,IAAI,EAAE,CAAC,CAAC;IACnF,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,SAAS,CAAC;QACzB,QAAQ,EAAE,OAAO,CAAC,QAAQ;QAC1B,KAAK,EAAE,OAAO,CAAC,KAAK;QACpB,YAAY;QACZ,gBAAgB;QAChB,cAAc;QACd,UAAU,EAAE,OAAO,CAAC,UAAU;QAC9B,UAAU,EAAE,OAAO;KACpB,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC;AACf,CAAC,CAAC"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { type ImageBatchCompletion } from './image-generation-completion.js';
|
|
2
|
+
export type ImageBatchCandidateIdentity = {
|
|
3
|
+
candidateId?: string;
|
|
4
|
+
outputPath: string;
|
|
5
|
+
idempotencyKey: string;
|
|
6
|
+
};
|
|
7
|
+
/**
|
|
8
|
+
* Move every candidate the provider settled — succeeded or failed — out of the
|
|
9
|
+
* hidden staging directory in one pass. Nothing is delivered mid-flight, so the
|
|
10
|
+
* candidates directory goes from empty to complete rather than through a
|
|
11
|
+
* half-written state that reads as failure.
|
|
12
|
+
*/
|
|
13
|
+
export declare const materializeImageBatch: (candidates: readonly ImageBatchCandidateIdentity[]) => Promise<void>;
|
|
14
|
+
export declare const publishImageBatchCompletion: (args: {
|
|
15
|
+
manifestPath: string;
|
|
16
|
+
manifestSha256: string;
|
|
17
|
+
batchAttemptFile: string;
|
|
18
|
+
provider: string;
|
|
19
|
+
model: string;
|
|
20
|
+
resumed: boolean;
|
|
21
|
+
status: "succeeded" | "failed";
|
|
22
|
+
candidates: readonly ImageBatchCandidateIdentity[];
|
|
23
|
+
}) => Promise<{
|
|
24
|
+
completionPath: string;
|
|
25
|
+
completion: ImageBatchCompletion;
|
|
26
|
+
}>;
|
|
27
|
+
//# sourceMappingURL=cli-image-batch-materialize.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cli-image-batch-materialize.d.ts","sourceRoot":"","sources":["../src/cli-image-batch-materialize.ts"],"names":[],"mappings":"AAAA,OAAO,EAIL,KAAK,oBAAoB,EAC1B,MAAM,kCAAkC,CAAC;AAG1C,MAAM,MAAM,2BAA2B,GAAG;IACxC,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,UAAU,EAAE,MAAM,CAAC;IACnB,cAAc,EAAE,MAAM,CAAC;CACxB,CAAC;AAMF;;;;;GAKG;AACH,eAAO,MAAM,qBAAqB,GAChC,YAAY,SAAS,2BAA2B,EAAE,KACjD,OAAO,CAAC,IAAI,CAId,CAAC;AAEF,eAAO,MAAM,2BAA2B,GAAU,MAAM;IACtD,YAAY,EAAE,MAAM,CAAC;IACrB,cAAc,EAAE,MAAM,CAAC;IACvB,gBAAgB,EAAE,MAAM,CAAC;IACzB,QAAQ,EAAE,MAAM,CAAC;IACjB,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,OAAO,CAAC;IACjB,MAAM,EAAE,WAAW,GAAG,QAAQ,CAAC;IAC/B,UAAU,EAAE,SAAS,2BAA2B,EAAE,CAAC;CACpD,KAAG,OAAO,CAAC;IAAE,cAAc,EAAE,MAAM,CAAC;IAAC,UAAU,EAAE,oBAAoB,CAAA;CAAE,CA2BvE,CAAC"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { imageBatchCompletionPath, summarizeImageBatchCandidates, writeImageBatchCompletion, } from './image-generation-completion.js';
|
|
2
|
+
import { materializeImageGeneration } from './image-generation-staging.js';
|
|
3
|
+
const identityId = (candidate, index) => (candidate.candidateId ?? String(index + 1));
|
|
4
|
+
/**
|
|
5
|
+
* Move every candidate the provider settled — succeeded or failed — out of the
|
|
6
|
+
* hidden staging directory in one pass. Nothing is delivered mid-flight, so the
|
|
7
|
+
* candidates directory goes from empty to complete rather than through a
|
|
8
|
+
* half-written state that reads as failure.
|
|
9
|
+
*/
|
|
10
|
+
export const materializeImageBatch = async (candidates) => {
|
|
11
|
+
await Promise.all(candidates.map((candidate) => (materializeImageGeneration(candidate.outputPath))));
|
|
12
|
+
};
|
|
13
|
+
export const publishImageBatchCompletion = async (args) => {
|
|
14
|
+
const completionPath = imageBatchCompletionPath({
|
|
15
|
+
manifestPath: args.manifestPath,
|
|
16
|
+
outputPaths: args.candidates.map((candidate) => candidate.outputPath),
|
|
17
|
+
});
|
|
18
|
+
const candidates = await summarizeImageBatchCandidates(args.candidates.map((candidate, index) => ({
|
|
19
|
+
id: identityId(candidate, index),
|
|
20
|
+
outputPath: candidate.outputPath,
|
|
21
|
+
idempotencyKey: candidate.idempotencyKey,
|
|
22
|
+
})));
|
|
23
|
+
const completion = {
|
|
24
|
+
version: 1,
|
|
25
|
+
status: args.status,
|
|
26
|
+
manifestPath: args.manifestPath,
|
|
27
|
+
manifestSha256: args.manifestSha256,
|
|
28
|
+
batchAttemptFile: args.batchAttemptFile,
|
|
29
|
+
provider: args.provider,
|
|
30
|
+
model: args.model,
|
|
31
|
+
resumed: args.resumed,
|
|
32
|
+
completedAt: new Date().toISOString(),
|
|
33
|
+
candidateCount: candidates.length,
|
|
34
|
+
succeededCount: candidates.filter((candidate) => candidate.status === 'succeeded').length,
|
|
35
|
+
failedCount: candidates.filter((candidate) => candidate.status !== 'succeeded').length,
|
|
36
|
+
candidates,
|
|
37
|
+
};
|
|
38
|
+
await writeImageBatchCompletion(completionPath, completion);
|
|
39
|
+
return { completionPath, completion };
|
|
40
|
+
};
|
|
41
|
+
//# sourceMappingURL=cli-image-batch-materialize.js.map
|
|
@@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GAAyB;QACvC,OAAO,EAAE,CAAC;QACV,MAAM,EAAE,IAAI,CAAC,MAAM;QACnB,YAAY,EAAE,IAAI,CAAC,YAAY;QAC/B,cAAc,EAAE,IAAI,CAAC,cAAc;QACnC,gBAAgB,EAAE,IAAI,CAAC,gBAAgB;QACvC,QAAQ,EAAE,IAAI,CAAC,QAAQ;QACvB,KAAK,EAAE,IAAI,CAAC,KAAK;QACjB,OAAO,EAAE,IAAI,CAAC,OAAO;QACrB,WAAW,EAAE,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE;QACrC,cAAc,EAAE,UAAU,CAAC,MAAM;QACjC,cAAc,EAAE,UAAU,CAAC,MAAM,CAAC,CAAC,SAAS,EAAE,EAAE,CAAC,SAAS,CAAC,MAAM,KAAK,WAAW,CAAC,CAAC,MAAM;QACzF,WAAW,EAAE,UAAU,CAAC,MAAM,CAAC,CAAC,SAAS,EAAE,EAAE,CAAC,SAAS,CAAC,MAAM,KAAK,WAAW,CAAC,CAAC,MAAM;QACtF,UAAU;KACX,CAAC;IACF,MAAM,yBAAyB,CAAC,cAAc,EAAE,UAAU,CAAC,CAAC;IAC5D,OAAO,EAAE,cAAc,EAAE,UAAU,EAAE,CAAC;AACxC,CAAC,CAAC"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { ensembleImage } from '@just-every/ensemble';
|
|
2
|
+
import { type ImageBatchAttempt } from './image-generation-batch-attempt.js';
|
|
3
|
+
import type { ImageGenerationRequest } from './image-generation-request.js';
|
|
4
|
+
import { type ImageGenerationResumeState } from './image-generation-resume.js';
|
|
5
|
+
import { preflightImageProvider } from './image-provider-preflight.js';
|
|
6
|
+
export declare const describeBatchRecovery: (states: readonly ImageGenerationResumeState[]) => string;
|
|
7
|
+
/**
|
|
8
|
+
* Recover a batch whose candidates were dispatched but never delivered.
|
|
9
|
+
*
|
|
10
|
+
* Every candidate is classified from its own durable ledger entry first. Work
|
|
11
|
+
* that was already bought is delivered from staging; work that provably was not
|
|
12
|
+
* bought, or that the provider will return again for free under the recorded
|
|
13
|
+
* idempotency key, is re-requested under that same identity. Anything else is
|
|
14
|
+
* refused rather than bought a second time.
|
|
15
|
+
*/
|
|
16
|
+
export declare const resumeImageBatchCommand: (args: {
|
|
17
|
+
manifestPath: string;
|
|
18
|
+
manifestSha256: string;
|
|
19
|
+
batchAttemptFile: string;
|
|
20
|
+
batchAttempt: ImageBatchAttempt;
|
|
21
|
+
requests: ImageGenerationRequest[];
|
|
22
|
+
dependencies: {
|
|
23
|
+
generate?: typeof ensembleImage;
|
|
24
|
+
preflight?: typeof preflightImageProvider;
|
|
25
|
+
};
|
|
26
|
+
}) => Promise<void>;
|
|
27
|
+
//# sourceMappingURL=cli-image-batch-resume.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cli-image-batch-resume.d.ts","sourceRoot":"","sources":["../src/cli-image-batch-resume.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAOrD,OAAO,EAEL,KAAK,iBAAiB,EACvB,MAAM,qCAAqC,CAAC;AAC7C,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,+BAA+B,CAAC;AAE5E,OAAO,EAIL,KAAK,0BAA0B,EAChC,MAAM,8BAA8B,CAAC;AAStC,OAAO,EAAE,sBAAsB,EAAE,MAAM,+BAA+B,CAAC;AAcvE,eAAO,MAAM,qBAAqB,GAChC,QAAQ,SAAS,0BAA0B,EAAE,KAC5C,MASF,CAAC;AAEF;;;;;;;;GAQG;AACH,eAAO,MAAM,uBAAuB,GAAU,MAAM;IAClD,YAAY,EAAE,MAAM,CAAC;IACrB,cAAc,EAAE,MAAM,CAAC;IACvB,gBAAgB,EAAE,MAAM,CAAC;IACzB,YAAY,EAAE,iBAAiB,CAAC;IAChC,QAAQ,EAAE,sBAAsB,EAAE,CAAC;IACnC,YAAY,EAAE;QACZ,QAAQ,CAAC,EAAE,OAAO,aAAa,CAAC;QAChC,SAAS,CAAC,EAAE,OAAO,sBAAsB,CAAC;KAC3C,CAAC;CACH,KAAG,OAAO,CAAC,IAAI,CA8If,CAAC"}
|