@12ui/design 0.2.13 → 0.2.15

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 (188) hide show
  1. package/README.md +35 -9
  2. package/dist/bounded-concurrency.d.ts +13 -0
  3. package/dist/bounded-concurrency.d.ts.map +1 -0
  4. package/dist/bounded-concurrency.js +43 -0
  5. package/dist/bounded-concurrency.js.map +1 -0
  6. package/dist/branch-client.d.ts +155 -0
  7. package/dist/branch-client.d.ts.map +1 -0
  8. package/dist/branch-client.js +179 -0
  9. package/dist/branch-client.js.map +1 -0
  10. package/dist/branch-completion.d.ts +37 -0
  11. package/dist/branch-completion.d.ts.map +1 -0
  12. package/dist/branch-completion.js +137 -0
  13. package/dist/branch-completion.js.map +1 -0
  14. package/dist/branch-dispatch-loop.d.ts +84 -0
  15. package/dist/branch-dispatch-loop.d.ts.map +1 -0
  16. package/dist/branch-dispatch-loop.js +206 -0
  17. package/dist/branch-dispatch-loop.js.map +1 -0
  18. package/dist/branch-downloads.d.ts +53 -0
  19. package/dist/branch-downloads.d.ts.map +1 -0
  20. package/dist/branch-downloads.js +114 -0
  21. package/dist/branch-downloads.js.map +1 -0
  22. package/dist/branch-execution-types.d.ts +54 -0
  23. package/dist/branch-execution-types.d.ts.map +1 -0
  24. package/dist/branch-execution-types.js +2 -0
  25. package/dist/branch-execution-types.js.map +1 -0
  26. package/dist/branch-execution.d.ts +20 -0
  27. package/dist/branch-execution.d.ts.map +1 -0
  28. package/dist/branch-execution.js +380 -0
  29. package/dist/branch-execution.js.map +1 -0
  30. package/dist/branch-identity.d.ts +71 -0
  31. package/dist/branch-identity.d.ts.map +1 -0
  32. package/dist/branch-identity.js +72 -0
  33. package/dist/branch-identity.js.map +1 -0
  34. package/dist/branch-materialize.d.ts +33 -0
  35. package/dist/branch-materialize.d.ts.map +1 -0
  36. package/dist/branch-materialize.js +64 -0
  37. package/dist/branch-materialize.js.map +1 -0
  38. package/dist/branch-page-conversion.d.ts +127 -0
  39. package/dist/branch-page-conversion.d.ts.map +1 -0
  40. package/dist/branch-page-conversion.js +382 -0
  41. package/dist/branch-page-conversion.js.map +1 -0
  42. package/dist/branch-plan.d.ts +63 -0
  43. package/dist/branch-plan.d.ts.map +1 -0
  44. package/dist/branch-plan.js +95 -0
  45. package/dist/branch-plan.js.map +1 -0
  46. package/dist/branch-progress.d.ts +99 -0
  47. package/dist/branch-progress.d.ts.map +1 -0
  48. package/dist/branch-progress.js +188 -0
  49. package/dist/branch-progress.js.map +1 -0
  50. package/dist/branch-run-record.d.ts +164 -0
  51. package/dist/branch-run-record.d.ts.map +1 -0
  52. package/dist/branch-run-record.js +94 -0
  53. package/dist/branch-run-record.js.map +1 -0
  54. package/dist/branch-schedule.d.ts +74 -0
  55. package/dist/branch-schedule.d.ts.map +1 -0
  56. package/dist/branch-schedule.js +130 -0
  57. package/dist/branch-schedule.js.map +1 -0
  58. package/dist/branch-status.d.ts +11 -0
  59. package/dist/branch-status.d.ts.map +1 -0
  60. package/dist/branch-status.js +118 -0
  61. package/dist/branch-status.js.map +1 -0
  62. package/dist/branch-viewport-normalization.d.ts +74 -0
  63. package/dist/branch-viewport-normalization.d.ts.map +1 -0
  64. package/dist/branch-viewport-normalization.js +120 -0
  65. package/dist/branch-viewport-normalization.js.map +1 -0
  66. package/dist/cli-arguments.d.ts.map +1 -1
  67. package/dist/cli-arguments.js +5 -0
  68. package/dist/cli-arguments.js.map +1 -1
  69. package/dist/cli-branch-command.d.ts +55 -0
  70. package/dist/cli-branch-command.d.ts.map +1 -0
  71. package/dist/cli-branch-command.js +475 -0
  72. package/dist/cli-branch-command.js.map +1 -0
  73. package/dist/cli-capabilities.d.ts +51 -0
  74. package/dist/cli-capabilities.d.ts.map +1 -1
  75. package/dist/cli-capabilities.js +52 -1
  76. package/dist/cli-capabilities.js.map +1 -1
  77. package/dist/cli-create-command.d.ts +21 -0
  78. package/dist/cli-create-command.d.ts.map +1 -0
  79. package/dist/cli-create-command.js +319 -0
  80. package/dist/cli-create-command.js.map +1 -0
  81. package/dist/cli-detach.d.ts +62 -0
  82. package/dist/cli-detach.d.ts.map +1 -0
  83. package/dist/cli-detach.js +123 -0
  84. package/dist/cli-detach.js.map +1 -0
  85. package/dist/cli-draft-command.d.ts +63 -0
  86. package/dist/cli-draft-command.d.ts.map +1 -0
  87. package/dist/cli-draft-command.js +220 -0
  88. package/dist/cli-draft-command.js.map +1 -0
  89. package/dist/cli-export-command.d.ts.map +1 -1
  90. package/dist/cli-export-command.js +2 -3
  91. package/dist/cli-export-command.js.map +1 -1
  92. package/dist/cli-image-batch-command.d.ts +21 -0
  93. package/dist/cli-image-batch-command.d.ts.map +1 -1
  94. package/dist/cli-image-batch-command.js +65 -4
  95. package/dist/cli-image-batch-command.js.map +1 -1
  96. package/dist/cli-image-batch-resume.d.ts +7 -0
  97. package/dist/cli-image-batch-resume.d.ts.map +1 -1
  98. package/dist/cli-image-batch-resume.js +19 -2
  99. package/dist/cli-image-batch-resume.js.map +1 -1
  100. package/dist/cli-package-command.d.ts +29 -0
  101. package/dist/cli-package-command.d.ts.map +1 -0
  102. package/dist/cli-package-command.js +128 -0
  103. package/dist/cli-package-command.js.map +1 -0
  104. package/dist/cli-progress.d.ts +137 -0
  105. package/dist/cli-progress.d.ts.map +1 -1
  106. package/dist/cli-progress.js +156 -0
  107. package/dist/cli-progress.js.map +1 -1
  108. package/dist/cli-select-command.d.ts +12 -0
  109. package/dist/cli-select-command.d.ts.map +1 -0
  110. package/dist/cli-select-command.js +66 -0
  111. package/dist/cli-select-command.js.map +1 -0
  112. package/dist/cli.js +150 -7
  113. package/dist/cli.js.map +1 -1
  114. package/dist/conversion-receipt.d.ts +127 -0
  115. package/dist/conversion-receipt.d.ts.map +1 -0
  116. package/dist/conversion-receipt.js +184 -0
  117. package/dist/conversion-receipt.js.map +1 -0
  118. package/dist/create-identity.d.ts +25 -0
  119. package/dist/create-identity.d.ts.map +1 -0
  120. package/dist/create-identity.js +0 -0
  121. package/dist/create-identity.js.map +1 -0
  122. package/dist/draft-identity.d.ts +30 -0
  123. package/dist/draft-identity.d.ts.map +1 -0
  124. package/dist/draft-identity.js +0 -0
  125. package/dist/draft-identity.js.map +1 -0
  126. package/dist/draft-prompts.d.ts +35 -0
  127. package/dist/draft-prompts.d.ts.map +1 -0
  128. package/dist/draft-prompts.js +51 -0
  129. package/dist/draft-prompts.js.map +1 -0
  130. package/dist/draft-run.d.ts +32 -0
  131. package/dist/draft-run.d.ts.map +1 -0
  132. package/dist/draft-run.js +152 -0
  133. package/dist/draft-run.js.map +1 -0
  134. package/dist/draft-workspace.d.ts +90 -0
  135. package/dist/draft-workspace.d.ts.map +1 -0
  136. package/dist/draft-workspace.js +64 -0
  137. package/dist/draft-workspace.js.map +1 -0
  138. package/dist/image-batch-status.d.ts +42 -0
  139. package/dist/image-batch-status.d.ts.map +1 -0
  140. package/dist/image-batch-status.js +142 -0
  141. package/dist/image-batch-status.js.map +1 -0
  142. package/dist/image-dimensions.d.ts +12 -0
  143. package/dist/image-dimensions.d.ts.map +1 -0
  144. package/dist/image-dimensions.js +14 -0
  145. package/dist/image-dimensions.js.map +1 -0
  146. package/dist/image-generation-resume.d.ts +13 -0
  147. package/dist/image-generation-resume.d.ts.map +1 -1
  148. package/dist/image-generation-resume.js +13 -0
  149. package/dist/image-generation-resume.js.map +1 -1
  150. package/dist/index.d.ts +6 -1
  151. package/dist/index.d.ts.map +1 -1
  152. package/dist/index.js +5 -1
  153. package/dist/index.js.map +1 -1
  154. package/dist/legacy-skill-catalog.d.ts.map +1 -1
  155. package/dist/legacy-skill-catalog.js +140 -0
  156. package/dist/legacy-skill-catalog.js.map +1 -1
  157. package/dist/package-client.d.ts +28 -0
  158. package/dist/package-client.d.ts.map +1 -1
  159. package/dist/package-client.js +21 -1
  160. package/dist/package-client.js.map +1 -1
  161. package/dist/package-manifest-file.d.ts +21 -0
  162. package/dist/package-manifest-file.d.ts.map +1 -0
  163. package/dist/package-manifest-file.js +119 -0
  164. package/dist/package-manifest-file.js.map +1 -0
  165. package/dist/package-manifest-template.d.ts +23 -0
  166. package/dist/package-manifest-template.d.ts.map +1 -0
  167. package/dist/package-manifest-template.js +60 -0
  168. package/dist/package-manifest-template.js.map +1 -0
  169. package/dist/package-source-refusal.d.ts +17 -0
  170. package/dist/package-source-refusal.d.ts.map +1 -0
  171. package/dist/package-source-refusal.js +61 -0
  172. package/dist/package-source-refusal.js.map +1 -0
  173. package/dist/package-submission.d.ts +134 -0
  174. package/dist/package-submission.d.ts.map +1 -0
  175. package/dist/package-submission.js +196 -0
  176. package/dist/package-submission.js.map +1 -0
  177. package/dist/selection-record.d.ts +95 -0
  178. package/dist/selection-record.d.ts.map +1 -0
  179. package/dist/selection-record.js +121 -0
  180. package/dist/selection-record.js.map +1 -0
  181. package/package.json +1 -1
  182. package/skills/design/SKILL.md +43 -266
  183. package/skills/design-branch/SKILL.md +37 -116
  184. package/skills/design-convert/SKILL.md +62 -148
  185. package/skills/design-draft/SKILL.md +71 -135
  186. package/skills/design-search/SKILL.md +29 -78
  187. package/skills/design/references/continuation-contract.md +0 -60
  188. package/skills/design/references/selection-contract.md +0 -112
