devcontour-harness 0.1.0-alpha.35 → 0.1.0-alpha.37

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 (116) hide show
  1. package/README.md +16 -2
  2. package/docs/contracts.md +261 -33
  3. package/docs/release-notes/0.1.0-alpha.36.md +26 -0
  4. package/docs/release-notes/0.1.0-alpha.37.md +40 -0
  5. package/docs/standalone.md +20 -0
  6. package/docs/toolchains.md +57 -2
  7. package/docs/upgrade.md +108 -0
  8. package/lib/agents/schemas.d.ts +84 -2
  9. package/lib/agents/schemas.js +49 -1
  10. package/lib/cli.js +149 -1
  11. package/lib/contracts/cli.d.ts +1495 -170
  12. package/lib/contracts/cli.js +232 -2
  13. package/lib/contracts/diagnosis.d.ts +8 -4
  14. package/lib/contracts/diagnosis.js +3 -0
  15. package/lib/contracts/errors.d.ts +7 -1
  16. package/lib/contracts/errors.js +6 -0
  17. package/lib/contracts/events.d.ts +453 -60
  18. package/lib/contracts/events.js +79 -0
  19. package/lib/contracts/execution.d.ts +270 -50
  20. package/lib/contracts/execution.js +41 -0
  21. package/lib/contracts/failure.d.ts +14 -1
  22. package/lib/contracts/failure.js +9 -1
  23. package/lib/contracts/handoff.d.ts +70 -20
  24. package/lib/contracts/handoff.js +42 -1
  25. package/lib/contracts/index.d.ts +1 -0
  26. package/lib/contracts/index.js +1 -0
  27. package/lib/contracts/input-state.d.ts +13 -0
  28. package/lib/contracts/input-state.js +32 -0
  29. package/lib/contracts/input.d.ts +442 -0
  30. package/lib/contracts/input.js +321 -0
  31. package/lib/contracts/planning.d.ts +2 -0
  32. package/lib/contracts/policy.d.ts +17 -2
  33. package/lib/contracts/policy.js +31 -2
  34. package/lib/contracts/ports.d.ts +54 -0
  35. package/lib/contracts/project.d.ts +127 -0
  36. package/lib/contracts/project.js +99 -0
  37. package/lib/contracts/published.d.ts +603 -92
  38. package/lib/contracts/published.js +4 -1
  39. package/lib/contracts/repair-policy.d.ts +20 -0
  40. package/lib/contracts/repair-policy.js +34 -0
  41. package/lib/contracts/report.d.ts +53 -21
  42. package/lib/contracts/report.js +33 -2
  43. package/lib/contracts/result.d.ts +26 -24
  44. package/lib/contracts/review.d.ts +47 -8
  45. package/lib/contracts/review.js +21 -1
  46. package/lib/control/harness.d.ts +2555 -51
  47. package/lib/control/harness.js +112 -6
  48. package/lib/control/recovery.d.ts +2 -2
  49. package/lib/control/report.js +1 -0
  50. package/lib/control/status.d.ts +30 -22
  51. package/lib/control/status.js +11 -1
  52. package/lib/control/workflow.d.ts +8 -8
  53. package/lib/engine/budget.d.ts +86 -3
  54. package/lib/engine/budget.js +45 -10
  55. package/lib/engine/engine.d.ts +3091 -85
  56. package/lib/engine/engine.js +1206 -101
  57. package/lib/engine/input-policy.d.ts +68 -0
  58. package/lib/engine/input-policy.js +285 -0
  59. package/lib/engine/input-requests.d.ts +64 -0
  60. package/lib/engine/input-requests.js +187 -0
  61. package/lib/engine/measured.d.ts +6 -1
  62. package/lib/engine/measured.js +12 -1
  63. package/lib/engine/prompt.d.ts +4 -2
  64. package/lib/engine/prompt.js +3 -1
  65. package/lib/engine/property-recovery.js +2 -0
  66. package/lib/engine/repair.d.ts +2 -0
  67. package/lib/engine/repair.js +10 -3
  68. package/lib/engine/runner.d.ts +33 -4
  69. package/lib/engine/runner.js +266 -23
  70. package/lib/environment/lifecycle.d.ts +8 -0
  71. package/lib/environment/lifecycle.js +15 -2
  72. package/lib/explain/state.d.ts +16 -2
  73. package/lib/explain/state.js +254 -77
  74. package/lib/handoff/markdown.js +10 -0
  75. package/lib/handoff/pack.js +42 -1
  76. package/lib/index.d.ts +10 -0
  77. package/lib/index.js +10 -0
  78. package/lib/init/inspect.d.ts +34 -0
  79. package/lib/init/inspect.js +292 -0
  80. package/lib/init/project.js +14 -31
  81. package/lib/integrations/connector/commands.d.ts +12 -12
  82. package/lib/integrations/connector/config.d.ts +4 -4
  83. package/lib/integrations/connector/delivery.d.ts +1 -1
  84. package/lib/integrations/relay-v2/protocol.d.ts +4 -4
  85. package/lib/profiles/resolve.d.ts +2 -1
  86. package/lib/projections/enums.d.ts +1 -1
  87. package/lib/projections/enums.js +4 -0
  88. package/lib/projections/index.d.ts +1 -0
  89. package/lib/projections/index.js +1 -0
  90. package/lib/projections/input.d.ts +17 -0
  91. package/lib/projections/input.js +28 -0
  92. package/lib/projections/stop.d.ts +40 -1
  93. package/lib/projections/stop.js +87 -4
  94. package/lib/report/compute.d.ts +4 -1
  95. package/lib/report/compute.js +25 -0
  96. package/lib/report/document.js +1 -0
  97. package/lib/storage/document.d.ts +66 -28
  98. package/lib/testing/index.d.ts +1 -1
  99. package/lib/testing/index.js +1 -1
  100. package/lib/testing/store-contract.d.ts +8 -1
  101. package/lib/testing/store-contract.js +194 -1
  102. package/lib/verification/confirm.d.ts +3 -3
  103. package/lib/verification/corpus.d.ts +9 -9
  104. package/lib/verification/gates.d.ts +119 -0
  105. package/lib/verification/gates.js +311 -4
  106. package/package.json +1 -1
  107. package/schemas/execution-document.schema.json +130 -0
  108. package/schemas/execution-policy.schema.json +26 -0
  109. package/schemas/handoff-pack.schema.json +146 -4
  110. package/schemas/input-request.schema.json +665 -0
  111. package/schemas/project-facts.schema.json +393 -0
  112. package/schemas/result-envelope.schema.json +1 -0
  113. package/schemas/run-event.schema.json +625 -0
  114. package/schemas/run-result.schema.json +1 -0
  115. package/schemas/stop-diagnosis.schema.json +5 -1
  116. package/schemas/value-report.schema.json +78 -7
