@adhdev/mesh-shared 1.0.60-rc.6 → 1.0.60-rc.60

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 (47) hide show
  1. package/dist/brain-routing.d.ts +2 -2
  2. package/dist/index.d.ts +10 -0
  3. package/dist/index.js +2831 -35
  4. package/dist/index.js.map +1 -1
  5. package/dist/index.mjs +2505 -35
  6. package/dist/index.mjs.map +1 -1
  7. package/dist/magi.d.ts +1 -1
  8. package/dist/mesh-tool-names.d.ts +27 -2
  9. package/dist/mesh-vocabulary.d.ts +70 -0
  10. package/dist/mission-brief.d.ts +62 -0
  11. package/dist/outbound-message.d.ts +202 -0
  12. package/dist/path-ownership.d.ts +101 -0
  13. package/dist/protocol/daemon-server.d.ts +388 -0
  14. package/dist/protocol/dashboard-daemon-p2p.d.ts +212 -0
  15. package/dist/protocol/dashboard-server.d.ts +240 -0
  16. package/dist/protocol/envelope.d.ts +55 -0
  17. package/dist/protocol/index.d.ts +15 -0
  18. package/dist/session-launch.d.ts +113 -0
  19. package/dist/session-status.d.ts +61 -0
  20. package/dist/slot-proposal.d.ts +1 -1
  21. package/dist/turn-evidence.d.ts +438 -0
  22. package/dist/turn-ipc.d.ts +974 -0
  23. package/dist/types.d.ts +11 -0
  24. package/dist/worker-protocol.d.ts +69 -0
  25. package/dist/ws-protocol.d.ts +71 -41
  26. package/package.json +1 -1
  27. package/src/brain-routing.ts +3 -3
  28. package/src/index.ts +10 -0
  29. package/src/magi.ts +1 -1
  30. package/src/mesh-tool-names.ts +65 -19
  31. package/src/mesh-vocabulary.ts +98 -0
  32. package/src/mission-brief.ts +153 -0
  33. package/src/outbound-message.ts +320 -0
  34. package/src/path-ownership.ts +271 -0
  35. package/src/protocol/daemon-server.ts +552 -0
  36. package/src/protocol/dashboard-daemon-p2p.ts +272 -0
  37. package/src/protocol/dashboard-server.ts +340 -0
  38. package/src/protocol/envelope.ts +75 -0
  39. package/src/protocol/index.ts +16 -0
  40. package/src/session-launch.ts +247 -0
  41. package/src/session-status.ts +140 -0
  42. package/src/slot-proposal.ts +1 -1
  43. package/src/turn-evidence.ts +602 -0
  44. package/src/turn-ipc.ts +2231 -0
  45. package/src/types.ts +8 -0
  46. package/src/worker-protocol.ts +164 -0
  47. package/src/ws-protocol.ts +102 -93
package/dist/index.js CHANGED
@@ -20,52 +20,362 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
20
20
  // src/index.ts
21
21
  var index_exports = {};