@@ -0,0 +1,128 @@
1
+ import { stat } from 'node:fs/promises';
2
+ import path from 'node:path';
3
+ import { booleanFlag, stringFlag } from './cli-arguments.js';
4
+ import { readConversionConfig } from './config.js';
5
+ import { conversionPackageKey } from './branch-identity.js';
6
+ import { normalizeOptionalIdempotencyKey } from './idempotency-key.js';
7
+ import { TwelveUiConversionPackageClient } from './package-client.js';
8
+ import { readLocalPackageManifest } from './package-manifest-file.js';
9
+ import { PACKAGE_MANIFEST_TEMPLATE_NOTES, renderPackageManifestTemplate, } from './package-manifest-template.js';
10
+ import { PACKAGE_RESULT_FILENAME, submitConversionPackage, writePackageResultRecord, } from './package-submission.js';
11
+ import { createPackageProgressReporter, formatDuration, nextActionLine, } from './cli-progress.js';
12
+ /**
13
+ * `12ui convert package` — the ordered-viewport submission that had no CLI at
14
+ * all. Without it the terminal step of the branch path was the least supported
15
+ * operation in the product, and an agent that got that far fell back to
16
+ * per-image conversion, losing page order and stitching.
17
+ */
18
+ export const PACKAGE_USAGE = 'Usage: 12ui convert package --manifest <package.json>'
19
+ + ' --out-dir <directory> [--idempotency-key <key>] [--timeout-ms <ms>] [--wait] [--quiet]'
20
+ + '\n 12ui convert package --template > package.json';
21
+ /** A multi-viewport page converts its viewports in parallel, then composes. */
22
+ export const PACKAGE_DURATION_SECONDS = 360;
23
+ const parseTimeoutMs = (value) => {
24
+ if (value === undefined)
25
+ return undefined;
26
+ const timeoutMs = Number(value);
27
+ if (!Number.isFinite(timeoutMs) || timeoutMs < 1_000) {
28
+ throw new Error('--timeout-ms must be a number of at least 1000');
29
+ }
30
+ return Math.floor(timeoutMs);
31
+ };
32
+ const refuseExistingResult = async (outDir) => {
33
+ const existing = path.join(outDir, PACKAGE_RESULT_FILENAME);
34
+ try {
35
+ await stat(existing);
36
+ }
37
+ catch (error) {
38
+ if (error.code === 'ENOENT')
39
+ return;
40
+ throw error;
41
+ }
42
+ throw new Error(`A package result already exists at ${existing}. It names the package id and every page's`
43
+ + ' conversion id — read it back rather than submitting the same pages again, or choose a'
44
+ + ' new --out-dir if you genuinely want another package.');
45
+ };
46
+ /**
47
+ * `12ui convert package --template` prints the starting manifest and returns
48
+ * before any config read or network call, so it works with no credentials.
49
+ * Guidance goes to stderr and only the JSON reaches stdout, which is what makes
50
+ * `--template > package.json` write a file that parses.
51
+ *
52
+ * Returns false when the caller did not ask for the template, so the dispatcher
53
+ * falls through to the real submission. This lives beside the command rather
54
+ * than inline in the dispatcher so the argv path is reachable from a test.
55
+ */
56
+ export const runPackageTemplateCommand = (flags) => {
57
+ if (!booleanFlag(flags, 'template'))
58
+ return false;
59
+ process.stderr.write(`${PACKAGE_MANIFEST_TEMPLATE_NOTES}\n`);
60
+ process.stdout.write(renderPackageManifestTemplate());
61
+ return true;
62
+ };
63
+ export const runPackageCommand = async (flags, dependencies = {}) => {
64
+ const manifestFlag = stringFlag(flags, 'manifest')?.trim();
65
+ const outDirFlag = stringFlag(flags, 'out-dir')?.trim();
66
+ if (!manifestFlag || !outDirFlag)
67
+ throw new Error(PACKAGE_USAGE);
68
+ const manifestPath = path.resolve(manifestFlag);
69
+ const outDir = path.resolve(outDirFlag);
70
+ const quiet = booleanFlag(flags, 'quiet');
71
+ await refuseExistingResult(outDir);
72
+ const manifest = await readLocalPackageManifest(manifestPath);
73
+ const idempotencyKey = normalizeOptionalIdempotencyKey(stringFlag(flags, 'idempotency-key'), '--idempotency-key') ?? conversionPackageKey({
74
+ manifestSha256: manifest.manifestSha256,
75
+ output: manifest.output,
76
+ });
77
+ const config = (dependencies.readConfig ?? readConversionConfig)({
78
+ origin: stringFlag(flags, 'origin'),
79
+ apiKey: stringFlag(flags, 'api-key'),
80
+ });
81
+ const client = (dependencies.createClient ?? ((value) => (new TwelveUiConversionPackageClient(value))))(config);
82
+ const viewportCount = manifest.pages.reduce((total, page) => total + page.viewports.length, 0);
83
+ if (!quiet) {
84
+ process.stderr.write(`12ui convert package — ${manifest.pages.length} page(s), ${viewportCount} viewport(s)`
85
+ + ` to ${manifest.output}; expect about ${formatDuration(PACKAGE_DURATION_SECONDS)}\n`);
86
+ }
87
+ const startedAt = Date.now();
88
+ const reportProgress = createPackageProgressReporter({
89
+ write: (line) => { process.stderr.write(`${line}\n`); },
90
+ elapsed: () => formatDuration((Date.now() - startedAt) / 1000),
91
+ });
92
+ const result = await submitConversionPackage({
93
+ client,
94
+ outDir,
95
+ submission: {
96
+ output: manifest.output,
97
+ ...(manifest.model ? { model: manifest.model } : {}),
98
+ ...(manifest.responsiveQuality ? { responsiveQuality: manifest.responsiveQuality } : {}),
99
+ pages: manifest.pages,
100
+ idempotencyKey,
101
+ },
102
+ ...(parseTimeoutMs(stringFlag(flags, 'timeout-ms')) === undefined
103
+ ? {}
104
+ : { timeoutMs: parseTimeoutMs(stringFlag(flags, 'timeout-ms')) }),
105
+ onSubmitted: quiet
106
+ ? undefined
107
+ : (packageId) => {
108
+ process.stderr.write(`12ui convert package ${packageId} submitted.\n${nextActionLine({
109
+ what: 'A multi-viewport page conversion',
110
+ typicalSeconds: PACKAGE_DURATION_SECONDS,
111
+ statusCommand: `GET /api/v1/convert/package/${packageId}`,
112
+ waitHint: 'or leave this command running, which is what --wait already does by default',
113
+ })}\n`);
114
+ },
115
+ onProgress: quiet ? undefined : (event) => { reportProgress(undefined, event); },
116
+ });
117
+ const resultPath = await writePackageResultRecord(outDir, result);
118
+ const reported = { ...result, resultPath };
119
+ console.log(JSON.stringify({ manifestPath, outDir, ...reported }, null, 2));
120
+ const failed = reported.pages.filter((page) => page.status === 'failed');
121
+ if (failed.length > 0) {
122
+ throw new Error(`Package ${reported.packageId} converted ${reported.pages.length - failed.length} of`
123
+ + ` ${reported.pages.length} page(s). Failed: ${failed.map((page) => page.id).join(', ')}.`
124
+ + ` Evidence: ${resultPath}`);
125
+ }
126
+ return reported;
127
+ };
128
+ //# sourceMappingURL=cli-package-command.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cli-package-command.js","sourceRoot":"","sources":["../src/cli-package-command.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AACxC,OAAO,IAAI,MAAM,WAAW,CAAC;AAE7B,OAAO,EAAE,WAAW,EAAE,UAAU,EAAiB,MAAM,oBAAoB,CAAC;AAC5E,OAAO,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;AACnD,OAAO,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;AAC5D,OAAO,EAAE,+BAA+B,EAAE,MAAM,sBAAsB,CAAC;AACvE,OAAO,EAAE,+BAA+B,EAAE,MAAM,qBAAqB,CAAC;AACtE,OAAO,EAAE,wBAAwB,EAAE,MAAM,4BAA4B,CAAC;AACtE,OAAO,EACL,+BAA+B,EAC/B,6BAA6B,GAC9B,MAAM,gCAAgC,CAAC;AACxC,OAAO,EACL,uBAAuB,EACvB,uBA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AQ,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,MAAM,KAAK,QAAQ,CAAC,CAAC;IACzE,IAAI,MAAM,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QACtB,MAAM,IAAI,KAAK,CACb,WAAW,QAAQ,CAAC,SAAS,cAAc,QAAQ,CAAC,KAAK,CAAC,MAAM,GAAG,MAAM,CAAC,MAAM,KAAK;cACnF,IAAI,QAAQ,CAAC,KAAK,CAAC,MAAM,qBAAqB,MAAM,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG;cACzF,cAAc,UAAU,EAAE,CAC7B,CAAC;IACJ,CAAC;IACD,OAAO,QAAQ,CAAC;AAClB,CAAC,CAAC"}
@@ -20,9 +20,146 @@ export declare const CONVERSION_DURATION_HINTS: {
20
20
  readonly fused: 300;
21
21
  };
