@adhdev/mesh-shared 1.0.60-rc.4 → 1.0.60-rc.41

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 (39) hide show
  1. package/dist/index.d.ts +10 -0
  2. package/dist/index.js +2764 -17
  3. package/dist/index.js.map +1 -1
  4. package/dist/index.mjs +2441 -17
  5. package/dist/index.mjs.map +1 -1
  6. package/dist/mesh-tool-names.d.ts +2 -2
  7. package/dist/mesh-vocabulary.d.ts +70 -0
  8. package/dist/mission-brief.d.ts +62 -0
  9. package/dist/outbound-message.d.ts +202 -0
  10. package/dist/path-ownership.d.ts +101 -0
  11. package/dist/protocol/daemon-server.d.ts +388 -0
  12. package/dist/protocol/dashboard-daemon-p2p.d.ts +212 -0
  13. package/dist/protocol/dashboard-server.d.ts +240 -0
  14. package/dist/protocol/envelope.d.ts +55 -0
  15. package/dist/protocol/index.d.ts +15 -0
  16. package/dist/session-launch.d.ts +113 -0
  17. package/dist/session-status.d.ts +61 -0
  18. package/dist/turn-evidence.d.ts +407 -0
  19. package/dist/turn-ipc.d.ts +974 -0
  20. package/dist/worker-protocol.d.ts +69 -0
  21. package/dist/ws-protocol.d.ts +71 -41
  22. package/package.json +1 -1
  23. package/src/index.ts +10 -0
  24. package/src/mesh-tool-names.ts +0 -1
  25. package/src/mesh-vocabulary.ts +98 -0
  26. package/src/mission-brief.ts +153 -0
  27. package/src/outbound-message.ts +320 -0
  28. package/src/path-ownership.ts +271 -0
  29. package/src/protocol/daemon-server.ts +552 -0
  30. package/src/protocol/dashboard-daemon-p2p.ts +272 -0
  31. package/src/protocol/dashboard-server.ts +340 -0
  32. package/src/protocol/envelope.ts +75 -0
  33. package/src/protocol/index.ts +16 -0
  34. package/src/session-launch.ts +247 -0
  35. package/src/session-status.ts +140 -0
  36. package/src/turn-evidence.ts +562 -0
  37. package/src/turn-ipc.ts +2231 -0
  38. package/src/worker-protocol.ts +142 -0
  39. package/src/ws-protocol.ts +102 -93