@@ -6,6 +6,7 @@ import { contextPinSchema, contextSnapshotSchema } from "./context.js";
6
6
  import { deliveryStateSchema, gateArtifactFilesSchema, jointActiveSchema, jointFailedSchema, jointPassedSchema, } from "./result.js";
7
7
  import { findingStatuses, reviewRecordSchema, reviewRoundSchema } from "./review.js";
8
8
  import { contractDocumentSchema, spikeSchema } from "./checks.js";
9
+ import { INPUT_LIMITS, inputPolicySchema, inputRequestSchema, recordedAssumptionSchema, } from "./input.js";
9
10
  /**
10
11
  * Нейтральная модель исполнения — то, что ExecutionStore обязан хранить
11
12
  * транзакционно. Формы совпадают с записями задач и попыток DevContour
@@ -65,6 +66,13 @@ export const failureKinds = [
65
66
  * сделанной механически нет: решение — за ведущим, не повтор.
66
67
  */
67
68
  'needs-lead',
69
+ /**
70
+ * Исполнитель остановился с вопросом, серьёзность которого не ниже порога
71
+ * закреплённой `inputPolicy`: запрос записан в `input-requests` той же
72
+ * транзакцией, черновик сохранён. Попытка засчитана; автоматического
73
+ * повтора нет — продолжение только после ответа и `applyInput`.
74
+ */
75
+ 'needs-input',
68
76
  'unknown',
69
77
  ];
70
78
  export const failureKindSchema = z.enum(failureKinds);