22
22
  export type ConversionDurationHintKind = keyof typeof CONVERSION_DURATION_HINTS;
23
+ /**
24
+ * Every long operation's typical wall time, in one place, so a status line, a
25
+ * skill sentence, and a capability document can never quote three different
26
+ * numbers for the same wait.
27
+ */
28
+ export declare const OPERATION_DURATION_HINTS: {
29
+ /** One generated candidate from the local image provider. */
30
+ readonly imageCandidate: 90;
31
+ /** Four candidates, started concurrently. */
32
+ readonly imageBatch: 90;
33
+ /** The build claim: the planner runs inline and buys no image. */
34
+ readonly branchClaim: 15;
35
+ /** One branch screen. The server's own provider budget is 150 s. */
36
+ readonly branchScreen: 90;
37
+ readonly branchScreenBudget: 150;
38
+ /**
39
+ * The screen-generation phase of a whole run. Viewport chains run in parallel
40
+ * across pages, so it tracks the depth of ONE page's chain rather than the
41
+ * screen count: measured median 3m22 over 49 four-page runs.
42
+ */
43
+ readonly branchScreenPhase: 202;
44
+ /** One branch page as one package. Measured median 2m10 over the same runs. */
45
+ readonly branchPackage: 130;
46
+ /** Downloads, the sentinel, and the final records. */
47
+ readonly branchFinalize: 15;
48
+ /**
49
+ * Whole runs, derived from the phases above by `branchRunEstimateSeconds` at
50
+ * the default page concurrency: one page for `--scope page`, four for
51
+ * `--scope site`. A test holds them to that derivation.
52
+ */
53
+ readonly branchPage: 362;
54
+ readonly branchSite: 492;
55
+ /** One `12ui convert package` submission, whose page count is not known here. */
56
+ readonly package: 360;
57
+ /** image -> LayerDoc. Extraction plus materialization. */
58
+ readonly convert: 240;
59
+ /** A responsive HTML export run on its own, after the conversion finished. */
60
+ readonly export: 240;
61
+ /**
62
+ * Fused convert + export. The export's reference and anchor conversions run
63
+ * alongside the conversion, so the bundle costs about the slower half plus
64
+ * assembly rather than the sum of both.
65
+ */
66
+ readonly fused: 300;
67
+ };
68
+ /**
69
+ * Three pages convert at a time. Each holds two or three viewport children on
70
+ * the server, so three pages sit just under the account's ~10 active
71
+ * conversions: a brief queue at the admission boundary is visible in the
72
+ * package's own published progress rather than looking like a stall. It lives
73
+ * beside the duration hints because the run estimate is a function of it.
74
+ */
75
+ export declare const BRANCH_PAGE_CONCURRENCY_DEFAULT = 3;
76
+ /**
77
+ * A whole branch run, decomposed rather than guessed: the claim, the screen
78
+ * phase, the page conversions — which run `concurrency` at a time and start as
79
+ * each page's own screens land — and the records at the end.
80
+ *
81
+ * The floor is the run whose conversions all overlap generation except the last
82
+ * one; the ceiling is the run where none of them do. Quoting the pair is what
83
+ * keeps a caller from reading the slower half of a normal distribution as a
84
+ * stall.
85
+ */
86
+ export declare const branchRunEstimateSeconds: (args: {
87
+ pages: number;
88
+ concurrency: number;
89
+ /** A run that stops at downloaded PNGs converts nothing. */
90
+ convert?: boolean;
91
+ }) => {
92
+ floor: number;
93
+ ceiling: number;
94
+ };
95
+ /** What `--scope site` plans in practice, for an estimate made before the plan. */
96
+ export declare const BRANCH_TYPICAL_SITE_PAGES = 4;
97
+ export type OperationDurationHintKind = keyof typeof OPERATION_DURATION_HINTS;
23
98
  export declare const formatDuration: (seconds: number) => string;