22
22
  __export(index_exports, {
23
+ CANCEL_REASONS: () => CANCEL_REASONS,
23
24
  CANONICAL_MESH_TOOL_COUNT: () => CANONICAL_MESH_TOOL_COUNT,
24
25
  CANONICAL_MESH_TOOL_NAMES: () => CANONICAL_MESH_TOOL_NAMES,
25
26
  CLAUDE_TUI_REVIEW_PAGE_NOT_FOCUSED_PREFIX: () => CLAUDE_TUI_REVIEW_PAGE_NOT_FOCUSED_PREFIX,
26
27
  CLAUDE_TUI_REVIEW_UNCONFIRMED_PREFIX: () => CLAUDE_TUI_REVIEW_UNCONFIRMED_PREFIX,
27
28
  CLI_SLOT_RECIPES: () => CLI_SLOT_RECIPES,
29
+ COMMIT_STRENGTHS: () => COMMIT_STRENGTHS,
30
+ CONSUME_PROFILES: () => CONSUME_PROFILES,
31
+ COORDINATOR_ACK_OUTCOMES: () => COORDINATOR_ACK_OUTCOMES,
32
+ DAEMON_P2P_SIGNAL_TYPES: () => DAEMON_P2P_SIGNAL_TYPES,
33
+ DAEMON_STATUS_EVENT_NAMES: () => DAEMON_STATUS_EVENT_NAMES,
34
+ DAEMON_TO_DASHBOARD_P2P_TYPES: () => DAEMON_TO_DASHBOARD_P2P_TYPES,
35
+ DAEMON_TO_SERVER_TYPES: () => DAEMON_TO_SERVER_TYPES,
28
36
  DAEMON_TO_SERVER_WS_MSGS: () => DAEMON_TO_SERVER_WS_MSGS,
37
+ DASHBOARD_P2P_MESSAGE_KINDS: () => DASHBOARD_P2P_MESSAGE_KINDS,
38
+ DASHBOARD_P2P_SIGNAL_TYPES: () => DASHBOARD_P2P_SIGNAL_TYPES,
39
+ DASHBOARD_STATUS_EVENT_NAMES: () => DASHBOARD_STATUS_EVENT_NAMES,
40
+ DASHBOARD_TO_DAEMON_P2P_TYPES: () => DASHBOARD_TO_DAEMON_P2P_TYPES,
41
+ DASHBOARD_TO_USER_SESSION_TYPES: () => DASHBOARD_TO_USER_SESSION_TYPES,
29
42
  DEFAULT_DIFFICULTY_BRAINS: () => DEFAULT_DIFFICULTY_BRAINS,
43
+ DELIVERY_OUTCOMES: () => DELIVERY_OUTCOMES,
44
+ DELIVERY_VIAS: () => DELIVERY_VIAS,
45
+ DISPATCH_FAILURE_REASONS: () => DISPATCH_FAILURE_REASONS,
46
+ EVIDENCE_ENVELOPE_FIELD_SPECS: () => EVIDENCE_ENVELOPE_FIELD_SPECS,
47
+ EVIDENCE_SOURCE_IDS: () => EVIDENCE_SOURCE_IDS,
48
+ GRAPH_AUDIT_EVENTS: () => GRAPH_AUDIT_EVENTS,
49
+ HOLD_REASONS: () => HOLD_REASONS,
50
+ LIVENESS_RESULTS: () => LIVENESS_RESULTS,
30
51
  MAGI_RAW_ANSWER_CAP: () => MAGI_RAW_ANSWER_CAP,
52
+ MAX_MESH_RECORD_STRING: () => MAX_MESH_RECORD_STRING,
53
+ MAX_OWNED_PATHS: () => MAX_OWNED_PATHS,
31
54
  MESH_CHUNK_KIND: () => MESH_CHUNK_KIND,
32
55
  MESH_CHUNK_PAYLOAD_CHARS: () => MESH_CHUNK_PAYLOAD_CHARS,
33
56
  MESH_CHUNK_TTL_MS: () => MESH_CHUNK_TTL_MS,
57
+ MESH_DELIVERY_MODES: () => MESH_DELIVERY_MODES,
58
+ MESH_INDEX_QUERY_WRITER_SCOPES: () => MESH_INDEX_QUERY_WRITER_SCOPES,
34
59
  MESH_MAX_CHUNKS: () => MESH_MAX_CHUNKS,
35
60
  MESH_MAX_INLINE_FRAME_BYTES: () => MESH_MAX_INLINE_FRAME_BYTES,
36
61
  MESH_MAX_REASSEMBLED_BYTES: () => MESH_MAX_REASSEMBLED_BYTES,
62
+ MESH_MISSION_SOURCES: () => MESH_MISSION_SOURCES,
63
+ MESH_MISSION_STATUSES: () => MESH_MISSION_STATUSES,
64
+ MESH_P2P_SIGNAL_TYPES: () => MESH_P2P_SIGNAL_TYPES,
65
+ MESH_RECORD_PAYLOAD_KEYS: () => MESH_RECORD_PAYLOAD_KEYS,
66
+ MESH_SESSION_CLEANUP_MODES: () => MESH_SESSION_CLEANUP_MODES,
37
67
  MESH_TASK_DIFFICULTIES: () => MESH_TASK_DIFFICULTIES,
68
+ MESH_TASK_MODES: () => MESH_TASK_MODES,
69
+ MESH_TASK_PRIORITIES: () => MESH_TASK_PRIORITIES,
70
+ MESH_TASK_STATUSES: () => MESH_TASK_STATUSES,
71
+ MESH_TERMINAL_TASK_STATUSES: () => MESH_TERMINAL_TASK_STATUSES,
72
+ MESH_THINKING_LEVELS: () => MESH_THINKING_LEVELS,
73
+ MESH_TOPIC_ENTRY_KINDS: () => MESH_TOPIC_ENTRY_KINDS,
74
+ MESH_TOPIC_PROTOCOL_VERSION: () => MESH_TOPIC_PROTOCOL_VERSION,
75
+ MISSION_BRIEF_RENDER_MAX_CHARS: () => MISSION_BRIEF_RENDER_MAX_CHARS,
76
+ MODEL_AXIS_SOURCES: () => MODEL_AXIS_SOURCES,
77
+ MODEL_SELECTION_HISTORY_LIMIT: () => MODEL_SELECTION_HISTORY_LIMIT,
38
78
  MeshChunkAssembler: () => MeshChunkAssembler,
79
+ NATIVE_TURN_OUTCOMES: () => NATIVE_TURN_OUTCOMES,
80
+ NOTIFY_KINDS: () => NOTIFY_KINDS,
81
+ NO_PROGRESS_OBSERVED_STATUSES: () => NO_PROGRESS_OBSERVED_STATUSES,
82
+ NPM_UPDATE_TAGS: () => NPM_UPDATE_TAGS,
83
+ OPERATING_NOTE_CATEGORIES: () => OPERATING_NOTE_CATEGORIES,
84
+ OPERATOR_STATUSES: () => OPERATOR_STATUSES,
85
+ OPERATOR_STATUS_REASONS: () => OPERATOR_STATUS_REASONS,
86
+ OPERATOR_STATUS_REASON_VALUES: () => OPERATOR_STATUS_REASON_VALUES,
87
+ OPERATOR_STATUS_VALUES: () => OPERATOR_STATUS_VALUES,
88
+ OUTBOUND_MESSAGE_ORIGINS: () => OUTBOUND_MESSAGE_ORIGINS,
89
+ P2P_SIGNAL_TYPES: () => P2P_SIGNAL_TYPES,
90
+ PROVIDER_FAILURES: () => PROVIDER_FAILURES,
39
91
  QUOTA_SUPPORTED_PROVIDERS: () => QUOTA_SUPPORTED_PROVIDERS,
92
+ RECENT_SESSION_BUCKETS: () => RECENT_SESSION_BUCKETS,
93
+ RECLAIMING_SEND_REFUSALS: () => RECLAIMING_SEND_REFUSALS,
94
+ RELEASE_CHANNELS: () => RELEASE_CHANNELS,
95
+ RETIRED_MESH_TOOLS: () => RETIRED_MESH_TOOLS,
96
+ SEND_POLICY_MODES: () => SEND_POLICY_MODES,
97
+ SEND_REFUSAL_REASONS: () => SEND_REFUSAL_REASONS,
98
+ SERVER_STATUS_EVENT_NAMES: () => SERVER_STATUS_EVENT_NAMES,
99
+ SERVER_TO_DAEMON_CONTROL_TYPES: () => SERVER_TO_DAEMON_CONTROL_TYPES,
40
100
  SERVER_TO_DAEMON_WS_MSGS: () => SERVER_TO_DAEMON_WS_MSGS,
101
+ SESSION_ERROR_REASONS: () => SESSION_ERROR_REASONS,
102
+ SESSION_LAUNCHED_BY: () => SESSION_LAUNCHED_BY,
103
+ SESSION_REBOUND_REASONS: () => SESSION_REBOUND_REASONS,
104
+ SESSION_STATUSES: () => SESSION_STATUSES,
105
+ SESSION_STATUS_ALIASES: () => SESSION_STATUS_ALIASES,
106
+ SESSION_STATUS_CLASS: () => SESSION_STATUS_CLASS,
107
+ SHARED_SESSION_TO_VIEWER_TYPES: () => SHARED_SESSION_TO_VIEWER_TYPES,
41
108
  STATUS_PROBE_ARG_KEY: () => STATUS_PROBE_ARG_KEY,
109
+ SUSPENSION_MODALS: () => SUSPENSION_MODALS,
110
+ SUSPENSION_RESOLUTIONS: () => SUSPENSION_RESOLUTIONS,
111
+ SUSPENSION_RESOLUTION_VIAS: () => SUSPENSION_RESOLUTION_VIAS,
112
+ SYSTEM_ANNOUNCEMENT_TYPES: () => SYSTEM_ANNOUNCEMENT_TYPES,
113
+ TERMINAL_CLASS_EVIDENCE_KINDS: () => TERMINAL_CLASS_EVIDENCE_KINDS,
114
+ TOOL_CALLER_ROLES: () => TOOL_CALLER_ROLES,
115
+ TURN_END_BLOCK_REASONS: () => TURN_END_BLOCK_REASONS,
116
+ TURN_END_STRENGTHS: () => TURN_END_STRENGTHS,
117
+ TURN_EVIDENCE_FIELD_SPECS: () => TURN_EVIDENCE_FIELD_SPECS,
118
+ TURN_EVIDENCE_FLAGS: () => TURN_EVIDENCE_FLAGS,
119
+ TURN_EVIDENCE_KINDS: () => TURN_EVIDENCE_KINDS,
120
+ TURN_IPC_COMMANDS: () => TURN_IPC_COMMANDS,
121
+ TURN_IPC_ERROR_CODES: () => TURN_IPC_ERROR_CODES,
122
+ TURN_IPC_PROTOCOL_VERSION: () => TURN_IPC_PROTOCOL_VERSION,
123
+ TURN_OBSERVE_VERDICTS: () => TURN_OBSERVE_VERDICTS,
124
+ TURN_OUTCOMES: () => TURN_OUTCOMES,
125
+ TURN_REASONS: () => TURN_REASONS,
126
+ TURN_SCOPES: () => TURN_SCOPES,
42
127
  UNKNOWN_CLI_SLOT_RECIPE: () => UNKNOWN_CLI_SLOT_RECIPE,
128
+ USER_SESSION_TO_DASHBOARD_TYPES: () => USER_SESSION_TO_DASHBOARD_TYPES,
129
+ VERSION_UPDATE_REASONS: () => VERSION_UPDATE_REASONS,
130
+ VIEWER_TO_SHARED_SESSION_TYPES: () => VIEWER_TO_SHARED_SESSION_TYPES,
131
+ WORKER_BRANCH_STATES: () => WORKER_BRANCH_STATES,
132
+ WORKER_PROTOCOL_FOOTER_MARKER: () => WORKER_PROTOCOL_FOOTER_MARKER,
133
+ WORKER_REPORT_OUTCOMES: () => WORKER_REPORT_OUTCOMES,
134
+ WORKER_TOOLS: () => WORKER_TOOLS,
135
+ appendWorkerProtocolFooter: () => appendWorkerProtocolFooter,
43
136
  argsCarryStatusProbeMarker: () => argsCarryStatusProbeMarker,
44
137
  buildMagiPanelProposal: () => buildMagiPanelProposal,
45
138
  buildSlotProposal: () => buildSlotProposal,
46
139
  canonicalDaemonId: () => canonicalDaemonId,
140
+ classifySessionStatus: () => classifySessionStatus,
47
141
  compareSemver: () => compareSemver,
48
142
  daemonIdsEquivalent: () => daemonIdsEquivalent,
143
+ decodeActiveWorkQueryRequest: () => decodeActiveWorkQueryRequest,
144
+ decodeActiveWorkQueryResponse: () => decodeActiveWorkQueryResponse,
145
+ decodeDaemonToDashboardP2P: () => decodeDaemonToDashboardP2P,
146
+ decodeDaemonToServer: () => decodeDaemonToServer,
147
+ decodeDashboardToDaemonP2P: () => decodeDashboardToDaemonP2P,
148
+ decodeDashboardToDaemonP2PChunk: () => decodeDashboardToDaemonP2PChunk,
149
+ decodeDashboardToUserSession: () => decodeDashboardToUserSession,
150
+ decodeDirectDispatchRecordRequest: () => decodeDirectDispatchRecordRequest,
151
+ decodeDirectDispatchRecordResponse: () => decodeDirectDispatchRecordResponse,
152
+ decodeGraphAuditRecordRequest: () => decodeGraphAuditRecordRequest,
153
+ decodeGraphAuditRecordResponse: () => decodeGraphAuditRecordResponse,
154
+ decodeGraphGateAbandonRequest: () => decodeGraphGateAbandonRequest,
155
+ decodeGraphGateAbandonResponse: () => decodeGraphGateAbandonResponse,
156
+ decodeGraphGateClaimRequest: () => decodeGraphGateClaimRequest,
157
+ decodeGraphGateClaimResponse: () => decodeGraphGateClaimResponse,
158
+ decodeGraphGateReleaseRequest: () => decodeGraphGateReleaseRequest,
159
+ decodeGraphGateReleaseResponse: () => decodeGraphGateReleaseResponse,
160
+ decodeGraphNodePatchRequest: () => decodeGraphNodePatchRequest,
161
+ decodeGraphNodePatchResponse: () => decodeGraphNodePatchResponse,
162
+ decodeGraphViewQueryRequest: () => decodeGraphViewQueryRequest,
163
+ decodeGraphViewQueryResponse: () => decodeGraphViewQueryResponse,
164
+ decodeLedgerQueryRequest: () => decodeLedgerQueryRequest,
165
+ decodeLedgerQueryResponse: () => decodeLedgerQueryResponse,
166
+ decodeMeshIndexQueryRequest: () => decodeMeshIndexQueryRequest,
167
+ decodeMeshIndexQueryResponse: () => decodeMeshIndexQueryResponse,
168
+ decodeMeshRecordRequest: () => decodeMeshRecordRequest,
169
+ decodeMeshRecordResponse: () => decodeMeshRecordResponse,
170
+ decodeMissionListQueryRequest: () => decodeMissionListQueryRequest,
171
+ decodeMissionListQueryResponse: () => decodeMissionListQueryResponse,
172
+ decodeMissionQueryRequest: () => decodeMissionQueryRequest,
173
+ decodeMissionQueryResponse: () => decodeMissionQueryResponse,
174
+ decodeMissionUpsertRequest: () => decodeMissionUpsertRequest,
175
+ decodeMissionUpsertResponse: () => decodeMissionUpsertResponse,
176
+ decodeNoteForgetRequest: () => decodeNoteForgetRequest,
177
+ decodeNoteForgetResponse: () => decodeNoteForgetResponse,
178
+ decodeNoteUpsertRequest: () => decodeNoteUpsertRequest,
179
+ decodeNoteUpsertResponse: () => decodeNoteUpsertResponse,
180
+ decodeOperatorStatusRequest: () => decodeOperatorStatusRequest,
181
+ decodeOperatorStatusResponse: () => decodeOperatorStatusResponse,
182
+ decodeOrphanedPinNotifyRequest: () => decodeOrphanedPinNotifyRequest,
183
+ decodeOrphanedPinNotifyResponse: () => decodeOrphanedPinNotifyResponse,
184
+ decodePruneStaleDirectRequest: () => decodePruneStaleDirectRequest,
185
+ decodePruneStaleDirectResponse: () => decodePruneStaleDirectResponse,
186
+ decodeQueueCancelRequest: () => decodeQueueCancelRequest,
187
+ decodeQueueCancelResponse: () => decodeQueueCancelResponse,
188
+ decodeQueueEnqueueGraphRequest: () => decodeQueueEnqueueGraphRequest,
189
+ decodeQueueEnqueueGraphResponse: () => decodeQueueEnqueueGraphResponse,
190
+ decodeQueueEnqueueRequest: () => decodeQueueEnqueueRequest,
191
+ decodeQueueEnqueueResponse: () => decodeQueueEnqueueResponse,
192
+ decodeQueueQueryRequest: () => decodeQueueQueryRequest,
193
+ decodeQueueQueryResponse: () => decodeQueueQueryResponse,
194
+ decodeQueueRequeueRequest: () => decodeQueueRequeueRequest,
195
+ decodeQueueRequeueResponse: () => decodeQueueRequeueResponse,
196
+ decodeRecordLocalRequest: () => decodeRecordLocalRequest,
197
+ decodeRecordLocalResponse: () => decodeRecordLocalResponse,
198
+ decodeRecoveryContextQueryRequest: () => decodeRecoveryContextQueryRequest,
199
+ decodeRecoveryContextQueryResponse: () => decodeRecoveryContextQueryResponse,
200
+ decodeServerToDaemon: () => decodeServerToDaemon,
201
+ decodeTaskStatsQueryRequest: () => decodeTaskStatsQueryRequest,
202
+ decodeTaskStatsQueryResponse: () => decodeTaskStatsQueryResponse,
203
+ decodeToolCallRecordRequest: () => decodeToolCallRecordRequest,
204
+ decodeToolCallRecordResponse: () => decodeToolCallRecordResponse,
205
+ decodeTurnCancelRequest: () => decodeTurnCancelRequest,
206
+ decodeTurnCancelResponse: () => decodeTurnCancelResponse,
207
+ decodeTurnObserveRequest: () => decodeTurnObserveRequest,
208
+ decodeTurnObserveResponse: () => decodeTurnObserveResponse,
209
+ decodeTurnQueryRequest: () => decodeTurnQueryRequest,
210
+ decodeTurnQueryResponse: () => decodeTurnQueryResponse,
211
+ decodeTypeField: () => decodeTypeField,
212
+ decodeUserSessionToDashboard: () => decodeUserSessionToDashboard,
213
+ decodeViewerToSharedSession: () => decodeViewerToSharedSession,
49
214
  deriveProviderPriorityFromSlots: () => deriveProviderPriorityFromSlots,
50
215
  deriveSlotsFromLegacy: () => deriveSlotsFromLegacy,
216
+ describeModelSelection: () => describeModelSelection,
217
+ effectiveModelSelectionValue: () => effectiveModelSelectionValue,
218
+ enumOf: () => enumOf,
51
219
  expandDaemonIdForms: () => expandDaemonIdForms,
220
+ findOwnershipConflicts: () => findOwnershipConflicts,
52
221
  formatQuotaAccount: () => formatQuotaAccount,
53
222
  hasGitStatusEvidence: () => hasGitStatusEvidence,
223
+ hasWorkerProtocolFooter: () => hasWorkerProtocolFooter,
54
224
  interpolateArgs: () => interpolateArgs,
55
225
  interpolateString: () => interpolateString,
226
+ isActiveWorkQueryRequest: () => isActiveWorkQueryRequest,
227
+ isActiveWorkQueryResponse: () => isActiveWorkQueryResponse,
228
+ isBlockedStatus: () => isBlockedStatus,
229
+ isBusyStatus: () => isBusyStatus,
230
+ isChunkType: () => isChunkType,
231
+ isCommitStrength: () => isCommitStrength,
232
+ isDaemonDirectCommandType: () => isDaemonDirectCommandType,
233
+ isDaemonP2PSignalType: () => isDaemonP2PSignalType,
234
+ isDaemonStatusEventName: () => isDaemonStatusEventName,
235
+ isDaemonToDashboardP2PType: () => isDaemonToDashboardP2PType,
236
+ isDaemonToServerType: () => isDaemonToServerType,
56
237
  isDaemonToServerWsMsg: () => isDaemonToServerWsMsg,
238
+ isDashboardP2PSignalType: () => isDashboardP2PSignalType,
239
+ isDashboardStatusEventName: () => isDashboardStatusEventName,
240
+ isDashboardToDaemonChunkType: () => isDashboardToDaemonChunkType,
241
+ isDashboardToDaemonP2PType: () => isDashboardToDaemonP2PType,
242
+ isDashboardToUserSessionType: () => isDashboardToUserSessionType,
243
+ isDeadStatus: () => isDeadStatus,
244
+ isDirectDispatchRecordRequest: () => isDirectDispatchRecordRequest,
245
+ isDirectDispatchRecordResponse: () => isDirectDispatchRecordResponse,
57
246
  isDowngrade: () => isDowngrade,
247
+ isEvidenceIdentifier: () => isEvidenceIdentifier,
248
+ isEvidenceSourceId: () => isEvidenceSourceId,
249
+ isFiniteNumber: () => isFiniteNumber,
250
+ isGraphAuditEvent: () => isGraphAuditEvent,
251
+ isGraphAuditRecordRequest: () => isGraphAuditRecordRequest,
252
+ isGraphAuditRecordResponse: () => isGraphAuditRecordResponse,
253
+ isGraphGateAbandonRequest: () => isGraphGateAbandonRequest,
254
+ isGraphGateAbandonResponse: () => isGraphGateAbandonResponse,
255
+ isGraphGateClaimRequest: () => isGraphGateClaimRequest,
256
+ isGraphGateClaimResponse: () => isGraphGateClaimResponse,
257
+ isGraphGateReleaseRequest: () => isGraphGateReleaseRequest,
258
+ isGraphGateReleaseResponse: () => isGraphGateReleaseResponse,
259
+ isGraphNodePatchRequest: () => isGraphNodePatchRequest,
260
+ isGraphNodePatchResponse: () => isGraphNodePatchResponse,
261
+ isGraphViewQueryRequest: () => isGraphViewQueryRequest,
262
+ isGraphViewQueryResponse: () => isGraphViewQueryResponse,
263
+ isHoldReason: () => isHoldReason,
264
+ isInputEnvelopeWire: () => isInputEnvelopeWire,
265
+ isLedgerQueryRequest: () => isLedgerQueryRequest,
266
+ isLedgerQueryResponse: () => isLedgerQueryResponse,
267
+ isMeshDeliveryMode: () => isMeshDeliveryMode,
268
+ isMeshIndexQueryRequest: () => isMeshIndexQueryRequest,
269
+ isMeshIndexQueryResponse: () => isMeshIndexQueryResponse,
270
+ isMeshIndexQueryWriterScope: () => isMeshIndexQueryWriterScope,
271
+ isMeshMissionSourceValue: () => isMeshMissionSourceValue,
272
+ isMeshMissionStatusValue: () => isMeshMissionStatusValue,
273
+ isMeshP2PSignalType: () => isMeshP2PSignalType,
274
+ isMeshRecordPayload: () => isMeshRecordPayload,
275
+ isMeshRecordRequest: () => isMeshRecordRequest,
276
+ isMeshRecordResponse: () => isMeshRecordResponse,
277
+ isMeshSessionCleanupMode: () => isMeshSessionCleanupMode,
58
278
  isMeshTaskDifficulty: () => isMeshTaskDifficulty,
279
+ isMeshTaskMode: () => isMeshTaskMode,
280
+ isMeshTaskPriority: () => isMeshTaskPriority,
281
+ isMeshTaskStatus: () => isMeshTaskStatus,
282
+ isMeshTerminalTaskStatus: () => isMeshTerminalTaskStatus,
283
+ isMeshThinkingLevel: () => isMeshThinkingLevel,
284
+ isMeshTopicEntry: () => isMeshTopicEntry,
285
+ isMeshTopicEntryKind: () => isMeshTopicEntryKind,
286
+ isMessageId: () => isMessageId,
287
+ isMissionListQueryRequest: () => isMissionListQueryRequest,
288
+ isMissionListQueryResponse: () => isMissionListQueryResponse,
289
+ isMissionQueryRequest: () => isMissionQueryRequest,
290
+ isMissionQueryResponse: () => isMissionQueryResponse,
291
+ isMissionUpsertRequest: () => isMissionUpsertRequest,
292
+ isMissionUpsertResponse: () => isMissionUpsertResponse,
293
+ isModelAxisSource: () => isModelAxisSource,
294
+ isNonEmptyString: () => isNonEmptyString,
295
+ isNoteForgetRequest: () => isNoteForgetRequest,
296
+ isNoteForgetResponse: () => isNoteForgetResponse,
297
+ isNoteUpsertRequest: () => isNoteUpsertRequest,
298
+ isNoteUpsertResponse: () => isNoteUpsertResponse,
299
+ isNotifyKind: () => isNotifyKind,
300
+ isOperatingNoteCategory: () => isOperatingNoteCategory,
301
+ isOperatorStatusReasonValue: () => isOperatorStatusReasonValue,
302
+ isOperatorStatusRequest: () => isOperatorStatusRequest,
303
+ isOperatorStatusResponse: () => isOperatorStatusResponse,
304
+ isOperatorStatusValue: () => isOperatorStatusValue,
305
+ isOrphanedPinNotifyRequest: () => isOrphanedPinNotifyRequest,
306
+ isOrphanedPinNotifyResponse: () => isOrphanedPinNotifyResponse,
307
+ isOutboundMessage: () => isOutboundMessage,
308
+ isOutboundMessageOrigin: () => isOutboundMessageOrigin,
309
+ isP2PSignalType: () => isP2PSignalType,
59
310
  isPhantomDaemonEntry: () => isPhantomDaemonEntry,
311
+ isPruneStaleDirectRequest: () => isPruneStaleDirectRequest,
312
+ isPruneStaleDirectResponse: () => isPruneStaleDirectResponse,
313
+ isQueueCancelRequest: () => isQueueCancelRequest,
314
+ isQueueCancelResponse: () => isQueueCancelResponse,
315
+ isQueueEnqueueGraphRequest: () => isQueueEnqueueGraphRequest,
316
+ isQueueEnqueueGraphResponse: () => isQueueEnqueueGraphResponse,
317
+ isQueueEnqueueRequest: () => isQueueEnqueueRequest,
318
+ isQueueEnqueueResponse: () => isQueueEnqueueResponse,
319
+ isQueueQueryRequest: () => isQueueQueryRequest,
320
+ isQueueQueryResponse: () => isQueueQueryResponse,
321
+ isQueueRequeueRequest: () => isQueueRequeueRequest,
322
+ isQueueRequeueResponse: () => isQueueRequeueResponse,
60
323
  isRawDaemonDoId: () => isRawDaemonDoId,
324
+ isReadyStatus: () => isReadyStatus,
325
+ isRecord: () => isRecord,
326
+ isRecordLocalRequest: () => isRecordLocalRequest,
327
+ isRecordLocalResponse: () => isRecordLocalResponse,
328
+ isRecoveryContextQueryRequest: () => isRecoveryContextQueryRequest,
329
+ isRecoveryContextQueryResponse: () => isRecoveryContextQueryResponse,
330
+ isSendPolicy: () => isSendPolicy,
331
+ isSendPolicyMode: () => isSendPolicyMode,
332
+ isSendRefusal: () => isSendRefusal,
333
+ isServerDirectCommandMsg: () => isServerDirectCommandMsg,
334
+ isServerToDaemonControlType: () => isServerToDaemonControlType,
61
335
  isServerToDaemonWsMsg: () => isServerToDaemonWsMsg,
336
+ isSessionLaunchedBy: () => isSessionLaunchedBy,
337
+ isSessionStatus: () => isSessionStatus,
338
+ isSharedSessionToViewerType: () => isSharedSessionToViewerType,
339
+ isSubmitOutcome: () => isSubmitOutcome,
340
+ isSummaryRef: () => isSummaryRef,
341
+ isTaskStatsQueryRequest: () => isTaskStatsQueryRequest,
342
+ isTaskStatsQueryResponse: () => isTaskStatsQueryResponse,
343
+ isTerminalClassEvidenceKind: () => isTerminalClassEvidenceKind,
344
+ isToolCallRecordRequest: () => isToolCallRecordRequest,
345
+ isToolCallRecordResponse: () => isToolCallRecordResponse,
346
+ isToolCallerRole: () => isToolCallerRole,
347
+ isTurnAttemptRef: () => isTurnAttemptRef,
348
+ isTurnCancelRequest: () => isTurnCancelRequest,
349
+ isTurnCancelResponse: () => isTurnCancelResponse,
350
+ isTurnEvidence: () => isTurnEvidence,
351
+ isTurnEvidenceKind: () => isTurnEvidenceKind,
352
+ isTurnIpcCommand: () => isTurnIpcCommand,
353
+ isTurnIpcError: () => isTurnIpcError,
354
+ isTurnIpcErrorCode: () => isTurnIpcErrorCode,
355
+ isTurnObserveRequest: () => isTurnObserveRequest,
356
+ isTurnObserveResponse: () => isTurnObserveResponse,
357
+ isTurnObserveVerdict: () => isTurnObserveVerdict,
358
+ isTurnOutcome: () => isTurnOutcome,
359
+ isTurnQueryRequest: () => isTurnQueryRequest,
360
+ isTurnQueryResponse: () => isTurnQueryResponse,
361
+ isTurnReason: () => isTurnReason,
362
+ isUserSessionToDashboardType: () => isUserSessionToDashboardType,
363
+ isViewerToSharedSessionType: () => isViewerToSharedSessionType,
364
+ isWorkerBranchState: () => isWorkerBranchState,
365
+ isWorkerReportOutcome: () => isWorkerReportOutcome,
366
+ isWorkerTool: () => isWorkerTool,
367
+ isWorkingStatus: () => isWorkingStatus,
62
368
  joinRepoPath: () => joinRepoPath,
369
+ launchModelSelectionValue: () => launchModelSelectionValue,
63
370
  machineCoreFromDaemonId: () => machineCoreFromDaemonId,
371
+ makeTypeGuard: () => makeTypeGuard,
64
372
  measureWorstCaseChunkEnvelopeBytes: () => measureWorstCaseChunkEnvelopeBytes,
65
373
  meshFrameNeedsChunking: () => meshFrameNeedsChunking,
66
374
  meshNodeIdMatches: () => meshNodeIdMatches,
67
375
  meshUtf8ByteLength: () => meshUtf8ByteLength,
68
376
  meshWorkspacesEquivalent: () => meshWorkspacesEquivalent,
377
+ mintMessageId: () => mintMessageId,
378
+ normalizeAuthOkLimits: () => normalizeAuthOkLimits,
69
379
  normalizeBrainSlot: () => normalizeBrainSlot,
70
380
  normalizeDifficultyBrainMap: () => normalizeDifficultyBrainMap,
71
381
  normalizeGitStatus: () => normalizeGitStatus,
@@ -73,25 +383,41 @@ __export(index_exports, {
73
383
  normalizeMeshNodeId: () => normalizeMeshNodeId,
74
384
  normalizeMeshSessionRecord: () => normalizeMeshSessionRecord,
75
385
  normalizeMeshWorkspaceForCompare: () => normalizeMeshWorkspaceForCompare,
386
+ normalizeMissionBrief: () => normalizeMissionBrief,
76
387
  normalizeNodeCapabilitySlot: () => normalizeNodeCapabilitySlot,
77
388
  normalizeNodeCapabilitySlots: () => normalizeNodeCapabilitySlots,
389
+ normalizeOwnedPaths: () => normalizeOwnedPaths,
390
+ normalizeSessionStatus: () => normalizeSessionStatus,
78
391
  normalizeThinkingLevel: () => normalizeThinkingLevel,
79
392
  parseJsonRecord: () => parseJsonRecord,
80
393
  parseSemver: () => parseSemver,
394
+ parseSessionLaunchRecord: () => parseSessionLaunchRecord,
395
+ pathsOverlap: () => pathsOverlap,
81
396
  pickBestTransitGitStatus: () => pickBestTransitGitStatus,
397
+ projectTurnEvidenceEntry: () => projectTurnEvidenceEntry,
82
398
  readBoolean: () => readBoolean,
399
+ readEnvelopeFields: () => readEnvelopeFields,
83
400
  readGitSubmodules: () => readGitSubmodules,
84
401
  readNumber: () => readNumber,
85
402
  readRecord: () => readRecord,
86
403
  readString: () => readString,
87
404
  readStringArray: () => readStringArray,
405
+ renderCoordinatorWorkerSection: () => renderCoordinatorWorkerSection,
406
+ renderMissionBriefBlock: () => renderMissionBriefBlock,
407
+ renderWorkerProtocolFooter: () => renderWorkerProtocolFooter,
408
+ retiredMeshToolError: () => retiredMeshToolError,
409
+ sanitizeModelIdentifier: () => sanitizeModelIdentifier,
410
+ sanitizeRefusalCode: () => sanitizeRefusalCode,
88
411
  scoreGitStatusCandidate: () => scoreGitStatusCandidate,
89
412
  scoreGitUpstreamFreshness: () => scoreGitUpstreamFreshness,
90
413
  sessionIdsEquivalent: () => sessionIdsEquivalent,
91
414
  splitMeshFrame: () => splitMeshFrame,
415
+ statusesOfClass: () => statusesOfClass,
92
416
  stripStatusProbeMarker: () => stripStatusProbeMarker,
417
+ stripWorkerProtocolFooter: () => stripWorkerProtocolFooter,
93
418
  summarizeGitShape: () => summarizeGitShape,
94
419
  supportsQuota: () => supportsQuota,
420
+ touchedFilesOutsideOwnership: () => touchedFilesOutsideOwnership,
95
421
  withStatusProbeMarker: () => withStatusProbeMarker
96
422
  });
97
423
  module.exports = __toCommonJS(index_exports);
@@ -385,8 +711,8 @@ function meshWorkspacesEquivalent(a, b) {
385
711
 
386
712
  // src/daemon-normalize.ts
387
713
  var DAEMON_ID_PREFIXES = ["daemon_", "standalone_"];
388
- function isRawDaemonDoId(id) {
389
- const trimmed = readString(id);
714
+ function isRawDaemonDoId(id2) {
715
+ const trimmed = readString(id2);
390
716
  return !!trimmed && /^[0-9a-f]{64}$/i.test(trimmed);
391
717
  }
392
718
  function isPhantomDaemonEntry(entry) {
@@ -397,8 +723,8 @@ function isPhantomDaemonEntry(entry) {
397
723
  );
398
724
  return !hasMachineEvidence;
399
725
  }
400
- function machineCoreFromDaemonId(id) {
401
- const trimmed = readString(id);
726
+ function machineCoreFromDaemonId(id2) {
727
+ const trimmed = readString(id2);
402
728
  if (!trimmed) return void 0;
403
729
  for (const prefix of DAEMON_ID_PREFIXES) {
404
730
  if (trimmed.startsWith(prefix)) {
@@ -408,8 +734,8 @@ function machineCoreFromDaemonId(id) {
408
734
  }
409
735
  return trimmed;
410
736
  }
411
- function canonicalDaemonId(id) {
412
- const core = machineCoreFromDaemonId(id);
737
+ function canonicalDaemonId(id2) {
738
+ const core = machineCoreFromDaemonId(id2);
413
739
  if (!core) return void 0;
414
740
  if (!core.startsWith("mach_")) return core;
415
741
  return `daemon_${core}`;
@@ -761,9 +1087,7 @@ var CANONICAL_MESH_TOOL_NAMES = [
761
1087
  "mesh_view_queue",
762
1088
  // GRAPH-ORCHESTRATION Phase E — the coordinator gate + graph view surface.
763
1089
  "mesh_graph_view",
764
- "mesh_graph_gate_claim",
765
- "mesh_graph_gate_release",
766
- "mesh_graph_gate_abandon",
1090
+ "mesh_graph_gate",
767
1091
  "mesh_graph_node_patch",
768
1092
  "mesh_queue_cancel",
769
1093
  "mesh_queue_requeue",
@@ -781,7 +1105,6 @@ var CANONICAL_MESH_TOOL_NAMES = [
781
1105
  "mesh_approve",
782
1106
  "mesh_answer_question",
783
1107
  "mesh_list_pending_approvals",
784
- "mesh_plan_onboarding",
785
1108
  "mesh_create",
786
1109
  "mesh_add_node",
787
1110
  "mesh_clone_node",
@@ -789,34 +1112,57 @@ var CANONICAL_MESH_TOOL_NAMES = [
789
1112
  "mesh_cleanup_worktree_nodes",
790
1113
  "mesh_refine_node",
791
1114
  "mesh_refine_batch",
792
- "mesh_refine_config",
793
- "mesh_change_impact_config",
1115
+ "mesh_config",
794
1116
  "mesh_init",
795
- "mesh_reinit",
796
- "mesh_write_mesh_json_config",
797
1117
  "mesh_refine_plan",
798
1118
  "mesh_cleanup_sessions",
799
- "mesh_prune_stale_direct",
800
1119
  "mesh_task_history",
801
1120
  "mesh_ledger_query",
802
- "mesh_record_note",
803
- "mesh_forget_note",
1121
+ "mesh_note",
804
1122
  "mesh_reconcile_ledger",
805
- "mesh_requeue_held_events",
806
1123
  "mesh_mission_upsert",
807
1124
  "mesh_mission_list",
808
1125
  "mesh_review_inbox",
809
1126
  "mesh_magi_review",
810
1127
  "mesh_magi_collect",
811
- "mesh_magi_kind_panel_set",
812
- "mesh_magi_kind_panel_list",
813
- "mesh_node_slots_set",
814
- "mesh_node_slots_list",
815
- "mesh_node_slots_propose",
816
- "mesh_coordinator_prompt_append_get",
817
- "mesh_coordinator_prompt_append_set"
1128
+ "mesh_magi_kind_panel",
1129
+ "mesh_node_slots",
1130
+ "mesh_coordinator_prompt_append"
818
1131
  ];
819
1132
  var CANONICAL_MESH_TOOL_COUNT = CANONICAL_MESH_TOOL_NAMES.length;
1133
+ var RETIRED_MESH_TOOLS = {
1134
+ mesh_graph_gate_claim: {
1135
+ tool: "mesh_graph_gate",
1136
+ args: { action: "claim" },
1137
+ note: 'The extend-only form (claim with extend_seconds) is now action: "extend" with the same extend_seconds.'
1138
+ },
1139
+ mesh_graph_gate_release: { tool: "mesh_graph_gate", args: { action: "release" } },
1140
+ mesh_graph_gate_abandon: { tool: "mesh_graph_gate", args: { action: "abandon" } },
1141
+ // Never a published tool (it is the daemon command behind the extend verb),
1142
+ // but an older gate-expiry notice told coordinators to call it by this name.
1143
+ mesh_graph_gate_extend: { tool: "mesh_graph_gate", args: { action: "extend" } },
1144
+ mesh_node_slots_set: { tool: "mesh_node_slots", args: { action: "set" } },
1145
+ mesh_node_slots_list: { tool: "mesh_node_slots", args: { action: "list" } },
1146
+ mesh_node_slots_propose: { tool: "mesh_node_slots", args: { action: "propose" } },
1147
+ mesh_magi_kind_panel_set: { tool: "mesh_magi_kind_panel", args: { action: "set" } },
1148
+ mesh_magi_kind_panel_list: { tool: "mesh_magi_kind_panel", args: { action: "list" } },
1149
+ mesh_coordinator_prompt_append_get: { tool: "mesh_coordinator_prompt_append", args: { action: "get" } },
1150
+ mesh_coordinator_prompt_append_set: { tool: "mesh_coordinator_prompt_append", args: { action: "set" } },
1151
+ mesh_record_note: { tool: "mesh_note", args: { action: "record" } },
1152
+ mesh_forget_note: { tool: "mesh_note", args: { action: "forget" } },
1153
+ mesh_reinit: { tool: "mesh_init", args: { mode: "reinit" } },
1154
+ mesh_refine_config: { tool: "mesh_config", args: { kind: "refine" } },
1155
+ mesh_change_impact_config: { tool: "mesh_config", args: { kind: "change_impact" } },
1156
+ mesh_write_mesh_json_config: { tool: "mesh_config", args: { kind: "mesh_json" } },
1157
+ mesh_plan_onboarding: { tool: "mesh_create", args: { mode: "plan" } },
1158
+ mesh_prune_stale_direct: { tool: "mesh_cleanup_sessions", args: { mode: "prune_stale_direct" } }
1159
+ };
1160
+ function retiredMeshToolError(name) {
1161
+ const entry = Object.prototype.hasOwnProperty.call(RETIRED_MESH_TOOLS, name) ? RETIRED_MESH_TOOLS[name] : void 0;
1162
+ if (!entry) return null;
1163
+ const discriminator = Object.entries(entry.args).map(([k, v]) => `${k}: "${v}"`).join(", ");
1164
+ return `Tool "${name}" was retired (merged into ${entry.tool}). Call ${entry.tool} with ${discriminator} and the same other arguments.` + (entry.note ? ` ${entry.note}` : "");
1165
+ }
820
1166
 
821
1167
  // src/mesh-status-probe.ts
822
1168
  var STATUS_PROBE_ARG_KEY = "_statusProbe";
@@ -1055,8 +1401,54 @@ function isDowngrade(current, target) {
1055
1401
  return direction < 0;
1056
1402
  }
1057
1403
 
1058
- // src/ws-protocol.ts
1059
- var DAEMON_TO_SERVER_WS_MSGS = [
1404
+ // src/protocol/envelope.ts
1405
+ function isRecord(value) {
1406
+ return typeof value === "object" && value !== null && !Array.isArray(value);
1407
+ }
1408
+ function isNonEmptyString(value) {
1409
+ return typeof value === "string" && value.length > 0;
1410
+ }
1411
+ function isFiniteNumber(value) {
1412
+ return typeof value === "number" && Number.isFinite(value);
1413
+ }
1414
+ function makeTypeGuard(names) {
1415
+ const set = new Set(names);
1416
+ return (value) => typeof value === "string" && set.has(value);
1417
+ }
1418
+ function decodeTypeField(raw, isType) {
1419
+ if (!isRecord(raw)) return null;
1420
+ if (!isType(raw.type)) return null;
1421
+ return { type: raw.type, frame: raw };
1422
+ }
1423
+ function readEnvelopeFields(frame) {
1424
+ return {
1425
+ ...isNonEmptyString(frame.id) ? { id: frame.id } : {},
1426
+ ...isFiniteNumber(frame.timestamp) ? { timestamp: frame.timestamp } : {}
1427
+ };
1428
+ }
1429
+
1430
+ // src/protocol/daemon-server.ts
1431
+ var DAEMON_STATUS_EVENT_NAMES = [
1432
+ "agent:generating_started",
1433
+ "agent:waiting_approval",
1434
+ "agent:waiting_choice",
1435
+ "agent:generating_completed",
1436
+ "agent:stopped",
1437
+ "monitor:no_progress",
1438
+ /** Legacy alias for `monitor:no_progress`, still emitted by older daemons. */
1439
+ "monitor:long_generating"
1440
+ ];
1441
+ var isDaemonStatusEventName = makeTypeGuard(DAEMON_STATUS_EVENT_NAMES);
1442
+ var RELEASE_CHANNELS = ["stable", "preview"];
1443
+ var NPM_UPDATE_TAGS = ["latest", "next"];
1444
+ var VERSION_UPDATE_REASONS = ["force_update_below", "major_minor_mismatch", "patch_mismatch", "daemon_ahead"];
1445
+ var P2P_SIGNAL_TYPES = ["p2p_ready", "p2p_offer", "p2p_answer", "p2p_ice"];
1446
+ var isP2PSignalType = makeTypeGuard(P2P_SIGNAL_TYPES);
1447
+ var DAEMON_P2P_SIGNAL_TYPES = ["p2p_offer", "p2p_ice"];
1448
+ var isDaemonP2PSignalType = makeTypeGuard(DAEMON_P2P_SIGNAL_TYPES);
1449
+ var MESH_P2P_SIGNAL_TYPES = ["mesh_p2p_ready", "mesh_p2p_offer", "mesh_p2p_answer", "mesh_p2p_ice"];
1450
+ var isMeshP2PSignalType = makeTypeGuard(MESH_P2P_SIGNAL_TYPES);
1451
+ var DAEMON_TO_SERVER_TYPES = [
1060
1452
  "auth",
1061
1453
  "status_report",
1062
1454
  "status_heartbeat",
@@ -1064,10 +1456,29 @@ var DAEMON_TO_SERVER_WS_MSGS = [
1064
1456
  "command_result",
1065
1457
  "error",
1066
1458
  "agent_event",
1067
- "log",
1068
- "beacon_vectors"
1459
+ "beacon_vectors",
1460
+ "daemon_mesh_command",
1461
+ "p2p_offer",
1462
+ "p2p_ice"
1069
1463
  ];
1070
- var SERVER_TO_DAEMON_WS_MSGS = [
1464
+ var isDaemonToServerType = makeTypeGuard(DAEMON_TO_SERVER_TYPES);
1465
+ function decodeDaemonToServer(raw) {
1466
+ if (!isRecord(raw) || !isDaemonToServerType(raw.type)) return null;
1467
+ if (raw.type === "daemon_mesh_command") {
1468
+ return {
1469
+ type: "daemon_mesh_command",
1470
+ requestId: typeof raw.requestId === "string" ? raw.requestId : String(raw.requestId ?? ""),
1471
+ targetDaemonId: typeof raw.targetDaemonId === "string" ? raw.targetDaemonId : "",
1472
+ command: raw.command,
1473
+ args: isRecord(raw.args) ? raw.args : {},
1474
+ timestamp: typeof raw.timestamp === "number" ? raw.timestamp : Date.now()
1475
+ };
1476
+ }
1477
+ if (!isRecord(raw.payload)) return null;
1478
+ if (raw.type === "auth" && !isNonEmptyString(raw.payload.token)) return null;
1479
+ return { type: raw.type, payload: raw.payload, ...readEnvelopeFields(raw) };
1480
+ }
1481
+ var SERVER_TO_DAEMON_CONTROL_TYPES = [
1071
1482
  "auth_ok",
1072
1483
  "auth_error",
1073
1484
  "machine_evicted",
@@ -1078,66 +1489,2435 @@ var SERVER_TO_DAEMON_WS_MSGS = [
1078
1489
  "command",
1079
1490
  "agent_command",
1080
1491
  "resolve_action",
1081
- "beacon_vectors_result"
1492
+ "beacon_vectors_result",
1493
+ "daemon_mesh_result",
1494
+ "p2p_ready",
1495
+ "p2p_offer",
1496
+ "p2p_answer",
1497
+ "p2p_ice",
1498
+ "mesh_p2p_ready",
1499
+ "mesh_p2p_offer",
1500
+ "mesh_p2p_answer",
1501
+ "mesh_p2p_ice"
1502
+ ];
1503
+ var isServerToDaemonControlType = makeTypeGuard(SERVER_TO_DAEMON_CONTROL_TYPES);
1504
+ function isServerDirectCommandMsg(msg) {
1505
+ return !isServerToDaemonControlType(msg.type);
1506
+ }
1507
+ var DIRECT_COMMAND_TYPE_PATTERN = /^[a-z][a-z0-9_:.-]{0,63}$/;
1508
+ function isDaemonDirectCommandType(value) {
1509
+ return typeof value === "string" && DIRECT_COMMAND_TYPE_PATTERN.test(value) && !isServerToDaemonControlType(value);
1510
+ }
1511
+ function decodeServerToDaemon(raw) {
1512
+ if (!isRecord(raw) || typeof raw.type !== "string") return null;
1513
+ const relay = {
1514
+ ...readEnvelopeFields(raw),
1515
+ ...isNonEmptyString(raw.source) ? { source: raw.source } : {}
1516
+ };
1517
+ if (raw.type === "beacon_vectors_result" || raw.type === "daemon_mesh_result") {
1518
+ if (!isNonEmptyString(raw.requestId)) return null;
1519
+ const base = { requestId: raw.requestId, success: raw.success === true };
1520
+ if (raw.type === "beacon_vectors_result") {
1521
+ return {
1522
+ type: "beacon_vectors_result",
1523
+ ...base,
1524
+ ...Array.isArray(raw.reports) ? { reports: raw.reports } : {},
1525
+ ...typeof raw.truncated === "number" ? { truncated: raw.truncated } : {},
1526
+ ...typeof raw.error === "string" ? { error: raw.error } : {}
1527
+ };
1528
+ }
1529
+ return {
1530
+ type: "daemon_mesh_result",
1531
+ ...base,
1532
+ ..."result" in raw ? { result: raw.result } : {},
1533
+ ...typeof raw.error === "string" ? { error: raw.error } : {}
1534
+ };
1535
+ }
1536
+ if (!isRecord(raw.payload)) return null;
1537
+ if (isServerToDaemonControlType(raw.type)) {
1538
+ return { type: raw.type, payload: raw.payload, ...relay };
1539
+ }
1540
+ if (!isDaemonDirectCommandType(raw.type)) return null;
1541
+ return { type: raw.type, payload: raw.payload, ...relay };
1542
+ }
1543
+
1544
+ // src/protocol/dashboard-server.ts
1545
+ var SERVER_STATUS_EVENT_NAMES = [
1546
+ "daemon:disconnect",
1547
+ "team:session_viewed",
1548
+ "team:view_request",
1549
+ "team:view_request_approved",
1550
+ "team:view_request_rejected"
1551
+ ];
1552
+ var DASHBOARD_STATUS_EVENT_NAMES = [...DAEMON_STATUS_EVENT_NAMES, ...SERVER_STATUS_EVENT_NAMES];
1553
+ var isDashboardStatusEventName = makeTypeGuard(DASHBOARD_STATUS_EVENT_NAMES);
1554
+ var SYSTEM_ANNOUNCEMENT_TYPES = ["info", "warning", "critical"];
1555
+ var USER_SESSION_TO_DASHBOARD_TYPES = [
1556
+ "connected",
1557
+ "initial_state",
1558
+ "daemon_status",
1559
+ "status_event",
1560
+ "system_announcement",
1561
+ "auth_error",
1562
+ "heartbeat",
1563
+ "p2p_offer",
1564
+ "p2p_ice"
1565
+ ];
1566
+ var isUserSessionToDashboardType = makeTypeGuard(USER_SESSION_TO_DASHBOARD_TYPES);
1567
+ function decodeUserSessionToDashboard(raw) {
1568
+ if (!isRecord(raw) || !isUserSessionToDashboardType(raw.type)) return null;
1569
+ if (raw.type === "heartbeat") {
1570
+ return { type: "heartbeat", payload: isRecord(raw.payload) ? raw.payload : {}, ...readEnvelopeFields(raw) };
1571
+ }
1572
+ if (!isRecord(raw.payload)) return null;
1573
+ return { type: raw.type, payload: raw.payload, ...readEnvelopeFields(raw) };
1574
+ }
1575
+ var DASHBOARD_TO_USER_SESSION_TYPES = ["heartbeat", "refresh", "p2p_ready", "p2p_answer", "p2p_ice"];
1576
+ var isDashboardToUserSessionType = makeTypeGuard(DASHBOARD_TO_USER_SESSION_TYPES);
1577
+ var DASHBOARD_P2P_SIGNAL_TYPES = ["p2p_ready", "p2p_answer", "p2p_ice"];
1578
+ var isDashboardP2PSignalType = makeTypeGuard(DASHBOARD_P2P_SIGNAL_TYPES);
1579
+ function decodeDashboardToUserSession(raw) {
1580
+ if (!isRecord(raw) || !isDashboardToUserSessionType(raw.type)) return null;
1581
+ if (raw.type === "heartbeat") return { type: "heartbeat", ...readEnvelopeFields(raw) };
1582
+ if (raw.type === "refresh") return { type: "refresh" };
1583
+ if (!isRecord(raw.payload) || typeof raw.payload.daemonId !== "string") return null;
1584
+ return { type: raw.type, payload: raw.payload, ...readEnvelopeFields(raw) };
1585
+ }
1586
+ var SHARED_SESSION_TO_VIEWER_TYPES = [
1587
+ "share:connected",
1588
+ "share:revoked",
1589
+ "share:expired",
1590
+ "share:error",
1591
+ "share:viewer_count",
1592
+ "p2p_offer",
1593
+ "p2p_ice"
1594
+ ];
1595
+ var isSharedSessionToViewerType = makeTypeGuard(SHARED_SESSION_TO_VIEWER_TYPES);
1596
+ var VIEWER_TO_SHARED_SESSION_TYPES = ["p2p_ready", "p2p_offer", "p2p_answer", "p2p_ice"];
1597
+ var isViewerToSharedSessionType = makeTypeGuard(VIEWER_TO_SHARED_SESSION_TYPES);
1598
+ function decodeViewerToSharedSession(raw) {
1599
+ if (!isRecord(raw) || !isViewerToSharedSessionType(raw.type)) return null;
1600
+ const payload = isRecord(raw.payload) ? raw.payload : {};
1601
+ return { type: raw.type, payload, ...readEnvelopeFields(raw) };
1602
+ }
1603
+
1604
+ // src/protocol/dashboard-daemon-p2p.ts
1605
+ function isChunkType(value) {
1606
+ return typeof value === "string" && value.endsWith("_chunk") && value.length > "_chunk".length;
1607
+ }
1608
+ function readChunkFields(frame) {
1609
+ if (!isNonEmptyString(frame.chunkId)) return null;
1610
+ if (!Number.isInteger(frame.index) || !Number.isInteger(frame.total)) return null;
1611
+ if (typeof frame.data !== "string") return null;
1612
+ return {
1613
+ ...isNonEmptyString(frame.id) ? { id: frame.id } : {},
1614
+ chunkId: frame.chunkId,
1615
+ index: frame.index,
1616
+ total: frame.total,
1617
+ data: frame.data
1618
+ };
1619
+ }
1620
+ var DASHBOARD_TO_DAEMON_P2P_TYPES = [
1621
+ "ping",
1622
+ "pong",
1623
+ "command",
1624
+ "input",
1625
+ "pty_input",
1626
+ "pty_resize",
1627
+ "screenshot_start",
1628
+ "screenshot_stop",
1629
+ "subscribe",
1630
+ "unsubscribe",
1631
+ "seqscribe_session_interest",
1632
+ "read",
1633
+ "write",
1634
+ "list"
1635
+ ];
1636
+ var isDashboardToDaemonP2PType = makeTypeGuard(DASHBOARD_TO_DAEMON_P2P_TYPES);
1637
+ function isDashboardToDaemonChunkType(value) {
1638
+ return isChunkType(value) && isDashboardToDaemonP2PType(value.slice(0, -"_chunk".length));
1639
+ }
1640
+ var DASHBOARD_REQUEST_TYPES = /* @__PURE__ */ new Set(["command", "input", "read", "write", "list"]);
1641
+ function decodeDashboardToDaemonP2PChunk(raw) {
1642
+ if (!isRecord(raw) || !isDashboardToDaemonChunkType(raw.type)) return null;
1643
+ const fields = readChunkFields(raw);
1644
+ return fields ? { type: raw.type, ...fields } : null;
1645
+ }
1646
+ function decodeDashboardToDaemonP2P(raw) {
1647
+ if (!isRecord(raw) || !isDashboardToDaemonP2PType(raw.type)) return null;
1648
+ if (DASHBOARD_REQUEST_TYPES.has(raw.type) && !isNonEmptyString(raw.id)) return null;
1649
+ return raw;
1650
+ }
1651
+ var DAEMON_TO_DASHBOARD_P2P_TYPES = [
1652
+ "ping",
1653
+ "pong",
1654
+ "p2p_evicted",
1655
+ "status_report",
1656
+ "status_event",
1657
+ "topic_update",
1658
+ "topic_update_chunk",
1659
+ "session_output",
1660
+ "session_output_chunk",
1661
+ "session_io_error",
1662
+ "command_result",
1663
+ "command_result_chunk",
1664
+ "response"
1082
1665
  ];
1083
- function isDaemonToServerWsMsg(value) {
1084
- return typeof value === "string" && DAEMON_TO_SERVER_WS_MSGS.includes(value);
1666
+ var isDaemonToDashboardP2PType = makeTypeGuard(DAEMON_TO_DASHBOARD_P2P_TYPES);
1667
+ function decodeDaemonToDashboardP2P(raw) {
1668
+ if (!isRecord(raw)) return null;
1669
+ if (raw.type === void 0 && isNonEmptyString(raw.id) && typeof raw.success === "boolean") {
1670
+ return { ...raw, type: "response" };
1671
+ }
1672
+ if (!isDaemonToDashboardP2PType(raw.type)) return null;
1673
+ switch (raw.type) {
1674
+ case "ping":
1675
+ case "pong":
1676
+ case "p2p_evicted":
1677
+ return raw;
1678
+ case "status_report":
1679
+ case "status_event":
1680
+ return isRecord(raw.payload) ? raw : null;
1681
+ case "topic_update":
1682
+ return isRecord(raw.update) ? raw : null;
1683
+ case "topic_update_chunk":
1684
+ case "command_result_chunk":
1685
+ case "session_output_chunk": {
1686
+ const fields = readChunkFields(raw);
1687
+ if (!fields) return null;
1688
+ if (raw.type === "session_output_chunk") {
1689
+ return isNonEmptyString(raw.sessionId) ? { type: raw.type, sessionId: raw.sessionId, ...fields } : null;
1690
+ }
1691
+ return { type: raw.type, ...fields };
1692
+ }
1693
+ case "session_output":
1694
+ return isNonEmptyString(raw.sessionId) && typeof raw.data === "string" ? raw : null;
1695
+ case "session_io_error":
1696
+ return isNonEmptyString(raw.sessionId) ? raw : null;
1697
+ case "command_result":
1698
+ case "response":
1699
+ return isNonEmptyString(raw.id) ? raw : null;
1700
+ }
1085
1701
  }
1086
- function isServerToDaemonWsMsg(value) {
1087
- return typeof value === "string" && SERVER_TO_DAEMON_WS_MSGS.includes(value);
1702
+ var DASHBOARD_P2P_MESSAGE_KINDS = [
1703
+ .../* @__PURE__ */ new Set([...DASHBOARD_TO_DAEMON_P2P_TYPES, ...DAEMON_TO_DASHBOARD_P2P_TYPES])
1704
+ ];
1705
+
1706
+ // src/ws-protocol.ts
1707
+ var DAEMON_TO_SERVER_WS_MSGS = DAEMON_TO_SERVER_TYPES;
1708
+ var SERVER_TO_DAEMON_WS_MSGS = SERVER_TO_DAEMON_CONTROL_TYPES;
1709
+ var isDaemonToServerWsMsg = isDaemonToServerType;
1710
+ var isServerToDaemonWsMsg = isServerToDaemonControlType;
1711
+ function normalizeAuthOkLimits(raw) {
1712
+ if (!raw || typeof raw !== "object") return null;
1713
+ const src = raw;
1714
+ const num = (value, fallback) => typeof value === "number" && Number.isFinite(value) ? value : fallback;
1715
+ return {
1716
+ maxP2Pconnections: num(
1717
+ src.maxP2Pconnections !== void 0 ? src.maxP2Pconnections : src.maxP2PConnections,
1718
+ -1
1719
+ ),
1720
+ screenshotIntervalSeconds: num(src.screenshotIntervalSeconds, 0),
1721
+ dailyScreenshotMinutes: num(src.dailyScreenshotMinutes, -1),
1722
+ maxMachines: num(src.maxMachines, -1)
1723
+ };
1088
1724
  }
1089
1725
 
1090
1726
  // src/interactive-prompt-constants.ts
1091
1727
  var CLAUDE_TUI_REVIEW_PAGE_NOT_FOCUSED_PREFIX = "Claude TUI review page is not focused";
1092
1728
  var CLAUDE_TUI_REVIEW_UNCONFIRMED_PREFIX = "Claude TUI answer delivered but not confirmed";
1729
+
1730
+ // src/session-status.ts
1731
+ var SESSION_STATUSES = [
1732
+ "idle",
1733
+ "generating",
1734
+ "waiting_approval",
1735
+ "waiting_choice",
1736
+ "finalizing",
1737
+ "error",
1738
+ "stopped",
1739
+ "starting",
1740
+ "panel_hidden",
1741
+ "not_monitored",
1742
+ "disconnected"
1743
+ ];
1744
+ var RECENT_SESSION_BUCKETS = ["needs_attention", "working", "task_complete", "idle"];
1745
+ var SESSION_STATUS_CLASS = {
1746
+ generating: "working",
1747
+ finalizing: "working",
1748
+ starting: "working",
1749
+ waiting_approval: "blocked",
1750
+ waiting_choice: "blocked",
1751
+ idle: "ready",
1752
+ panel_hidden: "ready",
1753
+ not_monitored: "ready",
1754
+ error: "dead",
1755
+ stopped: "dead",
1756
+ disconnected: "dead"
1757
+ };
1758
+ var SESSION_STATUS_ALIASES = {
1759
+ running: "generating",
1760
+ streaming: "generating",
1761
+ busy: "generating",
1762
+ working: "generating",
1763
+ loading: "generating",
1764
+ loading_reference: "generating",
1765
+ thinking: "generating",
1766
+ active: "generating",
1767
+ // Status-lane refinements of a turn that is still owned by the agent.
1768
+ no_progress: "generating",
1769
+ long_generating: "generating",
1770
+ initializing: "starting",
1771
+ waiting: "waiting_approval"
1772
+ };
1773
+ var SESSION_STATUS_SET = new Set(SESSION_STATUSES);
1774
+ function isSessionStatus(value) {
1775
+ return typeof value === "string" && SESSION_STATUS_SET.has(value);
1776
+ }
1777
+ function normalizeSessionStatus(raw) {
1778
+ if (typeof raw !== "string") return null;
1779
+ const value = raw.trim().toLowerCase();
1780
+ if (SESSION_STATUS_SET.has(value)) return value;
1781
+ return SESSION_STATUS_ALIASES[value] ?? null;
1782
+ }
1783
+ function classifySessionStatus(raw) {
1784
+ const status = normalizeSessionStatus(raw);
1785
+ return status ? SESSION_STATUS_CLASS[status] : "unknown";
1786
+ }
1787
+ function isWorkingStatus(raw) {
1788
+ return classifySessionStatus(raw) === "working";
1789
+ }
1790
+ function isBlockedStatus(raw) {
1791
+ return classifySessionStatus(raw) === "blocked";
1792
+ }
1793
+ function isReadyStatus(raw) {
1794
+ return classifySessionStatus(raw) === "ready";
1795
+ }
1796
+ function isDeadStatus(raw) {
1797
+ return classifySessionStatus(raw) === "dead";
1798
+ }
1799
+ function isBusyStatus(raw) {
1800
+ const cls = classifySessionStatus(raw);
1801
+ return cls === "working" || cls === "blocked";
1802
+ }
1803
+ function statusesOfClass(cls) {
1804
+ return SESSION_STATUSES.filter((status) => SESSION_STATUS_CLASS[status] === cls);
1805
+ }
1806
+
1807
+ // src/mesh-vocabulary.ts
1808
+ var MESH_TASK_STATUSES = ["pending", "assigned", "completed", "failed", "cancelled"];
1809
+ var MESH_TERMINAL_TASK_STATUSES = ["completed", "failed", "cancelled"];
1810
+ var MESH_TASK_MODES = ["code_change", "validation", "live_debug_readonly", "launch_app", "convergence"];
1811
+ var MESH_TASK_PRIORITIES = ["low", "normal", "high"];
1812
+ var MESH_THINKING_LEVELS = ["low", "medium", "high"];
1813
+ var MESH_DELIVERY_MODES = ["when_idle", "interrupt"];
1814
+ var MESH_SESSION_CLEANUP_MODES = ["preserve", "stop", "delete_stopped", "stop_and_delete"];
1815
+ var WORKER_REPORT_OUTCOMES = ["completed", "blocked", "failed"];
1816
+ var WORKER_BRANCH_STATES = [
1817
+ "merged_to_main",
1818
+ "pushed_feature_branch_needs_merge",
1819
+ "blocked_review",
1820
+ "cleanup_candidate",
1821
+ "not_mergeable"
1822
+ ];
1823
+ function makeGuard(values) {
1824
+ const set = new Set(values);
1825
+ return (value) => typeof value === "string" && set.has(value);
1826
+ }
1827
+ var isMeshTaskStatus = makeGuard(MESH_TASK_STATUSES);
1828
+ var isMeshTerminalTaskStatus = makeGuard(MESH_TERMINAL_TASK_STATUSES);
1829
+ var isMeshTaskMode = makeGuard(MESH_TASK_MODES);
1830
+ var isMeshTaskPriority = makeGuard(MESH_TASK_PRIORITIES);
1831
+ var isMeshThinkingLevel = makeGuard(MESH_THINKING_LEVELS);
1832
+ var isMeshDeliveryMode = makeGuard(MESH_DELIVERY_MODES);
1833
+ var isMeshSessionCleanupMode = makeGuard(MESH_SESSION_CLEANUP_MODES);
1834
+ var isWorkerReportOutcome = makeGuard(WORKER_REPORT_OUTCOMES);
1835
+ var isWorkerBranchState = makeGuard(WORKER_BRANCH_STATES);
1836
+ function enumOf(values, description) {
1837
+ return {
1838
+ type: "string",
1839
+ enum: [...values],
1840
+ ...description ? { description } : {}
1841
+ };
1842
+ }
1843
+
1844
+ // src/outbound-message.ts
1845
+ var outboundMessageIdCounter = 0;
1846
+ function mintMessageId(now = Date.now()) {
1847
+ try {
1848
+ const cryptoRef = typeof globalThis !== "undefined" ? globalThis.crypto : void 0;
1849
+ if (typeof cryptoRef?.randomUUID === "function") return `msg_${cryptoRef.randomUUID()}`;
1850
+ } catch {
1851
+ }
1852
+ outboundMessageIdCounter += 1;
1853
+ return `msg_${now}_${outboundMessageIdCounter}`;
1854
+ }
1855
+ var MESSAGE_ID_PREFIX = "msg_";
1856
+ function isMessageId(value) {
1857
+ return typeof value === "string" && value.length > MESSAGE_ID_PREFIX.length && value.startsWith(MESSAGE_ID_PREFIX);
1858
+ }
1859
+ var OUTBOUND_MESSAGE_ORIGINS = ["dashboard", "mcp", "mesh", "api", "cli"];
1860
+ function isOutboundMessageOrigin(value) {
1861
+ return typeof value === "string" && OUTBOUND_MESSAGE_ORIGINS.includes(value);
1862
+ }
1863
+ var SEND_POLICY_MODES = ["queue", "send_now", "interrupt"];
1864
+ function isSendPolicyMode(value) {
1865
+ return typeof value === "string" && SEND_POLICY_MODES.includes(value);
1866
+ }
1867
+ function isSendPolicy(value) {
1868
+ return !!value && typeof value === "object" && isSendPolicyMode(value.mode);
1869
+ }
1870
+ var SEND_REFUSAL_REASONS = [
1871
+ "not_ready",
1872
+ "send_in_flight",
1873
+ "not_generating",
1874
+ "not_supported",
1875
+ "platform_unsupported",
1876
+ "modal_parked",
1877
+ "interrupt_not_implemented",
1878
+ "interrupt_refused",
1879
+ "idle_timeout",
1880
+ "session_exited",
1881
+ "unsupported_input",
1882
+ "no_target",
1883
+ "bootstrap_pending",
1884
+ "duplicate_dispatch",
1885
+ "internal_error"
1886
+ ];
1887
+ function isSendRefusal(value) {
1888
+ return typeof value === "string" && SEND_REFUSAL_REASONS.includes(value);
1889
+ }
1890
+ var SUBMIT_OUTCOME_KINDS = ["delivered", "queued", "duplicate", "refused"];
1891
+ function isSubmitOutcome(value) {
1892
+ if (!value || typeof value !== "object") return false;
1893
+ const kind = value.kind;
1894
+ if (typeof kind !== "string" || !SUBMIT_OUTCOME_KINDS.includes(kind)) return false;
1895
+ if (kind === "queued") return typeof value.position === "number";
1896
+ if (kind === "duplicate") return typeof value.of === "string";
1897
+ if (kind === "refused") return isSendRefusal(value.reason);
1898
+ return true;
1899
+ }
1900
+ function isInputPartWire(value) {
1901
+ if (!value || typeof value !== "object") return false;
1902
+ const type = value.type;
1903
+ return type === "text" || type === "image" || type === "audio" || type === "video" || type === "resource" || type === "resource_link";
1904
+ }
1905
+ function isInputEnvelopeWire(value) {
1906
+ if (!value || typeof value !== "object") return false;
1907
+ const parts = value.parts;
1908
+ const textFallback = value.textFallback;
1909
+ return Array.isArray(parts) && parts.every(isInputPartWire) && typeof textFallback === "string";
1910
+ }
1911
+ function isOutboundMessage(value) {
1912
+ if (!value || typeof value !== "object") return false;
1913
+ const candidate = value;
1914
+ return isMessageId(candidate.messageId) && typeof candidate.sessionId === "string" && candidate.sessionId.length > 0 && isInputEnvelopeWire(candidate.input) && isOutboundMessageOrigin(candidate.origin) && isSendPolicy(candidate.policy) && typeof candidate.createdAt === "number";
1915
+ }
1916
+
1917
+ // src/mission-brief.ts
1918
+ var GOAL_MAX = 500;
1919
+ var LIST_ITEM_MAX = 200;
1920
+ var LIST_MAX_ITEMS = 12;
1921
+ var MISSION_BRIEF_RENDER_MAX_CHARS = 1200;
1922
+ function truncateString(value, max) {
1923
+ if (value.length <= max) return value;
1924
+ return `${value.slice(0, max - 1).trimEnd()}\u2026`;
1925
+ }
1926
+ function normalizeStringList(value, field, truncated) {
1927
+ if (value === void 0 || value === null) return void 0;
1928
+ if (!Array.isArray(value)) return void 0;
1929
+ const items = [];
1930
+ let itemTruncated = false;
1931
+ for (const raw of value) {
1932
+ if (typeof raw !== "string") continue;
1933
+ const trimmed = raw.trim();
1934
+ if (!trimmed) continue;
1935
+ if (trimmed.length > LIST_ITEM_MAX) itemTruncated = true;
1936
+ items.push(truncateString(trimmed, LIST_ITEM_MAX));
1937
+ }
1938
+ if (itemTruncated) truncated.push({ field, reason: "item_too_long" });
1939
+ if (items.length > LIST_MAX_ITEMS) {
1940
+ truncated.push({ field, reason: "list_too_long" });
1941
+ return items.slice(0, LIST_MAX_ITEMS);
1942
+ }
1943
+ return items.length > 0 ? items : void 0;
1944
+ }
1945
+ function normalizeMissionBrief(input) {
1946
+ const truncated = [];
1947
+ if (!input || typeof input !== "object") {
1948
+ return { brief: null, truncated };
1949
+ }
1950
+ const raw = input;
1951
+ const rawGoal = typeof raw.goal === "string" ? raw.goal.trim() : "";
1952
+ if (!rawGoal) {
1953
+ return { brief: null, truncated };
1954
+ }
1955
+ if (rawGoal.length > GOAL_MAX) truncated.push({ field: "goal", reason: "field_too_long" });
1956
+ const goal = truncateString(rawGoal, GOAL_MAX);
1957
+ const constraints = normalizeStringList(raw.constraints, "constraints", truncated);
1958
+ const doneCriteria = normalizeStringList(raw.doneCriteria ?? raw.done_criteria, "doneCriteria", truncated);
1959
+ const handoffNotes = normalizeStringList(raw.handoffNotes ?? raw.handoff_notes, "handoffNotes", truncated);
1960
+ const ownedPaths = normalizeStringList(raw.ownedPaths ?? raw.owned_paths, "ownedPaths", truncated);
1961
+ const brief = { goal };
1962
+ if (constraints) brief.constraints = constraints;
1963
+ if (doneCriteria) brief.doneCriteria = doneCriteria;
1964
+ if (handoffNotes) brief.handoffNotes = handoffNotes;
1965
+ if (ownedPaths) brief.ownedPaths = ownedPaths;
1966
+ return { brief, truncated };
1967
+ }
1968
+ function renderList(heading, items) {
1969
+ if (!items || items.length === 0) return [];
1970
+ return [`${heading}:`, ...items.map((item) => `- ${item}`)];
1971
+ }
1972
+ function renderMissionBriefBlock(brief) {
1973
+ const sections = [`Mission goal: ${brief.goal}`];
1974
+ sections.push(...renderList("Constraints", brief.constraints));
1975
+ sections.push(...renderList("Done when", brief.doneCriteria));
1976
+ sections.push(...renderList("Owned paths", brief.ownedPaths));
1977
+ sections.push(...renderList("Handoff notes", brief.handoffNotes));
1978
+ const full = sections.join("\n");
1979
+ if (full.length <= MISSION_BRIEF_RENDER_MAX_CHARS) return full;
1980
+ const marker = "\n(brief truncated)";
1981
+ const budget = MISSION_BRIEF_RENDER_MAX_CHARS - marker.length;
1982
+ const lines = full.split("\n");
1983
+ let acc = "";
1984
+ for (const line of lines) {
1985
+ const next = acc ? `${acc}
1986
+ ${line}` : line;
1987
+ if (next.length > budget) break;
1988
+ acc = next;
1989
+ }
1990
+ if (!acc) acc = truncateString(lines[0] ?? "", Math.max(budget, 0));
1991
+ return `${acc}${marker}`;
1992
+ }
1993
+
1994
+ // src/worker-protocol.ts
1995
+ var WORKER_TOOLS = [
1996
+ "report_completion",
1997
+ "progress_update",
1998
+ "peer_context_pull",
1999
+ "git_status",
2000
+ "git_log",
2001
+ "git_diff"
2002
+ ];
2003
+ var WORKER_TOOL_SET = new Set(WORKER_TOOLS);
2004
+ function isWorkerTool(value) {
2005
+ return typeof value === "string" && WORKER_TOOL_SET.has(value);
2006
+ }
2007
+ var WORKER_PROTOCOL_FOOTER_MARKER = "--- adhdev worker protocol ---";
2008
+ function hasWorkerProtocolFooter(body) {
2009
+ return typeof body === "string" && body.includes(WORKER_PROTOCOL_FOOTER_MARKER);
2010
+ }
2011
+ function renderWorkerProtocolFooter(input = {}) {
2012
+ const briefBlock = input.missionBrief ? renderMissionBriefBlock(input.missionBrief) : null;
2013
+ const lines = briefBlock ? [briefBlock, "", WORKER_PROTOCOL_FOOTER_MARKER] : [WORKER_PROTOCOL_FOOTER_MARKER];
2014
+ const scope = [];
2015
+ if (input.taskId) scope.push(`task ${input.taskId}`);
2016
+ if (input.taskMode) scope.push(`mode ${input.taskMode}`);
2017
+ if (input.difficulty) {
2018
+ if (isMeshTaskDifficulty(input.difficulty)) {
2019
+ scope.push(`difficulty ${input.difficulty}`);
2020
+ } else {
2021
+ console.warn(
2022
+ `[worker-protocol] task ${input.taskId ?? "(unknown)"}: dropping invalid difficulty '${input.difficulty}' from the worker footer (expected one of easy, medium, difficult, freeform)`
2023
+ );
2024
+ }
2025
+ }
2026
+ if (input.readonly) scope.push("read-only");
2027
+ if (scope.length) lines.push(`You are a delegated worker (${scope.join(", ")}).`);
2028
+ else lines.push("You are a delegated worker.");
2029
+ lines.push(
2030
+ "When your work is finished, blocked, or has failed, call `report_completion` exactly once. Its `summary` is recorded verbatim as the authoritative record of this task \u2014 your terminal is not scraped for it \u2014 so state what you did, what you found, and where you left the branch.",
2031
+ "For work that runs longer than a few minutes, call `progress_update` at natural checkpoints so the coordinator can see you are alive without polling.",
2032
+ "`peer_context_pull` shows what sibling tasks in this mission have reported; `git_status` / `git_diff` / `git_log` inspect your own workspace \u2014 all three REQUIRE the absolute path to it as `workspace`.",
2033
+ "You have no coordinator tools (no `mesh_*`) by design: do not enqueue, dispatch, or restart anything. If you need a decision from the coordinator, finish with `report_completion` and outcome `blocked`, listing what you need in `blockers`.",
2034
+ "On a code-changing task, `report_completion` with outcome `completed` requires `touched_files` \u2014 send `[]` if you changed nothing, omitting the field is what gets refused. `blocked`/`failed` never need it, and a read-only task should omit it or send `[]`.",
2035
+ "If `report_completion` is refused, the response carries `validationErrors` (or a `hint`) naming exactly what to fix \u2014 correct that field and call it again; a refusal records nothing."
2036
+ );
2037
+ if (input.enclosedHandoffNotes && input.enclosedHandoffNotes > 0) {
2038
+ lines.push(
2039
+ `The ${input.enclosedHandoffNotes} handoff note(s) above were written by agents who touched this code before you; honour their conflict guidance and add your own in \`handoff_notes\` when you report.`
2040
+ );
2041
+ }
2042
+ return lines.join("\n");
2043
+ }
2044
+ function stripWorkerProtocolFooter(body) {
2045
+ if (typeof body !== "string") return body;
2046
+ const at = body.indexOf(WORKER_PROTOCOL_FOOTER_MARKER);
2047
+ if (at < 0) return body;
2048
+ return body.slice(0, at).replace(/\s+$/, "");
2049
+ }
2050
+ function appendWorkerProtocolFooter(body, input = {}) {
2051
+ if (hasWorkerProtocolFooter(body)) return body;
2052
+ const trimmed = body.replace(/\s+$/, "");
2053
+ return `${trimmed}
2054
+
2055
+ ${renderWorkerProtocolFooter(input)}`;
2056
+ }
2057
+ function renderCoordinatorWorkerSection() {
2058
+ return [
2059
+ "## Workers",
2060
+ "",
2061
+ `Every task you dispatch is delivered with a worker protocol footer. Workers hold exactly these tools: ${WORKER_TOOLS.map((tool) => `\`${tool}\``).join(", ")} \u2014 and no \`mesh_*\` tools.`,
2062
+ "- A worker finishes by calling `report_completion`; its structured report (outcome, summary, touched files, branch state, handoff notes) is what reaches you as the completion event. Read that report \u2014 do not re-derive the outcome from `mesh_read_chat` or the terminal unless the report is missing.",
2063
+ "- `progress_update` from a worker arrives as a lightweight progress note. Do NOT poll `mesh_status`, `mesh_view_queue` or `mesh_read_chat` to check on a running worker; completion, progress, blocked and failure all arrive as events.",
2064
+ "- To reach a busy worker mid-task use `mesh_notify_worker`: the memo is delivered on the worker's next tool call (or when it becomes idle). A worker that reports `blocked` is asking you for a decision \u2014 answer it with `mesh_send_task` to the same session.",
2065
+ "- `mesh_status` is for node health and capacity before delegating, never for progress.",
2066
+ "- A `code_change` task's declared `owned_paths` (H1) is enforced at claim time: a second `code_change` task whose `owned_paths` overlaps an already-claimed task's is refused rather than silently racing it. A worker's `report_completion.touched_files` is compared against its own task's declaration afterward and any mismatch is surfaced back to you as evidence \u2014 it is never a validation failure, since a worker often cannot know its exact final file list at enqueue time."
2067
+ ].join("\n");
2068
+ }
2069
+
2070
+ // src/turn-evidence.ts
2071
+ var MESH_TOPIC_PROTOCOL_VERSION = 2;
2072
+ var EVIDENCE_SOURCE_IDS = [
2073
+ "fsm_edge",
2074
+ "short_gen_inline",
2075
+ "completion_flush_genuine",
2076
+ "completion_flush_weak",
2077
+ "monitor_final_summary",
2078
+ "pre_cleanup_transcript",
2079
+ "stall_transcript",
2080
+ "startup_grace_collapse",
2081
+ "acp_prompt_response",
2082
+ "cdp_state",
2083
+ "approval_gate",
2084
+ "modal_button",
2085
+ "mesh_stall_watchdog",
2086
+ "status_monitor",
2087
+ "pty_exit",
2088
+ "provider_error",
2089
+ "coordinator_probe",
2090
+ "mcp_probe",
2091
+ "worker_tool",
2092
+ "dispatch",
2093
+ "input_service",
2094
+ "operator",
2095
+ "intentional_cleanup",
2096
+ "scheduler",
2097
+ "git_probe",
2098
+ "session_registry"
2099
+ ];
2100
+ var TURN_SCOPES = ["mesh_queue", "mesh_direct", "plain"];
2101
+ var RECLAIMING_SEND_REFUSALS = ["session_exited", "no_target", "unsupported_input"];
2102
+ var DELIVERY_OUTCOMES = ["delivered", "queued"];
2103
+ var DELIVERY_VIAS = ["local", "p2p"];
2104
+ var DISPATCH_FAILURE_REASONS = ["worker_absent", "transport_error", "spawn_failed", "rejected_by_worker", "timeout"];
2105
+ function sanitizeRefusalCode(value) {
2106
+ if (typeof value !== "string") return void 0;
2107
+ const normalized = value.trim().toLowerCase().replace(/[^a-z_]/g, "_").replace(/_+/g, "_").replace(/^_+|_+$/g, "");
2108
+ if (!normalized) return void 0;
2109
+ return normalized.slice(0, 64);
2110
+ }
2111
+ var CONSUME_PROFILES = ["default", "native_source"];
2112
+ var SESSION_REBOUND_REASONS = ["restart", "live_holder"];
2113
+ var SUSPENSION_MODALS = ["approval", "choice"];
2114
+ var SUSPENSION_RESOLUTIONS = ["approved", "rejected", "answered"];
2115
+ var SUSPENSION_RESOLUTION_VIAS = ["modal_button", "auto_approve", "prompt_answer"];
2116
+ var TURN_END_STRENGTHS = ["genuine", "weak"];
2117
+ var TURN_END_BLOCK_REASONS = [
2118
+ "missing_final_assistant",
2119
+ "finalization_timeout",
2120
+ "terminal_block_hard_cap",
2121
+ "decoupled_completion"
2122
+ ];
2123
+ var NATIVE_TURN_OUTCOMES = ["completed", "aborted"];
2124
+ var LIVENESS_RESULTS = ["alive", "unknown", "read_failed", "dead"];
2125
+ var PROVIDER_FAILURES = ["auth_failed", "billing_failed"];
2126
+ var SESSION_ERROR_REASONS = ["provider_error", "adapter_error", "spawn_failed", "auth_failed", "billing_failed", "unknown", "daemon_restart"];
2127
+ var CANCEL_REASONS = ["operator_cancel", "intentional_cleanup", "task_removed", "mission_abandoned", "superseded"];
2128
+ var OPERATOR_STATUSES = ["completed", "failed"];
2129
+ var OPERATOR_STATUS_REASONS = ["operator_update", "refine_terminal", "validation_terminal"];
2130
+ var COORDINATOR_ACK_OUTCOMES = ["delivered", "queued", "duplicate"];
2131
+ var NO_PROGRESS_OBSERVED_STATUSES = [...SESSION_STATUSES, "unknown"];
2132
+ var HOLD_REASONS = [
2133
+ "await_delivery",
2134
+ "await_consume",
2135
+ "await_turn",
2136
+ "liveness",
2137
+ "hard_ceiling",
2138
+ "live_pending",
2139
+ "transcript_quiet",
2140
+ "weak_candidate",
2141
+ "suspension_before_consumed",
2142
+ // A genuine FSM end of a mesh turn whose worker holds a live worker-MCP bind:
2143
+ // the structured report is the primary evidence (design §F2), so the idle edge
2144
+ // only opens this hold (R9r) — a report commits (R17), a new busy edge cancels
2145
+ // it as a false idle (R12r), expiry commits weak (R13r).
2146
+ "await_report",
2147
+ // A worker report recorded while the session is still generating (R17g):
2148
+ // the report is the verdict, the idle edge is only awaited as corroboration
2149
+ // — a turn_end commits the report (R9t), expiry commits it anyway (R13t) so
2150
+ // a session whose FSM never shows the idle edge again does not wait for
2151
+ // liveness / hard_ceiling.
2152
+ "await_end"
2153
+ ];
2154
+ var TURN_OUTCOMES = ["completed", "failed", "cancelled"];
2155
+ var COMMIT_STRENGTHS = ["genuine", "weak", "tool_report", "operator"];
2156
+ var TURN_REASONS = [
2157
+ // commits
2158
+ "turn_end",
2159
+ "weak_end_confirmed",
2160
+ "transcript_final",
2161
+ "worker_reported",
2162
+ "finalization_timeout_no_response",
2163
+ "session_error",
2164
+ "provider_auth_failed",
2165
+ "provider_billing_failed",
2166
+ "operator_cancel",
2167
+ "intentional_cleanup",
2168
+ "task_removed",
2169
+ "mission_abandoned",
2170
+ "superseded",
2171
+ "operator_update",
2172
+ "refine_terminal",
2173
+ "validation_terminal",
2174
+ "hard_ceiling",
2175
+ "reclaim_budget_exhausted",
2176
+ "hollow_max_retries",
2177
+ "migration_orphan",
2178
+ // reclaims (generation + 1)
2179
+ "dispatch_refused_session_exited",
2180
+ "dispatch_refused_no_target",
2181
+ "dispatch_refused_unsupported_input",
2182
+ "dispatch_failed",
2183
+ "session_exit",
2184
+ "session_exit_before_turn",
2185
+ "session_dead",
2186
+ "hollow_completion",
2187
+ "assigned_stranded_dispatch_unconfirmed",
2188
+ "delivered_not_consumed_redrive",
2189
+ "delivered_no_turn_deadline"
2190
+ ];
2191
+ var NOTIFY_KINDS = [
2192
+ "completed",
2193
+ "failed",
2194
+ "cancelled",
2195
+ "stopped",
2196
+ "approval",
2197
+ "choice",
2198
+ "approval_resolved",
2199
+ "candidate",
2200
+ "no_progress",
2201
+ "progress",
2202
+ "late_completion",
2203
+ "mesh_event"
2204
+ ];
2205
+ var id = { t: "id" };
2206
+ var idOpt = { t: "id", optional: true };
2207
+ var bool = { t: "bool" };
2208
+ var boolOpt = { t: "bool", optional: true };
2209
+ var ms = { t: "ms" };
2210
+ var msOpt = { t: "ms", optional: true };
2211
+ var intOpt = { t: "int", optional: true };
2212
+ var en = (values) => ({ t: "enum", values });
2213
+ var enOpt = (values) => ({ t: "enum", values, optional: true });
2214
+ var EVIDENCE_ENVELOPE_FIELD_SPECS = {
2215
+ eventId: id,
2216
+ at: ms,
2217
+ source: en(EVIDENCE_SOURCE_IDS),
2218
+ sessionId: id,
2219
+ attemptRef: { t: "attempt_ref", optional: true },
2220
+ taskId: idOpt,
2221
+ observedBy: id
2222
+ };
2223
+ var TURN_EVIDENCE_FIELD_SPECS = {
2224
+ dispatch_accepted: {
2225
+ scope: en(TURN_SCOPES),
2226
+ messageId: id,
2227
+ meshId: idOpt,
2228
+ nodeId: idOpt,
2229
+ providerType: idOpt,
2230
+ attemptNo: intOpt,
2231
+ dispatchNonce: intOpt,
2232
+ consumeProfile: enOpt(CONSUME_PROFILES),
2233
+ maxTaskRetries: intOpt,
2234
+ coordinator: { t: "coordinator", optional: true }
2235
+ },
2236
+ delivered: { messageId: id, outcome: en(DELIVERY_OUTCOMES), via: en(DELIVERY_VIAS) },
2237
+ delivery_refused: { messageId: id, reason: en(SEND_REFUSAL_REASONS) },
2238
+ dispatch_failed: { workerAbsent: bool, reason: en(DISPATCH_FAILURE_REASONS), refusalCode: idOpt },
2239
+ duplicate_dispatch_refusal: { holderSessionId: id, holderAttemptId: idOpt },
2240
+ session_rebound: { toSessionId: id, reason: en(SESSION_REBOUND_REASONS) },
2241
+ turn_started: { retro: bool },
2242
+ suspension: { modal: en(SUSPENSION_MODALS), modalKey: idOpt },
2243
+ suspension_resolved: { resolution: en(SUSPENSION_RESOLUTIONS), via: en(SUSPENSION_RESOLUTION_VIAS) },
2244
+ turn_end: {
2245
+ strength: en(TURN_END_STRENGTHS),
2246
+ afterFinalizationTimeout: boolOpt,
2247
+ hollow: boolOpt,
2248
+ summary: { t: "summary_ref", optional: true },
2249
+ blockReason: enOpt(TURN_END_BLOCK_REASONS),
2250
+ releasedByHardCap: boolOpt,
2251
+ nativeOutcome: enOpt(NATIVE_TURN_OUTCOMES),
2252
+ live: { t: "live", optional: true },
2253
+ reportExpected: boolOpt
2254
+ },
2255
+ transcript_final: {
2256
+ selfAttributing: bool,
2257
+ nativeRead: bool,
2258
+ nativeMarker: { t: "native_marker", optional: true },
2259
+ live: { t: "live" },
2260
+ summary: { t: "summary_ref", optional: true },
2261
+ messageAt: msOpt
2262
+ },
2263
+ transcript_activity: { newestActivityAt: ms },
2264
+ no_progress: { stalledMs: ms, observedStatus: en(NO_PROGRESS_OBSERVED_STATUSES), finalAssistantPresent: bool },
2265
+ liveness: { result: en(LIVENESS_RESULTS) },
2266
+ process_exit: { exitCode: { t: "int", nullable: true }, providerFailure: enOpt(PROVIDER_FAILURES) },
2267
+ session_error: { reason: en(SESSION_ERROR_REASONS) },
2268
+ worker_report: {
2269
+ outcome: en(WORKER_REPORT_OUTCOMES),
2270
+ summary: { t: "summary_ref", optional: true },
2271
+ hasHandoffNotes: bool,
2272
+ branchState: enOpt(WORKER_BRANCH_STATES),
2273
+ touchedFileCount: intOpt
2274
+ },
2275
+ worker_progress: { note: { t: "summary_ref", optional: true } },
2276
+ git_side_effect: { dirty: bool, commitsSinceDispatch: { t: "int" }, attributable: bool },
2277
+ cancel: { reason: en(CANCEL_REASONS) },
2278
+ operator_status: { status: en(OPERATOR_STATUSES), reason: en(OPERATOR_STATUS_REASONS) },
2279
+ coordinator_ack: { notify: en(NOTIFY_KINDS), outcome: en(COORDINATOR_ACK_OUTCOMES) },
2280
+ hold_expired: { holdId: id, reason: en(HOLD_REASONS) }
2281
+ };
2282
+ var TURN_EVIDENCE_KINDS = Object.keys(TURN_EVIDENCE_FIELD_SPECS);
2283
+ var TERMINAL_CLASS_EVIDENCE_KINDS = [
2284
+ "turn_end",
2285
+ "transcript_final",
2286
+ "no_progress",
2287
+ "worker_report",
2288
+ "session_error",
2289
+ "process_exit",
2290
+ "cancel",
2291
+ "operator_status"
2292
+ ];
2293
+ var IDENTIFIER_RE = /^[^\s\u0000-\u001f\u007f]{1,256}$/;
2294
+ function makeGuard2(values) {
2295
+ const set = new Set(values);
2296
+ return (value) => typeof value === "string" && set.has(value);
2297
+ }
2298
+ var isEvidenceSourceId = makeGuard2(EVIDENCE_SOURCE_IDS);
2299
+ var isTurnEvidenceKind = makeGuard2(TURN_EVIDENCE_KINDS);
2300
+ var isTurnReason = makeGuard2(TURN_REASONS);
2301
+ var isNotifyKind = makeGuard2(NOTIFY_KINDS);
2302
+ var isHoldReason = makeGuard2(HOLD_REASONS);
2303
+ var isTurnOutcome = makeGuard2(TURN_OUTCOMES);
2304
+ var isCommitStrength = makeGuard2(COMMIT_STRENGTHS);
2305
+ function isRecord2(value) {
2306
+ return typeof value === "object" && value !== null && !Array.isArray(value);
2307
+ }
2308
+ function isEvidenceIdentifier(value) {
2309
+ return typeof value === "string" && IDENTIFIER_RE.test(value);
2310
+ }
2311
+ function isFiniteNumber2(value) {
2312
+ return typeof value === "number" && Number.isFinite(value);
2313
+ }
2314
+ function isSummaryRef(value) {
2315
+ return isRecord2(value) && hasOnlyKeys(value, ["topic", "writer", "seq"]) && isEvidenceIdentifier(value.topic) && isEvidenceIdentifier(value.writer) && Number.isSafeInteger(value.seq) && value.seq >= 0;
2316
+ }
2317
+ function isTurnAttemptRef(value) {
2318
+ return isRecord2(value) && hasOnlyKeys(value, ["attemptId", "generation"]) && isEvidenceIdentifier(value.attemptId) && Number.isSafeInteger(value.generation) && value.generation >= 0;
2319
+ }
2320
+ function isLiveTurnPending(value) {
2321
+ return isRecord2(value) && hasOnlyKeys(value, ["modal", "adapterPending", "trailingTool", "newestActivityAt"]) && typeof value.modal === "boolean" && typeof value.adapterPending === "boolean" && typeof value.trailingTool === "boolean" && (value.newestActivityAt === void 0 || isFiniteNumber2(value.newestActivityAt));
2322
+ }
2323
+ function isNativeMarkerRef(value) {
2324
+ return isRecord2(value) && hasOnlyKeys(value, ["outcome", "turnId"]) && NATIVE_TURN_OUTCOMES.includes(value.outcome) && (value.turnId === void 0 || isEvidenceIdentifier(value.turnId));
2325
+ }
2326
+ function isCoordinatorIdentity(value) {
2327
+ return isRecord2(value) && hasOnlyKeys(value, ["daemonId", "coordinatorRunId", "sessionId"]) && isEvidenceIdentifier(value.daemonId) && isEvidenceIdentifier(value.coordinatorRunId) && (value.sessionId === void 0 || isEvidenceIdentifier(value.sessionId));
2328
+ }
2329
+ function hasOnlyKeys(value, allowed) {
2330
+ for (const key of Object.keys(value)) {
2331
+ if (!allowed.includes(key)) return false;
2332
+ }
2333
+ return true;
2334
+ }
2335
+ function fieldMatches(spec, value) {
2336
+ if (value === void 0) return spec.optional === true;
2337
+ switch (spec.t) {
2338
+ case "id":
2339
+ return isEvidenceIdentifier(value);
2340
+ case "enum":
2341
+ return typeof value === "string" && spec.values.includes(value);
2342
+ case "bool":
2343
+ return typeof value === "boolean";
2344
+ case "int":
2345
+ return value === null && spec.nullable === true || Number.isSafeInteger(value);
2346
+ case "ms":
2347
+ return isFiniteNumber2(value) && value >= 0;
2348
+ case "summary_ref":
2349
+ return isSummaryRef(value);
2350
+ case "attempt_ref":
2351
+ return isTurnAttemptRef(value);
2352
+ case "live":
2353
+ return isLiveTurnPending(value);
2354
+ case "native_marker":
2355
+ return isNativeMarkerRef(value);
2356
+ case "coordinator":
2357
+ return isCoordinatorIdentity(value);
2358
+ }
2359
+ }
2360
+ function isTurnEvidence(value) {
2361
+ if (!isRecord2(value) || !isTurnEvidenceKind(value.kind)) return false;
2362
+ const bodySpecs = TURN_EVIDENCE_FIELD_SPECS[value.kind];
2363
+ const envelopeSpecs = EVIDENCE_ENVELOPE_FIELD_SPECS;
2364
+ for (const key of Object.keys(value)) {
2365
+ if (key === "kind") continue;
2366
+ if (!(key in bodySpecs) && !(key in envelopeSpecs)) return false;
2367
+ }
2368
+ for (const [key, spec] of Object.entries(envelopeSpecs)) {
2369
+ if (!fieldMatches(spec, value[key])) return false;
2370
+ }
2371
+ for (const [key, spec] of Object.entries(bodySpecs)) {
2372
+ if (!fieldMatches(spec, value[key])) return false;
2373
+ }
2374
+ return true;
2375
+ }
2376
+ function isTerminalClassEvidenceKind(kind) {
2377
+ return TERMINAL_CLASS_EVIDENCE_KINDS.includes(kind);
2378
+ }
2379
+ var TURN_EVIDENCE_FLAGS = ["hollow", "afterFinalizationTimeout", "nativeMarker", "selfAttributing"];
2380
+ var MESH_TOPIC_ENTRY_KINDS = ["turn.evidence", "turn.committed", "turn.notify", "mesh.record"];
2381
+ var isMeshTopicEntryKind = makeGuard2(MESH_TOPIC_ENTRY_KINDS);
2382
+ function isOptionalId(value) {
2383
+ return value === void 0 || isEvidenceIdentifier(value);
2384
+ }
2385
+ function isGeneration(value) {
2386
+ return Number.isSafeInteger(value) && value >= 0;
2387
+ }
2388
+ function isProjectedScalars(value) {
2389
+ if (!isRecord2(value)) return false;
2390
+ for (const v of Object.values(value)) {
2391
+ if (!(v === null || typeof v === "number" || typeof v === "boolean" || typeof v === "string")) return false;
2392
+ }
2393
+ return true;
2394
+ }
2395
+ function isMeshTopicEntry(value) {
2396
+ if (!isRecord2(value)) return false;
2397
+ if (value.v !== MESH_TOPIC_PROTOCOL_VERSION || !isEvidenceIdentifier(value.eventId) || !isFiniteNumber2(value.at)) return false;
2398
+ switch (value.k) {
2399
+ case "turn.evidence": {
2400
+ if (!isEvidenceIdentifier(value.attemptId) || !isGeneration(value.generation)) return false;
2401
+ if (!isEvidenceIdentifier(value.ownerDaemonId) || !isEvidenceIdentifier(value.sessionId) || !isOptionalId(value.taskId)) return false;
2402
+ if (!isTurnEvidenceKind(value.ev)) return false;
2403
+ if (value.strength !== void 0 && !TURN_END_STRENGTHS.includes(value.strength)) return false;
2404
+ if (value.flags !== void 0) {
2405
+ if (!isRecord2(value.flags)) return false;
2406
+ for (const [flag, on] of Object.entries(value.flags)) {
2407
+ if (!TURN_EVIDENCE_FLAGS.includes(flag) || typeof on !== "boolean") return false;
2408
+ }
2409
+ }
2410
+ if (value.evidence !== void 0 && !(isTurnEvidence(value.evidence) && value.evidence.kind === value.ev)) return false;
2411
+ return true;
2412
+ }
2413
+ case "turn.committed":
2414
+ return isEvidenceIdentifier(value.attemptId) && isGeneration(value.generation) && isOptionalId(value.taskId) && isTurnOutcome(value.outcome) && isCommitStrength(value.strength) && isTurnReason(value.reason);
2415
+ case "turn.notify":
2416
+ return isOptionalId(value.attemptId) && isNotifyKind(value.notify) && isEvidenceIdentifier(value.targetDaemonId) && isOptionalId(value.targetSessionId) && isOptionalId(value.taskId);
2417
+ case "mesh.record":
2418
+ return isEvidenceIdentifier(value.ledgerKind) && isOptionalId(value.nodeId) && isOptionalId(value.sessionId) && isOptionalId(value.taskId) && isProjectedScalars(value.payload);
2419
+ default:
2420
+ return false;
2421
+ }
2422
+ }
2423
+ function projectTurnEvidenceEntry(evidence, attempt) {
2424
+ const flags = {};
2425
+ if (evidence.kind === "turn_end") {
2426
+ if (evidence.hollow) flags.hollow = true;
2427
+ if (evidence.afterFinalizationTimeout) flags.afterFinalizationTimeout = true;
2428
+ }
2429
+ if (evidence.kind === "transcript_final") {
2430
+ if (evidence.nativeMarker) flags.nativeMarker = true;
2431
+ if (evidence.selfAttributing) flags.selfAttributing = true;
2432
+ }
2433
+ const taskId = evidence.taskId;
2434
+ return {
2435
+ v: MESH_TOPIC_PROTOCOL_VERSION,
2436
+ eventId: evidence.eventId,
2437
+ at: evidence.at,
2438
+ k: "turn.evidence",
2439
+ attemptId: attempt.attemptId,
2440
+ generation: attempt.generation,
2441
+ ownerDaemonId: attempt.ownerDaemonId,
2442
+ ...taskId ? { taskId } : {},
2443
+ sessionId: evidence.sessionId,
2444
+ ev: evidence.kind,
2445
+ ...evidence.kind === "turn_end" ? { strength: evidence.strength } : {},
2446
+ ...Object.keys(flags).length > 0 ? { flags } : {},
2447
+ evidence
2448
+ };
2449
+ }
2450
+
2451
+ // src/session-launch.ts
2452
+ var MODEL_AXIS_SOURCES = [
2453
+ /** Picked explicitly for this launch (dashboard dropdown, coordinator dialog). */
2454
+ "user",
2455
+ /** The dashboard dialog restored it from the last launch (browser-local memory). */
2456
+ "remembered",
2457
+ /** A mesh capability slot supplied it (or a difficulty preset the slot outranked). */
2458
+ "mesh_slot",
2459
+ /** An explicit per-task model / thinking level on a mesh queue task. */
2460
+ "task_override",
2461
+ /** Nothing was requested; the provider's default is known (discovery / manifest). */
2462
+ "provider_default",
2463
+ /** A value was requested without saying where it came from, or nothing is known. */
2464
+ "unspecified"
2465
+ ];
2466
+ function isModelAxisSource(value) {
2467
+ return typeof value === "string" && MODEL_AXIS_SOURCES.includes(value);
2468
+ }
2469
+ var SESSION_LAUNCHED_BY = ["dashboard", "mesh", "cli", "api", "restore"];
2470
+ function isSessionLaunchedBy(value) {
2471
+ return typeof value === "string" && SESSION_LAUNCHED_BY.includes(value);
2472
+ }
2473
+ var MODEL_SELECTION_HISTORY_LIMIT = 20;
2474
+ function effectiveModelSelectionValue(selection) {
2475
+ if (!selection) return void 0;
2476
+ const last = Array.isArray(selection.history) ? selection.history[selection.history.length - 1] : void 0;
2477
+ return last?.value ?? selection.current ?? selection.observed ?? launchModelSelectionValue(selection);
2478
+ }
2479
+ function launchModelSelectionValue(selection) {
2480
+ if (!selection) return void 0;
2481
+ const launch = Array.isArray(selection.history) ? selection.history.find((entry) => entry.via === "launch") : void 0;
2482
+ return launch?.value ?? selection.launchValue ?? selection.requested ?? selection.resolvedDefault;
2483
+ }
2484
+ function describeModelSelection(selection) {
2485
+ const value = effectiveModelSelectionValue(selection);
2486
+ if (!selection || !value) return void 0;
2487
+ const launched = launchModelSelectionValue(selection);
2488
+ return {
2489
+ value,
2490
+ ...launched && launched !== value ? { changedFrom: launched } : {},
2491
+ source: isModelAxisSource(selection.source) ? selection.source : "unspecified"
2492
+ };
2493
+ }
2494
+ var MODEL_IDENTIFIER_PATTERN = /^[A-Za-z0-9][A-Za-z0-9._:/@[\]+-]{0,95}$/;
2495
+ function sanitizeModelIdentifier(value) {
2496
+ if (typeof value !== "string") return void 0;
2497
+ const trimmed = value.trim();
2498
+ return MODEL_IDENTIFIER_PATTERN.test(trimmed) ? trimmed : void 0;
2499
+ }
2500
+ function readString2(value) {
2501
+ return typeof value === "string" && value.trim() ? value.trim() : void 0;
2502
+ }
2503
+ function readFiniteNumber(value) {
2504
+ return typeof value === "number" && Number.isFinite(value) ? value : void 0;
2505
+ }
2506
+ function parseModelSelection(raw) {
2507
+ if (!raw || typeof raw !== "object") return void 0;
2508
+ const record = raw;
2509
+ const history = [];
2510
+ if (Array.isArray(record.history)) {
2511
+ for (const entry of record.history) {
2512
+ if (!entry || typeof entry !== "object") continue;
2513
+ const e = entry;
2514
+ const value = readString2(e.value);
2515
+ const at = readFiniteNumber(e.at);
2516
+ const via = e.via === "launch" || e.via === "change_model" || e.via === "observed" ? e.via : void 0;
2517
+ if (value && at !== void 0 && via) history.push({ at, value, via });
2518
+ }
2519
+ }
2520
+ const requested = readString2(record.requested);
2521
+ const launchValue = readString2(record.launchValue);
2522
+ const resolvedDefault = readString2(record.resolvedDefault);
2523
+ const current = readString2(record.current);
2524
+ const observed = readString2(record.observed);
2525
+ const observedAt = readFiniteNumber(record.observedAt);
2526
+ return {
2527
+ source: isModelAxisSource(record.source) ? record.source : "unspecified",
2528
+ ...requested ? { requested } : {},
2529
+ ...launchValue ? { launchValue } : {},
2530
+ ...resolvedDefault ? { resolvedDefault } : {},
2531
+ ...current ? { current } : {},
2532
+ ...observed ? { observed } : {},
2533
+ ...observedAt !== void 0 ? { observedAt } : {},
2534
+ history: history.slice(-MODEL_SELECTION_HISTORY_LIMIT)
2535
+ };
2536
+ }
2537
+ function parseSessionLaunchRecord(raw) {
2538
+ if (!raw || typeof raw !== "object") return void 0;
2539
+ const record = raw;
2540
+ const sessionId = readString2(record.sessionId);
2541
+ const providerType = readString2(record.providerType);
2542
+ const launchedAt = readFiniteNumber(record.launchedAt);
2543
+ const model = parseModelSelection(record.model);
2544
+ const thinkingLevel = parseModelSelection(record.thinkingLevel);
2545
+ if (!sessionId || !providerType || launchedAt === void 0 || !model || !thinkingLevel) return void 0;
2546
+ const providerVersion = readString2(record.providerVersion);
2547
+ const workspace = readString2(record.workspace);
2548
+ const autoApproveModeId = readString2(record.autoApproveModeId);
2549
+ return {
2550
+ sessionId,
2551
+ providerType,
2552
+ ...providerVersion ? { providerVersion } : {},
2553
+ ...record.providerChannel === "stable" || record.providerChannel === "preview" ? { providerChannel: record.providerChannel } : {},
2554
+ launchedBy: isSessionLaunchedBy(record.launchedBy) ? record.launchedBy : "api",
2555
+ launchedAt,
2556
+ ...workspace ? { workspace } : {},
2557
+ model,
2558
+ thinkingLevel,
2559
+ ...autoApproveModeId ? { autoApproveModeId } : {}
2560
+ };
2561
+ }
2562
+
2563
+ // src/turn-ipc.ts
2564
+ var TURN_IPC_PROTOCOL_VERSION = 1;
2565
+ function isFiniteNumber3(value) {
2566
+ return typeof value === "number" && Number.isFinite(value);
2567
+ }
2568
+ function isNonNegativeInt(value) {
2569
+ return Number.isSafeInteger(value) && value >= 0;
2570
+ }
2571
+ function isOptionalId2(value) {
2572
+ return value === void 0 || isEvidenceIdentifier(value);
2573
+ }
2574
+ function hasOnlyKeys2(value, allowed) {
2575
+ for (const key of Object.keys(value)) {
2576
+ if (!allowed.includes(key)) return false;
2577
+ }
2578
+ return true;
2579
+ }
2580
+ var TURN_IPC_ERROR_CODES = ["daemon_required", "turn_ledger_unavailable", "ledger_not_owner"];
2581
+ function makeGuard3(values) {
2582
+ const set = new Set(values);
2583
+ return (value) => typeof value === "string" && set.has(value);
2584
+ }
2585
+ var isTurnIpcErrorCode = makeGuard3(TURN_IPC_ERROR_CODES);
2586
+ function isTurnIpcError(value) {
2587
+ return isRecord(value) && hasOnlyKeys2(value, ["code", "detail"]) && isTurnIpcErrorCode(value.code) && (value.detail === void 0 || typeof value.detail === "string");
2588
+ }
2589
+ var TURN_OBSERVE_VERDICTS = ["applied", "recorded", "rejected"];
2590
+ var isTurnObserveVerdict = makeGuard3(TURN_OBSERVE_VERDICTS);
2591
+ function isTurnObserveRequest(value) {
2592
+ return isRecord(value) && hasOnlyKeys2(value, ["v", "evidence"]) && value.v === TURN_IPC_PROTOCOL_VERSION && isTurnEvidence(value.evidence);
2593
+ }
2594
+ function decodeTurnObserveRequest(value) {
2595
+ return isTurnObserveRequest(value) ? value : null;
2596
+ }
2597
+ function isTurnAttemptRefValue(value) {
2598
+ return isRecord(value) && hasOnlyKeys2(value, ["attemptId", "generation"]) && isEvidenceIdentifier(value.attemptId) && isNonNegativeInt(value.generation);
2599
+ }
2600
+ function isTurnObserveResponse(value) {
2601
+ return isRecord(value) && hasOnlyKeys2(value, ["verdict", "attemptRef", "outcome"]) && isTurnObserveVerdict(value.verdict) && isTurnAttemptRefValue(value.attemptRef) && (value.outcome === void 0 || isTurnOutcomeValue(value.outcome));
2602
+ }
2603
+ var TURN_OUTCOMES_LOCAL = ["completed", "failed", "cancelled"];
2604
+ function isTurnOutcomeValue(value) {
2605
+ return typeof value === "string" && TURN_OUTCOMES_LOCAL.includes(value);
2606
+ }
2607
+ function decodeTurnObserveResponse(value) {
2608
+ return isTurnObserveResponse(value) ? value : null;
2609
+ }
2610
+ var MESH_RECORD_PAYLOAD_KEYS = [
2611
+ // Identifiers
2612
+ "taskId",
2613
+ "deliveryId",
2614
+ "attemptId",
2615
+ "missionId",
2616
+ "checkpointId",
2617
+ "promptId",
2618
+ "providerSessionId",
2619
+ "targetNoteId",
2620
+ // Routing / addressing
2621
+ "nodeId",
2622
+ "sessionId",
2623
+ "providerType",
2624
+ "transport",
2625
+ "attemptedSessionId",
2626
+ "holderSessionId",
2627
+ // Outcome enums
2628
+ "reason",
2629
+ "status",
2630
+ "outcome",
2631
+ "terminalKind",
2632
+ "event",
2633
+ "source",
2634
+ "intentionalStopReason",
2635
+ // Booleans
2636
+ "retryable",
2637
+ "rebound",
2638
+ "forced",
2639
+ "fallback",
2640
+ "membershipRemoved",
2641
+ "requestedForce",
2642
+ "removedByRemoteDaemon",
2643
+ "completedViaReady",
2644
+ "intentional",
2645
+ "weak",
2646
+ // Counters
2647
+ "attempt",
2648
+ "attemptCount",
2649
+ "count"
2650
+ ];
2651
+ var MESH_RECORD_PAYLOAD_KEY_SET = new Set(MESH_RECORD_PAYLOAD_KEYS);
2652
+ var MAX_MESH_RECORD_STRING = 200;
2653
+ function isProjectedScalarsValue(value) {
2654
+ if (!isRecord(value)) return false;
2655
+ for (const v of Object.values(value)) {
2656
+ if (v === null) continue;
2657
+ if (typeof v === "boolean" || typeof v === "number") continue;
2658
+ if (typeof v === "string") {
2659
+ if (v.length > MAX_MESH_RECORD_STRING) return false;
2660
+ continue;
2661
+ }
2662
+ return false;
2663
+ }
2664
+ return true;
2665
+ }
2666
+ function isMeshRecordPayload(value) {
2667
+ if (!isProjectedScalarsValue(value)) return false;
2668
+ for (const key of Object.keys(value)) {
2669
+ if (!MESH_RECORD_PAYLOAD_KEY_SET.has(key)) return false;
2670
+ }
2671
+ return true;
2672
+ }
2673
+ function isMeshRecordRequest(value) {
2674
+ return isRecord(value) && hasOnlyKeys2(value, ["v", "meshId", "ledgerKind", "nodeId", "sessionId", "taskId", "payload"]) && value.v === TURN_IPC_PROTOCOL_VERSION && isEvidenceIdentifier(value.meshId) && isEvidenceIdentifier(value.ledgerKind) && isOptionalId2(value.nodeId) && isOptionalId2(value.sessionId) && isOptionalId2(value.taskId) && isMeshRecordPayload(value.payload);
2675
+ }
2676
+ function decodeMeshRecordRequest(value) {
2677
+ return isMeshRecordRequest(value) ? value : null;
2678
+ }
2679
+ function isMeshRecordResponse(value) {
2680
+ return isRecord(value) && hasOnlyKeys2(value, ["eventId", "seq"]) && isEvidenceIdentifier(value.eventId) && isNonNegativeInt(value.seq);
2681
+ }
2682
+ function decodeMeshRecordResponse(value) {
2683
+ return isMeshRecordResponse(value) ? value : null;
2684
+ }
2685
+ function isTurnCancelRequest(value) {
2686
+ if (!isRecord(value) || !hasOnlyKeys2(value, ["v", "attemptId", "taskId", "reason"])) return false;
2687
+ if (value.v !== TURN_IPC_PROTOCOL_VERSION) return false;
2688
+ const hasAttempt = value.attemptId !== void 0;
2689
+ const hasTask = value.taskId !== void 0;
2690
+ if (hasAttempt === hasTask) return false;
2691
+ if (hasAttempt && !isEvidenceIdentifier(value.attemptId)) return false;
2692
+ if (hasTask && !isEvidenceIdentifier(value.taskId)) return false;
2693
+ return isTurnReason(value.reason);
2694
+ }
2695
+ function decodeTurnCancelRequest(value) {
2696
+ return isTurnCancelRequest(value) ? value : null;
2697
+ }
2698
+ function isTurnCancelResponse(value) {
2699
+ return isRecord(value) && hasOnlyKeys2(value, ["attemptRef", "verdict"]) && isTurnAttemptRefValue(value.attemptRef) && isTurnObserveVerdict(value.verdict);
2700
+ }
2701
+ function decodeTurnCancelResponse(value) {
2702
+ return isTurnCancelResponse(value) ? value : null;
2703
+ }
2704
+ var OPERATOR_STATUS_VALUES = ["completed", "failed"];
2705
+ var isOperatorStatusValue = makeGuard3(OPERATOR_STATUS_VALUES);
2706
+ var OPERATOR_STATUS_REASON_VALUES = ["operator_update", "refine_terminal", "validation_terminal"];
2707
+ var isOperatorStatusReasonValue = makeGuard3(OPERATOR_STATUS_REASON_VALUES);
2708
+ function isOperatorStatusRequest(value) {
2709
+ return isRecord(value) && hasOnlyKeys2(value, ["v", "taskId", "status", "reason"]) && value.v === TURN_IPC_PROTOCOL_VERSION && isEvidenceIdentifier(value.taskId) && isOperatorStatusValue(value.status) && isOperatorStatusReasonValue(value.reason);
2710
+ }
2711
+ function decodeOperatorStatusRequest(value) {
2712
+ return isOperatorStatusRequest(value) ? value : null;
2713
+ }
2714
+ function isOperatorStatusResponse(value) {
2715
+ return isRecord(value) && hasOnlyKeys2(value, ["accepted"]) && value.accepted === true;
2716
+ }
2717
+ function decodeOperatorStatusResponse(value) {
2718
+ return isOperatorStatusResponse(value) ? value : null;
2719
+ }
2720
+ function isTurnQueryRequest(value) {
2721
+ return isRecord(value) && hasOnlyKeys2(value, ["v", "meshId", "taskId", "attemptId", "sessionId", "state", "since", "tail"]) && value.v === TURN_IPC_PROTOCOL_VERSION && isEvidenceIdentifier(value.meshId) && isOptionalId2(value.taskId) && isOptionalId2(value.attemptId) && isOptionalId2(value.sessionId) && (value.state === void 0 || isEvidenceIdentifier(value.state)) && (value.since === void 0 || isFiniteNumber3(value.since)) && (value.tail === void 0 || isNonNegativeInt(value.tail));
2722
+ }
2723
+ function decodeTurnQueryRequest(value) {
2724
+ return isTurnQueryRequest(value) ? value : null;
2725
+ }
2726
+ var TURN_QUERY_ATTEMPT_ROW_KEYS = [
2727
+ "attemptId",
2728
+ "generation",
2729
+ "meshId",
2730
+ "taskId",
2731
+ "sessionId",
2732
+ "nodeId",
2733
+ "providerType",
2734
+ "state",
2735
+ "terminalOutcome",
2736
+ "terminalReason",
2737
+ "acceptedAt",
2738
+ "terminalAt"
2739
+ ];
2740
+ function isTurnQueryAttemptRow(value) {
2741
+ if (!isRecord(value) || !hasOnlyKeys2(value, TURN_QUERY_ATTEMPT_ROW_KEYS)) return false;
2742
+ if (!isEvidenceIdentifier(value.attemptId) || !isNonNegativeInt(value.generation)) return false;
2743
+ if (!isOptionalId2(value.meshId) || !isOptionalId2(value.taskId)) return false;
2744
+ if (!isEvidenceIdentifier(value.sessionId)) return false;
2745
+ if (!isOptionalId2(value.nodeId) || !isOptionalId2(value.providerType)) return false;
2746
+ if (typeof value.state !== "string") return false;
2747
+ if (value.terminalOutcome !== void 0 && !isTurnOutcomeValue(value.terminalOutcome)) return false;
2748
+ if (value.terminalReason !== void 0 && !isTurnReason(value.terminalReason)) return false;
2749
+ if (!isFiniteNumber3(value.acceptedAt)) return false;
2750
+ if (value.terminalAt !== void 0 && !isFiniteNumber3(value.terminalAt)) return false;
2751
+ return true;
2752
+ }
2753
+ var TURN_QUERY_EVENT_VERDICTS = ["applied", "recorded", "rejected", "forwarded"];
2754
+ var TURN_QUERY_EVENT_ROW_KEYS = ["eventId", "attemptId", "generation", "sessionId", "kind", "source", "verdict", "atMs"];
2755
+ function isTurnQueryEventRow(value) {
2756
+ if (!isRecord(value) || !hasOnlyKeys2(value, TURN_QUERY_EVENT_ROW_KEYS)) return false;
2757
+ if (!isEvidenceIdentifier(value.eventId)) return false;
2758
+ if (!isOptionalId2(value.attemptId)) return false;
2759
+ if (value.generation !== void 0 && !isNonNegativeInt(value.generation)) return false;
2760
+ if (!isEvidenceIdentifier(value.sessionId)) return false;
2761
+ if (typeof value.kind !== "string") return false;
2762
+ if (typeof value.source !== "string") return false;
2763
+ if (!TURN_QUERY_EVENT_VERDICTS.includes(value.verdict)) return false;
2764
+ if (!isFiniteNumber3(value.atMs)) return false;
2765
+ return true;
2766
+ }
2767
+ function isTurnQueryResponse(value) {
2768
+ if (!isRecord(value) || !hasOnlyKeys2(value, ["attempts", "events", "replicationPending"])) return false;
2769
+ if (!Array.isArray(value.attempts) || !value.attempts.every(isTurnQueryAttemptRow)) return false;
2770
+ if (!Array.isArray(value.events) || !value.events.every(isTurnQueryEventRow)) return false;
2771
+ if (value.replicationPending !== void 0 && typeof value.replicationPending !== "boolean") return false;
2772
+ return true;
2773
+ }
2774
+ function decodeTurnQueryResponse(value) {
2775
+ return isTurnQueryResponse(value) ? value : null;
2776
+ }
2777
+ var MESH_INDEX_QUERY_WRITER_SCOPES = ["own", "fleet"];
2778
+ var isMeshIndexQueryWriterScope = makeGuard3(MESH_INDEX_QUERY_WRITER_SCOPES);
2779
+ function isMeshIndexQueryRequest(value) {
2780
+ return isRecord(value) && hasOnlyKeys2(value, ["v", "meshId", "ledgerKind", "sessionId", "taskId", "writer", "since", "tail"]) && value.v === TURN_IPC_PROTOCOL_VERSION && isEvidenceIdentifier(value.meshId) && isOptionalId2(value.ledgerKind) && isOptionalId2(value.sessionId) && isOptionalId2(value.taskId) && (value.writer === void 0 || isMeshIndexQueryWriterScope(value.writer)) && (value.since === void 0 || isFiniteNumber3(value.since)) && (value.tail === void 0 || isNonNegativeInt(value.tail));
2781
+ }
2782
+ function decodeMeshIndexQueryRequest(value) {
2783
+ return isMeshIndexQueryRequest(value) ? value : null;
2784
+ }
2785
+ var MESH_TOPIC_INDEX_ROW_KEYS = [
2786
+ "writer",
2787
+ "seq",
2788
+ "meshId",
2789
+ "eventId",
2790
+ "kind",
2791
+ "ledgerKind",
2792
+ "taskId",
2793
+ "sessionId",
2794
+ "nodeId",
2795
+ "atMs",
2796
+ "payload"
2797
+ ];
2798
+ function isMeshTopicIndexRow(value) {
2799
+ if (!isRecord(value) || !hasOnlyKeys2(value, MESH_TOPIC_INDEX_ROW_KEYS)) return false;
2800
+ if (!isEvidenceIdentifier(value.writer) || !isNonNegativeInt(value.seq)) return false;
2801
+ if (!isEvidenceIdentifier(value.meshId) || !isEvidenceIdentifier(value.eventId)) return false;
2802
+ if (typeof value.kind !== "string") return false;
2803
+ if (!isOptionalId2(value.ledgerKind) || !isOptionalId2(value.taskId) || !isOptionalId2(value.sessionId) || !isOptionalId2(value.nodeId)) return false;
2804
+ if (!isFiniteNumber3(value.atMs)) return false;
2805
+ if (!isMeshRecordPayload(value.payload)) return false;
2806
+ return true;
2807
+ }
2808
+ function isMeshIndexQueryResponse(value) {
2809
+ if (!isRecord(value) || !hasOnlyKeys2(value, ["rows", "replicationPending"])) return false;
2810
+ if (!Array.isArray(value.rows) || !value.rows.every(isMeshTopicIndexRow)) return false;
2811
+ if (value.replicationPending !== void 0 && typeof value.replicationPending !== "boolean") return false;
2812
+ return true;
2813
+ }
2814
+ function decodeMeshIndexQueryResponse(value) {
2815
+ return isMeshIndexQueryResponse(value) ? value : null;
2816
+ }
2817
+ var MESH_MISSION_STATUSES = ["active", "paused", "completed", "abandoned"];
2818
+ var isMeshMissionStatusValue = makeGuard3(MESH_MISSION_STATUSES);
2819
+ var MESH_MISSION_SOURCES = ["magi", "coordinator"];
2820
+ var isMeshMissionSourceValue = makeGuard3(MESH_MISSION_SOURCES);
2821
+ function isStringArray(value) {
2822
+ return Array.isArray(value) && value.every((v) => typeof v === "string");
2823
+ }
2824
+ function isMissionBriefWire(value) {
2825
+ if (!isRecord(value) || !hasOnlyKeys2(value, ["goal", "constraints", "doneCriteria", "handoffNotes", "ownedPaths"])) return false;
2826
+ if (typeof value.goal !== "string" || value.goal.trim().length === 0) return false;
2827
+ for (const k of ["constraints", "doneCriteria", "handoffNotes", "ownedPaths"]) {
2828
+ if (value[k] !== void 0 && !isStringArray(value[k])) return false;
2829
+ }
2830
+ return true;
2831
+ }
2832
+ function isMeshMissionRecordWire(value) {
2833
+ if (!isRecord(value) || !hasOnlyKeys2(value, ["id", "meshId", "title", "goal", "status", "source", "brief"])) return false;
2834
+ if (!isEvidenceIdentifier(value.id) || !isEvidenceIdentifier(value.meshId)) return false;
2835
+ if (typeof value.title !== "string" || typeof value.goal !== "string") return false;
2836
+ if (!isMeshMissionStatusValue(value.status)) return false;
2837
+ if (value.source !== void 0 && !isMeshMissionSourceValue(value.source)) return false;
2838
+ if (value.brief !== void 0 && !isMissionBriefWire(value.brief)) return false;
2839
+ return true;
2840
+ }
2841
+ function isMissionUpsertRequest(value) {
2842
+ if (!isRecord(value) || !hasOnlyKeys2(value, ["v", "meshId", "id", "title", "goal", "status", "source", "brief"])) return false;
2843
+ if (value.v !== TURN_IPC_PROTOCOL_VERSION) return false;
2844
+ if (!isEvidenceIdentifier(value.meshId)) return false;
2845
+ if (value.id !== void 0 && !isEvidenceIdentifier(value.id)) return false;
2846
+ if (typeof value.title !== "string" || value.title.trim().length === 0) return false;
2847
+ if (value.goal !== void 0 && typeof value.goal !== "string") return false;
2848
+ if (value.status !== void 0 && !isMeshMissionStatusValue(value.status)) return false;
2849
+ if (value.source !== void 0 && !isMeshMissionSourceValue(value.source)) return false;
2850
+ if (value.brief !== void 0 && value.brief !== null && !isMissionBriefWire(value.brief)) return false;
2851
+ return true;
2852
+ }
2853
+ function decodeMissionUpsertRequest(value) {
2854
+ return isMissionUpsertRequest(value) ? value : null;
2855
+ }
2856
+ function isMissionUpsertResponse(value) {
2857
+ return isRecord(value) && hasOnlyKeys2(value, ["mission"]) && isMeshMissionRecordWire(value.mission);
2858
+ }
2859
+ function decodeMissionUpsertResponse(value) {
2860
+ return isMissionUpsertResponse(value) ? value : null;
2861
+ }
2862
+ function isMissionQueryRequest(value) {
2863
+ if (!isRecord(value) || !hasOnlyKeys2(value, ["v", "meshId", "statuses", "id"])) return false;
2864
+ if (value.v !== TURN_IPC_PROTOCOL_VERSION) return false;
2865
+ if (!isEvidenceIdentifier(value.meshId)) return false;
2866
+ if (value.id !== void 0 && !isEvidenceIdentifier(value.id)) return false;
2867
+ if (value.statuses !== void 0) {
2868
+ if (!Array.isArray(value.statuses) || value.statuses.length === 0) return false;
2869
+ if (!value.statuses.every(isMeshMissionStatusValue)) return false;
2870
+ }
2871
+ return true;
2872
+ }
2873
+ function decodeMissionQueryRequest(value) {
2874
+ return isMissionQueryRequest(value) ? value : null;
2875
+ }
2876
+ function isMissionQueryResponse(value) {
2877
+ return isRecord(value) && hasOnlyKeys2(value, ["missions"]) && Array.isArray(value.missions) && value.missions.every(isMeshMissionRecordWire);
2878
+ }
2879
+ function decodeMissionQueryResponse(value) {
2880
+ return isMissionQueryResponse(value) ? value : null;
2881
+ }
2882
+ function isMissionListQueryRequest(value) {
2883
+ if (!isRecord(value) || !hasOnlyKeys2(value, ["v", "meshId", "statuses", "verbose", "includeMagi", "withStats", "limit", "historyIdLimit"])) return false;
2884
+ if (value.v !== TURN_IPC_PROTOCOL_VERSION) return false;
2885
+ if (!isEvidenceIdentifier(value.meshId)) return false;
2886
+ if (value.statuses !== void 0) {
2887
+ if (!Array.isArray(value.statuses) || value.statuses.length === 0) return false;
2888
+ if (!value.statuses.every(isMeshMissionStatusValue)) return false;
2889
+ }
2890
+ if (value.verbose !== void 0 && typeof value.verbose !== "boolean") return false;
2891
+ if (value.includeMagi !== void 0 && typeof value.includeMagi !== "boolean") return false;
2892
+ if (value.withStats !== void 0 && typeof value.withStats !== "boolean") return false;
2893
+ if (value.limit !== void 0 && !isNonNegativeInt(value.limit)) return false;
2894
+ if (value.historyIdLimit !== void 0 && !isNonNegativeInt(value.historyIdLimit)) return false;
2895
+ return true;
2896
+ }
2897
+ function decodeMissionListQueryRequest(value) {
2898
+ return isMissionListQueryRequest(value) ? value : null;
2899
+ }
2900
+ function isMeshMissionTaskAggregateWire(value) {
2901
+ const keys = ["total", "pending", "assigned", "completed", "failed", "cancelled", "blocked", "lastActivityAt"];
2902
+ if (!isRecord(value) || !hasOnlyKeys2(value, keys)) return false;
2903
+ for (const k of ["total", "pending", "assigned", "completed", "failed", "cancelled", "blocked"]) {
2904
+ if (!isNonNegativeInt(value[k])) return false;
2905
+ }
2906
+ return value.lastActivityAt === null || typeof value.lastActivityAt === "string";
2907
+ }
2908
+ function isMeshMissionStatsWire(value) {
2909
+ const keys = ["missionId", "taskCount", "completed", "failed", "totalDurationMs", "wallClockMs", "retries", "incompleteTaskIds"];
2910
+ if (!isRecord(value) || !hasOnlyKeys2(value, keys)) return false;
2911
+ if (!isEvidenceIdentifier(value.missionId)) return false;
2912
+ for (const k of ["taskCount", "completed", "failed", "totalDurationMs", "retries"]) {
2913
+ if (!isNonNegativeInt(value[k])) return false;
2914
+ }
2915
+ if (value.wallClockMs !== null && !isNonNegativeInt(value.wallClockMs)) return false;
2916
+ if (!Array.isArray(value.incompleteTaskIds) || !value.incompleteTaskIds.every(isEvidenceIdentifier)) return false;
2917
+ return true;
2918
+ }
2919
+ function isMissionListSummaryWire(value) {
2920
+ if (!isRecord(value)) return false;
2921
+ const hasGoal = "goal" in value;
2922
+ const hasPreview = "goalPreview" in value && "goalTruncated" in value;
2923
+ if (hasGoal === hasPreview) return false;
2924
+ const baseKeys = ["id", "meshId", "title", "status", "source", "tasks", "stats", "brief"];
2925
+ const allowed = hasGoal ? [...baseKeys, "goal"] : [...baseKeys, "goalPreview", "goalTruncated"];
2926
+ if (!hasOnlyKeys2(value, allowed)) return false;
2927
+ if (!isEvidenceIdentifier(value.id) || !isEvidenceIdentifier(value.meshId)) return false;
2928
+ if (typeof value.title !== "string") return false;
2929
+ if (!isMeshMissionStatusValue(value.status)) return false;
2930
+ if (value.source !== void 0 && !isMeshMissionSourceValue(value.source)) return false;
2931
+ if (!isMeshMissionTaskAggregateWire(value.tasks)) return false;
2932
+ if (value.stats !== void 0 && !isMeshMissionStatsWire(value.stats)) return false;
2933
+ if (value.brief !== void 0 && !isMissionBriefWire(value.brief)) return false;
2934
+ if (hasGoal && typeof value.goal !== "string") return false;
2935
+ if (hasPreview && (typeof value.goalPreview !== "string" || typeof value.goalTruncated !== "boolean")) return false;
2936
+ return true;
2937
+ }
2938
+ function isMeshMissionHistoryFoldWire(value) {
2939
+ if (!isRecord(value) || !hasOnlyKeys2(value, ["count", "byStatus", "missionIds", "note"])) return false;
2940
+ if (!isNonNegativeInt(value.count)) return false;
2941
+ if (!isRecord(value.byStatus) || !Object.values(value.byStatus).every((n) => isNonNegativeInt(n))) return false;
2942
+ if (!Array.isArray(value.missionIds) || !value.missionIds.every(isEvidenceIdentifier)) return false;
2943
+ return typeof value.note === "string";
2944
+ }
2945
+ function isMissionListQueryResponse(value) {
2946
+ if (!isRecord(value) || !hasOnlyKeys2(value, ["missions", "historyFold", "truncated", "matched", "overflowIds"])) return false;
2947
+ if (!Array.isArray(value.missions) || !value.missions.every(isMissionListSummaryWire)) return false;
2948
+ if (value.historyFold !== null && !isMeshMissionHistoryFoldWire(value.historyFold)) return false;
2949
+ if (typeof value.truncated !== "boolean") return false;
2950
+ if (!isNonNegativeInt(value.matched)) return false;
2951
+ if (value.overflowIds !== void 0 && (!Array.isArray(value.overflowIds) || !value.overflowIds.every(isEvidenceIdentifier))) return false;
2952
+ return true;
2953
+ }
2954
+ function decodeMissionListQueryResponse(value) {
2955
+ return isMissionListQueryResponse(value) ? value : null;
2956
+ }
2957
+ var OPERATING_NOTE_CATEGORIES = ["provider_quirk", "pattern_to_avoid", "recovery_lesson"];
2958
+ var isOperatingNoteCategory = makeGuard3(OPERATING_NOTE_CATEGORIES);
2959
+ function isOptionalShortString(value, max = 512) {
2960
+ return value === void 0 || typeof value === "string" && value.trim().length > 0 && value.length <= max;
2961
+ }
2962
+ function isNoteUpsertRequest(value) {
2963
+ if (!isRecord(value) || !hasOnlyKeys2(value, ["v", "meshId", "text", "category", "pinned", "expiresAt", "supersedes", "subjectKey", "sourceCoordinator"])) return false;
2964
+ if (value.v !== TURN_IPC_PROTOCOL_VERSION) return false;
2965
+ if (!isEvidenceIdentifier(value.meshId)) return false;
2966
+ if (typeof value.text !== "string" || value.text.trim().length === 0) return false;
2967
+ if (value.category !== void 0 && !isOperatingNoteCategory(value.category)) return false;
2968
+ if (value.pinned !== void 0 && typeof value.pinned !== "boolean") return false;
2969
+ if (value.expiresAt !== void 0 && (typeof value.expiresAt !== "string" || Number.isNaN(Date.parse(value.expiresAt)))) return false;
2970
+ return isOptionalShortString(value.supersedes) && isOptionalShortString(value.subjectKey) && isOptionalShortString(value.sourceCoordinator);
2971
+ }
2972
+ function decodeNoteUpsertRequest(value) {
2973
+ return isNoteUpsertRequest(value) ? value : null;
2974
+ }
2975
+ function isNoteUpsertResponse(value) {
2976
+ return isRecord(value) && hasOnlyKeys2(value, ["noteId", "deduped", "createdAt"]) && isEvidenceIdentifier(value.noteId) && typeof value.deduped === "boolean" && typeof value.createdAt === "string";
2977
+ }
2978
+ function decodeNoteUpsertResponse(value) {
2979
+ return isNoteUpsertResponse(value) ? value : null;
2980
+ }
2981
+ function isNoteForgetRequest(value) {
2982
+ if (!isRecord(value) || !hasOnlyKeys2(value, ["v", "meshId", "noteId", "text", "reason"])) return false;
2983
+ if (value.v !== TURN_IPC_PROTOCOL_VERSION) return false;
2984
+ if (!isEvidenceIdentifier(value.meshId)) return false;
2985
+ if (value.noteId !== void 0 && !isEvidenceIdentifier(value.noteId)) return false;
2986
+ if (value.text !== void 0 && (typeof value.text !== "string" || value.text.trim().length === 0)) return false;
2987
+ if (value.noteId === void 0 && value.text === void 0) return false;
2988
+ return value.reason === void 0 || typeof value.reason === "string";
2989
+ }
2990
+ function decodeNoteForgetRequest(value) {
2991
+ return isNoteForgetRequest(value) ? value : null;
2992
+ }
2993
+ function isNoteForgetResponse(value) {
2994
+ return isRecord(value) && hasOnlyKeys2(value, ["matched", "tombstoneId"]) && typeof value.matched === "number" && Number.isInteger(value.matched) && value.matched >= 0 && isEvidenceIdentifier(value.tombstoneId);
2995
+ }
2996
+ function decodeNoteForgetResponse(value) {
2997
+ return isNoteForgetResponse(value) ? value : null;
2998
+ }
2999
+ var TOOL_CALLER_ROLES = ["coordinator", "unknown"];
3000
+ var isToolCallerRole = makeGuard3(TOOL_CALLER_ROLES);
3001
+ function isToolCallRecordRequest(value) {
3002
+ return isRecord(value) && hasOnlyKeys2(value, ["v", "meshId", "tool", "sessionId", "callerRole"]) && value.v === TURN_IPC_PROTOCOL_VERSION && isEvidenceIdentifier(value.meshId) && isEvidenceIdentifier(value.tool) && isOptionalId2(value.sessionId) && isToolCallerRole(value.callerRole);
3003
+ }
3004
+ function decodeToolCallRecordRequest(value) {
3005
+ return isToolCallRecordRequest(value) ? value : null;
3006
+ }
3007
+ function isToolCallRecordResponse(value) {
3008
+ return isRecord(value) && hasOnlyKeys2(value, ["rateLimitExceeded", "callsInWindow", "advisory"]) && typeof value.rateLimitExceeded === "boolean" && isNonNegativeInt(value.callsInWindow) && (value.advisory === null || typeof value.advisory === "string");
3009
+ }
3010
+ function decodeToolCallRecordResponse(value) {
3011
+ return isToolCallRecordResponse(value) ? value : null;
3012
+ }
3013
+ function isLedgerQueryRequest(value) {
3014
+ if (!isRecord(value) || !hasOnlyKeys2(value, ["v", "meshId", "kind", "since", "node", "tail", "includeSummary"])) return false;
3015
+ if (value.v !== TURN_IPC_PROTOCOL_VERSION) return false;
3016
+ if (!isEvidenceIdentifier(value.meshId)) return false;
3017
+ if (value.kind !== void 0 && (!Array.isArray(value.kind) || value.kind.length === 0 || !value.kind.every(isEvidenceIdentifier))) return false;
3018
+ if (value.since !== void 0 && typeof value.since !== "string") return false;
3019
+ if (!isOptionalId2(value.node)) return false;
3020
+ if (value.tail !== void 0 && !isNonNegativeInt(value.tail)) return false;
3021
+ if (value.includeSummary !== void 0 && typeof value.includeSummary !== "boolean") return false;
3022
+ return true;
3023
+ }
3024
+ function decodeLedgerQueryRequest(value) {
3025
+ return isLedgerQueryRequest(value) ? value : null;
3026
+ }
3027
+ var LEDGER_QUERY_ENTRY_KEYS = ["id", "meshId", "timestamp", "kind", "nodeId", "sessionId", "providerType", "taskId", "payload"];
3028
+ function isLedgerQueryEntryWire(value) {
3029
+ if (!isRecord(value) || !hasOnlyKeys2(value, LEDGER_QUERY_ENTRY_KEYS)) return false;
3030
+ if (!isEvidenceIdentifier(value.id) || !isEvidenceIdentifier(value.meshId)) return false;
3031
+ if (typeof value.timestamp !== "string" || typeof value.kind !== "string") return false;
3032
+ if (!isOptionalId2(value.nodeId) || !isOptionalId2(value.sessionId) || !isOptionalId2(value.providerType) || !isOptionalId2(value.taskId)) return false;
3033
+ if (!isRecord(value.payload)) return false;
3034
+ return true;
3035
+ }
3036
+ function isLedgerQuerySummaryWire(value) {
3037
+ const keys = ["meshId", "totalEntries", "taskDispatched", "taskCompleted", "taskFailed", "taskStalled", "sessionLaunched", "checkpointCreated", "lastActivityAt", "recentFailures"];
3038
+ if (!isRecord(value) || !hasOnlyKeys2(value, keys)) return false;
3039
+ if (!isEvidenceIdentifier(value.meshId)) return false;
3040
+ for (const k of ["totalEntries", "taskDispatched", "taskCompleted", "taskFailed", "taskStalled", "sessionLaunched", "checkpointCreated", "recentFailures"]) {
3041
+ if (!isNonNegativeInt(value[k])) return false;
3042
+ }
3043
+ if (value.lastActivityAt !== null && typeof value.lastActivityAt !== "string") return false;
3044
+ return true;
3045
+ }
3046
+ function isLedgerQueryResponse(value) {
3047
+ if (!isRecord(value) || !hasOnlyKeys2(value, ["entries", "summary"])) return false;
3048
+ if (!Array.isArray(value.entries) || !value.entries.every(isLedgerQueryEntryWire)) return false;
3049
+ if (value.summary !== void 0 && !isLedgerQuerySummaryWire(value.summary)) return false;
3050
+ return true;
3051
+ }
3052
+ function decodeLedgerQueryResponse(value) {
3053
+ return isLedgerQueryResponse(value) ? value : null;
3054
+ }
3055
+ function isRecordArray(value) {
3056
+ return Array.isArray(value) && value.every(isRecord);
3057
+ }
3058
+ function isOptionalRecord(value) {
3059
+ return value === void 0 || isRecord(value);
3060
+ }
3061
+ function isOptionalBoolean(value) {
3062
+ return value === void 0 || typeof value === "boolean";
3063
+ }
3064
+ function isOptionalString(value) {
3065
+ return value === void 0 || typeof value === "string";
3066
+ }
3067
+ function isQueueEntryWire(value) {
3068
+ return isRecord(value) && isEvidenceIdentifier(value.id) && typeof value.status === "string";
3069
+ }
3070
+ function isRecordLocalRequest(value) {
3071
+ return isRecord(value) && hasOnlyKeys2(value, ["v", "meshId", "kind", "nodeId", "sessionId", "providerType", "taskId", "payload"]) && value.v === TURN_IPC_PROTOCOL_VERSION && isEvidenceIdentifier(value.meshId) && isEvidenceIdentifier(value.kind) && isOptionalId2(value.nodeId) && isOptionalId2(value.sessionId) && isOptionalId2(value.providerType) && isOptionalId2(value.taskId) && isRecord(value.payload);
3072
+ }
3073
+ function decodeRecordLocalRequest(value) {
3074
+ return isRecordLocalRequest(value) ? value : null;
3075
+ }
3076
+ function isRecordLocalResponse(value) {
3077
+ return isRecord(value) && hasOnlyKeys2(value, ["eventId", "timestamp", "storedLocally", "published"]) && isEvidenceIdentifier(value.eventId) && typeof value.timestamp === "string" && typeof value.storedLocally === "boolean" && typeof value.published === "boolean";
3078
+ }
3079
+ function decodeRecordLocalResponse(value) {
3080
+ return isRecordLocalResponse(value) ? value : null;
3081
+ }
3082
+ function isQueueQueryRequest(value) {
3083
+ if (!isRecord(value) || !hasOnlyKeys2(value, ["v", "meshId", "statuses", "taskId", "view"])) return false;
3084
+ if (value.v !== TURN_IPC_PROTOCOL_VERSION || !isEvidenceIdentifier(value.meshId)) return false;
3085
+ if (value.statuses !== void 0 && (!Array.isArray(value.statuses) || !value.statuses.every(isEvidenceIdentifier))) return false;
3086
+ return isOptionalId2(value.taskId) && isOptionalBoolean(value.view);
3087
+ }
3088
+ function decodeQueueQueryRequest(value) {
3089
+ return isQueueQueryRequest(value) ? value : null;
3090
+ }
3091
+ function isQueueQueryResponse(value) {
3092
+ return isRecord(value) && hasOnlyKeys2(value, ["entries"]) && Array.isArray(value.entries) && value.entries.every(isQueueEntryWire);
3093
+ }
3094
+ function decodeQueueQueryResponse(value) {
3095
+ return isQueueQueryResponse(value) ? value : null;
3096
+ }
3097
+ function isQueueEnqueueRequest(value) {
3098
+ return isRecord(value) && hasOnlyKeys2(value, ["v", "meshId", "message", "options", "decision"]) && value.v === TURN_IPC_PROTOCOL_VERSION && isEvidenceIdentifier(value.meshId) && typeof value.message === "string" && isOptionalRecord(value.options) && isOptionalRecord(value.decision);
3099
+ }
3100
+ function decodeQueueEnqueueRequest(value) {
3101
+ return isQueueEnqueueRequest(value) ? value : null;
3102
+ }
3103
+ function isQueueEnqueueResponse(value) {
3104
+ return isRecord(value) && hasOnlyKeys2(value, ["entry"]) && isQueueEntryWire(value.entry);
3105
+ }
3106
+ function decodeQueueEnqueueResponse(value) {
3107
+ return isQueueEnqueueResponse(value) ? value : null;
3108
+ }
3109
+ function isQueueEnqueueGraphRequest(value) {
3110
+ if (!isRecord(value) || !hasOnlyKeys2(value, ["v", "meshId", "mode", "specs", "plan", "audit"])) return false;
3111
+ if (value.v !== TURN_IPC_PROTOCOL_VERSION || !isEvidenceIdentifier(value.meshId)) return false;
3112
+ if (value.mode === "compat") return isRecordArray(value.specs) && value.plan === void 0 && isOptionalRecord(value.audit);
3113
+ if (value.mode === "graph") return isRecord(value.plan) && value.specs === void 0 && isOptionalRecord(value.audit);
3114
+ return false;
3115
+ }
3116
+ function decodeQueueEnqueueGraphRequest(value) {
3117
+ return isQueueEnqueueGraphRequest(value) ? value : null;
3118
+ }
3119
+ function isQueueEnqueueGraphResponse(value) {
3120
+ if (!isRecord(value)) return false;
3121
+ if (value.ok === true) {
3122
+ return hasOnlyKeys2(value, ["ok", "tasks", "graph"]) && Array.isArray(value.tasks) && value.tasks.every(isQueueEntryWire) && isOptionalRecord(value.graph);
3123
+ }
3124
+ if (value.ok === false) {
3125
+ return hasOnlyKeys2(value, ["ok", "refusalCode", "message", "extra"]) && typeof value.message === "string" && isOptionalString(value.refusalCode) && isOptionalRecord(value.extra);
3126
+ }
3127
+ return false;
3128
+ }
3129
+ function decodeQueueEnqueueGraphResponse(value) {
3130
+ return isQueueEnqueueGraphResponse(value) ? value : null;
3131
+ }
3132
+ function isQueueCancelRequest(value) {
3133
+ return isRecord(value) && hasOnlyKeys2(value, ["v", "meshId", "taskId", "reason"]) && value.v === TURN_IPC_PROTOCOL_VERSION && isEvidenceIdentifier(value.meshId) && isEvidenceIdentifier(value.taskId) && isOptionalString(value.reason);
3134
+ }
3135
+ function decodeQueueCancelRequest(value) {
3136
+ return isQueueCancelRequest(value) ? value : null;
3137
+ }
3138
+ function isQueueCancelResponse(value) {
3139
+ return isRecord(value) && hasOnlyKeys2(value, ["task", "before"]) && (value.task === null || isQueueEntryWire(value.task)) && (value.before === null || isQueueEntryWire(value.before));
3140
+ }
3141
+ function decodeQueueCancelResponse(value) {
3142
+ return isQueueCancelResponse(value) ? value : null;
3143
+ }
3144
+ function isQueueRequeueRequest(value) {
3145
+ return isRecord(value) && hasOnlyKeys2(value, ["v", "meshId", "taskId", "options"]) && value.v === TURN_IPC_PROTOCOL_VERSION && isEvidenceIdentifier(value.meshId) && isEvidenceIdentifier(value.taskId) && isOptionalRecord(value.options);
3146
+ }
3147
+ function decodeQueueRequeueRequest(value) {
3148
+ return isQueueRequeueRequest(value) ? value : null;
3149
+ }
3150
+ function isQueueRequeueResponse(value) {
3151
+ return isRecord(value) && hasOnlyKeys2(value, ["task"]) && (value.task === null || isQueueEntryWire(value.task));
3152
+ }
3153
+ function decodeQueueRequeueResponse(value) {
3154
+ return isQueueRequeueResponse(value) ? value : null;
3155
+ }
3156
+ function isDirectDispatchRecordRequest(value) {
3157
+ return isRecord(value) && hasOnlyKeys2(value, ["v", "meshId", "taskId", "message", "task", "decision"]) && value.v === TURN_IPC_PROTOCOL_VERSION && isEvidenceIdentifier(value.meshId) && isEvidenceIdentifier(value.taskId) && typeof value.message === "string" && isOptionalRecord(value.task) && isOptionalRecord(value.decision);
3158
+ }
3159
+ function decodeDirectDispatchRecordRequest(value) {
3160
+ return isDirectDispatchRecordRequest(value) ? value : null;
3161
+ }
3162
+ function isDirectDispatchRecordResponse(value) {
3163
+ return isRecord(value) && hasOnlyKeys2(value, ["taskRecorded", "decisionRecorded"]) && typeof value.taskRecorded === "boolean" && typeof value.decisionRecorded === "boolean";
3164
+ }
3165
+ function decodeDirectDispatchRecordResponse(value) {
3166
+ return isDirectDispatchRecordResponse(value) ? value : null;
3167
+ }
3168
+ var GRAPH_AUDIT_EVENTS = ["gate_claimed", "gate_released", "gate_abandoned", "node_patched"];
3169
+ var isGraphAuditEvent = makeGuard3(GRAPH_AUDIT_EVENTS);
3170
+ function isGraphAuditRecordRequest(value) {
3171
+ return isRecord(value) && hasOnlyKeys2(value, ["v", "meshId", "event", "fields"]) && value.v === TURN_IPC_PROTOCOL_VERSION && isEvidenceIdentifier(value.meshId) && isGraphAuditEvent(value.event) && isRecord(value.fields);
3172
+ }
3173
+ function decodeGraphAuditRecordRequest(value) {
3174
+ return isGraphAuditRecordRequest(value) ? value : null;
3175
+ }
3176
+ function isGraphAuditRecordResponse(value) {
3177
+ return isRecord(value) && hasOnlyKeys2(value, ["recorded"]) && typeof value.recorded === "boolean";
3178
+ }
3179
+ function decodeGraphAuditRecordResponse(value) {
3180
+ return isGraphAuditRecordResponse(value) ? value : null;
3181
+ }
3182
+ function isActiveWorkQueryRequest(value) {
3183
+ if (!isRecord(value) || !hasOnlyKeys2(value, ["v", "meshId", "nodes", "queue", "recordTail", "includeTerminalDirect", "compute", "includeInputs", "includeSummary", "includeSchedulingRuntime", "mesh"])) return false;
3184
+ if (value.v !== TURN_IPC_PROTOCOL_VERSION || !isEvidenceIdentifier(value.meshId)) return false;
3185
+ if (value.nodes !== void 0 && !isRecordArray(value.nodes)) return false;
3186
+ if (value.queue !== void 0 && !isRecordArray(value.queue)) return false;
3187
+ if (value.recordTail !== void 0 && !isNonNegativeInt(value.recordTail)) return false;
3188
+ if (value.includeSchedulingRuntime === true && !isRecord(value.mesh)) return false;
3189
+ return isOptionalBoolean(value.includeTerminalDirect) && isOptionalBoolean(value.compute) && isOptionalBoolean(value.includeInputs) && isOptionalBoolean(value.includeSummary) && isOptionalBoolean(value.includeSchedulingRuntime) && isOptionalRecord(value.mesh);
3190
+ }
3191
+ function decodeActiveWorkQueryRequest(value) {
3192
+ return isActiveWorkQueryRequest(value) ? value : null;
3193
+ }
3194
+ function isActiveWorkQueryResponse(value) {
3195
+ if (!isRecord(value) || !hasOnlyKeys2(value, ["activeWork", "records", "directDispatches", "summary", "schedulingRuntime"])) return false;
3196
+ if (value.records !== void 0 && !isRecordArray(value.records)) return false;
3197
+ if (value.directDispatches !== void 0 && !isRecordArray(value.directDispatches)) return false;
3198
+ return isOptionalRecord(value.activeWork) && isOptionalRecord(value.summary) && isOptionalRecord(value.schedulingRuntime);
3199
+ }
3200
+ function decodeActiveWorkQueryResponse(value) {
3201
+ return isActiveWorkQueryResponse(value) ? value : null;
3202
+ }
3203
+ function isRecoveryContextQueryRequest(value) {
3204
+ return isRecord(value) && hasOnlyKeys2(value, ["v", "meshId", "nodeId", "sessionId", "maxRetries"]) && value.v === TURN_IPC_PROTOCOL_VERSION && isEvidenceIdentifier(value.meshId) && isOptionalId2(value.nodeId) && isOptionalId2(value.sessionId) && (value.maxRetries === void 0 || isNonNegativeInt(value.maxRetries)) && (value.nodeId !== void 0 || value.sessionId !== void 0);
3205
+ }
3206
+ function decodeRecoveryContextQueryRequest(value) {
3207
+ return isRecoveryContextQueryRequest(value) ? value : null;
3208
+ }
3209
+ function isRecoveryContextQueryResponse(value) {
3210
+ return isRecord(value) && hasOnlyKeys2(value, ["context"]) && isRecord(value.context) && typeof value.context.consecutiveNodeFailures === "number";
3211
+ }
3212
+ function decodeRecoveryContextQueryResponse(value) {
3213
+ return isRecoveryContextQueryResponse(value) ? value : null;
3214
+ }
3215
+ function isGraphGateClaimRequest(value) {
3216
+ if (!isRecord(value) || !hasOnlyKeys2(value, ["v", "meshId", "gateId", "coordinatorSessionId", "leaseSeconds", "extendDeadlineSeconds", "probeConvergenceEvidence"])) return false;
3217
+ if (value.v !== TURN_IPC_PROTOCOL_VERSION || !isEvidenceIdentifier(value.meshId) || !isEvidenceIdentifier(value.gateId) || !isEvidenceIdentifier(value.coordinatorSessionId)) return false;
3218
+ if (value.leaseSeconds !== void 0 && !isFiniteNumber3(value.leaseSeconds)) return false;
3219
+ if (value.extendDeadlineSeconds !== void 0 && !isFiniteNumber3(value.extendDeadlineSeconds)) return false;
3220
+ return isOptionalBoolean(value.probeConvergenceEvidence);
3221
+ }
3222
+ function decodeGraphGateClaimRequest(value) {
3223
+ return isGraphGateClaimRequest(value) ? value : null;
3224
+ }
3225
+ function isGraphGateClaimResponse(value) {
3226
+ if (!isRecord(value) || !hasOnlyKeys2(value, ["claimed", "reason", "gate", "leaseGeneration", "fencingToken", "leaseExpiresAt", "deadlineAt", "ambiguousExternalOutcome", "previousLeaseOwnerSessionId", "convergenceEvidence"])) return false;
3227
+ if (typeof value.claimed !== "boolean") return false;
3228
+ return isOptionalRecord(value.gate) && isOptionalRecord(value.convergenceEvidence) && isOptionalBoolean(value.ambiguousExternalOutcome);
3229
+ }
3230
+ function decodeGraphGateClaimResponse(value) {
3231
+ return isGraphGateClaimResponse(value) ? value : null;
3232
+ }
3233
+ function isGraphGateReleaseRequest(value) {
3234
+ if (!isRecord(value) || !hasOnlyKeys2(value, ["v", "meshId", "gateId", "fencingToken", "leaseGeneration", "idempotencyKey", "outcome", "result", "evidence", "patches"])) return false;
3235
+ if (value.v !== TURN_IPC_PROTOCOL_VERSION || !isEvidenceIdentifier(value.meshId) || !isEvidenceIdentifier(value.gateId)) return false;
3236
+ if (typeof value.fencingToken !== "string" || !value.fencingToken) return false;
3237
+ if (!isFiniteNumber3(value.leaseGeneration)) return false;
3238
+ if (typeof value.idempotencyKey !== "string" || !value.idempotencyKey) return false;
3239
+ if (typeof value.outcome !== "string" || !value.outcome) return false;
3240
+ if (value.patches !== void 0) {
3241
+ if (!Array.isArray(value.patches)) return false;
3242
+ for (const p of value.patches) {
3243
+ if (!isRecord(p) || typeof p.node !== "string" || !p.node || !isRecord(p.baseSpecPatch)) return false;
3244
+ }
3245
+ }
3246
+ return true;
3247
+ }
3248
+ function decodeGraphGateReleaseRequest(value) {
3249
+ return isGraphGateReleaseRequest(value) ? value : null;
3250
+ }
3251
+ function isGraphGateReleaseResponse(value) {
3252
+ if (!isRecord(value)) return false;
3253
+ if (value.released === true) {
3254
+ if (!hasOnlyKeys2(value, ["released", "duplicate", "gate", "materializedNodeIds", "downstreamNodeCount", "graphCompleted"])) return false;
3255
+ if (typeof value.duplicate !== "boolean") return false;
3256
+ if (!Array.isArray(value.materializedNodeIds) || !value.materializedNodeIds.every((n) => typeof n === "string")) return false;
3257
+ if (value.downstreamNodeCount !== void 0 && !isNonNegativeInt(value.downstreamNodeCount)) return false;
3258
+ return isOptionalRecord(value.gate) && isOptionalBoolean(value.graphCompleted);
3259
+ }
3260
+ if (value.released === false) {
3261
+ return hasOnlyKeys2(value, ["released", "refusalCode", "message"]) && typeof value.message === "string" && isOptionalString(value.refusalCode);
3262
+ }
3263
+ return false;
3264
+ }
3265
+ function decodeGraphGateReleaseResponse(value) {
3266
+ return isGraphGateReleaseResponse(value) ? value : null;
3267
+ }
3268
+ function isGraphGateAbandonRequest(value) {
3269
+ if (!isRecord(value) || !hasOnlyKeys2(value, ["v", "meshId", "gateId", "reason", "coordinatorSessionId", "force"])) return false;
3270
+ if (value.v !== TURN_IPC_PROTOCOL_VERSION || !isEvidenceIdentifier(value.meshId) || !isEvidenceIdentifier(value.gateId)) return false;
3271
+ if (typeof value.reason !== "string" || !value.reason) return false;
3272
+ if (value.coordinatorSessionId !== void 0 && !isEvidenceIdentifier(value.coordinatorSessionId)) return false;
3273
+ return isOptionalBoolean(value.force);
3274
+ }
3275
+ function decodeGraphGateAbandonRequest(value) {
3276
+ return isGraphGateAbandonRequest(value) ? value : null;
3277
+ }
3278
+ function isGraphGateAbandonResponse(value) {
3279
+ if (!isRecord(value) || !hasOnlyKeys2(value, ["abandoned", "reason", "gate", "cancelledNodeIds", "cancelledTaskIds", "graphStatus"])) return false;
3280
+ if (typeof value.abandoned !== "boolean") return false;
3281
+ if (!Array.isArray(value.cancelledNodeIds) || !value.cancelledNodeIds.every((n) => typeof n === "string")) return false;
3282
+ if (!Array.isArray(value.cancelledTaskIds) || !value.cancelledTaskIds.every((n) => typeof n === "string")) return false;
3283
+ return isOptionalRecord(value.gate);
3284
+ }
3285
+ function decodeGraphGateAbandonResponse(value) {
3286
+ return isGraphGateAbandonResponse(value) ? value : null;
3287
+ }
3288
+ function isGraphNodePatchRequest(value) {
3289
+ if (!isRecord(value) || !hasOnlyKeys2(value, ["v", "meshId", "node", "graphId", "baseSpecPatch"])) return false;
3290
+ if (value.v !== TURN_IPC_PROTOCOL_VERSION || !isEvidenceIdentifier(value.meshId)) return false;
3291
+ if (typeof value.node !== "string" || !value.node) return false;
3292
+ if (value.graphId !== void 0 && !isEvidenceIdentifier(value.graphId)) return false;
3293
+ return isRecord(value.baseSpecPatch) && Object.keys(value.baseSpecPatch).length > 0;
3294
+ }
3295
+ function decodeGraphNodePatchRequest(value) {
3296
+ return isGraphNodePatchRequest(value) ? value : null;
3297
+ }
3298
+ function isGraphNodePatchResponse(value) {
3299
+ if (!isRecord(value)) return false;
3300
+ if (value.patched === true) {
3301
+ if (!hasOnlyKeys2(value, ["patched", "graphId", "nodeId", "ref", "queueTaskId", "materializationVersion", "state", "outcomeKind", "skippedReason", "blockedReason"])) return false;
3302
+ if (!isEvidenceIdentifier(value.graphId) || !isEvidenceIdentifier(value.nodeId)) return false;
3303
+ if (!isNonNegativeInt(value.materializationVersion)) return false;
3304
+ return typeof value.state === "string" && typeof value.outcomeKind === "string";
3305
+ }
3306
+ if (value.patched === false) {
3307
+ return hasOnlyKeys2(value, ["patched", "refusalCode", "message"]) && typeof value.message === "string" && isOptionalString(value.refusalCode);
3308
+ }
3309
+ return false;
3310
+ }
3311
+ function decodeGraphNodePatchResponse(value) {
3312
+ return isGraphNodePatchResponse(value) ? value : null;
3313
+ }
3314
+ function isGraphViewQueryRequest(value) {
3315
+ if (!isRecord(value) || !hasOnlyKeys2(value, ["v", "meshId", "graphId", "batchId", "activeOnly", "limit", "probeGateEvidence"])) return false;
3316
+ if (value.v !== TURN_IPC_PROTOCOL_VERSION || !isEvidenceIdentifier(value.meshId)) return false;
3317
+ if (value.graphId !== void 0 && !isEvidenceIdentifier(value.graphId)) return false;
3318
+ if (value.batchId !== void 0 && !isEvidenceIdentifier(value.batchId)) return false;
3319
+ if (value.limit !== void 0 && !isNonNegativeInt(value.limit)) return false;
3320
+ return isOptionalBoolean(value.activeOnly) && isOptionalBoolean(value.probeGateEvidence);
3321
+ }
3322
+ function decodeGraphViewQueryRequest(value) {
3323
+ return isGraphViewQueryRequest(value) ? value : null;
3324
+ }
3325
+ function isGraphViewQueryResponse(value) {
3326
+ return isRecord(value) && hasOnlyKeys2(value, ["graphs"]) && isRecordArray(value.graphs);
3327
+ }
3328
+ function decodeGraphViewQueryResponse(value) {
3329
+ return isGraphViewQueryResponse(value) ? value : null;
3330
+ }
3331
+ function isTaskStatsQueryRequest(value) {
3332
+ if (!isRecord(value) || !hasOnlyKeys2(value, ["v", "meshId", "taskIds", "missionId", "tail", "rollup"])) return false;
3333
+ if (value.v !== TURN_IPC_PROTOCOL_VERSION || !isEvidenceIdentifier(value.meshId)) return false;
3334
+ if (value.taskIds !== void 0) {
3335
+ if (!Array.isArray(value.taskIds) || value.taskIds.length === 0 || !value.taskIds.every(isEvidenceIdentifier)) return false;
3336
+ }
3337
+ if (value.missionId !== void 0 && !isEvidenceIdentifier(value.missionId)) return false;
3338
+ if (value.tail !== void 0 && !isNonNegativeInt(value.tail)) return false;
3339
+ if (value.rollup === true && value.missionId === void 0) return false;
3340
+ return isOptionalBoolean(value.rollup);
3341
+ }
3342
+ function decodeTaskStatsQueryRequest(value) {
3343
+ return isTaskStatsQueryRequest(value) ? value : null;
3344
+ }
3345
+ function isTaskStatsQueryResponse(value) {
3346
+ return isRecord(value) && hasOnlyKeys2(value, ["tasks", "mission"]) && isRecordArray(value.tasks) && isOptionalRecord(value.mission);
3347
+ }
3348
+ function decodeTaskStatsQueryResponse(value) {
3349
+ return isTaskStatsQueryResponse(value) ? value : null;
3350
+ }
3351
+ function isPruneStaleDirectRequest(value) {
3352
+ if (!isRecord(value) || !hasOnlyKeys2(value, ["v", "meshId", "execute", "includeTerminal", "source"])) return false;
3353
+ if (value.v !== TURN_IPC_PROTOCOL_VERSION || !isEvidenceIdentifier(value.meshId)) return false;
3354
+ if (value.source !== void 0 && typeof value.source !== "string") return false;
3355
+ return isOptionalBoolean(value.execute) && isOptionalBoolean(value.includeTerminal);
3356
+ }
3357
+ function decodePruneStaleDirectRequest(value) {
3358
+ return isPruneStaleDirectRequest(value) ? value : null;
3359
+ }
3360
+ function isPruneStaleDirectResponse(value) {
3361
+ if (!isRecord(value) || !hasOnlyKeys2(value, ["mode", "includeTerminal", "candidateCount", "prunable", "prunedCount", "preservedUnacknowledged", "preservedLedgerOnly", "preservedNotOrphan"])) return false;
3362
+ if (value.mode !== "execute" && value.mode !== "dry_run") return false;
3363
+ if (typeof value.includeTerminal !== "boolean") return false;
3364
+ if (!isNonNegativeInt(value.candidateCount) || !isNonNegativeInt(value.prunedCount)) return false;
3365
+ return isRecordArray(value.prunable) && isRecordArray(value.preservedUnacknowledged) && isRecordArray(value.preservedLedgerOnly) && isRecordArray(value.preservedNotOrphan);
3366
+ }
3367
+ function decodePruneStaleDirectResponse(value) {
3368
+ return isPruneStaleDirectResponse(value) ? value : null;
3369
+ }
3370
+ function isOrphanedPinnedTaskWire(value) {
3371
+ if (!isRecord(value) || !hasOnlyKeys2(value, ["taskId", "title", "targetSessionId", "targetNodeId", "missionId"])) return false;
3372
+ if (!isEvidenceIdentifier(value.taskId) || !isEvidenceIdentifier(value.targetSessionId)) return false;
3373
+ if (typeof value.title !== "string") return false;
3374
+ if (value.targetNodeId !== void 0 && !isEvidenceIdentifier(value.targetNodeId)) return false;
3375
+ return value.missionId === void 0 || isEvidenceIdentifier(value.missionId);
3376
+ }
3377
+ function isOrphanedPinNotifyRequest(value) {
3378
+ if (!isRecord(value) || !hasOnlyKeys2(value, ["v", "meshId", "stoppedSessionId", "excludeTaskId", "cause", "nodeId", "coordinatorSessionId"])) return false;
3379
+ if (value.v !== TURN_IPC_PROTOCOL_VERSION || !isEvidenceIdentifier(value.meshId) || !isEvidenceIdentifier(value.stoppedSessionId)) return false;
3380
+ if (value.excludeTaskId !== void 0 && !isEvidenceIdentifier(value.excludeTaskId)) return false;
3381
+ if (value.cause !== void 0 && typeof value.cause !== "string") return false;
3382
+ if (value.nodeId !== void 0 && !isEvidenceIdentifier(value.nodeId)) return false;
3383
+ return value.coordinatorSessionId === void 0 || isEvidenceIdentifier(value.coordinatorSessionId);
3384
+ }
3385
+ function decodeOrphanedPinNotifyRequest(value) {
3386
+ return isOrphanedPinNotifyRequest(value) ? value : null;
3387
+ }
3388
+ function isOrphanedPinNotifyResponse(value) {
3389
+ return isRecord(value) && hasOnlyKeys2(value, ["orphans"]) && Array.isArray(value.orphans) && value.orphans.every(isOrphanedPinnedTaskWire);
3390
+ }
3391
+ function decodeOrphanedPinNotifyResponse(value) {
3392
+ return isOrphanedPinNotifyResponse(value) ? value : null;
3393
+ }
3394
+ var TURN_IPC_COMMANDS = [
3395
+ "turn_observe",
3396
+ "mesh_record",
3397
+ "turn_cancel",
3398
+ "operator_status",
3399
+ "turn_query",
3400
+ "mesh_index_query",
3401
+ "mission_upsert",
3402
+ "mission_query",
3403
+ "note_upsert",
3404
+ "note_forget",
3405
+ // C-W9b additions (2026-09-24 14:00 stamp "C-W9"):
3406
+ "tool_call_record",
3407
+ "ledger_query",
3408
+ "mission_list_query",
3409
+ // C-W9a additions (the event ledger retired; the queue behind IPC):
3410
+ "record_local",
3411
+ "queue_query",
3412
+ "queue_enqueue",
3413
+ "queue_enqueue_graph",
3414
+ "queue_cancel",
3415
+ "queue_requeue",
3416
+ "direct_dispatch_record",
3417
+ "graph_audit_record",
3418
+ "active_work_query",
3419
+ "recovery_context_query",
3420
+ // C-W9c additions (2026-09-24 19:00 stamp — the last mcp-server in-process
3421
+ // daemon-core paths: graph gates/plan/patch, mission reads (MAGI), task/
3422
+ // mission stats, orphaned-pin helpers, one prune audit):
3423
+ "graph_gate_claim",
3424
+ "graph_gate_release",
3425
+ "graph_gate_abandon",
3426
+ "graph_node_patch",
3427
+ "graph_view_query",
3428
+ "task_stats_query",
3429
+ "prune_stale_direct",
3430
+ "orphaned_pin_notify"
3431
+ ];
3432
+ var isTurnIpcCommand = makeGuard3(TURN_IPC_COMMANDS);
3433
+
3434
+ // src/path-ownership.ts
3435
+ var MAX_OWNED_PATHS = 64;
3436
+ function toPosix(raw) {
3437
+ return raw.replace(/\\/g, "/");
3438
+ }
3439
+ function normalizeOne(raw, rejected) {
3440
+ if (typeof raw !== "string") {
3441
+ rejected.push({ input: String(raw), reason: "not_a_string" });
3442
+ return null;
3443
+ }
3444
+ const trimmed = raw.trim();
3445
+ if (!trimmed) {
3446
+ rejected.push({ input: raw, reason: "empty" });
3447
+ return null;
3448
+ }
3449
+ let posix = toPosix(trimmed);
3450
+ if (posix.startsWith("/") || /^[a-zA-Z]:\//.test(posix) || posix.startsWith("~")) {
3451
+ rejected.push({ input: raw, reason: "absolute_path" });
3452
+ return null;
3453
+ }
3454
+ posix = posix.replace(/^\.\/+/, "");
3455
+ const segments = posix.split("/").filter(Boolean);
3456
+ if (segments.some((seg) => seg === "..")) {
3457
+ rejected.push({ input: raw, reason: "parent_traversal" });
3458
+ return null;
3459
+ }
3460
+ if (segments.length === 0) {
3461
+ rejected.push({ input: raw, reason: "empty" });
3462
+ return null;
3463
+ }
3464
+ let subtree = false;
3465
+ if (segments[segments.length - 1] === "**") {
3466
+ subtree = true;
3467
+ segments.pop();
3468
+ if (segments.length === 0) {
3469
+ }
3470
+ }
3471
+ if (segments.some((seg) => seg.includes("*") || seg.includes("?"))) {
3472
+ rejected.push({ input: raw, reason: "unsupported_glob" });
3473
+ return null;
3474
+ }
3475
+ return { path: segments.join("/"), subtree };
3476
+ }
3477
+ function normalizeOwnedPaths(input) {
3478
+ const rejected = [];
3479
+ if (input === void 0 || input === null) {
3480
+ return { declaration: { paths: [] }, rejected };
3481
+ }
3482
+ if (!Array.isArray(input)) {
3483
+ return { declaration: { paths: [] }, rejected: [{ input: String(input), reason: "not_an_array" }] };
3484
+ }
3485
+ const byPath = /* @__PURE__ */ new Map();
3486
+ for (const raw of input) {
3487
+ const entry = normalizeOne(raw, rejected);
3488
+ if (!entry) continue;
3489
+ const existing = byPath.get(entry.path);
3490
+ if (!existing) {
3491
+ byPath.set(entry.path, entry);
3492
+ } else if (entry.subtree && !existing.subtree) {
3493
+ byPath.set(entry.path, entry);
3494
+ }
3495
+ }
3496
+ const all = [...byPath.values()];
3497
+ const kept = all.slice(0, MAX_OWNED_PATHS);
3498
+ for (const dropped of all.slice(MAX_OWNED_PATHS)) {
3499
+ rejected.push({ input: dropped.path, reason: "over_cap" });
3500
+ }
3501
+ return { declaration: { paths: kept }, rejected };
3502
+ }
3503
+ function entryContains(base, path) {
3504
+ if (path === base.path) return true;
3505
+ if (base.subtree && (path === base.path || path.startsWith(`${base.path}/`))) return true;
3506
+ return false;
3507
+ }
3508
+ function entriesOverlap(a, b) {
3509
+ if (a.path === b.path) return true;
3510
+ if (a.subtree && (b.path === a.path || b.path.startsWith(`${a.path}/`))) return true;
3511
+ if (b.subtree && (a.path === b.path || a.path.startsWith(`${b.path}/`))) return true;
3512
+ return false;
3513
+ }
3514
+ function pathsOverlap(a, b) {
3515
+ if (a.paths.length === 0 || b.paths.length === 0) return false;
3516
+ for (const pa of a.paths) {
3517
+ for (const pb of b.paths) {
3518
+ if (entriesOverlap(pa, pb)) return true;
3519
+ }
3520
+ }
3521
+ return false;
3522
+ }
3523
+ function findOwnershipConflicts(candidate, inFlight) {
3524
+ if (candidate.paths.length === 0) return [];
3525
+ const conflicts = [];
3526
+ for (const other of inFlight) {
3527
+ if (other.paths.paths.length === 0) continue;
3528
+ const overlappingPaths = [];
3529
+ for (const pa of candidate.paths) {
3530
+ for (const pb of other.paths.paths) {
3531
+ if (entriesOverlap(pa, pb)) {
3532
+ const narrower = pa.path.length >= pb.path.length ? pa.path : pb.path;
3533
+ if (!overlappingPaths.includes(narrower)) overlappingPaths.push(narrower);
3534
+ }
3535
+ }
3536
+ }
3537
+ if (overlappingPaths.length > 0) {
3538
+ conflicts.push({ taskId: other.taskId, overlappingPaths });
3539
+ }
3540
+ }
3541
+ return conflicts;
3542
+ }
3543
+ function touchedFilesOutsideOwnership(touched, owned) {
3544
+ const undeclaredTouched = [];
3545
+ const usedDeclarations = /* @__PURE__ */ new Set();
3546
+ for (const raw of touched ?? []) {
3547
+ const rejectedSink = [];
3548
+ const entry = normalizeOne(raw, rejectedSink);
3549
+ if (!entry) {
3550
+ undeclaredTouched.push(raw);
3551
+ continue;
3552
+ }
3553
+ const matches = owned.paths.filter((base) => entryContains(base, entry.path));
3554
+ if (matches.length === 0) {
3555
+ undeclaredTouched.push(entry.path);
3556
+ } else {
3557
+ for (const m of matches) usedDeclarations.add(m.path);
3558
+ }
3559
+ }
3560
+ const unusedDeclarations = owned.paths.map((p) => p.path).filter((p) => !usedDeclarations.has(p));
3561
+ return { undeclaredTouched, unusedDeclarations };
3562
+ }
1093
3563
  // Annotate the CommonJS export names for ESM import in node:
1094
3564
  0 && (module.exports = {
3565
+ CANCEL_REASONS,
1095
3566
  CANONICAL_MESH_TOOL_COUNT,
1096
3567
  CANONICAL_MESH_TOOL_NAMES,
1097
3568
  CLAUDE_TUI_REVIEW_PAGE_NOT_FOCUSED_PREFIX,
1098
3569
  CLAUDE_TUI_REVIEW_UNCONFIRMED_PREFIX,
1099
3570
  CLI_SLOT_RECIPES,
3571
+ COMMIT_STRENGTHS,
3572
+ CONSUME_PROFILES,
3573
+ COORDINATOR_ACK_OUTCOMES,
3574
+ DAEMON_P2P_SIGNAL_TYPES,
3575
+ DAEMON_STATUS_EVENT_NAMES,
3576
+ DAEMON_TO_DASHBOARD_P2P_TYPES,
3577
+ DAEMON_TO_SERVER_TYPES,
1100
3578
  DAEMON_TO_SERVER_WS_MSGS,
3579
+ DASHBOARD_P2P_MESSAGE_KINDS,
3580
+ DASHBOARD_P2P_SIGNAL_TYPES,
3581
+ DASHBOARD_STATUS_EVENT_NAMES,
3582
+ DASHBOARD_TO_DAEMON_P2P_TYPES,
3583
+ DASHBOARD_TO_USER_SESSION_TYPES,
1101
3584
  DEFAULT_DIFFICULTY_BRAINS,
3585
+ DELIVERY_OUTCOMES,
3586
+ DELIVERY_VIAS,
3587
+ DISPATCH_FAILURE_REASONS,
3588
+ EVIDENCE_ENVELOPE_FIELD_SPECS,
3589
+ EVIDENCE_SOURCE_IDS,
3590
+ GRAPH_AUDIT_EVENTS,
3591
+ HOLD_REASONS,
3592
+ LIVENESS_RESULTS,
1102
3593
  MAGI_RAW_ANSWER_CAP,
3594
+ MAX_MESH_RECORD_STRING,
3595
+ MAX_OWNED_PATHS,
1103
3596
  MESH_CHUNK_KIND,
1104
3597
  MESH_CHUNK_PAYLOAD_CHARS,
1105
3598
  MESH_CHUNK_TTL_MS,
3599
+ MESH_DELIVERY_MODES,
3600
+ MESH_INDEX_QUERY_WRITER_SCOPES,
1106
3601
  MESH_MAX_CHUNKS,
1107
3602
  MESH_MAX_INLINE_FRAME_BYTES,
1108
3603
  MESH_MAX_REASSEMBLED_BYTES,
3604
+ MESH_MISSION_SOURCES,
3605
+ MESH_MISSION_STATUSES,
3606
+ MESH_P2P_SIGNAL_TYPES,
3607
+ MESH_RECORD_PAYLOAD_KEYS,
3608
+ MESH_SESSION_CLEANUP_MODES,
1109
3609
  MESH_TASK_DIFFICULTIES,
3610
+ MESH_TASK_MODES,
3611
+ MESH_TASK_PRIORITIES,
3612
+ MESH_TASK_STATUSES,
3613
+ MESH_TERMINAL_TASK_STATUSES,
3614
+ MESH_THINKING_LEVELS,
3615
+ MESH_TOPIC_ENTRY_KINDS,
3616
+ MESH_TOPIC_PROTOCOL_VERSION,
3617
+ MISSION_BRIEF_RENDER_MAX_CHARS,
3618
+ MODEL_AXIS_SOURCES,
3619
+ MODEL_SELECTION_HISTORY_LIMIT,
1110
3620
  MeshChunkAssembler,
3621
+ NATIVE_TURN_OUTCOMES,
3622
+ NOTIFY_KINDS,
3623
+ NO_PROGRESS_OBSERVED_STATUSES,
3624
+ NPM_UPDATE_TAGS,
3625
+ OPERATING_NOTE_CATEGORIES,
3626
+ OPERATOR_STATUSES,
3627
+ OPERATOR_STATUS_REASONS,
3628
+ OPERATOR_STATUS_REASON_VALUES,
3629
+ OPERATOR_STATUS_VALUES,
3630
+ OUTBOUND_MESSAGE_ORIGINS,
3631
+ P2P_SIGNAL_TYPES,
3632
+ PROVIDER_FAILURES,
1111
3633
  QUOTA_SUPPORTED_PROVIDERS,
3634
+ RECENT_SESSION_BUCKETS,
3635
+ RECLAIMING_SEND_REFUSALS,
3636
+ RELEASE_CHANNELS,
3637
+ RETIRED_MESH_TOOLS,
3638
+ SEND_POLICY_MODES,
3639
+ SEND_REFUSAL_REASONS,
3640
+ SERVER_STATUS_EVENT_NAMES,
3641
+ SERVER_TO_DAEMON_CONTROL_TYPES,
1112
3642
  SERVER_TO_DAEMON_WS_MSGS,
3643
+ SESSION_ERROR_REASONS,
3644
+ SESSION_LAUNCHED_BY,
3645
+ SESSION_REBOUND_REASONS,
3646
+ SESSION_STATUSES,
3647
+ SESSION_STATUS_ALIASES,
3648
+ SESSION_STATUS_CLASS,
3649
+ SHARED_SESSION_TO_VIEWER_TYPES,
1113
3650
  STATUS_PROBE_ARG_KEY,
3651
+ SUSPENSION_MODALS,
3652
+ SUSPENSION_RESOLUTIONS,
3653
+ SUSPENSION_RESOLUTION_VIAS,
3654
+ SYSTEM_ANNOUNCEMENT_TYPES,
3655
+ TERMINAL_CLASS_EVIDENCE_KINDS,
3656
+ TOOL_CALLER_ROLES,
3657
+ TURN_END_BLOCK_REASONS,
3658
+ TURN_END_STRENGTHS,
3659
+ TURN_EVIDENCE_FIELD_SPECS,
3660
+ TURN_EVIDENCE_FLAGS,
3661
+ TURN_EVIDENCE_KINDS,
3662
+ TURN_IPC_COMMANDS,
3663
+ TURN_IPC_ERROR_CODES,
3664
+ TURN_IPC_PROTOCOL_VERSION,
3665
+ TURN_OBSERVE_VERDICTS,
3666
+ TURN_OUTCOMES,
3667
+ TURN_REASONS,
3668
+ TURN_SCOPES,
1114
3669
  UNKNOWN_CLI_SLOT_RECIPE,
3670
+ USER_SESSION_TO_DASHBOARD_TYPES,
3671
+ VERSION_UPDATE_REASONS,
3672
+ VIEWER_TO_SHARED_SESSION_TYPES,
3673
+ WORKER_BRANCH_STATES,
3674
+ WORKER_PROTOCOL_FOOTER_MARKER,
3675
+ WORKER_REPORT_OUTCOMES,
3676
+ WORKER_TOOLS,
3677
+ appendWorkerProtocolFooter,
1115
3678
  argsCarryStatusProbeMarker,
1116
3679
  buildMagiPanelProposal,
1117
3680
  buildSlotProposal,
1118
3681
  canonicalDaemonId,
3682
+ classifySessionStatus,
1119
3683
  compareSemver,
1120
3684
  daemonIdsEquivalent,
3685
+ decodeActiveWorkQueryRequest,
3686
+ decodeActiveWorkQueryResponse,
3687
+ decodeDaemonToDashboardP2P,
3688
+ decodeDaemonToServer,
3689
+ decodeDashboardToDaemonP2P,
3690
+ decodeDashboardToDaemonP2PChunk,
3691
+ decodeDashboardToUserSession,
3692
+ decodeDirectDispatchRecordRequest,
3693
+ decodeDirectDispatchRecordResponse,
3694
+ decodeGraphAuditRecordRequest,
3695
+ decodeGraphAuditRecordResponse,
3696
+ decodeGraphGateAbandonRequest,
3697
+ decodeGraphGateAbandonResponse,
3698
+ decodeGraphGateClaimRequest,
3699
+ decodeGraphGateClaimResponse,
3700
+ decodeGraphGateReleaseRequest,
3701
+ decodeGraphGateReleaseResponse,
3702
+ decodeGraphNodePatchRequest,
3703
+ decodeGraphNodePatchResponse,
3704
+ decodeGraphViewQueryRequest,
3705
+ decodeGraphViewQueryResponse,
3706
+ decodeLedgerQueryRequest,
3707
+ decodeLedgerQueryResponse,
3708
+ decodeMeshIndexQueryRequest,
3709
+ decodeMeshIndexQueryResponse,
3710
+ decodeMeshRecordRequest,
3711
+ decodeMeshRecordResponse,
3712
+ decodeMissionListQueryRequest,
3713
+ decodeMissionListQueryResponse,
3714
+ decodeMissionQueryRequest,
3715
+ decodeMissionQueryResponse,
3716
+ decodeMissionUpsertRequest,
3717
+ decodeMissionUpsertResponse,
3718
+ decodeNoteForgetRequest,
3719
+ decodeNoteForgetResponse,
3720
+ decodeNoteUpsertRequest,
3721
+ decodeNoteUpsertResponse,
3722
+ decodeOperatorStatusRequest,
3723
+ decodeOperatorStatusResponse,
3724
+ decodeOrphanedPinNotifyRequest,
3725
+ decodeOrphanedPinNotifyResponse,
3726
+ decodePruneStaleDirectRequest,
3727
+ decodePruneStaleDirectResponse,
3728
+ decodeQueueCancelRequest,
3729
+ decodeQueueCancelResponse,
3730
+ decodeQueueEnqueueGraphRequest,
3731
+ decodeQueueEnqueueGraphResponse,
3732
+ decodeQueueEnqueueRequest,
3733
+ decodeQueueEnqueueResponse,
3734
+ decodeQueueQueryRequest,
3735
+ decodeQueueQueryResponse,
3736
+ decodeQueueRequeueRequest,
3737
+ decodeQueueRequeueResponse,
3738
+ decodeRecordLocalRequest,
3739
+ decodeRecordLocalResponse,
3740
+ decodeRecoveryContextQueryRequest,
3741
+ decodeRecoveryContextQueryResponse,
3742
+ decodeServerToDaemon,
3743
+ decodeTaskStatsQueryRequest,
3744
+ decodeTaskStatsQueryResponse,
3745
+ decodeToolCallRecordRequest,
3746
+ decodeToolCallRecordResponse,
3747
+ decodeTurnCancelRequest,
3748
+ decodeTurnCancelResponse,
3749
+ decodeTurnObserveRequest,
3750
+ decodeTurnObserveResponse,
3751
+ decodeTurnQueryRequest,
3752
+ decodeTurnQueryResponse,
3753
+ decodeTypeField,
3754
+ decodeUserSessionToDashboard,
3755
+ decodeViewerToSharedSession,
1121
3756
  deriveProviderPriorityFromSlots,
1122
3757
  deriveSlotsFromLegacy,
3758
+ describeModelSelection,
3759
+ effectiveModelSelectionValue,
3760
+ enumOf,
1123
3761
  expandDaemonIdForms,
3762
+ findOwnershipConflicts,
1124
3763
  formatQuotaAccount,
1125
3764
  hasGitStatusEvidence,
3765
+ hasWorkerProtocolFooter,
1126
3766
  interpolateArgs,
1127
3767
  interpolateString,
3768
+ isActiveWorkQueryRequest,
3769
+ isActiveWorkQueryResponse,
3770
+ isBlockedStatus,
3771
+ isBusyStatus,
3772
+ isChunkType,
3773
+ isCommitStrength,
3774
+ isDaemonDirectCommandType,
3775
+ isDaemonP2PSignalType,
3776
+ isDaemonStatusEventName,
3777
+ isDaemonToDashboardP2PType,
3778
+ isDaemonToServerType,
1128
3779
  isDaemonToServerWsMsg,
3780
+ isDashboardP2PSignalType,
3781
+ isDashboardStatusEventName,
3782
+ isDashboardToDaemonChunkType,
3783
+ isDashboardToDaemonP2PType,
3784
+ isDashboardToUserSessionType,
3785
+ isDeadStatus,
3786
+ isDirectDispatchRecordRequest,
3787
+ isDirectDispatchRecordResponse,
1129
3788
  isDowngrade,
3789
+ isEvidenceIdentifier,
3790
+ isEvidenceSourceId,
3791
+ isFiniteNumber,
3792
+ isGraphAuditEvent,
3793
+ isGraphAuditRecordRequest,
3794
+ isGraphAuditRecordResponse,
3795
+ isGraphGateAbandonRequest,
3796
+ isGraphGateAbandonResponse,
3797
+ isGraphGateClaimRequest,
3798
+ isGraphGateClaimResponse,
3799
+ isGraphGateReleaseRequest,
3800
+ isGraphGateReleaseResponse,
3801
+ isGraphNodePatchRequest,
3802
+ isGraphNodePatchResponse,
3803
+ isGraphViewQueryRequest,
3804
+ isGraphViewQueryResponse,
3805
+ isHoldReason,
3806
+ isInputEnvelopeWire,
3807
+ isLedgerQueryRequest,
3808
+ isLedgerQueryResponse,
3809
+ isMeshDeliveryMode,
3810
+ isMeshIndexQueryRequest,
3811
+ isMeshIndexQueryResponse,
3812
+ isMeshIndexQueryWriterScope,
3813
+ isMeshMissionSourceValue,
3814
+ isMeshMissionStatusValue,
3815
+ isMeshP2PSignalType,
3816
+ isMeshRecordPayload,
3817
+ isMeshRecordRequest,
3818
+ isMeshRecordResponse,
3819
+ isMeshSessionCleanupMode,
1130
3820
  isMeshTaskDifficulty,
3821
+ isMeshTaskMode,
3822
+ isMeshTaskPriority,
3823
+ isMeshTaskStatus,
3824
+ isMeshTerminalTaskStatus,
3825
+ isMeshThinkingLevel,
3826
+ isMeshTopicEntry,
3827
+ isMeshTopicEntryKind,
3828
+ isMessageId,
3829
+ isMissionListQueryRequest,
3830
+ isMissionListQueryResponse,
3831
+ isMissionQueryRequest,
3832
+ isMissionQueryResponse,
3833
+ isMissionUpsertRequest,
3834
+ isMissionUpsertResponse,
3835
+ isModelAxisSource,
3836
+ isNonEmptyString,
3837
+ isNoteForgetRequest,
3838
+ isNoteForgetResponse,
3839
+ isNoteUpsertRequest,
3840
+ isNoteUpsertResponse,
3841
+ isNotifyKind,
3842
+ isOperatingNoteCategory,
3843
+ isOperatorStatusReasonValue,
3844
+ isOperatorStatusRequest,
3845
+ isOperatorStatusResponse,
3846
+ isOperatorStatusValue,
3847
+ isOrphanedPinNotifyRequest,
3848
+ isOrphanedPinNotifyResponse,
3849
+ isOutboundMessage,
3850
+ isOutboundMessageOrigin,
3851
+ isP2PSignalType,
1131
3852
  isPhantomDaemonEntry,
3853
+ isPruneStaleDirectRequest,
3854
+ isPruneStaleDirectResponse,
3855
+ isQueueCancelRequest,
3856
+ isQueueCancelResponse,
3857
+ isQueueEnqueueGraphRequest,
3858
+ isQueueEnqueueGraphResponse,
3859
+ isQueueEnqueueRequest,
3860
+ isQueueEnqueueResponse,
3861
+ isQueueQueryRequest,
3862
+ isQueueQueryResponse,
3863
+ isQueueRequeueRequest,
3864
+ isQueueRequeueResponse,
1132
3865
  isRawDaemonDoId,
3866
+ isReadyStatus,
3867
+ isRecord,
3868
+ isRecordLocalRequest,
3869
+ isRecordLocalResponse,
3870
+ isRecoveryContextQueryRequest,
3871
+ isRecoveryContextQueryResponse,
3872
+ isSendPolicy,
3873
+ isSendPolicyMode,
3874
+ isSendRefusal,
3875
+ isServerDirectCommandMsg,
3876
+ isServerToDaemonControlType,
1133
3877
  isServerToDaemonWsMsg,
3878
+ isSessionLaunchedBy,
3879
+ isSessionStatus,
3880
+ isSharedSessionToViewerType,
3881
+ isSubmitOutcome,
3882
+ isSummaryRef,
3883
+ isTaskStatsQueryRequest,
3884
+ isTaskStatsQueryResponse,
3885
+ isTerminalClassEvidenceKind,
3886
+ isToolCallRecordRequest,
3887
+ isToolCallRecordResponse,
3888
+ isToolCallerRole,
3889
+ isTurnAttemptRef,
3890
+ isTurnCancelRequest,
3891
+ isTurnCancelResponse,
3892
+ isTurnEvidence,
3893
+ isTurnEvidenceKind,
3894
+ isTurnIpcCommand,
3895
+ isTurnIpcError,
3896
+ isTurnIpcErrorCode,
3897
+ isTurnObserveRequest,
3898
+ isTurnObserveResponse,
3899
+ isTurnObserveVerdict,
3900
+ isTurnOutcome,
3901
+ isTurnQueryRequest,
3902
+ isTurnQueryResponse,
3903
+ isTurnReason,
3904
+ isUserSessionToDashboardType,
3905
+ isViewerToSharedSessionType,
3906
+ isWorkerBranchState,
3907
+ isWorkerReportOutcome,
3908
+ isWorkerTool,
3909
+ isWorkingStatus,
1134
3910
  joinRepoPath,
3911
+ launchModelSelectionValue,
1135
3912
  machineCoreFromDaemonId,
3913
+ makeTypeGuard,
1136
3914
  measureWorstCaseChunkEnvelopeBytes,
1137
3915
  meshFrameNeedsChunking,
1138
3916
  meshNodeIdMatches,
1139
3917
  meshUtf8ByteLength,
1140
3918
  meshWorkspacesEquivalent,
3919
+ mintMessageId,
3920
+ normalizeAuthOkLimits,
1141
3921
  normalizeBrainSlot,
1142
3922
  normalizeDifficultyBrainMap,
1143
3923
  normalizeGitStatus,
@@ -1145,25 +3925,41 @@ var CLAUDE_TUI_REVIEW_UNCONFIRMED_PREFIX = "Claude TUI answer delivered but not
1145
3925
  normalizeMeshNodeId,
1146
3926
  normalizeMeshSessionRecord,
1147
3927
  normalizeMeshWorkspaceForCompare,
3928
+ normalizeMissionBrief,
1148
3929
  normalizeNodeCapabilitySlot,
1149
3930
  normalizeNodeCapabilitySlots,
3931
+ normalizeOwnedPaths,
3932
+ normalizeSessionStatus,
1150
3933
  normalizeThinkingLevel,
1151
3934
  parseJsonRecord,
1152
3935
  parseSemver,
3936
+ parseSessionLaunchRecord,
3937
+ pathsOverlap,
1153
3938
  pickBestTransitGitStatus,
3939
+ projectTurnEvidenceEntry,
1154
3940
  readBoolean,
3941
+ readEnvelopeFields,
1155
3942
  readGitSubmodules,
1156
3943
  readNumber,
1157
3944
  readRecord,
1158
3945
  readString,
1159
3946
  readStringArray,
3947
+ renderCoordinatorWorkerSection,
3948
+ renderMissionBriefBlock,
3949
+ renderWorkerProtocolFooter,
3950
+ retiredMeshToolError,
3951
+ sanitizeModelIdentifier,
3952
+ sanitizeRefusalCode,
1160
3953
  scoreGitStatusCandidate,
1161
3954
  scoreGitUpstreamFreshness,
1162
3955
  sessionIdsEquivalent,
1163
3956
  splitMeshFrame,
3957
+ statusesOfClass,
1164
3958
  stripStatusProbeMarker,
3959
+ stripWorkerProtocolFooter,
1165
3960
  summarizeGitShape,
1166
3961
  supportsQuota,
3962
+ touchedFilesOutsideOwnership,
1167
3963
  withStatusProbeMarker
1168
3964
  });
1169
3965
  //# sourceMappingURL=index.js.map