@12ui/design 0.2.16 → 0.2.18

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.
Files changed (105) hide show
  1. package/README.md +22 -0
  2. package/dist/branch-client.d.ts +6 -1
  3. package/dist/branch-client.d.ts.map +1 -1
  4. package/dist/branch-client.js +6 -1
  5. package/dist/branch-client.js.map +1 -1
  6. package/dist/branch-status.d.ts.map +1 -1
  7. package/dist/branch-status.js +3 -2
  8. package/dist/branch-status.js.map +1 -1
  9. package/dist/branch-winner.d.ts +31 -0
  10. package/dist/branch-winner.d.ts.map +1 -0
  11. package/dist/branch-winner.js +121 -0
  12. package/dist/branch-winner.js.map +1 -0
  13. package/dist/cli-arguments.d.ts +1 -0
  14. package/dist/cli-arguments.d.ts.map +1 -1
  15. package/dist/cli-arguments.js +4 -3
  16. package/dist/cli-arguments.js.map +1 -1
  17. package/dist/cli-branch-command.d.ts +3 -0
  18. package/dist/cli-branch-command.d.ts.map +1 -1
  19. package/dist/cli-branch-command.js +66 -98
  20. package/dist/cli-branch-command.js.map +1 -1
  21. package/dist/cli-capabilities.d.ts +18 -0
  22. package/dist/cli-capabilities.d.ts.map +1 -1
  23. package/dist/cli-capabilities.js +23 -0
  24. package/dist/cli-capabilities.js.map +1 -1
  25. package/dist/cli-convert-command.d.ts +10 -0
  26. package/dist/cli-convert-command.d.ts.map +1 -0
  27. package/dist/cli-convert-command.js +307 -0
  28. package/dist/cli-convert-command.js.map +1 -0
  29. package/dist/cli-corpus-command.d.ts +6 -1
  30. package/dist/cli-corpus-command.d.ts.map +1 -1
  31. package/dist/cli-corpus-command.js +17 -21
  32. package/dist/cli-corpus-command.js.map +1 -1
  33. package/dist/cli-create-command.d.ts +5 -1
  34. package/dist/cli-create-command.d.ts.map +1 -1
  35. package/dist/cli-create-command.js +28 -12
  36. package/dist/cli-create-command.js.map +1 -1
  37. package/dist/cli-detach.d.ts.map +1 -1
  38. package/dist/cli-detach.js +10 -2
  39. package/dist/cli-detach.js.map +1 -1
  40. package/dist/cli-draft-command.d.ts +7 -0
  41. package/dist/cli-draft-command.d.ts.map +1 -1
  42. package/dist/cli-draft-command.js +6 -4
  43. package/dist/cli-draft-command.js.map +1 -1
  44. package/dist/cli-export-command.d.ts +24 -1
  45. package/dist/cli-export-command.d.ts.map +1 -1
  46. package/dist/cli-export-command.js +6 -3
  47. package/dist/cli-export-command.js.map +1 -1
  48. package/dist/cli-image-batch-command.d.ts +8 -2
  49. package/dist/cli-image-batch-command.d.ts.map +1 -1
  50. package/dist/cli-image-batch-command.js +15 -11
  51. package/dist/cli-image-batch-command.js.map +1 -1
  52. package/dist/cli-image-batch-resume.d.ts +3 -1
  53. package/dist/cli-image-batch-resume.d.ts.map +1 -1
  54. package/dist/cli-image-batch-resume.js +1 -0
  55. package/dist/cli-image-batch-resume.js.map +1 -1
  56. package/dist/cli-image-command.d.ts +3 -1
  57. package/dist/cli-image-command.d.ts.map +1 -1
  58. package/dist/cli-image-command.js +4 -2
  59. package/dist/cli-image-command.js.map +1 -1
  60. package/dist/cli-package-command.d.ts.map +1 -1
  61. package/dist/cli-package-command.js +4 -3
  62. package/dist/cli-package-command.js.map +1 -1
  63. package/dist/cli-refusal.d.ts +20 -0
  64. package/dist/cli-refusal.d.ts.map +1 -0
  65. package/dist/cli-refusal.js +29 -0
  66. package/dist/cli-refusal.js.map +1 -0
  67. package/dist/cli-run.d.ts +4 -0
  68. package/dist/cli-run.d.ts.map +1 -0
  69. package/dist/cli-run.js +215 -0
  70. package/dist/cli-run.js.map +1 -0
  71. package/dist/cli-select-command.d.ts +6 -1
  72. package/dist/cli-select-command.d.ts.map +1 -1
  73. package/dist/cli-select-command.js +9 -7
  74. package/dist/cli-select-command.js.map +1 -1
  75. package/dist/cli-usage.d.ts +17 -0
  76. package/dist/cli-usage.d.ts.map +1 -0
  77. package/dist/cli-usage.js +69 -0
  78. package/dist/cli-usage.js.map +1 -0
  79. package/dist/cli-version.d.ts +2 -0
  80. package/dist/cli-version.d.ts.map +1 -0
  81. package/dist/cli-version.js +8 -0
  82. package/dist/cli-version.js.map +1 -0
  83. package/dist/cli.js +9 -491
  84. package/dist/cli.js.map +1 -1
  85. package/dist/concept-input.d.ts +34 -0
  86. package/dist/concept-input.d.ts.map +1 -0
  87. package/dist/concept-input.js +41 -0
  88. package/dist/concept-input.js.map +1 -0
  89. package/dist/index.d.ts +7 -1
  90. package/dist/index.d.ts.map +1 -1
  91. package/dist/index.js +6 -0
  92. package/dist/index.js.map +1 -1
  93. package/dist/package-client.d.ts +36 -0
  94. package/dist/package-client.d.ts.map +1 -1
  95. package/dist/package-client.js +89 -1
  96. package/dist/package-client.js.map +1 -1
  97. package/dist/run-journal-commands.d.ts +54 -0
  98. package/dist/run-journal-commands.d.ts.map +1 -0
  99. package/dist/run-journal-commands.js +258 -0
  100. package/dist/run-journal-commands.js.map +1 -0
  101. package/dist/run-journal.d.ts +231 -0
  102. package/dist/run-journal.d.ts.map +1 -0
  103. package/dist/run-journal.js +453 -0
  104. package/dist/run-journal.js.map +1 -0
  105. package/package.json +1 -1