24
99
  export declare const durationHint: (kind: ConversionDurationHintKind) => string;
100
+ /**
101
+ * `45s elapsed, ~90s typical`. A bare elapsed time reads as a stall; the pair
102
+ * is what tells a caller the wait is still inside the expected envelope.
103
+ */
104
+ export declare const elapsedAgainstTypical: (elapsedSeconds: number, typicalSeconds: number) => string;
105
+ /**
106
+ * THE mandatory closing line of any output that is not yet terminal.
107
+ *
108
+ * A poll surface that answers with bare absence is what makes a model conclude
109
+ * the process stalled and improvise around it. Every not-yet-done response ends
110
+ * by naming the typical duration, the exact command that narrates progress, and
111
+ * the blocking alternative — so the caller can sleep, schedule, or block
112
+ * according to what it can actually do.
113
+ */
114
+ export declare const nextActionLine: (args: {
115
+ what: string;
116
+ typicalSeconds: number;
117
+ statusCommand: string;
118
+ checkAgainSeconds?: number;
119
+ waitHint?: string;
120
+ }) => string;
121
+ /** `3 complete, 2 generating, 4 waiting, 0 blocked` — zeros included on purpose. */
122
+ export declare const narrateCounts: (counts: readonly {
123
+ label: string;
124
+ count: number;
125
+ detail?: string;
126
+ }[]) => string;
127
+ export declare const secondsSince: (iso: string | undefined, now: number) => number | undefined;
25
128
  export declare const stageLabel: (stage: string) => string;