@@ -488,6 +496,25 @@ export const attemptStateSchema = z.strictObject({
488
496
  .optional(),
489
497
  partial: partialDraftSchema.optional(),
490
498
  continuedFrom: continuationSchema.optional(),
499
+ /**
500
+ * Политика вопросов исполнителя, закреплённая при выдаче: смена порога
501
+ * действует со следующей попытки. Нет у попыток прежних версий.
502
+ */
503
+ inputPolicy: inputPolicySchema.optional(),
504
+ /** Развилки, решённые исполнителем, с оценкой controller (не больше 20). */
505
+ assumptions: z.array(recordedAssumptionSchema).max(INPUT_LIMITS.assumptions).optional(),
506
+ /**
507
+ * Ответ на вопрос, с которым выдана попытка: запрос, точный ответ и
508
+ * основание продолжения. Связывается при claim, только если применённое
509
+ * основание совпало с основанием выдачи.
510
+ */
511
+ input: z
512
+ .strictObject({
513
+ requestId: z.string().min(1).max(200),
514
+ answerDigest: digestSchema,
515
+ targetDigest: digestSchema,
516
+ })
517
+ .optional(),
491
518
  callsRecorded: z.literal(true).optional(),
492
519
  dispatch: z
493
520
  .strictObject({
@@ -533,6 +560,12 @@ export const attemptStateSchema = z.strictObject({
533
560
  ref: z.string().min(1).max(300),
534
561
  revision: z.string().min(1).max(200),
535
562
  }),
563
+ /**
564
+ * Действующий снимок контекста на момент выдачи (`null` — без
565
+ * контекста): runner загружает именно его. Нет — хост не связывает
566
+ * согласование с контекстом (или попытка прежней версии).
567
+ */
568
+ contextDigest: digestSchema.nullable().optional(),
536
569
  })
537
570
  .optional(),
538
571
  /**
@@ -1031,6 +1064,14 @@ export const localSchemas = {
1031
1064
  * передаются следующей попытке.
1032
1065
  */
1033
1066
  reproductions: reproductionRegistrySchema,
1067
+ /**
1068
+ * Вопросы исполнителей и ответы на них (`InputRequest`) по владельцу —
1069
+ * репозиторию поручения. Вопрос и основание неизменяемы, ответы только
1070
+ * дополняются, `version` — CAS записи: это правила движка (все записи —
1071
+ * через его операции); хранилище хранит запись целиком, как записана, и
1072
+ * отдаёт её в списке без владельца с `owner` и `key` (`executionStoreContract`).
1073
+ */
1074
+ 'input-requests': inputRequestSchema,
1034
1075
  };
1035
1076
  /* ------------------------------------------------------------------ */
1036
1077
  /* Документ standalone */
@@ -1,5 +1,6 @@
1
1
  import type { ContextLimit, FailureKind } from './execution.ts';
2
2
  import type { EnvironmentCause } from './events.ts';
3
+ import type { InputOutcome } from './input.ts';
3
4
  /** Отказ окружения до начала работы: попытка не засчитывается. */
4
5
  export declare class BlockedError extends Error {
5
6
  name: string;
@@ -27,6 +28,12 @@ export declare class TaskFailure extends Error {
27
28
  readonly diagnosis?: EnvironmentCause | undefined;
28
29
  /** Предел окна контекста у отказа `context-exhausted`, сообщённый runtime. */
29
30
  readonly contextLimit?: ContextLimit | undefined;
31
+ /**
32
+ * Вопрос, допущения и неблокирующие запросы из ответа writer
33
+ * (`needs-input`, `unfinished`): движок записывает их в той же
34
+ * транзакции, что и отказ.
35
+ */
36
+ readonly input?: InputOutcome | undefined;
30
37
  constructor(kind: FailureKind, message: string,
31
38
  /**
32
39
  * Свойства, с которыми связан отказ: `bound` — объявленные задачей
@@ -47,7 +54,13 @@ export declare class TaskFailure extends Error {
47
54
  /** Причина отказа окружения, известная в точке обнаружения (`attempt.diagnosed`). */
48
55
  diagnosis?: EnvironmentCause | undefined,
49
56
  /** Предел окна контекста у отказа `context-exhausted`, сообщённый runtime. */
50
- contextLimit?: ContextLimit | undefined);
57
+ contextLimit?: ContextLimit | undefined,
58
+ /**
59
+ * Вопрос, допущения и неблокирующие запросы из ответа writer
60
+ * (`needs-input`, `unfinished`): движок записывает их в той же
61
+ * транзакции, что и отказ.
62
+ */
63
+ input?: InputOutcome | undefined);
51
64
  }
52
65
  /**
53
66
  * Отпечаток отказа: одинаковые сбои должны совпадать, разные — расходиться.
@@ -9,6 +9,7 @@ export class TaskFailure extends Error {
9
9
  properties;
10
10
  diagnosis;
11
11
  contextLimit;
12
+ input;
12
13
  constructor(kind, message,
13
14
  /**
14
15
  * Свойства, с которыми связан отказ: `bound` — объявленные задачей
@@ -21,12 +22,19 @@ export class TaskFailure extends Error {
21
22
  /** Причина отказа окружения, известная в точке обнаружения (`attempt.diagnosed`). */
22
23
  diagnosis,
23
24
  /** Предел окна контекста у отказа `context-exhausted`, сообщённый runtime. */
24
- contextLimit) {
25
+ contextLimit,
26
+ /**
27
+ * Вопрос, допущения и неблокирующие запросы из ответа writer
28
+ * (`needs-input`, `unfinished`): движок записывает их в той же
29
+ * транзакции, что и отказ.
30
+ */
31
+ input) {
25
32
  super(message);
26
33
  this.kind = kind;
27
34
  this.properties = properties;
28
35
  this.diagnosis = diagnosis;
29
36
  this.contextLimit = contextLimit;
37
+ this.input = input;
30
38
  this.name = 'TaskFailure';
31
39
  }
