@i18nprune/core 0.1.0

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 (71) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +165 -0
  3. package/dist/adapters-gp1lXp0T.d.ts +12 -0
  4. package/dist/capabilities-x74cD2Hu.d.ts +48 -0
  5. package/dist/cleanup.d.ts +64 -0
  6. package/dist/cleanup.js +3999 -0
  7. package/dist/config.d.ts +201 -0
  8. package/dist/config.js +2865 -0
  9. package/dist/coreContext-DMaWLvmB.d.ts +388 -0
  10. package/dist/fs-BUYD8ZhA.d.ts +20 -0
  11. package/dist/generate.d.ts +487 -0
  12. package/dist/generate.js +9389 -0
  13. package/dist/humanEmit-ygNlYX-S.d.ts +79 -0
  14. package/dist/index-BQuLEQ9b.d.ts +7 -0
  15. package/dist/index-B_ow_Xvr.d.ts +97 -0
  16. package/dist/index-BgG01AKL.d.ts +287 -0
  17. package/dist/index-CIzZl4W8.d.ts +124 -0
  18. package/dist/index-Csm1w7XD.d.ts +58 -0
  19. package/dist/index-DLwTogCo.d.ts +43 -0
  20. package/dist/index-DVT26v11.d.ts +61 -0
  21. package/dist/index-DdjljwMj.d.ts +39 -0
  22. package/dist/index-DeIw-cZd.d.ts +52 -0
  23. package/dist/index-X50E1FIX.d.ts +50 -0
  24. package/dist/index.d.ts +9180 -0
  25. package/dist/index.js +21888 -0
  26. package/dist/init.d.ts +86 -0
  27. package/dist/init.js +848 -0
  28. package/dist/listWindow-XEFxQZi1.d.ts +30 -0
  29. package/dist/localeTargetCodes-BBIQjauw.d.ts +11 -0
  30. package/dist/locales.d.ts +39 -0
  31. package/dist/locales.js +2288 -0
  32. package/dist/missing-BVCvgUC8.d.ts +10 -0
  33. package/dist/missing.d.ts +85 -0
  34. package/dist/missing.js +5892 -0
  35. package/dist/modeResolve-cGVaY5Hh.d.ts +25 -0
  36. package/dist/path-Bfn3SAts.d.ts +11 -0
  37. package/dist/profile-BwOP9WKh.d.ts +9 -0
  38. package/dist/providers-0uMEfT6q.d.ts +82 -0
  39. package/dist/prune-c6hKZCv_.d.ts +33 -0
  40. package/dist/quality.d.ts +36 -0
  41. package/dist/quality.js +3868 -0
  42. package/dist/report-D5-6bVFj.d.ts +8 -0
  43. package/dist/report-schema.d.ts +102 -0
  44. package/dist/report-schema.js +42 -0
  45. package/dist/resumeCandidates-xR13eEwt.d.ts +200 -0
  46. package/dist/root-2-kCaBvQ.d.ts +1110 -0
  47. package/dist/runtime/edge.d.ts +21 -0
  48. package/dist/runtime/edge.js +87 -0
  49. package/dist/runtime/helpers/sync.d.ts +16 -0
  50. package/dist/runtime/helpers/sync.js +117 -0
  51. package/dist/runtime/node.d.ts +24 -0
  52. package/dist/runtime/node.js +204 -0
  53. package/dist/runtime/web.d.ts +21 -0
  54. package/dist/runtime/web.js +84 -0
  55. package/dist/shared.d.ts +1177 -0
  56. package/dist/shared.js +4897 -0
  57. package/dist/sourceContext-1LQg3HiQ.d.ts +36 -0
  58. package/dist/sourceSurface-mDtwGo1E.d.ts +122 -0
  59. package/dist/sync.d.ts +86 -0
  60. package/dist/sync.js +4971 -0
  61. package/dist/syncSegment-Bx6He2Mu.d.ts +149 -0
  62. package/dist/targets-EmtKyr6F.d.ts +23 -0
  63. package/dist/template-CGM-_WLT.d.ts +139 -0
  64. package/dist/translate-CIHYp7wi.d.ts +77 -0
  65. package/dist/types/shared.d.ts +21 -0
  66. package/dist/types/shared.js +1 -0
  67. package/dist/types.d.ts +1345 -0
  68. package/dist/types.js +1 -0
  69. package/dist/validate.d.ts +126 -0
  70. package/dist/validate.js +3717 -0
  71. package/package.json +128 -0
