@gestaltrun/dsh-agent-eval 0.0.0-stage → 0.1.1

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 (37) hide show
  1. package/LICENSE +21 -0
  2. package/README.i18n.yaml +58 -0
  3. package/README.md +194 -2
  4. package/README.zh.md +195 -0
  5. package/cordis.patch.yml +13 -0
  6. package/lib/cs-hosting-plugin-B9bjLaoE.js +6980 -0
  7. package/lib/cs-hosting.js +2 -0
  8. package/lib/index.js +2 -0
  9. package/lib/types/agent-runs.d.ts +56 -0
  10. package/lib/types/cs-hosting-evaluation.d.ts +235 -0
  11. package/lib/types/cs-hosting-plugin.d.ts +10 -0
  12. package/lib/types/handoff.d.ts +4 -0
  13. package/lib/types/human-actions.d.ts +36 -0
  14. package/lib/types/im-purchase-intent.d.ts +12 -0
  15. package/lib/types/im-target.d.ts +45 -0
  16. package/lib/types/index.d.ts +22 -0
  17. package/lib/types/input-admission.d.ts +10 -0
  18. package/lib/types/practice-failure.d.ts +17 -0
  19. package/lib/types/product-field-policy.d.ts +129 -0
  20. package/lib/types/production-budget.d.ts +21 -0
  21. package/lib/types/production-buyers.d.ts +20 -0
  22. package/lib/types/production-workspace.d.ts +64 -0
  23. package/lib/types/purchase-intent.d.ts +66 -0
  24. package/lib/types/record.d.ts +169 -0
  25. package/lib/types/replay-world.d.ts +25 -0
  26. package/lib/types/reply-latency.d.ts +21 -0
  27. package/lib/types/runner.d.ts +97 -0
  28. package/lib/types/sales.d.ts +33 -0
  29. package/lib/types/script-production.d.ts +955 -0
  30. package/lib/types/server-script-source.d.ts +65 -0
  31. package/lib/types/simulated-buyer-role.d.ts +41 -0
  32. package/lib/types/snapshot-replay.d.ts +15 -0
  33. package/lib/types/step-failure.d.ts +25 -0
  34. package/lib/types/types.d.ts +174 -0
  35. package/locale/en.json +6 -0
  36. package/locale/zh.json +6 -0
  37. package/package.json +106 -3
