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