129
+ export type PackageStageProgress = {
130
+ stage: string;
131
+ percent?: number;
132
+ completed?: number;
133
+ total?: number;
134
+ running?: number;
135
+ stageSince?: string;
136
+ pagesAvailable?: number;
137
+ };
138
+ /**
139
+ * `converting viewports 32% — 1 of 3 viewports, 2 running, 1m 20s in stage`.
140
+ *
141
+ * A percent alone is the number that stalls: a phase whose children each take
142
+ * minutes reports the same figure for minutes, and an agent polling it decides
143
+ * the run is wedged. The counts and the time in phase are facts that keep
144
+ * advancing while the percent does not. Every one of them is optional, because
145
+ * a server that predates them answers without them and a renderer that demanded
146
+ * them would print nothing at all.
147
+ */
148
+ export declare const packageProgressLine: (progress: PackageStageProgress, now?: number) => string;
149
+ /**
150
+ * One writer for every package progress line, deduplicated per page.
151
+ *
152
+ * The poll revalidates every few seconds and mostly sees the same facts;
153
+ * repeating an unchanged line is how a stream stops reading as motion. When the
154
+ * server publishes its time in phase the line advances on its own, which is the
155
+ * point — a percent that has not moved is exactly when a caller needs to see
156
+ * that something still is.
157
+ */
158
+ export declare const createPackageProgressReporter: (args: {
159
+ write: (line: string) => void;
160
+ elapsed: () => string;
161
+ now?: () => number;
162
+ }) => ((pageId: string | undefined, progress: PackageStageProgress) => void);
26
163
  export type ProgressReporter = {
27
164
  onProgress: (operation: ConversionOperation) => void;
28
165
  /** Final line for a finished operation. */
@@ -1 +1 @@
1
- {"version":3,"file":"cli-progress.d.ts","sourceRoot":"","sources":["../src/cli-progress.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,wBAAwB,CAAC;AAElE;;;;;;;GAOG;AACH,eAAO,MAAM,yBAAyB;IACpC,0DAA0D;;IAE1D,8EAA8E;;IAE9E;;;;OAIG;;CAEK,CAAC;AAEX,MAAM,MAAM,0BAA0B,GAAG,MAAM,OAAO,yBAAyB,CAAC;AAEhF,eAAO,MAAM,cAAc,GAAI,SAAS,MAAM,KAAG,MAMhD,CAAC;AAEF,eAAO,MAAM,YAAY,GAAI,MAAM,0BAA0B,KAAG,MAE/D,CAAC;AAsBF,eAAO,MAAM,UAAU,GAAI,OAAO,MAAM,KAAG,MAAsC,CAAC;AAElF,MAAM,MAAM,gBAAgB,GAAG;IAC7B,UAAU,EAAE,CAAC,SAAS,EAAE,mBAAmB,KAAK,IAAI,CAAC;IACrD,2CAA2C;IAC3C,IAAI,EAAE,CAAC,SAAS,EAAE,mBAAmB,KAAK,IAAI,CAAC;CAChD,CAAC;AAEF;;;;;;GAMG;AACH,eAAO,MAAM,sBAAsB,GAAI,MAAM;IAC3C,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,KAAK,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;IAC/B,GAAG,CAAC,EAAE,MAAM,MAAM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,EAAE,MAAM,GAAG,SAAS,EAAE,QAAQ,EAAE,oBAAoB,KAAK,IAAI,CAQxE,CAAC;AAEF,MAAM,MAAM,gBAAgB,GAAG;IAC7B,UAAU,EAAE,CAAC,SAAS,EAAE,mBAAmB,KAAK,IAAI,CAAC;IACrD,2CAA2C;IAC3C,IAAI,EAAE,CAAC,SAAS,EAAE,mBAAmB,KAAK,IAAI,CAAC;CAChD,CAAC;AAEF;;;;;;GAMG;AACH,eAAO,MAAM,sBAAsB,GAAI,MAAM;IAC3C,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,KAAK,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;IAC/B,GAAG,CAAC,EAAE,MAAM,MAAM,CAAC;CACpB,KAAG,gBAsBH,CAAC"}
@@ -18,6 +18,74 @@ export const CONVERSION_DURATION_HINTS = {
18
18
  */
19
19
  fused: 300,
20
20
  };
21
+ /**
22
+ * Every long operation's typical wall time, in one place, so a status line, a
23
+ * skill sentence, and a capability document can never quote three different
24
+ * numbers for the same wait.
25
+ */
26
+ export const OPERATION_DURATION_HINTS = {
27
+ ...CONVERSION_DURATION_HINTS,
28
+ /** One generated candidate from the local image provider. */
29
+ imageCandidate: 90,
30
+ /** Four candidates, started concurrently. */
31
+ imageBatch: 90,
32
+ /** The build claim: the planner runs inline and buys no image. */
33
+ branchClaim: 15,
34
+ /** One branch screen. The server's own provider budget is 150 s. */
35
+ branchScreen: 90,
36
+ branchScreenBudget: 150,
37
+ /**
38
+ * The screen-generation phase of a whole run. Viewport chains run in parallel
39
+ * across pages, so it tracks the depth of ONE page's chain rather than the
40
+ * screen count: measured median 3m22 over 49 four-page runs.
41
+ */
42
+ branchScreenPhase: 202,
43
+ /** One branch page as one package. Measured median 2m10 over the same runs. */
44
+ branchPackage: 130,
45
+ /** Downloads, the sentinel, and the final records. */
46
+ branchFinalize: 15,
47
+ /**
48
+ * Whole runs, derived from the phases above by `branchRunEstimateSeconds` at
49
+ * the default page concurrency: one page for `--scope page`, four for
50
+ * `--scope site`. A test holds them to that derivation.
51
+ */
52
+ branchPage: 362,
53
+ branchSite: 492,
54
+ /** One `12ui convert package` submission, whose page count is not known here. */
55
+ package: 360,
56
+ };
57
+ /**
58
+ * Three pages convert at a time. Each holds two or three viewport children on
59
+ * the server, so three pages sit just under the account's ~10 active
60
+ * conversions: a brief queue at the admission boundary is visible in the
61
+ * package's own published progress rather than looking like a stall. It lives
62
+ * beside the duration hints because the run estimate is a function of it.
63
+ */
64
+ export const BRANCH_PAGE_CONCURRENCY_DEFAULT = 3;
65
+ /**
66
+ * A whole branch run, decomposed rather than guessed: the claim, the screen
67
+ * phase, the page conversions — which run `concurrency` at a time and start as
68
+ * each page's own screens land — and the records at the end.
69
+ *
70
+ * The floor is the run whose conversions all overlap generation except the last
71
+ * one; the ceiling is the run where none of them do. Quoting the pair is what
72
+ * keeps a caller from reading the slower half of a normal distribution as a
73
+ * stall.
74
+ */
75
+ export const branchRunEstimateSeconds = (args) => {
76
+ const base = OPERATION_DURATION_HINTS.branchClaim
77
+ + OPERATION_DURATION_HINTS.branchScreenPhase
78
+ + OPERATION_DURATION_HINTS.branchFinalize;
79
+ if (args.convert === false)
80
+ return { floor: base, ceiling: base };
81
+ const waves = Math.max(1, Math.ceil(Math.max(1, args.pages) / Math.max(1, args.concurrency)));
82
+ return {
83
+ floor: base + OPERATION_DURATION_HINTS.branchPackage,
84
+ ceiling: base + waves * OPERATION_DURATION_HINTS.branchPackage,
85
+ };
86
+ };
87
+ /** What `--scope site` plans in practice, for an estimate made before the plan. */
88
+ export const BRANCH_TYPICAL_SITE_PAGES = 4;
21
89
  export const formatDuration = (seconds) => {
22
90
  const whole = Math.max(0, Math.round(seconds));
23
91
  if (whole < 90)
@@ -27,6 +95,36 @@ export const formatDuration = (seconds) => {
27
95
  return rest === 0 ? `${minutes}m` : `${minutes}m ${rest}s`;
28
96
  };
29
97
  export const durationHint = (kind) => (`expect about ${formatDuration(CONVERSION_DURATION_HINTS[kind])}`);
98
+ /**
99
+ * `45s elapsed, ~90s typical`. A bare elapsed time reads as a stall; the pair
100
+ * is what tells a caller the wait is still inside the expected envelope.
101
+ */
102
+ export const elapsedAgainstTypical = (elapsedSeconds, typicalSeconds) => (`${formatDuration(elapsedSeconds)} elapsed, ~${formatDuration(typicalSeconds)} typical`);
103
+ /**
104
+ * THE mandatory closing line of any output that is not yet terminal.
105
+ *
106
+ * A poll surface that answers with bare absence is what makes a model conclude
107
+ * the process stalled and improvise around it. Every not-yet-done response ends
108
+ * by naming the typical duration, the exact command that narrates progress, and
109
+ * the blocking alternative — so the caller can sleep, schedule, or block
110
+ * according to what it can actually do.
111
+ */
112
+ export const nextActionLine = (args) => {
113
+ const checkAgain = formatDuration(args.checkAgainSeconds ?? Math.max(30, Math.round(args.typicalSeconds / 3)));
114
+ const wait = args.waitHint ?? 'or re-run the command with --wait to block until it finishes';
115
+ return `${args.what} typically takes about ${formatDuration(args.typicalSeconds)}.`
116
+ + ` Check again in ${checkAgain} with \`${args.statusCommand}\`, ${wait}.`;
117
+ };
118
+ /** `3 complete, 2 generating, 4 waiting, 0 blocked` — zeros included on purpose. */
119
+ export const narrateCounts = (counts) => counts
120
+ .map((entry) => `${entry.count} ${entry.label}${entry.detail ? ` (${entry.detail})` : ''}`)
121
+ .join(', ');
122
+ export const secondsSince = (iso, now) => {
123
+ if (!iso)
124
+ return undefined;
125
+ const started = Date.parse(iso);
126
+ return Number.isFinite(started) ? Math.max(0, (now - started) / 1000) : undefined;
127
+ };
30
128
  /** Human-readable name for a pipeline stage, for progress lines. */
31
129
  const STAGE_LABELS = {
32
130
  queued: 'queued',
@@ -45,8 +143,66 @@ const STAGE_LABELS = {
45
143
  static_export: 'rendering export',
46
144
  project_export: 'building project',
47
145
  publish: 'publishing',
146
+ // The package coordinator's own phases.
147
+ convert_viewports: 'converting viewports',
148
+ compose_pages: 'composing pages',
149
+ export_pages: 'exporting pages',
48
150
  };
49
151
  export const stageLabel = (stage) => STAGE_LABELS[stage] ?? stage;
152
+ /** What the current package phase counts. */
153
+ const STAGE_UNITS = {
154
+ convert_viewports: 'viewport',
155
+ compose_pages: 'page',
156
+ export_pages: 'page',
157
+ publish: 'page',
158
+ };
159
+ /**
160
+ * `converting viewports 32% — 1 of 3 viewports, 2 running, 1m 20s in stage`.
161
+ *
162
+ * A percent alone is the number that stalls: a phase whose children each take
163
+ * minutes reports the same figure for minutes, and an agent polling it decides
164
+ * the run is wedged. The counts and the time in phase are facts that keep
165
+ * advancing while the percent does not. Every one of them is optional, because
166
+ * a server that predates them answers without them and a renderer that demanded
167
+ * them would print nothing at all.
168
+ */
169
+ export const packageProgressLine = (progress, now = Date.now()) => {
170
+ const head = progress.percent === undefined
171
+ ? stageLabel(progress.stage)
172
+ : `${stageLabel(progress.stage)} ${progress.percent}%`;
173
+ const unit = STAGE_UNITS[progress.stage];
174
+ const facts = [];
175
+ if (progress.total !== undefined) {
176
+ facts.push(`${progress.completed ?? 0} of ${progress.total}${unit ? ` ${unit}${progress.total === 1 ? '' : 's'}` : ''}`);
177
+ }
178
+ if (progress.running !== undefined)
179
+ facts.push(`${progress.running} running`);
180
+ const inStage = secondsSince(progress.stageSince, now);
181
+ if (inStage !== undefined)
182
+ facts.push(`${formatDuration(inStage)} in stage`);
183
+ if (progress.pagesAvailable)
184
+ facts.push(`${progress.pagesAvailable} page(s) ready`);
185
+ return facts.length === 0 ? head : `${head} — ${facts.join(', ')}`;
186
+ };
187
+ /**
188
+ * One writer for every package progress line, deduplicated per page.
189
+ *
190
+ * The poll revalidates every few seconds and mostly sees the same facts;
191
+ * repeating an unchanged line is how a stream stops reading as motion. When the
192
+ * server publishes its time in phase the line advances on its own, which is the
193
+ * point — a percent that has not moved is exactly when a caller needs to see
194
+ * that something still is.
195
+ */
196
+ export const createPackageProgressReporter = (args) => {
197
+ const last = new Map();
198
+ return (pageId, progress) => {
199
+ const line = packageProgressLine(progress, (args.now ?? Date.now)());
200
+ if (last.get(pageId ?? '') === line)
201
+ return;
202
+ last.set(pageId ?? '', line);
203
+ args.write(`[${args.elapsed()}] package${pageId ? ` ${pageId}` : ''}: ${line}`);
204
+ };
205
+ };
50
206
  /**
51
207
  * Streams stage progress to stderr, one line per distinct stage/percent.
52
208
  *
@@ -1 +1 @@
1
- {"version":3,"file":"cli-progress.js","sourceRoot":"","sources":["../src/cli-progress.ts"],"names":[],"mappings":"AAEA;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,yBAAyB,GAAG;IACvC,0DAA0D;IAC1D,OAAO,EAAE,GAAG;IACZ,8EAA8E;IAC9E,MAAM,EAAE,GAAG;IACX;;;;OAIG;IACH,KAAK,EAAE,GAAG;CACF,CAAC;AAIX,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC,OAAe,EAAU,EAAE;IACxD,MAAM,KAAK,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC;IAC/C,IAAI,KAAK,GAAG,EAAE;QAAE,OAAO,GAAG,KAAK,GAAG,CAAC;IACnC,MAAM,OAAO,GAAG,IAAI,CAAC,KAAK,CAAC,KAAK,GAAG,EAAE,CAAC,CAAC;IACvC,MAAM,IAAI,GAAG,KAAK,GAAG,EAAE,CAAC;IACxB,OAAO,IAAI,KAAK,CAAC,CAAC,CAAC,CAAC,GAAG,OAAO,GAAG,CAAC,CAAC,CAAC,GAAG,OAAO,KAAK,IAAI,GAAG,CAAC;AAC7D,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,YAAY,GAAG,CAAC,IAAgC,EAAU,EAAE,CAAC,CACxE,gBAAgB,cAAc,CAAC,yBAAyB,CAAC,IAAI,CAAC,CAAC,EAAE,CAClE,CAAC;AAEF,oEAAoE;AACpE,MAAM,YAAY,GAA2B;IAC3C,MAAM,EAAE,QAAQ;IAChB,OAAO,EAAE,WAAW;IACpB,kBAAkB,EAAE,mBAAmB;IACvC,WAAW,EA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C,IAAI,IAAI,GAAG,EAAE,CAAC;IACd,MAAM,OAAO,GAAG,GAAW,EAAE,CAAC,cAAc,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,IAAI,IAAI,CAAC,GAAG,CAAC,EAAE,GAAG,SAAS,CAAC,GAAG,IAAI,CAAC,CAAC;IAC5F,OAAO;QACL,UAAU,EAAE,CAAC,SAAS,EAAE,EAAE;YACxB,IAAI,IAAI,CAAC,KAAK;gBAAE,OAAO;YACvB,MAAM,KAAK,GAAG,SAAS,CAAC,QAAQ,EAAE,KAAK,IAAI,SAAS,CAAC,MAAM,CAAC;YAC5D,MAAM,OAAO,GAAG,SAAS,CAAC,QAAQ,EAAE,OAAO,CAAC;YAC5C,MAAM,IAAI,GAAG,OAAO,KAAK,SAAS;gBAChC,CAAC,CAAC,GAAG,IAAI,CAAC,KAAK,KAAK,UAAU,CAAC,KAAK,CAAC,EAAE;gBACvC,CAAC,CAAC,GAAG,IAAI,CAAC,KAAK,KAAK,UAAU,CAAC,KAAK,CAAC,IAAI,OAAO,GAAG,CAAC;YACtD,IAAI,IAAI,KAAK,IAAI;gBAAE,OAAO;YAC1B,IAAI,GAAG,IAAI,CAAC;YACZ,KAAK,CAAC,IAAI,OAAO,EAAE,KAAK,IAAI,EAAE,CAAC,CAAC;QAClC,CAAC;QACD,IAAI,EAAE,CAAC,SAAS,EAAE,EAAE;YAClB,IAAI,IAAI,CAAC,KAAK;gBAAE,OAAO;YACvB,KAAK,CAAC,IAAI,OAAO,EAAE,KAAK,IAAI,CAAC,KAAK,KAAK,SAAS,CAAC,MAAM,EAAE,CAAC,CAAC;QAC7D,CAAC;KACF,CAAC;AACJ,CAAC,CAAC"}
@@ -0,0 +1,12 @@
1
+ import { type CliFlags } from './cli-arguments.js';
2
+ /**
3
+ * `12ui select` — the choice, recorded.
4
+ *
5
+ * The judgement stays the model's: it has to look at four images and say which
6
+ * one and why. Assembling the evidence around that judgement does not, and used
7
+ * to be a contract the skill asked an agent to fill in from four other files by
8
+ * hand.
9
+ */
10
+ export declare const SELECT_USAGE: string;
11
+ export declare const runSelectCommand: (runDirArgument: string | undefined, flags: CliFlags) => Promise<void>;
12
+ //# sourceMappingURL=cli-select-command.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cli-select-command.d.ts","sourceRoot":"","sources":["../src/cli-select-command.ts"],"names":[],"mappings":"AAAA,OAAO,EAAc,KAAK,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAQ/D;;;;;;;GAOG;AAEH,eAAO,MAAM,YAAY,QAC4D,CAAC;AAWtF,eAAO,MAAM,gBAAgB,GAC3B,gBAAgB,MAAM,GAAG,SAAS,EAClC,OAAO,QAAQ,KACd,OAAO,CAAC,IAAI,CA8Cd,CAAC"}
@@ -0,0 +1,66 @@
1
+ import { stringFlag } from './cli-arguments.js';
2
+ import { draftPaths, readDraftRecord } from './draft-workspace.js';
3
+ import { buildSelectionRecord, readSelectionRecord, writeSelectionRecord, } from './selection-record.js';
4
+ /**
5
+ * `12ui select` — the choice, recorded.
6
+ *
7
+ * The judgement stays the model's: it has to look at four images and say which
8
+ * one and why. Assembling the evidence around that judgement does not, and used
9
+ * to be a contract the skill asked an agent to fill in from four other files by
10
+ * hand.
11
+ */
12
+ export const SELECT_USAGE = 'Usage: 12ui select <run-dir> --winner <id> --reason <text>'
13
+ + ' [--recommended <id>] [--recommendation-source <text>] [--reject <id>=<reason>]';
14
+ /** `--reject B=too generic --reject C=illegible headline` */
15
+ const parseRejections = (flags) => {
16
+ const raw = stringFlag(flags, 'reject');
17
+ if (!raw)
18
+ return {};
19
+ const separator = raw.indexOf('=');
20
+ if (separator <= 0)
21
+ throw new Error('--reject must be <candidate-id>=<reason>');
22
+ return { [raw.slice(0, separator).trim()]: [raw.slice(separator + 1).trim()] };
23
+ };
24
+ export const runSelectCommand = async (runDirArgument, flags) => {
25
+ if (!runDirArgument)
26
+ throw new Error(SELECT_USAGE);
27
+ const winner = stringFlag(flags, 'winner')?.trim();
28
+ const reason = stringFlag(flags, 'reason')?.trim();
29
+ if (!winner || !reason)
30
+ throw new Error(SELECT_USAGE);
31
+ const paths = draftPaths(runDirArgument);
32
+ const draft = await readDraftRecord(paths.draftRecord);
33
+ if (!draft) {
34
+ throw new Error(`No draft run in ${paths.runDir} — there is nothing to select from, and nothing has failed.`
35
+ + ' Start one with `12ui draft --query "<product, audience, surface, goal, personality>"`.');
36
+ }
37
+ const existing = await readSelectionRecord(paths.selection);
38
+ if (existing) {
39
+ throw new Error(`A selection already exists at ${paths.selection}: candidate ${existing.winner}. Read it`
40
+ + ' rather than choosing again, or start a new draft to explore other directions.');
41
+ }
42
+ const recommended = stringFlag(flags, 'recommended')?.trim();
43
+ const record = await buildSelectionRecord({
44
+ draft,
45
+ winner,
46
+ reason,
47
+ recommendation: {
48
+ candidateId: recommended ?? null,
49
+ source: recommended ? stringFlag(flags, 'recommendation-source')?.trim() ?? 'run' : null,
50
+ },
51
+ rejectionReasons: parseRejections(flags),
52
+ });
53
+ await writeSelectionRecord(paths.selection, record);
54
+ console.log(JSON.stringify({
55
+ runDir: paths.runDir,
56
+ selection: paths.selection,
57
+ winner: record.winner,
58
+ winnerPath: record.candidates.find((candidate) => candidate.id === record.winner)?.path,
59
+ selectionSource: record.selectionSource,
60
+ nextAction: `Convert the winner alone with \`12ui convert ${paths.candidatesDir}/${record.winner}.png`
61
+ + ' --export html`, or grow the whole surface with'
62
+ + ` \`12ui branch execute ${paths.runDir} --concept "<what the rest must cover>"`
63
+ + ' --scope page|site --convert html`.',
64
+ }, null, 2));
65
+ };
66
+ //# sourceMappingURL=cli-select-command.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cli-select-command.js","sourceRoot":"","sources":["../src/cli-select-command.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAiB,MAAM,oBAAoB,CAAC;AAC/D,OAAO,EAAE,UAAU,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AACnE,OAAO,EACL,oBAAoB,EACpB,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