package/dist/cli.js CHANGED
@@ -1,498 +1,16 @@
1
1
  #!/usr/bin/env node
2
- import { readFile, writeFile } from 'node:fs/promises';
3
- import path from 'node:path';
4
2
  import { fileURLToPath } from 'node:url';
5
- import { materializeConversionArtifacts } from './artifact-materializer.js';
6
- import { booleanFlag, parseCliArguments, stringFlag, } from './cli-arguments.js';
7
- import { runAuthCommand } from './cli-auth-command.js';
8
- import { runBranchCommand } from './cli-branch-command.js';
9
- import { CLI_CAPABILITIES } from './cli-capabilities.js';
10
- import { runCliCommand } from './cli-cli-command.js';
11
- import { runCorpusCommand } from './cli-corpus-command.js';
12
- import { runExportCommand } from './cli-export-command.js';
13
- import { runImageBatchCommand, runImageBatchStatusCommand, } from './cli-image-batch-command.js';
14
- import { runImageCommand } from './cli-image-command.js';
15
- import { runCreateCommand } from './cli-create-command.js';
16
- import { runPackageCommand, runPackageTemplateCommand } from './cli-package-command.js';
17
- import { runSkillCommand } from './cli-skill-command.js';
18
- import { isConversionModel } from './conversion-models.js';
19
- import { TwelveUiConversionClient, } from './conversion-client.js';
20
- import { detachBranchRun, detachImageBatch } from './cli-detach.js';
21
- import { runDraftCommand, runDraftStatusCommand } from './cli-draft-command.js';
22
- import { runSelectCommand } from './cli-select-command.js';
23
- import { resolveBranchDirectory } from './cli-branch-command.js';
24
- import { CONVERSION_DURATION_HINTS, OPERATION_DURATION_HINTS, createProgressReporter, durationHint, nextActionLine, } from './cli-progress.js';
25
- import { CONVERSION_OUTPUTS, isConversionOutput } from './conversion-outputs.js';
26
- import { recordConvertedImageReceipt } from './conversion-receipt.js';
27
- import { readConversionConfig } from './config.js';
28
- import { classifyLocalConversionInput, createInputForLocalFile, defaultConversionOutputPath, } from './local-conversion-input.js';
29
- import { normalizeImageOutputWidth, parseImageOutputWidth, } from './image-output-width.js';
30
- import { normalizeOptionalIdempotencyKey } from './idempotency-key.js';
31
- import { isProjectConversionOutput, parseConversionOutputProfile, } from './project-profiles.js';
32
- import { isResponsiveConversionQuality, RESPONSIVE_CONVERSION_QUALITIES, } from './responsive-quality.js';
33
- import { startMcpServer } from './server.js';
34
- const usage = (exitCode = 1) => {
35
- const outputs = CONVERSION_OUTPUTS.join('|');
36
- console.error(`Usage:
37
- 12ui auth login [--api-key <personal-key>] [--login-origin <url>] [--key-name <name>]
38
- 12ui auth status [--login-origin <url>] [--json]
39
- 12ui auth logout [--login-origin <url>]
40
- 12ui cli install
41
- 12ui cli status [--json]
42
- 12ui skill install [--skill design|design-search|design-draft|design-branch|design-convert] [--client codex|claude-code|grok|cursor|antigravity|copilot] [--home <client-home>] [--api-key <key>] [--login-origin <url>] [--key-name <name>] [--force] [--skip-auth]
43
- 12ui skill status [--skill design|design-search|design-draft|design-branch|design-convert] [--client codex|claude-code|grok|cursor|antigravity|copilot] [--home <client-home>] [--json]
44
- 12ui skill print --skill design|design-search|design-draft|design-branch|design-convert
45
- 12ui skill remove [--skill design|design-search|design-draft|design-branch|design-convert] [--client codex|claude-code|grok|cursor|antigravity|copilot] [--home <client-home>]
46
- 12ui corpus inspire --query <text>|--query-file <file> --out-dir <directory> [--mode direct|balanced|adventurer] [--count <1-48>] [--reference-image <png|jpeg|webp>] [--idempotency-key <key>] [--origin <url>] [--api-key <key>]
47
- 12ui corpus resume --out-dir <directory> [--origin <url>] [--api-key <key>]
48
- 12ui image generate --prompt <text>|--prompt-file <file> --reference <file> --out <file.png> [--aspect landscape|portrait|square] [--reference-mode inspiration|preserve-structure] [--provider auto|codex|openai] --project-root <directory> --idempotency-key <key>
49
- 12ui draft --query <text> [--redesign-source <png>] [--mode exploratory|reskin] [--aspect landscape|portrait|square] [--provider auto|codex|openai] [--project-root <directory>] [--wait] [--quiet] [--origin <url>] [--api-key <key>]
50
- 12ui draft status <run-dir> [--json]
51
- 12ui select <run-dir> --winner <id> --reason <text> [--recommended <id>] [--recommendation-source <text>] [--reject <id>=<reason>]
52
- 12ui create claim --concept <text>|--concept-file <file> --candidates <json>|@<file> [--aspect landscape|portrait|square] [--mode inspiration|preserve-structure] [--reference-image <png|jpeg|webp>] [--idempotency-key <key>] [--origin <url>] [--api-key <key>]
53
- 12ui create dispatch <run-id> [--slot <a,b,...>] [--quiet] [--origin <url>] [--api-key <key>]
54
- 12ui create status <run-id> [--json] [--origin <url>] [--api-key <key>]
55
- 12ui create download <run-id> --out-dir <directory> [--slot <a,b,...>] [--origin <url>] [--api-key <key>]
56
- 12ui image generate-batch --manifest <batch.json> [--resume] [--wait] [--quiet]
57
- 12ui image batch-status --manifest <batch.json> [--json]
58
- 12ui branch execute <run-dir> --concept <text>|--concept-file <file> --scope page|site [--convert html] [--convert-model fast|standard|pro] [--convert-quality standard|pro] [--winner-image <file>|--winner-run <crt-id> --winner-slot <slot>] [--source-conversion-id <id>] [--max-screens <n>] [--page-concurrency <n>] [--idempotency-key <key>] [--out-dir <directory>] [--resume] [--dry-run] [--wait] [--quiet] [--origin <url>] [--api-key <key>]
59
- 12ui branch resume <run-dir> [--quiet] [--origin <url>] [--api-key <key>]
60
- 12ui branch status <run-dir> [--json] [--origin <url>] [--api-key <key>]
61
- 12ui capabilities [--json]
62
- 12ui convert <image.png|jpg|webp|layerdoc.json> --output ${outputs} [--model fast|standard|pro] [--width <px>] [--export html] [--export-quality standard|pro] [--export-out <file>] [--responsive-quality standard|pro] [--profile <json|file>] [--out <file>] [--detach] [--quiet] [--timeout-ms <ms>] [--idempotency-key <key>] [--origin <url>] [--api-key <key>]
63
- 12ui convert package --manifest <package.json> --out-dir <directory> [--idempotency-key <key>] [--timeout-ms <ms>] [--wait] [--quiet] [--origin <url>] [--api-key <key>]
64
- 12ui convert package --template
65
- 12ui export <source-conversion-id> --output <comma-separated-formats> --out-dir <directory> [--idempotency-key <key>] [--responsive-quality standard|pro] [--web-profile <json|file>] [--app-profile <json|file>] [--timeout-ms <ms>] [--origin <url>] [--api-key <key>]
66
- 12ui resume <conversion-id> --output ${outputs} --out <file> [--timeout-ms <ms>] [--origin <url>] [--api-key <key>]
67
- 12ui mcp [--origin <url>] [--api-key <key>]
68
- 12ui --version
69
-
70
- --export html converts and exports responsive HTML in ONE blocking command; the
71
- export runs alongside the conversion, so the pair finishes in about the time of
72
- the conversion alone (~5m) instead of ~8m. Progress goes to stderr; --quiet
73
- silences it.
74
-
75
- \`branch execute\`, \`branch resume\` and \`image generate-batch\` START the work and
76
- return: the run continues in its own process group and survives the shell that
77
- launched it. Follow it with \`12ui branch status --out-dir <dir>\` or
78
- \`12ui image batch-status --manifest <file>\`; both always report what is moving
79
- and what to do next. Add --wait to block in this shell instead. Never list an
80
- output directory to decide whether work is still running.
81
-
82
- Omit --client to discover and target every supported CLI installation.`);
83
- process.exit(exitCode);
84
- };
85
- /** This file, as the worker re-executes it. */
86
- const CLI_PATH = fileURLToPath(import.meta.url);
3
+ import { runCli } from './cli-run.js';
87
4
  /**
88
- * Long dispatches detach by default. `--wait` keeps the work in this shell for
89
- * a human at a terminal; `--dry-run` never starts anything to detach from.
5
+ * The executable entry point, and nothing else.
6
+ *
7
+ * The dispatcher lives in `cli-run.ts` so a test can drive the real command
8
+ * surface in-process. This file exists to supply the one thing only the
9
+ * executable knows: its own path, which the detached workers re-execute.
90
10
  */
