@12ui/design 0.2.54 → 0.2.56
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/SKILL.md +1 -1
- package/dist/cli-arguments.d.ts.map +1 -1
- package/dist/cli-arguments.js +2 -0
- package/dist/cli-arguments.js.map +1 -1
- package/dist/cli-conversion-derivation.d.ts +2 -1
- package/dist/cli-conversion-derivation.d.ts.map +1 -1
- package/dist/cli-conversion-derivation.js +9 -1
- package/dist/cli-conversion-derivation.js.map +1 -1
- package/dist/cli-convert-command.js +1 -1
- package/dist/cli-convert-command.js.map +1 -1
- package/dist/cli-draft-command.d.ts +11 -0
- package/dist/cli-draft-command.d.ts.map +1 -1
- package/dist/cli-draft-command.js +10 -1
- package/dist/cli-draft-command.js.map +1 -1
- package/dist/cli-help/design.d.ts +1 -1
- package/dist/cli-help/design.d.ts.map +1 -1
- package/dist/cli-help/design.js +8 -0
- package/dist/cli-help/design.js.map +1 -1
- package/dist/cli-help/index.d.ts +1 -1
- package/dist/cli-improve-command.d.ts.map +1 -1
- package/dist/cli-improve-command.js +257 -57
- package/dist/cli-improve-command.js.map +1 -1
- package/dist/cli-next-command.d.ts.map +1 -1
- package/dist/cli-next-command.js +44 -4
- package/dist/cli-next-command.js.map +1 -1
- package/dist/cli-usage.js +1 -1
- package/dist/improve-conversion-attempts.d.ts +92 -0
- package/dist/improve-conversion-attempts.d.ts.map +1 -0
- package/dist/improve-conversion-attempts.js +88 -0
- package/dist/improve-conversion-attempts.js.map +1 -0
- package/dist/improve-conversion-stage.d.ts +35 -0
- package/dist/improve-conversion-stage.d.ts.map +1 -0
- package/dist/improve-conversion-stage.js +381 -0
- package/dist/improve-conversion-stage.js.map +1 -0
- package/dist/improve-convert-resilience.d.ts +148 -0
- package/dist/improve-convert-resilience.d.ts.map +1 -0
- package/dist/improve-convert-resilience.js +266 -0
- package/dist/improve-convert-resilience.js.map +1 -0
- package/dist/improve-delivery-stages.d.ts +0 -6
- package/dist/improve-delivery-stages.d.ts.map +1 -1
- package/dist/improve-delivery-stages.js +5 -103
- package/dist/improve-delivery-stages.js.map +1 -1
- package/dist/improve-dom-diff.d.ts +2 -0
- package/dist/improve-dom-diff.d.ts.map +1 -1
- package/dist/improve-dom-diff.js +7 -0
- package/dist/improve-dom-diff.js.map +1 -1
- package/dist/improve-dom-gate.d.ts +7 -0
- package/dist/improve-dom-gate.d.ts.map +1 -1
- package/dist/improve-dom-gate.js +13 -0
- package/dist/improve-dom-gate.js.map +1 -1
- package/dist/improve-generation-stages.d.ts +3 -0
- package/dist/improve-generation-stages.d.ts.map +1 -1
- package/dist/improve-generation-stages.js +24 -7
- package/dist/improve-generation-stages.js.map +1 -1
- package/dist/improve-kit-assets.d.ts +129 -0
- package/dist/improve-kit-assets.d.ts.map +1 -0
- package/dist/improve-kit-assets.js +333 -0
- package/dist/improve-kit-assets.js.map +1 -0
- package/dist/improve-kit-readme.d.ts +11 -2
- package/dist/improve-kit-readme.d.ts.map +1 -1
- package/dist/improve-kit-readme.js +192 -21
- package/dist/improve-kit-readme.js.map +1 -1
- package/dist/improve-kit-stall.d.ts +67 -0
- package/dist/improve-kit-stall.d.ts.map +1 -0
- package/dist/improve-kit-stall.js +159 -0
- package/dist/improve-kit-stall.js.map +1 -0
- package/dist/improve-kit-status.d.ts +69 -0
- package/dist/improve-kit-status.d.ts.map +1 -0
- package/dist/improve-kit-status.js +145 -0
- package/dist/improve-kit-status.js.map +1 -0
- package/dist/improve-options.d.ts +13 -1
- package/dist/improve-options.d.ts.map +1 -1
- package/dist/improve-options.js +77 -15
- package/dist/improve-options.js.map +1 -1
- package/dist/improve-plan-annotated-render.d.ts +33 -0
- package/dist/improve-plan-annotated-render.d.ts.map +1 -0
- package/dist/improve-plan-annotated-render.js +175 -0
- package/dist/improve-plan-annotated-render.js.map +1 -0
- package/dist/improve-plan-annotator.d.ts +2 -1
- package/dist/improve-plan-annotator.d.ts.map +1 -1
- package/dist/improve-plan-annotator.js +21 -45
- package/dist/improve-plan-annotator.js.map +1 -1
- package/dist/improve-raster-layers-section.d.ts +21 -0
- package/dist/improve-raster-layers-section.d.ts.map +1 -0
- package/dist/improve-raster-layers-section.js +45 -0
- package/dist/improve-raster-layers-section.js.map +1 -0
- package/dist/improve-reset.d.ts +122 -0
- package/dist/improve-reset.d.ts.map +1 -0
- package/dist/improve-reset.js +141 -0
- package/dist/improve-reset.js.map +1 -0
- package/dist/improve-run-summary.d.ts +35 -0
- package/dist/improve-run-summary.d.ts.map +1 -0
- package/dist/improve-run-summary.js +134 -0
- package/dist/improve-run-summary.js.map +1 -0
- package/dist/improve-stage-runners.d.ts +2 -1
- package/dist/improve-stage-runners.d.ts.map +1 -1
- package/dist/improve-stage-runners.js +2 -1
- package/dist/improve-stage-runners.js.map +1 -1
- package/dist/improve-stage-shared.d.ts +6 -0
- package/dist/improve-stage-shared.d.ts.map +1 -1
- package/dist/improve-stage-shared.js.map +1 -1
- package/dist/improve-stop-handler.d.ts +73 -0
- package/dist/improve-stop-handler.d.ts.map +1 -0
- package/dist/improve-stop-handler.js +126 -0
- package/dist/improve-stop-handler.js.map +1 -0
- package/dist/improve-terminal-event.d.ts +118 -0
- package/dist/improve-terminal-event.d.ts.map +1 -0
- package/dist/improve-terminal-event.js +81 -0
- package/dist/improve-terminal-event.js.map +1 -0
- package/dist/improve-workspace.d.ts +25 -0
- package/dist/improve-workspace.d.ts.map +1 -1
- package/dist/improve-workspace.js +14 -0
- package/dist/improve-workspace.js.map +1 -1
- package/dist/legacy-skill-catalog.d.ts.map +1 -1
- package/dist/legacy-skill-catalog.js +23 -3
- package/dist/legacy-skill-catalog.js.map +1 -1
- package/dist/redesign-capture.d.ts +16 -0
- package/dist/redesign-capture.d.ts.map +1 -1
- package/dist/redesign-capture.js +49 -3
- package/dist/redesign-capture.js.map +1 -1
- package/dist/run-journal-unfinished.d.ts +56 -0
- package/dist/run-journal-unfinished.d.ts.map +1 -0
- package/dist/run-journal-unfinished.js +126 -0
- package/dist/run-journal-unfinished.js.map +1 -0
- package/dist/run-journal.d.ts +25 -1
- package/dist/run-journal.d.ts.map +1 -1
- package/dist/run-journal.js +15 -1
- package/dist/run-journal.js.map +1 -1
- package/open-design.json +2 -2
- package/package.json +1 -1
- package/skills/12ui-design/SKILL.md +2 -0
- package/skills/12ui-design/improve.md +68 -5
|
@@ -0,0 +1,381 @@
|
|
|
1
|
+
import { copyFile, cp, readFile, stat } from 'node:fs/promises';
|
|
2
|
+
import sharp from 'sharp';
|
|
3
|
+
import { runConversionCommand } from './cli-convert-command.js';
|
|
4
|
+
import { CliRefusal } from './cli-refusal.js';
|
|
5
|
+
import { prepareOutputDirectory } from './cli-output-paths.js';
|
|
6
|
+
import { fixedImproveHtml, improveConversionIdFromText, improveConvertRetryKey, improveConvertStallCount, improveConvertStallExhausted, improveConvertStallReason, improveConvertStallRetryAllowed, improveErrorText, improveStalled, IMPROVE_CONVERT_STALL_ATTEMPTS, IMPROVE_FRESH_ABANDON_REASON, prepareImproveTargetAttempt, resetImproveTargetAttempt, responsiveFallbackReason, } from './improve-convert-resilience.js';
|
|
7
|
+
import { improveFreshConversionKey, noteImproveConversionAttemptId, openImproveConversionAttempt, settleImproveConversionAttempt, startImproveConversionAttempt, } from './improve-conversion-attempts.js';
|
|
8
|
+
import { canvasOfDoc } from './improve-layerdoc-diff.js';
|
|
9
|
+
import { abandonImproveConversion, abandonImproveConversions, noteAbandonedAttempts, withoutImproveStages, } from './improve-reset.js';
|
|
10
|
+
import { improveSha256, noteImproveStage, } from './improve-stage-shared.js';
|
|
11
|
+
import { readImproveRecord, writeImproveRecord } from './improve-workspace.js';
|
|
12
|
+
export const runImproveConversion = async (args) => {
|
|
13
|
+
const artifacts = [];
|
|
14
|
+
const purchaseIds = [];
|
|
15
|
+
const runIds = [];
|
|
16
|
+
const collector = {
|
|
17
|
+
note: (facts) => {
|
|
18
|
+
artifacts.push(...(facts.artifacts ?? []));
|
|
19
|
+
purchaseIds.push(...(facts.purchased ?? []));
|
|
20
|
+
if (facts.runId) {
|
|
21
|
+
if (!runIds.includes(facts.runId))
|
|
22
|
+
args.onConversionId?.(facts.runId);
|
|
23
|
+
runIds.push(facts.runId);
|
|
24
|
+
}
|
|
25
|
+
args.journal?.note(facts);
|
|
26
|
+
},
|
|
27
|
+
heartbeat: (progress) => { args.journal?.heartbeat(progress); },
|
|
28
|
+
};
|
|
29
|
+
const flags = {
|
|
30
|
+
output: args.output,
|
|
31
|
+
...(args.model ? { model: args.model } : {}),
|
|
32
|
+
...(args.responsiveQuality ? { 'responsive-quality': args.responsiveQuality } : {}),
|
|
33
|
+
...(args.timeoutMs === undefined ? {} : { 'timeout-ms': String(args.timeoutMs) }),
|
|
34
|
+
'out-dir': args.outDir,
|
|
35
|
+
'idempotency-key': args.key,
|
|
36
|
+
quiet: true,
|
|
37
|
+
};
|
|
38
|
+
try {
|
|
39
|
+
await args.runner(['convert', args.input], flags, collector, { writeResult: () => undefined });
|
|
40
|
+
}
|
|
41
|
+
catch (error) {
|
|
42
|
+
throw new ImproveConvertAttemptError(error, {
|
|
43
|
+
artifacts: [...new Set(artifacts)],
|
|
44
|
+
purchaseIds: [...new Set(purchaseIds)],
|
|
45
|
+
runIds: [...new Set(runIds)],
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
return {
|
|
49
|
+
artifacts: [...new Set(artifacts)],
|
|
50
|
+
purchaseIds: [...new Set(purchaseIds)],
|
|
51
|
+
runIds: [...new Set(runIds)],
|
|
52
|
+
};
|
|
53
|
+
};
|
|
54
|
+
class ImproveConvertAttemptError extends Error {
|
|
55
|
+
attempt;
|
|
56
|
+
constructor(error, attempt) {
|
|
57
|
+
super(improveErrorText(error), { cause: error });
|
|
58
|
+
this.name = 'ImproveConvertAttemptError';
|
|
59
|
+
this.attempt = attempt;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* `--fresh` re-buys ONE conversion of the SAME settled winner under a new
|
|
64
|
+
* idempotency key. Capture, draft and pick stay settled and are not redrawn —
|
|
65
|
+
* `--redraw` is the flag for that.
|
|
66
|
+
*/
|
|
67
|
+
const recordFreshConversion = async (args) => {
|
|
68
|
+
const durable = await readImproveRecord(args.options.paths.record) ?? args.record;
|
|
69
|
+
const abandoned = await abandonImproveConversion({
|
|
70
|
+
record: durable,
|
|
71
|
+
reason: IMPROVE_FRESH_ABANDON_REASON,
|
|
72
|
+
warn: args.dependencies.warn ?? ((line) => { console.warn(line); }),
|
|
73
|
+
});
|
|
74
|
+
const record = withoutImproveStages(abandoned.record, ['convert', 'plan']);
|
|
75
|
+
await writeImproveRecord(args.options.paths.record, record);
|
|
76
|
+
return record;
|
|
77
|
+
};
|
|
78
|
+
export const runImproveConvertStage = async (args) => {
|
|
79
|
+
if (args.record.convert && !args.options.fresh)
|
|
80
|
+
return noteImproveStage({
|
|
81
|
+
record: args.record, stage: 'convert', priceCeilingUsd: args.price, replayed: true, write: true,
|
|
82
|
+
});
|
|
83
|
+
if (!args.record.pick && !args.record.target)
|
|
84
|
+
throw new Error('Cannot convert before pick');
|
|
85
|
+
await prepareOutputDirectory(args.options.paths.targetDir);
|
|
86
|
+
if (args.record.target?.kind === 'layerdoc') {
|
|
87
|
+
const bytes = await readFile(args.record.target.value);
|
|
88
|
+
canvasOfDoc(JSON.parse(bytes.toString('utf8')));
|
|
89
|
+
await copyFile(args.record.target.value, args.options.paths.targetLayerDoc);
|
|
90
|
+
const assetSource = `${args.record.target.value}.assets`;
|
|
91
|
+
if ((await stat(assetSource).catch(() => undefined))?.isDirectory()) {
|
|
92
|
+
await cp(assetSource, `${args.options.paths.targetLayerDoc}.assets`, { recursive: true });
|
|
93
|
+
}
|
|
94
|
+
let record = {
|
|
95
|
+
...args.record,
|
|
96
|
+
target: { ...args.record.target, sha256: improveSha256(bytes) },
|
|
97
|
+
convert: {
|
|
98
|
+
layerDoc: args.options.paths.targetLayerDoc,
|
|
99
|
+
html: '',
|
|
100
|
+
layout: 'document',
|
|
101
|
+
artifacts: [args.options.paths.targetLayerDoc],
|
|
102
|
+
purchaseIds: [],
|
|
103
|
+
},
|
|
104
|
+
};
|
|
105
|
+
record = await noteImproveStage({
|
|
106
|
+
record, stage: 'convert', priceCeilingUsd: args.price, replayed: false, write: false,
|
|
107
|
+
});
|
|
108
|
+
await writeImproveRecord(args.options.paths.record, record);
|
|
109
|
+
return record;
|
|
110
|
+
}
|
|
111
|
+
let recordBeforeConvert = args.options.fresh
|
|
112
|
+
? await recordFreshConversion(args)
|
|
113
|
+
: args.record;
|
|
114
|
+
let input = args.record.pick?.imagePath;
|
|
115
|
+
let inputSha = args.record.pick?.sha256;
|
|
116
|
+
if (args.record.target?.kind === 'image') {
|
|
117
|
+
const bytes = await readFile(args.record.target.value);
|
|
118
|
+
const image = sharp(bytes, { animated: false, failOn: 'warning' });
|
|
119
|
+
const metadata = await image.metadata();
|
|
120
|
+
if (!metadata.width || !metadata.height || !['png', 'jpeg', 'webp'].includes(metadata.format ?? '')) {
|
|
121
|
+
throw new CliRefusal('--target image is not a usable PNG, JPEG, or WebP', 'improve_target_invalid');
|
|
122
|
+
}
|
|
123
|
+
await image.png().toFile(args.options.paths.winnerImage);
|
|
124
|
+
input = args.options.paths.winnerImage;
|
|
125
|
+
inputSha = improveSha256(bytes);
|
|
126
|
+
recordBeforeConvert = { ...recordBeforeConvert, target: { ...args.record.target, sha256: inputSha } };
|
|
127
|
+
}
|
|
128
|
+
if (!input || !inputSha)
|
|
129
|
+
throw new Error('Improve has no design image to convert');
|
|
130
|
+
const targetIdentity = improveSha256(Buffer.from(`${inputSha}:${args.record.conversionModel}:${args.options.responsiveQuality}`)).slice(0, 32);
|
|
131
|
+
const baseKey = `improve-target:v2:${targetIdentity}`;
|
|
132
|
+
// How many conversions of this winner the kit has already bought and
|
|
133
|
+
// abandoned to a stall, and which of them to wait on now. A resume
|
|
134
|
+
// re-attaches to the NEWEST one — it is bought, it is still running, and it
|
|
135
|
+
// is the only way to get anything back for it — instead of rebuilding the
|
|
136
|
+
// base key and waiting out the whole bound on the first, oldest, already
|
|
137
|
+
// declared-dead conversion.
|
|
138
|
+
let bought = args.options.fresh ? 0 : improveConvertStallCount(recordBeforeConvert);
|
|
139
|
+
let index = Math.max(1, bought);
|
|
140
|
+
// WHICH CONVERSION THIS INVOCATION IS ABOUT TO WAIT ON. The attempt ledger
|
|
141
|
+
// decides, because it holds the exact key: a `--fresh` or retry attempt that
|
|
142
|
+
// was stopped mid-flight is reachable only through the key it was dispatched
|
|
143
|
+
// under, and the derived stall key below cannot express a nonce. Without it,
|
|
144
|
+
// `--from convert` rebuilt the base key, the server's dedupe handed back the
|
|
145
|
+
// older recorded conversion, and the fresh one kept running and kept billing
|
|
146
|
+
// with nothing able to collect it. The derived key stays the fallback for
|
|
147
|
+
// kits written before the ledger.
|
|
148
|
+
//
|
|
149
|
+
// Only an attempt minted for THIS winner counts: every recorded key is the
|
|
150
|
+
// base key plus a suffix, so the prefix is what says the conversion behind it
|
|
151
|
+
// is of the design this run is converting. A redraw or a re-pick already
|
|
152
|
+
// closes its attempts (`abandonImproveConversions`); this is the second lock
|
|
153
|
+
// on that door, because re-attaching to a conversion of a discarded design
|
|
154
|
+
// would deliver the wrong page and read as a replay.
|
|
155
|
+
const open = args.options.fresh ? undefined : openImproveConversionAttempt(recordBeforeConvert);
|
|
156
|
+
const resumed = open?.key.startsWith(`${baseKey}:`) ? open : undefined;
|
|
157
|
+
const nonce = args.freshConversionNonce;
|
|
158
|
+
if (args.options.fresh && !nonce) {
|
|
159
|
+
throw new Error('improve --fresh needs a per-invocation conversion nonce, so the conversion it dispatches'
|
|
160
|
+
+ ' can be recorded and resumed rather than orphaned');
|
|
161
|
+
}
|
|
162
|
+
const key = args.options.fresh && nonce
|
|
163
|
+
? improveFreshConversionKey(baseKey, nonce)
|
|
164
|
+
: resumed?.key ?? (index === 1 ? baseKey : improveConvertRetryKey(baseKey, index));
|
|
165
|
+
// The transaction is taken ONCE, outside the retry: a second
|
|
166
|
+
// `prepareImproveTargetAttempt` while the first backup exists would delete
|
|
167
|
+
// the previous good target instead of preserving it.
|
|
168
|
+
const transaction = await prepareImproveTargetAttempt(args.options.paths.targetDir);
|
|
169
|
+
const warn = args.dependencies.warn ?? ((line) => { console.warn(line); });
|
|
170
|
+
try {
|
|
171
|
+
// The hosted id joins its key on the record as soon as the conversion
|
|
172
|
+
// reports one, so a reader of `improve.json` alone can say which conversion
|
|
173
|
+
// a recorded key bought. Only ledger attempts have anywhere to put it, so
|
|
174
|
+
// the ordinary base-key path writes nothing extra. The writes are chained
|
|
175
|
+
// and drained before the stage writes the record itself: a stamp landing
|
|
176
|
+
// after the settled record would write a record that has no convert block.
|
|
177
|
+
let pendingLedgerWrite = Promise.resolve();
|
|
178
|
+
const rememberConversionId = (attemptKey, id) => {
|
|
179
|
+
const noted = noteImproveConversionAttemptId(recordBeforeConvert, {
|
|
180
|
+
key: attemptKey,
|
|
181
|
+
conversionId: id,
|
|
182
|
+
});
|
|
183
|
+
if (noted === recordBeforeConvert)
|
|
184
|
+
return;
|
|
185
|
+
recordBeforeConvert = noted;
|
|
186
|
+
pendingLedgerWrite = pendingLedgerWrite
|
|
187
|
+
.then(async () => writeImproveRecord(args.options.paths.record, recordBeforeConvert))
|
|
188
|
+
.catch((error) => {
|
|
189
|
+
warn(`[ledger] convert: could not record conversion ${id} against its key:`
|
|
190
|
+
+ ` ${improveErrorText(error)}`);
|
|
191
|
+
});
|
|
192
|
+
};
|
|
193
|
+
const attemptConversion = async (attemptKey) => runImproveConversion({
|
|
194
|
+
input,
|
|
195
|
+
outDir: args.options.paths.targetDir,
|
|
196
|
+
output: 'html',
|
|
197
|
+
model: args.record.conversionModel,
|
|
198
|
+
responsiveQuality: args.options.responsiveQuality,
|
|
199
|
+
timeoutMs: args.options.convertStallSeconds * 1_000,
|
|
200
|
+
key: attemptKey,
|
|
201
|
+
runner: args.dependencies.runConvert ?? runConversionCommand,
|
|
202
|
+
journal: args.dependencies.journal,
|
|
203
|
+
onConversionId: (id) => { rememberConversionId(attemptKey, id); },
|
|
204
|
+
}).catch(async (error) => {
|
|
205
|
+
const attempt = error instanceof ImproveConvertAttemptError
|
|
206
|
+
? error.attempt
|
|
207
|
+
: { artifacts: [], purchaseIds: [], runIds: [] };
|
|
208
|
+
const warning = responsiveFallbackReason(error);
|
|
209
|
+
const sourceConversionId = attempt.runIds[0]
|
|
210
|
+
?? improveConversionIdFromText(improveErrorText(error));
|
|
211
|
+
const layerDocPresent = (await stat(args.options.paths.targetLayerDoc).catch(() => undefined))?.isFile();
|
|
212
|
+
const assetsPresent = (await stat(`${args.options.paths.targetLayerDoc}.assets`).catch(() => undefined))?.isDirectory();
|
|
213
|
+
if (!warning || !sourceConversionId || !layerDocPresent || !assetsPresent)
|
|
214
|
+
throw error;
|
|
215
|
+
(args.dependencies.warn ?? console.warn)(`Responsive HTML was unavailable; deriving fixed-layout HTML free from ${sourceConversionId}`);
|
|
216
|
+
// The derivation is free, not unbounded. Passing no timeout dropped it
|
|
217
|
+
// through to waitForOperation's twenty-minute default while the docs
|
|
218
|
+
// promised `--convert-stall-seconds` bounds the conversion wait, so a
|
|
219
|
+
// wedged derivation hung the run for twenty minutes with no STALL.md —
|
|
220
|
+
// the pipedrive shape, on the one path the reader was told was bounded.
|
|
221
|
+
const fixed = await runImproveConversion({
|
|
222
|
+
input: sourceConversionId,
|
|
223
|
+
outDir: args.options.paths.targetDir,
|
|
224
|
+
output: 'html_fixed',
|
|
225
|
+
timeoutMs: args.options.convertStallSeconds * 1_000,
|
|
226
|
+
key: `improve-fixed:v1:${sourceConversionId}`,
|
|
227
|
+
runner: args.dependencies.runConvert ?? runConversionCommand,
|
|
228
|
+
journal: args.dependencies.journal,
|
|
229
|
+
});
|
|
230
|
+
const fixedOutput = await fixedImproveHtml(args.options.paths.targetDir);
|
|
231
|
+
args.dependencies.journal?.note({ degradations: ['improve_fixed_layout_fallback'] });
|
|
232
|
+
return {
|
|
233
|
+
artifacts: [...new Set([
|
|
234
|
+
...attempt.artifacts,
|
|
235
|
+
...fixed.artifacts,
|
|
236
|
+
args.options.paths.targetLayerDoc,
|
|
237
|
+
`${args.options.paths.targetLayerDoc}.assets`,
|
|
238
|
+
fixedOutput.html,
|
|
239
|
+
fixedOutput.assets,
|
|
240
|
+
])],
|
|
241
|
+
purchaseIds: [...new Set([...attempt.purchaseIds, ...fixed.purchaseIds])],
|
|
242
|
+
runIds: [...new Set([sourceConversionId, ...attempt.runIds, ...fixed.runIds])],
|
|
243
|
+
fallback: { html: fixedOutput.html, warning },
|
|
244
|
+
};
|
|
245
|
+
});
|
|
246
|
+
// ONE retry, and only for the stall with nothing to derive: the wait ended,
|
|
247
|
+
// no LayerDoc reached disk, so no fixed-layout fallback is possible and the
|
|
248
|
+
// stage has nothing at all. The guard is the LayerDoc on disk rather than
|
|
249
|
+
// the error text — if the conversion delivered, re-dispatching is pure
|
|
250
|
+
// waste of a second paid conversion.
|
|
251
|
+
//
|
|
252
|
+
// What is actually guaranteed, stated exactly: the default bound is twice
|
|
253
|
+
// the model's typical wall (see improveConvertStallDefaultSeconds), and an
|
|
254
|
+
// explicit --convert-stall-seconds is refused below one typical wall. So
|
|
255
|
+
// the retry sits outside the median by construction and inside no measured
|
|
256
|
+
// healthy population — nobody has measured P(convert half > bound | healthy)
|
|
257
|
+
// on the fused population, so it is a bound, not a proof.
|
|
258
|
+
//
|
|
259
|
+
// The budget belongs to the KIT, not to this process. Both the retry's
|
|
260
|
+
// identity and its count come from the durable ledgers, so a resume
|
|
261
|
+
// attaches to the conversion the retry actually dispatched instead of to
|
|
262
|
+
// the first, known-stalled one, and a kit that has already retried refuses
|
|
263
|
+
// to buy a third rather than dispatching one per resume forever.
|
|
264
|
+
let converted;
|
|
265
|
+
let convertedKey;
|
|
266
|
+
const retries = bought === 0 && improveConvertStallRetryAllowed(args.record.conversionModel)
|
|
267
|
+
? IMPROVE_CONVERT_STALL_ATTEMPTS - 1
|
|
268
|
+
: 0;
|
|
269
|
+
// Why an attempt is being dispatched, which is what the ledger records it
|
|
270
|
+
// as. A resume of a recorded attempt re-declares the reason it was opened
|
|
271
|
+
// with and dedupes to a no-op; the plain base key is not recorded at all.
|
|
272
|
+
const dispatchReason = (attempt) => {
|
|
273
|
+
if (attempt > 0)
|
|
274
|
+
return 'stall-retry';
|
|
275
|
+
if (args.options.fresh)
|
|
276
|
+
return 'fresh';
|
|
277
|
+
return resumed?.reason ?? (index === 1 ? undefined : 'stall-retry');
|
|
278
|
+
};
|
|
279
|
+
for (let attempt = 0; attempt <= retries; attempt += 1) {
|
|
280
|
+
const attemptKey = attempt === 0 ? key : improveConvertRetryKey(key, index);
|
|
281
|
+
// BEFORE THE DISPATCH, because a conversion nothing wrote down before it
|
|
282
|
+
// started is a conversion a stop cannot leave resumable. `--fresh` also
|
|
283
|
+
// walks away here from whatever attempt this kit still had open: it is
|
|
284
|
+
// buying a replacement for it, and an attempt left open would send the
|
|
285
|
+
// next resume back to the run this one supersedes.
|
|
286
|
+
const reason = dispatchReason(attempt);
|
|
287
|
+
if (reason) {
|
|
288
|
+
const started = startImproveConversionAttempt(recordBeforeConvert, {
|
|
289
|
+
key: attemptKey,
|
|
290
|
+
reason,
|
|
291
|
+
...(args.options.fresh ? { supersedes: IMPROVE_FRESH_ABANDON_REASON } : {}),
|
|
292
|
+
});
|
|
293
|
+
if (started.record !== recordBeforeConvert) {
|
|
294
|
+
recordBeforeConvert = noteAbandonedAttempts({
|
|
295
|
+
record: started.record,
|
|
296
|
+
attempts: started.superseded,
|
|
297
|
+
reason: IMPROVE_FRESH_ABANDON_REASON,
|
|
298
|
+
warn,
|
|
299
|
+
});
|
|
300
|
+
await writeImproveRecord(args.options.paths.record, recordBeforeConvert);
|
|
301
|
+
}
|
|
302
|
+
}
|
|
303
|
+
try {
|
|
304
|
+
converted = await attemptConversion(attemptKey);
|
|
305
|
+
convertedKey = attemptKey;
|
|
306
|
+
await pendingLedgerWrite;
|
|
307
|
+
break;
|
|
308
|
+
}
|
|
309
|
+
catch (error) {
|
|
310
|
+
await pendingLedgerWrite;
|
|
311
|
+
const layerDocPresent = (await stat(args.options.paths.targetLayerDoc)
|
|
312
|
+
.catch(() => undefined))?.isFile();
|
|
313
|
+
if (layerDocPresent || !improveStalled(error))
|
|
314
|
+
throw error;
|
|
315
|
+
// The stalled attempt knows its own id even when the record does not:
|
|
316
|
+
// nothing settled, so `recordedImproveConversionId` has nowhere to look.
|
|
317
|
+
const stalledId = (error instanceof ImproveConvertAttemptError
|
|
318
|
+
? error.attempt.runIds[0]
|
|
319
|
+
: undefined) ?? improveConversionIdFromText(improveErrorText(error));
|
|
320
|
+
// The attempt ledger closes with the conversion, by key: the run this
|
|
321
|
+
// key reaches is dead, and a later resume must not rebuild it.
|
|
322
|
+
const abandoned = await abandonImproveConversions({
|
|
323
|
+
record: recordBeforeConvert,
|
|
324
|
+
reason: improveConvertStallReason(args.options.convertStallSeconds),
|
|
325
|
+
...(stalledId ? { id: stalledId } : {}),
|
|
326
|
+
warn,
|
|
327
|
+
});
|
|
328
|
+
recordBeforeConvert = abandoned.record;
|
|
329
|
+
await writeImproveRecord(args.options.paths.record, recordBeforeConvert);
|
|
330
|
+
// The ledger is the source of truth, and it cannot record a stall whose
|
|
331
|
+
// id nothing reported. Taking the larger of the two keeps the next key
|
|
332
|
+
// distinct in that case without ever going backwards.
|
|
333
|
+
bought = Math.max(bought + 1, improveConvertStallCount(recordBeforeConvert));
|
|
334
|
+
index = bought + 1;
|
|
335
|
+
if (attempt >= retries) {
|
|
336
|
+
throw improveConvertStallExhausted({
|
|
337
|
+
seconds: args.options.convertStallSeconds,
|
|
338
|
+
bought,
|
|
339
|
+
model: args.record.conversionModel,
|
|
340
|
+
cause: error,
|
|
341
|
+
});
|
|
342
|
+
}
|
|
343
|
+
args.dependencies.journal?.note({ degradations: ['improve_convert_stall_retry'] });
|
|
344
|
+
warn(`[stall] convert: nothing materialized in ${args.options.convertStallSeconds}s;`
|
|
345
|
+
+ ' dispatching one fresh conversion of the same winner');
|
|
346
|
+
await resetImproveTargetAttempt(args.options.paths.targetDir);
|
|
347
|
+
}
|
|
348
|
+
}
|
|
349
|
+
if (!converted)
|
|
350
|
+
throw new Error('Improve conversion ended without a result');
|
|
351
|
+
const html = converted.fallback ? converted.fallback.html : args.options.paths.targetHtml;
|
|
352
|
+
for (const expected of [args.options.paths.targetLayerDoc, html]) {
|
|
353
|
+
if (!(await stat(expected).catch(() => undefined))?.isFile()) {
|
|
354
|
+
throw new Error(`Improve conversion completed without ${expected}`);
|
|
355
|
+
}
|
|
356
|
+
}
|
|
357
|
+
let record = settleImproveConversionAttempt({
|
|
358
|
+
...recordBeforeConvert,
|
|
359
|
+
convert: {
|
|
360
|
+
layerDoc: args.options.paths.targetLayerDoc,
|
|
361
|
+
html,
|
|
362
|
+
layout: converted.fallback ? 'fixed' : 'responsive',
|
|
363
|
+
...(converted.runIds[0] ? { sourceConversionId: converted.runIds[0] } : {}),
|
|
364
|
+
...(converted.fallback ? { responsiveWarning: converted.fallback.warning } : {}),
|
|
365
|
+
artifacts: converted.artifacts,
|
|
366
|
+
purchaseIds: converted.purchaseIds,
|
|
367
|
+
},
|
|
368
|
+
}, { ...(convertedKey === undefined ? {} : { key: convertedKey }) });
|
|
369
|
+
record = await noteImproveStage({
|
|
370
|
+
record, stage: 'convert', priceCeilingUsd: args.price, replayed: false, write: false,
|
|
371
|
+
});
|
|
372
|
+
await writeImproveRecord(args.options.paths.record, record);
|
|
373
|
+
await transaction.commit();
|
|
374
|
+
return record;
|
|
375
|
+
}
|
|
376
|
+
catch (error) {
|
|
377
|
+
await transaction.restore();
|
|
378
|
+
throw error;
|
|
379
|
+
}
|
|
380
|
+
};
|
|
381
|
+
//# sourceMappingURL=improve-conversion-stage.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"improve-conversion-stage.js","sourceRoot":"","sources":["../src/improve-conversion-stage.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,MAA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AChB,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,MAAM,WAAW,CAAC,OAAO,EAAE,CAAC;QAC5B,MAAM,KAAK,CAAC;IACd,CAAC;AACH,CAAC,CAAC"}
|
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
import type { ConversionModel } from './conversion-models.js';
|
|
2
|
+
import type { ImproveRecord } from './improve-workspace.js';
|
|
3
|
+
/**
|
|
4
|
+
* The fused median. It is what the wait was before a retry existed, and it is
|
|
5
|
+
* still the lower end of the default below.
|
|
6
|
+
*
|
|
7
|
+
* The premise that this bound did not cover `materializing_assets` does not
|
|
8
|
+
* survive the code: `waitForOperation` applies the deadline over the whole poll
|
|
9
|
+
* loop, stage-agnostic. Pipedrive is not a counter-example either — its
|
|
10
|
+
* conversion entered that stage about fifty minutes BEFORE the bound shipped,
|
|
11
|
+
* on 0.2.54.
|
|
12
|
+
*/
|
|
13
|
+
export declare const IMPROVE_RESPONSIVE_TIMEOUT_MS: number;
|
|
14
|
+
export declare const IMPROVE_TEMPORARY_UNAVAILABLE_RETRY_DELAY_MS = 30000;
|
|
15
|
+
/** At most one extra conversion, and only on a stall with nothing to derive. */
|
|
16
|
+
export declare const IMPROVE_CONVERT_STALL_ATTEMPTS = 2;
|
|
17
|
+
/**
|
|
18
|
+
* The floor `--convert-stall-seconds` refuses below: the conversion's own
|
|
19
|
+
* typical wall for the model in play. A bound inside the typical window would
|
|
20
|
+
* make the retry fire on a healthy run and buy the same design twice.
|
|
21
|
+
*
|
|
22
|
+
* `pro` has no measured hint of its own, so it borrows the standard wall and
|
|
23
|
+
* pays for that borrowing below: no automatic retry until somebody measures it.
|
|
24
|
+
*/
|
|
25
|
+
export declare const improveConvertStallFloorSeconds: (model: ConversionModel) => number;
|
|
26
|
+
/**
|
|
27
|
+
* The DEFAULT bound, which used to be the fused median alone — 300s against a
|
|
28
|
+
* standard conversion's own 240s typical wall, a ratio of 1.25. That is inside
|
|
29
|
+
* the healthy population by any reading, and it stopped being free the moment
|
|
30
|
+
* the stall bought a second conversion: a healthy-but-above-median convert half
|
|
31
|
+
* would cost double, and nothing measures P(convert half > 300s | healthy).
|
|
32
|
+
*
|
|
33
|
+
* So the default now obeys the rule the floor states: twice the model's typical
|
|
34
|
+
* wall, or the fused median, whichever is larger. Standard 480s, fast 300s. An
|
|
35
|
+
* explicit `--convert-stall-seconds` is still allowed down to the floor — a
|
|
36
|
+
* caller who wants the tighter bound can ask for it and owns the consequence.
|
|
37
|
+
*/
|
|
38
|
+
export declare const improveConvertStallDefaultSeconds: (model: ConversionModel) => number;
|
|
39
|
+
/**
|
|
40
|
+
* Whether the automatic retry may fire for this model.
|
|
41
|
+
*
|
|
42
|
+
* The retry's whole justification is that the bound sits outside the model's
|
|
43
|
+
* typical window, so it cannot fire on healthy work. `pro` has no measured
|
|
44
|
+
* typical wall — `CONVERSION_DURATION_HINTS` carries `convert` and
|
|
45
|
+
* `convertFast` and nothing else — so for pro that justification does not
|
|
46
|
+
* exist, and buying a second pro conversion on an unmeasured guess is the
|
|
47
|
+
* blind fix the study-first doctrine forbids. Pro stalls the way it did before
|
|
48
|
+
* the retry shipped: STALL.md, terminal event, recovery commands.
|
|
49
|
+
*/
|
|
50
|
+
export declare const improveConvertStallRetryAllowed: (model: ConversionModel) => boolean;
|
|
51
|
+
/** The reason every stall abandonment carries, and the prefix that counts them. */
|
|
52
|
+
export declare const IMPROVE_CONVERT_STALL_REASON = "convert stalled";
|
|
53
|
+
/** The reason `--fresh` writes when it rotates the base key away from a conversion. */
|
|
54
|
+
export declare const IMPROVE_FRESH_ABANDON_REASON = "fresh requested after recorded conversion remained unavailable";
|
|
55
|
+
export declare const improveConvertStallReason: (seconds: number) => string;
|
|
56
|
+
/**
|
|
57
|
+
* How many conversions this KIT has already bought and abandoned to a stall.
|
|
58
|
+
*
|
|
59
|
+
* The retry used to be bounded per process and keyed on `randomUUID()`, so
|
|
60
|
+
* nothing about it survived the invocation: on the resume STALL.md asks for,
|
|
61
|
+
* attempt 1 rebuilt the deterministic base key, the server's dedupe attached it
|
|
62
|
+
* to the FIRST, known-stalled conversion, and the run waited out the whole bound
|
|
63
|
+
* on a run it had already declared dead before dispatching a third under
|
|
64
|
+
* another random key. Counting the durable abandonments makes the retry's
|
|
65
|
+
* identity reproducible across invocations and makes the bound a property of
|
|
66
|
+
* the kit rather than of one shell.
|
|
67
|
+
*
|
|
68
|
+
* The attempt ledger is counted alongside them, and the larger wins: a stall
|
|
69
|
+
* whose conversion never reported an id cannot be abandoned by id, so counting
|
|
70
|
+
* abandonments alone read that spend as zero and let the next resume buy
|
|
71
|
+
* another retry, and the one after that, forever.
|
|
72
|
+
*/
|
|
73
|
+
export declare const improveConvertStallCount: (record: ImproveRecord) => number;
|
|
74
|
+
/**
|
|
75
|
+
* The idempotency key of the Nth conversion dispatched under one attempt key.
|
|
76
|
+
* The first is the key itself — the base key, or the `--fresh` key this
|
|
77
|
+
* invocation is spending — and every later one is derived from the count of
|
|
78
|
+
* stalls that preceded it, so two invocations of the same kit compute the same
|
|
79
|
+
* key for the same conversion even with no ledger to read.
|
|
80
|
+
*/
|
|
81
|
+
export declare const improveConvertRetryKey: (key: string, index: number) => string;
|
|
82
|
+
/** Why the resume reaches the conversion it reaches. */
|
|
83
|
+
export type ImproveResumeReason = 'settled' | 'fresh' | 'stall-retry' | 'fresh-rotated-away';
|
|
84
|
+
/** The id is absent when the attempt is recorded but never reported one. */
|
|
85
|
+
export type ImproveResumeConversion = {
|
|
86
|
+
id?: string;
|
|
87
|
+
reason: ImproveResumeReason;
|
|
88
|
+
};
|
|
89
|
+
/**
|
|
90
|
+
* The conversion a `--from convert` resume will attach to, read off the record.
|
|
91
|
+
*
|
|
92
|
+
* A resume never names an id. It rebuilds an idempotency key and the server's
|
|
93
|
+
* dedupe decides which conversion that key reaches, so this reads the key rules
|
|
94
|
+
* above backwards:
|
|
95
|
+
* - a settled convert block: the stage replays and buys nothing;
|
|
96
|
+
* - an open attempt in the ledger: the resume rebuilds the exact key that
|
|
97
|
+
* attempt was dispatched under, whether `--fresh` or the stall retry minted
|
|
98
|
+
* it, and lands back on the conversion it is still waiting for;
|
|
99
|
+
* - a kit that abandoned conversions to a stall with no ledger to read (one
|
|
100
|
+
* written before the ledger existed): `improveConvertRetryKey` reaches the
|
|
101
|
+
* newest of them, which is also what the base key reaches when only one was
|
|
102
|
+
* abandoned;
|
|
103
|
+
* - a kit whose base-key conversion `--fresh` rotated away from, again with no
|
|
104
|
+
* ledger: the resume rebuilds that base key and lands back on it.
|
|
105
|
+
*
|
|
106
|
+
* `fresh-rotated-away` is the only reading that leaves a conversion nothing can
|
|
107
|
+
* reach, and it now belongs to pre-ledger kits alone. The ledger is what ended
|
|
108
|
+
* it: the nonce is on the record before the conversion is dispatched.
|
|
109
|
+
*/
|
|
110
|
+
export declare const improveResumeConversion: (record: ImproveRecord) => ImproveResumeConversion | undefined;
|
|
111
|
+
/**
|
|
112
|
+
* The end of the line: this kit has spent every conversion the stall budget
|
|
113
|
+
* allows. It reads as a stall so the terminal event, `plan/STALL.md` and the
|
|
114
|
+
* recovery commands are all written exactly as a first stall's are.
|
|
115
|
+
*/
|
|
116
|
+
export declare const improveConvertStallExhausted: (args: {
|
|
117
|
+
seconds: number;
|
|
118
|
+
bought: number;
|
|
119
|
+
model: ConversionModel;
|
|
120
|
+
cause: unknown;
|
|
121
|
+
}) => Error;
|
|
122
|
+
export declare const improveErrorText: (error: unknown) => string;
|
|
123
|
+
export declare const isImproveTemporarilyUnavailable: (error: unknown) => boolean;
|
|
124
|
+
export declare const retryImproveTemporarilyUnavailable: <T>(args: {
|
|
125
|
+
stage: string;
|
|
126
|
+
action: () => Promise<T>;
|
|
127
|
+
sleep?: (milliseconds: number) => Promise<void>;
|
|
128
|
+
warn?: (line: string) => void;
|
|
129
|
+
}) => Promise<T>;
|
|
130
|
+
export declare const improveStalled: (error: unknown) => boolean;
|
|
131
|
+
export declare const improveConversionIdFromText: (value: string) => string | undefined;
|
|
132
|
+
export declare const recordedImproveConversionId: (record: ImproveRecord) => Promise<string | undefined>;
|
|
133
|
+
export declare const responsiveFallbackReason: (error: unknown) => string | undefined;
|
|
134
|
+
export declare const fixedImproveHtml: (targetDir: string) => Promise<{
|
|
135
|
+
html: string;
|
|
136
|
+
assets: string;
|
|
137
|
+
}>;
|
|
138
|
+
/**
|
|
139
|
+
* Clear the target directory between two attempts of the SAME transaction. The
|
|
140
|
+
* backup taken by `prepareImproveTargetAttempt` is untouched, so the previous
|
|
141
|
+
* good target is still recoverable; only the half-written attempt goes.
|
|
142
|
+
*/
|
|
143
|
+
export declare const resetImproveTargetAttempt: (targetDir: string) => Promise<void>;
|
|
144
|
+
export declare const prepareImproveTargetAttempt: (targetDir: string) => Promise<{
|
|
145
|
+
commit: () => Promise<void>;
|
|
146
|
+
restore: () => Promise<void>;
|
|
147
|
+
}>;
|
|
148
|
+
//# sourceMappingURL=improve-convert-resilience.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"improve-convert-resilience.d.ts","sourceRoot":"","sources":["../src/improve-convert-resilience.ts"],"names":[],"mappings":"AAWA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAC9D,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AAI5D;;;;;;;;;GASG;AACH,eAAO,MAAM,6BAA6B,QAA0C,CAAC;AACrF,eAAO,MAAM,4CAA4C,QAAS,CAAC;AAEnE,gFAAgF;AAChF,eAAO,MAAM,8BAA8B,IAAI,CAAC;AAEhD;;;;;;;GAOG;AACH,eAAO,MAAM,+BAA+B,GAAI,OAAO,eAAe,KAAG,MAExE,CAAC;AAEF;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,iCAAiC,GAAI,OAAO,eAAe,KAAG,MAG1E,CAAC;AAEF;;;;;;;;;;GAUG;AACH,eAAO,MAAM,+BAA+B,GAAI,OAAO,eAAe,KAAG,OAA0B,CAAC;AAEpG,mFAAmF;AACnF,eAAO,MAAM,4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