@adhdev/mesh-shared 1.0.60-rc.9 → 1.0.61-rc.1

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