@12ui/design 0.2.5 → 0.2.7
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 +12 -17
- package/dist/cli-corpus-reference-downloads.d.ts.map +1 -1
- package/dist/cli-corpus-reference-downloads.js +4 -0
- package/dist/cli-corpus-reference-downloads.js.map +1 -1
- package/dist/cli-corpus-types.d.ts +4 -0
- package/dist/cli-corpus-types.d.ts.map +1 -1
- package/dist/cli-image-batch-command.d.ts +8 -0
- package/dist/cli-image-batch-command.d.ts.map +1 -0
- package/dist/cli-image-batch-command.js +127 -0
- package/dist/cli-image-batch-command.js.map +1 -0
- package/dist/cli-image-command.d.ts.map +1 -1
- package/dist/cli-image-command.js +17 -111
- package/dist/cli-image-command.js.map +1 -1
- package/dist/cli-persistence.d.ts +3 -0
- package/dist/cli-persistence.d.ts.map +1 -1
- package/dist/cli-persistence.js +66 -3
- package/dist/cli-persistence.js.map +1 -1
- package/dist/cli-skill-command.d.ts.map +1 -1
- package/dist/cli-skill-command.js +5 -0
- package/dist/cli-skill-command.js.map +1 -1
- package/dist/cli.js +6 -1
- package/dist/cli.js.map +1 -1
- package/dist/client-auth-guidance.d.ts +3 -0
- package/dist/client-auth-guidance.d.ts.map +1 -0
- package/dist/client-auth-guidance.js +14 -0
- package/dist/client-auth-guidance.js.map +1 -0
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +2 -1
- package/dist/config.js.map +1 -1
- package/dist/conversion-client.d.ts.map +1 -1
- package/dist/conversion-client.js +2 -1
- package/dist/conversion-client.js.map +1 -1
- package/dist/corpus-client.d.ts.map +1 -1
- package/dist/corpus-client.js +2 -1
- package/dist/corpus-client.js.map +1 -1
- package/dist/image-generation-batch-manifest.d.ts +24 -0
- package/dist/image-generation-batch-manifest.d.ts.map +1 -0
- package/dist/image-generation-batch-manifest.js +91 -0
- package/dist/image-generation-batch-manifest.js.map +1 -0
- package/dist/image-generation-evidence.d.ts +9 -1
- package/dist/image-generation-evidence.d.ts.map +1 -1
- package/dist/image-generation-evidence.js.map +1 -1
- package/dist/image-generation-request.d.ts +29 -0
- package/dist/image-generation-request.d.ts.map +1 -0
- package/dist/image-generation-request.js +46 -0
- package/dist/image-generation-request.js.map +1 -0
- package/dist/image-generation-run.d.ts +35 -0
- package/dist/image-generation-run.d.ts.map +1 -0
- package/dist/image-generation-run.js +134 -0
- package/dist/image-generation-run.js.map +1 -0
- package/dist/image-generation-usage.d.ts +71 -0
- package/dist/image-generation-usage.d.ts.map +1 -0
- package/dist/image-generation-usage.js +192 -0
- package/dist/image-generation-usage.js.map +1 -0
- package/dist/legacy-cli-cleanup.d.ts +1 -0
- package/dist/legacy-cli-cleanup.d.ts.map +1 -1
- package/dist/legacy-cli-cleanup.js +12 -0
- package/dist/legacy-cli-cleanup.js.map +1 -1
- package/dist/legacy-npm-global-cli-cleanup.d.ts +16 -0
- package/dist/legacy-npm-global-cli-cleanup.d.ts.map +1 -0
- package/dist/legacy-npm-global-cli-cleanup.js +102 -0
- package/dist/legacy-npm-global-cli-cleanup.js.map +1 -0
- package/dist/legacy-npm-global-cli-recognition.d.ts +12 -0
- package/dist/legacy-npm-global-cli-recognition.d.ts.map +1 -0
- package/dist/legacy-npm-global-cli-recognition.js +105 -0
- package/dist/legacy-npm-global-cli-recognition.js.map +1 -0
- package/dist/legacy-skill-catalog.d.ts.map +1 -1
- package/dist/legacy-skill-catalog.js +23 -2
- package/dist/legacy-skill-catalog.js.map +1 -1
- package/package.json +1 -1
- package/skills/design/SKILL.md +108 -205
- package/skills/design/references/selection-contract.md +43 -75
- package/skills/design-convert/SKILL.md +47 -97
- package/skills/design-search/SKILL.md +26 -60
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import { readFile } from 'node:fs/promises';
|
|
2
|
+
import path from 'node:path';
|
|
3
|
+
import { isImageGenerationAspect, } from './image-generation-request.js';
|
|
4
|
+
import { isImageGenerationProvider, } from './image-provider-preflight.js';
|
|
5
|
+
import { normalizeOptionalIdempotencyKey } from './idempotency-key.js';
|
|
6
|
+
const isRecord = (value) => (typeof value === 'object' && value !== null && !Array.isArray(value));
|
|
7
|
+
const requiredString = (record, key, context) => {
|
|
8
|
+
const value = record[key];
|
|
9
|
+
if (typeof value !== 'string' || !value.trim()) {
|
|
10
|
+
throw new Error(`${context}.${key} must be a non-empty string`);
|
|
11
|
+
}
|
|
12
|
+
return value.trim();
|
|
13
|
+
};
|
|
14
|
+
const unique = (values, name) => {
|
|
15
|
+
if (new Set(values).size !== values.length) {
|
|
16
|
+
throw new Error(`Image batch candidates must use unique ${name}`);
|
|
17
|
+
}
|
|
18
|
+
};
|
|
19
|
+
export const readImageGenerationBatchManifest = async (manifestPath) => {
|
|
20
|
+
const source = new Uint8Array(await readFile(manifestPath));
|
|
21
|
+
let value;
|
|
22
|
+
try {
|
|
23
|
+
value = JSON.parse(new TextDecoder().decode(source));
|
|
24
|
+
}
|
|
25
|
+
catch (error) {
|
|
26
|
+
throw new Error(`Image batch manifest is not valid JSON: ${manifestPath}`, { cause: error });
|
|
27
|
+
}
|
|
28
|
+
if (!isRecord(value) || value.version !== 1) {
|
|
29
|
+
throw new Error('Image batch manifest.version must be 1');
|
|
30
|
+
}
|
|
31
|
+
const provider = value.provider ?? 'auto';
|
|
32
|
+
if (!isImageGenerationProvider(provider)) {
|
|
33
|
+
throw new Error('Image batch manifest.provider must be auto, codex, or openai');
|
|
34
|
+
}
|
|
35
|
+
const aspect = value.aspect ?? 'landscape';
|
|
36
|
+
if (!isImageGenerationAspect(aspect)) {
|
|
37
|
+
throw new Error('Image batch manifest.aspect must be landscape, portrait, or square');
|
|
38
|
+
}
|
|
39
|
+
if (!Array.isArray(value.candidates) || value.candidates.length < 2 || value.candidates.length > 16) {
|
|
40
|
+
throw new Error('Image batch manifest.candidates must contain between 2 and 16 jobs');
|
|
41
|
+
}
|
|
42
|
+
const candidates = value.candidates.map((candidate, index) => {
|
|
43
|
+
const context = `Image batch manifest.candidates[${index}]`;
|
|
44
|
+
if (!isRecord(candidate))
|
|
45
|
+
throw new Error(`${context} must be an object`);
|
|
46
|
+
const id = requiredString(candidate, 'id', context);
|
|
47
|
+
if (!/^[A-Za-z0-9][A-Za-z0-9._-]{0,63}$/u.test(id)) {
|
|
48
|
+
throw new Error(`${context}.id contains unsupported characters`);
|
|
49
|
+
}
|
|
50
|
+
const idempotencyKey = normalizeOptionalIdempotencyKey(requiredString(candidate, 'idempotencyKey', context), `${context}.idempotencyKey`);
|
|
51
|
+
if (!idempotencyKey)
|
|
52
|
+
throw new Error(`${context}.idempotencyKey is required`);
|
|
53
|
+
return {
|
|
54
|
+
id,
|
|
55
|
+
prompt: requiredString(candidate, 'prompt', context),
|
|
56
|
+
reference: requiredString(candidate, 'reference', context),
|
|
57
|
+
out: requiredString(candidate, 'out', context),
|
|
58
|
+
idempotencyKey,
|
|
59
|
+
};
|
|
60
|
+
});
|
|
61
|
+
unique(candidates.map((candidate) => candidate.id), 'ids');
|
|
62
|
+
unique(candidates.map((candidate) => candidate.idempotencyKey), 'idempotency keys');
|
|
63
|
+
return {
|
|
64
|
+
source,
|
|
65
|
+
manifest: {
|
|
66
|
+
version: 1,
|
|
67
|
+
projectRoot: requiredString(value, 'projectRoot', 'Image batch manifest'),
|
|
68
|
+
provider,
|
|
69
|
+
aspect,
|
|
70
|
+
candidates,
|
|
71
|
+
},
|
|
72
|
+
};
|
|
73
|
+
};
|
|
74
|
+
export const resolveImageGenerationBatchRequests = (args) => {
|
|
75
|
+
const base = path.dirname(args.manifestPath);
|
|
76
|
+
const resolve = (value) => path.resolve(base, value);
|
|
77
|
+
const requests = args.manifest.candidates.map((candidate) => ({
|
|
78
|
+
candidateId: candidate.id,
|
|
79
|
+
prompt: candidate.prompt,
|
|
80
|
+
promptSource: { kind: 'inline' },
|
|
81
|
+
referencePath: resolve(candidate.reference),
|
|
82
|
+
outputPath: resolve(candidate.out),
|
|
83
|
+
projectRoot: resolve(args.manifest.projectRoot),
|
|
84
|
+
provider: args.manifest.provider,
|
|
85
|
+
aspect: args.manifest.aspect,
|
|
86
|
+
idempotencyKey: candidate.idempotencyKey,
|
|
87
|
+
}));
|
|
88
|
+
unique(requests.map((request) => request.outputPath), 'output paths');
|
|
89
|
+
return requests;
|
|
90
|
+
};
|
|
91
|
+
//# sourceMappingURL=image-generation-batch-manifest.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"image-generation-batch-manifest.js","sourceRoot":"","sources":["../src/image-generation-batch-manifest.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5C,OAAO,IAAI,MAAM,WAAW,CAAC;AAE7B,OAAO,EACL,uBAAuB,GAGxB,MAAM,+BAA+B,CAAC;AACvC,OAAO,EACL,yBAAyB,GAE1B,MAAM,+BAA+B,CAAC;AACvC,OAAO,EAAE,+BAA+B,EAAE,MAAM,sBAAsB,CAAC;AAgBvE,MAAM,QAAQ,GAAG,CAAC,KAAc,EAAoC,EAAE,CAAC,CACrE,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CACrE,CAAC;AAEF,MAAM,cAAc,GAAG,CAAC,MAA+B,EAAE,GAAW,EAAE,OAAe,EAAU,EAAE;IAC/F,MAAM,KAAK,GAAG,MAAM,CAAC,GAAG,CAAC,CAAC;IAC1B,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,CAAC,KAAK,CAAC,IAAI,EAAE,EAAE,CAAC;QAC/C,MAAM,IAAI,KAAK,CAAC,GAAG,OAAO,IAAI,GAAG,6BAA6B,CAAC,CAAC;IAClE,CAAC;IACD,OAAO,KAAK,CAAC,IAAI,EAAE,CAAC;AACtB,CAAC,CAAC;AAEF,MAAM,MAAM,GAAG,CAAC,MAAgB,EAAE,IAAY,EAAQ,EAAE;IACtD,IAAI,IAAI,GAAG,CAAC,MAAM,CAAC,CAAC,IAAI,KAAK,M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AQ,CAAC;AAClB,CAAC,CAAC"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
+
import type { ImageGenerationUsageEvidence } from './image-generation-usage.js';
|
|
1
2
|
export type ImageGenerationAttempt = {
|
|
2
|
-
schemaVersion:
|
|
3
|
+
schemaVersion: 3;
|
|
3
4
|
status: 'prepared' | 'dispatched' | 'succeeded' | 'failed';
|
|
4
5
|
idempotencyKey: string;
|
|
5
6
|
provider: 'codex' | 'openai';
|
|
@@ -23,9 +24,16 @@ export type ImageGenerationAttempt = {
|
|
|
23
24
|
};
|
|
24
25
|
outputPath: string;
|
|
25
26
|
preparedAt: string;
|
|
27
|
+
batch?: {
|
|
28
|
+
candidateId: string;
|
|
29
|
+
manifestPath: string;
|
|
30
|
+
manifestSha256: string;
|
|
31
|
+
};
|
|
26
32
|
dispatchedAt?: string;
|
|
33
|
+
providerStartedAt?: string;
|
|
27
34
|
completedAt?: string;
|
|
28
35
|
outputSha256?: string;
|
|
36
|
+
usage?: ImageGenerationUsageEvidence;
|
|
29
37
|
error?: string;
|
|
30
38
|
};
|
|
31
39
|
export declare const imageAttemptPath: (outputPath: string) => string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"image-generation-evidence.d.ts","sourceRoot":"","sources":["../src/image-generation-evidence.ts"],"names":[],"mappings":"AAIA,MAAM,MAAM,sBAAsB,GAAG;IACnC,aAAa,EAAE,CAAC,CAAC;IACjB,MAAM,EAAE,UAAU,GAAG,YAAY,GAAG,WAAW,GAAG,QAAQ,CAAC;IAC3D,cAAc,EAAE,MAAM,CAAC;IACvB,QAAQ,EAAE,OAAO,GAAG,QAAQ,CAAC;IAC7B,KAAK,EAAE,mBAAmB,GAAG,aAAa,CAAC;IAC3C,2BAA2B,EAAE,OAAO,CAAC;IACrC,gBAAgB,EAAE;QAChB,YAAY,CAAC,EAAE,MAAM,CAAC;QACtB,SAAS,CAAC,EAAE,SAAS,GAAG,aAAa,CAAC;KACvC,CAAC;IACF,MAAM,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AM,EAAE,MAAM,CAAC;IACf,YAAY,EAAE;QAAE,IAAI,EAAE,QAAQ,CAAA;KAAE,GAAG;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,CAAC;IAClE,YAAY,EAAE,MAAM,CAAC;IACrB,SAAS,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE,CAAC;IAC5C,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,EAAE,MAAM,CAAC;IACnB,KAAK,CAAC,EAAE;QACN,WAAW,EAAE,MAAM,CAAC;QACpB,YAAY,EAAE,MAAM,CAAC;QACrB,cAAc,EAAE,MAAM,CAAC;KACxB,CAAC;IACF,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,KAAK,CAAC,EAAE,4BAA4B,CAAC;IACrC,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB,CAAC;AAEF,eAAO,MAAM,gBAAgB,GAAI,YAAY,MAAM,KAAG,MAAsC,CAAC;AAE7F,eAAO,MAAM,2BAA2B,GACtC,UAAU,MAAM,EAChB,SAAS,sBAAsB,EAC/B,mBAAiB,KAChB,OAAO,CAAC,IAAI,CAqBd,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"image-generation-evidence.js","sourceRoot":"","sources":["../src/image-generation-evidence.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,EAAE,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAChE,OAAO,IAAI,MAAM,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"image-generation-evidence.js","sourceRoot":"","sources":["../src/image-generation-evidence.ts"],"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
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import type { ImageGenerationAttempt } from './image-generation-evidence.js';
|
|
2
|
+
import type { ImageGenerationProvider } from './image-provider-preflight.js';
|
|
3
|
+
export declare const IMAGE_GENERATION_ASPECTS: readonly ["landscape", "portrait", "square"];
|
|
4
|
+
export type ImageGenerationAspect = (typeof IMAGE_GENERATION_ASPECTS)[number];
|
|
5
|
+
export declare const isImageGenerationAspect: (value: unknown) => value is ImageGenerationAspect;
|
|
6
|
+
export declare const imageGenerationSha256: (value: Uint8Array | string) => string;
|
|
7
|
+
export type ImageGenerationRequest = {
|
|
8
|
+
candidateId?: string;
|
|
9
|
+
prompt: string;
|
|
10
|
+
promptSource: ImageGenerationAttempt['promptSource'];
|
|
11
|
+
referencePath: string;
|
|
12
|
+
outputPath: string;
|
|
13
|
+
projectRoot: string;
|
|
14
|
+
provider: ImageGenerationProvider;
|
|
15
|
+
aspect: ImageGenerationAspect;
|
|
16
|
+
idempotencyKey: string;
|
|
17
|
+
};
|
|
18
|
+
export type PreparedImageGenerationRequest = ImageGenerationRequest & {
|
|
19
|
+
attemptFile: string;
|
|
20
|
+
promptSha256: string;
|
|
21
|
+
reference: {
|
|
22
|
+
path: string;
|
|
23
|
+
sha256: string;
|
|
24
|
+
dataUrl: string;
|
|
25
|
+
};
|
|
26
|
+
};
|
|
27
|
+
export declare const imageGenerationPathExists: (target: string) => Promise<boolean>;
|
|
28
|
+
export declare const prepareImageGenerationRequest: (request: ImageGenerationRequest) => Promise<PreparedImageGenerationRequest>;
|
|
29
|
+
//# sourceMappingURL=image-generation-request.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"image-generation-request.d.ts","sourceRoot":"","sources":["../src/image-generation-request.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,gCAAgC,CAAC;AAG7E,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,+BAA+B,CAAC;AAE7E,eAAO,MAAM,wBAAwB,8CAA+C,CAAC;AACrF,MAAM,MAAM,qBAAqB,GAAG,CAAC,OAAO,wBAAwB,CAAC,CAAC,MAAM,CAAC,CAAC;AAE9E,eAAO,MAAM,uBAAuB,GAAI,OAAO,OAAO,KAAG,KAAK,IAAI,qBAGjE,CAAC;AAEF,eAAO,MAAM,qBAAqB,GAAI,OAAO,UAAU,GAAG,MAAM,KAAG,MAElE,CAAC;AAEF,MAAM,MAAM,sBAAsB,GAAG;IACnC,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,MAAM,EAAE,MAAM,CAAC;IACf,YAAY,EAAE,sBAAsB,CAAC,cAAc,CAAC,CAAC;IACrD,aAAa,EAAE,MAAM,CAAC;IACtB,UAAU,EAAE,MAAM,CAAC;IACnB,WAAW,EAAE,MAAM,CAAC;IACpB,QAAQ,EAAE,uBAAuB,CAAC;IAClC,MAAM,EAAE,qBAAqB,CAAC;IAC9B,cAAc,EAAE,MAAM,CAAC;CACxB,CAAC;AAEF,MAAM,MAAM,8BAA8B,GAAG,sBAAsB,GAAG;IACpE,WAAW,EAAE,MAAM,CAAC;IACpB,YAAY,EAAE,MAAM,CAAC;IACrB,SAAS,EAAE;QACT,IAAI,EAAE,MAAM,CAAC;QACb,MAAM,EAAE,MAAM,CAAC;QACf,OAAO,EAAE,MAAM,CAAC;KACjB,CAAC;CACH,CAAC;AAEF,eAAO,MAAM,yBAAyB,GAAU,QAAQ,MAAM,KAAG,OAAO,CAAC,OAAO,CAQ/E,CAAC;AAEF,eAAO,MAAM,6BAA6B,GACxC,SAAS,sBAAsB,KAC9B,OAAO,CAAC,8BAA8B,CA0BxC,CAAC"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { createHash } from 'node:crypto';
|
|
2
|
+
import { lstat, mkdir, readFile } from 'node:fs/promises';
|
|
3
|
+
import path from 'node:path';
|
|
4
|
+
import { imageAttemptPath } from './image-generation-evidence.js';
|
|
5
|
+
import { referenceImageDataUrl } from './image-generation-output.js';
|
|
6
|
+
export const IMAGE_GENERATION_ASPECTS = ['landscape', 'portrait', 'square'];
|
|
7
|
+
export const isImageGenerationAspect = (value) => (typeof value === 'string'
|
|
8
|
+
&& IMAGE_GENERATION_ASPECTS.includes(value));
|
|
9
|
+
export const imageGenerationSha256 = (value) => (createHash('sha256').update(value).digest('hex'));
|
|
10
|
+
export const imageGenerationPathExists = async (target) => {
|
|
11
|
+
try {
|
|
12
|
+
await lstat(target);
|
|
13
|
+
return true;
|
|
14
|
+
}
|
|
15
|
+
catch (error) {
|
|
16
|
+
if (error.code === 'ENOENT')
|
|
17
|
+
return false;
|
|
18
|
+
throw error;
|
|
19
|
+
}
|
|
20
|
+
};
|
|
21
|
+
export const prepareImageGenerationRequest = async (request) => {
|
|
22
|
+
if (path.extname(request.outputPath).toLowerCase() !== '.png') {
|
|
23
|
+
throw new Error('Image output must end in .png because image generation always writes PNG bytes');
|
|
24
|
+
}
|
|
25
|
+
const attemptFile = imageAttemptPath(request.outputPath);
|
|
26
|
+
if (await imageGenerationPathExists(request.outputPath)) {
|
|
27
|
+
throw new Error(`Refusing to dispatch because output already exists at ${request.outputPath}`);
|
|
28
|
+
}
|
|
29
|
+
if (await imageGenerationPathExists(attemptFile)) {
|
|
30
|
+
throw new Error(`Image attempt evidence already exists at ${attemptFile}. Refusing to redispatch an`
|
|
31
|
+
+ ' ambiguous or completed request; inspect it and use a new output/idempotency key.');
|
|
32
|
+
}
|
|
33
|
+
await mkdir(path.dirname(request.outputPath), { recursive: true });
|
|
34
|
+
const referenceBytes = new Uint8Array(await readFile(request.referencePath));
|
|
35
|
+
return {
|
|
36
|
+
...request,
|
|
37
|
+
attemptFile,
|
|
38
|
+
promptSha256: imageGenerationSha256(request.prompt),
|
|
39
|
+
reference: {
|
|
40
|
+
path: request.referencePath,
|
|
41
|
+
sha256: imageGenerationSha256(referenceBytes),
|
|
42
|
+
dataUrl: await referenceImageDataUrl(referenceBytes, request.referencePath),
|
|
43
|
+
},
|
|
44
|
+
};
|
|
45
|
+
};
|
|
46
|
+
//# sourceMappingURL=image-generation-request.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"image-generation-request.js","sourceRoot":"","sources":["../src/image-generation-request.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC1D,OAAO,IAAI,MAAM,WAAW,CAAC;AAG7B,OAAO,EAAE,gBAAgB,EAAE,MAAM,gCAAgC,CAAC;AAClE,OAAO,EAAE,qBAAqB,EAAE,MAAM,8BAA8B,CAAC;AAGrE,MAAM,CAAC,MAAM,wBAAwB,GAAG,CAAC,WAAW,EAAE,UAAU,EAAE,QAAQ,CAAU,CAAC;AAGrF,MAAM,CAAC,MAAM,uBAAuB,GAAG,CAAC,KAAc,EAAkC,EAAE,CAAC,CACzF,OAAO,KAAK,KAAK,QAAQ;OACrB,wBAA8C,CAAC,QAAQ,CAAC,KAAK,CAAC,CACnE,CAAC;AAEF,MAAM,CAAC,MAAM,qBAAqB,GAAG,CAAC,KAA0B,EAAU,EAAE,CAAC,CAC3E,UAAU,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CACjD,CAAC;AAwBF,MAAM,CAAC,MAAM,yBAAyB,GAAG,KAAK,EAAE,MAAc,EAAoB,EAAE;IAClF,IAAI,CAAC;QACH,MAAM,KAAK,CAAC,MAAM,CAAC,CAAC;QACpB,OAAO,IAAI,CAAC;IACd,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,IAAK,KAA+B,CAAC,IAAI,KAAK,QAAQ;YAAE,OAAO,KAAK,CAAC;QACrE,MAAM,KAAK,CAAC;IACd,CAAC;AACH,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,6BAA6B,GAAG,KAAK,EAChD,OAA+B,EACU,EAAE;IAC3C,IAAI,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC,WAAW,EAAE,KAAK,MAAM,EAAE,CAAC;QAC9D,MAAM,IAAI,KAAK,CAAC,gFAAgF,CAAC,CAAC;IACpG,CAAC;IACD,MAAM,WAAW,GAAG,gBAAgB,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC;IACzD,IAAI,MAAM,yBAAyB,CAAC,OAAO,CAAC,UAAU,CAAC,EAAE,CAAC;QACxD,MAAM,IAAI,KAAK,CAAC,yDAAyD,OAAO,CAAC,UAAU,EAAE,CAAC,CAAC;IACjG,CAAC;IACD,IAAI,MAAM,yBAAyB,CAAC,WAAW,CAAC,EAAE,CAAC;QACjD,MAAM,IAAI,KAAK,CACb,4CAA4C,WAAW,6BAA6B;cAClF,mFAAmF,CACtF,CAAC;IACJ,CAAC;IACD,MAAM,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,UAAU,CAAC,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;IACnE,MAAM,cAAc,GAAG,IAAI,UAAU,CAAC,MAAM,QAAQ,CAAC,OAAO,CAAC,aAAa,CAAC,CAAC,CAAC;IAC7E,OAAO;QACL,GAAG,OAAO;QACV,WAAW;QACX,YAAY,EAAE,qBAAqB,CAAC,OAAO,CAAC,MAAM,CAAC;QACnD,SAAS,EAAE;YACT,IAAI,EAAE,OAAO,CAAC,aAAa;YAC3B,MAAM,EAAE,qBAAqB,CAAC,cAAc,CAAC;YAC7C,OAAO,EAAE,MAAM,qBAAqB,CAAC,cAAc,EAAE,OAAO,CAAC,aAAa,CAAC;SAC5E;KACF,CAAC;AACJ,CAAC,CAAC"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { ensembleImage } from '@just-every/ensemble';
|
|
2
|
+
import { type ImageGenerationAttempt } from './image-generation-evidence.js';
|
|
3
|
+
import { type PreparedImageGenerationRequest } from './image-generation-request.js';
|
|
4
|
+
import { type ImageGenerationUsageEvidence } from './image-generation-usage.js';
|
|
5
|
+
import type { ImageProviderPreflight } from './image-provider-preflight.js';
|
|
6
|
+
export type ImageGenerationDependencies = {
|
|
7
|
+
generate?: typeof ensembleImage;
|
|
8
|
+
now?: () => Date;
|
|
9
|
+
};
|
|
10
|
+
export type ReservedImageGeneration = {
|
|
11
|
+
request: PreparedImageGenerationRequest;
|
|
12
|
+
preflight: ImageProviderPreflight;
|
|
13
|
+
attempt: ImageGenerationAttempt;
|
|
14
|
+
};
|
|
15
|
+
export type ImageGenerationResult = {
|
|
16
|
+
candidateId?: string;
|
|
17
|
+
provider: ImageGenerationAttempt['provider'];
|
|
18
|
+
model: ImageGenerationAttempt['model'];
|
|
19
|
+
outputPath: string;
|
|
20
|
+
outputSha256: string;
|
|
21
|
+
attemptFile: string;
|
|
22
|
+
providerStartedAt: string;
|
|
23
|
+
completedAt: string;
|
|
24
|
+
usage: ImageGenerationUsageEvidence;
|
|
25
|
+
};
|
|
26
|
+
export declare const reserveImageGeneration: (args: {
|
|
27
|
+
request: PreparedImageGenerationRequest;
|
|
28
|
+
preflight: ImageProviderPreflight;
|
|
29
|
+
batch?: ImageGenerationAttempt["batch"];
|
|
30
|
+
dependencies?: ImageGenerationDependencies;
|
|
31
|
+
}) => Promise<ReservedImageGeneration>;
|
|
32
|
+
export declare const markImageGenerationDispatched: (reserved: ReservedImageGeneration, dependencies?: ImageGenerationDependencies) => Promise<void>;
|
|
33
|
+
export declare const failImageGenerationBeforeDispatch: (reserved: ReservedImageGeneration, error: string, dependencies?: ImageGenerationDependencies) => Promise<void>;
|
|
34
|
+
export declare const dispatchImageGeneration: (reserved: ReservedImageGeneration, dependencies?: ImageGenerationDependencies) => Promise<ImageGenerationResult>;
|
|
35
|
+
//# sourceMappingURL=image-generation-run.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"image-generation-run.d.ts","sourceRoot":"","sources":["../src/image-generation-run.ts"],"names":[],"mappings":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AAc,2BAAgC,KAC7C,OAAO,CAAC,IAAI,CAId,CAAC;AAEF,eAAO,MAAM,iCAAiC,GAC5C,UAAU,uBAAuB,EACjC,OAAO,MAAM,EACb,eAAc,2BAAgC,KAC7C,OAAO,CAAC,IAAI,CAKd,CAAC;AAEF,eAAO,MAAM,uBAAuB,GAClC,UAAU,uBAAuB,EACjC,eAAc,2BAAgC,KAC7C,OAAO,CAAC,qBAAqB,CAsF/B,CAAC"}
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
import { writeFile } from 'node:fs/promises';
|
|
2
|
+
import { ensembleImage, } from '@just-every/ensemble';
|
|
3
|
+
import { OpenAIProvider } from '@just-every/ensemble/model_providers/openai';
|
|
4
|
+
import { writeImageGenerationAttempt, } from './image-generation-evidence.js';
|
|
5
|
+
import { generatedPngBytes } from './image-generation-output.js';
|
|
6
|
+
import { imageGenerationSha256, } from './image-generation-request.js';
|
|
7
|
+
import { captureImageGenerationUsage, imageGenerationUsageEvidence, } from './image-generation-usage.js';
|
|
8
|
+
const timestamp = (dependencies) => ((dependencies.now ?? (() => new Date()))().toISOString());
|
|
9
|
+
export const reserveImageGeneration = async (args) => {
|
|
10
|
+
const dependencies = args.dependencies ?? {};
|
|
11
|
+
const attempt = {
|
|
12
|
+
schemaVersion: 3,
|
|
13
|
+
status: 'prepared',
|
|
14
|
+
idempotencyKey: args.request.idempotencyKey,
|
|
15
|
+
provider: args.preflight.provider,
|
|
16
|
+
model: args.preflight.model,
|
|
17
|
+
providerIdempotencyEnforced: args.preflight.provider === 'openai',
|
|
18
|
+
providerEvidence: args.preflight.provider === 'codex'
|
|
19
|
+
? { codexVersion: args.preflight.codexVersion }
|
|
20
|
+
: { keySource: args.preflight.keySource },
|
|
21
|
+
prompt: args.request.prompt,
|
|
22
|
+
promptSource: args.request.promptSource,
|
|
23
|
+
promptSha256: args.request.promptSha256,
|
|
24
|
+
reference: {
|
|
25
|
+
path: args.request.reference.path,
|
|
26
|
+
sha256: args.request.reference.sha256,
|
|
27
|
+
},
|
|
28
|
+
outputPath: args.request.outputPath,
|
|
29
|
+
preparedAt: timestamp(dependencies),
|
|
30
|
+
...(args.batch ? { batch: args.batch } : {}),
|
|
31
|
+
};
|
|
32
|
+
await writeImageGenerationAttempt(args.request.attemptFile, attempt, true).catch((error) => {
|
|
33
|
+
if (error.code === 'EEXIST') {
|
|
34
|
+
throw new Error(`Image attempt evidence already exists at ${args.request.attemptFile}. Refusing to`
|
|
35
|
+
+ ' redispatch an ambiguous or completed request; inspect it and use a new output/'
|
|
36
|
+
+ 'idempotency key.');
|
|
37
|
+
}
|
|
38
|
+
throw error;
|
|
39
|
+
});
|
|
40
|
+
return { request: args.request, preflight: args.preflight, attempt };
|
|
41
|
+
};
|
|
42
|
+
export const markImageGenerationDispatched = async (reserved, dependencies = {}) => {
|
|
43
|
+
reserved.attempt.status = 'dispatched';
|
|
44
|
+
reserved.attempt.dispatchedAt = timestamp(dependencies);
|
|
45
|
+
await writeImageGenerationAttempt(reserved.request.attemptFile, reserved.attempt);
|
|
46
|
+
};
|
|
47
|
+
export const failImageGenerationBeforeDispatch = async (reserved, error, dependencies = {}) => {
|
|
48
|
+
reserved.attempt.status = 'failed';
|
|
49
|
+
reserved.attempt.completedAt = timestamp(dependencies);
|
|
50
|
+
reserved.attempt.error = error;
|
|
51
|
+
await writeImageGenerationAttempt(reserved.request.attemptFile, reserved.attempt);
|
|
52
|
+
};
|
|
53
|
+
export const dispatchImageGeneration = async (reserved, dependencies = {}) => {
|
|
54
|
+
const { request, preflight, attempt } = reserved;
|
|
55
|
+
attempt.providerStartedAt = timestamp(dependencies);
|
|
56
|
+
await writeImageGenerationAttempt(request.attemptFile, attempt);
|
|
57
|
+
try {
|
|
58
|
+
const agent = {
|
|
59
|
+
agent_id: `12ui-image-${imageGenerationSha256(request.idempotencyKey).slice(0, 16)}`,
|
|
60
|
+
model: preflight.model,
|
|
61
|
+
cwd: request.projectRoot,
|
|
62
|
+
retryOptions: { maxRetries: 0 },
|
|
63
|
+
};
|
|
64
|
+
let providerRequestId;
|
|
65
|
+
const options = {
|
|
66
|
+
n: 1,
|
|
67
|
+
size: request.aspect,
|
|
68
|
+
quality: 'high',
|
|
69
|
+
source_images: [request.reference.dataUrl],
|
|
70
|
+
...(preflight.provider === 'codex' ? { input_fidelity: 'high' } : {}),
|
|
71
|
+
output_format: 'png',
|
|
72
|
+
idempotency_key: request.idempotencyKey,
|
|
73
|
+
request_id: request.idempotencyKey,
|
|
74
|
+
on_metadata: (metadata) => {
|
|
75
|
+
if (metadata.request_id && metadata.request_id !== request.idempotencyKey)
|
|
76
|
+
return;
|
|
77
|
+
if (metadata.provider_request_id)
|
|
78
|
+
providerRequestId = metadata.provider_request_id;
|
|
79
|
+
},
|
|
80
|
+
};
|
|
81
|
+
const captured = await captureImageGenerationUsage({
|
|
82
|
+
requestId: request.idempotencyKey,
|
|
83
|
+
run: async () => (dependencies.generate
|
|
84
|
+
? dependencies.generate(request.prompt, agent, options)
|
|
85
|
+
: preflight.provider === 'openai'
|
|
86
|
+
? new OpenAIProvider(preflight.apiKey).createImage(request.prompt, preflight.model, agent, options)
|
|
87
|
+
: ensembleImage(request.prompt, agent, options)),
|
|
88
|
+
});
|
|
89
|
+
const generated = captured.outcome.status === 'fulfilled'
|
|
90
|
+
? captured.outcome.value
|
|
91
|
+
: undefined;
|
|
92
|
+
attempt.usage = imageGenerationUsageEvidence({
|
|
93
|
+
provider: preflight.provider,
|
|
94
|
+
model: preflight.model,
|
|
95
|
+
requestId: request.idempotencyKey,
|
|
96
|
+
...(providerRequestId ? { providerRequestId } : {}),
|
|
97
|
+
entries: captured.entries,
|
|
98
|
+
providerCompleted: captured.outcome.status === 'fulfilled',
|
|
99
|
+
...(Array.isArray(generated) ? { generatedImageCount: generated.length } : {}),
|
|
100
|
+
});
|
|
101
|
+
await writeImageGenerationAttempt(request.attemptFile, attempt);
|
|
102
|
+
if (captured.outcome.status === 'rejected')
|
|
103
|
+
throw captured.outcome.reason;
|
|
104
|
+
if (!Array.isArray(generated) || generated.length !== 1 || typeof generated[0] !== 'string') {
|
|
105
|
+
throw new Error('Image provider did not return exactly one image');
|
|
106
|
+
}
|
|
107
|
+
const bytes = await generatedPngBytes(generated[0]);
|
|
108
|
+
await writeFile(request.outputPath, bytes, { flag: 'wx' });
|
|
109
|
+
attempt.status = 'succeeded';
|
|
110
|
+
attempt.completedAt = timestamp(dependencies);
|
|
111
|
+
attempt.outputSha256 = imageGenerationSha256(bytes);
|
|
112
|
+
await writeImageGenerationAttempt(request.attemptFile, attempt);
|
|
113
|
+
return {
|
|
114
|
+
...(request.candidateId ? { candidateId: request.candidateId } : {}),
|
|
115
|
+
provider: attempt.provider,
|
|
116
|
+
model: attempt.model,
|
|
117
|
+
outputPath: request.outputPath,
|
|
118
|
+
outputSha256: attempt.outputSha256,
|
|
119
|
+
attemptFile: request.attemptFile,
|
|
120
|
+
providerStartedAt: attempt.providerStartedAt,
|
|
121
|
+
completedAt: attempt.completedAt,
|
|
122
|
+
usage: attempt.usage,
|
|
123
|
+
};
|
|
124
|
+
}
|
|
125
|
+
catch (error) {
|
|
126
|
+
attempt.status = 'failed';
|
|
127
|
+
attempt.completedAt = timestamp(dependencies);
|
|
128
|
+
attempt.error = error instanceof Error ? error.message : String(error);
|
|
129
|
+
await writeImageGenerationAttempt(request.attemptFile, attempt);
|
|
130
|
+
throw new Error(`Image generation failed after dispatch with ${attempt.provider}; no provider fallback`
|
|
131
|
+
+ ` was attempted. Evidence: ${request.attemptFile}. ${attempt.error}`, { cause: error });
|
|
132
|
+
}
|
|
133
|
+
};
|
|
134
|
+
//# sourceMappingURL=image-generation-run.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"image-generation-run.js","sourceRoot":"","sources":["../src/image-generation-run.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAE7C,OAAO,EACL,aAAa,GAGd,MAAM,sBAAsB,CAAC;AAC9B,OAA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,OAAO,CAAC,WAAW,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;YACpE,QAAQ,EAAE,OAAO,CAAC,QAAQ;YAC1B,KAAK,EAAE,OAAO,CAAC,KAAK;YACpB,UAAU,EAAE,OAAO,CAAC,UAAU;YAC9B,YAAY,EAAE,OAAO,CAAC,YAAY;YAClC,WAAW,EAAE,OAAO,CAAC,WAAW;YAChC,iBAAiB,EAAE,OAAO,CAAC,iBAAiB;YAC5C,WAAW,EAAE,OAAO,CAAC,WAAW;YAChC,KAAK,EAAE,OAAO,CAAC,KAAK;SACrB,CAAC;IACJ,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,OAAO,CAAC,MAAM,GAAG,QAAQ,CAAC;QAC1B,OAAO,CAAC,WAAW,GAAG,SAAS,CAAC,YAAY,CAAC,CAAC;QAC9C,OAAO,CAAC,KAAK,GAAG,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;QACvE,MAAM,2BAA2B,CAAC,OAAO,CAAC,WAAW,EAAE,OAAO,CAAC,CAAC;QAChE,MAAM,IAAI,KAAK,CACb,+CAA+C,OAAO,CAAC,QAAQ,wBAAwB;cACrF,6BAA6B,OAAO,CAAC,WAAW,KAAK,OAAO,CAAC,KAAK,EAAE,EACtE,EAAE,KAAK,EAAE,KAAK,EAAE,CACjB,CAAC;IACJ,CAAC;AACH,CAAC,CAAC"}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { type ModelUsage } from '@just-every/ensemble';
|
|
2
|
+
export type ImageGenerationUsageEntry = {
|
|
3
|
+
model?: string;
|
|
4
|
+
inputTokens?: number;
|
|
5
|
+
inputTokensByModality?: {
|
|
6
|
+
text: number;
|
|
7
|
+
image: number;
|
|
8
|
+
};
|
|
9
|
+
outputTokens?: number;
|
|
10
|
+
totalTokens?: number;
|
|
11
|
+
cachedTokens?: number;
|
|
12
|
+
imageCount?: number;
|
|
13
|
+
inputModality?: ModelUsage['input_modality'];
|
|
14
|
+
outputModality?: ModelUsage['output_modality'];
|
|
15
|
+
costUsd?: number;
|
|
16
|
+
estimatedCostUsd?: number;
|
|
17
|
+
};
|
|
18
|
+
export type ImageGenerationUsageEvidence = {
|
|
19
|
+
requestId: string;
|
|
20
|
+
providerRequestId?: string;
|
|
21
|
+
billing: 'openai-api' | 'codex-included-quota';
|
|
22
|
+
method: 'provider-reported-token-usage' | 'provider-estimated-output-only' | 'incomplete-provider-token-usage' | 'missing-provider-usage' | 'provider-reported-included-quota' | 'selected-provider-included-quota';
|
|
23
|
+
completeness: 'full' | 'partial' | 'missing' | 'included-quota';
|
|
24
|
+
costUsd: number | null;
|
|
25
|
+
estimatedCostUsd?: number;
|
|
26
|
+
inputTokens?: number;
|
|
27
|
+
inputTokensByModality?: {
|
|
28
|
+
text: number;
|
|
29
|
+
image: number;
|
|
30
|
+
};
|
|
31
|
+
outputTokens?: number;
|
|
32
|
+
totalTokens?: number;
|
|
33
|
+
cachedTokens?: number;
|
|
34
|
+
imageCount?: number;
|
|
35
|
+
entries: ImageGenerationUsageEntry[];
|
|
36
|
+
};
|
|
37
|
+
export type ImageGenerationBatchAccounting = {
|
|
38
|
+
billing: ImageGenerationUsageEvidence['billing'];
|
|
39
|
+
method: 'sum-candidate-evidence';
|
|
40
|
+
completeness: 'full' | 'partial' | 'missing' | 'included-quota';
|
|
41
|
+
candidateCount: number;
|
|
42
|
+
fullCostCandidateCount: number;
|
|
43
|
+
includedQuotaCandidateCount: number;
|
|
44
|
+
incompleteCandidateCount: number;
|
|
45
|
+
costUsd: number | null;
|
|
46
|
+
recordedCostUsd: number | null;
|
|
47
|
+
};
|
|
48
|
+
export type CapturedImageGeneration<T> = {
|
|
49
|
+
outcome: PromiseSettledResult<T>;
|
|
50
|
+
entries: ModelUsage[];
|
|
51
|
+
};
|
|
52
|
+
/**
|
|
53
|
+
* Capture usage for one provider request without serializing other image calls.
|
|
54
|
+
* Ensemble emits the caller-supplied request_id synchronously to every listener,
|
|
55
|
+
* so exact request filtering keeps parallel candidates isolated.
|
|
56
|
+
*/
|
|
57
|
+
export declare const captureImageGenerationUsage: <T>(args: {
|
|
58
|
+
requestId: string;
|
|
59
|
+
run: () => Promise<T>;
|
|
60
|
+
}) => Promise<CapturedImageGeneration<T>>;
|
|
61
|
+
export declare const imageGenerationUsageEvidence: (args: {
|
|
62
|
+
provider: "codex" | "openai";
|
|
63
|
+
model: "codex-gpt-image-2" | "gpt-image-2";
|
|
64
|
+
requestId: string;
|
|
65
|
+
providerRequestId?: string;
|
|
66
|
+
entries: ModelUsage[];
|
|
67
|
+
providerCompleted: boolean;
|
|
68
|
+
generatedImageCount?: number;
|
|
69
|
+
}) => ImageGenerationUsageEvidence;
|
|
70
|
+
export declare const summarizeImageGenerationUsage: (usages: Array<ImageGenerationUsageEvidence | undefined>, provider: "codex" | "openai") => ImageGenerationBatchAccounting;
|
|
71
|
+
//# sourceMappingURL=image-generation-usage.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"image-generation-usage.d.ts","sourceRoot":"","sources":["../src/image-generation-usage.ts"],"names":[],"mappings":"AAAA,OAAO,EAAe,KAAK,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAEpE,MAAM,MAAM,yBAAyB,GAAG;IACtC,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,qBAAqB,CAAC,EAAE;QACtB,IAAI,EAAE,MAAM,CAAC;QACb,KAAK,EAAE,MAAM,CAAC;KACf,CAAC;IACF,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,aAAa,CAAC,EAAE,UAAU,CAAC,gBAAgB,CAAC,CAAC;IAC7C,cAAc,CAAC,EAAE,UAAU,CAAC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