91
- const detaches = (flags) => (!booleanFlag(flags, 'wait') && !booleanFlag(flags, 'dry-run'));
92
- const parseTimeoutMs = (value) => {
93
- if (value === undefined)
94
- return undefined;
95
- const timeoutMs = Number(value);
96
- if (!Number.isFinite(timeoutMs) || timeoutMs < 1_000) {
97
- throw new Error('--timeout-ms must be a number of at least 1000');
98
- }
99
- return Math.floor(timeoutMs);
100
- };
101
- const parseProjectProfileFlag = async (output, value) => {
102
- if (!isProjectConversionOutput(output)) {
103
- if (value !== undefined)
104
- throw new Error('--profile is only valid for project outputs');
105
- return undefined;
106
- }
107
- if (!value?.trim())
108
- throw new Error(`--profile is required for ${output}`);
109
- const trimmed = value.trim();
110
- const source = trimmed.startsWith('{')
111
- ? trimmed
112
- : await readFile(path.resolve(trimmed.startsWith('@') ? trimmed.slice(1) : trimmed), 'utf8');
113
- let parsed;
114
- try {
115
- parsed = JSON.parse(source);
116
- }
117
- catch (error) {
118
- throw new Error(`--profile must contain valid JSON: ${error instanceof Error ? error.message : String(error)}`);
119
- }
120
- return parseConversionOutputProfile(output, parsed);
121
- };
122
- const downloadCompletedConversion = async (args) => {
123
- const downloaded = await args.client.downloadResult(args.operation.id, args.output);
124
- await writeFile(args.outFile, downloaded.bytes);
125
- const artifactManifest = await materializeConversionArtifacts(args.client, args.operation, args.outFile);
126
- return {
127
- id: args.operation.id,
128
- output: args.output,
129
- outFile: args.outFile,
130
- artifactManifest,
131
- };
132
- };
133
- const writeCompletedConversion = async (args) => {
134
- console.log(JSON.stringify(await downloadCompletedConversion(args), null, 2));
135
- };
136
- const printCapabilities = () => {
137
- console.log(JSON.stringify(CLI_CAPABILITIES, null, 2));
138
- };
139
- const printVersion = async () => {
140
- const packageJson = JSON.parse(await readFile(new URL('../package.json', import.meta.url), 'utf8'));
141
- if (typeof packageJson.version !== 'string')
142
- throw new Error('Invalid package version');
143
- console.log(packageJson.version);
144
- };
145
- const runConversionCommand = async (command, flags) => {
146
- const verb = command[0];
147
- // The hosted candidate API as commands: claim, dispatch, status, download.
148
- if (verb === 'create') {
149
- await runCreateCommand(command, flags);
150
- return;
151
- }
152
- // Ordered viewports of one page are ONE package conversion, not N converts.
153
- if (verb === 'convert' && command[1] === 'package') {
154
- if (runPackageTemplateCommand(flags))
155
- return;
156
- await runPackageCommand(flags);
157
- return;
158
- }
159
- const config = readConversionConfig({
160
- origin: stringFlag(flags, 'origin'),
161
- apiKey: stringFlag(flags, 'api-key'),
162
- });
163
- if (verb === 'mcp') {
164
- await startMcpServer({ config });
165
- return;
166
- }
167
- // `12ui convert <image> --export html` is the whole command for a single
168
- // screen. The export is derived from a LayerDoc conversion, so asking for the
169
- // output as well is asking the caller to restate the only value it can have.
170
- const outputValue = stringFlag(flags, 'output')
171
- ?? (stringFlag(flags, 'export') !== undefined ? 'layerdoc' : undefined);
172
- const output = isConversionOutput(outputValue) ? outputValue : usage();
173
- const client = new TwelveUiConversionClient(config);
174
- const timeoutMs = parseTimeoutMs(stringFlag(flags, 'timeout-ms'));
175
- if (verb === 'resume') {
176
- if (stringFlag(flags, 'profile') !== undefined
177
- || stringFlag(flags, 'model') !== undefined
178
- || stringFlag(flags, 'width') !== undefined
179
- || stringFlag(flags, 'responsive-quality') !== undefined
180
- || booleanFlag(flags, 'detach')) {
181
- throw new Error('--profile, --model, --width, --responsive-quality, and --detach are not accepted by resume');
182
- }
183
- const conversionId = command[1]?.trim();
184
- const outFile = stringFlag(flags, 'out');
185
- if (!conversionId)
186
- usage();
187
- const resolvedOutFile = outFile ? path.resolve(outFile) : usage();
188
- const current = await client.getConversion(conversionId);
189
- if (current.output !== output) {
190
- throw new Error(`Conversion ${conversionId} produces ${current.output}, not ${output}`);
191
- }
192
- const completed = current.status === 'succeeded'
193
- ? current
194
- : await client.waitForConversion(current.id, {
195
- expiresAt: current.expires_at,
196
- timeoutMs,
197
- });
198
- await writeCompletedConversion({
199
- client,
200
- operation: completed,
201
- output,
202
- outFile: resolvedOutFile,
203
- });
204
- return;
205
- }
206
- if (verb !== 'convert' || !command[1])
207
- usage();
208
- const modelValue = stringFlag(flags, 'model');
209
- const model = modelValue === undefined
210
- ? undefined
211
- : isConversionModel(modelValue)
212
- ? modelValue
213
- : usage();
214
- const responsiveValue = stringFlag(flags, 'responsive-quality');
215
- if (responsiveValue !== undefined && !isResponsiveConversionQuality(responsiveValue)) {
216
- throw new Error(`--responsive-quality must be one of: ${RESPONSIVE_CONVERSION_QUALITIES.join(', ')}`);
217
- }
218
- const profile = await parseProjectProfileFlag(output, stringFlag(flags, 'profile'));
219
- const inputPath = path.resolve(command[1]);
220
- const localInput = classifyLocalConversionInput(inputPath);
221
- const outputWidth = parseImageOutputWidth(stringFlag(flags, 'width'));
222
- if (outputWidth !== undefined && localInput.kind === 'layerdoc') {
223
- throw new Error('--width is only valid for image input');
224
- }
225
- const sourceBytes = new Uint8Array(await readFile(inputPath));
226
- const inputBytes = outputWidth !== undefined && localInput.kind === 'image'
227
- ? await normalizeImageOutputWidth({
228
- bytes: sourceBytes,
229
- mediaType: localInput.mediaType,
230
- width: outputWidth,
231
- })
232
- : sourceBytes;
233
- const input = createInputForLocalFile({
234
- bytes: inputBytes,
235
- filePath: inputPath,
236
- output,
237
- ...(profile ? { profile } : {}),
238
- });
239
- const idempotencyKey = normalizeOptionalIdempotencyKey(stringFlag(flags, 'idempotency-key'), '--idempotency-key');
240
- if (input.layerdoc !== undefined && model)
241
- throw new Error('--model is only valid for image input');
242
- if (input.layerdoc !== undefined && responsiveValue) {
243
- throw new Error('--responsive-quality with LayerDoc input requires the SDK source-conversion workflow');
244
- }
245
- if (responsiveValue && output !== 'html') {
246
- throw new Error('--responsive-quality is only valid with --output html');
247
- }
248
- // --export asks for the responsive HTML export to run ALONGSIDE the
249
- // conversion in one blocking command, instead of the create-then-export
250
- // choreography that costs the two runs back to back.
251
- const exportValue = stringFlag(flags, 'export');
252
- if (exportValue !== undefined && exportValue !== 'html') {
253
- throw new Error('--export must be html');
254
- }
255
- const exportQualityValue = stringFlag(flags, 'export-quality');
256
- if (exportQualityValue !== undefined && !isResponsiveConversionQuality(exportQualityValue)) {
257
- throw new Error(`--export-quality must be one of: ${RESPONSIVE_CONVERSION_QUALITIES.join(', ')}`);
258
- }
259
- if (exportQualityValue !== undefined && exportValue === undefined) {
260
- throw new Error('--export-quality requires --export html');
261
- }
262
- const exportOutValue = stringFlag(flags, 'export-out');
263
- if (exportOutValue !== undefined && exportValue === undefined) {
264
- throw new Error('--export-out requires --export html');
265
- }
266
- if (exportValue !== undefined) {
267
- if (input.layerdoc !== undefined)
268
- throw new Error('--export requires image input');
269
- if (output !== 'layerdoc')
270
- throw new Error('--export requires --output layerdoc');
271
- }
272
- const exportHtml = exportValue === 'html'
273
- ? { ...(exportQualityValue ? { responsiveQuality: exportQualityValue } : {}) }
274
- : undefined;
275
- const conversionInput = input.layerdoc !== undefined
276
- ? input
277
- : {
278
- ...input,
279
- ...(model ? { model } : {}),
280
- ...(responsiveValue ? { responsiveQuality: responsiveValue } : {}),
281
- ...(exportHtml ? { exportHtml } : {}),
282
- };
283
- const detach = booleanFlag(flags, 'detach');
284
- const quiet = booleanFlag(flags, 'quiet');
285
- const created = await client.createConversion({
286
- ...conversionInput,
287
- ...(idempotencyKey ? { idempotencyKey } : {}),
288
- waitSeconds: detach ? 0 : 20,
289
- });
290
- if (detach) {
291
- const resumeCommand = `12ui resume ${created.id} --output ${output} --out <file>`;
292
- console.log(JSON.stringify({
293
- id: created.id,
294
- status: created.status,
295
- output: created.output,
296
- ...(created.export ? { export: created.export } : {}),
297
- expiresAt: created.expires_at,
298
- // A detached operation is the one case with nothing streaming, so the
299
- // response has to say how long it takes and how to collect it.
300
- nextAction: nextActionLine({
301
- what: 'A conversion',
302
- typicalSeconds: CONVERSION_DURATION_HINTS[created.export ? 'fused' : 'convert'],
303
- statusCommand: resumeCommand,
304
- waitHint: 'which blocks until it finishes and writes the result',
305
- }),
306
- }, null, 2));
307
- return;
308
- }
309
- const exportOperationId = created.export?.conversion_id ?? null;
310
- if (!quiet) {
311
- process.stderr.write(`12ui convert ${created.id}${exportOperationId ? ` (+ export ${exportOperationId})` : ''}`
312
- + ` — ${durationHint(exportOperationId ? 'fused' : 'convert')}\n`
313
- + `${nextActionLine({
314
- what: 'A conversion',
315
- typicalSeconds: CONVERSION_DURATION_HINTS[exportOperationId ? 'fused' : 'convert'],
316
- statusCommand: `12ui resume ${created.id} --output ${output} --out <file>`,
317
- waitHint: 'or leave this command running, which is what --wait already does by default',
318
- })}\n`);
319
- }
320
- const reporter = createProgressReporter({ label: 'convert', quiet });
321
- let operation;
322
- try {
323
- operation = created.status === 'succeeded'
324
- ? created
325
- : await client.waitForConversion(created.id, {
326
- expiresAt: created.expires_at,
327
- timeoutMs,
328
- onProgress: reporter.onProgress,
329
- });
330
- }
331
- catch (error) {
332
- const detail = error instanceof Error ? error.message : String(error);
333
- throw new Error(`Conversion ${created.id} failed: ${detail}`, { cause: error });
334
- }
335
- reporter.done(operation);
336
- // The proof that pairs these exact bytes with the conversion just bought, so
337
- // a later `12ui branch execute` from the same image attaches it instead of
338
- // buying viewport 1 of its source page a second time. It goes to the per-user
339
- // store rather than beside the image, so it is found from every copy of those
340
- // bytes. Best effort by design: a store that refuses the write costs a later
341
- // conversion and nothing else.
342
- if (input.layerdoc === undefined) {
343
- await recordConvertedImageReceipt({
344
- bytes: inputBytes,
345
- operation,
346
- ...(quiet ? {} : { warn: (message) => process.stderr.write(`${message}\n`) }),
347
- });
348
- }
349
- const outFile = path.resolve(stringFlag(flags, 'out') || defaultConversionOutputPath(inputPath, output));
350
- const result = await downloadCompletedConversion({ client, operation, output, outFile });
351
- if (!exportOperationId) {
352
- console.log(JSON.stringify(result, null, 2));
353
- return;
354
- }
355
- // The conversion is already on disk. An export that fails or is still
356
- // running after the budget must not take it back: the two halves are
357
- // separate operations and the conversion is the authoritative answer for its
358
- // own half.
359
- const exportReporter = createProgressReporter({ label: 'export', quiet });
360
- const exportOutFile = path.resolve(exportOutValue || defaultConversionOutputPath(inputPath, 'html'));
361
- let exportResult = null;
362
- let exportError = null;
363
- try {
364
- const exportOperation = await client.waitForConversion(exportOperationId, {
365
- expiresAt: created.expires_at,
366
- timeoutMs,
367
- onProgress: exportReporter.onProgress,
368
- });
369
- exportReporter.done(exportOperation);
370
- exportResult = await downloadCompletedConversion({
371
- client,
372
- operation: exportOperation,
373
- output: 'html',
374
- outFile: exportOutFile,
375
- });
376
- }
377
- catch (error) {
378
- exportError = error instanceof Error ? error.message : String(error);
379
- }
380
- console.log(JSON.stringify({
381
- ...result,
382
- export: exportResult
383
- ? { ...exportResult, status: 'succeeded' }
384
- : { id: exportOperationId, output: 'html', status: 'failed', error: exportError },
385
- }, null, 2));
386
- if (!exportResult) {
387
- throw new Error(`Conversion ${created.id} succeeded and was written to ${outFile}, but its responsive HTML`
388
- + ` export ${exportOperationId} did not: ${exportError}`);
389
- }
390
- };
391
- const main = async () => {
392
- const { command, flags } = parseCliArguments(process.argv.slice(2));
393
- if (booleanFlag(flags, 'help'))
394
- usage(0);
395
- if (booleanFlag(flags, 'version') || command[0] === 'version') {
396
- await printVersion();
397
- return;
398
- }
399
- if (command[0] === 'skill') {
400
- await runSkillCommand(command[1], flags);
401
- return;
402
- }
403
- if (command[0] === 'auth') {
404
- await runAuthCommand(command[1], flags);
405
- return;
406
- }
407
- if (command[0] === 'cli') {
408
- await runCliCommand(command[1], flags);
409
- return;
410
- }
411
- if (command[0] === 'corpus') {
412
- await runCorpusCommand(command[1], flags);
413
- return;
414
- }
415
- if (command[0] === 'image') {
416
- if (command[1] === 'generate-batch') {
417
- if (detaches(flags)) {
418
- const manifest = stringFlag(flags, 'manifest')?.trim();
419
- if (!manifest)
420
- throw new Error('--manifest is required');
421
- console.log(JSON.stringify(await detachImageBatch({
422
- cliPath: CLI_PATH,
423
- argv: process.argv.slice(2),
424
- manifestPath: path.resolve(manifest),
425
- typicalSeconds: OPERATION_DURATION_HINTS.imageBatch,
426
- }), null, 2));
427
- return;
428
- }
429
- await runImageBatchCommand(flags);
430
- }
431
- else if (command[1] === 'batch-status')
432
- await runImageBatchStatusCommand(flags);
433
- else
434
- await runImageCommand(command[1], flags);
435
- return;
436
- }
437
- if (command[0] === 'draft') {
438
- if (command[1] === 'status') {
439
- console.log(JSON.stringify(await runDraftStatusCommand(command[2], flags), null, 2));
440
- return;
441
- }
442
- await runDraftCommand(flags, {
443
- generate: async ({ manifestPath, detach }) => {
444
- if (!detach)
445
- return runImageBatchCommand({ ...flags, manifest: manifestPath });
446
- return console.log(JSON.stringify(await detachImageBatch({
447
- cliPath: CLI_PATH,
448
- argv: ['image', 'generate-batch', '--manifest', manifestPath],
449
- manifestPath,
450
- typicalSeconds: OPERATION_DURATION_HINTS.imageBatch,
451
- }), null, 2));
452
- },
453
- });
454
- return;
455
- }
456
- if (command[0] === 'select') {
457
- await runSelectCommand(command[1], flags);
458
- return;
459
- }
460
- if (command[0] === 'branch') {
461
- // `branch execute <run-dir>` — the directory `12ui draft` printed.
462
- const runDirArgument = command[2]?.trim();
463
- if ((command[1] === 'execute' || command[1] === 'resume') && detaches(flags)) {
464
- const resolved = await resolveBranchDirectory({
465
- ...(stringFlag(flags, 'out-dir')?.trim()
466
- ? { outDirFlag: stringFlag(flags, 'out-dir').trim() }
467
- : {}),
468
- ...(runDirArgument ? { runDirArgument } : {}),
469
- });
470
- console.log(JSON.stringify(await detachBranchRun({
471
- cliPath: CLI_PATH,
472
- argv: process.argv.slice(2),
473
- outDir: resolved.branchDir,
474
- typicalSeconds: stringFlag(flags, 'scope') === 'site'
475
- ? OPERATION_DURATION_HINTS.branchSite
476
- : OPERATION_DURATION_HINTS.branchPage,
477
- }), null, 2));
478
- return;
479
- }
480
- await runBranchCommand(command[1], flags, {
481
- ...(runDirArgument ? { runDirArgument } : {}),
482
- });
483
- return;
484
- }
485
- if (command[0] === 'export') {
486
- await runExportCommand(command[1], flags);
487
- return;
488
- }
489
- if (command[0] === 'capabilities') {
490
- printCapabilities();
491
- return;
492
- }
493
- await runConversionCommand(command, flags);
494
- };
495
- main().catch((error) => {
11
+ /** This file, as the worker re-executes it. */
12
+ const CLI_PATH = fileURLToPath(import.meta.url);
13
+ runCli(process.argv.slice(2), { cliPath: CLI_PATH }).catch((error) => {
496
14
  console.error(error instanceof Error ? error.message : String(error));
497
15
  process.exitCode = 1;
498
16
  });
package/dist/cli.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AACvD,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAEzC,OAAO,EAAE,8BAA8B,EAAE,MAAM,4BAA4B,CAAC;AAC5E,OAAO,EACL,WAAW,EACX,iBAAiB,EACjB,UAAU,GAEX,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AACvD,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAC3D,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AACzD,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AACrD,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAC3D,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAC3D,OAAO,EACL,oBAAoB,EACpB,0BAA0B,GAC3B,MAAM,8BAA8B,CAAC;AACtC,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AACzD,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAC3D,OAAO,EAAE,iBAAiB,EAAE,yBAAyB,EAA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C,CAAC,CAAC;IACtE,OAAO,CAAC,QAAQ,GAAG,CAAC,CAAC;AACvB,CAAC,CAAC,CAAC"}
@@ -0,0 +1,34 @@
1
+ /**
2
+ * One place decides what a concept may be, because the service decides it once.
3
+ *
4
+ * `cleanText` in `workers/api/src/create/validation.ts` collapses every run of
5
+ * whitespace to a single space, trims, and then counts CODE POINTS. Over the
6
+ * limit is rejected with a 400; it is never truncated. Both `POST /api/v1/create`
7
+ * and the same route's `source: "build"` claim (what `12ui branch execute`
8
+ * calls) measure it that way, and the build claim spends a metered plan call
9
+ * the moment it is accepted.
10
+ *
11
+ * The CLI has to measure it identically in both directions. Counting the raw
12
+ * text would refuse a wrapped `--concept-file` the service would have taken,
13
+ * and not counting it at all is how `12ui create claim` used to put an
14
+ * over-length brief on the wire and learn the limit from a 400 (2026-08-12).
15
+ */
16
+ export declare const MAX_CONCEPT_CHARACTERS = 600;
17
+ /** Exactly the service's normalization, so client and server count one string. */
18
+ export declare const normalizeConceptText: (value: string) => string;
19
+ /** Code points, not UTF-16 units: one emoji is one character to the service. */
20
+ export declare const conceptCharacterCount: (value: string) => number;
21
+ export type ConceptInput = {
22
+ /** Raw text, straight from `--concept` or a `--concept-file` read. */
23
+ value: string;
24
+ /** How to name the flag pair in a refusal, e.g. `--concept`. */
25
+ flag: string;
26
+ /** One clause naming where the cut detail belongs instead. */
27
+ trimHint: string;
28
+ };
29
+ /**
30
+ * Normalize and measure before anything is sent. Returns the exact text the
31
+ * caller should submit, so what was measured is what goes on the wire.
32
+ */
33
+ export declare const readConceptValue: (input: ConceptInput) => string;
34
+ //# sourceMappingURL=concept-input.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"concept-input.d.ts","sourceRoot":"","sources":["../src/concept-input.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,eAAO,MAAM,sBAAsB,MAAM,CAAC;AAE1C,kFAAkF;AAClF,eAAO,MAAM,oBAAoB,GAAI,OAAO,MAAM,KAAG,MAA4C,CAAC;AAElG,gFAAgF;AAChF,eAAO,MAAM,qBAAqB,GAAI,OAAO,MAAM,KAAG,MAA2B,CAAC;AAElF,MAAM,MAAM,YAAY,GAAG;IACzB,sEAAsE;IACtE,KAAK,EAAE,MAAM,CAAC;IACd,gEAAgE;IAChE,IAAI,EAAE,MAAM,CAAC;IACb,8DAA8D;IAC9D,QAAQ,EAAE,MAAM,CAAC;CAClB,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,gBAAgB,GAAI,OAAO,YAAY,KAAG,MAetD,CAAC"}
@@ -0,0 +1,41 @@
1
+ /**
2
+ * One place decides what a concept may be, because the service decides it once.
3
+ *
4
+ * `cleanText` in `workers/api/src/create/validation.ts` collapses every run of
5
+ * whitespace to a single space, trims, and then counts CODE POINTS. Over the
6
+ * limit is rejected with a 400; it is never truncated. Both `POST /api/v1/create`
7
+ * and the same route's `source: "build"` claim (what `12ui branch execute`
8
+ * calls) measure it that way, and the build claim spends a metered plan call
9
+ * the moment it is accepted.
10
+ *
11
+ * The CLI has to measure it identically in both directions. Counting the raw
12
+ * text would refuse a wrapped `--concept-file` the service would have taken,
13
+ * and not counting it at all is how `12ui create claim` used to put an
14
+ * over-length brief on the wire and learn the limit from a 400 (2026-08-12).
15
+ */
16
+ export const MAX_CONCEPT_CHARACTERS = 600;
17
+ /** Exactly the service's normalization, so client and server count one string. */
18
+ export const normalizeConceptText = (value) => value.replace(/\s+/gu, ' ').trim();
19
+ /** Code points, not UTF-16 units: one emoji is one character to the service. */
20
+ export const conceptCharacterCount = (value) => [...value].length;
21
+ /**
22
+ * Normalize and measure before anything is sent. Returns the exact text the
23
+ * caller should submit, so what was measured is what goes on the wire.
24
+ */
25
+ export const readConceptValue = (input) => {
26
+ const concept = normalizeConceptText(input.value);
27
+ if (!concept)
28
+ throw new Error(`${input.flag} must not be empty`);
29
+ const length = conceptCharacterCount(concept);
30
+ if (length <= MAX_CONCEPT_CHARACTERS)
31
+ return concept;
32
+ // The raw count is what the caller can see in their editor. Name the counted
33
+ // one when they differ, or the refusal looks like it is off by the newlines.
34
+ const measured = length === conceptCharacterCount(input.value)
35
+ ? `${length} characters`
36
+ : `${length} characters once its whitespace collapses`;
37
+ throw new Error(`${input.flag} is ${measured}; the limit is ${MAX_CONCEPT_CHARACTERS}.`
38
+ + ` Trim ${length - MAX_CONCEPT_CHARACTERS}. ${input.trimHint}`
39
+ + ' Nothing was sent and nothing was bought.');
40
+ };
41
+ //# sourceMappingURL=concept-input.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"concept-input.js","sourceRoot":"","sources":["../src/concept-input.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,MAAM,CAAC,MAAM,sBAAsB,GAAG,GAAG,CAAC;AAE1C,kFAAkF;AAClF,MAAM,CAAC,MAAM,oBAAoB,GAAG,CAAC,KAAa,EAAU,EAAE,CAAC,KAAK,CAAC,OAAO,CAAC,OAAO,EAAE,GAAG,CAAC,CAAC,IAAI,EAAE,CAAC;AAElG,gFAAgF;AAChF,MAAM,CAAC,MAAM,qBAAqB,GAAG,CAAC,KAAa,EAAU,EAAE,CAAC,CAAC,GAAG,KAAK,CAAC,CAAC,MAAM,CAAC;AAWlF;;;GAGG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,KAAmB,EAAU,EAAE;IAC9D,MAAM,OAAO,GAAG,oBAAoB,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;IAClD,IAAI,CAAC,OAAO;QAAE,MAAM,IAAI,KAAK,CAAC,GAAG,KAAK,CAAC,IAAI,oBAAoB,CAAC,CAAC;IACjE,MAAM,MAAM,GAAG,qBAAqB,CAAC,OAAO,CAAC,CAAC;IAC9C,IAAI,MAAM,IAAI,sBAAsB;QAAE,OAAO,OAAO,CAAC;IACrD,6EAA6E;IAC7E,6EAA6E;IAC7E,MAAM,QAAQ,GAAG,MAAM,KAAK,qBAAqB,CAAC,KAAK,CAAC,KAAK,CAAC;QAC5D,CAAC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