@@ -0,0 +1,487 @@
1
+ import { T as TranslateContext, a as TranslationTickProgressOptions, I as IdentityStreakGuard, b as TranslationTickProgressFn, P as ProviderAttemptOutcome, c as TranslateFailureOutcome, G as GenerateResumeRefContext, d as TranslateRunPartialStats, H as HandoffEligibilityRow, e as GenerateTranslateCache, f as GenerateResumeCandidateLeafInput } from './resumeCandidates-xR13eEwt.js';
2
+ import { C as CoreContext, T as TranslationSurfaceLeaf } from './coreContext-DMaWLvmB.js';
3
+ export { c as CoreResolvedPaths } from './coreContext-DMaWLvmB.js';
4
+ import { I as Issue } from './index-X50E1FIX.js';
5
+ import { L as LocaleMetadataReport } from './index-DLwTogCo.js';
6
+ import { T as TranslationProviderId } from './providers-0uMEfT6q.js';
7
+ import { a as RunEvent, R as RunEmitter } from './index-BgG01AKL.js';
8
+ import { b as TranslateTargetLanguage, c as Translator, R as ResolveLocaleLeafModeInput } from './index-B_ow_Xvr.js';
9
+ import { S as StringLeaf } from './index-BQuLEQ9b.js';
10
+ import { a as PreservePolicy, P as ParityPolicy, E as EffectiveReferenceConfig } from './root-2-kCaBvQ.js';
11
+ import { a as TranslateStartRateLimit } from './translate-CIHYp7wi.js';
12
+ import { r as resolveLocaleLeafMode } from './modeResolve-cGVaY5Hh.js';
13
+ import './adapters-gp1lXp0T.js';
14
+ import './capabilities-x74cD2Hu.js';
15
+ import './fs-BUYD8ZhA.js';
16
+ import './path-Bfn3SAts.js';
17
+ import 'zod';
18
+
19
+ declare function createCoreContext(input: {
20
+ config: CoreContext['config'];
21
+ adapters: CoreContext['adapters'];
22
+ env: CoreContext['env'];
23
+ paths: CoreContext['paths'];
24
+ configFileLoaded?: CoreContext['configFileLoaded'];
25
+ run?: CoreContext['run'];
26
+ cache?: CoreContext['cache'];
27
+ localeRead?: CoreContext['localeRead'];
28
+ }): CoreContext;
29
+ /** Project-wide ops pass this into {@link runTranslate} / translator helpers that only need the translate block. */
30
+ declare function translateContextFromCore(ctx: CoreContext): TranslateContext;
31
+
32
+ /** Display metadata for a generate target, resolved from the bundled language catalog. */
33
+ type GenerateLocaleDisplay = {
34
+ /** English label from catalog (falls back to target code). */
35
+ englishName: string;
36
+ /** Native endonym from catalog (falls back to target code). */
37
+ nativeName: string;
38
+ /** Layout direction from catalog or RTL heuristic. */
39
+ direction: 'ltr' | 'rtl';
40
+ };
41
+
42
+ /**
43
+ * Thrown when the streak guard decides not to proceed (cap reached + non-interactive, or
44
+ * the user declined the confirm prompt). The host catches this, prints a friendly notice,
45
+ * and surfaces a structured `i18nprune.translate.identity_streak_abort` issue.
46
+ */
47
+ declare class IdentityAbortError extends Error {
48
+ readonly command: string;
49
+ readonly target: string;
50
+ readonly threshold: number;
51
+ readonly count: number;
52
+ readonly path: string;
53
+ constructor(command: string, target: string, threshold: number, count: number, path: string);
54
+ }
55
+
56
+ /** Shared per-target counters for JSON payloads (CLI-compatible). */
57
+ type GenerateTargetProgressSummary = {
58
+ sourceLeafCount?: number;
59
+ processedLeafCount?: number;
60
+ translatedLeafCount?: number;
61
+ /** Present on **`generate --resume`** rows (leaves written this run). */
62
+ updatedLeafCount?: number;
63
+ preserveCount?: number;
64
+ paritySkipCount?: number;
65
+ forced?: boolean;
66
+ durationMs?: number;
67
+ requestAttempts?: number;
68
+ requestRetries?: number;
69
+ requestSuccesses?: number;
70
+ requestFailures?: number;
71
+ };
72
+ type GenerateProgressEmit = (e: Omit<Extract<RunEvent, {
73
+ type: 'run.progress.generate';
74
+ }>, 'op' | 'runId' | 'at'>) => void;
75
+ /** Session progress API produced by the host (CLI: {@link createSessionProgress}). */
76
+ type GenerateHostSession = {
77
+ readonly progress: {
78
+ tick(current: number, total: number, label: string, options?: TranslationTickProgressOptions): void;
79
+ pauseClock?(opts?: {
80
+ clearBar?: boolean;
81
+ }): void;
82
+ resumeClock?(): void;
83
+ };
84
+ finish(): void;
85
+ fail(): void;
86
+ };
87
+ /** Interactive choice when a target locale is only partially translated. */
88
+ type GeneratePartialTargetChoice = 'skip' | 'fill_missing' | 'retranslate_all';
89
+ type GenerateFinalizeSummaryInput = {
90
+ target: string;
91
+ englishName: string;
92
+ nativeName: string;
93
+ direction: 'ltr' | 'rtl';
94
+ targetPath: string;
95
+ leafCount: number;
96
+ /** When more than one segment file was written, finalize uses an aggregate summary line. */
97
+ wroteSegmentCount?: number;
98
+ dryRun?: boolean;
99
+ /** Pre-formatted locale line (e.g. `ar · Arabic · العربية · RTL`) when the host already resolved catalog labels. */
100
+ localeSubtitle?: string;
101
+ };
102
+ /**
103
+ * CLI / Worker wires TTY, prompts, progress bars, and JSON **`run.progress`** here — operation
104
+ * messages use the shared `RunEmitter` / `run.message` channel.
105
+ */
106
+ type GenerateHostHooks = {
107
+ emitProgress: GenerateProgressEmit;
108
+ emit?: RunEmitter;
109
+ runId?: string;
110
+ createSession: () => GenerateHostSession;
111
+ createIdentityStreakGuard: (target: string, clock: {
112
+ pauseClock?: () => void;
113
+ resumeClock?: () => void;
114
+ }) => IdentityStreakGuard;
115
+ buildTickProgressRelay: (input: {
116
+ tick: GenerateHostSession['progress']['tick'];
117
+ target: string;
118
+ translationMeta: {
119
+ providerId: TranslationProviderId;
120
+ translationModel?: string;
121
+ };
122
+ }) => TranslationTickProgressFn;
123
+ /** Optional decorative newline before provider-fallback warning (CLI cursor lift). */
124
+ beforeProviderFallbackWarn?: () => void;
125
+ shouldSkipInteractivePrompts: () => boolean;
126
+ canAskInteractive: () => boolean;
127
+ promptFullRetranslate: () => Promise<boolean>;
128
+ /**
129
+ * Target locale exists but is incomplete (missing segment files and/or keys vs source).
130
+ * Host should offer skip, fill missing keys/segments, or full re-translate.
131
+ */
132
+ promptPartialTargetGenerate: (input: {
133
+ target: string;
134
+ missingSegmentPaths: string[];
135
+ missingKeyPaths: string[];
136
+ }) => Promise<GeneratePartialTargetChoice>;
137
+ printPreserveParityReport: (preserveCount: number, paritySkip: number) => void;
138
+ printFinalizeSummary: (input: GenerateFinalizeSummaryInput) => void;
139
+ onIdentityAbortNotice: (err: IdentityAbortError, opts: {
140
+ dryRun: boolean;
141
+ }) => void;
142
+ };
143
+ type ProviderAttemptReportJson = {
144
+ providerId: TranslationProviderId;
145
+ /** Legacy coarse bucket for CLI summaries (`rate_limited` / `network_error` / `non_retryable_error` / `success`). */
146
+ outcome: ProviderAttemptOutcome;
147
+ /**
148
+ * Fine-grained failure taxonomy from {@link classifyTranslateFailure} — present on **failed**
149
+ * attempts only (`translate-policy (shipped)` step 8, `--json` `targetResults[].providerAttempts[]`).
150
+ */
151
+ translateFailureOutcome?: TranslateFailureOutcome;
152
+ };
153
+ /** One row in {@link GenerateJsonPayload.targetResults}. */
154
+ type GenerateTargetJsonRow = {
155
+ target: string;
156
+ status: 'written' | 'dry_run' | 'skipped_user_declined';
157
+ /** True when this target was written from a partial translate (policy / hook), not a full success. */
158
+ partial?: boolean;
159
+ /** Leaf values updated this run (**`generate --resume`** only). */
160
+ resumeUpdatedLeafCount?: number;
161
+ progress?: GenerateTargetProgressSummary;
162
+ sourceLeafCount?: number;
163
+ preserveCount?: number;
164
+ paritySkip?: number;
165
+ providerAttempts?: ProviderAttemptReportJson[];
166
+ winnerProviderId?: TranslationProviderId;
167
+ fallbackCount?: number;
168
+ markedForReview?: number;
169
+ paths?: {
170
+ /** Primary target locale path for single-file layouts. */
171
+ localeJson?: string;
172
+ /** Target locale segment paths for multi-file layouts (`locale_directory`). */
173
+ localeJsonPaths?: string[];
174
+ };
175
+ localeMetadata?: LocaleMetadataReport;
176
+ };
177
+ /** Payload inside `CliJsonEnvelope<'generate', …>` — stable JSON contract. */
178
+ type GenerateJsonPayload = {
179
+ kind: 'generate';
180
+ providerId?: TranslationProviderId;
181
+ dryRun: boolean;
182
+ force: boolean;
183
+ targets: string[];
184
+ dynamicKeySites: number;
185
+ leavesProcessed: number;
186
+ targetResults: GenerateTargetJsonRow[];
187
+ /** Present when at least one target was written from a partial run (`translate.policy.onIncompleteRun`). */
188
+ partial?: boolean;
189
+ /** Hint for topping up leaves after a partial write (stable contract string). */
190
+ resumeHint?: string;
191
+ /** Sum of {@link GenerateTargetJsonRow.markedForReview} across targets written as partial in this run. */
192
+ markedForReview?: number;
193
+ };
194
+ /**
195
+ * Per-call options for {@link runGenerate}. **`targets`** must be resolved by the host (interactive
196
+ * prompt or **`--target`** parse). Use **`resume`** (+ optional **`all`**) for top-up runs.
197
+ */
198
+ type GenerateRunOptions = {
199
+ readonly targets: readonly string[];
200
+ readonly dynamicKeySites: number;
201
+ readonly source?: string;
202
+ readonly provider?: string;
203
+ readonly workers?: number;
204
+ readonly force?: boolean;
205
+ readonly dryRun?: boolean;
206
+ readonly metadata?: boolean;
207
+ /** With **`--resume`**: confirm before processing targets. */
208
+ readonly ask?: boolean;
209
+ /**
210
+ * Top-up existing locale JSON (review-eligible leaves only). Requires existing **`&lt;target&gt;.json`**.
211
+ * Always combine with the **`--resume`** CLI flag — not a persisted config field.
212
+ */
213
+ readonly resume?: boolean;
214
+ /**
215
+ * CLI-built uncertain-prefix slice for resume eligibility; required when **`resume`** is true.
216
+ * Omitted on normal **`generate`** runs.
217
+ */
218
+ readonly resumeReference?: GenerateResumeRefContext;
219
+ /**
220
+ * When the CLI has already read the source JSON and emitted **`read_source`**, pass it here to avoid a
221
+ * second read and preserve **`run.progress`** ordering (**`read_source` → `resolve_targets`**).
222
+ */
223
+ readonly preloadedRaw?: unknown;
224
+ };
225
+ type GenerateRunResult = {
226
+ payload: GenerateJsonPayload;
227
+ /** Issues owned by generate (identity streak, empty-source warnings). Host merges discovery warnings. */
228
+ issues: Issue[];
229
+ };
230
+
231
+ /**
232
+ * Decision hooks for {@link runGenerate}. Pure type contracts: hosts implement them; core awaits
233
+ * each one at a defined consent point and the host's return value drives the run.
234
+ *
235
+ * Observability is intentionally **not** here — the existing `RunEmitter` / `RunEvent` surface
236
+ * carries `run.message`, `run.progress.generate`, `run.started`, `run.completed`, `run.summary`,
237
+ * and `run.failed`. New observability needs extend that union, not these hooks.
238
+ */
239
+
240
+ /**
241
+ * Why **`runGenerate`** stopped before all source leaves were translated. Hosts use this to choose
242
+ * the right copy in the prompt and the right default action.
243
+ */
244
+ type IncompleteRunReason =
245
+ /** Every provider in the chain was attempted; all failed with retryable errors (network / 5xx / rate-limit). */
246
+ 'provider_chain_exhausted'
247
+ /** Mid-run hard failure (non-retryable error from a provider). Partial JSON is in memory. */
248
+ | 'partial_after_non_retryable'
249
+ /** Every provider hit a rate-limit window and the run can't make forward progress without waiting. */
250
+ | 'rate_limit_persistent';
251
+ /** Information passed to {@link GenerateRunHooks.onIncomplete}. */
252
+ type IncompleteRunInfo = {
253
+ readonly target: string;
254
+ readonly reason: IncompleteRunReason;
255
+ readonly partial: TranslateRunPartialStats;
256
+ readonly successfulLeaves: number;
257
+ readonly failedLeaves: number;
258
+ readonly providerAttempts: readonly ProviderAttemptReportJson[];
259
+ readonly remainingProviderIds: readonly TranslationProviderId[];
260
+ readonly lastError?: {
261
+ readonly code: string;
262
+ readonly message: string;
263
+ };
264
+ };
265
+ /**
266
+ * Host's choice when {@link GenerateRunHooks.onIncomplete} is asked.
267
+ *
268
+ * - **`write_partial`** — keep what we have. **`metadata: true`** runs mark untranslated leaves
269
+ * **`needsReview: true`** so a later **`generate --resume`** can top them up.
270
+ * - **`abort_no_write`** — re-throw the last error; no file is written; matches today's default.
271
+ * - **`retry_provider`** — try another provider id from {@link IncompleteRunInfo.remainingProviderIds}
272
+ * with the partial state still in memory (no re-translation of completed leaves).
273
+ */
274
+ type IncompleteRunDecision = {
275
+ readonly action: 'write_partial';
276
+ } | {
277
+ readonly action: 'abort_no_write';
278
+ } | {
279
+ readonly action: 'retry_provider';
280
+ readonly providerId: TranslationProviderId;
281
+ };
282
+ /** Information passed to {@link GenerateRunHooks.onHandoffPick}. */
283
+ type HandoffOffer = {
284
+ readonly target: string;
285
+ readonly failedProviderId: TranslationProviderId;
286
+ readonly failureReason: 'rate_limited' | 'network_error' | 'non_retryable_error';
287
+ /** Classifier outcome for richer host copy (optional — legacy **`failureReason`** stays stable). */
288
+ readonly translateFailureOutcome?: TranslateFailureOutcome;
289
+ /** Config chain remainder (may be empty when **`routing: single`**). */
290
+ readonly remainingProviderIds: readonly TranslationProviderId[];
291
+ readonly partialStats: TranslateRunPartialStats;
292
+ /**
293
+ * Built-in catalogue pool eligible for rescue picks — **not** the same shape as **`remainingProviderIds`**
294
+ * (`translate-policy (shipped)` §8). Hosts render this list; **`onHandoffPick`** must return **`null`** (means
295
+ * “first **`eligibleHandoffRows`** entry”) or an id present in this list.
296
+ */
297
+ readonly eligibleHandoffRows: readonly HandoffEligibilityRow[];
298
+ };
299
+ /**
300
+ * Decision hooks for **`runGenerate`**. Each is optional; omitting one means "use core's default
301
+ * for that consent point" (see **`translate.policy`** merge in core).
302
+ *
303
+ * Hosts that need full UX (CLI prompt, web modal, etc.) supply these. Headless hosts (CI, Worker,
304
+ * SDK) often omit **`onIncomplete`** so **`onIncompleteRun: 'confirm'`** defaults to **`write_partial`**
305
+ * in core, or set **`onIncompleteRun: 'write'`** / **`'discard'`** for policy-only behavior.
306
+ */
307
+ type GenerateRunHooks = {
308
+ /**
309
+ * Invoked only when **`translate.policy.onIncompleteRun`** is **`'confirm'`** and a target stops
310
+ * before every leaf finished. Return **`write_partial`** to finalize and write in-memory JSON, or
311
+ * **`abort_no_write`** to rethrow the last error. **`retry_provider`** is reserved (throws if returned).
312
+ * For **`onIncompleteRun: 'write'`** or **`'discard'`**, core does not call **`onIncomplete`**.
313
+ */
314
+ readonly onIncomplete?: (info: IncompleteRunInfo) => Promise<IncompleteRunDecision>;
315
+ /**
316
+ * Mid-run picker for **`prompt`** verbs (`quota_exceeded · prompt`, **`onAuthFailure: prompt`**, …).
317
+ * Return **`null`** to accept the default (**first **`eligibleHandoffRows`** row**). Any non-null id
318
+ * must appear in **`offer.eligibleHandoffRows`**.
319
+ */
320
+ readonly onHandoffPick?: (offer: HandoffOffer) => Promise<TranslationProviderId | null>;
321
+ };
322
+
323
+ /**
324
+ * Public **`runGenerate`** — project-scoped generate: read source locale, walk targets, run per-provider
325
+ * translate+normalize, write files. Host supplies TTY / prompts / progress via {@link GenerateHostHooks}.
326
+ */
327
+
328
+ declare function runGenerate(ctx: CoreContext, opts: GenerateRunOptions, host: GenerateHostHooks, hooks?: GenerateRunHooks): Promise<GenerateRunResult>;
329
+
330
+ /**
331
+ * Stable human-readable finalize lines for generate (locale identity + write summary).
332
+ * Hosts map {@link GenerateFinalizeSummaryInput.localeSubtitle} from catalog metadata; core owns wording only.
333
+ */
334
+ declare function formatGenerateFinalizeSummaryLines(input: GenerateFinalizeSummaryInput & {
335
+ localeSubtitle: string;
336
+ }): string[];
337
+
338
+ /**
339
+ * Resolve English/native labels and layout direction for a generate target.
340
+ *
341
+ * @remarks Pure — catalog + heuristics only; no flags or sidecar files.
342
+ */
343
+ declare function resolveLocaleDirection(targetCode: string, catalogDirection?: unknown): 'ltr' | 'rtl';
344
+ /**
345
+ * @param targetCode - BCP-47-ish locale code being generated.
346
+ * @param catalogEntry - Row from `languages.json` when the code is catalog-backed.
347
+ */
348
+ declare function resolveGenerateLocaleDisplay(targetCode: string, catalogEntry?: TranslateTargetLanguage): GenerateLocaleDisplay;
349
+
350
+ /**
351
+ * Walk source leaves: preserve / parity rules, then translate or copy into `working` object.
352
+ * Callers supply `Translator`, policies, and progress hooks (CLI wires TTY / `run.progress` here).
353
+ */
354
+ declare function buildTranslatedLocaleFromSourceLeaves(input: {
355
+ sourceLeaves: readonly StringLeaf[];
356
+ working: unknown;
357
+ existingRaw: unknown | null;
358
+ preserve?: PreservePolicy;
359
+ parity?: ParityPolicy;
360
+ dryRun: boolean;
361
+ force: boolean;
362
+ provider: Translator;
363
+ /** When true, write `{ value, status, … }` leaves using merged {@link translateLeaf} metadata. */
364
+ persistStructuredLeafMetadata: boolean;
365
+ providerId: TranslationProviderId;
366
+ /** BCP-47-ish source tag passed to **`translateLeaf`** (default **`en`**). */
367
+ sourceLang?: string;
368
+ targetLang: string;
369
+ /** Per-run L1 memo; omitted when host bypassed cache (`--no-cache`). */
370
+ translationCache?: GenerateTranslateCache;
371
+ /** Max in-flight **`translateLeaf`** calls; **1** keeps serial semantics (default). */
372
+ maxParallelTranslates?: number;
373
+ rateLimit?: TranslateStartRateLimit;
374
+ tickProgress: TranslationTickProgressFn;
375
+ onTranslatedLeaf?: (sourceText: string, translatedText: string, path: string) => Promise<void> | void;
376
+ }): Promise<{
377
+ working: unknown;
378
+ preserveCount: number;
379
+ paritySkip: number;
380
+ /** Leaf paths whose source **value** was whitespace-only — copied without calling the translator. */
381
+ emptySourceLeafPaths: readonly string[];
382
+ translateStats: TranslateRunPartialStats;
383
+ /** Count of translated leaves classified as review-needed by policy/meta pipeline. */
384
+ markedForReview: number;
385
+ }>;
386
+ /** Re-scan paths that still exist after deletes (cleanup helper). */
387
+ declare function localeJsonHasKeyPath(data: unknown, keyPath: string): boolean;
388
+ /**
389
+ * **`generate --resume`**: walk review leaves, translate candidates that still match source, update JSON.
390
+ */
391
+ declare function translateResumeCandidateLeaves(input: {
392
+ tLeaves: readonly TranslationSurfaceLeaf[];
393
+ next: unknown;
394
+ sourceMap: Map<string, string>;
395
+ refCtx: GenerateResumeRefContext;
396
+ eff: EffectiveReferenceConfig;
397
+ preserve?: PreservePolicy;
398
+ parity?: ParityPolicy;
399
+ provider: Translator;
400
+ providerId: TranslationProviderId;
401
+ /** BCP-47-ish source tag passed to **`translateLeaf`** (default **`en`**). */
402
+ sourceLang?: string;
403
+ persistStructuredLeafMetadata: boolean;
404
+ target: string;
405
+ dryRun: boolean;
406
+ maxParallelTranslates?: number;
407
+ rateLimit?: TranslateStartRateLimit;
408
+ /** Per-run L1 memo; omitted when host bypassed cache (`--no-cache`). */
409
+ translationCache?: GenerateTranslateCache;
410
+ tickProgress: TranslationTickProgressFn;
411
+ onTranslatedLeaf?: (sourceText: string, translatedText: string, path: string) => Promise<void> | void;
412
+ }): Promise<{
413
+ next: unknown;
414
+ changed: number;
415
+ translateStats: TranslateRunPartialStats;
416
+ markedForReview: number;
417
+ }>;
418
+
419
+ /**
420
+ * Generate: translate source leaves into a working locale object, then apply structured-metadata /
421
+ * legacy normalization (same ordering as CLI `executeGenerate`).
422
+ */
423
+ declare function translateAndNormalizeGenerateLocale(input: {
424
+ sourceLeaves: readonly StringLeaf[];
425
+ working: unknown;
426
+ existingRaw: unknown | null;
427
+ preserve?: PreservePolicy;
428
+ parity?: ParityPolicy;
429
+ dryRun: boolean;
430
+ force: boolean;
431
+ provider: Translator;
432
+ providerId: TranslationProviderId;
433
+ /** BCP-47-ish source tag passed to **`translateLeaf`** (default **`en`**). */
434
+ sourceLang?: string;
435
+ targetLang: string;
436
+ sourceMap: Map<string, string>;
437
+ tickProgress: TranslationTickProgressFn;
438
+ onTranslatedLeaf?: (sourceText: string, translatedText: string, path: string) => Promise<void> | void;
439
+ localeLeafResolve: ResolveLocaleLeafModeInput;
440
+ /** Max in-flight **`translateLeaf`** calls during generate (default **1**). */
441
+ maxParallelTranslates?: number;
442
+ /** Optional translate request pacing limits (rpm/rps/intervalMs). */
443
+ rateLimit?: TranslateStartRateLimit;
444
+ /** Per-run L1 memo; omitted when host bypassed cache (`--no-cache`). */
445
+ translationCache?: GenerateTranslateCache;
446
+ }): Promise<{
447
+ preserveCount: number;
448
+ paritySkip: number;
449
+ /** Leaves whose source string value was whitespace-only (**`dryRun`** counts them too). */
450
+ emptySourceLeafCount: number;
451
+ next: unknown;
452
+ report: LocaleMetadataReport;
453
+ modeDecision: ReturnType<typeof resolveLocaleLeafMode>;
454
+ issues: Issue[];
455
+ translateStats: TranslateRunPartialStats;
456
+ markedForReview: number;
457
+ }>;
458
+
459
+ /**
460
+ * Thrown when **`translateLeaf`** fails mid-run while the translator pool / serial loop has already
461
+ * committed earlier leaf updates into **`partialLocaleJson`**. Callers (currently **`runGenerate`** and
462
+ * **`generate --resume`**) catch this so a fallback provider can resume without re-translating completed paths.
463
+ */
464
+ declare class TranslateRunInterruptedError extends Error {
465
+ readonly name = "TranslateRunInterruptedError";
466
+ readonly partialLocaleJson: unknown;
467
+ readonly translateStats: TranslateRunPartialStats;
468
+ constructor(init: {
469
+ /** Usually the backend rejection that stopped the pool / serial loop. */
470
+ cause: unknown;
471
+ partialLocaleJson: unknown;
472
+ translateStats: TranslateRunPartialStats;
473
+ message?: string;
474
+ });
475
+ }
476
+
477
+ /** Whether this leaf would be considered for **`generate --resume`**. */
478
+ declare function isResumeCandidateLeaf(input: GenerateResumeCandidateLeafInput): boolean;
479
+
480
+ /**
481
+ * Detects when a locale string still matches the **source** string closely enough that a
482
+ * **`generate --resume`** pass should treat it as a stale / untranslated copy (strict equality plus
483
+ * light normalization).
484
+ */
485
+ declare function leafMatchesSourceForResume(leafValue: string, sourceValue: string): boolean;
486
+
487
+ export { CoreContext, type GenerateHostHooks, type GenerateJsonPayload, type GenerateRunHooks, type GenerateRunOptions, type GenerateRunResult, type GenerateTargetJsonRow, type GenerateTargetProgressSummary, HandoffEligibilityRow, type HandoffOffer, type IncompleteRunDecision, type IncompleteRunInfo, type IncompleteRunReason, TranslateRunInterruptedError, TranslateRunPartialStats, buildTranslatedLocaleFromSourceLeaves, createCoreContext, formatGenerateFinalizeSummaryLines, isResumeCandidateLeaf, leafMatchesSourceForResume, localeJsonHasKeyPath, resolveGenerateLocaleDisplay, resolveLocaleDirection, runGenerate, translateAndNormalizeGenerateLocale, translateContextFromCore, translateResumeCandidateLeaves };