@@ -0,0 +1,955 @@
1
+ import type { MerchantIdentityCapture } from '@gestaltrun/dsh-merchant-account';
2
+ import type { Context } from '@deepseek-ai/cordis';
3
+ import { z } from 'zod';
4
+ import { type CaseDataCollectionSummary } from '@gestaltrun/dsh-cs-hosting/case-data';
5
+ import { type SalesCase, type SalesCoverageResult } from '@gestaltrun/dsh-cs-hosting/sales-case-contract';
6
+ import type { ProductionWork } from './production-budget.ts';
7
+ import type { CsHostingEvaluationProduction, CsHostingPrepareCounts } from '@gestaltrun/dsh-cs-hosting/types';
8
+ import type { ProductionWindow } from './production-buyers.ts';
9
+ /** Explicit operator release; unconfirmed versions may remain unused on the server. */
10
+ export declare const ScriptRecoveryRequest: z.ZodObject<{
11
+ operationId: z.ZodUUID;
12
+ setId: z.ZodUUID;
13
+ unconfirmedScriptKeys: z.ZodArray<z.ZodUUID>;
14
+ invalidScriptVersionIds: z.ZodArray<z.ZodUUID>;
15
+ reason: z.ZodString;
16
+ }, z.core.$strict>;
17
+ declare const InvalidScript: z.ZodObject<{
18
+ caseId: z.ZodUUID;
19
+ scriptKey: z.ZodUUID;
20
+ scriptVersionId: z.ZodUUID;
21
+ reason: z.ZodString;
22
+ }, z.core.$strict>;
23
+ /** Legacy unscoped sets use this server default; shorter previews rediscover buyers before production. */
24
+ export declare const SERVER_COVERAGE_LOOKBACK_DAYS = 180;
25
+ /**
26
+ * Require each selection, or one of its same-group alternates, to be submitted and inside the window.
27
+ * A larger case revision is current when the case segment message keys still match the feature material.
28
+ * @param ctx - Tenant-bound merchant reader.
29
+ * @param coverage - Immutable set whose selected inputs will be used.
30
+ * @param window - Admitted last-message window.
31
+ * @param signal - Run or preview lifetime.
32
+ */
33
+ export declare function verifyCoverageScope(ctx: Context, coverage: z.infer<typeof SalesCoverageResult>, window: ProductionWindow, signal: AbortSignal): Promise<void>;
34
+ /** Validated deployment choices for production workers and server polling. */
35
+ export interface ProductionConfig {
36
+ readonly taskConcurrency: number;
37
+ /** Concurrent script authors. Independent of case-data workers. */
38
+ readonly scriptConcurrency: number;
39
+ readonly pollIntervalMs: number;
40
+ readonly jobTimeoutMs: number;
41
+ readonly revisionRetries: number;
42
+ /** Additional attempts for transient case-page reads; defaults to 3. */
43
+ readonly caseReadRetries?: number;
44
+ /** First exponential retry delay; defaults to 1000 ms. */
45
+ readonly caseReadRetryInitialMs?: number;
46
+ /** Retry-delay ceiling; defaults to 10000 ms. */
47
+ readonly caseReadRetryMaxMs?: number;
48
+ }
49
+ /** Stages that admit model work against the shop quota. */
50
+ export type ProductionBudgetStage = 'coverage' | 'case_data' | 'scripts';
51
+ /** Production-owned operations whose successful results can be resumed without another model call. */
52
+ export interface ProductionOperations {
53
+ /** @param signal - Shop/run lifetime. @param window - Fixed production range, if supplied. @returns All distinct buyers in the server's formal-message range. */
54
+ buyers(signal: AbortSignal, window?: ProductionWindow): Promise<readonly string[]>;
55
+ /** Rejects with SupplyCaptureError when write certainty is known; other errors retain an unknown outcome. @param signal - Shop/run lifetime. @returns Submitted supply revision and notice read counts. */
56
+ captureSupply(signal: AbortSignal): Promise<{
57
+ readonly revision: number;
58
+ readonly noticeReadFailures: number;
59
+ readonly noticeTruncations: number;
60
+ readonly products?: number;
61
+ readonly destinations?: number;
62
+ }>;
63
+ /** @param row - Current server revision. @param signal - Task lifetime. @returns Revision acknowledged by the submission tool. */
64
+ collect(row: z.infer<typeof SalesCase>, signal: AbortSignal): Promise<number>;
65
+ /** @param caseId - Collected demand line. @returns Submitted-data counts, absent for historical checkpoints. */
66
+ collectionSummary?(caseId: string): CaseDataCollectionSummary | undefined;
67
+ /** True when author calls beforeSubmit durably before its first server write. */
68
+ readonly checkpointsScriptSubmission?: boolean;
69
+ /** @param set - Immutable selected material. @param scriptKey - Missing slot. @param signal - Task lifetime. @param beforeSubmit - Durable write intent, required before a server submission when supported. @returns Submitted immutable version UUID. */
70
+ author(set: z.infer<typeof SalesCoverageResult>, scriptKey: string, signal: AbortSignal, beforeSubmit: () => Promise<void>): Promise<string>;
71
+ /** @param work - Remaining model tasks. @param signal - Request lifetime. @param stage - Requesting stage; quota refusals carry it as the failure stage. @returns Affordable new script/evaluation pairs after this work; rejects insufficient quota. */
72
+ budget(work: ProductionWork, signal: AbortSignal, stage: ProductionBudgetStage): Promise<number>;
73
+ /** @param signal - Read lifetime. @returns Untrusted durable checkpoint, or null on first start. */
74
+ load(signal: AbortSignal): Promise<unknown>;
75
+ /** @param value - Validated checkpoint. @param signal - Write lifetime. */
76
+ save(value: ProductionCheckpoint, signal: AbortSignal): Promise<void>;
77
+ /** Discard retained case replay when a deleted server reference invalidates the batch. */
78
+ resetRetained?(): void;
79
+ }
80
+ declare const Checkpoint: z.ZodPipe<z.ZodUnion<readonly [z.ZodObject<{
81
+ substitutions: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
82
+ collectionRestart: z.ZodOptional<z.ZodObject<{
83
+ operationId: z.ZodUUID;
84
+ actorUserId: z.ZodString;
85
+ startedAt: z.ZodISODateTime;
86
+ previousSetId: z.ZodNullable<z.ZodUUID>;
87
+ previousCaseIds: z.ZodArray<z.ZodUUID>;
88
+ setId: z.ZodOptional<z.ZodUUID>;
89
+ version: z.ZodOptional<z.ZodNumber>;
90
+ supplyRevision: z.ZodOptional<z.ZodNumber>;
91
+ selectionDifference: z.ZodOptional<z.ZodObject<{
92
+ same: z.ZodNumber;
93
+ added: z.ZodNumber;
94
+ removed: z.ZodNumber;
95
+ }, z.core.$strict>>;
96
+ events: z.ZodArray<z.ZodObject<{
97
+ stage: z.ZodEnum<{
98
+ prescreen: "prescreen";
99
+ coverage: "coverage";
100
+ scripts: "scripts";
101
+ reuse: "reuse";
102
+ aggregation: "aggregation";
103
+ case_data: "case_data";
104
+ evaluation: "evaluation";
105
+ report: "report";
106
+ }>;
107
+ at: z.ZodISODateTime;
108
+ status: z.ZodEnum<{
109
+ failed: "failed";
110
+ completed: "completed";
111
+ started: "started";
112
+ }>;
113
+ code: z.ZodOptional<z.ZodString>;
114
+ }, z.core.$strict>>;
115
+ endedAt: z.ZodOptional<z.ZodISODateTime>;
116
+ }, z.core.$strict>>;
117
+ collectionRestartHistory: z.ZodOptional<z.ZodArray<z.ZodObject<{
118
+ operationId: z.ZodUUID;
119
+ actorUserId: z.ZodString;
120
+ startedAt: z.ZodISODateTime;
121
+ previousSetId: z.ZodNullable<z.ZodUUID>;
122
+ previousCaseIds: z.ZodArray<z.ZodUUID>;
123
+ setId: z.ZodOptional<z.ZodUUID>;
124
+ version: z.ZodOptional<z.ZodNumber>;
125
+ supplyRevision: z.ZodOptional<z.ZodNumber>;
126
+ selectionDifference: z.ZodOptional<z.ZodObject<{
127
+ same: z.ZodNumber;
128
+ added: z.ZodNumber;
129
+ removed: z.ZodNumber;
130
+ }, z.core.$strict>>;
131
+ events: z.ZodArray<z.ZodObject<{
132
+ stage: z.ZodEnum<{
133
+ prescreen: "prescreen";
134
+ coverage: "coverage";
135
+ scripts: "scripts";
136
+ reuse: "reuse";
137
+ aggregation: "aggregation";
138
+ case_data: "case_data";
139
+ evaluation: "evaluation";
140
+ report: "report";
141
+ }>;
142
+ at: z.ZodISODateTime;
143
+ status: z.ZodEnum<{
144
+ failed: "failed";
145
+ completed: "completed";
146
+ started: "started";
147
+ }>;
148
+ code: z.ZodOptional<z.ZodString>;
149
+ }, z.core.$strict>>;
150
+ endedAt: z.ZodOptional<z.ZodISODateTime>;
151
+ }, z.core.$strict>>>;
152
+ restartSubmittedCaseIds: z.ZodOptional<z.ZodArray<z.ZodString>>;
153
+ supplyRevision: z.ZodNullable<z.ZodNumber>;
154
+ supplyDestinationExtractionVersion: z.ZodOptional<z.ZodNumber>;
155
+ buyers: z.ZodNullable<z.ZodArray<z.ZodString>>;
156
+ aggregations: z.ZodRecord<z.ZodString, z.ZodObject<{
157
+ jobId: z.ZodUUID;
158
+ status: z.ZodString;
159
+ attempts: z.ZodNumber;
160
+ errorCode: z.ZodNullable<z.ZodString>;
161
+ }, z.core.$strip>>;
162
+ completed: z.ZodRecord<z.ZodString, z.ZodNumber>;
163
+ coverageJob: z.ZodNullable<z.ZodObject<{
164
+ jobId: z.ZodUUID;
165
+ status: z.ZodString;
166
+ attempts: z.ZodNumber;
167
+ errorCode: z.ZodNullable<z.ZodString>;
168
+ setId: z.ZodNullable<z.ZodUUID>;
169
+ }, z.core.$strip>>;
170
+ setId: z.ZodNullable<z.ZodUUID>;
171
+ scripts: z.ZodRecord<z.ZodString, z.ZodUUID>;
172
+ uncertain: z.ZodNullable<z.ZodEnum<{
173
+ script: "script";
174
+ coverage: "coverage";
175
+ supply: "supply";
176
+ aggregation: "aggregation";
177
+ prescreen: "prescreen";
178
+ }>>;
179
+ unconfirmedScriptKeys: z.ZodOptional<z.ZodArray<z.ZodString>>;
180
+ scriptRecoveries: z.ZodOptional<z.ZodArray<z.ZodObject<{
181
+ operationId: z.ZodUUID;
182
+ setId: z.ZodUUID;
183
+ unconfirmedScriptKeys: z.ZodArray<z.ZodUUID>;
184
+ invalidScriptVersionIds: z.ZodArray<z.ZodUUID>;
185
+ reason: z.ZodString;
186
+ actorUserId: z.ZodString;
187
+ at: z.ZodISODateTime;
188
+ invalidScripts: z.ZodArray<z.ZodObject<{
189
+ caseId: z.ZodUUID;
190
+ scriptKey: z.ZodUUID;
191
+ scriptVersionId: z.ZodUUID;
192
+ reason: z.ZodString;
193
+ }, z.core.$strict>>;
194
+ orphanedVersionsPossible: z.ZodLiteral<true>;
195
+ }, z.core.$strict>>>;
196
+ dataFailures: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodObject<{
197
+ code: z.ZodString;
198
+ attempts: z.ZodNumber;
199
+ revision: z.ZodOptional<z.ZodNumber>;
200
+ }, z.core.$strict>>>;
201
+ dataCollection: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodObject<{
202
+ records: z.ZodNumber;
203
+ gapCount: z.ZodNumber;
204
+ gapReasons: z.ZodRecord<z.ZodString, z.ZodNumber>;
205
+ inventoryEstimates: z.ZodNumber;
206
+ }, z.core.$strip>>>;
207
+ retryReleases: z.ZodOptional<z.ZodArray<z.ZodObject<{
208
+ operationId: z.ZodUUID;
209
+ actorUserId: z.ZodString;
210
+ at: z.ZodISODateTime;
211
+ cases: z.ZodArray<z.ZodObject<{
212
+ caseId: z.ZodUUID;
213
+ revision: z.ZodNumber;
214
+ previousCode: z.ZodString;
215
+ }, z.core.$strict>>;
216
+ scripts: z.ZodOptional<z.ZodArray<z.ZodObject<{
217
+ scriptKey: z.ZodString;
218
+ previousCode: z.ZodString;
219
+ }, z.core.$strict>>>;
220
+ }, z.core.$strict>>>;
221
+ scriptFailures: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodObject<{
222
+ code: z.ZodString;
223
+ attempts: z.ZodNumber;
224
+ revision: z.ZodOptional<z.ZodNumber>;
225
+ }, z.core.$strict>>>;
226
+ prescreenJob: z.ZodOptional<z.ZodNullable<z.ZodObject<{
227
+ jobId: z.ZodUUID;
228
+ status: z.ZodString;
229
+ attempts: z.ZodNumber;
230
+ errorCode: z.ZodNullable<z.ZodString>;
231
+ }, z.core.$strip>>>;
232
+ skippedPrescreen: z.ZodOptional<z.ZodNumber>;
233
+ supplyProducts: z.ZodOptional<z.ZodNumber>;
234
+ supplyDestinations: z.ZodOptional<z.ZodNumber>;
235
+ threadCount: z.ZodOptional<z.ZodNumber>;
236
+ passedCount: z.ZodOptional<z.ZodNumber>;
237
+ window: z.ZodOptional<z.ZodObject<{
238
+ from: z.ZodISODateTime;
239
+ to: z.ZodISODateTime;
240
+ }, z.core.$strip>>;
241
+ skippedOutsideWindow: z.ZodOptional<z.ZodNumber>;
242
+ noticeReadFailures: z.ZodOptional<z.ZodNumber>;
243
+ noticeTruncations: z.ZodOptional<z.ZodNumber>;
244
+ version: z.ZodLiteral<2>;
245
+ }, z.core.$strict>, z.ZodObject<{
246
+ collectionRestart: z.ZodOptional<z.ZodObject<{
247
+ operationId: z.ZodUUID;
248
+ actorUserId: z.ZodString;
249
+ startedAt: z.ZodISODateTime;
250
+ previousSetId: z.ZodNullable<z.ZodUUID>;
251
+ previousCaseIds: z.ZodArray<z.ZodUUID>;
252
+ setId: z.ZodOptional<z.ZodUUID>;
253
+ version: z.ZodOptional<z.ZodNumber>;
254
+ supplyRevision: z.ZodOptional<z.ZodNumber>;
255
+ selectionDifference: z.ZodOptional<z.ZodObject<{
256
+ same: z.ZodNumber;
257
+ added: z.ZodNumber;
258
+ removed: z.ZodNumber;
259
+ }, z.core.$strict>>;
260
+ events: z.ZodArray<z.ZodObject<{
261
+ stage: z.ZodEnum<{
262
+ prescreen: "prescreen";
263
+ coverage: "coverage";
264
+ scripts: "scripts";
265
+ reuse: "reuse";
266
+ aggregation: "aggregation";
267
+ case_data: "case_data";
268
+ evaluation: "evaluation";
269
+ report: "report";
270
+ }>;
271
+ at: z.ZodISODateTime;
272
+ status: z.ZodEnum<{
273
+ failed: "failed";
274
+ completed: "completed";
275
+ started: "started";
276
+ }>;
277
+ code: z.ZodOptional<z.ZodString>;
278
+ }, z.core.$strict>>;
279
+ endedAt: z.ZodOptional<z.ZodISODateTime>;
280
+ }, z.core.$strict>>;
281
+ collectionRestartHistory: z.ZodOptional<z.ZodArray<z.ZodObject<{
282
+ operationId: z.ZodUUID;
283
+ actorUserId: z.ZodString;
284
+ startedAt: z.ZodISODateTime;
285
+ previousSetId: z.ZodNullable<z.ZodUUID>;
286
+ previousCaseIds: z.ZodArray<z.ZodUUID>;
287
+ setId: z.ZodOptional<z.ZodUUID>;
288
+ version: z.ZodOptional<z.ZodNumber>;
289
+ supplyRevision: z.ZodOptional<z.ZodNumber>;
290
+ selectionDifference: z.ZodOptional<z.ZodObject<{
291
+ same: z.ZodNumber;
292
+ added: z.ZodNumber;
293
+ removed: z.ZodNumber;
294
+ }, z.core.$strict>>;
295
+ events: z.ZodArray<z.ZodObject<{
296
+ stage: z.ZodEnum<{
297
+ prescreen: "prescreen";
298
+ coverage: "coverage";
299
+ scripts: "scripts";
300
+ reuse: "reuse";
301
+ aggregation: "aggregation";
302
+ case_data: "case_data";
303
+ evaluation: "evaluation";
304
+ report: "report";
305
+ }>;
306
+ at: z.ZodISODateTime;
307
+ status: z.ZodEnum<{
308
+ failed: "failed";
309
+ completed: "completed";
310
+ started: "started";
311
+ }>;
312
+ code: z.ZodOptional<z.ZodString>;
313
+ }, z.core.$strict>>;
314
+ endedAt: z.ZodOptional<z.ZodISODateTime>;
315
+ }, z.core.$strict>>>;
316
+ restartSubmittedCaseIds: z.ZodOptional<z.ZodArray<z.ZodString>>;
317
+ supplyRevision: z.ZodNullable<z.ZodNumber>;
318
+ supplyDestinationExtractionVersion: z.ZodOptional<z.ZodNumber>;
319
+ buyers: z.ZodNullable<z.ZodArray<z.ZodString>>;
320
+ aggregations: z.ZodRecord<z.ZodString, z.ZodObject<{
321
+ jobId: z.ZodUUID;
322
+ status: z.ZodString;
323
+ attempts: z.ZodNumber;
324
+ errorCode: z.ZodNullable<z.ZodString>;
325
+ }, z.core.$strip>>;
326
+ completed: z.ZodRecord<z.ZodString, z.ZodNumber>;
327
+ coverageJob: z.ZodNullable<z.ZodObject<{
328
+ jobId: z.ZodUUID;
329
+ status: z.ZodString;
330
+ attempts: z.ZodNumber;
331
+ errorCode: z.ZodNullable<z.ZodString>;
332
+ setId: z.ZodNullable<z.ZodUUID>;
333
+ }, z.core.$strip>>;
334
+ setId: z.ZodNullable<z.ZodUUID>;
335
+ scripts: z.ZodRecord<z.ZodString, z.ZodUUID>;
336
+ uncertain: z.ZodNullable<z.ZodEnum<{
337
+ script: "script";
338
+ coverage: "coverage";
339
+ supply: "supply";
340
+ aggregation: "aggregation";
341
+ prescreen: "prescreen";
342
+ }>>;
343
+ unconfirmedScriptKeys: z.ZodOptional<z.ZodArray<z.ZodString>>;
344
+ scriptRecoveries: z.ZodOptional<z.ZodArray<z.ZodObject<{
345
+ operationId: z.ZodUUID;
346
+ setId: z.ZodUUID;
347
+ unconfirmedScriptKeys: z.ZodArray<z.ZodUUID>;
348
+ invalidScriptVersionIds: z.ZodArray<z.ZodUUID>;
349
+ reason: z.ZodString;
350
+ actorUserId: z.ZodString;
351
+ at: z.ZodISODateTime;
352
+ invalidScripts: z.ZodArray<z.ZodObject<{
353
+ caseId: z.ZodUUID;
354
+ scriptKey: z.ZodUUID;
355
+ scriptVersionId: z.ZodUUID;
356
+ reason: z.ZodString;
357
+ }, z.core.$strict>>;
358
+ orphanedVersionsPossible: z.ZodLiteral<true>;
359
+ }, z.core.$strict>>>;
360
+ dataFailures: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodObject<{
361
+ code: z.ZodString;
362
+ attempts: z.ZodNumber;
363
+ revision: z.ZodOptional<z.ZodNumber>;
364
+ }, z.core.$strict>>>;
365
+ dataCollection: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodObject<{
366
+ records: z.ZodNumber;
367
+ gapCount: z.ZodNumber;
368
+ gapReasons: z.ZodRecord<z.ZodString, z.ZodNumber>;
369
+ inventoryEstimates: z.ZodNumber;
370
+ }, z.core.$strip>>>;
371
+ retryReleases: z.ZodOptional<z.ZodArray<z.ZodObject<{
372
+ operationId: z.ZodUUID;
373
+ actorUserId: z.ZodString;
374
+ at: z.ZodISODateTime;
375
+ cases: z.ZodArray<z.ZodObject<{
376
+ caseId: z.ZodUUID;
377
+ revision: z.ZodNumber;
378
+ previousCode: z.ZodString;
379
+ }, z.core.$strict>>;
380
+ scripts: z.ZodOptional<z.ZodArray<z.ZodObject<{
381
+ scriptKey: z.ZodString;
382
+ previousCode: z.ZodString;
383
+ }, z.core.$strict>>>;
384
+ }, z.core.$strict>>>;
385
+ scriptFailures: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodObject<{
386
+ code: z.ZodString;
387
+ attempts: z.ZodNumber;
388
+ revision: z.ZodOptional<z.ZodNumber>;
389
+ }, z.core.$strict>>>;
390
+ prescreenJob: z.ZodOptional<z.ZodNullable<z.ZodObject<{
391
+ jobId: z.ZodUUID;
392
+ status: z.ZodString;
393
+ attempts: z.ZodNumber;
394
+ errorCode: z.ZodNullable<z.ZodString>;
395
+ }, z.core.$strip>>>;
396
+ skippedPrescreen: z.ZodOptional<z.ZodNumber>;
397
+ supplyProducts: z.ZodOptional<z.ZodNumber>;
398
+ supplyDestinations: z.ZodOptional<z.ZodNumber>;
399
+ threadCount: z.ZodOptional<z.ZodNumber>;
400
+ passedCount: z.ZodOptional<z.ZodNumber>;
401
+ window: z.ZodOptional<z.ZodObject<{
402
+ from: z.ZodISODateTime;
403
+ to: z.ZodISODateTime;
404
+ }, z.core.$strip>>;
405
+ skippedOutsideWindow: z.ZodOptional<z.ZodNumber>;
406
+ noticeReadFailures: z.ZodOptional<z.ZodNumber>;
407
+ noticeTruncations: z.ZodOptional<z.ZodNumber>;
408
+ version: z.ZodLiteral<1>;
409
+ }, z.core.$strict>]>, z.ZodTransform<{
410
+ supplyRevision: number | null;
411
+ buyers: string[] | null;
412
+ aggregations: Record<string, {
413
+ jobId: string;
414
+ status: string;
415
+ attempts: number;
416
+ errorCode: string | null;
417
+ }>;
418
+ completed: Record<string, number>;
419
+ coverageJob: {
420
+ jobId: string;
421
+ status: string;
422
+ attempts: number;
423
+ errorCode: string | null;
424
+ setId: string | null;
425
+ } | null;
426
+ setId: string | null;
427
+ scripts: Record<string, string>;
428
+ uncertain: "script" | "coverage" | "supply" | "aggregation" | "prescreen" | null;
429
+ version: 2;
430
+ substitutions?: Record<string, string> | undefined;
431
+ collectionRestart?: {
432
+ operationId: string;
433
+ actorUserId: string;
434
+ startedAt: string;
435
+ previousSetId: string | null;
436
+ previousCaseIds: string[];
437
+ events: {
438
+ stage: "case_data" | "coverage" | "aggregation" | "prescreen" | "scripts" | "reuse" | "evaluation" | "report";
439
+ at: string;
440
+ status: "failed" | "completed" | "started";
441
+ code?: string | undefined;
442
+ }[];
443
+ setId?: string | undefined;
444
+ version?: number | undefined;
445
+ supplyRevision?: number | undefined;
446
+ selectionDifference?: {
447
+ same: number;
448
+ added: number;
449
+ removed: number;
450
+ } | undefined;
451
+ endedAt?: string | undefined;
452
+ } | undefined;
453
+ collectionRestartHistory?: {
454
+ operationId: string;
455
+ actorUserId: string;
456
+ startedAt: string;
457
+ previousSetId: string | null;
458
+ previousCaseIds: string[];
459
+ events: {
460
+ stage: "case_data" | "coverage" | "aggregation" | "prescreen" | "scripts" | "reuse" | "evaluation" | "report";
461
+ at: string;
462
+ status: "failed" | "completed" | "started";
463
+ code?: string | undefined;
464
+ }[];
465
+ setId?: string | undefined;
466
+ version?: number | undefined;
467
+ supplyRevision?: number | undefined;
468
+ selectionDifference?: {
469
+ same: number;
470
+ added: number;
471
+ removed: number;
472
+ } | undefined;
473
+ endedAt?: string | undefined;
474
+ }[] | undefined;
475
+ restartSubmittedCaseIds?: string[] | undefined;
476
+ supplyDestinationExtractionVersion?: number | undefined;
477
+ unconfirmedScriptKeys?: string[] | undefined;
478
+ scriptRecoveries?: {
479
+ operationId: string;
480
+ setId: string;
481
+ unconfirmedScriptKeys: string[];
482
+ invalidScriptVersionIds: string[];
483
+ reason: string;
484
+ actorUserId: string;
485
+ at: string;
486
+ invalidScripts: {
487
+ caseId: string;
488
+ scriptKey: string;
489
+ scriptVersionId: string;
490
+ reason: string;
491
+ }[];
492
+ orphanedVersionsPossible: true;
493
+ }[] | undefined;
494
+ dataFailures?: Record<string, {
495
+ code: string;
496
+ attempts: number;
497
+ revision?: number | undefined;
498
+ }> | undefined;
499
+ dataCollection?: Record<string, {
500
+ records: number;
501
+ gapCount: number;
502
+ gapReasons: Record<string, number>;
503
+ inventoryEstimates: number;
504
+ }> | undefined;
505
+ retryReleases?: {
506
+ operationId: string;
507
+ actorUserId: string;
508
+ at: string;
509
+ cases: {
510
+ caseId: string;
511
+ revision: number;
512
+ previousCode: string;
513
+ }[];
514
+ scripts?: {
515
+ scriptKey: string;
516
+ previousCode: string;
517
+ }[] | undefined;
518
+ }[] | undefined;
519
+ scriptFailures?: Record<string, {
520
+ code: string;
521
+ attempts: number;
522
+ revision?: number | undefined;
523
+ }> | undefined;
524
+ prescreenJob?: {
525
+ jobId: string;
526
+ status: string;
527
+ attempts: number;
528
+ errorCode: string | null;
529
+ } | null | undefined;
530
+ skippedPrescreen?: number | undefined;
531
+ supplyProducts?: number | undefined;
532
+ supplyDestinations?: number | undefined;
533
+ threadCount?: number | undefined;
534
+ passedCount?: number | undefined;
535
+ window?: {
536
+ from: string;
537
+ to: string;
538
+ } | undefined;
539
+ skippedOutsideWindow?: number | undefined;
540
+ noticeReadFailures?: number | undefined;
541
+ noticeTruncations?: number | undefined;
542
+ }, {
543
+ supplyRevision: number | null;
544
+ buyers: string[] | null;
545
+ aggregations: Record<string, {
546
+ jobId: string;
547
+ status: string;
548
+ attempts: number;
549
+ errorCode: string | null;
550
+ }>;
551
+ completed: Record<string, number>;
552
+ coverageJob: {
553
+ jobId: string;
554
+ status: string;
555
+ attempts: number;
556
+ errorCode: string | null;
557
+ setId: string | null;
558
+ } | null;
559
+ setId: string | null;
560
+ scripts: Record<string, string>;
561
+ uncertain: "script" | "coverage" | "supply" | "aggregation" | "prescreen" | null;
562
+ version: 2;
563
+ substitutions?: Record<string, string> | undefined;
564
+ collectionRestart?: {
565
+ operationId: string;
566
+ actorUserId: string;
567
+ startedAt: string;
568
+ previousSetId: string | null;
569
+ previousCaseIds: string[];
570
+ events: {
571
+ stage: "case_data" | "coverage" | "aggregation" | "prescreen" | "scripts" | "reuse" | "evaluation" | "report";
572
+ at: string;
573
+ status: "failed" | "completed" | "started";
574
+ code?: string | undefined;
575
+ }[];
576
+ setId?: string | undefined;
577
+ version?: number | undefined;
578
+ supplyRevision?: number | undefined;
579
+ selectionDifference?: {
580
+ same: number;
581
+ added: number;
582
+ removed: number;
583
+ } | undefined;
584
+ endedAt?: string | undefined;
585
+ } | undefined;
586
+ collectionRestartHistory?: {
587
+ operationId: string;
588
+ actorUserId: string;
589
+ startedAt: string;
590
+ previousSetId: string | null;
591
+ previousCaseIds: string[];
592
+ events: {
593
+ stage: "case_data" | "coverage" | "aggregation" | "prescreen" | "scripts" | "reuse" | "evaluation" | "report";
594
+ at: string;
595
+ status: "failed" | "completed" | "started";
596
+ code?: string | undefined;
597
+ }[];
598
+ setId?: string | undefined;
599
+ version?: number | undefined;
600
+ supplyRevision?: number | undefined;
601
+ selectionDifference?: {
602
+ same: number;
603
+ added: number;
604
+ removed: number;
605
+ } | undefined;
606
+ endedAt?: string | undefined;
607
+ }[] | undefined;
608
+ restartSubmittedCaseIds?: string[] | undefined;
609
+ supplyDestinationExtractionVersion?: number | undefined;
610
+ unconfirmedScriptKeys?: string[] | undefined;
611
+ scriptRecoveries?: {
612
+ operationId: string;
613
+ setId: string;
614
+ unconfirmedScriptKeys: string[];
615
+ invalidScriptVersionIds: string[];
616
+ reason: string;
617
+ actorUserId: string;
618
+ at: string;
619
+ invalidScripts: {
620
+ caseId: string;
621
+ scriptKey: string;
622
+ scriptVersionId: string;
623
+ reason: string;
624
+ }[];
625
+ orphanedVersionsPossible: true;
626
+ }[] | undefined;
627
+ dataFailures?: Record<string, {
628
+ code: string;
629
+ attempts: number;
630
+ revision?: number | undefined;
631
+ }> | undefined;
632
+ dataCollection?: Record<string, {
633
+ records: number;
634
+ gapCount: number;
635
+ gapReasons: Record<string, number>;
636
+ inventoryEstimates: number;
637
+ }> | undefined;
638
+ retryReleases?: {
639
+ operationId: string;
640
+ actorUserId: string;
641
+ at: string;
642
+ cases: {
643
+ caseId: string;
644
+ revision: number;
645
+ previousCode: string;
646
+ }[];
647
+ scripts?: {
648
+ scriptKey: string;
649
+ previousCode: string;
650
+ }[] | undefined;
651
+ }[] | undefined;
652
+ scriptFailures?: Record<string, {
653
+ code: string;
654
+ attempts: number;
655
+ revision?: number | undefined;
656
+ }> | undefined;
657
+ prescreenJob?: {
658
+ jobId: string;
659
+ status: string;
660
+ attempts: number;
661
+ errorCode: string | null;
662
+ } | null | undefined;
663
+ skippedPrescreen?: number | undefined;
664
+ supplyProducts?: number | undefined;
665
+ supplyDestinations?: number | undefined;
666
+ threadCount?: number | undefined;
667
+ passedCount?: number | undefined;
668
+ window?: {
669
+ from: string;
670
+ to: string;
671
+ } | undefined;
672
+ skippedOutsideWindow?: number | undefined;
673
+ noticeReadFailures?: number | undefined;
674
+ noticeTruncations?: number | undefined;
675
+ } | {
676
+ supplyRevision: number | null;
677
+ buyers: string[] | null;
678
+ aggregations: Record<string, {
679
+ jobId: string;
680
+ status: string;
681
+ attempts: number;
682
+ errorCode: string | null;
683
+ }>;
684
+ completed: Record<string, number>;
685
+ coverageJob: {
686
+ jobId: string;
687
+ status: string;
688
+ attempts: number;
689
+ errorCode: string | null;
690
+ setId: string | null;
691
+ } | null;
692
+ setId: string | null;
693
+ scripts: Record<string, string>;
694
+ uncertain: "script" | "coverage" | "supply" | "aggregation" | "prescreen" | null;
695
+ version: 1;
696
+ collectionRestart?: {
697
+ operationId: string;
698
+ actorUserId: string;
699
+ startedAt: string;
700
+ previousSetId: string | null;
701
+ previousCaseIds: string[];
702
+ events: {
703
+ stage: "case_data" | "coverage" | "aggregation" | "prescreen" | "scripts" | "reuse" | "evaluation" | "report";
704
+ at: string;
705
+ status: "failed" | "completed" | "started";
706
+ code?: string | undefined;
707
+ }[];
708
+ setId?: string | undefined;
709
+ version?: number | undefined;
710
+ supplyRevision?: number | undefined;
711
+ selectionDifference?: {
712
+ same: number;
713
+ added: number;
714
+ removed: number;
715
+ } | undefined;
716
+ endedAt?: string | undefined;
717
+ } | undefined;
718
+ collectionRestartHistory?: {
719
+ operationId: string;
720
+ actorUserId: string;
721
+ startedAt: string;
722
+ previousSetId: string | null;
723
+ previousCaseIds: string[];
724
+ events: {
725
+ stage: "case_data" | "coverage" | "aggregation" | "prescreen" | "scripts" | "reuse" | "evaluation" | "report";
726
+ at: string;
727
+ status: "failed" | "completed" | "started";
728
+ code?: string | undefined;
729
+ }[];
730
+ setId?: string | undefined;
731
+ version?: number | undefined;
732
+ supplyRevision?: number | undefined;
733
+ selectionDifference?: {
734
+ same: number;
735
+ added: number;
736
+ removed: number;
737
+ } | undefined;
738
+ endedAt?: string | undefined;
739
+ }[] | undefined;
740
+ restartSubmittedCaseIds?: string[] | undefined;
741
+ supplyDestinationExtractionVersion?: number | undefined;
742
+ unconfirmedScriptKeys?: string[] | undefined;
743
+ scriptRecoveries?: {
744
+ operationId: string;
745
+ setId: string;
746
+ unconfirmedScriptKeys: string[];
747
+ invalidScriptVersionIds: string[];
748
+ reason: string;
749
+ actorUserId: string;
750
+ at: string;
751
+ invalidScripts: {
752
+ caseId: string;
753
+ scriptKey: string;
754
+ scriptVersionId: string;
755
+ reason: string;
756
+ }[];
757
+ orphanedVersionsPossible: true;
758
+ }[] | undefined;
759
+ dataFailures?: Record<string, {
760
+ code: string;
761
+ attempts: number;
762
+ revision?: number | undefined;
763
+ }> | undefined;
764
+ dataCollection?: Record<string, {
765
+ records: number;
766
+ gapCount: number;
767
+ gapReasons: Record<string, number>;
768
+ inventoryEstimates: number;
769
+ }> | undefined;
770
+ retryReleases?: {
771
+ operationId: string;
772
+ actorUserId: string;
773
+ at: string;
774
+ cases: {
775
+ caseId: string;
776
+ revision: number;
777
+ previousCode: string;
778
+ }[];
779
+ scripts?: {
780
+ scriptKey: string;
781
+ previousCode: string;
782
+ }[] | undefined;
783
+ }[] | undefined;
784
+ scriptFailures?: Record<string, {
785
+ code: string;
786
+ attempts: number;
787
+ revision?: number | undefined;
788
+ }> | undefined;
789
+ prescreenJob?: {
790
+ jobId: string;
791
+ status: string;
792
+ attempts: number;
793
+ errorCode: string | null;
794
+ } | null | undefined;
795
+ skippedPrescreen?: number | undefined;
796
+ supplyProducts?: number | undefined;
797
+ supplyDestinations?: number | undefined;
798
+ threadCount?: number | undefined;
799
+ passedCount?: number | undefined;
800
+ window?: {
801
+ from: string;
802
+ to: string;
803
+ } | undefined;
804
+ skippedOutsideWindow?: number | undefined;
805
+ noticeReadFailures?: number | undefined;
806
+ noticeTruncations?: number | undefined;
807
+ }>>;
808
+ /** Durable production state; model output and credentials are never checkpoint fields. Version 1 loads as version 2. */
809
+ export type ProductionCheckpoint = z.output<typeof Checkpoint>;
810
+ /** A stopped stage with a stable machine code; completed checkpoints remain reusable. */
811
+ export declare class ProductionFailure extends Error {
812
+ readonly code: string;
813
+ readonly stage: CsHostingEvaluationProduction['stage'];
814
+ readonly terminalJob: boolean;
815
+ /** @param code - Machine-readable cause. @param stage - Operation that stopped. @param terminalJob - True only after a definitive server job failure; omission retains its id for polling. */
816
+ constructor(code: string, stage: CsHostingEvaluationProduction['stage'], terminalJob?: boolean);
817
+ }
818
+ /** Owns supply, aggregation, prescreen, coverage, selected case data, and script attachment. A definite per-item failure does not block the later stages. */
819
+ export declare class ScriptProductionPipeline {
820
+ private readonly ctx;
821
+ private readonly config;
822
+ private readonly operations;
823
+ private state;
824
+ private saving;
825
+ private scriptAttach;
826
+ private readonly caseReadPolicy;
827
+ /** @param ctx - Tenant-bound merchant requests. @param config - Resolved deployment choices. @param operations - Workspace tasks and durable checkpoint IO. */
828
+ constructor(ctx: Context, config: ProductionConfig, operations: ProductionOperations);
829
+ /** @returns The durable fresh-collection audit, absent on ordinary production. */
830
+ get collectionRestart(): CsHostingEvaluationProduction['collectionRestart'];
831
+ /** @param signal - Shop lifetime. @returns After confirming that no previously submitted write has an unknown outcome. */
832
+ assertResumable(signal: AbortSignal): Promise<void>;
833
+ /** @param signal - Shop lifetime. @returns The unfinished durable batch for explicit cancellation; unknown writes reject before any mutation. */
834
+ restoreCollectionRestart(signal: AbortSignal): Promise<CsHostingEvaluationProduction['collectionRestart']>;
835
+ /** @param fallback - Window of a new batch. @param signal - Shop lifetime. @returns The saved unfinished batch window, or the new window, without writing a checkpoint. */
836
+ previewCollectionRestart(fallback: ProductionWindow, signal: AbortSignal): Promise<{
837
+ window: ProductionWindow;
838
+ resuming: boolean;
839
+ caseCount?: number;
840
+ }>;
841
+ /** @param stage - Completed or started operation. @param status - Acknowledged stage outcome. @param signal - Shop lifetime. @param code - Safe failure code. */
842
+ auditRestart(stage: NonNullable<CsHostingEvaluationProduction['collectionRestart']>['events'][number]['stage'], status: 'started' | 'completed' | 'failed', signal: AbortSignal, code?: string): Promise<void>;
843
+ /** @returns Practice cases acknowledged in this restart batch, including cases still awaiting judgment. */
844
+ get submittedPracticeCaseIds(): readonly string[];
845
+ /** @param caseId - Server-acknowledged practice case. @param signal - Shop lifetime. */
846
+ acknowledgePractice(caseId: string, signal: AbortSignal): Promise<void>;
847
+ private captureSupply;
848
+ private beginRestart;
849
+ /**
850
+ * Release explicitly named unknown script writes and exclude fixed versions without changing server bindings.
851
+ * @param request - Operator-authorized recovery, including acceptance of possibly unused server versions.
852
+ * @param actorUserId - Current Host-authenticated administrator.
853
+ * @param signal - Captured shop lifetime.
854
+ * @returns After the release and audit are durable; identical operation ids are idempotent.
855
+ */
856
+ recoverScripts(request: z.input<typeof ScriptRecoveryRequest>, actorUserId: MerchantIdentityCapture['identity']['userId'], signal: AbortSignal): Promise<void>;
857
+ /** @returns Explicitly excluded immutable versions, retained across production restarts. */
858
+ get invalidScripts(): readonly z.infer<typeof InvalidScript>[];
859
+ /** @returns Durable operator recovery identities associated with this production checkpoint. */
860
+ get scriptRecoveryOperationIds(): string[];
861
+ /**
862
+ * Grant one further attempt to every exhausted primary, alternate and missing script slot in this set; committed material and coverage remain intact.
863
+ * @param actorUserId - Host-authenticated administrator responsible for this release.
864
+ * @param signal - Current shop lifetime.
865
+ * @param operationId - Stable command identity when retry is dispatched remotely.
866
+ * @returns Released case ids and script keys after the audit record and grants are durable.
867
+ */
868
+ retryFailedCases(actorUserId: MerchantIdentityCapture['identity']['userId'], signal: AbortSignal, operationId?: string): Promise<{
869
+ readonly caseIds: readonly string[];
870
+ readonly scriptKeys: readonly string[];
871
+ }>;
872
+ /** @returns The admitted persisted range, or undefined when neither the checkpoint nor caller supplied one. */
873
+ get window(): ProductionWindow | undefined;
874
+ /** @param signal - Shop lifetime. @returns The checkpoint's set and fixed window, if available. */
875
+ checkpointScope(signal: AbortSignal): Promise<{
876
+ setId: string | null;
877
+ window?: ProductionWindow;
878
+ } | undefined>;
879
+ /**
880
+ * Counts this process has already read. Supply stays absent until capture or a successful supply read;
881
+ * buyers stay absent until discovery; threads and passed stay absent until the prescreen case read.
882
+ * @returns The measured subset, or undefined when none of those reads has finished.
883
+ */
884
+ prepareFacts(): CsHostingPrepareCounts | undefined;
885
+ /**
886
+ * Resume committed stages and attach every confirmed script before returning.
887
+ * A definite per-item failure is checkpointed and retried once; unknown writes stop until the owning operator resolves them.
888
+ * @param signal - Run and shop lifetime; cancellation joins all workers.
889
+ * @param progress - Running-workbench stage projection.
890
+ * @param existingSetId - Published set to reuse when no local checkpoint exists; omission runs all production stages.
891
+ * @param window - Fixed last-message range sent to coverage; omission uses the server's default range.
892
+ * @param restartActorUserId - Explicit fresh collection request; stale supply is refreshed once, and unfinished batches resume their acknowledged revision and saved window.
893
+ * @param resuming - Whether this is an existing assigned run whose checkpoint must not be replaced.
894
+ * @returns Ready immutable evaluation set UUID.
895
+ */
896
+ prepare(signal: AbortSignal, progress: (value: CsHostingEvaluationProduction) => void, existingSetId?: string, window?: ProductionWindow, restartActorUserId?: string, resuming?: boolean): Promise<string>;
897
+ private prepareOnce;
898
+ private cases;
899
+ private casePage;
900
+ private poll;
901
+ private work;
902
+ private acceptsSubmitted;
903
+ private collectSelected;
904
+ private currentCaseId;
905
+ private openSlot;
906
+ private filledCount;
907
+ private slotResolved;
908
+ private hasCollectableAlternative;
909
+ private promote;
910
+ private practiced;
911
+ private collectCases;
912
+ /** Cancellation, unknown writes, quota, and identity failure stop every worker. Other task errors stay on that item. */
913
+ private stopsStage;
914
+ private definiteTaskError;
915
+ private noteDataFailure;
916
+ private clearDataFailure;
917
+ private noteScriptFailure;
918
+ private clearScriptFailure;
919
+ private alternativeProjection;
920
+ private noticeProjection;
921
+ private failureProjection;
922
+ private throwIfUnconfirmed;
923
+ private markScriptUnconfirmed;
924
+ private clearScriptUnconfirmed;
925
+ /** Attach one confirmed version at a time. The route updates the set atomically, so overlapping posts can reject a new version. */
926
+ private attachScript;
927
+ private refused;
928
+ private save;
929
+ }
930
+ /**
931
+ * A higher revision stays current when the ordered case segment message keys still equal the feature material keys.
932
+ * Script submit and attach accept that revision only when the feature material signature matches the current conversation; this check uses those keys and does not read sourceSignature.
933
+ * @param row - Current case.
934
+ * @param recorded - Revision stored on the selection or alternate.
935
+ * @param feature - Coverage feature that owns the saved material.
936
+ * @returns Whether the case is still the recorded conversation.
937
+ */
938
+ export declare function caseMaterialCurrent(row: z.infer<typeof SalesCase>, recorded: number, feature: {
939
+ material: readonly {
940
+ messageKey: string;
941
+ }[];
942
+ } | undefined): boolean;
943
+ /**
944
+ * Feature id to send when the practiced selection is an alternate.
945
+ * Omission means the original selected feature.
946
+ * @param selection - Selection after a possible alternate substitution.
947
+ * @returns The alternate feature id, or undefined for the original selection.
948
+ */
949
+ export declare function alternateFeatureId(selection: {
950
+ featureId: string;
951
+ alternates?: readonly {
952
+ featureId: string;
953
+ }[] | undefined;
954
+ }): string | undefined;
955
+ export {};