@@ -0,0 +1,974 @@
1
+ /**
2
+ * turn-ipc — typed IPC command contracts for the six commands that replace
3
+ * mcp-server's direct `mesh-runtime.db` access (design §5 C2 "MCP server").
4
+ *
5
+ * Wiring-unification Phase C, workstream C-W6
6
+ * (docs/design/2026-09-23-wiring-unification.md §5 C2/C3, C9 row C-W6).
7
+ *
8
+ * WHY THIS FILE EXISTS
9
+ * ---------------------
10
+ * mcp-server is a second, in-process writer of `mesh-runtime.db` (~45-69
11
+ * direct-mutation call sites, ~54 reads, per the C-W6 brief). C2 moves every
12
+ * one of those call sites behind IPC, executed in the daemon that owns the
13
+ * turn ledger and the seqscribe node, so mcp-server never opens the SQLite
14
+ * file itself. This file is the WIRE CONTRACT for that IPC surface — request/
15
+ * response shapes, closed enums, runtime decoders — shared by the daemon-core
16
+ * command handlers (added with C-W6 proper; NOT this file) and the mcp-server
17
+ * client (`mcp-server/src/ipc/turn-commands.ts`, this workstream).
18
+ *
19
+ * The six commands (§5 C2):
20
+ * - turn_observe — submit one TurnEvidence; returns the reducer verdict.
21
+ * - mesh_record — append a content-free scalar record (`mesh.record`
22
+ * topic entry), replacing `appendLedgerEntry`.
23
+ * - turn_cancel — cancel an attempt (`cancel` evidence, source `mcp_probe`
24
+ * or `operator`).
25
+ * - operator_status — record a fire-and-forget operator/tool-call status
26
+ * (`operator_status` evidence + the former
27
+ * `recordMeshCoordinatorToolCall` log write).
28
+ * - turn_query — read attempt/event rows (own or fleet scope).
29
+ * - mesh_index_query — read `mesh_topic_index` rows (fleet-wide, replacing
30
+ * the in-memory read model / parity reads).
31
+ *
32
+ * CONTENT BOUNDARY
33
+ * -----------------
34
+ * Every request/response field is an identifier, a closed enum, a boolean, a
35
+ * counter or a timestamp. `turn_observe` carries a `TurnEvidence`, which is
36
+ * content-free by construction (`turn-evidence.ts`). `mesh_record` carries a
37
+ * `ProjectedScalars` payload restricted to the SAME allow-list keys
38
+ * `seqscribe/mesh-event-projection.ts` already reviews and ships
39
+ * (`PROJECTED_PAYLOAD_KEYS`, 35 keys) — this file pins a STRUCTURAL COPY of
40
+ * that key list (`MESH_RECORD_PAYLOAD_KEYS`) so mesh-shared does not import
41
+ * daemon-core (leaf constraint), with a test asserting the two lists agree.
42
+ * Summaries, report bodies, progress notes and modal text never travel in any
43
+ * of these payloads — they go to the content-class `mesh.<id>.handoff` topic
44
+ * and are referenced by `SummaryRef {topic, writer, seq}` (already declared
45
+ * in `./turn-evidence.ts`).
46
+ *
47
+ * VERSIONING
48
+ * -----------
49
+ * Every request carries `v: 1` so a future incompatible change can be
50
+ * detected by the responder before it tries to interpret the args.
51
+ */
52
+ import { type ProjectedScalars, type TurnAttemptRef, type TurnEvidence, type TurnEvidenceKind, type TurnOutcome, type TurnReason } from './turn-evidence';
53
+ /** Every request in this file is versioned so a responder can reject a shape it predates. */
54
+ export declare const TURN_IPC_PROTOCOL_VERSION: 1;
55
+ /**
56
+ * Closed error-code union every command response may carry instead of (or in
57
+ * addition to, for the client-side wrapper) a result.
58
+ *
59
+ * daemon_required — no daemon reachable (no IPC/local transport
60
+ * connection could be established). Distinct from
61
+ * every other failure: it means "there is nobody to
62
+ * ask", not "the ask failed."
63
+ * turn_ledger_unavailable — a daemon answered but its turn ledger is not
64
+ * armed yet (mid-boot, mid-migration).
65
+ * ledger_not_owner — the daemon that answered does not own the
66
+ * attempt/mesh addressed by the request (routing
67
+ * mistake, or the owner changed after a reclaim).
68
+ */
69
+ export declare const TURN_IPC_ERROR_CODES: readonly ["daemon_required", "turn_ledger_unavailable", "ledger_not_owner"];
70
+ export type TurnIpcErrorCode = typeof TURN_IPC_ERROR_CODES[number];
71
+ export declare const isTurnIpcErrorCode: (value: unknown) => value is "daemon_required" | "turn_ledger_unavailable" | "ledger_not_owner";
72
+ /** Structured failure shape a responder returns instead of a result. Never thrown across the wire — the client maps it to a typed error (see mcp-server/src/ipc/turn-commands.ts). */
73
+ export interface TurnIpcError {
74
+ code: TurnIpcErrorCode;
75
+ /** Short machine-oriented detail, e.g. which daemon was expected. Never free text describing content. */
76
+ detail?: string;
77
+ }
78
+ export declare function isTurnIpcError(value: unknown): value is TurnIpcError;
79
+ /** Reducer verdict, mirrored from the C1 reducer's `reduce()` return shape. */
80
+ export declare const TURN_OBSERVE_VERDICTS: readonly ["applied", "recorded", "rejected"];
81
+ export type TurnObserveVerdict = typeof TURN_OBSERVE_VERDICTS[number];
82
+ export declare const isTurnObserveVerdict: (value: unknown) => value is "rejected" | "applied" | "recorded";
83
+ export interface TurnObserveRequest {
84
+ v: typeof TURN_IPC_PROTOCOL_VERSION;
85
+ evidence: TurnEvidence;
86
+ }
87
+ export interface TurnObserveResponse {
88
+ verdict: TurnObserveVerdict;
89
+ attemptRef: TurnAttemptRef;
90
+ /** Present only when the evidence committed the attempt (verdict 'applied' + a terminal-class kind). */
91
+ outcome?: TurnOutcome;
92
+ }
93
+ export declare function isTurnObserveRequest(value: unknown): value is TurnObserveRequest;
94
+ export declare function decodeTurnObserveRequest(value: unknown): TurnObserveRequest | null;
95
+ export declare function isTurnObserveResponse(value: unknown): value is TurnObserveResponse;
96
+ export declare function decodeTurnObserveResponse(value: unknown): TurnObserveResponse | null;
97
+ /**
98
+ * Structural pin of `seqscribe/mesh-event-projection.ts` `PROJECTED_PAYLOAD_KEYS`
99
+ * (daemon-core; this leaf cannot import it). A test in this package's test
100
+ * suite AND a daemon-core test each assert their list equals this one — see
101
+ * `mesh-shared/test/turn-ipc.test.ts` and the C-W6 report's break-once table.
102
+ * Adding a key here is the SAME assertion as adding it there: non-content
103
+ * (identifier, enum, boolean, or counter), never free text.
104
+ */
105
+ export declare const MESH_RECORD_PAYLOAD_KEYS: readonly ["taskId", "deliveryId", "attemptId", "missionId", "checkpointId", "promptId", "providerSessionId", "targetNoteId", "nodeId", "sessionId", "providerType", "transport", "attemptedSessionId", "holderSessionId", "reason", "status", "outcome", "terminalKind", "event", "source", "intentionalStopReason", "retryable", "rebound", "forced", "fallback", "membershipRemoved", "requestedForce", "removedByRemoteDaemon", "completedViaReady", "intentional", "weak", "attempt", "attemptCount", "count"];
106
+ export type MeshRecordPayloadKey = typeof MESH_RECORD_PAYLOAD_KEYS[number];
107
+ /** Maximum length of any string value in a `mesh_record` payload (mirrors `MAX_PROJECTED_STRING`). */
108
+ export declare const MAX_MESH_RECORD_STRING = 200;
109
+ export interface MeshRecordRequest {
110
+ v: typeof TURN_IPC_PROTOCOL_VERSION;
111
+ meshId: string;
112
+ /** The original ledger `kind` string (daemon-core `MeshLedgerKind`; mesh-shared cannot import that union, so it is an identifier here). */
113
+ ledgerKind: string;
114
+ nodeId?: string;
115
+ sessionId?: string;
116
+ taskId?: string;
117
+ /** Restricted to `MESH_RECORD_PAYLOAD_KEYS` — an unknown key is a decode failure, not a silently dropped field. */
118
+ payload: ProjectedScalars;
119
+ }
120
+ export interface MeshRecordResponse {
121
+ /** `mesh.<id>.events` append coordinates, for callers that need to reference the entry (e.g. a `ref`'d handoff). */
122
+ eventId: string;
123
+ seq: number;
124
+ }
125
+ /** Every payload key must be a member of `MESH_RECORD_PAYLOAD_KEYS` — the allow-list boundary at the wire. */
126
+ export declare function isMeshRecordPayload(value: unknown): value is ProjectedScalars;
127
+ export declare function isMeshRecordRequest(value: unknown): value is MeshRecordRequest;
128
+ export declare function decodeMeshRecordRequest(value: unknown): MeshRecordRequest | null;
129
+ export declare function isMeshRecordResponse(value: unknown): value is MeshRecordResponse;
130
+ export declare function decodeMeshRecordResponse(value: unknown): MeshRecordResponse | null;
131
+ export interface TurnCancelRequest {
132
+ v: typeof TURN_IPC_PROTOCOL_VERSION;
133
+ /** Exactly one of the two must be present — the decoder rejects both-or-neither. */
134
+ attemptId?: string;
135
+ taskId?: string;
136
+ reason: TurnReason;
137
+ }
138
+ export interface TurnCancelResponse {
139
+ attemptRef: TurnAttemptRef;
140
+ verdict: TurnObserveVerdict;
141
+ }
142
+ export declare function isTurnCancelRequest(value: unknown): value is TurnCancelRequest;
143
+ export declare function decodeTurnCancelRequest(value: unknown): TurnCancelRequest | null;
144
+ export declare function isTurnCancelResponse(value: unknown): value is TurnCancelResponse;
145
+ export declare function decodeTurnCancelResponse(value: unknown): TurnCancelResponse | null;
146
+ /**
147
+ * Fire-and-forget operator/tool-call status record — replaces
148
+ * `recordMeshCoordinatorToolCall` (10 sites, `mesh_tool_call_log`) and doubles
149
+ * as the `operator_status` evidence kind's wire shape.
150
+ *
151
+ * NAMING NOTE (flagged for the C-W6 implementer, see report §"mismatch"):
152
+ * the C-W6 brief's DELIVERABLES describes this request as
153
+ * `{taskId, status: MeshTaskStatus, reason}`, but C1's `operator_status`
154
+ * evidence kind (`turn-evidence.ts` `OPERATOR_STATUSES`) is the closed
155
+ * 2-value set `'completed' | 'failed'` — a verdict on an operator ACTION, not
156
+ * a `MeshTaskStatus` (5-value queue-row status: pending/assigned/completed/
157
+ * failed/cancelled). This contract follows `turn-evidence.ts` because that is
158
+ * what the C1 reducer actually consumes for this evidence kind; using the
159
+ * 5-value `MeshTaskStatus` here would let this request carry `pending` or
160
+ * `assigned`, which the reducer has no transition for.
161
+ */
162
+ export declare const OPERATOR_STATUS_VALUES: readonly ["completed", "failed"];
163
+ export type OperatorStatusValue = typeof OPERATOR_STATUS_VALUES[number];
164
+ export declare const isOperatorStatusValue: (value: unknown) => value is "failed" | "completed";
165
+ export declare const OPERATOR_STATUS_REASON_VALUES: readonly ["operator_update", "refine_terminal", "validation_terminal"];
166
+ export type OperatorStatusReasonValue = typeof OPERATOR_STATUS_REASON_VALUES[number];
167
+ export declare const isOperatorStatusReasonValue: (value: unknown) => value is "operator_update" | "refine_terminal" | "validation_terminal";
168
+ export interface OperatorStatusRequest {
169
+ v: typeof TURN_IPC_PROTOCOL_VERSION;
170
+ taskId: string;
171
+ status: OperatorStatusValue;
172
+ reason: OperatorStatusReasonValue;
173
+ }
174
+ /** Acknowledgement only — this command is fire-and-forget by design (the daemon owns rate-limiting the underlying log). */
175
+ export interface OperatorStatusResponse {
176
+ accepted: true;
177
+ }
178
+ export declare function isOperatorStatusRequest(value: unknown): value is OperatorStatusRequest;
179
+ export declare function decodeOperatorStatusRequest(value: unknown): OperatorStatusRequest | null;
180
+ export declare function isOperatorStatusResponse(value: unknown): value is OperatorStatusResponse;
181
+ export declare function decodeOperatorStatusResponse(value: unknown): OperatorStatusResponse | null;
182
+ /** Row shape returned by `turn_query` — scalar projection of a `turn_attempts` row (C3 schema), never `data_json`/`payload_json` content. */
183
+ export interface TurnQueryAttemptRow {
184
+ attemptId: string;
185
+ generation: number;
186
+ meshId?: string;
187
+ taskId?: string;
188
+ sessionId: string;
189
+ nodeId?: string;
190
+ providerType?: string;
191
+ state: string;
192
+ terminalOutcome?: TurnOutcome;
193
+ terminalReason?: TurnReason;
194
+ acceptedAt: number;
195
+ terminalAt?: number;
196
+ }
197
+ /** Row shape returned by `turn_query` for the event stream — scalar projection of a `turn_events` row, `payload_json` NEVER included. */
198
+ export interface TurnQueryEventRow {
199
+ eventId: string;
200
+ attemptId?: string;
201
+ generation?: number;
202
+ sessionId: string;
203
+ kind: TurnEvidenceKind;
204
+ source: string;
205
+ verdict: TurnObserveVerdict | 'forwarded';
206
+ atMs: number;
207
+ }
208
+ export interface TurnQueryRequest {
209
+ v: typeof TURN_IPC_PROTOCOL_VERSION;
210
+ meshId: string;
211
+ taskId?: string;
212
+ attemptId?: string;
213
+ sessionId?: string;
214
+ state?: string;
215
+ since?: number;
216
+ tail?: number;
217
+ }
218
+ export interface TurnQueryResponse {
219
+ attempts: readonly TurnQueryAttemptRow[];
220
+ events: readonly TurnQueryEventRow[];
221
+ /** C7-5: set while `mesh.<id>.events` replication is behind for this mesh — the caller must not treat a fleet-scope answer as complete. */
222
+ replicationPending?: boolean;
223
+ }
224
+ export declare function isTurnQueryRequest(value: unknown): value is TurnQueryRequest;
225
+ export declare function decodeTurnQueryRequest(value: unknown): TurnQueryRequest | null;
226
+ export declare function isTurnQueryResponse(value: unknown): value is TurnQueryResponse;
227
+ export declare function decodeTurnQueryResponse(value: unknown): TurnQueryResponse | null;
228
+ export declare const MESH_INDEX_QUERY_WRITER_SCOPES: readonly ["own", "fleet"];
229
+ export type MeshIndexQueryWriterScope = typeof MESH_INDEX_QUERY_WRITER_SCOPES[number];
230
+ export declare const isMeshIndexQueryWriterScope: (value: unknown) => value is "own" | "fleet";
231
+ export interface MeshIndexQueryRequest {
232
+ v: typeof TURN_IPC_PROTOCOL_VERSION;
233
+ meshId: string;
234
+ ledgerKind?: string;
235
+ sessionId?: string;
236
+ taskId?: string;
237
+ writer?: MeshIndexQueryWriterScope;
238
+ since?: number;
239
+ tail?: number;
240
+ }
241
+ /** Row shape returned by `mesh_index_query` — a `mesh_topic_index` row (C3 schema). */
242
+ export interface MeshTopicIndexRow {
243
+ writer: string;
244
+ seq: number;
245
+ meshId: string;
246
+ eventId: string;
247
+ kind: string;
248
+ ledgerKind?: string;
249
+ taskId?: string;
250
+ sessionId?: string;
251
+ nodeId?: string;
252
+ atMs: number;
253
+ payload: ProjectedScalars;
254
+ }
255
+ export interface MeshIndexQueryResponse {
256
+ rows: readonly MeshTopicIndexRow[];
257
+ /** C7-5: true while `mesh.<id>.events` replication is behind for this mesh. */
258
+ replicationPending?: boolean;
259
+ }
260
+ export declare function isMeshIndexQueryRequest(value: unknown): value is MeshIndexQueryRequest;
261
+ export declare function decodeMeshIndexQueryRequest(value: unknown): MeshIndexQueryRequest | null;
262
+ export declare function isMeshIndexQueryResponse(value: unknown): value is MeshIndexQueryResponse;
263
+ export declare function decodeMeshIndexQueryResponse(value: unknown): MeshIndexQueryResponse | null;
264
+ export declare const MESH_MISSION_STATUSES: readonly ["active", "paused", "completed", "abandoned"];
265
+ export type MeshMissionStatusValue = typeof MESH_MISSION_STATUSES[number];
266
+ export declare const isMeshMissionStatusValue: (value: unknown) => value is "active" | "completed" | "paused" | "abandoned";
267
+ export declare const MESH_MISSION_SOURCES: readonly ["magi", "coordinator"];
268
+ export type MeshMissionSourceValue = typeof MESH_MISSION_SOURCES[number];
269
+ export declare const isMeshMissionSourceValue: (value: unknown) => value is "coordinator" | "magi";
270
+ export interface MissionBriefWire {
271
+ goal: string;
272
+ constraints?: readonly string[];
273
+ doneCriteria?: readonly string[];
274
+ handoffNotes?: readonly string[];
275
+ ownedPaths?: readonly string[];
276
+ }
277
+ export interface MissionUpsertRequest {
278
+ v: typeof TURN_IPC_PROTOCOL_VERSION;
279
+ meshId: string;
280
+ /** Omitted = create a new mission; present = update (must resolve to an existing mission — see mesh-missions.ts MISSION-UPSERT-SILENT-CREATE). */
281
+ id?: string;
282
+ title: string;
283
+ /** Free text — see file-header note on why this is fine over local IPC. */
284
+ goal?: string;
285
+ status?: MeshMissionStatusValue;
286
+ source?: MeshMissionSourceValue;
287
+ /**
288
+ * H2: `undefined` = do not touch the stored brief. `null` = explicitly clear it.
289
+ * A present object with no usable `goal` is treated by the daemon's own
290
+ * `normalizeMissionBrief` as "no brief" (see mesh-missions.ts upsertMeshMission) —
291
+ * this wire guard only checks SHAPE, not that decision.
292
+ */
293
+ brief?: MissionBriefWire | null;
294
+ }
295
+ export interface MeshMissionRecordWire {
296
+ id: string;
297
+ meshId: string;
298
+ title: string;
299
+ goal: string;
300
+ status: MeshMissionStatusValue;
301
+ source?: MeshMissionSourceValue;
302
+ /** H2: absent = no brief attached to this mission. */
303
+ brief?: MissionBriefWire;
304
+ }
305
+ export interface MissionUpsertResponse {
306
+ mission: MeshMissionRecordWire;
307
+ }
308
+ export declare function isMissionUpsertRequest(value: unknown): value is MissionUpsertRequest;
309
+ export declare function decodeMissionUpsertRequest(value: unknown): MissionUpsertRequest | null;
310
+ export declare function isMissionUpsertResponse(value: unknown): value is MissionUpsertResponse;
311
+ export declare function decodeMissionUpsertResponse(value: unknown): MissionUpsertResponse | null;
312
+ export interface MissionQueryRequest {
313
+ v: typeof TURN_IPC_PROTOCOL_VERSION;
314
+ meshId: string;
315
+ /** Omitted = every status. */
316
+ statuses?: readonly MeshMissionStatusValue[];
317
+ /** Single-mission lookup (mesh-missions.ts `getMeshMission`'s shape) — mutually exclusive with `statuses`. */
318
+ id?: string;
319
+ }
320
+ export interface MissionQueryResponse {
321
+ missions: readonly MeshMissionRecordWire[];
322
+ }
323
+ export declare function isMissionQueryRequest(value: unknown): value is MissionQueryRequest;
324
+ export declare function decodeMissionQueryRequest(value: unknown): MissionQueryRequest | null;
325
+ export declare function isMissionQueryResponse(value: unknown): value is MissionQueryResponse;
326
+ export declare function decodeMissionQueryResponse(value: unknown): MissionQueryResponse | null;
327
+ export interface MissionListQueryRequest {
328
+ v: typeof TURN_IPC_PROTOCOL_VERSION;
329
+ meshId: string;
330
+ statuses?: readonly MeshMissionStatusValue[];
331
+ verbose?: boolean;
332
+ includeMagi?: boolean;
333
+ withStats?: boolean;
334
+ limit?: number;
335
+ historyIdLimit?: number;
336
+ }
337
+ export interface MeshMissionTaskAggregateWire {
338
+ total: number;
339
+ pending: number;
340
+ assigned: number;
341
+ completed: number;
342
+ failed: number;
343
+ cancelled: number;
344
+ blocked: number;
345
+ lastActivityAt: string | null;
346
+ }
347
+ export interface MeshMissionStatsWire {
348
+ missionId: string;
349
+ taskCount: number;
350
+ completed: number;
351
+ failed: number;
352
+ totalDurationMs: number;
353
+ wallClockMs: number | null;
354
+ retries: number;
355
+ incompleteTaskIds: readonly string[];
356
+ }
357
+ /** Verbose (full-goal) mission row. `goal` present, `goalPreview`/`goalTruncated` absent. */
358
+ export interface MissionListSummaryVerboseWire {
359
+ id: string;
360
+ meshId: string;
361
+ title: string;
362
+ goal: string;
363
+ status: MeshMissionStatusValue;
364
+ source?: MeshMissionSourceValue;
365
+ tasks: MeshMissionTaskAggregateWire;
366
+ stats?: MeshMissionStatsWire;
367
+ /** H2: absent = no brief attached. */
368
+ brief?: MissionBriefWire;
369
+ }
370
+ /** Compact (default) mission row. `goalPreview`/`goalTruncated` present, `goal` absent. */
371
+ export interface MissionListSummarySlimWire {
372
+ id: string;
373
+ meshId: string;
374
+ title: string;
375
+ goalPreview: string;
376
+ goalTruncated: boolean;
377
+ status: MeshMissionStatusValue;
378
+ source?: MeshMissionSourceValue;
379
+ tasks: MeshMissionTaskAggregateWire;
380
+ stats?: MeshMissionStatsWire;
381
+ /** H2: absent = no brief attached. */
382
+ brief?: MissionBriefWire;
383
+ }
384
+ export type MissionListSummaryWire = MissionListSummaryVerboseWire | MissionListSummarySlimWire;
385
+ export interface MeshMissionHistoryFoldWire {
386
+ count: number;
387
+ byStatus: Record<string, number>;
388
+ missionIds: readonly string[];
389
+ note: string;
390
+ }
391
+ export interface MissionListQueryResponse {
392
+ missions: readonly MissionListSummaryWire[];
393
+ historyFold: MeshMissionHistoryFoldWire | null;
394
+ truncated: boolean;
395
+ matched: number;
396
+ overflowIds?: readonly string[];
397
+ }
398
+ export declare function isMissionListQueryRequest(value: unknown): value is MissionListQueryRequest;
399
+ export declare function decodeMissionListQueryRequest(value: unknown): MissionListQueryRequest | null;
400
+ export declare function isMissionListQueryResponse(value: unknown): value is MissionListQueryResponse;
401
+ export declare function decodeMissionListQueryResponse(value: unknown): MissionListQueryResponse | null;
402
+ export declare const OPERATING_NOTE_CATEGORIES: readonly ["provider_quirk", "pattern_to_avoid", "recovery_lesson"];
403
+ export type OperatingNoteCategory = typeof OPERATING_NOTE_CATEGORIES[number];
404
+ export declare const isOperatingNoteCategory: (value: unknown) => value is "provider_quirk" | "pattern_to_avoid" | "recovery_lesson";
405
+ export interface NoteUpsertRequest {
406
+ v: typeof TURN_IPC_PROTOCOL_VERSION;
407
+ meshId: string;
408
+ /** Free text (local IPC — see the section note). */
409
+ text: string;
410
+ category?: OperatingNoteCategory;
411
+ pinned?: boolean;
412
+ /** Explicit expiry, ISO-8601. */
413
+ expiresAt?: string;
414
+ /** Note id (or subject key) this note supersedes. */
415
+ supersedes?: string;
416
+ subjectKey?: string;
417
+ /** Best-effort identity of the recording coordinator (session id / daemon id / host). */
418
+ sourceCoordinator?: string;
419
+ }
420
+ export interface NoteUpsertResponse {
421
+ noteId: string;
422
+ /** True when the same text was already among the recent live notes (no new note). */
423
+ deduped: boolean;
424
+ createdAt: string;
425
+ }
426
+ export declare function isNoteUpsertRequest(value: unknown): value is NoteUpsertRequest;
427
+ export declare function decodeNoteUpsertRequest(value: unknown): NoteUpsertRequest | null;
428
+ export declare function isNoteUpsertResponse(value: unknown): value is NoteUpsertResponse;
429
+ export declare function decodeNoteUpsertResponse(value: unknown): NoteUpsertResponse | null;
430
+ export interface NoteForgetRequest {
431
+ v: typeof TURN_IPC_PROTOCOL_VERSION;
432
+ meshId: string;
433
+ /** At least one of `noteId` / `text` (a text forget retracts every note with that exact text, and any recorded later). */
434
+ noteId?: string;
435
+ text?: string;
436
+ reason?: string;
437
+ }
438
+ export interface NoteForgetResponse {
439
+ /** Live notes this forget hid. */
440
+ matched: number;
441
+ tombstoneId: string;
442
+ }
443
+ export declare function isNoteForgetRequest(value: unknown): value is NoteForgetRequest;
444
+ export declare function decodeNoteForgetRequest(value: unknown): NoteForgetRequest | null;
445
+ export declare function isNoteForgetResponse(value: unknown): value is NoteForgetResponse;
446
+ export declare function decodeNoteForgetResponse(value: unknown): NoteForgetResponse | null;
447
+ export declare const TOOL_CALLER_ROLES: readonly ["coordinator", "unknown"];
448
+ export type ToolCallerRole = typeof TOOL_CALLER_ROLES[number];
449
+ export declare const isToolCallerRole: (value: unknown) => value is "unknown" | "coordinator";
450
+ export interface ToolCallRecordRequest {
451
+ v: typeof TURN_IPC_PROTOCOL_VERSION;
452
+ meshId: string;
453
+ /** The mesh tool name, e.g. `mesh_status` (identifier, not free text — always a fixed tool-name string). */
454
+ tool: string;
455
+ sessionId?: string;
456
+ callerRole: ToolCallerRole;
457
+ }
458
+ export interface ToolCallRecordResponse {
459
+ rateLimitExceeded: boolean;
460
+ callsInWindow: number;
461
+ /** Short machine-oriented advisory string, or null. Never free text describing content. */
462
+ advisory: string | null;
463
+ }
464
+ export declare function isToolCallRecordRequest(value: unknown): value is ToolCallRecordRequest;
465
+ export declare function decodeToolCallRecordRequest(value: unknown): ToolCallRecordRequest | null;
466
+ export declare function isToolCallRecordResponse(value: unknown): value is ToolCallRecordResponse;
467
+ export declare function decodeToolCallRecordResponse(value: unknown): ToolCallRecordResponse | null;
468
+ export interface LedgerQueryRequest {
469
+ v: typeof TURN_IPC_PROTOCOL_VERSION;
470
+ meshId: string;
471
+ /** One or more ledger `kind` strings (daemon-core `MeshLedgerKind`; mesh-shared cannot import that union, so these are identifiers here). Omitted = every kind. */
472
+ kind?: readonly string[];
473
+ /** ISO-8601 or epoch-ms-as-string — passed through to `readLedgerEntries`'s `since` (parsed via `new Date()`). */
474
+ since?: string;
475
+ /** Filter to entries whose nodeId is equivalent to this daemon id (matched via `daemonIdsEquivalent` daemon-side, not raw `===`). */
476
+ node?: string;
477
+ tail?: number;
478
+ /** Also return `getLedgerSummary(meshId)` alongside the entries — saves a second round trip for callers that want both (the common case: every existing call site fetches both together). */
479
+ includeSummary?: boolean;
480
+ }
481
+ export interface LedgerQueryEntryWire {
482
+ id: string;
483
+ meshId: string;
484
+ timestamp: string;
485
+ kind: string;
486
+ nodeId?: string;
487
+ sessionId?: string;
488
+ providerType?: string;
489
+ taskId?: string;
490
+ /** Unbounded JSON passthrough — see file section's CONTENT BOUNDARY note. */
491
+ payload: Record<string, unknown>;
492
+ }
493
+ export interface LedgerQuerySummaryWire {
494
+ meshId: string;
495
+ totalEntries: number;
496
+ taskDispatched: number;
497
+ taskCompleted: number;
498
+ taskFailed: number;
499
+ taskStalled: number;
500
+ sessionLaunched: number;
501
+ checkpointCreated: number;
502
+ lastActivityAt: string | null;
503
+ recentFailures: number;
504
+ }
505
+ export interface LedgerQueryResponse {
506
+ entries: readonly LedgerQueryEntryWire[];
507
+ summary?: LedgerQuerySummaryWire;
508
+ }
509
+ export declare function isLedgerQueryRequest(value: unknown): value is LedgerQueryRequest;
510
+ export declare function decodeLedgerQueryRequest(value: unknown): LedgerQueryRequest | null;
511
+ export declare function isLedgerQueryResponse(value: unknown): value is LedgerQueryResponse;
512
+ export declare function decodeLedgerQueryResponse(value: unknown): LedgerQueryResponse | null;
513
+ /** A queue row as the daemon's `getQueue` returns it — a JSON passthrough (see the section note). */
514
+ export type QueueEntryWire = Record<string, unknown> & {
515
+ id: string;
516
+ status: string;
517
+ };
518
+ export interface RecordLocalRequest {
519
+ v: typeof TURN_IPC_PROTOCOL_VERSION;
520
+ meshId: string;
521
+ /** A `MeshLedgerKind` (daemon-core); an identifier here (mesh-shared cannot import that union). */
522
+ kind: string;
523
+ nodeId?: string;
524
+ sessionId?: string;
525
+ providerType?: string;
526
+ taskId?: string;
527
+ payload: Record<string, unknown>;
528
+ }
529
+ export interface RecordLocalResponse {
530
+ eventId: string;
531
+ timestamp: string;
532
+ storedLocally: boolean;
533
+ published: boolean;
534
+ }
535
+ export declare function isRecordLocalRequest(value: unknown): value is RecordLocalRequest;
536
+ export declare function decodeRecordLocalRequest(value: unknown): RecordLocalRequest | null;
537
+ export declare function isRecordLocalResponse(value: unknown): value is RecordLocalResponse;
538
+ export declare function decodeRecordLocalResponse(value: unknown): RecordLocalResponse | null;
539
+ export interface QueueQueryRequest {
540
+ v: typeof TURN_IPC_PROTOCOL_VERSION;
541
+ meshId: string;
542
+ /** Status filter (queue statuses); omitted = every row. */
543
+ statuses?: readonly string[];
544
+ /** One row by id (returns 0 or 1 entries). */
545
+ taskId?: string;
546
+ /** Project for a VIEW surface: the persisted input envelope → `inputSummary` (summarizeQueueEntryInputForView). */
547
+ view?: boolean;
548
+ }
549
+ export interface QueueQueryResponse {
550
+ entries: readonly QueueEntryWire[];
551
+ }
552
+ export declare function isQueueQueryRequest(value: unknown): value is QueueQueryRequest;
553
+ export declare function decodeQueueQueryRequest(value: unknown): QueueQueryRequest | null;
554
+ export declare function isQueueQueryResponse(value: unknown): value is QueueQueryResponse;
555
+ export declare function decodeQueueQueryResponse(value: unknown): QueueQueryResponse | null;
556
+ export interface QueueEnqueueRequest {
557
+ v: typeof TURN_IPC_PROTOCOL_VERSION;
558
+ meshId: string;
559
+ /** Free text (the task message — see the section note). */
560
+ message: string;
561
+ options?: Record<string, unknown>;
562
+ /** `recordSingleEnqueueDecision` args minus `taskId` (the daemon fills it). */
563
+ decision?: Record<string, unknown>;
564
+ }
565
+ export interface QueueEnqueueResponse {
566
+ entry: QueueEntryWire;
567
+ }
568
+ export declare function isQueueEnqueueRequest(value: unknown): value is QueueEnqueueRequest;
569
+ export declare function decodeQueueEnqueueRequest(value: unknown): QueueEnqueueRequest | null;
570
+ export declare function isQueueEnqueueResponse(value: unknown): value is QueueEnqueueResponse;
571
+ export declare function decodeQueueEnqueueResponse(value: unknown): QueueEnqueueResponse | null;
572
+ export interface QueueEnqueueGraphRequest {
573
+ v: typeof TURN_IPC_PROTOCOL_VERSION;
574
+ meshId: string;
575
+ mode: 'compat' | 'graph';
576
+ /** compat: `MeshTaskGraphEntrySpec[]` (JSON passthrough). */
577
+ specs?: readonly Record<string, unknown>[];
578
+ /** graph: `commitMeshGraphPlan` input minus `meshId` (JSON passthrough). */
579
+ plan?: Record<string, unknown>;
580
+ /** Audit context: batchId / missionId / coordinatorSessionId / onDependencyFailure / orchestrationDecision / taskCount. */
581
+ audit?: Record<string, unknown>;
582
+ }
583
+ export type QueueEnqueueGraphResponse = {
584
+ ok: true;
585
+ tasks: readonly QueueEntryWire[];
586
+ graph?: Record<string, unknown>;
587
+ } | {
588
+ ok: false;
589
+ refusalCode?: string;
590
+ message: string;
591
+ extra?: Record<string, unknown>;
592
+ };
593
+ export declare function isQueueEnqueueGraphRequest(value: unknown): value is QueueEnqueueGraphRequest;
594
+ export declare function decodeQueueEnqueueGraphRequest(value: unknown): QueueEnqueueGraphRequest | null;
595
+ export declare function isQueueEnqueueGraphResponse(value: unknown): value is QueueEnqueueGraphResponse;
596
+ export declare function decodeQueueEnqueueGraphResponse(value: unknown): QueueEnqueueGraphResponse | null;
597
+ export interface QueueCancelRequest {
598
+ v: typeof TURN_IPC_PROTOCOL_VERSION;
599
+ meshId: string;
600
+ taskId: string;
601
+ /** Operator reason (free text, local IPC). */
602
+ reason?: string;
603
+ }
604
+ export interface QueueCancelResponse {
605
+ /** The cancelled row, or null when no such task. */
606
+ task: QueueEntryWire | null;
607
+ /** The row as it was BEFORE the cancel (its assignment is what a caller stops). */
608
+ before: QueueEntryWire | null;
609
+ }
610
+ export declare function isQueueCancelRequest(value: unknown): value is QueueCancelRequest;
611
+ export declare function decodeQueueCancelRequest(value: unknown): QueueCancelRequest | null;
612
+ export declare function isQueueCancelResponse(value: unknown): value is QueueCancelResponse;
613
+ export declare function decodeQueueCancelResponse(value: unknown): QueueCancelResponse | null;
614
+ export interface QueueRequeueRequest {
615
+ v: typeof TURN_IPC_PROTOCOL_VERSION;
616
+ meshId: string;
617
+ taskId: string;
618
+ /** `requeueTask` options (reason / targetNodeId / targetSessionId / clear* / force / message / maxRetries / notBefore), JSON passthrough. */
619
+ options?: Record<string, unknown>;
620
+ }
621
+ export interface QueueRequeueResponse {
622
+ task: QueueEntryWire | null;
623
+ }
624
+ export declare function isQueueRequeueRequest(value: unknown): value is QueueRequeueRequest;
625
+ export declare function decodeQueueRequeueRequest(value: unknown): QueueRequeueRequest | null;
626
+ export declare function isQueueRequeueResponse(value: unknown): value is QueueRequeueResponse;
627
+ export declare function decodeQueueRequeueResponse(value: unknown): QueueRequeueResponse | null;
628
+ export interface DirectDispatchRecordRequest {
629
+ v: typeof TURN_IPC_PROTOCOL_VERSION;
630
+ meshId: string;
631
+ taskId: string;
632
+ /** Free text (the authored task message — the materialised row keeps it). */
633
+ message: string;
634
+ /** `recordDirectDispatchTask` options minus `id` (JSON passthrough). */
635
+ task?: Record<string, unknown>;
636
+ /** `recordDirectDispatchDecision` args minus `taskId` (JSON passthrough). */
637
+ decision?: Record<string, unknown>;
638
+ }
639
+ export interface DirectDispatchRecordResponse {
640
+ taskRecorded: boolean;
641
+ decisionRecorded: boolean;
642
+ }
643
+ export declare function isDirectDispatchRecordRequest(value: unknown): value is DirectDispatchRecordRequest;
644
+ export declare function decodeDirectDispatchRecordRequest(value: unknown): DirectDispatchRecordRequest | null;
645
+ export declare function isDirectDispatchRecordResponse(value: unknown): value is DirectDispatchRecordResponse;
646
+ export declare function decodeDirectDispatchRecordResponse(value: unknown): DirectDispatchRecordResponse | null;
647
+ export declare const GRAPH_AUDIT_EVENTS: readonly ["gate_claimed", "gate_released", "gate_abandoned", "node_patched"];
648
+ export type GraphAuditEvent = typeof GRAPH_AUDIT_EVENTS[number];
649
+ export declare const isGraphAuditEvent: (value: unknown) => value is "gate_claimed" | "gate_released" | "gate_abandoned" | "node_patched";
650
+ export interface GraphAuditRecordRequest {
651
+ v: typeof TURN_IPC_PROTOCOL_VERSION;
652
+ meshId: string;
653
+ event: GraphAuditEvent;
654
+ fields: Record<string, unknown>;
655
+ }
656
+ export interface GraphAuditRecordResponse {
657
+ recorded: boolean;
658
+ }
659
+ export declare function isGraphAuditRecordRequest(value: unknown): value is GraphAuditRecordRequest;
660
+ export declare function decodeGraphAuditRecordRequest(value: unknown): GraphAuditRecordRequest | null;
661
+ export declare function isGraphAuditRecordResponse(value: unknown): value is GraphAuditRecordResponse;
662
+ export declare function decodeGraphAuditRecordResponse(value: unknown): GraphAuditRecordResponse | null;
663
+ export interface ActiveWorkQueryRequest {
664
+ v: typeof TURN_IPC_PROTOCOL_VERSION;
665
+ meshId: string;
666
+ /** Live node probe results (`buildMeshActiveWork`'s `nodes`), JSON passthrough. */
667
+ nodes?: readonly Record<string, unknown>[];
668
+ /** Substitute queue rows (default: the daemon's `getQueue`). */
669
+ queue?: readonly Record<string, unknown>[];
670
+ /** Record tail fed to active work (default 200). */
671
+ recordTail?: number;
672
+ includeTerminalDirect?: boolean;
673
+ /** Default true. */
674
+ compute?: boolean;
675
+ includeInputs?: boolean;
676
+ includeSummary?: boolean;
677
+ includeSchedulingRuntime?: boolean;
678
+ /** The caller's mesh snapshot (required for the scheduling runtime), JSON passthrough. */
679
+ mesh?: Record<string, unknown>;
680
+ }
681
+ export interface ActiveWorkQueryResponse {
682
+ /** `MeshActiveWorkEvidence` (daemon-core), JSON passthrough; absent when `compute: false`. */
683
+ activeWork?: Record<string, unknown>;
684
+ records?: readonly Record<string, unknown>[];
685
+ directDispatches?: readonly Record<string, unknown>[];
686
+ /** `MeshLedgerSummary`-shaped record summary. */
687
+ summary?: Record<string, unknown>;
688
+ schedulingRuntime?: Record<string, unknown>;
689
+ }
690
+ export declare function isActiveWorkQueryRequest(value: unknown): value is ActiveWorkQueryRequest;
691
+ export declare function decodeActiveWorkQueryRequest(value: unknown): ActiveWorkQueryRequest | null;
692
+ export declare function isActiveWorkQueryResponse(value: unknown): value is ActiveWorkQueryResponse;
693
+ export declare function decodeActiveWorkQueryResponse(value: unknown): ActiveWorkQueryResponse | null;
694
+ export interface RecoveryContextQueryRequest {
695
+ v: typeof TURN_IPC_PROTOCOL_VERSION;
696
+ meshId: string;
697
+ nodeId?: string;
698
+ sessionId?: string;
699
+ maxRetries?: number;
700
+ }
701
+ export interface RecoveryContextQueryResponse {
702
+ context: Record<string, unknown>;
703
+ }
704
+ export declare function isRecoveryContextQueryRequest(value: unknown): value is RecoveryContextQueryRequest;
705
+ export declare function decodeRecoveryContextQueryRequest(value: unknown): RecoveryContextQueryRequest | null;
706
+ export declare function isRecoveryContextQueryResponse(value: unknown): value is RecoveryContextQueryResponse;
707
+ export declare function decodeRecoveryContextQueryResponse(value: unknown): RecoveryContextQueryResponse | null;
708
+ export interface GraphGateClaimRequest {
709
+ v: typeof TURN_IPC_PROTOCOL_VERSION;
710
+ meshId: string;
711
+ gateId: string;
712
+ coordinatorSessionId: string;
713
+ leaseSeconds?: number;
714
+ extendDeadlineSeconds?: number;
715
+ /** Also collect `collectGateConvergenceEvidence` on a successful claim (mesh_graph_gate_claim's own behavior). */
716
+ probeConvergenceEvidence?: boolean;
717
+ }
718
+ export interface GraphGateClaimResponse {
719
+ claimed: boolean;
720
+ /** gate_not_found / gate_not_eligible / gate_not_awaiting / gate_lease_held / gate_claim_race / gate_terminal:<state> / gate_not_claimable, when `claimed: false`. */
721
+ reason?: string;
722
+ /** `MeshGraphGateRow`, JSON passthrough; present whenever the core found the gate. */
723
+ gate?: Record<string, unknown>;
724
+ leaseGeneration?: number;
725
+ fencingToken?: string;
726
+ leaseExpiresAt?: string;
727
+ deadlineAt?: string;
728
+ ambiguousExternalOutcome?: boolean;
729
+ previousLeaseOwnerSessionId?: string;
730
+ /** `GateConvergenceEvidence`, JSON passthrough; present only when requested and found. */
731
+ convergenceEvidence?: Record<string, unknown>;
732
+ }
733
+ export declare function isGraphGateClaimRequest(value: unknown): value is GraphGateClaimRequest;
734
+ export declare function decodeGraphGateClaimRequest(value: unknown): GraphGateClaimRequest | null;
735
+ export declare function isGraphGateClaimResponse(value: unknown): value is GraphGateClaimResponse;
736
+ export declare function decodeGraphGateClaimResponse(value: unknown): GraphGateClaimResponse | null;
737
+ export interface GraphGateReleaseRequest {
738
+ v: typeof TURN_IPC_PROTOCOL_VERSION;
739
+ meshId: string;
740
+ gateId: string;
741
+ fencingToken: string;
742
+ leaseGeneration: number;
743
+ idempotencyKey: string;
744
+ outcome: string;
745
+ /** Action-specific structured result/evidence the CALLER supplied — JSON passthrough, echoed back unmodified. */
746
+ result?: unknown;
747
+ evidence?: unknown;
748
+ patches?: readonly {
749
+ node: string;
750
+ baseSpecPatch: Record<string, unknown>;
751
+ }[];
752
+ }
753
+ export type GraphGateReleaseResponse = {
754
+ released: true;
755
+ duplicate: boolean;
756
+ gate?: Record<string, unknown>;
757
+ materializedNodeIds: readonly string[];
758
+ downstreamNodeCount?: number;
759
+ graphCompleted?: boolean;
760
+ } | {
761
+ released: false;
762
+ refusalCode?: string;
763
+ message: string;
764
+ };
765
+ export declare function isGraphGateReleaseRequest(value: unknown): value is GraphGateReleaseRequest;
766
+ export declare function decodeGraphGateReleaseRequest(value: unknown): GraphGateReleaseRequest | null;
767
+ export declare function isGraphGateReleaseResponse(value: unknown): value is GraphGateReleaseResponse;
768
+ export declare function decodeGraphGateReleaseResponse(value: unknown): GraphGateReleaseResponse | null;
769
+ export interface GraphGateAbandonRequest {
770
+ v: typeof TURN_IPC_PROTOCOL_VERSION;
771
+ meshId: string;
772
+ gateId: string;
773
+ reason: string;
774
+ coordinatorSessionId?: string;
775
+ force?: boolean;
776
+ }
777
+ export interface GraphGateAbandonResponse {
778
+ abandoned: boolean;
779
+ /** gate_not_found / gate_lease_held / gate_abandon_race / gate_terminal:<state> / gate_not_abandonable, when `abandoned: false`. */
780
+ reason?: string;
781
+ gate?: Record<string, unknown>;
782
+ cancelledNodeIds: readonly string[];
783
+ cancelledTaskIds: readonly string[];
784
+ graphStatus?: string;
785
+ }
786
+ export declare function isGraphGateAbandonRequest(value: unknown): value is GraphGateAbandonRequest;
787
+ export declare function decodeGraphGateAbandonRequest(value: unknown): GraphGateAbandonRequest | null;
788
+ export declare function isGraphGateAbandonResponse(value: unknown): value is GraphGateAbandonResponse;
789
+ export declare function decodeGraphGateAbandonResponse(value: unknown): GraphGateAbandonResponse | null;
790
+ export interface GraphNodePatchRequest {
791
+ v: typeof TURN_IPC_PROTOCOL_VERSION;
792
+ meshId: string;
793
+ node: string;
794
+ graphId?: string;
795
+ /** Only {@link MESH_NODE_PATCH_KEYS}-shaped keys are permitted; the daemon enforces the allow-list. */
796
+ baseSpecPatch: Record<string, unknown>;
797
+ }
798
+ export type GraphNodePatchResponse = {
799
+ patched: true;
800
+ graphId: string;
801
+ nodeId: string;
802
+ ref?: string;
803
+ queueTaskId?: string;
804
+ materializationVersion: number;
805
+ state: string;
806
+ /** `SettleOutcome['kind']` — materialized / deferred / skipped / error. */
807
+ outcomeKind: string;
808
+ /** Present when `outcomeKind === 'skipped'`. */
809
+ skippedReason?: string;
810
+ blockedReason?: string;
811
+ } | {
812
+ patched: false;
813
+ refusalCode?: string;
814
+ message: string;
815
+ };
816
+ export declare function isGraphNodePatchRequest(value: unknown): value is GraphNodePatchRequest;
817
+ export declare function decodeGraphNodePatchRequest(value: unknown): GraphNodePatchRequest | null;
818
+ export declare function isGraphNodePatchResponse(value: unknown): value is GraphNodePatchResponse;
819
+ export declare function decodeGraphNodePatchResponse(value: unknown): GraphNodePatchResponse | null;
820
+ export interface GraphViewQueryRequest {
821
+ v: typeof TURN_IPC_PROTOCOL_VERSION;
822
+ meshId: string;
823
+ graphId?: string;
824
+ batchId?: string;
825
+ /** Default true: only graphs that still need attention. */
826
+ activeOnly?: boolean;
827
+ limit?: number;
828
+ /** Attach `collectGateConvergenceEvidence` to the first few waiting gates (mesh_graph_view's G4 opt-in probe). */
829
+ probeGateEvidence?: boolean;
830
+ }
831
+ export interface GraphViewQueryResponse {
832
+ /** `MeshGraphView[]`, JSON passthrough — see this section's content-boundary note. */
833
+ graphs: readonly Record<string, unknown>[];
834
+ }
835
+ export declare function isGraphViewQueryRequest(value: unknown): value is GraphViewQueryRequest;
836
+ export declare function decodeGraphViewQueryRequest(value: unknown): GraphViewQueryRequest | null;
837
+ export declare function isGraphViewQueryResponse(value: unknown): value is GraphViewQueryResponse;
838
+ export declare function decodeGraphViewQueryResponse(value: unknown): GraphViewQueryResponse | null;
839
+ export interface TaskStatsQueryRequest {
840
+ v: typeof TURN_IPC_PROTOCOL_VERSION;
841
+ meshId: string;
842
+ taskIds?: readonly string[];
843
+ missionId?: string;
844
+ tail?: number;
845
+ /** Also compute `computeMeshMissionStats` — requires `missionId`. */
846
+ rollup?: boolean;
847
+ }
848
+ export interface TaskStatsQueryResponse {
849
+ /** `MeshTaskStats[]`, JSON passthrough. */
850
+ tasks: readonly Record<string, unknown>[];
851
+ /** `MeshMissionStats`, JSON passthrough; present only when `rollup: true` was requested and satisfiable. */
852
+ mission?: Record<string, unknown>;
853
+ }
854
+ export declare function isTaskStatsQueryRequest(value: unknown): value is TaskStatsQueryRequest;
855
+ export declare function decodeTaskStatsQueryRequest(value: unknown): TaskStatsQueryRequest | null;
856
+ export declare function isTaskStatsQueryResponse(value: unknown): value is TaskStatsQueryResponse;
857
+ export declare function decodeTaskStatsQueryResponse(value: unknown): TaskStatsQueryResponse | null;
858
+ export interface PruneStaleDirectRequest {
859
+ v: typeof TURN_IPC_PROTOCOL_VERSION;
860
+ meshId: string;
861
+ execute?: boolean;
862
+ includeTerminal?: boolean;
863
+ source?: string;
864
+ }
865
+ export interface PruneStaleDirectResponse {
866
+ mode: 'execute' | 'dry_run';
867
+ includeTerminal: boolean;
868
+ candidateCount: number;
869
+ /** `MeshActiveWorkRecord[]`, JSON passthrough. */
870
+ prunable: readonly Record<string, unknown>[];
871
+ prunedCount: number;
872
+ preservedUnacknowledged: readonly Record<string, unknown>[];
873
+ preservedLedgerOnly: readonly Record<string, unknown>[];
874
+ preservedNotOrphan: readonly Record<string, unknown>[];
875
+ }
876
+ export declare function isPruneStaleDirectRequest(value: unknown): value is PruneStaleDirectRequest;
877
+ export declare function decodePruneStaleDirectRequest(value: unknown): PruneStaleDirectRequest | null;
878
+ export declare function isPruneStaleDirectResponse(value: unknown): value is PruneStaleDirectResponse;
879
+ export declare function decodePruneStaleDirectResponse(value: unknown): PruneStaleDirectResponse | null;
880
+ export interface OrphanedPinNotifyRequest {
881
+ v: typeof TURN_IPC_PROTOCOL_VERSION;
882
+ meshId: string;
883
+ stoppedSessionId: string;
884
+ excludeTaskId?: string;
885
+ cause?: string;
886
+ nodeId?: string;
887
+ coordinatorSessionId?: string;
888
+ }
889
+ export interface OrphanedPinnedTaskWire {
890
+ taskId: string;
891
+ title: string;
892
+ targetSessionId: string;
893
+ targetNodeId?: string;
894
+ missionId?: string;
895
+ }
896
+ export interface OrphanedPinNotifyResponse {
897
+ orphans: readonly OrphanedPinnedTaskWire[];
898
+ }
899
+ export declare function isOrphanedPinNotifyRequest(value: unknown): value is OrphanedPinNotifyRequest;
900
+ export declare function decodeOrphanedPinNotifyRequest(value: unknown): OrphanedPinNotifyRequest | null;
901
+ export declare function isOrphanedPinNotifyResponse(value: unknown): value is OrphanedPinNotifyResponse;
902
+ export declare function decodeOrphanedPinNotifyResponse(value: unknown): OrphanedPinNotifyResponse | null;
903
+ /** The complete, closed set of IPC command names this contract defines. */
904
+ export declare const TURN_IPC_COMMANDS: readonly ["turn_observe", "mesh_record", "turn_cancel", "operator_status", "turn_query", "mesh_index_query", "mission_upsert", "mission_query", "note_upsert", "note_forget", "tool_call_record", "ledger_query", "mission_list_query", "record_local", "queue_query", "queue_enqueue", "queue_enqueue_graph", "queue_cancel", "queue_requeue", "direct_dispatch_record", "graph_audit_record", "active_work_query", "recovery_context_query", "graph_gate_claim", "graph_gate_release", "graph_gate_abandon", "graph_node_patch", "graph_view_query", "task_stats_query", "prune_stale_direct", "orphaned_pin_notify"];
905
+ export type TurnIpcCommand = typeof TURN_IPC_COMMANDS[number];
906
+ export declare const isTurnIpcCommand: (value: unknown) => value is "operator_status" | "turn_observe" | "mesh_record" | "turn_cancel" | "turn_query" | "mesh_index_query" | "mission_upsert" | "mission_query" | "note_upsert" | "note_forget" | "tool_call_record" | "ledger_query" | "mission_list_query" | "record_local" | "queue_query" | "queue_enqueue" | "queue_enqueue_graph" | "queue_cancel" | "queue_requeue" | "direct_dispatch_record" | "graph_audit_record" | "active_work_query" | "recovery_context_query" | "graph_gate_claim" | "graph_gate_release" | "graph_gate_abandon" | "graph_node_patch" | "graph_view_query" | "task_stats_query" | "prune_stale_direct" | "orphaned_pin_notify";
907
+ /** Request type keyed by command name — for a generically-typed dispatcher on either end. */
908
+ export interface TurnIpcRequestByCommand {
909
+ turn_observe: TurnObserveRequest;
910
+ mesh_record: MeshRecordRequest;
911
+ turn_cancel: TurnCancelRequest;
912
+ operator_status: OperatorStatusRequest;
913
+ turn_query: TurnQueryRequest;
914
+ mesh_index_query: MeshIndexQueryRequest;
915
+ mission_upsert: MissionUpsertRequest;
916
+ mission_query: MissionQueryRequest;
917
+ note_upsert: NoteUpsertRequest;
918
+ note_forget: NoteForgetRequest;
919
+ tool_call_record: ToolCallRecordRequest;
920
+ ledger_query: LedgerQueryRequest;
921
+ mission_list_query: MissionListQueryRequest;
922
+ record_local: RecordLocalRequest;
923
+ queue_query: QueueQueryRequest;
924
+ queue_enqueue: QueueEnqueueRequest;
925
+ queue_enqueue_graph: QueueEnqueueGraphRequest;
926
+ queue_cancel: QueueCancelRequest;
927
+ queue_requeue: QueueRequeueRequest;
928
+ direct_dispatch_record: DirectDispatchRecordRequest;
929
+ graph_audit_record: GraphAuditRecordRequest;
930
+ active_work_query: ActiveWorkQueryRequest;
931
+ recovery_context_query: RecoveryContextQueryRequest;
932
+ graph_gate_claim: GraphGateClaimRequest;
933
+ graph_gate_release: GraphGateReleaseRequest;
934
+ graph_gate_abandon: GraphGateAbandonRequest;
935
+ graph_node_patch: GraphNodePatchRequest;
936
+ graph_view_query: GraphViewQueryRequest;
937
+ task_stats_query: TaskStatsQueryRequest;
938
+ prune_stale_direct: PruneStaleDirectRequest;
939
+ orphaned_pin_notify: OrphanedPinNotifyRequest;
940
+ }
941
+ /** Response type keyed by command name — for a generically-typed dispatcher on either end. */
942
+ export interface TurnIpcResponseByCommand {
943
+ turn_observe: TurnObserveResponse;
944
+ mesh_record: MeshRecordResponse;
945
+ turn_cancel: TurnCancelResponse;
946
+ operator_status: OperatorStatusResponse;
947
+ turn_query: TurnQueryResponse;
948
+ mission_upsert: MissionUpsertResponse;
949
+ mission_query: MissionQueryResponse;
950
+ mesh_index_query: MeshIndexQueryResponse;
951
+ note_upsert: NoteUpsertResponse;
952
+ note_forget: NoteForgetResponse;
953
+ tool_call_record: ToolCallRecordResponse;
954
+ ledger_query: LedgerQueryResponse;
955
+ mission_list_query: MissionListQueryResponse;
956
+ record_local: RecordLocalResponse;
957
+ queue_query: QueueQueryResponse;
958
+ queue_enqueue: QueueEnqueueResponse;
959
+ queue_enqueue_graph: QueueEnqueueGraphResponse;
960
+ queue_cancel: QueueCancelResponse;
961
+ queue_requeue: QueueRequeueResponse;
962
+ direct_dispatch_record: DirectDispatchRecordResponse;
963
+ graph_audit_record: GraphAuditRecordResponse;
964
+ active_work_query: ActiveWorkQueryResponse;
965
+ recovery_context_query: RecoveryContextQueryResponse;
966
+ graph_gate_claim: GraphGateClaimResponse;
967
+ graph_gate_release: GraphGateReleaseResponse;
968
+ graph_gate_abandon: GraphGateAbandonResponse;
969
+ graph_node_patch: GraphNodePatchResponse;
970
+ graph_view_query: GraphViewQueryResponse;
971
+ task_stats_query: TaskStatsQueryResponse;
972
+ prune_stale_direct: PruneStaleDirectResponse;
973
+ orphaned_pin_notify: OrphanedPinNotifyResponse;
974
+ }