@adhdev/mesh-shared 1.0.82-rc.9 → 1.0.82-rc.91
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/assistant-protocol.d.ts +163 -6
- package/dist/decision-push-relay.d.ts +20 -0
- package/dist/index.d.ts +12 -0
- package/dist/index.js +1641 -124
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1502 -124
- package/dist/index.mjs.map +1 -1
- package/dist/launch-defaults.d.ts +196 -0
- package/dist/light-task.d.ts +96 -0
- package/dist/mesh-tool-names.d.ts +2 -2
- package/dist/mesh-vocabulary.d.ts +13 -4
- package/dist/mission-git-state.d.ts +83 -0
- package/dist/mission-items.d.ts +202 -0
- package/dist/node-facts.d.ts +61 -1
- package/dist/outbound-message.d.ts +9 -2
- package/dist/path-ownership.d.ts +1 -1
- package/dist/protocol/daemon-server.d.ts +42 -2
- package/dist/protocol/dashboard-daemon-p2p.d.ts +1 -1
- package/dist/protocol/dashboard-server.d.ts +20 -2
- package/dist/provider-approval.d.ts +36 -0
- package/dist/provider-question.d.ts +19 -0
- package/dist/quota-freshness.d.ts +4 -4
- package/dist/relay-reprobe.d.ts +52 -0
- package/dist/release.d.ts +90 -0
- package/dist/role-launch.d.ts +11 -0
- package/dist/session-launch.d.ts +10 -22
- package/dist/slot-proposal.d.ts +14 -0
- package/dist/task-source-phase.d.ts +83 -0
- package/dist/task-stages.d.ts +208 -0
- package/dist/turn-evidence.d.ts +43 -13
- package/dist/turn-ipc-mission.d.ts +72 -1
- package/dist/turn-ipc-queue.d.ts +30 -0
- package/dist/turn-ipc.d.ts +2 -2
- package/dist/types.d.ts +1 -0
- package/dist/worker-protocol.d.ts +41 -1
- package/package.json +1 -1
- package/src/assistant-protocol.ts +306 -6
- package/src/daemon-normalize.ts +7 -5
- package/src/decision-push-relay.ts +23 -0
- package/src/index.ts +13 -0
- package/src/keyed-doc-delta.ts +9 -1
- package/src/launch-defaults.ts +170 -0
- package/src/light-task.ts +116 -0
- package/src/mesh-tool-names.ts +22 -0
- package/src/mesh-vocabulary.ts +12 -2
- package/src/mission-git-state.ts +112 -0
- package/src/mission-items.ts +421 -0
- package/src/node-facts.ts +56 -1
- package/src/outbound-message.ts +19 -0
- package/src/path-ownership.ts +4 -6
- package/src/protocol/daemon-server.ts +37 -2
- package/src/protocol/dashboard-server.ts +13 -2
- package/src/provider-approval.ts +59 -0
- package/src/provider-question.ts +31 -0
- package/src/quota-freshness.ts +29 -13
- package/src/relay-reprobe.ts +117 -0
- package/src/release.ts +121 -0
- package/src/role-launch.ts +51 -0
- package/src/session-launch.ts +17 -1
- package/src/slot-proposal.ts +61 -2
- package/src/task-source-phase.ts +70 -0
- package/src/task-stages.ts +457 -0
- package/src/turn-evidence.ts +56 -20
- package/src/turn-ipc-mission.ts +127 -11
- package/src/turn-ipc-queue.ts +45 -2
- package/src/turn-ipc-turn.ts +1 -1
- package/src/turn-ipc.ts +1 -0
- package/src/types.ts +1 -0
- package/src/worker-protocol.ts +92 -0
package/src/turn-evidence.ts
CHANGED
|
@@ -56,7 +56,11 @@ export type DeliveryOutcome = typeof DELIVERY_OUTCOMES[number]
|
|
|
56
56
|
export const DELIVERY_VIAS = ['local', 'p2p'] as const
|
|
57
57
|
export type DeliveryVia = typeof DELIVERY_VIAS[number]
|
|
58
58
|
|
|
59
|
-
|
|
59
|
+
/** `submit_unconfirmed` (SUBMIT-UNCONFIRMED-RECLAIM): the worker's CLI never
|
|
60
|
+
* took the written prompt — the submit budget and one re-paste were spent at
|
|
61
|
+
* an idle composer. An owner daemon older than this value drops the evidence
|
|
62
|
+
* as invalid and falls back to its consume/turn holds (the pre-fix path). */
|
|
63
|
+
export const DISPATCH_FAILURE_REASONS = ['worker_absent', 'transport_error', 'spawn_failed', 'rejected_by_worker', 'timeout', 'submit_unconfirmed'] as const
|
|
60
64
|
export type DispatchFailureReason = typeof DISPATCH_FAILURE_REASONS[number]
|
|
61
65
|
|
|
62
66
|
/**
|
|
@@ -75,6 +79,33 @@ export function sanitizeRefusalCode(value: unknown): string | undefined {
|
|
|
75
79
|
return normalized.slice(0, 64)
|
|
76
80
|
}
|
|
77
81
|
|
|
82
|
+
/** Longest refusal message kept on a failed dispatch (see {@link sanitizeDispatchRefusalDetail}). */
|
|
83
|
+
export const DISPATCH_REFUSAL_DETAIL_MAX = 200
|
|
84
|
+
|
|
85
|
+
/**
|
|
86
|
+
* Bounded, sanitized "why was this dispatch refused" detail for triage:
|
|
87
|
+
* `{code, message}` with the code in the refusal-code identifier shape and the
|
|
88
|
+
* message a single printable line of at most {@link DISPATCH_REFUSAL_DETAIL_MAX}
|
|
89
|
+
* chars (home-directory prefixes collapsed to `~`). Refusal texts are generated
|
|
90
|
+
* by the daemon / transport, never by a user or an agent. LOCAL records only:
|
|
91
|
+
* it is deliberately NOT part of the replicated turn evidence (content-free).
|
|
92
|
+
*/
|
|
93
|
+
export function sanitizeDispatchRefusalDetail(code: unknown, message: unknown): { code?: string; message?: string } | undefined {
|
|
94
|
+
const cleanCode = sanitizeRefusalCode(code)
|
|
95
|
+
let cleanMessage: string | undefined
|
|
96
|
+
if (typeof message === 'string') {
|
|
97
|
+
const line = message
|
|
98
|
+
.replace(/(?:[A-Za-z]:)?[\\/](?:Users|home)[\\/][^\s\\/]+/g, '~')
|
|
99
|
+
// eslint-disable-next-line no-control-regex
|
|
100
|
+
.replace(/[\u0000-\u001f\u007f]+/g, ' ')
|
|
101
|
+
.replace(/\s+/g, ' ')
|
|
102
|
+
.trim()
|
|
103
|
+
if (line) cleanMessage = line.length > DISPATCH_REFUSAL_DETAIL_MAX ? `${line.slice(0, DISPATCH_REFUSAL_DETAIL_MAX - 1)}…` : line
|
|
104
|
+
}
|
|
105
|
+
if (!cleanCode && !cleanMessage) return undefined
|
|
106
|
+
return { ...(cleanCode ? { code: cleanCode } : {}), ...(cleanMessage ? { message: cleanMessage } : {}) }
|
|
107
|
+
}
|
|
108
|
+
|
|
78
109
|
export const CONSUME_PROFILES = ['default', 'native_source'] as const
|
|
79
110
|
export type ConsumeProfile = typeof CONSUME_PROFILES[number]
|
|
80
111
|
|
|
@@ -83,9 +114,9 @@ export type SessionReboundReason = typeof SESSION_REBOUND_REASONS[number]
|
|
|
83
114
|
|
|
84
115
|
export const SUSPENSION_MODALS = ['approval', 'choice'] as const
|
|
85
116
|
export type SuspensionModal = typeof SUSPENSION_MODALS[number]
|
|
86
|
-
export const SUSPENSION_RESOLUTIONS = ['approved', 'rejected', 'answered'] as const
|
|
117
|
+
export const SUSPENSION_RESOLUTIONS = ['approved', 'rejected', 'answered', 'dismissed'] as const
|
|
87
118
|
export type SuspensionResolution = typeof SUSPENSION_RESOLUTIONS[number]
|
|
88
|
-
export const SUSPENSION_RESOLUTION_VIAS = ['modal_button', 'auto_approve', 'prompt_answer'] as const
|
|
119
|
+
export const SUSPENSION_RESOLUTION_VIAS = ['modal_button', 'auto_approve', 'prompt_answer', 'modal_disappeared'] as const
|
|
89
120
|
export type SuspensionResolutionVia = typeof SUSPENSION_RESOLUTION_VIAS[number]
|
|
90
121
|
|
|
91
122
|
export const TURN_END_STRENGTHS = ['genuine', 'weak'] as const
|
|
@@ -97,13 +128,13 @@ export const TURN_END_BLOCK_REASONS = [
|
|
|
97
128
|
] as const
|
|
98
129
|
export type TurnEndBlockReason = typeof TURN_END_BLOCK_REASONS[number]
|
|
99
130
|
|
|
100
|
-
export const NATIVE_TURN_OUTCOMES = ['completed', 'aborted'] as const
|
|
131
|
+
export const NATIVE_TURN_OUTCOMES = ['completed', 'aborted', 'failed'] as const
|
|
101
132
|
export type NativeTurnOutcome = typeof NATIVE_TURN_OUTCOMES[number]
|
|
102
133
|
|
|
103
134
|
export const LIVENESS_RESULTS = ['alive', 'unknown', 'read_failed', 'dead'] as const
|
|
104
135
|
export type LivenessResult = typeof LIVENESS_RESULTS[number]
|
|
105
136
|
|
|
106
|
-
export const PROVIDER_FAILURES = ['auth_failed', 'billing_failed'] as const
|
|
137
|
+
export const PROVIDER_FAILURES = ['auth_failed', 'billing_failed', 'usage_limit_exceeded', 'server_overloaded', 'provider_error'] as const
|
|
107
138
|
export type ProviderFailure = typeof PROVIDER_FAILURES[number]
|
|
108
139
|
|
|
109
140
|
/**
|
|
@@ -150,11 +181,11 @@ export const HOLD_REASONS = [
|
|
|
150
181
|
// — a turn_end commits the report (R9t), expiry commits it anyway (R13t) so
|
|
151
182
|
// a session whose FSM never shows the idle edge again does not wait for
|
|
152
183
|
// liveness / hard_ceiling.
|
|
153
|
-
'await_end',
|
|
184
|
+
'await_end', 'report_correction',
|
|
154
185
|
] as const
|
|
155
186
|
export type HoldReason = typeof HOLD_REASONS[number]
|
|
156
187
|
|
|
157
|
-
export const TURN_OUTCOMES = ['completed', 'failed', 'cancelled'] as const
|
|
188
|
+
export const TURN_OUTCOMES = ['completed', 'blocked', 'failed', 'cancelled'] as const
|
|
158
189
|
export type TurnOutcome = typeof TURN_OUTCOMES[number]
|
|
159
190
|
|
|
160
191
|
export const COMMIT_STRENGTHS = ['genuine', 'weak', 'tool_report', 'operator'] as const
|
|
@@ -164,10 +195,12 @@ export type CommitStrength = typeof COMMIT_STRENGTHS[number]
|
|
|
164
195
|
export const TURN_REASONS = [
|
|
165
196
|
// commits
|
|
166
197
|
'turn_end', 'weak_end_confirmed', 'transcript_final', 'worker_reported',
|
|
167
|
-
'finalization_timeout_no_response', 'session_error', 'provider_auth_failed', 'provider_billing_failed',
|
|
198
|
+
'finalization_timeout_no_response', 'weak_end_liveness_unconfirmed', 'weak_end_probe_unobserved', 'report_correction_expired', 'session_error', 'provider_auth_failed', 'provider_billing_failed', 'provider_usage_limit_exceeded', 'provider_server_overloaded', 'provider_error',
|
|
168
199
|
'operator_cancel', 'intentional_cleanup', 'task_removed', 'mission_abandoned', 'superseded',
|
|
169
200
|
'operator_update', 'refine_terminal', 'validation_terminal',
|
|
170
201
|
'hard_ceiling', 'reclaim_budget_exhausted', 'hollow_max_retries', 'migration_orphan',
|
|
202
|
+
// a stopping attempt whose writer node stayed unreachable (or was removed) past the bound
|
|
203
|
+
'writer_unreachable',
|
|
171
204
|
// reclaims (generation + 1)
|
|
172
205
|
'dispatch_refused_session_exited', 'dispatch_refused_no_target', 'dispatch_refused_unsupported_input', 'dispatch_failed',
|
|
173
206
|
'session_exit', 'session_exit_before_turn', 'session_dead', 'hollow_completion',
|
|
@@ -186,7 +219,7 @@ export type TurnReason = typeof TURN_REASONS[number]
|
|
|
186
219
|
* owner's local `turn_events.payload_json` and is rendered at deliver time.
|
|
187
220
|
*/
|
|
188
221
|
export const NOTIFY_KINDS = [
|
|
189
|
-
'completed', 'failed', 'cancelled', 'stopped', 'approval', 'choice', 'approval_resolved',
|
|
222
|
+
'completed', 'blocked', 'failed', 'cancelled', 'stopped', 'approval', 'choice', 'approval_resolved',
|
|
190
223
|
'candidate', 'no_progress', 'progress', 'late_completion', 'mesh_event',
|
|
191
224
|
] as const
|
|
192
225
|
export type NotifyKind = typeof NOTIFY_KINDS[number]
|
|
@@ -207,7 +240,7 @@ export interface LiveTurnPending { modal: boolean; adapterPending: boolean; trai
|
|
|
207
240
|
/** Structural copy of daemon-core's `CoordinatorIdentity` (this package cannot import daemon-core). */
|
|
208
241
|
export interface EvidenceCoordinatorIdentity { daemonId: string; coordinatorRunId: string; sessionId?: string }
|
|
209
242
|
|
|
210
|
-
export interface NativeTurnMarkerRef { outcome: NativeTurnOutcome; turnId?: string }
|
|
243
|
+
export interface NativeTurnMarkerRef { outcome: NativeTurnOutcome; turnId?: string; receivedAt?: number; startedAt?: number; errorAt?: number }
|
|
211
244
|
|
|
212
245
|
export interface EvidenceEnvelope {
|
|
213
246
|
/** Stable id of this observation; dedupe key across republish/replication. */
|
|
@@ -250,10 +283,10 @@ export type TurnEvidenceBody =
|
|
|
250
283
|
| { kind: 'session_rebound'; toSessionId: string; reason: SessionReboundReason }
|
|
251
284
|
// ── worker turn lifecycle ──
|
|
252
285
|
| { kind: 'turn_started'; retro: boolean }
|
|
253
|
-
| { kind: 'suspension'; modal: SuspensionModal; modalKey?: string }
|
|
254
|
-
| { kind: 'suspension_resolved'; resolution: SuspensionResolution; via: SuspensionResolutionVia }
|
|
286
|
+
| { kind: 'suspension'; modal: SuspensionModal; modalKey?: string; providerSetup?: boolean; clockUnknown?: boolean }
|
|
287
|
+
| { kind: 'suspension_resolved'; resolution: SuspensionResolution; via: SuspensionResolutionVia; modalKey?: string }
|
|
255
288
|
| { kind: 'turn_end'; strength: TurnEndStrength; afterFinalizationTimeout?: boolean; hollow?: boolean; summary?: SummaryRef
|
|
256
|
-
blockReason?: TurnEndBlockReason; releasedByHardCap?: boolean; nativeOutcome?: NativeTurnOutcome; live?: LiveTurnPending
|
|
289
|
+
blockReason?: TurnEndBlockReason; releasedByHardCap?: boolean; nativeOutcome?: NativeTurnOutcome; nativeMarker?: NativeTurnMarkerRef; live?: LiveTurnPending
|
|
257
290
|
/**
|
|
258
291
|
* Stamped (true only) by the WORKER's daemon when the session holds a live
|
|
259
292
|
* worker-MCP session bind, i.e. the worker can call report_completion. The
|
|
@@ -273,7 +306,7 @@ export type TurnEvidenceBody =
|
|
|
273
306
|
live: LiveTurnPending; summary?: SummaryRef; messageAt?: number }
|
|
274
307
|
| { kind: 'transcript_activity'; newestActivityAt: number }
|
|
275
308
|
| { kind: 'no_progress'; stalledMs: number; observedStatus: NoProgressObservedStatus; finalAssistantPresent: boolean }
|
|
276
|
-
| { kind: 'liveness'; result: LivenessResult }
|
|
309
|
+
| { kind: 'liveness'; result: LivenessResult; probeStartedAtMs?: number }
|
|
277
310
|
| { kind: 'process_exit'; exitCode: number | null; providerFailure?: ProviderFailure }
|
|
278
311
|
| { kind: 'session_error'; reason: SessionErrorReason }
|
|
279
312
|
// ── worker MCP (F2) ──
|
|
@@ -284,6 +317,7 @@ export type TurnEvidenceBody =
|
|
|
284
317
|
*/
|
|
285
318
|
| { kind: 'worker_report'; outcome: WorkerReportOutcome; summary?: SummaryRef; hasHandoffNotes: boolean
|
|
286
319
|
branchState?: WorkerBranchState; touchedFileCount?: number }
|
|
320
|
+
| { kind: 'worker_report_correction_requested'; deliveryId?: string }
|
|
287
321
|
| { kind: 'worker_progress'; note?: SummaryRef }
|
|
288
322
|
// ── coordinator / operator ──
|
|
289
323
|
| { kind: 'git_side_effect'; dirty: boolean; commitsSinceDispatch: number; attributable: boolean }
|
|
@@ -352,13 +386,13 @@ export const TURN_EVIDENCE_FIELD_SPECS: TurnEvidenceFieldSpecs = {
|
|
|
352
386
|
duplicate_dispatch_refusal: { holderSessionId: id, holderAttemptId: idOpt },
|
|
353
387
|
session_rebound: { toSessionId: id, reason: en(SESSION_REBOUND_REASONS) },
|
|
354
388
|
turn_started: { retro: bool },
|
|
355
|
-
suspension: { modal: en(SUSPENSION_MODALS), modalKey: idOpt },
|
|
356
|
-
suspension_resolved: { resolution: en(SUSPENSION_RESOLUTIONS), via: en(SUSPENSION_RESOLUTION_VIAS) },
|
|
389
|
+
suspension: { modal: en(SUSPENSION_MODALS), modalKey: idOpt, providerSetup: boolOpt, clockUnknown: boolOpt },
|
|
390
|
+
suspension_resolved: { resolution: en(SUSPENSION_RESOLUTIONS), via: en(SUSPENSION_RESOLUTION_VIAS), modalKey: idOpt },
|
|
357
391
|
turn_end: {
|
|
358
392
|
strength: en(TURN_END_STRENGTHS), afterFinalizationTimeout: boolOpt, hollow: boolOpt,
|
|
359
393
|
summary: { t: 'summary_ref', optional: true }, blockReason: enOpt(TURN_END_BLOCK_REASONS),
|
|
360
394
|
releasedByHardCap: boolOpt, nativeOutcome: enOpt(NATIVE_TURN_OUTCOMES), live: { t: 'live', optional: true },
|
|
361
|
-
reportExpected: boolOpt, providerFailure: enOpt(PROVIDER_FAILURES),
|
|
395
|
+
nativeMarker: { t: 'native_marker', optional: true }, reportExpected: boolOpt, providerFailure: enOpt(PROVIDER_FAILURES),
|
|
362
396
|
},
|
|
363
397
|
transcript_final: {
|
|
364
398
|
selfAttributing: bool, nativeRead: bool, nativeMarker: { t: 'native_marker', optional: true },
|
|
@@ -366,13 +400,14 @@ export const TURN_EVIDENCE_FIELD_SPECS: TurnEvidenceFieldSpecs = {
|
|
|
366
400
|
},
|
|
367
401
|
transcript_activity: { newestActivityAt: ms },
|
|
368
402
|
no_progress: { stalledMs: ms, observedStatus: en(NO_PROGRESS_OBSERVED_STATUSES), finalAssistantPresent: bool },
|
|
369
|
-
liveness: { result: en(LIVENESS_RESULTS) },
|
|
403
|
+
liveness: { result: en(LIVENESS_RESULTS), probeStartedAtMs: msOpt },
|
|
370
404
|
process_exit: { exitCode: { t: 'int', nullable: true }, providerFailure: enOpt(PROVIDER_FAILURES) },
|
|
371
405
|
session_error: { reason: en(SESSION_ERROR_REASONS) },
|
|
372
406
|
worker_report: {
|
|
373
407
|
outcome: en(WORKER_REPORT_OUTCOMES), summary: { t: 'summary_ref', optional: true }, hasHandoffNotes: bool,
|
|
374
408
|
branchState: enOpt(WORKER_BRANCH_STATES), touchedFileCount: intOpt,
|
|
375
409
|
},
|
|
410
|
+
worker_report_correction_requested: { deliveryId: { t: 'id', optional: true } },
|
|
376
411
|
worker_progress: { note: { t: 'summary_ref', optional: true } },
|
|
377
412
|
git_side_effect: { dirty: bool, commitsSinceDispatch: { t: 'int' }, attributable: bool },
|
|
378
413
|
cancel: { reason: en(CANCEL_REASONS) },
|
|
@@ -440,11 +475,12 @@ function isLiveTurnPending(value: unknown): value is LiveTurnPending {
|
|
|
440
475
|
&& (value.newestActivityAt === undefined || isFiniteNumber(value.newestActivityAt))
|
|
441
476
|
}
|
|
442
477
|
|
|
443
|
-
function isNativeMarkerRef(value: unknown): value is NativeTurnMarkerRef {
|
|
478
|
+
export function isNativeMarkerRef(value: unknown): value is NativeTurnMarkerRef {
|
|
444
479
|
return isRecord(value)
|
|
445
|
-
&& hasOnlyKeys(value, ['outcome', 'turnId'])
|
|
480
|
+
&& hasOnlyKeys(value, ['outcome', 'turnId', 'receivedAt', 'startedAt', 'errorAt'])
|
|
446
481
|
&& (NATIVE_TURN_OUTCOMES as readonly string[]).includes(value.outcome as string)
|
|
447
482
|
&& (value.turnId === undefined || isEvidenceIdentifier(value.turnId))
|
|
483
|
+
&& ['receivedAt', 'startedAt', 'errorAt'].every((key) => value[key] === undefined || isFiniteNumber(value[key]))
|
|
448
484
|
}
|
|
449
485
|
|
|
450
486
|
function isCoordinatorIdentity(value: unknown): value is EvidenceCoordinatorIdentity {
|
package/src/turn-ipc-mission.ts
CHANGED
|
@@ -85,9 +85,46 @@ export interface MissionUpsertRequest {
|
|
|
85
85
|
* this wire guard only checks SHAPE, not that decision.
|
|
86
86
|
*/
|
|
87
87
|
brief?: MissionBriefWire | null
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
88
|
+
/**
|
|
89
|
+
* Structured-missions bundle A (design 2026-10-28 §5.1). Every key below is optional
|
|
90
|
+
* and ABSENT on a legacy call. `structured: true` is the caller's capability flag: the
|
|
91
|
+
* daemon only puts the new keys on the response (mission summary/outcome/version,
|
|
92
|
+
* `result`) when it is set, so an older mcp-server that never sends it keeps decoding
|
|
93
|
+
* byte-identical responses (mixed-version fleets, design §13.1).
|
|
94
|
+
*/
|
|
95
|
+
structured?: boolean
|
|
96
|
+
summary?: string
|
|
97
|
+
/** One user/operator-visible sentence for the release CHANGELOG draft (design 2026-11-01-release-objects L5). `''` clears. */
|
|
98
|
+
releaseNote?: string
|
|
99
|
+
outcome?: string
|
|
100
|
+
outcomeReason?: string
|
|
101
|
+
/** Mission id open items move to when this call closes the mission (default: the carry-over mission). */
|
|
102
|
+
carryOverTo?: string
|
|
103
|
+
/** Route to the mesh's auto-created carry-over mission instead of `id`/`title` (decision requests without a mission). `title` may then be empty. */
|
|
104
|
+
toCarryOver?: boolean
|
|
105
|
+
itemsAdd?: readonly Record<string, unknown>[]
|
|
106
|
+
itemsUpdate?: readonly Record<string, unknown>[]
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
export interface MeshMissionOpenItemCountsWire {
|
|
110
|
+
remaining: number
|
|
111
|
+
live_check: number
|
|
112
|
+
decision: number
|
|
113
|
+
evidence: number
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
/** Structured-missions fields (only with `structured: true` on the request). */
|
|
117
|
+
export interface MeshMissionStructuredWire {
|
|
118
|
+
summary?: string
|
|
119
|
+
releaseNote?: string
|
|
120
|
+
outcome?: string
|
|
121
|
+
outcomeReason?: string
|
|
122
|
+
version?: number
|
|
123
|
+
carryOver?: boolean
|
|
124
|
+
openItems?: MeshMissionOpenItemCountsWire
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
export interface MeshMissionRecordWire extends MeshMissionStructuredWire {
|
|
91
128
|
id: string
|
|
92
129
|
meshId: string
|
|
93
130
|
title: string
|
|
@@ -99,10 +136,30 @@ export interface MeshMissionRecordWire {
|
|
|
99
136
|
|
|
100
137
|
export interface MissionUpsertResponse {
|
|
101
138
|
mission: MeshMissionRecordWire
|
|
139
|
+
/** Structured calls only: per-item results, movedItems/movedTo, restoredItems, ownerConfirmationItemId, warnings. */
|
|
140
|
+
result?: Record<string, unknown>
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
const STRUCTURED_MISSION_KEYS = ['summary', 'releaseNote', 'outcome', 'outcomeReason', 'version', 'carryOver', 'openItems'] as const
|
|
144
|
+
|
|
145
|
+
function isOpenItemCountsWire(value: unknown): value is MeshMissionOpenItemCountsWire {
|
|
146
|
+
if (!isRecord(value) || !hasOnlyKeys(value, ['remaining', 'live_check', 'decision', 'evidence'])) return false
|
|
147
|
+
return (['remaining', 'live_check', 'decision', 'evidence'] as const).every((k) => isNonNegativeInt(value[k]))
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
function isStructuredMissionFields(value: Record<string, unknown>): boolean {
|
|
151
|
+
for (const k of ['summary', 'releaseNote', 'outcome', 'outcomeReason'] as const) {
|
|
152
|
+
if (value[k] !== undefined && typeof value[k] !== 'string') return false
|
|
153
|
+
}
|
|
154
|
+
if (value.version !== undefined && !isNonNegativeInt(value.version)) return false
|
|
155
|
+
if (value.carryOver !== undefined && typeof value.carryOver !== 'boolean') return false
|
|
156
|
+
if (value.openItems !== undefined && !isOpenItemCountsWire(value.openItems)) return false
|
|
157
|
+
return true
|
|
102
158
|
}
|
|
103
159
|
|
|
104
160
|
function isMeshMissionRecordWire(value: unknown): value is MeshMissionRecordWire {
|
|
105
|
-
if (!isRecord(value) || !hasOnlyKeys(value, ['id', 'meshId', 'title', 'goal', 'status', 'brief'])) return false
|
|
161
|
+
if (!isRecord(value) || !hasOnlyKeys(value, ['id', 'meshId', 'title', 'goal', 'status', 'brief', ...STRUCTURED_MISSION_KEYS])) return false
|
|
162
|
+
if (!isStructuredMissionFields(value)) return false
|
|
106
163
|
if (!isEvidenceIdentifier(value.id) || !isEvidenceIdentifier(value.meshId)) return false
|
|
107
164
|
if (typeof value.title !== 'string' || typeof value.goal !== 'string') return false
|
|
108
165
|
if (!isMeshMissionStatusValue(value.status)) return false
|
|
@@ -111,11 +168,24 @@ function isMeshMissionRecordWire(value: unknown): value is MeshMissionRecordWire
|
|
|
111
168
|
}
|
|
112
169
|
|
|
113
170
|
function isMissionUpsertRequest(value: unknown): value is MissionUpsertRequest {
|
|
114
|
-
if (!isRecord(value) || !hasOnlyKeys(value, ['v', 'meshId', 'id', 'title', 'goal', 'status', 'brief'])) return false
|
|
171
|
+
if (!isRecord(value) || !hasOnlyKeys(value, ['v', 'meshId', 'id', 'title', 'goal', 'status', 'brief', 'structured', 'summary', 'releaseNote', 'outcome', 'outcomeReason', 'carryOverTo', 'toCarryOver', 'itemsAdd', 'itemsUpdate'])) return false
|
|
115
172
|
if (value.v !== TURN_IPC_PROTOCOL_VERSION) return false
|
|
116
173
|
if (!isEvidenceIdentifier(value.meshId)) return false
|
|
117
174
|
if (value.id !== undefined && !isEvidenceIdentifier(value.id)) return false
|
|
118
|
-
if (typeof value.title !== 'string'
|
|
175
|
+
if (typeof value.title !== 'string') return false
|
|
176
|
+
// An empty title is allowed only when the daemon can supply one: an existing mission (id) or the carry-over mission.
|
|
177
|
+
if (value.title.trim().length === 0 && value.toCarryOver !== true && value.id === undefined) return false
|
|
178
|
+
if (value.structured !== undefined && typeof value.structured !== 'boolean') return false
|
|
179
|
+
if (value.toCarryOver !== undefined && typeof value.toCarryOver !== 'boolean') return false
|
|
180
|
+
for (const k of ['summary', 'releaseNote', 'outcome', 'outcomeReason'] as const) {
|
|
181
|
+
if (value[k] !== undefined && typeof value[k] !== 'string') return false
|
|
182
|
+
}
|
|
183
|
+
if (value.carryOverTo !== undefined && !isEvidenceIdentifier(value.carryOverTo)) return false
|
|
184
|
+
for (const k of ['itemsAdd', 'itemsUpdate'] as const) {
|
|
185
|
+
const list = value[k]
|
|
186
|
+
// Bounded only to keep the IPC message sane; per-entry shape/size is clamped (never rejected) by the daemon.
|
|
187
|
+
if (list !== undefined && (!Array.isArray(list) || list.length > 500 || !list.every(isRecord))) return false
|
|
188
|
+
}
|
|
119
189
|
if (value.goal !== undefined && typeof value.goal !== 'string') return false
|
|
120
190
|
if (value.status !== undefined && !isMeshMissionStatusValue(value.status)) return false
|
|
121
191
|
if (value.brief !== undefined && value.brief !== null && !isMissionBriefWire(value.brief)) return false
|
|
@@ -127,7 +197,8 @@ export function decodeMissionUpsertRequest(value: unknown): MissionUpsertRequest
|
|
|
127
197
|
}
|
|
128
198
|
|
|
129
199
|
export function isMissionUpsertResponse(value: unknown): value is MissionUpsertResponse {
|
|
130
|
-
return isRecord(value) && hasOnlyKeys(value, ['mission']) && isMeshMissionRecordWire(value.mission)
|
|
200
|
+
return isRecord(value) && hasOnlyKeys(value, ['mission', 'result']) && isMeshMissionRecordWire(value.mission)
|
|
201
|
+
&& (value.result === undefined || isRecord(value.result))
|
|
131
202
|
}
|
|
132
203
|
|
|
133
204
|
export function decodeMissionUpsertResponse(value: unknown): MissionUpsertResponse | null {
|
|
@@ -207,6 +278,12 @@ export interface MissionListQueryRequest {
|
|
|
207
278
|
* option except `historyIdLimit` is ignored. An older daemon rejects the key.
|
|
208
279
|
*/
|
|
209
280
|
meshStatusView?: 'compact' | 'verbose'
|
|
281
|
+
/** Structured-missions capability flag (see MissionUpsertRequest.structured): rows then carry summary/outcome/openItems/carryOver/version. */
|
|
282
|
+
structured?: boolean
|
|
283
|
+
/** Structured only: attach each mission's items. */
|
|
284
|
+
items?: boolean
|
|
285
|
+
/** Structured only: attach each mission's change history (bounded tail). */
|
|
286
|
+
history?: boolean
|
|
210
287
|
}
|
|
211
288
|
|
|
212
289
|
export interface MeshMissionTaskAggregateWire {
|
|
@@ -221,6 +298,8 @@ export interface MeshMissionTaskAggregateWire {
|
|
|
221
298
|
}
|
|
222
299
|
|
|
223
300
|
export interface MeshMissionStatsWire {
|
|
301
|
+
/** Present on peers that project proven blocked outcomes separately. */
|
|
302
|
+
blocked?: number
|
|
224
303
|
missionId: string
|
|
225
304
|
taskCount: number
|
|
226
305
|
completed: number
|
|
@@ -246,6 +325,16 @@ export interface MissionListSummaryVerboseWire {
|
|
|
246
325
|
createdAt?: string
|
|
247
326
|
updatedAt?: string
|
|
248
327
|
closeCandidateEmittedAt?: string | null
|
|
328
|
+
/** Structured lists only. */
|
|
329
|
+
summary?: string
|
|
330
|
+
releaseNote?: string
|
|
331
|
+
outcome?: string
|
|
332
|
+
outcomeReason?: string
|
|
333
|
+
version?: number
|
|
334
|
+
carryOver?: boolean
|
|
335
|
+
openItems?: MeshMissionOpenItemCountsWire
|
|
336
|
+
items?: readonly Record<string, unknown>[]
|
|
337
|
+
history?: readonly Record<string, unknown>[]
|
|
249
338
|
}
|
|
250
339
|
|
|
251
340
|
/** Compact (default) mission row. `goalPreview`/`goalTruncated` present, `goal` absent. */
|
|
@@ -264,6 +353,16 @@ export interface MissionListSummarySlimWire {
|
|
|
264
353
|
createdAt?: string
|
|
265
354
|
updatedAt?: string
|
|
266
355
|
closeCandidateEmittedAt?: string | null
|
|
356
|
+
/** Structured lists only. */
|
|
357
|
+
summary?: string
|
|
358
|
+
releaseNote?: string
|
|
359
|
+
outcome?: string
|
|
360
|
+
outcomeReason?: string
|
|
361
|
+
version?: number
|
|
362
|
+
carryOver?: boolean
|
|
363
|
+
openItems?: MeshMissionOpenItemCountsWire
|
|
364
|
+
items?: readonly Record<string, unknown>[]
|
|
365
|
+
history?: readonly Record<string, unknown>[]
|
|
267
366
|
}
|
|
268
367
|
|
|
269
368
|
export type MissionListSummaryWire = MissionListSummaryVerboseWire | MissionListSummarySlimWire
|
|
@@ -284,7 +383,10 @@ export interface MissionListQueryResponse {
|
|
|
284
383
|
}
|
|
285
384
|
|
|
286
385
|
function isMissionListQueryRequest(value: unknown): value is MissionListQueryRequest {
|
|
287
|
-
if (!isRecord(value) || !hasOnlyKeys(value, ['v', 'meshId', 'statuses', 'verbose', 'withStats', 'limit', 'historyIdLimit', 'meshStatusView'])) return false
|
|
386
|
+
if (!isRecord(value) || !hasOnlyKeys(value, ['v', 'meshId', 'statuses', 'verbose', 'withStats', 'limit', 'historyIdLimit', 'meshStatusView', 'structured', 'items', 'history'])) return false
|
|
387
|
+
for (const k of ['structured', 'items', 'history'] as const) {
|
|
388
|
+
if (value[k] !== undefined && typeof value[k] !== 'boolean') return false
|
|
389
|
+
}
|
|
288
390
|
if (value.meshStatusView !== undefined && value.meshStatusView !== 'compact' && value.meshStatusView !== 'verbose') return false
|
|
289
391
|
if (value.v !== TURN_IPC_PROTOCOL_VERSION) return false
|
|
290
392
|
if (!isEvidenceIdentifier(value.meshId)) return false
|
|
@@ -313,12 +415,13 @@ function isMeshMissionTaskAggregateWire(value: unknown): value is MeshMissionTas
|
|
|
313
415
|
}
|
|
314
416
|
|
|
315
417
|
function isMeshMissionStatsWire(value: unknown): value is MeshMissionStatsWire {
|
|
316
|
-
const keys = ['missionId', 'taskCount', 'completed', 'failed', 'totalDurationMs', 'wallClockMs', 'retries', 'incompleteTaskIds'] as const
|
|
418
|
+
const keys = ['missionId', 'taskCount', 'completed', 'failed', 'blocked', 'totalDurationMs', 'wallClockMs', 'retries', 'incompleteTaskIds'] as const
|
|
317
419
|
if (!isRecord(value) || !hasOnlyKeys(value, keys)) return false
|
|
318
420
|
if (!isEvidenceIdentifier(value.missionId)) return false
|
|
319
421
|
for (const k of ['taskCount', 'completed', 'failed', 'totalDurationMs', 'retries'] as const) {
|
|
320
422
|
if (!isNonNegativeInt(value[k])) return false
|
|
321
423
|
}
|
|
424
|
+
if (value.blocked !== undefined && !isNonNegativeInt(value.blocked)) return false
|
|
322
425
|
if (value.wallClockMs !== null && !isNonNegativeInt(value.wallClockMs)) return false
|
|
323
426
|
if (!Array.isArray(value.incompleteTaskIds) || !value.incompleteTaskIds.every(isEvidenceIdentifier)) return false
|
|
324
427
|
return true
|
|
@@ -329,7 +432,7 @@ function isMissionListSummaryWire(value: unknown): value is MissionListSummaryWi
|
|
|
329
432
|
const hasGoal = 'goal' in value
|
|
330
433
|
const hasPreview = 'goalPreview' in value && 'goalTruncated' in value
|
|
331
434
|
if (hasGoal === hasPreview) return false // exactly one of the two shapes
|
|
332
|
-
const baseKeys = ['id', 'meshId', 'title', 'status', 'tasks', 'stats', 'brief', 'createdAt', 'updatedAt', 'closeCandidateEmittedAt'] as const
|
|
435
|
+
const baseKeys = ['id', 'meshId', 'title', 'status', 'tasks', 'stats', 'brief', 'createdAt', 'updatedAt', 'closeCandidateEmittedAt', ...STRUCTURED_MISSION_KEYS, 'items', 'history'] as const
|
|
333
436
|
const allowed = hasGoal ? [...baseKeys, 'goal'] : [...baseKeys, 'goalPreview', 'goalTruncated']
|
|
334
437
|
if (!hasOnlyKeys(value, allowed)) return false
|
|
335
438
|
if (!isEvidenceIdentifier(value.id) || !isEvidenceIdentifier(value.meshId)) return false
|
|
@@ -343,6 +446,10 @@ function isMissionListSummaryWire(value: unknown): value is MissionListSummaryWi
|
|
|
343
446
|
if (value.createdAt !== undefined && typeof value.createdAt !== 'string') return false
|
|
344
447
|
if (value.updatedAt !== undefined && typeof value.updatedAt !== 'string') return false
|
|
345
448
|
if (value.closeCandidateEmittedAt !== undefined && value.closeCandidateEmittedAt !== null && typeof value.closeCandidateEmittedAt !== 'string') return false
|
|
449
|
+
if (!isStructuredMissionFields(value)) return false
|
|
450
|
+
for (const k of ['items', 'history'] as const) {
|
|
451
|
+
if (value[k] !== undefined && (!Array.isArray(value[k]) || !(value[k] as unknown[]).every(isRecord))) return false
|
|
452
|
+
}
|
|
346
453
|
return true
|
|
347
454
|
}
|
|
348
455
|
|
|
@@ -580,6 +687,12 @@ export interface LedgerQueryEntryWire {
|
|
|
580
687
|
}
|
|
581
688
|
|
|
582
689
|
export interface LedgerQuerySummaryWire {
|
|
690
|
+
/** Absent on older peers; never folded into failed by the decoder. */
|
|
691
|
+
taskBlocked?: number
|
|
692
|
+
/** Failed Refinery jobs (not tasks). Absent on older peers. Lifetime, not the current window. */
|
|
693
|
+
refineFailed?: number
|
|
694
|
+
/** Refine failures inside the 30-minute current window. Absent on older peers. */
|
|
695
|
+
recentRefineFailures?: number
|
|
583
696
|
meshId: string
|
|
584
697
|
totalEntries: number
|
|
585
698
|
taskDispatched: number
|
|
@@ -625,12 +738,15 @@ function isLedgerQueryEntryWire(value: unknown): value is LedgerQueryEntryWire {
|
|
|
625
738
|
}
|
|
626
739
|
|
|
627
740
|
function isLedgerQuerySummaryWire(value: unknown): value is LedgerQuerySummaryWire {
|
|
628
|
-
const keys = ['meshId', 'totalEntries', 'taskDispatched', 'taskCompleted', 'taskFailed', 'taskStalled', 'sessionLaunched', 'checkpointCreated', 'lastActivityAt', 'recentFailures'] as const
|
|
741
|
+
const keys = ['meshId', 'totalEntries', 'taskDispatched', 'taskCompleted', 'taskFailed', 'taskBlocked', 'taskStalled', 'sessionLaunched', 'checkpointCreated', 'lastActivityAt', 'recentFailures', 'taskBlocked', 'refineFailed', 'recentRefineFailures'] as const
|
|
629
742
|
if (!isRecord(value) || !hasOnlyKeys(value, keys)) return false
|
|
630
743
|
if (!isEvidenceIdentifier(value.meshId)) return false
|
|
631
744
|
for (const k of ['totalEntries', 'taskDispatched', 'taskCompleted', 'taskFailed', 'taskStalled', 'sessionLaunched', 'checkpointCreated', 'recentFailures'] as const) {
|
|
632
745
|
if (!isNonNegativeInt(value[k])) return false
|
|
633
746
|
}
|
|
747
|
+
if (value.taskBlocked !== undefined && !isNonNegativeInt(value.taskBlocked)) return false
|
|
748
|
+
if (value.refineFailed !== undefined && !isNonNegativeInt(value.refineFailed)) return false
|
|
749
|
+
if (value.recentRefineFailures !== undefined && !isNonNegativeInt(value.recentRefineFailures)) return false
|
|
634
750
|
if (value.lastActivityAt !== null && typeof value.lastActivityAt !== 'string') return false
|
|
635
751
|
return true
|
|
636
752
|
}
|
package/src/turn-ipc-queue.ts
CHANGED
|
@@ -135,6 +135,8 @@ export interface QueueQueryResponse {
|
|
|
135
135
|
counts?: Record<string, number>
|
|
136
136
|
/** `withCounts` + `historicalOlderThanMs`: terminal rows older than that age. */
|
|
137
137
|
oldHistoricalCount?: number
|
|
138
|
+
/** Included in counts.blocked, derived from proven worker reports; stored failed rows stay unchanged. */
|
|
139
|
+
legacyReportedBlockedCount?: number
|
|
138
140
|
/** `withDependencyHeads`. */
|
|
139
141
|
dependencyHeads?: readonly QueueDependencyHeadWire[]
|
|
140
142
|
}
|
|
@@ -159,9 +161,10 @@ function isQueueDependencyHeadWire(value: unknown): value is QueueDependencyHead
|
|
|
159
161
|
}
|
|
160
162
|
|
|
161
163
|
function isQueueQueryResponse(value: unknown): value is QueueQueryResponse {
|
|
162
|
-
if (!isRecord(value) || !hasOnlyKeys(value, ['entries', 'counts', 'oldHistoricalCount', 'dependencyHeads'])) return false
|
|
164
|
+
if (!isRecord(value) || !hasOnlyKeys(value, ['entries', 'counts', 'oldHistoricalCount', 'legacyReportedBlockedCount', 'dependencyHeads'])) return false
|
|
163
165
|
if (!Array.isArray(value.entries) || !value.entries.every(isQueueEntryWire)) return false
|
|
164
166
|
if (value.counts !== undefined && (!isRecord(value.counts) || !Object.values(value.counts).every(isNonNegativeInt))) return false
|
|
167
|
+
if (value.legacyReportedBlockedCount !== undefined && !isNonNegativeInt(value.legacyReportedBlockedCount)) return false
|
|
165
168
|
if (value.oldHistoricalCount !== undefined && !isNonNegativeInt(value.oldHistoricalCount)) return false
|
|
166
169
|
if (value.dependencyHeads !== undefined && (!Array.isArray(value.dependencyHeads) || !value.dependencyHeads.every(isQueueDependencyHeadWire))) return false
|
|
167
170
|
return true
|
|
@@ -305,6 +308,8 @@ export interface QueueRequeueRequest {
|
|
|
305
308
|
|
|
306
309
|
export interface QueueRequeueResponse {
|
|
307
310
|
task: QueueEntryWire | null
|
|
311
|
+
/** queue_revise {requestQuotaOverride}: the owner decision that was raised (or already open). Never a grant. */
|
|
312
|
+
quotaOverrideRequested?: { decisionId: string; alreadyAsked: boolean; options: string[] }
|
|
308
313
|
}
|
|
309
314
|
|
|
310
315
|
function isQueueRequeueRequest(value: unknown): value is QueueRequeueRequest {
|
|
@@ -318,7 +323,8 @@ export function decodeQueueRequeueRequest(value: unknown): QueueRequeueRequest |
|
|
|
318
323
|
}
|
|
319
324
|
|
|
320
325
|
function isQueueRequeueResponse(value: unknown): value is QueueRequeueResponse {
|
|
321
|
-
return isRecord(value) && hasOnlyKeys(value, ['task']) && (value.task === null || isQueueEntryWire(value.task))
|
|
326
|
+
return isRecord(value) && hasOnlyKeys(value, ['task', 'quotaOverrideRequested']) && (value.task === null || isQueueEntryWire(value.task))
|
|
327
|
+
&& (value.quotaOverrideRequested === undefined || (isRecord(value.quotaOverrideRequested) && typeof value.quotaOverrideRequested.decisionId === 'string'))
|
|
322
328
|
}
|
|
323
329
|
|
|
324
330
|
export function decodeQueueRequeueResponse(value: unknown): QueueRequeueResponse | null {
|
|
@@ -491,3 +497,40 @@ function isRecoveryContextQueryResponse(value: unknown): value is RecoveryContex
|
|
|
491
497
|
export function decodeRecoveryContextQueryResponse(value: unknown): RecoveryContextQueryResponse | null {
|
|
492
498
|
return isRecoveryContextQueryResponse(value) ? value : null
|
|
493
499
|
}
|
|
500
|
+
|
|
501
|
+
// ── queue_revise: host-authenticated pending CAS, never a force requeue ──
|
|
502
|
+
export interface QueueReviseRequest {
|
|
503
|
+
v: typeof TURN_IPC_PROTOCOL_VERSION
|
|
504
|
+
meshId: string
|
|
505
|
+
taskId: string
|
|
506
|
+
expectedRevision: number
|
|
507
|
+
dryRun?: boolean
|
|
508
|
+
deferScheduling?: boolean
|
|
509
|
+
patch: { message?: string; ownedPaths?: string[]; phase?: 'source' | 'integration'; dependsOn?: string[]; routingPreferences?: import('./task-source-phase').MeshRoutingPreferences; review?: import('./task-source-phase').MeshReviewConstraint; difficulty?: 'easy' | 'medium' | 'difficult' | 'freeform'; requestQuotaOverride?: true; attestActiveOwnership?: true }
|
|
510
|
+
}
|
|
511
|
+
export type QueueReviseResponse = QueueRequeueResponse
|
|
512
|
+
export function decodeQueueReviseRequest(value: unknown): QueueReviseRequest | null {
|
|
513
|
+
if (!isRecord(value) || !hasOnlyKeys(value, ['v', 'meshId', 'taskId', 'expectedRevision', 'patch', 'dryRun', 'deferScheduling'])
|
|
514
|
+
|| value.v !== TURN_IPC_PROTOCOL_VERSION || !isEvidenceIdentifier(value.meshId) || !isEvidenceIdentifier(value.taskId)
|
|
515
|
+
|| !Number.isSafeInteger(value.expectedRevision) || (value.expectedRevision as number) < 0
|
|
516
|
+
|| !isRecord(value.patch) || !Object.keys(value.patch).length
|
|
517
|
+
|| !hasOnlyKeys(value.patch, ['message', 'ownedPaths', 'phase', 'dependsOn', 'routingPreferences', 'review', 'difficulty', 'requestQuotaOverride', 'attestActiveOwnership'])) return null
|
|
518
|
+
if (value.dryRun !== undefined && typeof value.dryRun !== 'boolean') return null
|
|
519
|
+
if (value.deferScheduling !== undefined && typeof value.deferScheduling !== 'boolean') return null
|
|
520
|
+
const p = value.patch
|
|
521
|
+
if (p.requestQuotaOverride && (value.dryRun !== undefined || value.deferScheduling !== undefined)) return null
|
|
522
|
+
if (p.requestQuotaOverride !== undefined && (p.requestQuotaOverride !== true || Object.keys(p).length !== 1)) return null
|
|
523
|
+
// Alone, like the quota request: it edits no field, it only attaches the missing physical proof of a running writer.
|
|
524
|
+
// `dry_run` is allowed (the hold text recommends it): it validates the same gates and saves nothing.
|
|
525
|
+
// There is nothing to defer, so `defer_scheduling` stays refused.
|
|
526
|
+
if (p.attestActiveOwnership && value.deferScheduling !== undefined) return null
|
|
527
|
+
if (p.attestActiveOwnership !== undefined && (p.attestActiveOwnership !== true || Object.keys(p).length !== 1)) return null
|
|
528
|
+
if (p.message !== undefined && (typeof p.message !== 'string' || !p.message.trim())) return null
|
|
529
|
+
if (p.phase !== undefined && p.phase !== 'source' && p.phase !== 'integration') return null
|
|
530
|
+
if (p.difficulty !== undefined && p.difficulty !== 'easy' && p.difficulty !== 'medium' && p.difficulty !== 'difficult' && p.difficulty !== 'freeform') return null
|
|
531
|
+
for (const key of ['ownedPaths', 'dependsOn']) {
|
|
532
|
+
if (p[key] !== undefined && (!Array.isArray(p[key]) || !(p[key] as unknown[]).every(x => typeof x === 'string' && !!x.trim()))) return null
|
|
533
|
+
}
|
|
534
|
+
return value as unknown as QueueReviseRequest
|
|
535
|
+
}
|
|
536
|
+
export const decodeQueueReviseResponse = decodeQueueRequeueResponse
|
package/src/turn-ipc-turn.ts
CHANGED
|
@@ -66,7 +66,7 @@ function isTurnObserveResponse(value: unknown): value is TurnObserveResponse {
|
|
|
66
66
|
&& (value.outcome === undefined || isTurnOutcomeValue(value.outcome))
|
|
67
67
|
}
|
|
68
68
|
|
|
69
|
-
const TURN_OUTCOMES_LOCAL = ['completed', 'failed', 'cancelled'] as const
|
|
69
|
+
const TURN_OUTCOMES_LOCAL = ['completed', 'blocked', 'failed', 'cancelled'] as const
|
|
70
70
|
function isTurnOutcomeValue(value: unknown): value is TurnOutcome {
|
|
71
71
|
return typeof value === 'string' && (TURN_OUTCOMES_LOCAL as readonly string[]).includes(value)
|
|
72
72
|
}
|
package/src/turn-ipc.ts
CHANGED
package/src/types.ts
CHANGED