32
40
  }
@@ -38,6 +38,10 @@ export declare const HANDOFF_LIMITS: {
38
38
  /** Намерения агента и знаков в каждом. */
39
39
  readonly intentions: 20;
40
40
  readonly intentionChars: 1000;
41
+ /** Вопросы исполнителя (открытые запросы), вопросы первыми. */
42
+ readonly inputs: 10;
43
+ /** Знаков ответа в пакете (`answer.excerpt`). */
44
+ readonly answerChars: 500;
41
45
  /** Предел строки факта из хранилища. */
42
46
  readonly text: 300;
43
47
  /** Предел идентификатора, имени стадии, владельца из хранилища. */
@@ -70,10 +74,10 @@ export declare const handoffPackSchema: z.ZodObject<{
70
74
  cancelled: z.ZodNumber;
71
75
  byStatus: z.ZodArray<z.ZodObject<{
72
76
  status: z.ZodEnum<{
73
- ready: "ready";
74
- failed: "failed";
75
77
  cancelled: "cancelled";
76
78
  draft: "draft";
79
+ ready: "ready";
80
+ failed: "failed";
77
81
  running: "running";
78
82
  verifying: "verifying";
79
83
  reviewing: "reviewing";
@@ -86,8 +90,8 @@ export declare const handoffPackSchema: z.ZodObject<{
86
90
  queue: z.ZodObject<{
87
91
  paused: z.ZodBoolean;
88
92
  reason: z.ZodOptional<z.ZodEnum<{
89
- runtime: "runtime";
90
93
  operator: "operator";
94
+ runtime: "runtime";
91
95
  shutdown: "shutdown";
92
96
  "base-check": "base-check";
93
97
  reconfigure: "reconfigure";
@@ -113,6 +117,7 @@ export declare const handoffPackSchema: z.ZodObject<{
113
117
  merge: "merge";
114
118
  budget: "budget";
115
119
  "needs-lead": "needs-lead";
120
+ "needs-input": "needs-input";
116
121
  }>>>;
117
122
  liftedByRun: z.ZodOptional<z.ZodLiteral<true>>;
118
123
  code: z.ZodOptional<z.ZodEnum<{
@@ -140,6 +145,7 @@ export declare const handoffPackSchema: z.ZodObject<{
140
145
  BUDGET_UNKNOWN: "BUDGET_UNKNOWN";
141
146
  ATTEMPTS_EXHAUSTED: "ATTEMPTS_EXHAUSTED";
142
147
  CONTEXT_EXHAUSTED: "CONTEXT_EXHAUSTED";
148
+ INPUT_REQUIRED: "INPUT_REQUIRED";
143
149
  REVISION_CONFLICT: "REVISION_CONFLICT";
144
150
  CANCELLED: "CANCELLED";
145
151
  NOT_FOUND: "NOT_FOUND";
@@ -154,8 +160,8 @@ export declare const handoffPackSchema: z.ZodObject<{
154
160
  INTERNAL: "INTERNAL";
155
161
  }>>;
156
162
  actor: z.ZodOptional<z.ZodNullable<z.ZodEnum<{
157
- controller: "controller";
158
163
  lead: "lead";
164
+ controller: "controller";
159
165
  user: "user";
160
166
  }>>>;
161
167
  action: z.ZodOptional<z.ZodEnum<{
@@ -172,6 +178,8 @@ export declare const handoffPackSchema: z.ZodObject<{
172
178
  "resume-queue": "resume-queue";
173
179
  "fix-environment": "fix-environment";
174
180
  "fix-access": "fix-access";
181
+ "answer-input": "answer-input";
182
+ "apply-input": "apply-input";
175
183
  }>>;
176
184
  }, z.core.$strict>;
177
185
  controller: z.ZodOptional<z.ZodObject<{
@@ -185,10 +193,10 @@ export declare const handoffPackSchema: z.ZodObject<{
185
193
  runId: z.ZodString;
186
194
  attempt: z.ZodNumber;
187
195
  phase: z.ZodEnum<{
188
- ready: "ready";
189
- failed: "failed";
190
196
  cancelled: "cancelled";
191
197
  draft: "draft";
198
+ ready: "ready";
199
+ failed: "failed";
192
200
  running: "running";
193
201
  verifying: "verifying";
194
202
  reviewing: "reviewing";
@@ -220,10 +228,10 @@ export declare const handoffPackSchema: z.ZodObject<{
220
228
  workId: z.ZodString;
221
229
  attempt: z.ZodNumber;
222
230
  phase: z.ZodEnum<{
223
- ready: "ready";
224
- failed: "failed";
225
231
  cancelled: "cancelled";
226
232
  draft: "draft";
233
+ ready: "ready";
234
+ failed: "failed";
227
235
  running: "running";
228
236
  verifying: "verifying";
229
237
  reviewing: "reviewing";
@@ -240,10 +248,10 @@ export declare const handoffPackSchema: z.ZodObject<{
240
248
  graphId: z.ZodString;
241
249
  title: z.ZodString;
242
250
  status: z.ZodEnum<{
243
- ready: "ready";
244
- failed: "failed";
245
251
  cancelled: "cancelled";
246
252
  draft: "draft";
253
+ ready: "ready";
254
+ failed: "failed";
247
255
  running: "running";
248
256
  verifying: "verifying";
249
257
  reviewing: "reviewing";
@@ -269,6 +277,7 @@ export declare const handoffPackSchema: z.ZodObject<{
269
277
  merge: "merge";
270
278
  budget: "budget";
271
279
  "needs-lead": "needs-lead";
280
+ "needs-input": "needs-input";
272
281
  }>>;
273
282
  failure: z.ZodOptional<z.ZodString>;
274
283
  hold: z.ZodOptional<z.ZodObject<{
@@ -307,6 +316,7 @@ export declare const handoffPackSchema: z.ZodObject<{
307
316
  BUDGET_UNKNOWN: "BUDGET_UNKNOWN";
308
317
  ATTEMPTS_EXHAUSTED: "ATTEMPTS_EXHAUSTED";
309
318
  CONTEXT_EXHAUSTED: "CONTEXT_EXHAUSTED";
319
+ INPUT_REQUIRED: "INPUT_REQUIRED";
310
320
  REVISION_CONFLICT: "REVISION_CONFLICT";
311
321
  CANCELLED: "CANCELLED";
312
322
  NOT_FOUND: "NOT_FOUND";
@@ -325,8 +335,8 @@ export declare const handoffPackSchema: z.ZodObject<{
325
335
  blockersTruncated: z.ZodOptional<z.ZodNumber>;
326
336
  next: z.ZodObject<{
327
337
  actor: z.ZodNullable<z.ZodEnum<{
328
- controller: "controller";
329
338
  lead: "lead";
339
+ controller: "controller";
330
340
  user: "user";
331
341
  }>>;
332
342
  action: z.ZodEnum<{
@@ -343,10 +353,12 @@ export declare const handoffPackSchema: z.ZodObject<{
343
353
  "resume-queue": "resume-queue";
344
354
  "fix-environment": "fix-environment";
345
355
  "fix-access": "fix-access";
356
+ "answer-input": "answer-input";
357
+ "apply-input": "apply-input";
346
358
  }>;
347
359
  step: z.ZodOptional<z.ZodEnum<{
348
- accepted: "accepted";
349
360
  cancelled: "cancelled";
361
+ accepted: "accepted";
350
362
  "recovery-awaiting-lead": "recovery-awaiting-lead";
351
363
  "recovery-analyzing": "recovery-analyzing";
352
364
  "recovery-applying": "recovery-applying";
@@ -396,6 +408,7 @@ export declare const handoffPackSchema: z.ZodObject<{
396
408
  BUDGET_UNKNOWN: "BUDGET_UNKNOWN";
397
409
  ATTEMPTS_EXHAUSTED: "ATTEMPTS_EXHAUSTED";
398
410
  CONTEXT_EXHAUSTED: "CONTEXT_EXHAUSTED";
411
+ INPUT_REQUIRED: "INPUT_REQUIRED";
399
412
  REVISION_CONFLICT: "REVISION_CONFLICT";
400
413
  CANCELLED: "CANCELLED";
401
414
  NOT_FOUND: "NOT_FOUND";
@@ -427,6 +440,7 @@ export declare const handoffPackSchema: z.ZodObject<{
427
440
  merge: "merge";
428
441
  budget: "budget";
429
442
  "needs-lead": "needs-lead";
443
+ "needs-input": "needs-input";
430
444
  "runtime-missing": "runtime-missing";
431
445
  "controller-busy": "controller-busy";
432
446
  "operator-pause": "operator-pause";
@@ -435,16 +449,16 @@ export declare const handoffPackSchema: z.ZodObject<{
435
449
  }>;
436
450
  phase: z.ZodEnum<{
437
451
  gates: "gates";
438
- preflight: "preflight";
439
452
  review: "review";
453
+ preflight: "preflight";
440
454
  integration: "integration";
441
455
  delivery: "delivery";
442
456
  claim: "claim";
443
457
  implementation: "implementation";
444
458
  }>;
445
459
  actor: z.ZodNullable<z.ZodEnum<{
446
- controller: "controller";
447
460
  lead: "lead";
461
+ controller: "controller";
448
462
  user: "user";
449
463
  }>>;
450
464
  action: z.ZodEnum<{
@@ -461,6 +475,8 @@ export declare const handoffPackSchema: z.ZodObject<{
461
475
  "resume-queue": "resume-queue";
462
476
  "fix-environment": "fix-environment";
463
477
  "fix-access": "fix-access";
478
+ "answer-input": "answer-input";
479
+ "apply-input": "apply-input";
464
480
  }>;
465
481
  retryPlanned: z.ZodBoolean;
466
482
  message: z.ZodString;
@@ -484,10 +500,10 @@ export declare const handoffPackSchema: z.ZodObject<{
484
500
  runId: z.ZodString;
485
501
  workId: z.ZodString;
486
502
  workStatus: z.ZodOptional<z.ZodEnum<{
487
- ready: "ready";
488
- failed: "failed";
489
503
  cancelled: "cancelled";
490
504
  draft: "draft";
505
+ ready: "ready";
506
+ failed: "failed";
491
507
  running: "running";
492
508
  verifying: "verifying";
493
509
  reviewing: "reviewing";
@@ -500,10 +516,10 @@ export declare const handoffPackSchema: z.ZodObject<{
500
516
  expired: "expired";
501
517
  }>;
502
518
  phase: z.ZodEnum<{
503
- ready: "ready";
504
- failed: "failed";
505
519
  cancelled: "cancelled";
506
520
  draft: "draft";
521
+ ready: "ready";
522
+ failed: "failed";
507
523
  running: "running";
508
524
  verifying: "verifying";
509
525
  reviewing: "reviewing";
@@ -529,6 +545,7 @@ export declare const handoffPackSchema: z.ZodObject<{
529
545
  merge: "merge";
530
546
  budget: "budget";
531
547
  "needs-lead": "needs-lead";
548
+ "needs-input": "needs-input";
532
549
  }>>;
533
550
  code: z.ZodEnum<{
534
551
  INVALID_INPUT: "INVALID_INPUT";
@@ -555,6 +572,7 @@ export declare const handoffPackSchema: z.ZodObject<{
555
572
  BUDGET_UNKNOWN: "BUDGET_UNKNOWN";
556
573
  ATTEMPTS_EXHAUSTED: "ATTEMPTS_EXHAUSTED";
557
574
  CONTEXT_EXHAUSTED: "CONTEXT_EXHAUSTED";
575
+ INPUT_REQUIRED: "INPUT_REQUIRED";
558
576
  REVISION_CONFLICT: "REVISION_CONFLICT";
559
577
  CANCELLED: "CANCELLED";
560
578
  NOT_FOUND: "NOT_FOUND";
@@ -608,10 +626,38 @@ export declare const handoffPackSchema: z.ZodObject<{
608
626
  used: z.ZodNumber;
609
627
  budget: z.ZodNumber;
610
628
  }, z.core.$strict>>;
629
+ inputs: z.ZodOptional<z.ZodArray<z.ZodObject<{
630
+ requestId: z.ZodString;
631
+ workId: z.ZodString;
632
+ kind: z.ZodEnum<{
633
+ question: "question";
634
+ "follow-up": "follow-up";
635
+ }>;
636
+ state: z.ZodEnum<{
637
+ "awaiting-answer": "awaiting-answer";
638
+ "answered-not-applied": "answered-not-applied";
639
+ "applied-awaiting-claim": "applied-awaiting-claim";
640
+ "carry-stale": "carry-stale";
641
+ }>;
642
+ severity: z.ZodNumber;
643
+ question: z.ZodString;
644
+ options: z.ZodArray<z.ZodString>;
645
+ answer: z.ZodOptional<z.ZodObject<{
646
+ revision: z.ZodNumber;
647
+ digest: z.ZodString;
648
+ excerpt: z.ZodString;
649
+ }, z.core.$strict>>;
650
+ origin: z.ZodObject<{
651
+ graphDigest: z.ZodString;
652
+ orderDigest: z.ZodString;
653
+ contextDigest: z.ZodNullable<z.ZodString>;
654
+ }, z.core.$strict>;
655
+ targetDigest: z.ZodOptional<z.ZodString>;
656
+ }, z.core.$strict>>>;
611
657
  next: z.ZodObject<{
612
658
  actor: z.ZodNullable<z.ZodEnum<{
613
- controller: "controller";
614
659
  lead: "lead";
660
+ controller: "controller";
615
661
  user: "user";
616
662
  }>>;
617
663
  action: z.ZodEnum<{
@@ -628,10 +674,12 @@ export declare const handoffPackSchema: z.ZodObject<{
628
674
  "resume-queue": "resume-queue";
629
675
  "fix-environment": "fix-environment";
630
676
  "fix-access": "fix-access";
677
+ "answer-input": "answer-input";
678
+ "apply-input": "apply-input";
631
679
  }>;
632
680
  step: z.ZodOptional<z.ZodEnum<{
633
- accepted: "accepted";
634
681
  cancelled: "cancelled";
682
+ accepted: "accepted";
635
683
  "recovery-awaiting-lead": "recovery-awaiting-lead";
636
684
  "recovery-analyzing": "recovery-analyzing";
637
685
  "recovery-applying": "recovery-applying";
@@ -679,6 +727,7 @@ export declare const handoffPackSchema: z.ZodObject<{
679
727
  BUDGET_UNKNOWN: "BUDGET_UNKNOWN";
680
728
  ATTEMPTS_EXHAUSTED: "ATTEMPTS_EXHAUSTED";
681
729
  CONTEXT_EXHAUSTED: "CONTEXT_EXHAUSTED";
730
+ INPUT_REQUIRED: "INPUT_REQUIRED";
682
731
  REVISION_CONFLICT: "REVISION_CONFLICT";
683
732
  CANCELLED: "CANCELLED";
684
733
  NOT_FOUND: "NOT_FOUND";
@@ -703,6 +752,7 @@ export declare const handoffPackSchema: z.ZodObject<{
703
752
  budgetsWithin: z.ZodNumber;
704
753
  budgetsShared: z.ZodDefault<z.ZodNumber>;
705
754
  repairs: z.ZodNumber;
755
+ inputs: z.ZodDefault<z.ZodNumber>;
706
756
  intentions: z.ZodNumber;
707
757
  intentionsDropped: z.ZodNumber;
708
758
  bySize: z.ZodBoolean;
@@ -2,7 +2,7 @@ import { z } from 'zod';
2
2
  import { diagnosisActions, diagnosisActors, diagnosisCauses, diagnosisPhases, } from "./diagnosis.js";
3
3
  import { errorCodes } from "./errors.js";
4
4
  import { failureKindSchema, pauseReasons, workStatusSchema } from "./execution.js";
5
- import { idSchema, isoTimeSchema } from "./primitives.js";
5
+ import { digestSchema, idSchema, isoTimeSchema } from "./primitives.js";
6
6
  /**
7
7
  * Пакет передачи контекста (`harness handoff`, `handoffPack`): состояние доски
8
8
  * для следующей сессии ведущего агента, собранное из хранилища, а не из
@@ -42,6 +42,10 @@ export const HANDOFF_LIMITS = {
42
42
  /** Намерения агента и знаков в каждом. */
43
43
  intentions: 20,
44
44
  intentionChars: 1000,
45
+ /** Вопросы исполнителя (открытые запросы), вопросы первыми. */
46
+ inputs: 10,
47
+ /** Знаков ответа в пакете (`answer.excerpt`). */
48
+ answerChars: 500,
45
49
  /** Предел строки факта из хранилища. */
46
50
  text: 300,
47
51
  /** Предел идентификатора, имени стадии, владельца из хранилища. */
@@ -272,6 +276,41 @@ export const handoffPackSchema = z.strictObject({
272
276
  budget: count,
273
277
  }))
274
278
  .max(HANDOFF_LIMITS.repairs),
279
+ /**
280
+ * Открытые вопросы исполнителя (H02): вопрос — усечённый, варианты — ID,
281
+ * ответ — версия, digest и начало текста, основания — digests. Нет поля —
282
+ * пакет прежней версии.
283
+ */
284
+ inputs: z
285
+ .array(z.strictObject({
286
+ requestId: name,
287
+ workId: idSchema,
288
+ kind: z.enum(['question', 'follow-up']),
289
+ state: z.enum([
290
+ 'awaiting-answer',
291
+ 'answered-not-applied',
292
+ 'applied-awaiting-claim',
293
+ 'carry-stale',
294
+ ]),
295
+ severity: z.number().int().min(1).max(10),
296
+ question: text,
297
+ options: z.array(name).max(6),
298
+ answer: z
299
+ .strictObject({
300
+ revision: z.number().int().positive(),
301
+ digest: digestSchema,
302
+ excerpt: clipped(HANDOFF_LIMITS.answerChars),
303
+ })
304
+ .optional(),
305
+ origin: z.strictObject({
306
+ graphDigest: digestSchema,
307
+ orderDigest: digestSchema,
308
+ contextDigest: digestSchema.nullable(),
309
+ }),
310
+ targetDigest: digestSchema.optional(),
311
+ }))
312
+ .max(HANDOFF_LIMITS.inputs)
313
+ .optional(),
275
314
  /** Следующий шаг доски: первое решение lead/user, иначе ход controller. */
276
315
  next: nextSchema.extend({ workId: idSchema.optional(), code: errorCodeSchema.optional() }),
277
316
  /** Намерения агента — единственный текст не из хранилища. */
@@ -298,6 +337,8 @@ export const handoffPackSchema = z.strictObject({
298
337
  // Пакеты прежних версий поля не знают: при разборе — 0.
299
338
  budgetsShared: count.default(0),
300
339
  repairs: count,
340
+ // Пакеты прежних версий поля не знают: при разборе — 0.
341
+ inputs: count.default(0),
301
342
  intentions: count,
302
343
  intentionsDropped: count,
303
344
  bySize: z.boolean(),
@@ -8,6 +8,7 @@ export * from './context.ts';
8
8
  export * from './result.ts';
9
9
  export * from './events.ts';
10
10
  export * from './execution.ts';
11
+ export * from './input.ts';
11
12
  export * from './review.ts';
12
13
  export * from './checks.ts';
13
14
  export * from './profiles.ts';
@@ -8,6 +8,7 @@ export * from "./context.js";
8
8
  export * from "./result.js";
9
9
  export * from "./events.js";
10
10
  export * from "./execution.js";
11
+ export * from "./input.js";
11
12
  export * from "./review.js";
12
13
  export * from "./checks.js";
13
14
  export * from "./profiles.js";
@@ -0,0 +1,13 @@
1
+ import type { InputRequest } from './input.ts';
2
+ /**
3
+ * Где вопрос: ждёт ответа (`awaiting-answer`), ответ записан, но не применён
4
+ * (`answered-not-applied`), применён и ждёт выдачи попытки или её первого
5
+ * вызова (`applied-awaiting-claim`), передан исполнителю началом вызова
6
+ * (`delivered`); перенесённый ответ заменённого вопроса устарел до выдачи
7
+ * (`carry-stale`: перенести снова или снять). Закрытые запросы иначе
8
+ * состояния не имеют.
9
+ */
10
+ export declare const inputStates: readonly ["awaiting-answer", "answered-not-applied", "applied-awaiting-claim", "delivered", "carry-stale"];
11
+ export type InputState = (typeof inputStates)[number];
12
+ export type RequestLike = Pick<InputRequest, 'id' | 'kind' | 'lifecycle' | 'delivered' | 'version' | 'effectiveSeverity' | 'createdAt'> & Partial<Pick<InputRequest, 'stale' | 'target'>>;
13
+ export declare function inputStateOf(r: Pick<RequestLike, 'lifecycle' | 'delivered' | 'stale' | 'target'>): InputState | undefined;
@@ -0,0 +1,32 @@
1
+ // Состояние вопроса исполнителя по записи запроса — без node:*, zod и
2
+ // движка. Общий лист договоров: его импортируют и проекции, и отчёт (оба
3
+ // годятся для браузерного бандла), чтобы правило было одно.
4
+ /**
5
+ * Где вопрос: ждёт ответа (`awaiting-answer`), ответ записан, но не применён
6
+ * (`answered-not-applied`), применён и ждёт выдачи попытки или её первого
7
+ * вызова (`applied-awaiting-claim`), передан исполнителю началом вызова
8
+ * (`delivered`); перенесённый ответ заменённого вопроса устарел до выдачи
9
+ * (`carry-stale`: перенести снова или снять). Закрытые запросы иначе
10
+ * состояния не имеют.
11
+ */
12
+ export const inputStates = [
13
+ 'awaiting-answer',
14
+ 'answered-not-applied',
15
+ 'applied-awaiting-claim',
16
+ 'delivered',
17
+ 'carry-stale',
18
+ ];
19
+ export function inputStateOf(r) {
20
+ switch (r.lifecycle) {
21
+ case 'pending':
22
+ return 'awaiting-answer';
23
+ case 'answered':
24
+ return 'answered-not-applied';
25
+ case 'applied':
26
+ return r.delivered ? 'delivered' : 'applied-awaiting-claim';
27
+ case 'superseded':
28
+ return r.stale && !r.target ? 'carry-stale' : undefined;
29
+ default:
30
+ return undefined;
31
+ }
32
+ }