@adhdev/mesh-shared 1.0.60-rc.4 → 1.0.60-rc.41
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +10 -0
- package/dist/index.js +2764 -17
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +2441 -17
- package/dist/index.mjs.map +1 -1
- package/dist/mesh-tool-names.d.ts +2 -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 +388 -0
- package/dist/protocol/dashboard-daemon-p2p.d.ts +212 -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/turn-evidence.d.ts +407 -0
- package/dist/turn-ipc.d.ts +974 -0
- package/dist/worker-protocol.d.ts +69 -0
- package/dist/ws-protocol.d.ts +71 -41
- package/package.json +1 -1
- package/src/index.ts +10 -0
- package/src/mesh-tool-names.ts +0 -1
- 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 +552 -0
- package/src/protocol/dashboard-daemon-p2p.ts +272 -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/turn-evidence.ts +562 -0
- package/src/turn-ipc.ts +2231 -0
- package/src/worker-protocol.ts +142 -0
- package/src/ws-protocol.ts +102 -93
package/dist/index.mjs
CHANGED
|
@@ -287,8 +287,8 @@ function meshWorkspacesEquivalent(a, b) {
|
|
|
287
287
|
|
|
288
288
|
// src/daemon-normalize.ts
|
|
289
289
|
var DAEMON_ID_PREFIXES = ["daemon_", "standalone_"];
|
|
290
|
-
function isRawDaemonDoId(
|
|
291
|
-
const trimmed = readString(
|
|
290
|
+
function isRawDaemonDoId(id2) {
|
|
291
|
+
const trimmed = readString(id2);
|
|
292
292
|
return !!trimmed && /^[0-9a-f]{64}$/i.test(trimmed);
|
|
293
293
|
}
|
|
294
294
|
function isPhantomDaemonEntry(entry) {
|
|
@@ -299,8 +299,8 @@ function isPhantomDaemonEntry(entry) {
|
|
|
299
299
|
);
|
|
300
300
|
return !hasMachineEvidence;
|
|
301
301
|
}
|
|
302
|
-
function machineCoreFromDaemonId(
|
|
303
|
-
const trimmed = readString(
|
|
302
|
+
function machineCoreFromDaemonId(id2) {
|
|
303
|
+
const trimmed = readString(id2);
|
|
304
304
|
if (!trimmed) return void 0;
|
|
305
305
|
for (const prefix of DAEMON_ID_PREFIXES) {
|
|
306
306
|
if (trimmed.startsWith(prefix)) {
|
|
@@ -310,8 +310,8 @@ function machineCoreFromDaemonId(id) {
|
|
|
310
310
|
}
|
|
311
311
|
return trimmed;
|
|
312
312
|
}
|
|
313
|
-
function canonicalDaemonId(
|
|
314
|
-
const core = machineCoreFromDaemonId(
|
|
313
|
+
function canonicalDaemonId(id2) {
|
|
314
|
+
const core = machineCoreFromDaemonId(id2);
|
|
315
315
|
if (!core) return void 0;
|
|
316
316
|
if (!core.startsWith("mach_")) return core;
|
|
317
317
|
return `daemon_${core}`;
|
|
@@ -704,7 +704,6 @@ var CANONICAL_MESH_TOOL_NAMES = [
|
|
|
704
704
|
"mesh_record_note",
|
|
705
705
|
"mesh_forget_note",
|
|
706
706
|
"mesh_reconcile_ledger",
|
|
707
|
-
"mesh_requeue_held_events",
|
|
708
707
|
"mesh_mission_upsert",
|
|
709
708
|
"mesh_mission_list",
|
|
710
709
|
"mesh_review_inbox",
|
|
@@ -957,8 +956,54 @@ function isDowngrade(current, target) {
|
|
|
957
956
|
return direction < 0;
|
|
958
957
|
}
|
|
959
958
|
|
|
960
|
-
// src/
|
|
961
|
-
|
|
959
|
+
// src/protocol/envelope.ts
|
|
960
|
+
function isRecord(value) {
|
|
961
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
962
|
+
}
|
|
963
|
+
function isNonEmptyString(value) {
|
|
964
|
+
return typeof value === "string" && value.length > 0;
|
|
965
|
+
}
|
|
966
|
+
function isFiniteNumber(value) {
|
|
967
|
+
return typeof value === "number" && Number.isFinite(value);
|
|
968
|
+
}
|
|
969
|
+
function makeTypeGuard(names) {
|
|
970
|
+
const set = new Set(names);
|
|
971
|
+
return (value) => typeof value === "string" && set.has(value);
|
|
972
|
+
}
|
|
973
|
+
function decodeTypeField(raw, isType) {
|
|
974
|
+
if (!isRecord(raw)) return null;
|
|
975
|
+
if (!isType(raw.type)) return null;
|
|
976
|
+
return { type: raw.type, frame: raw };
|
|
977
|
+
}
|
|
978
|
+
function readEnvelopeFields(frame) {
|
|
979
|
+
return {
|
|
980
|
+
...isNonEmptyString(frame.id) ? { id: frame.id } : {},
|
|
981
|
+
...isFiniteNumber(frame.timestamp) ? { timestamp: frame.timestamp } : {}
|
|
982
|
+
};
|
|
983
|
+
}
|
|
984
|
+
|
|
985
|
+
// src/protocol/daemon-server.ts
|
|
986
|
+
var DAEMON_STATUS_EVENT_NAMES = [
|
|
987
|
+
"agent:generating_started",
|
|
988
|
+
"agent:waiting_approval",
|
|
989
|
+
"agent:waiting_choice",
|
|
990
|
+
"agent:generating_completed",
|
|
991
|
+
"agent:stopped",
|
|
992
|
+
"monitor:no_progress",
|
|
993
|
+
/** Legacy alias for `monitor:no_progress`, still emitted by older daemons. */
|
|
994
|
+
"monitor:long_generating"
|
|
995
|
+
];
|
|
996
|
+
var isDaemonStatusEventName = makeTypeGuard(DAEMON_STATUS_EVENT_NAMES);
|
|
997
|
+
var RELEASE_CHANNELS = ["stable", "preview"];
|
|
998
|
+
var NPM_UPDATE_TAGS = ["latest", "next"];
|
|
999
|
+
var VERSION_UPDATE_REASONS = ["force_update_below", "major_minor_mismatch", "patch_mismatch", "daemon_ahead"];
|
|
1000
|
+
var P2P_SIGNAL_TYPES = ["p2p_ready", "p2p_offer", "p2p_answer", "p2p_ice"];
|
|
1001
|
+
var isP2PSignalType = makeTypeGuard(P2P_SIGNAL_TYPES);
|
|
1002
|
+
var DAEMON_P2P_SIGNAL_TYPES = ["p2p_offer", "p2p_ice"];
|
|
1003
|
+
var isDaemonP2PSignalType = makeTypeGuard(DAEMON_P2P_SIGNAL_TYPES);
|
|
1004
|
+
var MESH_P2P_SIGNAL_TYPES = ["mesh_p2p_ready", "mesh_p2p_offer", "mesh_p2p_answer", "mesh_p2p_ice"];
|
|
1005
|
+
var isMeshP2PSignalType = makeTypeGuard(MESH_P2P_SIGNAL_TYPES);
|
|
1006
|
+
var DAEMON_TO_SERVER_TYPES = [
|
|
962
1007
|
"auth",
|
|
963
1008
|
"status_report",
|
|
964
1009
|
"status_heartbeat",
|
|
@@ -966,10 +1011,29 @@ var DAEMON_TO_SERVER_WS_MSGS = [
|
|
|
966
1011
|
"command_result",
|
|
967
1012
|
"error",
|
|
968
1013
|
"agent_event",
|
|
969
|
-
"
|
|
970
|
-
"
|
|
1014
|
+
"beacon_vectors",
|
|
1015
|
+
"daemon_mesh_command",
|
|
1016
|
+
"p2p_offer",
|
|
1017
|
+
"p2p_ice"
|
|
971
1018
|
];
|
|
972
|
-
var
|
|
1019
|
+
var isDaemonToServerType = makeTypeGuard(DAEMON_TO_SERVER_TYPES);
|
|
1020
|
+
function decodeDaemonToServer(raw) {
|
|
1021
|
+
if (!isRecord(raw) || !isDaemonToServerType(raw.type)) return null;
|
|
1022
|
+
if (raw.type === "daemon_mesh_command") {
|
|
1023
|
+
return {
|
|
1024
|
+
type: "daemon_mesh_command",
|
|
1025
|
+
requestId: typeof raw.requestId === "string" ? raw.requestId : String(raw.requestId ?? ""),
|
|
1026
|
+
targetDaemonId: typeof raw.targetDaemonId === "string" ? raw.targetDaemonId : "",
|
|
1027
|
+
command: raw.command,
|
|
1028
|
+
args: isRecord(raw.args) ? raw.args : {},
|
|
1029
|
+
timestamp: typeof raw.timestamp === "number" ? raw.timestamp : Date.now()
|
|
1030
|
+
};
|
|
1031
|
+
}
|
|
1032
|
+
if (!isRecord(raw.payload)) return null;
|
|
1033
|
+
if (raw.type === "auth" && !isNonEmptyString(raw.payload.token)) return null;
|
|
1034
|
+
return { type: raw.type, payload: raw.payload, ...readEnvelopeFields(raw) };
|
|
1035
|
+
}
|
|
1036
|
+
var SERVER_TO_DAEMON_CONTROL_TYPES = [
|
|
973
1037
|
"auth_ok",
|
|
974
1038
|
"auth_error",
|
|
975
1039
|
"machine_evicted",
|
|
@@ -980,65 +1044,2411 @@ var SERVER_TO_DAEMON_WS_MSGS = [
|
|
|
980
1044
|
"command",
|
|
981
1045
|
"agent_command",
|
|
982
1046
|
"resolve_action",
|
|
983
|
-
"beacon_vectors_result"
|
|
1047
|
+
"beacon_vectors_result",
|
|
1048
|
+
"daemon_mesh_result",
|
|
1049
|
+
"p2p_ready",
|
|
1050
|
+
"p2p_offer",
|
|
1051
|
+
"p2p_answer",
|
|
1052
|
+
"p2p_ice",
|
|
1053
|
+
"mesh_p2p_ready",
|
|
1054
|
+
"mesh_p2p_offer",
|
|
1055
|
+
"mesh_p2p_answer",
|
|
1056
|
+
"mesh_p2p_ice"
|
|
1057
|
+
];
|
|
1058
|
+
var isServerToDaemonControlType = makeTypeGuard(SERVER_TO_DAEMON_CONTROL_TYPES);
|
|
1059
|
+
function isServerDirectCommandMsg(msg) {
|
|
1060
|
+
return !isServerToDaemonControlType(msg.type);
|
|
1061
|
+
}
|
|
1062
|
+
var DIRECT_COMMAND_TYPE_PATTERN = /^[a-z][a-z0-9_:.-]{0,63}$/;
|
|
1063
|
+
function isDaemonDirectCommandType(value) {
|
|
1064
|
+
return typeof value === "string" && DIRECT_COMMAND_TYPE_PATTERN.test(value) && !isServerToDaemonControlType(value);
|
|
1065
|
+
}
|
|
1066
|
+
function decodeServerToDaemon(raw) {
|
|
1067
|
+
if (!isRecord(raw) || typeof raw.type !== "string") return null;
|
|
1068
|
+
const relay = {
|
|
1069
|
+
...readEnvelopeFields(raw),
|
|
1070
|
+
...isNonEmptyString(raw.source) ? { source: raw.source } : {}
|
|
1071
|
+
};
|
|
1072
|
+
if (raw.type === "beacon_vectors_result" || raw.type === "daemon_mesh_result") {
|
|
1073
|
+
if (!isNonEmptyString(raw.requestId)) return null;
|
|
1074
|
+
const base = { requestId: raw.requestId, success: raw.success === true };
|
|
1075
|
+
if (raw.type === "beacon_vectors_result") {
|
|
1076
|
+
return {
|
|
1077
|
+
type: "beacon_vectors_result",
|
|
1078
|
+
...base,
|
|
1079
|
+
...Array.isArray(raw.reports) ? { reports: raw.reports } : {},
|
|
1080
|
+
...typeof raw.truncated === "number" ? { truncated: raw.truncated } : {},
|
|
1081
|
+
...typeof raw.error === "string" ? { error: raw.error } : {}
|
|
1082
|
+
};
|
|
1083
|
+
}
|
|
1084
|
+
return {
|
|
1085
|
+
type: "daemon_mesh_result",
|
|
1086
|
+
...base,
|
|
1087
|
+
..."result" in raw ? { result: raw.result } : {},
|
|
1088
|
+
...typeof raw.error === "string" ? { error: raw.error } : {}
|
|
1089
|
+
};
|
|
1090
|
+
}
|
|
1091
|
+
if (!isRecord(raw.payload)) return null;
|
|
1092
|
+
if (isServerToDaemonControlType(raw.type)) {
|
|
1093
|
+
return { type: raw.type, payload: raw.payload, ...relay };
|
|
1094
|
+
}
|
|
1095
|
+
if (!isDaemonDirectCommandType(raw.type)) return null;
|
|
1096
|
+
return { type: raw.type, payload: raw.payload, ...relay };
|
|
1097
|
+
}
|
|
1098
|
+
|
|
1099
|
+
// src/protocol/dashboard-server.ts
|
|
1100
|
+
var SERVER_STATUS_EVENT_NAMES = [
|
|
1101
|
+
"daemon:disconnect",
|
|
1102
|
+
"team:session_viewed",
|
|
1103
|
+
"team:view_request",
|
|
1104
|
+
"team:view_request_approved",
|
|
1105
|
+
"team:view_request_rejected"
|
|
984
1106
|
];
|
|
985
|
-
|
|
986
|
-
|
|
1107
|
+
var DASHBOARD_STATUS_EVENT_NAMES = [...DAEMON_STATUS_EVENT_NAMES, ...SERVER_STATUS_EVENT_NAMES];
|
|
1108
|
+
var isDashboardStatusEventName = makeTypeGuard(DASHBOARD_STATUS_EVENT_NAMES);
|
|
1109
|
+
var SYSTEM_ANNOUNCEMENT_TYPES = ["info", "warning", "critical"];
|
|
1110
|
+
var USER_SESSION_TO_DASHBOARD_TYPES = [
|
|
1111
|
+
"connected",
|
|
1112
|
+
"initial_state",
|
|
1113
|
+
"daemon_status",
|
|
1114
|
+
"status_event",
|
|
1115
|
+
"system_announcement",
|
|
1116
|
+
"auth_error",
|
|
1117
|
+
"heartbeat",
|
|
1118
|
+
"p2p_offer",
|
|
1119
|
+
"p2p_ice"
|
|
1120
|
+
];
|
|
1121
|
+
var isUserSessionToDashboardType = makeTypeGuard(USER_SESSION_TO_DASHBOARD_TYPES);
|
|
1122
|
+
function decodeUserSessionToDashboard(raw) {
|
|
1123
|
+
if (!isRecord(raw) || !isUserSessionToDashboardType(raw.type)) return null;
|
|
1124
|
+
if (raw.type === "heartbeat") {
|
|
1125
|
+
return { type: "heartbeat", payload: isRecord(raw.payload) ? raw.payload : {}, ...readEnvelopeFields(raw) };
|
|
1126
|
+
}
|
|
1127
|
+
if (!isRecord(raw.payload)) return null;
|
|
1128
|
+
return { type: raw.type, payload: raw.payload, ...readEnvelopeFields(raw) };
|
|
987
1129
|
}
|
|
988
|
-
|
|
989
|
-
|
|
1130
|
+
var DASHBOARD_TO_USER_SESSION_TYPES = ["heartbeat", "refresh", "p2p_ready", "p2p_answer", "p2p_ice"];
|
|
1131
|
+
var isDashboardToUserSessionType = makeTypeGuard(DASHBOARD_TO_USER_SESSION_TYPES);
|
|
1132
|
+
var DASHBOARD_P2P_SIGNAL_TYPES = ["p2p_ready", "p2p_answer", "p2p_ice"];
|
|
1133
|
+
var isDashboardP2PSignalType = makeTypeGuard(DASHBOARD_P2P_SIGNAL_TYPES);
|
|
1134
|
+
function decodeDashboardToUserSession(raw) {
|
|
1135
|
+
if (!isRecord(raw) || !isDashboardToUserSessionType(raw.type)) return null;
|
|
1136
|
+
if (raw.type === "heartbeat") return { type: "heartbeat", ...readEnvelopeFields(raw) };
|
|
1137
|
+
if (raw.type === "refresh") return { type: "refresh" };
|
|
1138
|
+
if (!isRecord(raw.payload) || typeof raw.payload.daemonId !== "string") return null;
|
|
1139
|
+
return { type: raw.type, payload: raw.payload, ...readEnvelopeFields(raw) };
|
|
1140
|
+
}
|
|
1141
|
+
var SHARED_SESSION_TO_VIEWER_TYPES = [
|
|
1142
|
+
"share:connected",
|
|
1143
|
+
"share:revoked",
|
|
1144
|
+
"share:expired",
|
|
1145
|
+
"share:error",
|
|
1146
|
+
"share:viewer_count",
|
|
1147
|
+
"p2p_offer",
|
|
1148
|
+
"p2p_ice"
|
|
1149
|
+
];
|
|
1150
|
+
var isSharedSessionToViewerType = makeTypeGuard(SHARED_SESSION_TO_VIEWER_TYPES);
|
|
1151
|
+
var VIEWER_TO_SHARED_SESSION_TYPES = ["p2p_ready", "p2p_offer", "p2p_answer", "p2p_ice"];
|
|
1152
|
+
var isViewerToSharedSessionType = makeTypeGuard(VIEWER_TO_SHARED_SESSION_TYPES);
|
|
1153
|
+
function decodeViewerToSharedSession(raw) {
|
|
1154
|
+
if (!isRecord(raw) || !isViewerToSharedSessionType(raw.type)) return null;
|
|
1155
|
+
const payload = isRecord(raw.payload) ? raw.payload : {};
|
|
1156
|
+
return { type: raw.type, payload, ...readEnvelopeFields(raw) };
|
|
1157
|
+
}
|
|
1158
|
+
|
|
1159
|
+
// src/protocol/dashboard-daemon-p2p.ts
|
|
1160
|
+
function isChunkType(value) {
|
|
1161
|
+
return typeof value === "string" && value.endsWith("_chunk") && value.length > "_chunk".length;
|
|
1162
|
+
}
|
|
1163
|
+
function readChunkFields(frame) {
|
|
1164
|
+
if (!isNonEmptyString(frame.chunkId)) return null;
|
|
1165
|
+
if (!Number.isInteger(frame.index) || !Number.isInteger(frame.total)) return null;
|
|
1166
|
+
if (typeof frame.data !== "string") return null;
|
|
1167
|
+
return {
|
|
1168
|
+
...isNonEmptyString(frame.id) ? { id: frame.id } : {},
|
|
1169
|
+
chunkId: frame.chunkId,
|
|
1170
|
+
index: frame.index,
|
|
1171
|
+
total: frame.total,
|
|
1172
|
+
data: frame.data
|
|
1173
|
+
};
|
|
1174
|
+
}
|
|
1175
|
+
var DASHBOARD_TO_DAEMON_P2P_TYPES = [
|
|
1176
|
+
"ping",
|
|
1177
|
+
"pong",
|
|
1178
|
+
"command",
|
|
1179
|
+
"input",
|
|
1180
|
+
"pty_input",
|
|
1181
|
+
"pty_resize",
|
|
1182
|
+
"screenshot_start",
|
|
1183
|
+
"screenshot_stop",
|
|
1184
|
+
"subscribe",
|
|
1185
|
+
"unsubscribe",
|
|
1186
|
+
"seqscribe_session_interest",
|
|
1187
|
+
"read",
|
|
1188
|
+
"write",
|
|
1189
|
+
"list"
|
|
1190
|
+
];
|
|
1191
|
+
var isDashboardToDaemonP2PType = makeTypeGuard(DASHBOARD_TO_DAEMON_P2P_TYPES);
|
|
1192
|
+
function isDashboardToDaemonChunkType(value) {
|
|
1193
|
+
return isChunkType(value) && isDashboardToDaemonP2PType(value.slice(0, -"_chunk".length));
|
|
1194
|
+
}
|
|
1195
|
+
var DASHBOARD_REQUEST_TYPES = /* @__PURE__ */ new Set(["command", "input", "read", "write", "list"]);
|
|
1196
|
+
function decodeDashboardToDaemonP2PChunk(raw) {
|
|
1197
|
+
if (!isRecord(raw) || !isDashboardToDaemonChunkType(raw.type)) return null;
|
|
1198
|
+
const fields = readChunkFields(raw);
|
|
1199
|
+
return fields ? { type: raw.type, ...fields } : null;
|
|
1200
|
+
}
|
|
1201
|
+
function decodeDashboardToDaemonP2P(raw) {
|
|
1202
|
+
if (!isRecord(raw) || !isDashboardToDaemonP2PType(raw.type)) return null;
|
|
1203
|
+
if (DASHBOARD_REQUEST_TYPES.has(raw.type) && !isNonEmptyString(raw.id)) return null;
|
|
1204
|
+
return raw;
|
|
1205
|
+
}
|
|
1206
|
+
var DAEMON_TO_DASHBOARD_P2P_TYPES = [
|
|
1207
|
+
"ping",
|
|
1208
|
+
"pong",
|
|
1209
|
+
"p2p_evicted",
|
|
1210
|
+
"status_report",
|
|
1211
|
+
"status_event",
|
|
1212
|
+
"topic_update",
|
|
1213
|
+
"topic_update_chunk",
|
|
1214
|
+
"session_output",
|
|
1215
|
+
"session_output_chunk",
|
|
1216
|
+
"session_io_error",
|
|
1217
|
+
"command_result",
|
|
1218
|
+
"command_result_chunk",
|
|
1219
|
+
"response"
|
|
1220
|
+
];
|
|
1221
|
+
var isDaemonToDashboardP2PType = makeTypeGuard(DAEMON_TO_DASHBOARD_P2P_TYPES);
|
|
1222
|
+
function decodeDaemonToDashboardP2P(raw) {
|
|
1223
|
+
if (!isRecord(raw)) return null;
|
|
1224
|
+
if (raw.type === void 0 && isNonEmptyString(raw.id) && typeof raw.success === "boolean") {
|
|
1225
|
+
return { ...raw, type: "response" };
|
|
1226
|
+
}
|
|
1227
|
+
if (!isDaemonToDashboardP2PType(raw.type)) return null;
|
|
1228
|
+
switch (raw.type) {
|
|
1229
|
+
case "ping":
|
|
1230
|
+
case "pong":
|
|
1231
|
+
case "p2p_evicted":
|
|
1232
|
+
return raw;
|
|
1233
|
+
case "status_report":
|
|
1234
|
+
case "status_event":
|
|
1235
|
+
return isRecord(raw.payload) ? raw : null;
|
|
1236
|
+
case "topic_update":
|
|
1237
|
+
return isRecord(raw.update) ? raw : null;
|
|
1238
|
+
case "topic_update_chunk":
|
|
1239
|
+
case "command_result_chunk":
|
|
1240
|
+
case "session_output_chunk": {
|
|
1241
|
+
const fields = readChunkFields(raw);
|
|
1242
|
+
if (!fields) return null;
|
|
1243
|
+
if (raw.type === "session_output_chunk") {
|
|
1244
|
+
return isNonEmptyString(raw.sessionId) ? { type: raw.type, sessionId: raw.sessionId, ...fields } : null;
|
|
1245
|
+
}
|
|
1246
|
+
return { type: raw.type, ...fields };
|
|
1247
|
+
}
|
|
1248
|
+
case "session_output":
|
|
1249
|
+
return isNonEmptyString(raw.sessionId) && typeof raw.data === "string" ? raw : null;
|
|
1250
|
+
case "session_io_error":
|
|
1251
|
+
return isNonEmptyString(raw.sessionId) ? raw : null;
|
|
1252
|
+
case "command_result":
|
|
1253
|
+
case "response":
|
|
1254
|
+
return isNonEmptyString(raw.id) ? raw : null;
|
|
1255
|
+
}
|
|
1256
|
+
}
|
|
1257
|
+
var DASHBOARD_P2P_MESSAGE_KINDS = [
|
|
1258
|
+
.../* @__PURE__ */ new Set([...DASHBOARD_TO_DAEMON_P2P_TYPES, ...DAEMON_TO_DASHBOARD_P2P_TYPES])
|
|
1259
|
+
];
|
|
1260
|
+
|
|
1261
|
+
// src/ws-protocol.ts
|
|
1262
|
+
var DAEMON_TO_SERVER_WS_MSGS = DAEMON_TO_SERVER_TYPES;
|
|
1263
|
+
var SERVER_TO_DAEMON_WS_MSGS = SERVER_TO_DAEMON_CONTROL_TYPES;
|
|
1264
|
+
var isDaemonToServerWsMsg = isDaemonToServerType;
|
|
1265
|
+
var isServerToDaemonWsMsg = isServerToDaemonControlType;
|
|
1266
|
+
function normalizeAuthOkLimits(raw) {
|
|
1267
|
+
if (!raw || typeof raw !== "object") return null;
|
|
1268
|
+
const src = raw;
|
|
1269
|
+
const num = (value, fallback) => typeof value === "number" && Number.isFinite(value) ? value : fallback;
|
|
1270
|
+
return {
|
|
1271
|
+
maxP2Pconnections: num(
|
|
1272
|
+
src.maxP2Pconnections !== void 0 ? src.maxP2Pconnections : src.maxP2PConnections,
|
|
1273
|
+
-1
|
|
1274
|
+
),
|
|
1275
|
+
screenshotIntervalSeconds: num(src.screenshotIntervalSeconds, 0),
|
|
1276
|
+
dailyScreenshotMinutes: num(src.dailyScreenshotMinutes, -1),
|
|
1277
|
+
maxMachines: num(src.maxMachines, -1)
|
|
1278
|
+
};
|
|
990
1279
|
}
|
|
991
1280
|
|
|
992
1281
|
// src/interactive-prompt-constants.ts
|
|
993
1282
|
var CLAUDE_TUI_REVIEW_PAGE_NOT_FOCUSED_PREFIX = "Claude TUI review page is not focused";
|
|
994
1283
|
var CLAUDE_TUI_REVIEW_UNCONFIRMED_PREFIX = "Claude TUI answer delivered but not confirmed";
|
|
1284
|
+
|
|
1285
|
+
// src/session-status.ts
|
|
1286
|
+
var SESSION_STATUSES = [
|
|
1287
|
+
"idle",
|
|
1288
|
+
"generating",
|
|
1289
|
+
"waiting_approval",
|
|
1290
|
+
"waiting_choice",
|
|
1291
|
+
"finalizing",
|
|
1292
|
+
"error",
|
|
1293
|
+
"stopped",
|
|
1294
|
+
"starting",
|
|
1295
|
+
"panel_hidden",
|
|
1296
|
+
"not_monitored",
|
|
1297
|
+
"disconnected"
|
|
1298
|
+
];
|
|
1299
|
+
var RECENT_SESSION_BUCKETS = ["needs_attention", "working", "task_complete", "idle"];
|
|
1300
|
+
var SESSION_STATUS_CLASS = {
|
|
1301
|
+
generating: "working",
|
|
1302
|
+
finalizing: "working",
|
|
1303
|
+
starting: "working",
|
|
1304
|
+
waiting_approval: "blocked",
|
|
1305
|
+
waiting_choice: "blocked",
|
|
1306
|
+
idle: "ready",
|
|
1307
|
+
panel_hidden: "ready",
|
|
1308
|
+
not_monitored: "ready",
|
|
1309
|
+
error: "dead",
|
|
1310
|
+
stopped: "dead",
|
|
1311
|
+
disconnected: "dead"
|
|
1312
|
+
};
|
|
1313
|
+
var SESSION_STATUS_ALIASES = {
|
|
1314
|
+
running: "generating",
|
|
1315
|
+
streaming: "generating",
|
|
1316
|
+
busy: "generating",
|
|
1317
|
+
working: "generating",
|
|
1318
|
+
loading: "generating",
|
|
1319
|
+
loading_reference: "generating",
|
|
1320
|
+
thinking: "generating",
|
|
1321
|
+
active: "generating",
|
|
1322
|
+
// Status-lane refinements of a turn that is still owned by the agent.
|
|
1323
|
+
no_progress: "generating",
|
|
1324
|
+
long_generating: "generating",
|
|
1325
|
+
initializing: "starting",
|
|
1326
|
+
waiting: "waiting_approval"
|
|
1327
|
+
};
|
|
1328
|
+
var SESSION_STATUS_SET = new Set(SESSION_STATUSES);
|
|
1329
|
+
function isSessionStatus(value) {
|
|
1330
|
+
return typeof value === "string" && SESSION_STATUS_SET.has(value);
|
|
1331
|
+
}
|
|
1332
|
+
function normalizeSessionStatus(raw) {
|
|
1333
|
+
if (typeof raw !== "string") return null;
|
|
1334
|
+
const value = raw.trim().toLowerCase();
|
|
1335
|
+
if (SESSION_STATUS_SET.has(value)) return value;
|
|
1336
|
+
return SESSION_STATUS_ALIASES[value] ?? null;
|
|
1337
|
+
}
|
|
1338
|
+
function classifySessionStatus(raw) {
|
|
1339
|
+
const status = normalizeSessionStatus(raw);
|
|
1340
|
+
return status ? SESSION_STATUS_CLASS[status] : "unknown";
|
|
1341
|
+
}
|
|
1342
|
+
function isWorkingStatus(raw) {
|
|
1343
|
+
return classifySessionStatus(raw) === "working";
|
|
1344
|
+
}
|
|
1345
|
+
function isBlockedStatus(raw) {
|
|
1346
|
+
return classifySessionStatus(raw) === "blocked";
|
|
1347
|
+
}
|
|
1348
|
+
function isReadyStatus(raw) {
|
|
1349
|
+
return classifySessionStatus(raw) === "ready";
|
|
1350
|
+
}
|
|
1351
|
+
function isDeadStatus(raw) {
|
|
1352
|
+
return classifySessionStatus(raw) === "dead";
|
|
1353
|
+
}
|
|
1354
|
+
function isBusyStatus(raw) {
|
|
1355
|
+
const cls = classifySessionStatus(raw);
|
|
1356
|
+
return cls === "working" || cls === "blocked";
|
|
1357
|
+
}
|
|
1358
|
+
function statusesOfClass(cls) {
|
|
1359
|
+
return SESSION_STATUSES.filter((status) => SESSION_STATUS_CLASS[status] === cls);
|
|
1360
|
+
}
|
|
1361
|
+
|
|
1362
|
+
// src/mesh-vocabulary.ts
|
|
1363
|
+
var MESH_TASK_STATUSES = ["pending", "assigned", "completed", "failed", "cancelled"];
|
|
1364
|
+
var MESH_TERMINAL_TASK_STATUSES = ["completed", "failed", "cancelled"];
|
|
1365
|
+
var MESH_TASK_MODES = ["code_change", "validation", "live_debug_readonly", "launch_app", "convergence"];
|
|
1366
|
+
var MESH_TASK_PRIORITIES = ["low", "normal", "high"];
|
|
1367
|
+
var MESH_THINKING_LEVELS = ["low", "medium", "high"];
|
|
1368
|
+
var MESH_DELIVERY_MODES = ["when_idle", "interrupt"];
|
|
1369
|
+
var MESH_SESSION_CLEANUP_MODES = ["preserve", "stop", "delete_stopped", "stop_and_delete"];
|
|
1370
|
+
var WORKER_REPORT_OUTCOMES = ["completed", "blocked", "failed"];
|
|
1371
|
+
var WORKER_BRANCH_STATES = [
|
|
1372
|
+
"merged_to_main",
|
|
1373
|
+
"pushed_feature_branch_needs_merge",
|
|
1374
|
+
"blocked_review",
|
|
1375
|
+
"cleanup_candidate",
|
|
1376
|
+
"not_mergeable"
|
|
1377
|
+
];
|
|
1378
|
+
function makeGuard(values) {
|
|
1379
|
+
const set = new Set(values);
|
|
1380
|
+
return (value) => typeof value === "string" && set.has(value);
|
|
1381
|
+
}
|
|
1382
|
+
var isMeshTaskStatus = makeGuard(MESH_TASK_STATUSES);
|
|
1383
|
+
var isMeshTerminalTaskStatus = makeGuard(MESH_TERMINAL_TASK_STATUSES);
|
|
1384
|
+
var isMeshTaskMode = makeGuard(MESH_TASK_MODES);
|
|
1385
|
+
var isMeshTaskPriority = makeGuard(MESH_TASK_PRIORITIES);
|
|
1386
|
+
var isMeshThinkingLevel = makeGuard(MESH_THINKING_LEVELS);
|
|
1387
|
+
var isMeshDeliveryMode = makeGuard(MESH_DELIVERY_MODES);
|
|
1388
|
+
var isMeshSessionCleanupMode = makeGuard(MESH_SESSION_CLEANUP_MODES);
|
|
1389
|
+
var isWorkerReportOutcome = makeGuard(WORKER_REPORT_OUTCOMES);
|
|
1390
|
+
var isWorkerBranchState = makeGuard(WORKER_BRANCH_STATES);
|
|
1391
|
+
function enumOf(values, description) {
|
|
1392
|
+
return {
|
|
1393
|
+
type: "string",
|
|
1394
|
+
enum: [...values],
|
|
1395
|
+
...description ? { description } : {}
|
|
1396
|
+
};
|
|
1397
|
+
}
|
|
1398
|
+
|
|
1399
|
+
// src/outbound-message.ts
|
|
1400
|
+
var outboundMessageIdCounter = 0;
|
|
1401
|
+
function mintMessageId(now = Date.now()) {
|
|
1402
|
+
try {
|
|
1403
|
+
const cryptoRef = typeof globalThis !== "undefined" ? globalThis.crypto : void 0;
|
|
1404
|
+
if (typeof cryptoRef?.randomUUID === "function") return `msg_${cryptoRef.randomUUID()}`;
|
|
1405
|
+
} catch {
|
|
1406
|
+
}
|
|
1407
|
+
outboundMessageIdCounter += 1;
|
|
1408
|
+
return `msg_${now}_${outboundMessageIdCounter}`;
|
|
1409
|
+
}
|
|
1410
|
+
var MESSAGE_ID_PREFIX = "msg_";
|
|
1411
|
+
function isMessageId(value) {
|
|
1412
|
+
return typeof value === "string" && value.length > MESSAGE_ID_PREFIX.length && value.startsWith(MESSAGE_ID_PREFIX);
|
|
1413
|
+
}
|
|
1414
|
+
var OUTBOUND_MESSAGE_ORIGINS = ["dashboard", "mcp", "mesh", "api", "cli"];
|
|
1415
|
+
function isOutboundMessageOrigin(value) {
|
|
1416
|
+
return typeof value === "string" && OUTBOUND_MESSAGE_ORIGINS.includes(value);
|
|
1417
|
+
}
|
|
1418
|
+
var SEND_POLICY_MODES = ["queue", "send_now", "interrupt"];
|
|
1419
|
+
function isSendPolicyMode(value) {
|
|
1420
|
+
return typeof value === "string" && SEND_POLICY_MODES.includes(value);
|
|
1421
|
+
}
|
|
1422
|
+
function isSendPolicy(value) {
|
|
1423
|
+
return !!value && typeof value === "object" && isSendPolicyMode(value.mode);
|
|
1424
|
+
}
|
|
1425
|
+
var SEND_REFUSAL_REASONS = [
|
|
1426
|
+
"not_ready",
|
|
1427
|
+
"send_in_flight",
|
|
1428
|
+
"not_generating",
|
|
1429
|
+
"not_supported",
|
|
1430
|
+
"platform_unsupported",
|
|
1431
|
+
"modal_parked",
|
|
1432
|
+
"interrupt_not_implemented",
|
|
1433
|
+
"interrupt_refused",
|
|
1434
|
+
"idle_timeout",
|
|
1435
|
+
"session_exited",
|
|
1436
|
+
"unsupported_input",
|
|
1437
|
+
"no_target",
|
|
1438
|
+
"bootstrap_pending",
|
|
1439
|
+
"duplicate_dispatch",
|
|
1440
|
+
"internal_error"
|
|
1441
|
+
];
|
|
1442
|
+
function isSendRefusal(value) {
|
|
1443
|
+
return typeof value === "string" && SEND_REFUSAL_REASONS.includes(value);
|
|
1444
|
+
}
|
|
1445
|
+
var SUBMIT_OUTCOME_KINDS = ["delivered", "queued", "duplicate", "refused"];
|
|
1446
|
+
function isSubmitOutcome(value) {
|
|
1447
|
+
if (!value || typeof value !== "object") return false;
|
|
1448
|
+
const kind = value.kind;
|
|
1449
|
+
if (typeof kind !== "string" || !SUBMIT_OUTCOME_KINDS.includes(kind)) return false;
|
|
1450
|
+
if (kind === "queued") return typeof value.position === "number";
|
|
1451
|
+
if (kind === "duplicate") return typeof value.of === "string";
|
|
1452
|
+
if (kind === "refused") return isSendRefusal(value.reason);
|
|
1453
|
+
return true;
|
|
1454
|
+
}
|
|
1455
|
+
function isInputPartWire(value) {
|
|
1456
|
+
if (!value || typeof value !== "object") return false;
|
|
1457
|
+
const type = value.type;
|
|
1458
|
+
return type === "text" || type === "image" || type === "audio" || type === "video" || type === "resource" || type === "resource_link";
|
|
1459
|
+
}
|
|
1460
|
+
function isInputEnvelopeWire(value) {
|
|
1461
|
+
if (!value || typeof value !== "object") return false;
|
|
1462
|
+
const parts = value.parts;
|
|
1463
|
+
const textFallback = value.textFallback;
|
|
1464
|
+
return Array.isArray(parts) && parts.every(isInputPartWire) && typeof textFallback === "string";
|
|
1465
|
+
}
|
|
1466
|
+
function isOutboundMessage(value) {
|
|
1467
|
+
if (!value || typeof value !== "object") return false;
|
|
1468
|
+
const candidate = value;
|
|
1469
|
+
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";
|
|
1470
|
+
}
|
|
1471
|
+
|
|
1472
|
+
// src/mission-brief.ts
|
|
1473
|
+
var GOAL_MAX = 500;
|
|
1474
|
+
var LIST_ITEM_MAX = 200;
|
|
1475
|
+
var LIST_MAX_ITEMS = 12;
|
|
1476
|
+
var MISSION_BRIEF_RENDER_MAX_CHARS = 1200;
|
|
1477
|
+
function truncateString(value, max) {
|
|
1478
|
+
if (value.length <= max) return value;
|
|
1479
|
+
return `${value.slice(0, max - 1).trimEnd()}\u2026`;
|
|
1480
|
+
}
|
|
1481
|
+
function normalizeStringList(value, field, truncated) {
|
|
1482
|
+
if (value === void 0 || value === null) return void 0;
|
|
1483
|
+
if (!Array.isArray(value)) return void 0;
|
|
1484
|
+
const items = [];
|
|
1485
|
+
let itemTruncated = false;
|
|
1486
|
+
for (const raw of value) {
|
|
1487
|
+
if (typeof raw !== "string") continue;
|
|
1488
|
+
const trimmed = raw.trim();
|
|
1489
|
+
if (!trimmed) continue;
|
|
1490
|
+
if (trimmed.length > LIST_ITEM_MAX) itemTruncated = true;
|
|
1491
|
+
items.push(truncateString(trimmed, LIST_ITEM_MAX));
|
|
1492
|
+
}
|
|
1493
|
+
if (itemTruncated) truncated.push({ field, reason: "item_too_long" });
|
|
1494
|
+
if (items.length > LIST_MAX_ITEMS) {
|
|
1495
|
+
truncated.push({ field, reason: "list_too_long" });
|
|
1496
|
+
return items.slice(0, LIST_MAX_ITEMS);
|
|
1497
|
+
}
|
|
1498
|
+
return items.length > 0 ? items : void 0;
|
|
1499
|
+
}
|
|
1500
|
+
function normalizeMissionBrief(input) {
|
|
1501
|
+
const truncated = [];
|
|
1502
|
+
if (!input || typeof input !== "object") {
|
|
1503
|
+
return { brief: null, truncated };
|
|
1504
|
+
}
|
|
1505
|
+
const raw = input;
|
|
1506
|
+
const rawGoal = typeof raw.goal === "string" ? raw.goal.trim() : "";
|
|
1507
|
+
if (!rawGoal) {
|
|
1508
|
+
return { brief: null, truncated };
|
|
1509
|
+
}
|
|
1510
|
+
if (rawGoal.length > GOAL_MAX) truncated.push({ field: "goal", reason: "field_too_long" });
|
|
1511
|
+
const goal = truncateString(rawGoal, GOAL_MAX);
|
|
1512
|
+
const constraints = normalizeStringList(raw.constraints, "constraints", truncated);
|
|
1513
|
+
const doneCriteria = normalizeStringList(raw.doneCriteria ?? raw.done_criteria, "doneCriteria", truncated);
|
|
1514
|
+
const handoffNotes = normalizeStringList(raw.handoffNotes ?? raw.handoff_notes, "handoffNotes", truncated);
|
|
1515
|
+
const ownedPaths = normalizeStringList(raw.ownedPaths ?? raw.owned_paths, "ownedPaths", truncated);
|
|
1516
|
+
const brief = { goal };
|
|
1517
|
+
if (constraints) brief.constraints = constraints;
|
|
1518
|
+
if (doneCriteria) brief.doneCriteria = doneCriteria;
|
|
1519
|
+
if (handoffNotes) brief.handoffNotes = handoffNotes;
|
|
1520
|
+
if (ownedPaths) brief.ownedPaths = ownedPaths;
|
|
1521
|
+
return { brief, truncated };
|
|
1522
|
+
}
|
|
1523
|
+
function renderList(heading, items) {
|
|
1524
|
+
if (!items || items.length === 0) return [];
|
|
1525
|
+
return [`${heading}:`, ...items.map((item) => `- ${item}`)];
|
|
1526
|
+
}
|
|
1527
|
+
function renderMissionBriefBlock(brief) {
|
|
1528
|
+
const sections = [`Mission goal: ${brief.goal}`];
|
|
1529
|
+
sections.push(...renderList("Constraints", brief.constraints));
|
|
1530
|
+
sections.push(...renderList("Done when", brief.doneCriteria));
|
|
1531
|
+
sections.push(...renderList("Owned paths", brief.ownedPaths));
|
|
1532
|
+
sections.push(...renderList("Handoff notes", brief.handoffNotes));
|
|
1533
|
+
const full = sections.join("\n");
|
|
1534
|
+
if (full.length <= MISSION_BRIEF_RENDER_MAX_CHARS) return full;
|
|
1535
|
+
const marker = "\n(brief truncated)";
|
|
1536
|
+
const budget = MISSION_BRIEF_RENDER_MAX_CHARS - marker.length;
|
|
1537
|
+
const lines = full.split("\n");
|
|
1538
|
+
let acc = "";
|
|
1539
|
+
for (const line of lines) {
|
|
1540
|
+
const next = acc ? `${acc}
|
|
1541
|
+
${line}` : line;
|
|
1542
|
+
if (next.length > budget) break;
|
|
1543
|
+
acc = next;
|
|
1544
|
+
}
|
|
1545
|
+
if (!acc) acc = truncateString(lines[0] ?? "", Math.max(budget, 0));
|
|
1546
|
+
return `${acc}${marker}`;
|
|
1547
|
+
}
|
|
1548
|
+
|
|
1549
|
+
// src/worker-protocol.ts
|
|
1550
|
+
var WORKER_TOOLS = [
|
|
1551
|
+
"report_completion",
|
|
1552
|
+
"progress_update",
|
|
1553
|
+
"peer_context_pull",
|
|
1554
|
+
"git_status",
|
|
1555
|
+
"git_log",
|
|
1556
|
+
"git_diff"
|
|
1557
|
+
];
|
|
1558
|
+
var WORKER_TOOL_SET = new Set(WORKER_TOOLS);
|
|
1559
|
+
function isWorkerTool(value) {
|
|
1560
|
+
return typeof value === "string" && WORKER_TOOL_SET.has(value);
|
|
1561
|
+
}
|
|
1562
|
+
var WORKER_PROTOCOL_FOOTER_MARKER = "--- adhdev worker protocol ---";
|
|
1563
|
+
function hasWorkerProtocolFooter(body) {
|
|
1564
|
+
return typeof body === "string" && body.includes(WORKER_PROTOCOL_FOOTER_MARKER);
|
|
1565
|
+
}
|
|
1566
|
+
function renderWorkerProtocolFooter(input = {}) {
|
|
1567
|
+
const briefBlock = input.missionBrief ? renderMissionBriefBlock(input.missionBrief) : null;
|
|
1568
|
+
const lines = briefBlock ? [briefBlock, "", WORKER_PROTOCOL_FOOTER_MARKER] : [WORKER_PROTOCOL_FOOTER_MARKER];
|
|
1569
|
+
const scope = [];
|
|
1570
|
+
if (input.taskId) scope.push(`task ${input.taskId}`);
|
|
1571
|
+
if (input.taskMode) scope.push(`mode ${input.taskMode}`);
|
|
1572
|
+
if (input.difficulty) scope.push(`difficulty ${input.difficulty}`);
|
|
1573
|
+
if (input.readonly) scope.push("read-only");
|
|
1574
|
+
if (scope.length) lines.push(`You are a delegated worker (${scope.join(", ")}).`);
|
|
1575
|
+
else lines.push("You are a delegated worker.");
|
|
1576
|
+
lines.push(
|
|
1577
|
+
"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.",
|
|
1578
|
+
"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.",
|
|
1579
|
+
"`peer_context_pull` shows what sibling tasks in this mission have reported; `git_status` / `git_diff` / `git_log` inspect your own workspace (pass its absolute path as `workspace`).",
|
|
1580
|
+
"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`."
|
|
1581
|
+
);
|
|
1582
|
+
if (input.enclosedHandoffNotes && input.enclosedHandoffNotes > 0) {
|
|
1583
|
+
lines.push(
|
|
1584
|
+
`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.`
|
|
1585
|
+
);
|
|
1586
|
+
}
|
|
1587
|
+
return lines.join("\n");
|
|
1588
|
+
}
|
|
1589
|
+
function stripWorkerProtocolFooter(body) {
|
|
1590
|
+
if (typeof body !== "string") return body;
|
|
1591
|
+
const at = body.indexOf(WORKER_PROTOCOL_FOOTER_MARKER);
|
|
1592
|
+
if (at < 0) return body;
|
|
1593
|
+
return body.slice(0, at).replace(/\s+$/, "");
|
|
1594
|
+
}
|
|
1595
|
+
function appendWorkerProtocolFooter(body, input = {}) {
|
|
1596
|
+
if (hasWorkerProtocolFooter(body)) return body;
|
|
1597
|
+
const trimmed = body.replace(/\s+$/, "");
|
|
1598
|
+
return `${trimmed}
|
|
1599
|
+
|
|
1600
|
+
${renderWorkerProtocolFooter(input)}`;
|
|
1601
|
+
}
|
|
1602
|
+
function renderCoordinatorWorkerSection() {
|
|
1603
|
+
return [
|
|
1604
|
+
"## Workers",
|
|
1605
|
+
"",
|
|
1606
|
+
`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.`,
|
|
1607
|
+
"- 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.",
|
|
1608
|
+
"- `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.",
|
|
1609
|
+
"- 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.",
|
|
1610
|
+
"- `mesh_status` is for node health and capacity before delegating, never for progress.",
|
|
1611
|
+
"- 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."
|
|
1612
|
+
].join("\n");
|
|
1613
|
+
}
|
|
1614
|
+
|
|
1615
|
+
// src/turn-evidence.ts
|
|
1616
|
+
var MESH_TOPIC_PROTOCOL_VERSION = 2;
|
|
1617
|
+
var EVIDENCE_SOURCE_IDS = [
|
|
1618
|
+
"fsm_edge",
|
|
1619
|
+
"short_gen_inline",
|
|
1620
|
+
"completion_flush_genuine",
|
|
1621
|
+
"completion_flush_weak",
|
|
1622
|
+
"monitor_final_summary",
|
|
1623
|
+
"pre_cleanup_transcript",
|
|
1624
|
+
"stall_transcript",
|
|
1625
|
+
"startup_grace_collapse",
|
|
1626
|
+
"acp_prompt_response",
|
|
1627
|
+
"cdp_state",
|
|
1628
|
+
"approval_gate",
|
|
1629
|
+
"modal_button",
|
|
1630
|
+
"mesh_stall_watchdog",
|
|
1631
|
+
"status_monitor",
|
|
1632
|
+
"pty_exit",
|
|
1633
|
+
"provider_error",
|
|
1634
|
+
"coordinator_probe",
|
|
1635
|
+
"mcp_probe",
|
|
1636
|
+
"worker_tool",
|
|
1637
|
+
"dispatch",
|
|
1638
|
+
"input_service",
|
|
1639
|
+
"operator",
|
|
1640
|
+
"intentional_cleanup",
|
|
1641
|
+
"scheduler",
|
|
1642
|
+
"git_probe",
|
|
1643
|
+
"session_registry"
|
|
1644
|
+
];
|
|
1645
|
+
var TURN_SCOPES = ["mesh_queue", "mesh_direct", "plain"];
|
|
1646
|
+
var RECLAIMING_SEND_REFUSALS = ["session_exited", "no_target", "unsupported_input"];
|
|
1647
|
+
var DELIVERY_OUTCOMES = ["delivered", "queued"];
|
|
1648
|
+
var DELIVERY_VIAS = ["local", "p2p"];
|
|
1649
|
+
var DISPATCH_FAILURE_REASONS = ["worker_absent", "transport_error", "spawn_failed", "rejected_by_worker", "timeout"];
|
|
1650
|
+
var CONSUME_PROFILES = ["default", "native_source"];
|
|
1651
|
+
var SESSION_REBOUND_REASONS = ["restart", "live_holder"];
|
|
1652
|
+
var SUSPENSION_MODALS = ["approval", "choice"];
|
|
1653
|
+
var SUSPENSION_RESOLUTIONS = ["approved", "rejected", "answered"];
|
|
1654
|
+
var SUSPENSION_RESOLUTION_VIAS = ["modal_button", "auto_approve", "prompt_answer"];
|
|
1655
|
+
var TURN_END_STRENGTHS = ["genuine", "weak"];
|
|
1656
|
+
var TURN_END_BLOCK_REASONS = [
|
|
1657
|
+
"missing_final_assistant",
|
|
1658
|
+
"finalization_timeout",
|
|
1659
|
+
"terminal_block_hard_cap",
|
|
1660
|
+
"decoupled_completion"
|
|
1661
|
+
];
|
|
1662
|
+
var NATIVE_TURN_OUTCOMES = ["completed", "aborted"];
|
|
1663
|
+
var LIVENESS_RESULTS = ["alive", "unknown", "read_failed", "dead"];
|
|
1664
|
+
var PROVIDER_FAILURES = ["auth_failed", "billing_failed"];
|
|
1665
|
+
var SESSION_ERROR_REASONS = ["provider_error", "adapter_error", "spawn_failed", "auth_failed", "billing_failed", "unknown", "daemon_restart"];
|
|
1666
|
+
var CANCEL_REASONS = ["operator_cancel", "intentional_cleanup", "task_removed", "mission_abandoned", "superseded"];
|
|
1667
|
+
var OPERATOR_STATUSES = ["completed", "failed"];
|
|
1668
|
+
var OPERATOR_STATUS_REASONS = ["operator_update", "refine_terminal", "validation_terminal"];
|
|
1669
|
+
var COORDINATOR_ACK_OUTCOMES = ["delivered", "queued", "duplicate"];
|
|
1670
|
+
var NO_PROGRESS_OBSERVED_STATUSES = [...SESSION_STATUSES, "unknown"];
|
|
1671
|
+
var HOLD_REASONS = [
|
|
1672
|
+
"await_delivery",
|
|
1673
|
+
"await_consume",
|
|
1674
|
+
"await_turn",
|
|
1675
|
+
"liveness",
|
|
1676
|
+
"hard_ceiling",
|
|
1677
|
+
"live_pending",
|
|
1678
|
+
"transcript_quiet",
|
|
1679
|
+
"weak_candidate",
|
|
1680
|
+
"suspension_before_consumed",
|
|
1681
|
+
// A genuine FSM end of a mesh turn whose worker holds a live worker-MCP bind:
|
|
1682
|
+
// the structured report is the primary evidence (design §F2), so the idle edge
|
|
1683
|
+
// only opens this hold (R9r) — a report commits (R17), a new busy edge cancels
|
|
1684
|
+
// it as a false idle (R12r), expiry commits weak (R13r).
|
|
1685
|
+
"await_report"
|
|
1686
|
+
];
|
|
1687
|
+
var TURN_OUTCOMES = ["completed", "failed", "cancelled"];
|
|
1688
|
+
var COMMIT_STRENGTHS = ["genuine", "weak", "tool_report", "operator"];
|
|
1689
|
+
var TURN_REASONS = [
|
|
1690
|
+
// commits
|
|
1691
|
+
"turn_end",
|
|
1692
|
+
"weak_end_confirmed",
|
|
1693
|
+
"transcript_final",
|
|
1694
|
+
"worker_reported",
|
|
1695
|
+
"finalization_timeout_no_response",
|
|
1696
|
+
"session_error",
|
|
1697
|
+
"provider_auth_failed",
|
|
1698
|
+
"provider_billing_failed",
|
|
1699
|
+
"operator_cancel",
|
|
1700
|
+
"intentional_cleanup",
|
|
1701
|
+
"task_removed",
|
|
1702
|
+
"mission_abandoned",
|
|
1703
|
+
"superseded",
|
|
1704
|
+
"operator_update",
|
|
1705
|
+
"refine_terminal",
|
|
1706
|
+
"validation_terminal",
|
|
1707
|
+
"hard_ceiling",
|
|
1708
|
+
"reclaim_budget_exhausted",
|
|
1709
|
+
"hollow_max_retries",
|
|
1710
|
+
"migration_orphan",
|
|
1711
|
+
// reclaims (generation + 1)
|
|
1712
|
+
"dispatch_refused_session_exited",
|
|
1713
|
+
"dispatch_refused_no_target",
|
|
1714
|
+
"dispatch_refused_unsupported_input",
|
|
1715
|
+
"dispatch_failed",
|
|
1716
|
+
"session_exit",
|
|
1717
|
+
"session_exit_before_turn",
|
|
1718
|
+
"session_dead",
|
|
1719
|
+
"hollow_completion",
|
|
1720
|
+
"assigned_stranded_dispatch_unconfirmed",
|
|
1721
|
+
"delivered_not_consumed_redrive",
|
|
1722
|
+
"delivered_no_turn_deadline"
|
|
1723
|
+
];
|
|
1724
|
+
var NOTIFY_KINDS = [
|
|
1725
|
+
"completed",
|
|
1726
|
+
"failed",
|
|
1727
|
+
"cancelled",
|
|
1728
|
+
"stopped",
|
|
1729
|
+
"approval",
|
|
1730
|
+
"choice",
|
|
1731
|
+
"approval_resolved",
|
|
1732
|
+
"candidate",
|
|
1733
|
+
"no_progress",
|
|
1734
|
+
"progress",
|
|
1735
|
+
"late_completion",
|
|
1736
|
+
"mesh_event"
|
|
1737
|
+
];
|
|
1738
|
+
var id = { t: "id" };
|
|
1739
|
+
var idOpt = { t: "id", optional: true };
|
|
1740
|
+
var bool = { t: "bool" };
|
|
1741
|
+
var boolOpt = { t: "bool", optional: true };
|
|
1742
|
+
var ms = { t: "ms" };
|
|
1743
|
+
var msOpt = { t: "ms", optional: true };
|
|
1744
|
+
var intOpt = { t: "int", optional: true };
|
|
1745
|
+
var en = (values) => ({ t: "enum", values });
|
|
1746
|
+
var enOpt = (values) => ({ t: "enum", values, optional: true });
|
|
1747
|
+
var EVIDENCE_ENVELOPE_FIELD_SPECS = {
|
|
1748
|
+
eventId: id,
|
|
1749
|
+
at: ms,
|
|
1750
|
+
source: en(EVIDENCE_SOURCE_IDS),
|
|
1751
|
+
sessionId: id,
|
|
1752
|
+
attemptRef: { t: "attempt_ref", optional: true },
|
|
1753
|
+
taskId: idOpt,
|
|
1754
|
+
observedBy: id
|
|
1755
|
+
};
|
|
1756
|
+
var TURN_EVIDENCE_FIELD_SPECS = {
|
|
1757
|
+
dispatch_accepted: {
|
|
1758
|
+
scope: en(TURN_SCOPES),
|
|
1759
|
+
messageId: id,
|
|
1760
|
+
meshId: idOpt,
|
|
1761
|
+
nodeId: idOpt,
|
|
1762
|
+
providerType: idOpt,
|
|
1763
|
+
attemptNo: intOpt,
|
|
1764
|
+
dispatchNonce: intOpt,
|
|
1765
|
+
consumeProfile: enOpt(CONSUME_PROFILES),
|
|
1766
|
+
maxTaskRetries: intOpt,
|
|
1767
|
+
coordinator: { t: "coordinator", optional: true }
|
|
1768
|
+
},
|
|
1769
|
+
delivered: { messageId: id, outcome: en(DELIVERY_OUTCOMES), via: en(DELIVERY_VIAS) },
|
|
1770
|
+
delivery_refused: { messageId: id, reason: en(SEND_REFUSAL_REASONS) },
|
|
1771
|
+
dispatch_failed: { workerAbsent: bool, reason: en(DISPATCH_FAILURE_REASONS) },
|
|
1772
|
+
duplicate_dispatch_refusal: { holderSessionId: id, holderAttemptId: idOpt },
|
|
1773
|
+
session_rebound: { toSessionId: id, reason: en(SESSION_REBOUND_REASONS) },
|
|
1774
|
+
turn_started: { retro: bool },
|
|
1775
|
+
suspension: { modal: en(SUSPENSION_MODALS), modalKey: idOpt },
|
|
1776
|
+
suspension_resolved: { resolution: en(SUSPENSION_RESOLUTIONS), via: en(SUSPENSION_RESOLUTION_VIAS) },
|
|
1777
|
+
turn_end: {
|
|
1778
|
+
strength: en(TURN_END_STRENGTHS),
|
|
1779
|
+
afterFinalizationTimeout: boolOpt,
|
|
1780
|
+
hollow: boolOpt,
|
|
1781
|
+
summary: { t: "summary_ref", optional: true },
|
|
1782
|
+
blockReason: enOpt(TURN_END_BLOCK_REASONS),
|
|
1783
|
+
releasedByHardCap: boolOpt,
|
|
1784
|
+
nativeOutcome: enOpt(NATIVE_TURN_OUTCOMES),
|
|
1785
|
+
live: { t: "live", optional: true },
|
|
1786
|
+
reportExpected: boolOpt
|
|
1787
|
+
},
|
|
1788
|
+
transcript_final: {
|
|
1789
|
+
selfAttributing: bool,
|
|
1790
|
+
nativeRead: bool,
|
|
1791
|
+
nativeMarker: { t: "native_marker", optional: true },
|
|
1792
|
+
live: { t: "live" },
|
|
1793
|
+
summary: { t: "summary_ref", optional: true },
|
|
1794
|
+
messageAt: msOpt
|
|
1795
|
+
},
|
|
1796
|
+
transcript_activity: { newestActivityAt: ms },
|
|
1797
|
+
no_progress: { stalledMs: ms, observedStatus: en(NO_PROGRESS_OBSERVED_STATUSES), finalAssistantPresent: bool },
|
|
1798
|
+
liveness: { result: en(LIVENESS_RESULTS) },
|
|
1799
|
+
process_exit: { exitCode: { t: "int", nullable: true }, providerFailure: enOpt(PROVIDER_FAILURES) },
|
|
1800
|
+
session_error: { reason: en(SESSION_ERROR_REASONS) },
|
|
1801
|
+
worker_report: {
|
|
1802
|
+
outcome: en(WORKER_REPORT_OUTCOMES),
|
|
1803
|
+
summary: { t: "summary_ref" },
|
|
1804
|
+
hasHandoffNotes: bool,
|
|
1805
|
+
branchState: enOpt(WORKER_BRANCH_STATES),
|
|
1806
|
+
touchedFileCount: intOpt
|
|
1807
|
+
},
|
|
1808
|
+
worker_progress: { note: { t: "summary_ref", optional: true } },
|
|
1809
|
+
git_side_effect: { dirty: bool, commitsSinceDispatch: { t: "int" }, attributable: bool },
|
|
1810
|
+
cancel: { reason: en(CANCEL_REASONS) },
|
|
1811
|
+
operator_status: { status: en(OPERATOR_STATUSES), reason: en(OPERATOR_STATUS_REASONS) },
|
|
1812
|
+
coordinator_ack: { notify: en(NOTIFY_KINDS), outcome: en(COORDINATOR_ACK_OUTCOMES) },
|
|
1813
|
+
hold_expired: { holdId: id, reason: en(HOLD_REASONS) }
|
|
1814
|
+
};
|
|
1815
|
+
var TURN_EVIDENCE_KINDS = Object.keys(TURN_EVIDENCE_FIELD_SPECS);
|
|
1816
|
+
var TERMINAL_CLASS_EVIDENCE_KINDS = [
|
|
1817
|
+
"turn_end",
|
|
1818
|
+
"transcript_final",
|
|
1819
|
+
"no_progress",
|
|
1820
|
+
"worker_report",
|
|
1821
|
+
"session_error",
|
|
1822
|
+
"process_exit",
|
|
1823
|
+
"cancel",
|
|
1824
|
+
"operator_status"
|
|
1825
|
+
];
|
|
1826
|
+
var IDENTIFIER_RE = /^[^\s\u0000-\u001f\u007f]{1,256}$/;
|
|
1827
|
+
function makeGuard2(values) {
|
|
1828
|
+
const set = new Set(values);
|
|
1829
|
+
return (value) => typeof value === "string" && set.has(value);
|
|
1830
|
+
}
|
|
1831
|
+
var isEvidenceSourceId = makeGuard2(EVIDENCE_SOURCE_IDS);
|
|
1832
|
+
var isTurnEvidenceKind = makeGuard2(TURN_EVIDENCE_KINDS);
|
|
1833
|
+
var isTurnReason = makeGuard2(TURN_REASONS);
|
|
1834
|
+
var isNotifyKind = makeGuard2(NOTIFY_KINDS);
|
|
1835
|
+
var isHoldReason = makeGuard2(HOLD_REASONS);
|
|
1836
|
+
var isTurnOutcome = makeGuard2(TURN_OUTCOMES);
|
|
1837
|
+
var isCommitStrength = makeGuard2(COMMIT_STRENGTHS);
|
|
1838
|
+
function isRecord2(value) {
|
|
1839
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
1840
|
+
}
|
|
1841
|
+
function isEvidenceIdentifier(value) {
|
|
1842
|
+
return typeof value === "string" && IDENTIFIER_RE.test(value);
|
|
1843
|
+
}
|
|
1844
|
+
function isFiniteNumber2(value) {
|
|
1845
|
+
return typeof value === "number" && Number.isFinite(value);
|
|
1846
|
+
}
|
|
1847
|
+
function isSummaryRef(value) {
|
|
1848
|
+
return isRecord2(value) && hasOnlyKeys(value, ["topic", "writer", "seq"]) && isEvidenceIdentifier(value.topic) && isEvidenceIdentifier(value.writer) && Number.isSafeInteger(value.seq) && value.seq >= 0;
|
|
1849
|
+
}
|
|
1850
|
+
function isTurnAttemptRef(value) {
|
|
1851
|
+
return isRecord2(value) && hasOnlyKeys(value, ["attemptId", "generation"]) && isEvidenceIdentifier(value.attemptId) && Number.isSafeInteger(value.generation) && value.generation >= 0;
|
|
1852
|
+
}
|
|
1853
|
+
function isLiveTurnPending(value) {
|
|
1854
|
+
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));
|
|
1855
|
+
}
|
|
1856
|
+
function isNativeMarkerRef(value) {
|
|
1857
|
+
return isRecord2(value) && hasOnlyKeys(value, ["outcome", "turnId"]) && NATIVE_TURN_OUTCOMES.includes(value.outcome) && (value.turnId === void 0 || isEvidenceIdentifier(value.turnId));
|
|
1858
|
+
}
|
|
1859
|
+
function isCoordinatorIdentity(value) {
|
|
1860
|
+
return isRecord2(value) && hasOnlyKeys(value, ["daemonId", "coordinatorRunId", "sessionId"]) && isEvidenceIdentifier(value.daemonId) && isEvidenceIdentifier(value.coordinatorRunId) && (value.sessionId === void 0 || isEvidenceIdentifier(value.sessionId));
|
|
1861
|
+
}
|
|
1862
|
+
function hasOnlyKeys(value, allowed) {
|
|
1863
|
+
for (const key of Object.keys(value)) {
|
|
1864
|
+
if (!allowed.includes(key)) return false;
|
|
1865
|
+
}
|
|
1866
|
+
return true;
|
|
1867
|
+
}
|
|
1868
|
+
function fieldMatches(spec, value) {
|
|
1869
|
+
if (value === void 0) return spec.optional === true;
|
|
1870
|
+
switch (spec.t) {
|
|
1871
|
+
case "id":
|
|
1872
|
+
return isEvidenceIdentifier(value);
|
|
1873
|
+
case "enum":
|
|
1874
|
+
return typeof value === "string" && spec.values.includes(value);
|
|
1875
|
+
case "bool":
|
|
1876
|
+
return typeof value === "boolean";
|
|
1877
|
+
case "int":
|
|
1878
|
+
return value === null && spec.nullable === true || Number.isSafeInteger(value);
|
|
1879
|
+
case "ms":
|
|
1880
|
+
return isFiniteNumber2(value) && value >= 0;
|
|
1881
|
+
case "summary_ref":
|
|
1882
|
+
return isSummaryRef(value);
|
|
1883
|
+
case "attempt_ref":
|
|
1884
|
+
return isTurnAttemptRef(value);
|
|
1885
|
+
case "live":
|
|
1886
|
+
return isLiveTurnPending(value);
|
|
1887
|
+
case "native_marker":
|
|
1888
|
+
return isNativeMarkerRef(value);
|
|
1889
|
+
case "coordinator":
|
|
1890
|
+
return isCoordinatorIdentity(value);
|
|
1891
|
+
}
|
|
1892
|
+
}
|
|
1893
|
+
function isTurnEvidence(value) {
|
|
1894
|
+
if (!isRecord2(value) || !isTurnEvidenceKind(value.kind)) return false;
|
|
1895
|
+
const bodySpecs = TURN_EVIDENCE_FIELD_SPECS[value.kind];
|
|
1896
|
+
const envelopeSpecs = EVIDENCE_ENVELOPE_FIELD_SPECS;
|
|
1897
|
+
for (const key of Object.keys(value)) {
|
|
1898
|
+
if (key === "kind") continue;
|
|
1899
|
+
if (!(key in bodySpecs) && !(key in envelopeSpecs)) return false;
|
|
1900
|
+
}
|
|
1901
|
+
for (const [key, spec] of Object.entries(envelopeSpecs)) {
|
|
1902
|
+
if (!fieldMatches(spec, value[key])) return false;
|
|
1903
|
+
}
|
|
1904
|
+
for (const [key, spec] of Object.entries(bodySpecs)) {
|
|
1905
|
+
if (!fieldMatches(spec, value[key])) return false;
|
|
1906
|
+
}
|
|
1907
|
+
return true;
|
|
1908
|
+
}
|
|
1909
|
+
function isTerminalClassEvidenceKind(kind) {
|
|
1910
|
+
return TERMINAL_CLASS_EVIDENCE_KINDS.includes(kind);
|
|
1911
|
+
}
|
|
1912
|
+
var TURN_EVIDENCE_FLAGS = ["hollow", "afterFinalizationTimeout", "nativeMarker", "selfAttributing"];
|
|
1913
|
+
var MESH_TOPIC_ENTRY_KINDS = ["turn.evidence", "turn.committed", "turn.notify", "mesh.record"];
|
|
1914
|
+
var isMeshTopicEntryKind = makeGuard2(MESH_TOPIC_ENTRY_KINDS);
|
|
1915
|
+
function isOptionalId(value) {
|
|
1916
|
+
return value === void 0 || isEvidenceIdentifier(value);
|
|
1917
|
+
}
|
|
1918
|
+
function isGeneration(value) {
|
|
1919
|
+
return Number.isSafeInteger(value) && value >= 0;
|
|
1920
|
+
}
|
|
1921
|
+
function isProjectedScalars(value) {
|
|
1922
|
+
if (!isRecord2(value)) return false;
|
|
1923
|
+
for (const v of Object.values(value)) {
|
|
1924
|
+
if (!(v === null || typeof v === "number" || typeof v === "boolean" || typeof v === "string")) return false;
|
|
1925
|
+
}
|
|
1926
|
+
return true;
|
|
1927
|
+
}
|
|
1928
|
+
function isMeshTopicEntry(value) {
|
|
1929
|
+
if (!isRecord2(value)) return false;
|
|
1930
|
+
if (value.v !== MESH_TOPIC_PROTOCOL_VERSION || !isEvidenceIdentifier(value.eventId) || !isFiniteNumber2(value.at)) return false;
|
|
1931
|
+
switch (value.k) {
|
|
1932
|
+
case "turn.evidence": {
|
|
1933
|
+
if (!isEvidenceIdentifier(value.attemptId) || !isGeneration(value.generation)) return false;
|
|
1934
|
+
if (!isEvidenceIdentifier(value.ownerDaemonId) || !isEvidenceIdentifier(value.sessionId) || !isOptionalId(value.taskId)) return false;
|
|
1935
|
+
if (!isTurnEvidenceKind(value.ev)) return false;
|
|
1936
|
+
if (value.strength !== void 0 && !TURN_END_STRENGTHS.includes(value.strength)) return false;
|
|
1937
|
+
if (value.flags !== void 0) {
|
|
1938
|
+
if (!isRecord2(value.flags)) return false;
|
|
1939
|
+
for (const [flag, on] of Object.entries(value.flags)) {
|
|
1940
|
+
if (!TURN_EVIDENCE_FLAGS.includes(flag) || typeof on !== "boolean") return false;
|
|
1941
|
+
}
|
|
1942
|
+
}
|
|
1943
|
+
if (value.evidence !== void 0 && !(isTurnEvidence(value.evidence) && value.evidence.kind === value.ev)) return false;
|
|
1944
|
+
return true;
|
|
1945
|
+
}
|
|
1946
|
+
case "turn.committed":
|
|
1947
|
+
return isEvidenceIdentifier(value.attemptId) && isGeneration(value.generation) && isOptionalId(value.taskId) && isTurnOutcome(value.outcome) && isCommitStrength(value.strength) && isTurnReason(value.reason);
|
|
1948
|
+
case "turn.notify":
|
|
1949
|
+
return isOptionalId(value.attemptId) && isNotifyKind(value.notify) && isEvidenceIdentifier(value.targetDaemonId) && isOptionalId(value.targetSessionId) && isOptionalId(value.taskId);
|
|
1950
|
+
case "mesh.record":
|
|
1951
|
+
return isEvidenceIdentifier(value.ledgerKind) && isOptionalId(value.nodeId) && isOptionalId(value.sessionId) && isOptionalId(value.taskId) && isProjectedScalars(value.payload);
|
|
1952
|
+
default:
|
|
1953
|
+
return false;
|
|
1954
|
+
}
|
|
1955
|
+
}
|
|
1956
|
+
function projectTurnEvidenceEntry(evidence, attempt) {
|
|
1957
|
+
const flags = {};
|
|
1958
|
+
if (evidence.kind === "turn_end") {
|
|
1959
|
+
if (evidence.hollow) flags.hollow = true;
|
|
1960
|
+
if (evidence.afterFinalizationTimeout) flags.afterFinalizationTimeout = true;
|
|
1961
|
+
}
|
|
1962
|
+
if (evidence.kind === "transcript_final") {
|
|
1963
|
+
if (evidence.nativeMarker) flags.nativeMarker = true;
|
|
1964
|
+
if (evidence.selfAttributing) flags.selfAttributing = true;
|
|
1965
|
+
}
|
|
1966
|
+
const taskId = evidence.taskId;
|
|
1967
|
+
return {
|
|
1968
|
+
v: MESH_TOPIC_PROTOCOL_VERSION,
|
|
1969
|
+
eventId: evidence.eventId,
|
|
1970
|
+
at: evidence.at,
|
|
1971
|
+
k: "turn.evidence",
|
|
1972
|
+
attemptId: attempt.attemptId,
|
|
1973
|
+
generation: attempt.generation,
|
|
1974
|
+
ownerDaemonId: attempt.ownerDaemonId,
|
|
1975
|
+
...taskId ? { taskId } : {},
|
|
1976
|
+
sessionId: evidence.sessionId,
|
|
1977
|
+
ev: evidence.kind,
|
|
1978
|
+
...evidence.kind === "turn_end" ? { strength: evidence.strength } : {},
|
|
1979
|
+
...Object.keys(flags).length > 0 ? { flags } : {},
|
|
1980
|
+
evidence
|
|
1981
|
+
};
|
|
1982
|
+
}
|
|
1983
|
+
|
|
1984
|
+
// src/session-launch.ts
|
|
1985
|
+
var MODEL_AXIS_SOURCES = [
|
|
1986
|
+
/** Picked explicitly for this launch (dashboard dropdown, coordinator dialog). */
|
|
1987
|
+
"user",
|
|
1988
|
+
/** The dashboard dialog restored it from the last launch (browser-local memory). */
|
|
1989
|
+
"remembered",
|
|
1990
|
+
/** A mesh capability slot supplied it (or a difficulty preset the slot outranked). */
|
|
1991
|
+
"mesh_slot",
|
|
1992
|
+
/** An explicit per-task model / thinking level on a mesh queue task. */
|
|
1993
|
+
"task_override",
|
|
1994
|
+
/** Nothing was requested; the provider's default is known (discovery / manifest). */
|
|
1995
|
+
"provider_default",
|
|
1996
|
+
/** A value was requested without saying where it came from, or nothing is known. */
|
|
1997
|
+
"unspecified"
|
|
1998
|
+
];
|
|
1999
|
+
function isModelAxisSource(value) {
|
|
2000
|
+
return typeof value === "string" && MODEL_AXIS_SOURCES.includes(value);
|
|
2001
|
+
}
|
|
2002
|
+
var SESSION_LAUNCHED_BY = ["dashboard", "mesh", "cli", "api", "restore"];
|
|
2003
|
+
function isSessionLaunchedBy(value) {
|
|
2004
|
+
return typeof value === "string" && SESSION_LAUNCHED_BY.includes(value);
|
|
2005
|
+
}
|
|
2006
|
+
var MODEL_SELECTION_HISTORY_LIMIT = 20;
|
|
2007
|
+
function effectiveModelSelectionValue(selection) {
|
|
2008
|
+
if (!selection) return void 0;
|
|
2009
|
+
const last = Array.isArray(selection.history) ? selection.history[selection.history.length - 1] : void 0;
|
|
2010
|
+
return last?.value ?? selection.current ?? selection.observed ?? launchModelSelectionValue(selection);
|
|
2011
|
+
}
|
|
2012
|
+
function launchModelSelectionValue(selection) {
|
|
2013
|
+
if (!selection) return void 0;
|
|
2014
|
+
const launch = Array.isArray(selection.history) ? selection.history.find((entry) => entry.via === "launch") : void 0;
|
|
2015
|
+
return launch?.value ?? selection.launchValue ?? selection.requested ?? selection.resolvedDefault;
|
|
2016
|
+
}
|
|
2017
|
+
function describeModelSelection(selection) {
|
|
2018
|
+
const value = effectiveModelSelectionValue(selection);
|
|
2019
|
+
if (!selection || !value) return void 0;
|
|
2020
|
+
const launched = launchModelSelectionValue(selection);
|
|
2021
|
+
return {
|
|
2022
|
+
value,
|
|
2023
|
+
...launched && launched !== value ? { changedFrom: launched } : {},
|
|
2024
|
+
source: isModelAxisSource(selection.source) ? selection.source : "unspecified"
|
|
2025
|
+
};
|
|
2026
|
+
}
|
|
2027
|
+
var MODEL_IDENTIFIER_PATTERN = /^[A-Za-z0-9][A-Za-z0-9._:/@[\]+-]{0,95}$/;
|
|
2028
|
+
function sanitizeModelIdentifier(value) {
|
|
2029
|
+
if (typeof value !== "string") return void 0;
|
|
2030
|
+
const trimmed = value.trim();
|
|
2031
|
+
return MODEL_IDENTIFIER_PATTERN.test(trimmed) ? trimmed : void 0;
|
|
2032
|
+
}
|
|
2033
|
+
function readString2(value) {
|
|
2034
|
+
return typeof value === "string" && value.trim() ? value.trim() : void 0;
|
|
2035
|
+
}
|
|
2036
|
+
function readFiniteNumber(value) {
|
|
2037
|
+
return typeof value === "number" && Number.isFinite(value) ? value : void 0;
|
|
2038
|
+
}
|
|
2039
|
+
function parseModelSelection(raw) {
|
|
2040
|
+
if (!raw || typeof raw !== "object") return void 0;
|
|
2041
|
+
const record = raw;
|
|
2042
|
+
const history = [];
|
|
2043
|
+
if (Array.isArray(record.history)) {
|
|
2044
|
+
for (const entry of record.history) {
|
|
2045
|
+
if (!entry || typeof entry !== "object") continue;
|
|
2046
|
+
const e = entry;
|
|
2047
|
+
const value = readString2(e.value);
|
|
2048
|
+
const at = readFiniteNumber(e.at);
|
|
2049
|
+
const via = e.via === "launch" || e.via === "change_model" || e.via === "observed" ? e.via : void 0;
|
|
2050
|
+
if (value && at !== void 0 && via) history.push({ at, value, via });
|
|
2051
|
+
}
|
|
2052
|
+
}
|
|
2053
|
+
const requested = readString2(record.requested);
|
|
2054
|
+
const launchValue = readString2(record.launchValue);
|
|
2055
|
+
const resolvedDefault = readString2(record.resolvedDefault);
|
|
2056
|
+
const current = readString2(record.current);
|
|
2057
|
+
const observed = readString2(record.observed);
|
|
2058
|
+
const observedAt = readFiniteNumber(record.observedAt);
|
|
2059
|
+
return {
|
|
2060
|
+
source: isModelAxisSource(record.source) ? record.source : "unspecified",
|
|
2061
|
+
...requested ? { requested } : {},
|
|
2062
|
+
...launchValue ? { launchValue } : {},
|
|
2063
|
+
...resolvedDefault ? { resolvedDefault } : {},
|
|
2064
|
+
...current ? { current } : {},
|
|
2065
|
+
...observed ? { observed } : {},
|
|
2066
|
+
...observedAt !== void 0 ? { observedAt } : {},
|
|
2067
|
+
history: history.slice(-MODEL_SELECTION_HISTORY_LIMIT)
|
|
2068
|
+
};
|
|
2069
|
+
}
|
|
2070
|
+
function parseSessionLaunchRecord(raw) {
|
|
2071
|
+
if (!raw || typeof raw !== "object") return void 0;
|
|
2072
|
+
const record = raw;
|
|
2073
|
+
const sessionId = readString2(record.sessionId);
|
|
2074
|
+
const providerType = readString2(record.providerType);
|
|
2075
|
+
const launchedAt = readFiniteNumber(record.launchedAt);
|
|
2076
|
+
const model = parseModelSelection(record.model);
|
|
2077
|
+
const thinkingLevel = parseModelSelection(record.thinkingLevel);
|
|
2078
|
+
if (!sessionId || !providerType || launchedAt === void 0 || !model || !thinkingLevel) return void 0;
|
|
2079
|
+
const providerVersion = readString2(record.providerVersion);
|
|
2080
|
+
const workspace = readString2(record.workspace);
|
|
2081
|
+
const autoApproveModeId = readString2(record.autoApproveModeId);
|
|
2082
|
+
return {
|
|
2083
|
+
sessionId,
|
|
2084
|
+
providerType,
|
|
2085
|
+
...providerVersion ? { providerVersion } : {},
|
|
2086
|
+
...record.providerChannel === "stable" || record.providerChannel === "preview" ? { providerChannel: record.providerChannel } : {},
|
|
2087
|
+
launchedBy: isSessionLaunchedBy(record.launchedBy) ? record.launchedBy : "api",
|
|
2088
|
+
launchedAt,
|
|
2089
|
+
...workspace ? { workspace } : {},
|
|
2090
|
+
model,
|
|
2091
|
+
thinkingLevel,
|
|
2092
|
+
...autoApproveModeId ? { autoApproveModeId } : {}
|
|
2093
|
+
};
|
|
2094
|
+
}
|
|
2095
|
+
|
|
2096
|
+
// src/turn-ipc.ts
|
|
2097
|
+
var TURN_IPC_PROTOCOL_VERSION = 1;
|
|
2098
|
+
function isFiniteNumber3(value) {
|
|
2099
|
+
return typeof value === "number" && Number.isFinite(value);
|
|
2100
|
+
}
|
|
2101
|
+
function isNonNegativeInt(value) {
|
|
2102
|
+
return Number.isSafeInteger(value) && value >= 0;
|
|
2103
|
+
}
|
|
2104
|
+
function isOptionalId2(value) {
|
|
2105
|
+
return value === void 0 || isEvidenceIdentifier(value);
|
|
2106
|
+
}
|
|
2107
|
+
function hasOnlyKeys2(value, allowed) {
|
|
2108
|
+
for (const key of Object.keys(value)) {
|
|
2109
|
+
if (!allowed.includes(key)) return false;
|
|
2110
|
+
}
|
|
2111
|
+
return true;
|
|
2112
|
+
}
|
|
2113
|
+
var TURN_IPC_ERROR_CODES = ["daemon_required", "turn_ledger_unavailable", "ledger_not_owner"];
|
|
2114
|
+
function makeGuard3(values) {
|
|
2115
|
+
const set = new Set(values);
|
|
2116
|
+
return (value) => typeof value === "string" && set.has(value);
|
|
2117
|
+
}
|
|
2118
|
+
var isTurnIpcErrorCode = makeGuard3(TURN_IPC_ERROR_CODES);
|
|
2119
|
+
function isTurnIpcError(value) {
|
|
2120
|
+
return isRecord(value) && hasOnlyKeys2(value, ["code", "detail"]) && isTurnIpcErrorCode(value.code) && (value.detail === void 0 || typeof value.detail === "string");
|
|
2121
|
+
}
|
|
2122
|
+
var TURN_OBSERVE_VERDICTS = ["applied", "recorded", "rejected"];
|
|
2123
|
+
var isTurnObserveVerdict = makeGuard3(TURN_OBSERVE_VERDICTS);
|
|
2124
|
+
function isTurnObserveRequest(value) {
|
|
2125
|
+
return isRecord(value) && hasOnlyKeys2(value, ["v", "evidence"]) && value.v === TURN_IPC_PROTOCOL_VERSION && isTurnEvidence(value.evidence);
|
|
2126
|
+
}
|
|
2127
|
+
function decodeTurnObserveRequest(value) {
|
|
2128
|
+
return isTurnObserveRequest(value) ? value : null;
|
|
2129
|
+
}
|
|
2130
|
+
function isTurnAttemptRefValue(value) {
|
|
2131
|
+
return isRecord(value) && hasOnlyKeys2(value, ["attemptId", "generation"]) && isEvidenceIdentifier(value.attemptId) && isNonNegativeInt(value.generation);
|
|
2132
|
+
}
|
|
2133
|
+
function isTurnObserveResponse(value) {
|
|
2134
|
+
return isRecord(value) && hasOnlyKeys2(value, ["verdict", "attemptRef", "outcome"]) && isTurnObserveVerdict(value.verdict) && isTurnAttemptRefValue(value.attemptRef) && (value.outcome === void 0 || isTurnOutcomeValue(value.outcome));
|
|
2135
|
+
}
|
|
2136
|
+
var TURN_OUTCOMES_LOCAL = ["completed", "failed", "cancelled"];
|
|
2137
|
+
function isTurnOutcomeValue(value) {
|
|
2138
|
+
return typeof value === "string" && TURN_OUTCOMES_LOCAL.includes(value);
|
|
2139
|
+
}
|
|
2140
|
+
function decodeTurnObserveResponse(value) {
|
|
2141
|
+
return isTurnObserveResponse(value) ? value : null;
|
|
2142
|
+
}
|
|
2143
|
+
var MESH_RECORD_PAYLOAD_KEYS = [
|
|
2144
|
+
// Identifiers
|
|
2145
|
+
"taskId",
|
|
2146
|
+
"deliveryId",
|
|
2147
|
+
"attemptId",
|
|
2148
|
+
"missionId",
|
|
2149
|
+
"checkpointId",
|
|
2150
|
+
"promptId",
|
|
2151
|
+
"providerSessionId",
|
|
2152
|
+
"targetNoteId",
|
|
2153
|
+
// Routing / addressing
|
|
2154
|
+
"nodeId",
|
|
2155
|
+
"sessionId",
|
|
2156
|
+
"providerType",
|
|
2157
|
+
"transport",
|
|
2158
|
+
"attemptedSessionId",
|
|
2159
|
+
"holderSessionId",
|
|
2160
|
+
// Outcome enums
|
|
2161
|
+
"reason",
|
|
2162
|
+
"status",
|
|
2163
|
+
"outcome",
|
|
2164
|
+
"terminalKind",
|
|
2165
|
+
"event",
|
|
2166
|
+
"source",
|
|
2167
|
+
"intentionalStopReason",
|
|
2168
|
+
// Booleans
|
|
2169
|
+
"retryable",
|
|
2170
|
+
"rebound",
|
|
2171
|
+
"forced",
|
|
2172
|
+
"fallback",
|
|
2173
|
+
"membershipRemoved",
|
|
2174
|
+
"requestedForce",
|
|
2175
|
+
"removedByRemoteDaemon",
|
|
2176
|
+
"completedViaReady",
|
|
2177
|
+
"intentional",
|
|
2178
|
+
"weak",
|
|
2179
|
+
// Counters
|
|
2180
|
+
"attempt",
|
|
2181
|
+
"attemptCount",
|
|
2182
|
+
"count"
|
|
2183
|
+
];
|
|
2184
|
+
var MESH_RECORD_PAYLOAD_KEY_SET = new Set(MESH_RECORD_PAYLOAD_KEYS);
|
|
2185
|
+
var MAX_MESH_RECORD_STRING = 200;
|
|
2186
|
+
function isProjectedScalarsValue(value) {
|
|
2187
|
+
if (!isRecord(value)) return false;
|
|
2188
|
+
for (const v of Object.values(value)) {
|
|
2189
|
+
if (v === null) continue;
|
|
2190
|
+
if (typeof v === "boolean" || typeof v === "number") continue;
|
|
2191
|
+
if (typeof v === "string") {
|
|
2192
|
+
if (v.length > MAX_MESH_RECORD_STRING) return false;
|
|
2193
|
+
continue;
|
|
2194
|
+
}
|
|
2195
|
+
return false;
|
|
2196
|
+
}
|
|
2197
|
+
return true;
|
|
2198
|
+
}
|
|
2199
|
+
function isMeshRecordPayload(value) {
|
|
2200
|
+
if (!isProjectedScalarsValue(value)) return false;
|
|
2201
|
+
for (const key of Object.keys(value)) {
|
|
2202
|
+
if (!MESH_RECORD_PAYLOAD_KEY_SET.has(key)) return false;
|
|
2203
|
+
}
|
|
2204
|
+
return true;
|
|
2205
|
+
}
|
|
2206
|
+
function isMeshRecordRequest(value) {
|
|
2207
|
+
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);
|
|
2208
|
+
}
|
|
2209
|
+
function decodeMeshRecordRequest(value) {
|
|
2210
|
+
return isMeshRecordRequest(value) ? value : null;
|
|
2211
|
+
}
|
|
2212
|
+
function isMeshRecordResponse(value) {
|
|
2213
|
+
return isRecord(value) && hasOnlyKeys2(value, ["eventId", "seq"]) && isEvidenceIdentifier(value.eventId) && isNonNegativeInt(value.seq);
|
|
2214
|
+
}
|
|
2215
|
+
function decodeMeshRecordResponse(value) {
|
|
2216
|
+
return isMeshRecordResponse(value) ? value : null;
|
|
2217
|
+
}
|
|
2218
|
+
function isTurnCancelRequest(value) {
|
|
2219
|
+
if (!isRecord(value) || !hasOnlyKeys2(value, ["v", "attemptId", "taskId", "reason"])) return false;
|
|
2220
|
+
if (value.v !== TURN_IPC_PROTOCOL_VERSION) return false;
|
|
2221
|
+
const hasAttempt = value.attemptId !== void 0;
|
|
2222
|
+
const hasTask = value.taskId !== void 0;
|
|
2223
|
+
if (hasAttempt === hasTask) return false;
|
|
2224
|
+
if (hasAttempt && !isEvidenceIdentifier(value.attemptId)) return false;
|
|
2225
|
+
if (hasTask && !isEvidenceIdentifier(value.taskId)) return false;
|
|
2226
|
+
return isTurnReason(value.reason);
|
|
2227
|
+
}
|
|
2228
|
+
function decodeTurnCancelRequest(value) {
|
|
2229
|
+
return isTurnCancelRequest(value) ? value : null;
|
|
2230
|
+
}
|
|
2231
|
+
function isTurnCancelResponse(value) {
|
|
2232
|
+
return isRecord(value) && hasOnlyKeys2(value, ["attemptRef", "verdict"]) && isTurnAttemptRefValue(value.attemptRef) && isTurnObserveVerdict(value.verdict);
|
|
2233
|
+
}
|
|
2234
|
+
function decodeTurnCancelResponse(value) {
|
|
2235
|
+
return isTurnCancelResponse(value) ? value : null;
|
|
2236
|
+
}
|
|
2237
|
+
var OPERATOR_STATUS_VALUES = ["completed", "failed"];
|
|
2238
|
+
var isOperatorStatusValue = makeGuard3(OPERATOR_STATUS_VALUES);
|
|
2239
|
+
var OPERATOR_STATUS_REASON_VALUES = ["operator_update", "refine_terminal", "validation_terminal"];
|
|
2240
|
+
var isOperatorStatusReasonValue = makeGuard3(OPERATOR_STATUS_REASON_VALUES);
|
|
2241
|
+
function isOperatorStatusRequest(value) {
|
|
2242
|
+
return isRecord(value) && hasOnlyKeys2(value, ["v", "taskId", "status", "reason"]) && value.v === TURN_IPC_PROTOCOL_VERSION && isEvidenceIdentifier(value.taskId) && isOperatorStatusValue(value.status) && isOperatorStatusReasonValue(value.reason);
|
|
2243
|
+
}
|
|
2244
|
+
function decodeOperatorStatusRequest(value) {
|
|
2245
|
+
return isOperatorStatusRequest(value) ? value : null;
|
|
2246
|
+
}
|
|
2247
|
+
function isOperatorStatusResponse(value) {
|
|
2248
|
+
return isRecord(value) && hasOnlyKeys2(value, ["accepted"]) && value.accepted === true;
|
|
2249
|
+
}
|
|
2250
|
+
function decodeOperatorStatusResponse(value) {
|
|
2251
|
+
return isOperatorStatusResponse(value) ? value : null;
|
|
2252
|
+
}
|
|
2253
|
+
function isTurnQueryRequest(value) {
|
|
2254
|
+
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));
|
|
2255
|
+
}
|
|
2256
|
+
function decodeTurnQueryRequest(value) {
|
|
2257
|
+
return isTurnQueryRequest(value) ? value : null;
|
|
2258
|
+
}
|
|
2259
|
+
var TURN_QUERY_ATTEMPT_ROW_KEYS = [
|
|
2260
|
+
"attemptId",
|
|
2261
|
+
"generation",
|
|
2262
|
+
"meshId",
|
|
2263
|
+
"taskId",
|
|
2264
|
+
"sessionId",
|
|
2265
|
+
"nodeId",
|
|
2266
|
+
"providerType",
|
|
2267
|
+
"state",
|
|
2268
|
+
"terminalOutcome",
|
|
2269
|
+
"terminalReason",
|
|
2270
|
+
"acceptedAt",
|
|
2271
|
+
"terminalAt"
|
|
2272
|
+
];
|
|
2273
|
+
function isTurnQueryAttemptRow(value) {
|
|
2274
|
+
if (!isRecord(value) || !hasOnlyKeys2(value, TURN_QUERY_ATTEMPT_ROW_KEYS)) return false;
|
|
2275
|
+
if (!isEvidenceIdentifier(value.attemptId) || !isNonNegativeInt(value.generation)) return false;
|
|
2276
|
+
if (!isOptionalId2(value.meshId) || !isOptionalId2(value.taskId)) return false;
|
|
2277
|
+
if (!isEvidenceIdentifier(value.sessionId)) return false;
|
|
2278
|
+
if (!isOptionalId2(value.nodeId) || !isOptionalId2(value.providerType)) return false;
|
|
2279
|
+
if (typeof value.state !== "string") return false;
|
|
2280
|
+
if (value.terminalOutcome !== void 0 && !isTurnOutcomeValue(value.terminalOutcome)) return false;
|
|
2281
|
+
if (value.terminalReason !== void 0 && !isTurnReason(value.terminalReason)) return false;
|
|
2282
|
+
if (!isFiniteNumber3(value.acceptedAt)) return false;
|
|
2283
|
+
if (value.terminalAt !== void 0 && !isFiniteNumber3(value.terminalAt)) return false;
|
|
2284
|
+
return true;
|
|
2285
|
+
}
|
|
2286
|
+
var TURN_QUERY_EVENT_VERDICTS = ["applied", "recorded", "rejected", "forwarded"];
|
|
2287
|
+
var TURN_QUERY_EVENT_ROW_KEYS = ["eventId", "attemptId", "generation", "sessionId", "kind", "source", "verdict", "atMs"];
|
|
2288
|
+
function isTurnQueryEventRow(value) {
|
|
2289
|
+
if (!isRecord(value) || !hasOnlyKeys2(value, TURN_QUERY_EVENT_ROW_KEYS)) return false;
|
|
2290
|
+
if (!isEvidenceIdentifier(value.eventId)) return false;
|
|
2291
|
+
if (!isOptionalId2(value.attemptId)) return false;
|
|
2292
|
+
if (value.generation !== void 0 && !isNonNegativeInt(value.generation)) return false;
|
|
2293
|
+
if (!isEvidenceIdentifier(value.sessionId)) return false;
|
|
2294
|
+
if (typeof value.kind !== "string") return false;
|
|
2295
|
+
if (typeof value.source !== "string") return false;
|
|
2296
|
+
if (!TURN_QUERY_EVENT_VERDICTS.includes(value.verdict)) return false;
|
|
2297
|
+
if (!isFiniteNumber3(value.atMs)) return false;
|
|
2298
|
+
return true;
|
|
2299
|
+
}
|
|
2300
|
+
function isTurnQueryResponse(value) {
|
|
2301
|
+
if (!isRecord(value) || !hasOnlyKeys2(value, ["attempts", "events", "replicationPending"])) return false;
|
|
2302
|
+
if (!Array.isArray(value.attempts) || !value.attempts.every(isTurnQueryAttemptRow)) return false;
|
|
2303
|
+
if (!Array.isArray(value.events) || !value.events.every(isTurnQueryEventRow)) return false;
|
|
2304
|
+
if (value.replicationPending !== void 0 && typeof value.replicationPending !== "boolean") return false;
|
|
2305
|
+
return true;
|
|
2306
|
+
}
|
|
2307
|
+
function decodeTurnQueryResponse(value) {
|
|
2308
|
+
return isTurnQueryResponse(value) ? value : null;
|
|
2309
|
+
}
|
|
2310
|
+
var MESH_INDEX_QUERY_WRITER_SCOPES = ["own", "fleet"];
|
|
2311
|
+
var isMeshIndexQueryWriterScope = makeGuard3(MESH_INDEX_QUERY_WRITER_SCOPES);
|
|
2312
|
+
function isMeshIndexQueryRequest(value) {
|
|
2313
|
+
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));
|
|
2314
|
+
}
|
|
2315
|
+
function decodeMeshIndexQueryRequest(value) {
|
|
2316
|
+
return isMeshIndexQueryRequest(value) ? value : null;
|
|
2317
|
+
}
|
|
2318
|
+
var MESH_TOPIC_INDEX_ROW_KEYS = [
|
|
2319
|
+
"writer",
|
|
2320
|
+
"seq",
|
|
2321
|
+
"meshId",
|
|
2322
|
+
"eventId",
|
|
2323
|
+
"kind",
|
|
2324
|
+
"ledgerKind",
|
|
2325
|
+
"taskId",
|
|
2326
|
+
"sessionId",
|
|
2327
|
+
"nodeId",
|
|
2328
|
+
"atMs",
|
|
2329
|
+
"payload"
|
|
2330
|
+
];
|
|
2331
|
+
function isMeshTopicIndexRow(value) {
|
|
2332
|
+
if (!isRecord(value) || !hasOnlyKeys2(value, MESH_TOPIC_INDEX_ROW_KEYS)) return false;
|
|
2333
|
+
if (!isEvidenceIdentifier(value.writer) || !isNonNegativeInt(value.seq)) return false;
|
|
2334
|
+
if (!isEvidenceIdentifier(value.meshId) || !isEvidenceIdentifier(value.eventId)) return false;
|
|
2335
|
+
if (typeof value.kind !== "string") return false;
|
|
2336
|
+
if (!isOptionalId2(value.ledgerKind) || !isOptionalId2(value.taskId) || !isOptionalId2(value.sessionId) || !isOptionalId2(value.nodeId)) return false;
|
|
2337
|
+
if (!isFiniteNumber3(value.atMs)) return false;
|
|
2338
|
+
if (!isMeshRecordPayload(value.payload)) return false;
|
|
2339
|
+
return true;
|
|
2340
|
+
}
|
|
2341
|
+
function isMeshIndexQueryResponse(value) {
|
|
2342
|
+
if (!isRecord(value) || !hasOnlyKeys2(value, ["rows", "replicationPending"])) return false;
|
|
2343
|
+
if (!Array.isArray(value.rows) || !value.rows.every(isMeshTopicIndexRow)) return false;
|
|
2344
|
+
if (value.replicationPending !== void 0 && typeof value.replicationPending !== "boolean") return false;
|
|
2345
|
+
return true;
|
|
2346
|
+
}
|
|
2347
|
+
function decodeMeshIndexQueryResponse(value) {
|
|
2348
|
+
return isMeshIndexQueryResponse(value) ? value : null;
|
|
2349
|
+
}
|
|
2350
|
+
var MESH_MISSION_STATUSES = ["active", "paused", "completed", "abandoned"];
|
|
2351
|
+
var isMeshMissionStatusValue = makeGuard3(MESH_MISSION_STATUSES);
|
|
2352
|
+
var MESH_MISSION_SOURCES = ["magi", "coordinator"];
|
|
2353
|
+
var isMeshMissionSourceValue = makeGuard3(MESH_MISSION_SOURCES);
|
|
2354
|
+
function isStringArray(value) {
|
|
2355
|
+
return Array.isArray(value) && value.every((v) => typeof v === "string");
|
|
2356
|
+
}
|
|
2357
|
+
function isMissionBriefWire(value) {
|
|
2358
|
+
if (!isRecord(value) || !hasOnlyKeys2(value, ["goal", "constraints", "doneCriteria", "handoffNotes", "ownedPaths"])) return false;
|
|
2359
|
+
if (typeof value.goal !== "string" || value.goal.trim().length === 0) return false;
|
|
2360
|
+
for (const k of ["constraints", "doneCriteria", "handoffNotes", "ownedPaths"]) {
|
|
2361
|
+
if (value[k] !== void 0 && !isStringArray(value[k])) return false;
|
|
2362
|
+
}
|
|
2363
|
+
return true;
|
|
2364
|
+
}
|
|
2365
|
+
function isMeshMissionRecordWire(value) {
|
|
2366
|
+
if (!isRecord(value) || !hasOnlyKeys2(value, ["id", "meshId", "title", "goal", "status", "source", "brief"])) return false;
|
|
2367
|
+
if (!isEvidenceIdentifier(value.id) || !isEvidenceIdentifier(value.meshId)) return false;
|
|
2368
|
+
if (typeof value.title !== "string" || typeof value.goal !== "string") return false;
|
|
2369
|
+
if (!isMeshMissionStatusValue(value.status)) return false;
|
|
2370
|
+
if (value.source !== void 0 && !isMeshMissionSourceValue(value.source)) return false;
|
|
2371
|
+
if (value.brief !== void 0 && !isMissionBriefWire(value.brief)) return false;
|
|
2372
|
+
return true;
|
|
2373
|
+
}
|
|
2374
|
+
function isMissionUpsertRequest(value) {
|
|
2375
|
+
if (!isRecord(value) || !hasOnlyKeys2(value, ["v", "meshId", "id", "title", "goal", "status", "source", "brief"])) return false;
|
|
2376
|
+
if (value.v !== TURN_IPC_PROTOCOL_VERSION) return false;
|
|
2377
|
+
if (!isEvidenceIdentifier(value.meshId)) return false;
|
|
2378
|
+
if (value.id !== void 0 && !isEvidenceIdentifier(value.id)) return false;
|
|
2379
|
+
if (typeof value.title !== "string" || value.title.trim().length === 0) return false;
|
|
2380
|
+
if (value.goal !== void 0 && typeof value.goal !== "string") return false;
|
|
2381
|
+
if (value.status !== void 0 && !isMeshMissionStatusValue(value.status)) return false;
|
|
2382
|
+
if (value.source !== void 0 && !isMeshMissionSourceValue(value.source)) return false;
|
|
2383
|
+
if (value.brief !== void 0 && value.brief !== null && !isMissionBriefWire(value.brief)) return false;
|
|
2384
|
+
return true;
|
|
2385
|
+
}
|
|
2386
|
+
function decodeMissionUpsertRequest(value) {
|
|
2387
|
+
return isMissionUpsertRequest(value) ? value : null;
|
|
2388
|
+
}
|
|
2389
|
+
function isMissionUpsertResponse(value) {
|
|
2390
|
+
return isRecord(value) && hasOnlyKeys2(value, ["mission"]) && isMeshMissionRecordWire(value.mission);
|
|
2391
|
+
}
|
|
2392
|
+
function decodeMissionUpsertResponse(value) {
|
|
2393
|
+
return isMissionUpsertResponse(value) ? value : null;
|
|
2394
|
+
}
|
|
2395
|
+
function isMissionQueryRequest(value) {
|
|
2396
|
+
if (!isRecord(value) || !hasOnlyKeys2(value, ["v", "meshId", "statuses", "id"])) return false;
|
|
2397
|
+
if (value.v !== TURN_IPC_PROTOCOL_VERSION) return false;
|
|
2398
|
+
if (!isEvidenceIdentifier(value.meshId)) return false;
|
|
2399
|
+
if (value.id !== void 0 && !isEvidenceIdentifier(value.id)) return false;
|
|
2400
|
+
if (value.statuses !== void 0) {
|
|
2401
|
+
if (!Array.isArray(value.statuses) || value.statuses.length === 0) return false;
|
|
2402
|
+
if (!value.statuses.every(isMeshMissionStatusValue)) return false;
|
|
2403
|
+
}
|
|
2404
|
+
return true;
|
|
2405
|
+
}
|
|
2406
|
+
function decodeMissionQueryRequest(value) {
|
|
2407
|
+
return isMissionQueryRequest(value) ? value : null;
|
|
2408
|
+
}
|
|
2409
|
+
function isMissionQueryResponse(value) {
|
|
2410
|
+
return isRecord(value) && hasOnlyKeys2(value, ["missions"]) && Array.isArray(value.missions) && value.missions.every(isMeshMissionRecordWire);
|
|
2411
|
+
}
|
|
2412
|
+
function decodeMissionQueryResponse(value) {
|
|
2413
|
+
return isMissionQueryResponse(value) ? value : null;
|
|
2414
|
+
}
|
|
2415
|
+
function isMissionListQueryRequest(value) {
|
|
2416
|
+
if (!isRecord(value) || !hasOnlyKeys2(value, ["v", "meshId", "statuses", "verbose", "includeMagi", "withStats", "limit", "historyIdLimit"])) return false;
|
|
2417
|
+
if (value.v !== TURN_IPC_PROTOCOL_VERSION) return false;
|
|
2418
|
+
if (!isEvidenceIdentifier(value.meshId)) return false;
|
|
2419
|
+
if (value.statuses !== void 0) {
|
|
2420
|
+
if (!Array.isArray(value.statuses) || value.statuses.length === 0) return false;
|
|
2421
|
+
if (!value.statuses.every(isMeshMissionStatusValue)) return false;
|
|
2422
|
+
}
|
|
2423
|
+
if (value.verbose !== void 0 && typeof value.verbose !== "boolean") return false;
|
|
2424
|
+
if (value.includeMagi !== void 0 && typeof value.includeMagi !== "boolean") return false;
|
|
2425
|
+
if (value.withStats !== void 0 && typeof value.withStats !== "boolean") return false;
|
|
2426
|
+
if (value.limit !== void 0 && !isNonNegativeInt(value.limit)) return false;
|
|
2427
|
+
if (value.historyIdLimit !== void 0 && !isNonNegativeInt(value.historyIdLimit)) return false;
|
|
2428
|
+
return true;
|
|
2429
|
+
}
|
|
2430
|
+
function decodeMissionListQueryRequest(value) {
|
|
2431
|
+
return isMissionListQueryRequest(value) ? value : null;
|
|
2432
|
+
}
|
|
2433
|
+
function isMeshMissionTaskAggregateWire(value) {
|
|
2434
|
+
const keys = ["total", "pending", "assigned", "completed", "failed", "cancelled", "blocked", "lastActivityAt"];
|
|
2435
|
+
if (!isRecord(value) || !hasOnlyKeys2(value, keys)) return false;
|
|
2436
|
+
for (const k of ["total", "pending", "assigned", "completed", "failed", "cancelled", "blocked"]) {
|
|
2437
|
+
if (!isNonNegativeInt(value[k])) return false;
|
|
2438
|
+
}
|
|
2439
|
+
return value.lastActivityAt === null || typeof value.lastActivityAt === "string";
|
|
2440
|
+
}
|
|
2441
|
+
function isMeshMissionStatsWire(value) {
|
|
2442
|
+
const keys = ["missionId", "taskCount", "completed", "failed", "totalDurationMs", "wallClockMs", "retries", "incompleteTaskIds"];
|
|
2443
|
+
if (!isRecord(value) || !hasOnlyKeys2(value, keys)) return false;
|
|
2444
|
+
if (!isEvidenceIdentifier(value.missionId)) return false;
|
|
2445
|
+
for (const k of ["taskCount", "completed", "failed", "totalDurationMs", "retries"]) {
|
|
2446
|
+
if (!isNonNegativeInt(value[k])) return false;
|
|
2447
|
+
}
|
|
2448
|
+
if (value.wallClockMs !== null && !isNonNegativeInt(value.wallClockMs)) return false;
|
|
2449
|
+
if (!Array.isArray(value.incompleteTaskIds) || !value.incompleteTaskIds.every(isEvidenceIdentifier)) return false;
|
|
2450
|
+
return true;
|
|
2451
|
+
}
|
|
2452
|
+
function isMissionListSummaryWire(value) {
|
|
2453
|
+
if (!isRecord(value)) return false;
|
|
2454
|
+
const hasGoal = "goal" in value;
|
|
2455
|
+
const hasPreview = "goalPreview" in value && "goalTruncated" in value;
|
|
2456
|
+
if (hasGoal === hasPreview) return false;
|
|
2457
|
+
const baseKeys = ["id", "meshId", "title", "status", "source", "tasks", "stats", "brief"];
|
|
2458
|
+
const allowed = hasGoal ? [...baseKeys, "goal"] : [...baseKeys, "goalPreview", "goalTruncated"];
|
|
2459
|
+
if (!hasOnlyKeys2(value, allowed)) return false;
|
|
2460
|
+
if (!isEvidenceIdentifier(value.id) || !isEvidenceIdentifier(value.meshId)) return false;
|
|
2461
|
+
if (typeof value.title !== "string") return false;
|
|
2462
|
+
if (!isMeshMissionStatusValue(value.status)) return false;
|
|
2463
|
+
if (value.source !== void 0 && !isMeshMissionSourceValue(value.source)) return false;
|
|
2464
|
+
if (!isMeshMissionTaskAggregateWire(value.tasks)) return false;
|
|
2465
|
+
if (value.stats !== void 0 && !isMeshMissionStatsWire(value.stats)) return false;
|
|
2466
|
+
if (value.brief !== void 0 && !isMissionBriefWire(value.brief)) return false;
|
|
2467
|
+
if (hasGoal && typeof value.goal !== "string") return false;
|
|
2468
|
+
if (hasPreview && (typeof value.goalPreview !== "string" || typeof value.goalTruncated !== "boolean")) return false;
|
|
2469
|
+
return true;
|
|
2470
|
+
}
|
|
2471
|
+
function isMeshMissionHistoryFoldWire(value) {
|
|
2472
|
+
if (!isRecord(value) || !hasOnlyKeys2(value, ["count", "byStatus", "missionIds", "note"])) return false;
|
|
2473
|
+
if (!isNonNegativeInt(value.count)) return false;
|
|
2474
|
+
if (!isRecord(value.byStatus) || !Object.values(value.byStatus).every((n) => isNonNegativeInt(n))) return false;
|
|
2475
|
+
if (!Array.isArray(value.missionIds) || !value.missionIds.every(isEvidenceIdentifier)) return false;
|
|
2476
|
+
return typeof value.note === "string";
|
|
2477
|
+
}
|
|
2478
|
+
function isMissionListQueryResponse(value) {
|
|
2479
|
+
if (!isRecord(value) || !hasOnlyKeys2(value, ["missions", "historyFold", "truncated", "matched", "overflowIds"])) return false;
|
|
2480
|
+
if (!Array.isArray(value.missions) || !value.missions.every(isMissionListSummaryWire)) return false;
|
|
2481
|
+
if (value.historyFold !== null && !isMeshMissionHistoryFoldWire(value.historyFold)) return false;
|
|
2482
|
+
if (typeof value.truncated !== "boolean") return false;
|
|
2483
|
+
if (!isNonNegativeInt(value.matched)) return false;
|
|
2484
|
+
if (value.overflowIds !== void 0 && (!Array.isArray(value.overflowIds) || !value.overflowIds.every(isEvidenceIdentifier))) return false;
|
|
2485
|
+
return true;
|
|
2486
|
+
}
|
|
2487
|
+
function decodeMissionListQueryResponse(value) {
|
|
2488
|
+
return isMissionListQueryResponse(value) ? value : null;
|
|
2489
|
+
}
|
|
2490
|
+
var OPERATING_NOTE_CATEGORIES = ["provider_quirk", "pattern_to_avoid", "recovery_lesson"];
|
|
2491
|
+
var isOperatingNoteCategory = makeGuard3(OPERATING_NOTE_CATEGORIES);
|
|
2492
|
+
function isOptionalShortString(value, max = 512) {
|
|
2493
|
+
return value === void 0 || typeof value === "string" && value.trim().length > 0 && value.length <= max;
|
|
2494
|
+
}
|
|
2495
|
+
function isNoteUpsertRequest(value) {
|
|
2496
|
+
if (!isRecord(value) || !hasOnlyKeys2(value, ["v", "meshId", "text", "category", "pinned", "expiresAt", "supersedes", "subjectKey", "sourceCoordinator"])) return false;
|
|
2497
|
+
if (value.v !== TURN_IPC_PROTOCOL_VERSION) return false;
|
|
2498
|
+
if (!isEvidenceIdentifier(value.meshId)) return false;
|
|
2499
|
+
if (typeof value.text !== "string" || value.text.trim().length === 0) return false;
|
|
2500
|
+
if (value.category !== void 0 && !isOperatingNoteCategory(value.category)) return false;
|
|
2501
|
+
if (value.pinned !== void 0 && typeof value.pinned !== "boolean") return false;
|
|
2502
|
+
if (value.expiresAt !== void 0 && (typeof value.expiresAt !== "string" || Number.isNaN(Date.parse(value.expiresAt)))) return false;
|
|
2503
|
+
return isOptionalShortString(value.supersedes) && isOptionalShortString(value.subjectKey) && isOptionalShortString(value.sourceCoordinator);
|
|
2504
|
+
}
|
|
2505
|
+
function decodeNoteUpsertRequest(value) {
|
|
2506
|
+
return isNoteUpsertRequest(value) ? value : null;
|
|
2507
|
+
}
|
|
2508
|
+
function isNoteUpsertResponse(value) {
|
|
2509
|
+
return isRecord(value) && hasOnlyKeys2(value, ["noteId", "deduped", "createdAt"]) && isEvidenceIdentifier(value.noteId) && typeof value.deduped === "boolean" && typeof value.createdAt === "string";
|
|
2510
|
+
}
|
|
2511
|
+
function decodeNoteUpsertResponse(value) {
|
|
2512
|
+
return isNoteUpsertResponse(value) ? value : null;
|
|
2513
|
+
}
|
|
2514
|
+
function isNoteForgetRequest(value) {
|
|
2515
|
+
if (!isRecord(value) || !hasOnlyKeys2(value, ["v", "meshId", "noteId", "text", "reason"])) return false;
|
|
2516
|
+
if (value.v !== TURN_IPC_PROTOCOL_VERSION) return false;
|
|
2517
|
+
if (!isEvidenceIdentifier(value.meshId)) return false;
|
|
2518
|
+
if (value.noteId !== void 0 && !isEvidenceIdentifier(value.noteId)) return false;
|
|
2519
|
+
if (value.text !== void 0 && (typeof value.text !== "string" || value.text.trim().length === 0)) return false;
|
|
2520
|
+
if (value.noteId === void 0 && value.text === void 0) return false;
|
|
2521
|
+
return value.reason === void 0 || typeof value.reason === "string";
|
|
2522
|
+
}
|
|
2523
|
+
function decodeNoteForgetRequest(value) {
|
|
2524
|
+
return isNoteForgetRequest(value) ? value : null;
|
|
2525
|
+
}
|
|
2526
|
+
function isNoteForgetResponse(value) {
|
|
2527
|
+
return isRecord(value) && hasOnlyKeys2(value, ["matched", "tombstoneId"]) && typeof value.matched === "number" && Number.isInteger(value.matched) && value.matched >= 0 && isEvidenceIdentifier(value.tombstoneId);
|
|
2528
|
+
}
|
|
2529
|
+
function decodeNoteForgetResponse(value) {
|
|
2530
|
+
return isNoteForgetResponse(value) ? value : null;
|
|
2531
|
+
}
|
|
2532
|
+
var TOOL_CALLER_ROLES = ["coordinator", "unknown"];
|
|
2533
|
+
var isToolCallerRole = makeGuard3(TOOL_CALLER_ROLES);
|
|
2534
|
+
function isToolCallRecordRequest(value) {
|
|
2535
|
+
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);
|
|
2536
|
+
}
|
|
2537
|
+
function decodeToolCallRecordRequest(value) {
|
|
2538
|
+
return isToolCallRecordRequest(value) ? value : null;
|
|
2539
|
+
}
|
|
2540
|
+
function isToolCallRecordResponse(value) {
|
|
2541
|
+
return isRecord(value) && hasOnlyKeys2(value, ["rateLimitExceeded", "callsInWindow", "advisory"]) && typeof value.rateLimitExceeded === "boolean" && isNonNegativeInt(value.callsInWindow) && (value.advisory === null || typeof value.advisory === "string");
|
|
2542
|
+
}
|
|
2543
|
+
function decodeToolCallRecordResponse(value) {
|
|
2544
|
+
return isToolCallRecordResponse(value) ? value : null;
|
|
2545
|
+
}
|
|
2546
|
+
function isLedgerQueryRequest(value) {
|
|
2547
|
+
if (!isRecord(value) || !hasOnlyKeys2(value, ["v", "meshId", "kind", "since", "node", "tail", "includeSummary"])) return false;
|
|
2548
|
+
if (value.v !== TURN_IPC_PROTOCOL_VERSION) return false;
|
|
2549
|
+
if (!isEvidenceIdentifier(value.meshId)) return false;
|
|
2550
|
+
if (value.kind !== void 0 && (!Array.isArray(value.kind) || value.kind.length === 0 || !value.kind.every(isEvidenceIdentifier))) return false;
|
|
2551
|
+
if (value.since !== void 0 && typeof value.since !== "string") return false;
|
|
2552
|
+
if (!isOptionalId2(value.node)) return false;
|
|
2553
|
+
if (value.tail !== void 0 && !isNonNegativeInt(value.tail)) return false;
|
|
2554
|
+
if (value.includeSummary !== void 0 && typeof value.includeSummary !== "boolean") return false;
|
|
2555
|
+
return true;
|
|
2556
|
+
}
|
|
2557
|
+
function decodeLedgerQueryRequest(value) {
|
|
2558
|
+
return isLedgerQueryRequest(value) ? value : null;
|
|
2559
|
+
}
|
|
2560
|
+
var LEDGER_QUERY_ENTRY_KEYS = ["id", "meshId", "timestamp", "kind", "nodeId", "sessionId", "providerType", "taskId", "payload"];
|
|
2561
|
+
function isLedgerQueryEntryWire(value) {
|
|
2562
|
+
if (!isRecord(value) || !hasOnlyKeys2(value, LEDGER_QUERY_ENTRY_KEYS)) return false;
|
|
2563
|
+
if (!isEvidenceIdentifier(value.id) || !isEvidenceIdentifier(value.meshId)) return false;
|
|
2564
|
+
if (typeof value.timestamp !== "string" || typeof value.kind !== "string") return false;
|
|
2565
|
+
if (!isOptionalId2(value.nodeId) || !isOptionalId2(value.sessionId) || !isOptionalId2(value.providerType) || !isOptionalId2(value.taskId)) return false;
|
|
2566
|
+
if (!isRecord(value.payload)) return false;
|
|
2567
|
+
return true;
|
|
2568
|
+
}
|
|
2569
|
+
function isLedgerQuerySummaryWire(value) {
|
|
2570
|
+
const keys = ["meshId", "totalEntries", "taskDispatched", "taskCompleted", "taskFailed", "taskStalled", "sessionLaunched", "checkpointCreated", "lastActivityAt", "recentFailures"];
|
|
2571
|
+
if (!isRecord(value) || !hasOnlyKeys2(value, keys)) return false;
|
|
2572
|
+
if (!isEvidenceIdentifier(value.meshId)) return false;
|
|
2573
|
+
for (const k of ["totalEntries", "taskDispatched", "taskCompleted", "taskFailed", "taskStalled", "sessionLaunched", "checkpointCreated", "recentFailures"]) {
|
|
2574
|
+
if (!isNonNegativeInt(value[k])) return false;
|
|
2575
|
+
}
|
|
2576
|
+
if (value.lastActivityAt !== null && typeof value.lastActivityAt !== "string") return false;
|
|
2577
|
+
return true;
|
|
2578
|
+
}
|
|
2579
|
+
function isLedgerQueryResponse(value) {
|
|
2580
|
+
if (!isRecord(value) || !hasOnlyKeys2(value, ["entries", "summary"])) return false;
|
|
2581
|
+
if (!Array.isArray(value.entries) || !value.entries.every(isLedgerQueryEntryWire)) return false;
|
|
2582
|
+
if (value.summary !== void 0 && !isLedgerQuerySummaryWire(value.summary)) return false;
|
|
2583
|
+
return true;
|
|
2584
|
+
}
|
|
2585
|
+
function decodeLedgerQueryResponse(value) {
|
|
2586
|
+
return isLedgerQueryResponse(value) ? value : null;
|
|
2587
|
+
}
|
|
2588
|
+
function isRecordArray(value) {
|
|
2589
|
+
return Array.isArray(value) && value.every(isRecord);
|
|
2590
|
+
}
|
|
2591
|
+
function isOptionalRecord(value) {
|
|
2592
|
+
return value === void 0 || isRecord(value);
|
|
2593
|
+
}
|
|
2594
|
+
function isOptionalBoolean(value) {
|
|
2595
|
+
return value === void 0 || typeof value === "boolean";
|
|
2596
|
+
}
|
|
2597
|
+
function isOptionalString(value) {
|
|
2598
|
+
return value === void 0 || typeof value === "string";
|
|
2599
|
+
}
|
|
2600
|
+
function isQueueEntryWire(value) {
|
|
2601
|
+
return isRecord(value) && isEvidenceIdentifier(value.id) && typeof value.status === "string";
|
|
2602
|
+
}
|
|
2603
|
+
function isRecordLocalRequest(value) {
|
|
2604
|
+
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);
|
|
2605
|
+
}
|
|
2606
|
+
function decodeRecordLocalRequest(value) {
|
|
2607
|
+
return isRecordLocalRequest(value) ? value : null;
|
|
2608
|
+
}
|
|
2609
|
+
function isRecordLocalResponse(value) {
|
|
2610
|
+
return isRecord(value) && hasOnlyKeys2(value, ["eventId", "timestamp", "storedLocally", "published"]) && isEvidenceIdentifier(value.eventId) && typeof value.timestamp === "string" && typeof value.storedLocally === "boolean" && typeof value.published === "boolean";
|
|
2611
|
+
}
|
|
2612
|
+
function decodeRecordLocalResponse(value) {
|
|
2613
|
+
return isRecordLocalResponse(value) ? value : null;
|
|
2614
|
+
}
|
|
2615
|
+
function isQueueQueryRequest(value) {
|
|
2616
|
+
if (!isRecord(value) || !hasOnlyKeys2(value, ["v", "meshId", "statuses", "taskId", "view"])) return false;
|
|
2617
|
+
if (value.v !== TURN_IPC_PROTOCOL_VERSION || !isEvidenceIdentifier(value.meshId)) return false;
|
|
2618
|
+
if (value.statuses !== void 0 && (!Array.isArray(value.statuses) || !value.statuses.every(isEvidenceIdentifier))) return false;
|
|
2619
|
+
return isOptionalId2(value.taskId) && isOptionalBoolean(value.view);
|
|
2620
|
+
}
|
|
2621
|
+
function decodeQueueQueryRequest(value) {
|
|
2622
|
+
return isQueueQueryRequest(value) ? value : null;
|
|
2623
|
+
}
|
|
2624
|
+
function isQueueQueryResponse(value) {
|
|
2625
|
+
return isRecord(value) && hasOnlyKeys2(value, ["entries"]) && Array.isArray(value.entries) && value.entries.every(isQueueEntryWire);
|
|
2626
|
+
}
|
|
2627
|
+
function decodeQueueQueryResponse(value) {
|
|
2628
|
+
return isQueueQueryResponse(value) ? value : null;
|
|
2629
|
+
}
|
|
2630
|
+
function isQueueEnqueueRequest(value) {
|
|
2631
|
+
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);
|
|
2632
|
+
}
|
|
2633
|
+
function decodeQueueEnqueueRequest(value) {
|
|
2634
|
+
return isQueueEnqueueRequest(value) ? value : null;
|
|
2635
|
+
}
|
|
2636
|
+
function isQueueEnqueueResponse(value) {
|
|
2637
|
+
return isRecord(value) && hasOnlyKeys2(value, ["entry"]) && isQueueEntryWire(value.entry);
|
|
2638
|
+
}
|
|
2639
|
+
function decodeQueueEnqueueResponse(value) {
|
|
2640
|
+
return isQueueEnqueueResponse(value) ? value : null;
|
|
2641
|
+
}
|
|
2642
|
+
function isQueueEnqueueGraphRequest(value) {
|
|
2643
|
+
if (!isRecord(value) || !hasOnlyKeys2(value, ["v", "meshId", "mode", "specs", "plan", "audit"])) return false;
|
|
2644
|
+
if (value.v !== TURN_IPC_PROTOCOL_VERSION || !isEvidenceIdentifier(value.meshId)) return false;
|
|
2645
|
+
if (value.mode === "compat") return isRecordArray(value.specs) && value.plan === void 0 && isOptionalRecord(value.audit);
|
|
2646
|
+
if (value.mode === "graph") return isRecord(value.plan) && value.specs === void 0 && isOptionalRecord(value.audit);
|
|
2647
|
+
return false;
|
|
2648
|
+
}
|
|
2649
|
+
function decodeQueueEnqueueGraphRequest(value) {
|
|
2650
|
+
return isQueueEnqueueGraphRequest(value) ? value : null;
|
|
2651
|
+
}
|
|
2652
|
+
function isQueueEnqueueGraphResponse(value) {
|
|
2653
|
+
if (!isRecord(value)) return false;
|
|
2654
|
+
if (value.ok === true) {
|
|
2655
|
+
return hasOnlyKeys2(value, ["ok", "tasks", "graph"]) && Array.isArray(value.tasks) && value.tasks.every(isQueueEntryWire) && isOptionalRecord(value.graph);
|
|
2656
|
+
}
|
|
2657
|
+
if (value.ok === false) {
|
|
2658
|
+
return hasOnlyKeys2(value, ["ok", "refusalCode", "message", "extra"]) && typeof value.message === "string" && isOptionalString(value.refusalCode) && isOptionalRecord(value.extra);
|
|
2659
|
+
}
|
|
2660
|
+
return false;
|
|
2661
|
+
}
|
|
2662
|
+
function decodeQueueEnqueueGraphResponse(value) {
|
|
2663
|
+
return isQueueEnqueueGraphResponse(value) ? value : null;
|
|
2664
|
+
}
|
|
2665
|
+
function isQueueCancelRequest(value) {
|
|
2666
|
+
return isRecord(value) && hasOnlyKeys2(value, ["v", "meshId", "taskId", "reason"]) && value.v === TURN_IPC_PROTOCOL_VERSION && isEvidenceIdentifier(value.meshId) && isEvidenceIdentifier(value.taskId) && isOptionalString(value.reason);
|
|
2667
|
+
}
|
|
2668
|
+
function decodeQueueCancelRequest(value) {
|
|
2669
|
+
return isQueueCancelRequest(value) ? value : null;
|
|
2670
|
+
}
|
|
2671
|
+
function isQueueCancelResponse(value) {
|
|
2672
|
+
return isRecord(value) && hasOnlyKeys2(value, ["task", "before"]) && (value.task === null || isQueueEntryWire(value.task)) && (value.before === null || isQueueEntryWire(value.before));
|
|
2673
|
+
}
|
|
2674
|
+
function decodeQueueCancelResponse(value) {
|
|
2675
|
+
return isQueueCancelResponse(value) ? value : null;
|
|
2676
|
+
}
|
|
2677
|
+
function isQueueRequeueRequest(value) {
|
|
2678
|
+
return isRecord(value) && hasOnlyKeys2(value, ["v", "meshId", "taskId", "options"]) && value.v === TURN_IPC_PROTOCOL_VERSION && isEvidenceIdentifier(value.meshId) && isEvidenceIdentifier(value.taskId) && isOptionalRecord(value.options);
|
|
2679
|
+
}
|
|
2680
|
+
function decodeQueueRequeueRequest(value) {
|
|
2681
|
+
return isQueueRequeueRequest(value) ? value : null;
|
|
2682
|
+
}
|
|
2683
|
+
function isQueueRequeueResponse(value) {
|
|
2684
|
+
return isRecord(value) && hasOnlyKeys2(value, ["task"]) && (value.task === null || isQueueEntryWire(value.task));
|
|
2685
|
+
}
|
|
2686
|
+
function decodeQueueRequeueResponse(value) {
|
|
2687
|
+
return isQueueRequeueResponse(value) ? value : null;
|
|
2688
|
+
}
|
|
2689
|
+
function isDirectDispatchRecordRequest(value) {
|
|
2690
|
+
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);
|
|
2691
|
+
}
|
|
2692
|
+
function decodeDirectDispatchRecordRequest(value) {
|
|
2693
|
+
return isDirectDispatchRecordRequest(value) ? value : null;
|
|
2694
|
+
}
|
|
2695
|
+
function isDirectDispatchRecordResponse(value) {
|
|
2696
|
+
return isRecord(value) && hasOnlyKeys2(value, ["taskRecorded", "decisionRecorded"]) && typeof value.taskRecorded === "boolean" && typeof value.decisionRecorded === "boolean";
|
|
2697
|
+
}
|
|
2698
|
+
function decodeDirectDispatchRecordResponse(value) {
|
|
2699
|
+
return isDirectDispatchRecordResponse(value) ? value : null;
|
|
2700
|
+
}
|
|
2701
|
+
var GRAPH_AUDIT_EVENTS = ["gate_claimed", "gate_released", "gate_abandoned", "node_patched"];
|
|
2702
|
+
var isGraphAuditEvent = makeGuard3(GRAPH_AUDIT_EVENTS);
|
|
2703
|
+
function isGraphAuditRecordRequest(value) {
|
|
2704
|
+
return isRecord(value) && hasOnlyKeys2(value, ["v", "meshId", "event", "fields"]) && value.v === TURN_IPC_PROTOCOL_VERSION && isEvidenceIdentifier(value.meshId) && isGraphAuditEvent(value.event) && isRecord(value.fields);
|
|
2705
|
+
}
|
|
2706
|
+
function decodeGraphAuditRecordRequest(value) {
|
|
2707
|
+
return isGraphAuditRecordRequest(value) ? value : null;
|
|
2708
|
+
}
|
|
2709
|
+
function isGraphAuditRecordResponse(value) {
|
|
2710
|
+
return isRecord(value) && hasOnlyKeys2(value, ["recorded"]) && typeof value.recorded === "boolean";
|
|
2711
|
+
}
|
|
2712
|
+
function decodeGraphAuditRecordResponse(value) {
|
|
2713
|
+
return isGraphAuditRecordResponse(value) ? value : null;
|
|
2714
|
+
}
|
|
2715
|
+
function isActiveWorkQueryRequest(value) {
|
|
2716
|
+
if (!isRecord(value) || !hasOnlyKeys2(value, ["v", "meshId", "nodes", "queue", "recordTail", "includeTerminalDirect", "compute", "includeInputs", "includeSummary", "includeSchedulingRuntime", "mesh"])) return false;
|
|
2717
|
+
if (value.v !== TURN_IPC_PROTOCOL_VERSION || !isEvidenceIdentifier(value.meshId)) return false;
|
|
2718
|
+
if (value.nodes !== void 0 && !isRecordArray(value.nodes)) return false;
|
|
2719
|
+
if (value.queue !== void 0 && !isRecordArray(value.queue)) return false;
|
|
2720
|
+
if (value.recordTail !== void 0 && !isNonNegativeInt(value.recordTail)) return false;
|
|
2721
|
+
if (value.includeSchedulingRuntime === true && !isRecord(value.mesh)) return false;
|
|
2722
|
+
return isOptionalBoolean(value.includeTerminalDirect) && isOptionalBoolean(value.compute) && isOptionalBoolean(value.includeInputs) && isOptionalBoolean(value.includeSummary) && isOptionalBoolean(value.includeSchedulingRuntime) && isOptionalRecord(value.mesh);
|
|
2723
|
+
}
|
|
2724
|
+
function decodeActiveWorkQueryRequest(value) {
|
|
2725
|
+
return isActiveWorkQueryRequest(value) ? value : null;
|
|
2726
|
+
}
|
|
2727
|
+
function isActiveWorkQueryResponse(value) {
|
|
2728
|
+
if (!isRecord(value) || !hasOnlyKeys2(value, ["activeWork", "records", "directDispatches", "summary", "schedulingRuntime"])) return false;
|
|
2729
|
+
if (value.records !== void 0 && !isRecordArray(value.records)) return false;
|
|
2730
|
+
if (value.directDispatches !== void 0 && !isRecordArray(value.directDispatches)) return false;
|
|
2731
|
+
return isOptionalRecord(value.activeWork) && isOptionalRecord(value.summary) && isOptionalRecord(value.schedulingRuntime);
|
|
2732
|
+
}
|
|
2733
|
+
function decodeActiveWorkQueryResponse(value) {
|
|
2734
|
+
return isActiveWorkQueryResponse(value) ? value : null;
|
|
2735
|
+
}
|
|
2736
|
+
function isRecoveryContextQueryRequest(value) {
|
|
2737
|
+
return isRecord(value) && hasOnlyKeys2(value, ["v", "meshId", "nodeId", "sessionId", "maxRetries"]) && value.v === TURN_IPC_PROTOCOL_VERSION && isEvidenceIdentifier(value.meshId) && isOptionalId2(value.nodeId) && isOptionalId2(value.sessionId) && (value.maxRetries === void 0 || isNonNegativeInt(value.maxRetries)) && (value.nodeId !== void 0 || value.sessionId !== void 0);
|
|
2738
|
+
}
|
|
2739
|
+
function decodeRecoveryContextQueryRequest(value) {
|
|
2740
|
+
return isRecoveryContextQueryRequest(value) ? value : null;
|
|
2741
|
+
}
|
|
2742
|
+
function isRecoveryContextQueryResponse(value) {
|
|
2743
|
+
return isRecord(value) && hasOnlyKeys2(value, ["context"]) && isRecord(value.context) && typeof value.context.consecutiveNodeFailures === "number";
|
|
2744
|
+
}
|
|
2745
|
+
function decodeRecoveryContextQueryResponse(value) {
|
|
2746
|
+
return isRecoveryContextQueryResponse(value) ? value : null;
|
|
2747
|
+
}
|
|
2748
|
+
function isGraphGateClaimRequest(value) {
|
|
2749
|
+
if (!isRecord(value) || !hasOnlyKeys2(value, ["v", "meshId", "gateId", "coordinatorSessionId", "leaseSeconds", "extendDeadlineSeconds", "probeConvergenceEvidence"])) return false;
|
|
2750
|
+
if (value.v !== TURN_IPC_PROTOCOL_VERSION || !isEvidenceIdentifier(value.meshId) || !isEvidenceIdentifier(value.gateId) || !isEvidenceIdentifier(value.coordinatorSessionId)) return false;
|
|
2751
|
+
if (value.leaseSeconds !== void 0 && !isFiniteNumber3(value.leaseSeconds)) return false;
|
|
2752
|
+
if (value.extendDeadlineSeconds !== void 0 && !isFiniteNumber3(value.extendDeadlineSeconds)) return false;
|
|
2753
|
+
return isOptionalBoolean(value.probeConvergenceEvidence);
|
|
2754
|
+
}
|
|
2755
|
+
function decodeGraphGateClaimRequest(value) {
|
|
2756
|
+
return isGraphGateClaimRequest(value) ? value : null;
|
|
2757
|
+
}
|
|
2758
|
+
function isGraphGateClaimResponse(value) {
|
|
2759
|
+
if (!isRecord(value) || !hasOnlyKeys2(value, ["claimed", "reason", "gate", "leaseGeneration", "fencingToken", "leaseExpiresAt", "deadlineAt", "ambiguousExternalOutcome", "previousLeaseOwnerSessionId", "convergenceEvidence"])) return false;
|
|
2760
|
+
if (typeof value.claimed !== "boolean") return false;
|
|
2761
|
+
return isOptionalRecord(value.gate) && isOptionalRecord(value.convergenceEvidence) && isOptionalBoolean(value.ambiguousExternalOutcome);
|
|
2762
|
+
}
|
|
2763
|
+
function decodeGraphGateClaimResponse(value) {
|
|
2764
|
+
return isGraphGateClaimResponse(value) ? value : null;
|
|
2765
|
+
}
|
|
2766
|
+
function isGraphGateReleaseRequest(value) {
|
|
2767
|
+
if (!isRecord(value) || !hasOnlyKeys2(value, ["v", "meshId", "gateId", "fencingToken", "leaseGeneration", "idempotencyKey", "outcome", "result", "evidence", "patches"])) return false;
|
|
2768
|
+
if (value.v !== TURN_IPC_PROTOCOL_VERSION || !isEvidenceIdentifier(value.meshId) || !isEvidenceIdentifier(value.gateId)) return false;
|
|
2769
|
+
if (typeof value.fencingToken !== "string" || !value.fencingToken) return false;
|
|
2770
|
+
if (!isFiniteNumber3(value.leaseGeneration)) return false;
|
|
2771
|
+
if (typeof value.idempotencyKey !== "string" || !value.idempotencyKey) return false;
|
|
2772
|
+
if (typeof value.outcome !== "string" || !value.outcome) return false;
|
|
2773
|
+
if (value.patches !== void 0) {
|
|
2774
|
+
if (!Array.isArray(value.patches)) return false;
|
|
2775
|
+
for (const p of value.patches) {
|
|
2776
|
+
if (!isRecord(p) || typeof p.node !== "string" || !p.node || !isRecord(p.baseSpecPatch)) return false;
|
|
2777
|
+
}
|
|
2778
|
+
}
|
|
2779
|
+
return true;
|
|
2780
|
+
}
|
|
2781
|
+
function decodeGraphGateReleaseRequest(value) {
|
|
2782
|
+
return isGraphGateReleaseRequest(value) ? value : null;
|
|
2783
|
+
}
|
|
2784
|
+
function isGraphGateReleaseResponse(value) {
|
|
2785
|
+
if (!isRecord(value)) return false;
|
|
2786
|
+
if (value.released === true) {
|
|
2787
|
+
if (!hasOnlyKeys2(value, ["released", "duplicate", "gate", "materializedNodeIds", "downstreamNodeCount", "graphCompleted"])) return false;
|
|
2788
|
+
if (typeof value.duplicate !== "boolean") return false;
|
|
2789
|
+
if (!Array.isArray(value.materializedNodeIds) || !value.materializedNodeIds.every((n) => typeof n === "string")) return false;
|
|
2790
|
+
if (value.downstreamNodeCount !== void 0 && !isNonNegativeInt(value.downstreamNodeCount)) return false;
|
|
2791
|
+
return isOptionalRecord(value.gate) && isOptionalBoolean(value.graphCompleted);
|
|
2792
|
+
}
|
|
2793
|
+
if (value.released === false) {
|
|
2794
|
+
return hasOnlyKeys2(value, ["released", "refusalCode", "message"]) && typeof value.message === "string" && isOptionalString(value.refusalCode);
|
|
2795
|
+
}
|
|
2796
|
+
return false;
|
|
2797
|
+
}
|
|
2798
|
+
function decodeGraphGateReleaseResponse(value) {
|
|
2799
|
+
return isGraphGateReleaseResponse(value) ? value : null;
|
|
2800
|
+
}
|
|
2801
|
+
function isGraphGateAbandonRequest(value) {
|
|
2802
|
+
if (!isRecord(value) || !hasOnlyKeys2(value, ["v", "meshId", "gateId", "reason", "coordinatorSessionId", "force"])) return false;
|
|
2803
|
+
if (value.v !== TURN_IPC_PROTOCOL_VERSION || !isEvidenceIdentifier(value.meshId) || !isEvidenceIdentifier(value.gateId)) return false;
|
|
2804
|
+
if (typeof value.reason !== "string" || !value.reason) return false;
|
|
2805
|
+
if (value.coordinatorSessionId !== void 0 && !isEvidenceIdentifier(value.coordinatorSessionId)) return false;
|
|
2806
|
+
return isOptionalBoolean(value.force);
|
|
2807
|
+
}
|
|
2808
|
+
function decodeGraphGateAbandonRequest(value) {
|
|
2809
|
+
return isGraphGateAbandonRequest(value) ? value : null;
|
|
2810
|
+
}
|
|
2811
|
+
function isGraphGateAbandonResponse(value) {
|
|
2812
|
+
if (!isRecord(value) || !hasOnlyKeys2(value, ["abandoned", "reason", "gate", "cancelledNodeIds", "cancelledTaskIds", "graphStatus"])) return false;
|
|
2813
|
+
if (typeof value.abandoned !== "boolean") return false;
|
|
2814
|
+
if (!Array.isArray(value.cancelledNodeIds) || !value.cancelledNodeIds.every((n) => typeof n === "string")) return false;
|
|
2815
|
+
if (!Array.isArray(value.cancelledTaskIds) || !value.cancelledTaskIds.every((n) => typeof n === "string")) return false;
|
|
2816
|
+
return isOptionalRecord(value.gate);
|
|
2817
|
+
}
|
|
2818
|
+
function decodeGraphGateAbandonResponse(value) {
|
|
2819
|
+
return isGraphGateAbandonResponse(value) ? value : null;
|
|
2820
|
+
}
|
|
2821
|
+
function isGraphNodePatchRequest(value) {
|
|
2822
|
+
if (!isRecord(value) || !hasOnlyKeys2(value, ["v", "meshId", "node", "graphId", "baseSpecPatch"])) return false;
|
|
2823
|
+
if (value.v !== TURN_IPC_PROTOCOL_VERSION || !isEvidenceIdentifier(value.meshId)) return false;
|
|
2824
|
+
if (typeof value.node !== "string" || !value.node) return false;
|
|
2825
|
+
if (value.graphId !== void 0 && !isEvidenceIdentifier(value.graphId)) return false;
|
|
2826
|
+
return isRecord(value.baseSpecPatch) && Object.keys(value.baseSpecPatch).length > 0;
|
|
2827
|
+
}
|
|
2828
|
+
function decodeGraphNodePatchRequest(value) {
|
|
2829
|
+
return isGraphNodePatchRequest(value) ? value : null;
|
|
2830
|
+
}
|
|
2831
|
+
function isGraphNodePatchResponse(value) {
|
|
2832
|
+
if (!isRecord(value)) return false;
|
|
2833
|
+
if (value.patched === true) {
|
|
2834
|
+
if (!hasOnlyKeys2(value, ["patched", "graphId", "nodeId", "ref", "queueTaskId", "materializationVersion", "state", "outcomeKind", "skippedReason", "blockedReason"])) return false;
|
|
2835
|
+
if (!isEvidenceIdentifier(value.graphId) || !isEvidenceIdentifier(value.nodeId)) return false;
|
|
2836
|
+
if (!isNonNegativeInt(value.materializationVersion)) return false;
|
|
2837
|
+
return typeof value.state === "string" && typeof value.outcomeKind === "string";
|
|
2838
|
+
}
|
|
2839
|
+
if (value.patched === false) {
|
|
2840
|
+
return hasOnlyKeys2(value, ["patched", "refusalCode", "message"]) && typeof value.message === "string" && isOptionalString(value.refusalCode);
|
|
2841
|
+
}
|
|
2842
|
+
return false;
|
|
2843
|
+
}
|
|
2844
|
+
function decodeGraphNodePatchResponse(value) {
|
|
2845
|
+
return isGraphNodePatchResponse(value) ? value : null;
|
|
2846
|
+
}
|
|
2847
|
+
function isGraphViewQueryRequest(value) {
|
|
2848
|
+
if (!isRecord(value) || !hasOnlyKeys2(value, ["v", "meshId", "graphId", "batchId", "activeOnly", "limit", "probeGateEvidence"])) return false;
|
|
2849
|
+
if (value.v !== TURN_IPC_PROTOCOL_VERSION || !isEvidenceIdentifier(value.meshId)) return false;
|
|
2850
|
+
if (value.graphId !== void 0 && !isEvidenceIdentifier(value.graphId)) return false;
|
|
2851
|
+
if (value.batchId !== void 0 && !isEvidenceIdentifier(value.batchId)) return false;
|
|
2852
|
+
if (value.limit !== void 0 && !isNonNegativeInt(value.limit)) return false;
|
|
2853
|
+
return isOptionalBoolean(value.activeOnly) && isOptionalBoolean(value.probeGateEvidence);
|
|
2854
|
+
}
|
|
2855
|
+
function decodeGraphViewQueryRequest(value) {
|
|
2856
|
+
return isGraphViewQueryRequest(value) ? value : null;
|
|
2857
|
+
}
|
|
2858
|
+
function isGraphViewQueryResponse(value) {
|
|
2859
|
+
return isRecord(value) && hasOnlyKeys2(value, ["graphs"]) && isRecordArray(value.graphs);
|
|
2860
|
+
}
|
|
2861
|
+
function decodeGraphViewQueryResponse(value) {
|
|
2862
|
+
return isGraphViewQueryResponse(value) ? value : null;
|
|
2863
|
+
}
|
|
2864
|
+
function isTaskStatsQueryRequest(value) {
|
|
2865
|
+
if (!isRecord(value) || !hasOnlyKeys2(value, ["v", "meshId", "taskIds", "missionId", "tail", "rollup"])) return false;
|
|
2866
|
+
if (value.v !== TURN_IPC_PROTOCOL_VERSION || !isEvidenceIdentifier(value.meshId)) return false;
|
|
2867
|
+
if (value.taskIds !== void 0) {
|
|
2868
|
+
if (!Array.isArray(value.taskIds) || value.taskIds.length === 0 || !value.taskIds.every(isEvidenceIdentifier)) return false;
|
|
2869
|
+
}
|
|
2870
|
+
if (value.missionId !== void 0 && !isEvidenceIdentifier(value.missionId)) return false;
|
|
2871
|
+
if (value.tail !== void 0 && !isNonNegativeInt(value.tail)) return false;
|
|
2872
|
+
if (value.rollup === true && value.missionId === void 0) return false;
|
|
2873
|
+
return isOptionalBoolean(value.rollup);
|
|
2874
|
+
}
|
|
2875
|
+
function decodeTaskStatsQueryRequest(value) {
|
|
2876
|
+
return isTaskStatsQueryRequest(value) ? value : null;
|
|
2877
|
+
}
|
|
2878
|
+
function isTaskStatsQueryResponse(value) {
|
|
2879
|
+
return isRecord(value) && hasOnlyKeys2(value, ["tasks", "mission"]) && isRecordArray(value.tasks) && isOptionalRecord(value.mission);
|
|
2880
|
+
}
|
|
2881
|
+
function decodeTaskStatsQueryResponse(value) {
|
|
2882
|
+
return isTaskStatsQueryResponse(value) ? value : null;
|
|
2883
|
+
}
|
|
2884
|
+
function isPruneStaleDirectRequest(value) {
|
|
2885
|
+
if (!isRecord(value) || !hasOnlyKeys2(value, ["v", "meshId", "execute", "includeTerminal", "source"])) return false;
|
|
2886
|
+
if (value.v !== TURN_IPC_PROTOCOL_VERSION || !isEvidenceIdentifier(value.meshId)) return false;
|
|
2887
|
+
if (value.source !== void 0 && typeof value.source !== "string") return false;
|
|
2888
|
+
return isOptionalBoolean(value.execute) && isOptionalBoolean(value.includeTerminal);
|
|
2889
|
+
}
|
|
2890
|
+
function decodePruneStaleDirectRequest(value) {
|
|
2891
|
+
return isPruneStaleDirectRequest(value) ? value : null;
|
|
2892
|
+
}
|
|
2893
|
+
function isPruneStaleDirectResponse(value) {
|
|
2894
|
+
if (!isRecord(value) || !hasOnlyKeys2(value, ["mode", "includeTerminal", "candidateCount", "prunable", "prunedCount", "preservedUnacknowledged", "preservedLedgerOnly", "preservedNotOrphan"])) return false;
|
|
2895
|
+
if (value.mode !== "execute" && value.mode !== "dry_run") return false;
|
|
2896
|
+
if (typeof value.includeTerminal !== "boolean") return false;
|
|
2897
|
+
if (!isNonNegativeInt(value.candidateCount) || !isNonNegativeInt(value.prunedCount)) return false;
|
|
2898
|
+
return isRecordArray(value.prunable) && isRecordArray(value.preservedUnacknowledged) && isRecordArray(value.preservedLedgerOnly) && isRecordArray(value.preservedNotOrphan);
|
|
2899
|
+
}
|
|
2900
|
+
function decodePruneStaleDirectResponse(value) {
|
|
2901
|
+
return isPruneStaleDirectResponse(value) ? value : null;
|
|
2902
|
+
}
|
|
2903
|
+
function isOrphanedPinnedTaskWire(value) {
|
|
2904
|
+
if (!isRecord(value) || !hasOnlyKeys2(value, ["taskId", "title", "targetSessionId", "targetNodeId", "missionId"])) return false;
|
|
2905
|
+
if (!isEvidenceIdentifier(value.taskId) || !isEvidenceIdentifier(value.targetSessionId)) return false;
|
|
2906
|
+
if (typeof value.title !== "string") return false;
|
|
2907
|
+
if (value.targetNodeId !== void 0 && !isEvidenceIdentifier(value.targetNodeId)) return false;
|
|
2908
|
+
return value.missionId === void 0 || isEvidenceIdentifier(value.missionId);
|
|
2909
|
+
}
|
|
2910
|
+
function isOrphanedPinNotifyRequest(value) {
|
|
2911
|
+
if (!isRecord(value) || !hasOnlyKeys2(value, ["v", "meshId", "stoppedSessionId", "excludeTaskId", "cause", "nodeId", "coordinatorSessionId"])) return false;
|
|
2912
|
+
if (value.v !== TURN_IPC_PROTOCOL_VERSION || !isEvidenceIdentifier(value.meshId) || !isEvidenceIdentifier(value.stoppedSessionId)) return false;
|
|
2913
|
+
if (value.excludeTaskId !== void 0 && !isEvidenceIdentifier(value.excludeTaskId)) return false;
|
|
2914
|
+
if (value.cause !== void 0 && typeof value.cause !== "string") return false;
|
|
2915
|
+
if (value.nodeId !== void 0 && !isEvidenceIdentifier(value.nodeId)) return false;
|
|
2916
|
+
return value.coordinatorSessionId === void 0 || isEvidenceIdentifier(value.coordinatorSessionId);
|
|
2917
|
+
}
|
|
2918
|
+
function decodeOrphanedPinNotifyRequest(value) {
|
|
2919
|
+
return isOrphanedPinNotifyRequest(value) ? value : null;
|
|
2920
|
+
}
|
|
2921
|
+
function isOrphanedPinNotifyResponse(value) {
|
|
2922
|
+
return isRecord(value) && hasOnlyKeys2(value, ["orphans"]) && Array.isArray(value.orphans) && value.orphans.every(isOrphanedPinnedTaskWire);
|
|
2923
|
+
}
|
|
2924
|
+
function decodeOrphanedPinNotifyResponse(value) {
|
|
2925
|
+
return isOrphanedPinNotifyResponse(value) ? value : null;
|
|
2926
|
+
}
|
|
2927
|
+
var TURN_IPC_COMMANDS = [
|
|
2928
|
+
"turn_observe",
|
|
2929
|
+
"mesh_record",
|
|
2930
|
+
"turn_cancel",
|
|
2931
|
+
"operator_status",
|
|
2932
|
+
"turn_query",
|
|
2933
|
+
"mesh_index_query",
|
|
2934
|
+
"mission_upsert",
|
|
2935
|
+
"mission_query",
|
|
2936
|
+
"note_upsert",
|
|
2937
|
+
"note_forget",
|
|
2938
|
+
// C-W9b additions (2026-09-24 14:00 stamp "C-W9"):
|
|
2939
|
+
"tool_call_record",
|
|
2940
|
+
"ledger_query",
|
|
2941
|
+
"mission_list_query",
|
|
2942
|
+
// C-W9a additions (the event ledger retired; the queue behind IPC):
|
|
2943
|
+
"record_local",
|
|
2944
|
+
"queue_query",
|
|
2945
|
+
"queue_enqueue",
|
|
2946
|
+
"queue_enqueue_graph",
|
|
2947
|
+
"queue_cancel",
|
|
2948
|
+
"queue_requeue",
|
|
2949
|
+
"direct_dispatch_record",
|
|
2950
|
+
"graph_audit_record",
|
|
2951
|
+
"active_work_query",
|
|
2952
|
+
"recovery_context_query",
|
|
2953
|
+
// C-W9c additions (2026-09-24 19:00 stamp — the last mcp-server in-process
|
|
2954
|
+
// daemon-core paths: graph gates/plan/patch, mission reads (MAGI), task/
|
|
2955
|
+
// mission stats, orphaned-pin helpers, one prune audit):
|
|
2956
|
+
"graph_gate_claim",
|
|
2957
|
+
"graph_gate_release",
|
|
2958
|
+
"graph_gate_abandon",
|
|
2959
|
+
"graph_node_patch",
|
|
2960
|
+
"graph_view_query",
|
|
2961
|
+
"task_stats_query",
|
|
2962
|
+
"prune_stale_direct",
|
|
2963
|
+
"orphaned_pin_notify"
|
|
2964
|
+
];
|
|
2965
|
+
var isTurnIpcCommand = makeGuard3(TURN_IPC_COMMANDS);
|
|
2966
|
+
|
|
2967
|
+
// src/path-ownership.ts
|
|
2968
|
+
var MAX_OWNED_PATHS = 64;
|
|
2969
|
+
function toPosix(raw) {
|
|
2970
|
+
return raw.replace(/\\/g, "/");
|
|
2971
|
+
}
|
|
2972
|
+
function normalizeOne(raw, rejected) {
|
|
2973
|
+
if (typeof raw !== "string") {
|
|
2974
|
+
rejected.push({ input: String(raw), reason: "not_a_string" });
|
|
2975
|
+
return null;
|
|
2976
|
+
}
|
|
2977
|
+
const trimmed = raw.trim();
|
|
2978
|
+
if (!trimmed) {
|
|
2979
|
+
rejected.push({ input: raw, reason: "empty" });
|
|
2980
|
+
return null;
|
|
2981
|
+
}
|
|
2982
|
+
let posix = toPosix(trimmed);
|
|
2983
|
+
if (posix.startsWith("/") || /^[a-zA-Z]:\//.test(posix) || posix.startsWith("~")) {
|
|
2984
|
+
rejected.push({ input: raw, reason: "absolute_path" });
|
|
2985
|
+
return null;
|
|
2986
|
+
}
|
|
2987
|
+
posix = posix.replace(/^\.\/+/, "");
|
|
2988
|
+
const segments = posix.split("/").filter(Boolean);
|
|
2989
|
+
if (segments.some((seg) => seg === "..")) {
|
|
2990
|
+
rejected.push({ input: raw, reason: "parent_traversal" });
|
|
2991
|
+
return null;
|
|
2992
|
+
}
|
|
2993
|
+
if (segments.length === 0) {
|
|
2994
|
+
rejected.push({ input: raw, reason: "empty" });
|
|
2995
|
+
return null;
|
|
2996
|
+
}
|
|
2997
|
+
let subtree = false;
|
|
2998
|
+
if (segments[segments.length - 1] === "**") {
|
|
2999
|
+
subtree = true;
|
|
3000
|
+
segments.pop();
|
|
3001
|
+
if (segments.length === 0) {
|
|
3002
|
+
}
|
|
3003
|
+
}
|
|
3004
|
+
if (segments.some((seg) => seg.includes("*") || seg.includes("?"))) {
|
|
3005
|
+
rejected.push({ input: raw, reason: "unsupported_glob" });
|
|
3006
|
+
return null;
|
|
3007
|
+
}
|
|
3008
|
+
return { path: segments.join("/"), subtree };
|
|
3009
|
+
}
|
|
3010
|
+
function normalizeOwnedPaths(input) {
|
|
3011
|
+
const rejected = [];
|
|
3012
|
+
if (input === void 0 || input === null) {
|
|
3013
|
+
return { declaration: { paths: [] }, rejected };
|
|
3014
|
+
}
|
|
3015
|
+
if (!Array.isArray(input)) {
|
|
3016
|
+
return { declaration: { paths: [] }, rejected: [{ input: String(input), reason: "not_an_array" }] };
|
|
3017
|
+
}
|
|
3018
|
+
const byPath = /* @__PURE__ */ new Map();
|
|
3019
|
+
for (const raw of input) {
|
|
3020
|
+
const entry = normalizeOne(raw, rejected);
|
|
3021
|
+
if (!entry) continue;
|
|
3022
|
+
const existing = byPath.get(entry.path);
|
|
3023
|
+
if (!existing) {
|
|
3024
|
+
byPath.set(entry.path, entry);
|
|
3025
|
+
} else if (entry.subtree && !existing.subtree) {
|
|
3026
|
+
byPath.set(entry.path, entry);
|
|
3027
|
+
}
|
|
3028
|
+
}
|
|
3029
|
+
const all = [...byPath.values()];
|
|
3030
|
+
const kept = all.slice(0, MAX_OWNED_PATHS);
|
|
3031
|
+
for (const dropped of all.slice(MAX_OWNED_PATHS)) {
|
|
3032
|
+
rejected.push({ input: dropped.path, reason: "over_cap" });
|
|
3033
|
+
}
|
|
3034
|
+
return { declaration: { paths: kept }, rejected };
|
|
3035
|
+
}
|
|
3036
|
+
function entryContains(base, path) {
|
|
3037
|
+
if (path === base.path) return true;
|
|
3038
|
+
if (base.subtree && (path === base.path || path.startsWith(`${base.path}/`))) return true;
|
|
3039
|
+
return false;
|
|
3040
|
+
}
|
|
3041
|
+
function entriesOverlap(a, b) {
|
|
3042
|
+
if (a.path === b.path) return true;
|
|
3043
|
+
if (a.subtree && (b.path === a.path || b.path.startsWith(`${a.path}/`))) return true;
|
|
3044
|
+
if (b.subtree && (a.path === b.path || a.path.startsWith(`${b.path}/`))) return true;
|
|
3045
|
+
return false;
|
|
3046
|
+
}
|
|
3047
|
+
function pathsOverlap(a, b) {
|
|
3048
|
+
if (a.paths.length === 0 || b.paths.length === 0) return false;
|
|
3049
|
+
for (const pa of a.paths) {
|
|
3050
|
+
for (const pb of b.paths) {
|
|
3051
|
+
if (entriesOverlap(pa, pb)) return true;
|
|
3052
|
+
}
|
|
3053
|
+
}
|
|
3054
|
+
return false;
|
|
3055
|
+
}
|
|
3056
|
+
function findOwnershipConflicts(candidate, inFlight) {
|
|
3057
|
+
if (candidate.paths.length === 0) return [];
|
|
3058
|
+
const conflicts = [];
|
|
3059
|
+
for (const other of inFlight) {
|
|
3060
|
+
if (other.paths.paths.length === 0) continue;
|
|
3061
|
+
const overlappingPaths = [];
|
|
3062
|
+
for (const pa of candidate.paths) {
|
|
3063
|
+
for (const pb of other.paths.paths) {
|
|
3064
|
+
if (entriesOverlap(pa, pb)) {
|
|
3065
|
+
const narrower = pa.path.length >= pb.path.length ? pa.path : pb.path;
|
|
3066
|
+
if (!overlappingPaths.includes(narrower)) overlappingPaths.push(narrower);
|
|
3067
|
+
}
|
|
3068
|
+
}
|
|
3069
|
+
}
|
|
3070
|
+
if (overlappingPaths.length > 0) {
|
|
3071
|
+
conflicts.push({ taskId: other.taskId, overlappingPaths });
|
|
3072
|
+
}
|
|
3073
|
+
}
|
|
3074
|
+
return conflicts;
|
|
3075
|
+
}
|
|
3076
|
+
function touchedFilesOutsideOwnership(touched, owned) {
|
|
3077
|
+
const undeclaredTouched = [];
|
|
3078
|
+
const usedDeclarations = /* @__PURE__ */ new Set();
|
|
3079
|
+
for (const raw of touched ?? []) {
|
|
3080
|
+
const rejectedSink = [];
|
|
3081
|
+
const entry = normalizeOne(raw, rejectedSink);
|
|
3082
|
+
if (!entry) {
|
|
3083
|
+
undeclaredTouched.push(raw);
|
|
3084
|
+
continue;
|
|
3085
|
+
}
|
|
3086
|
+
const matches = owned.paths.filter((base) => entryContains(base, entry.path));
|
|
3087
|
+
if (matches.length === 0) {
|
|
3088
|
+
undeclaredTouched.push(entry.path);
|
|
3089
|
+
} else {
|
|
3090
|
+
for (const m of matches) usedDeclarations.add(m.path);
|
|
3091
|
+
}
|
|
3092
|
+
}
|
|
3093
|
+
const unusedDeclarations = owned.paths.map((p) => p.path).filter((p) => !usedDeclarations.has(p));
|
|
3094
|
+
return { undeclaredTouched, unusedDeclarations };
|
|
3095
|
+
}
|
|
995
3096
|
export {
|
|
3097
|
+
CANCEL_REASONS,
|
|
996
3098
|
CANONICAL_MESH_TOOL_COUNT,
|
|
997
3099
|
CANONICAL_MESH_TOOL_NAMES,
|
|
998
3100
|
CLAUDE_TUI_REVIEW_PAGE_NOT_FOCUSED_PREFIX,
|
|
999
3101
|
CLAUDE_TUI_REVIEW_UNCONFIRMED_PREFIX,
|
|
1000
3102
|
CLI_SLOT_RECIPES,
|
|
3103
|
+
COMMIT_STRENGTHS,
|
|
3104
|
+
CONSUME_PROFILES,
|
|
3105
|
+
COORDINATOR_ACK_OUTCOMES,
|
|
3106
|
+
DAEMON_P2P_SIGNAL_TYPES,
|
|
3107
|
+
DAEMON_STATUS_EVENT_NAMES,
|
|
3108
|
+
DAEMON_TO_DASHBOARD_P2P_TYPES,
|
|
3109
|
+
DAEMON_TO_SERVER_TYPES,
|
|
1001
3110
|
DAEMON_TO_SERVER_WS_MSGS,
|
|
3111
|
+
DASHBOARD_P2P_MESSAGE_KINDS,
|
|
3112
|
+
DASHBOARD_P2P_SIGNAL_TYPES,
|
|
3113
|
+
DASHBOARD_STATUS_EVENT_NAMES,
|
|
3114
|
+
DASHBOARD_TO_DAEMON_P2P_TYPES,
|
|
3115
|
+
DASHBOARD_TO_USER_SESSION_TYPES,
|
|
1002
3116
|
DEFAULT_DIFFICULTY_BRAINS,
|
|
3117
|
+
DELIVERY_OUTCOMES,
|
|
3118
|
+
DELIVERY_VIAS,
|
|
3119
|
+
DISPATCH_FAILURE_REASONS,
|
|
3120
|
+
EVIDENCE_ENVELOPE_FIELD_SPECS,
|
|
3121
|
+
EVIDENCE_SOURCE_IDS,
|
|
3122
|
+
GRAPH_AUDIT_EVENTS,
|
|
3123
|
+
HOLD_REASONS,
|
|
3124
|
+
LIVENESS_RESULTS,
|
|
1003
3125
|
MAGI_RAW_ANSWER_CAP,
|
|
3126
|
+
MAX_MESH_RECORD_STRING,
|
|
3127
|
+
MAX_OWNED_PATHS,
|
|
1004
3128
|
MESH_CHUNK_KIND,
|
|
1005
3129
|
MESH_CHUNK_PAYLOAD_CHARS,
|
|
1006
3130
|
MESH_CHUNK_TTL_MS,
|
|
3131
|
+
MESH_DELIVERY_MODES,
|
|
3132
|
+
MESH_INDEX_QUERY_WRITER_SCOPES,
|
|
1007
3133
|
MESH_MAX_CHUNKS,
|
|
1008
3134
|
MESH_MAX_INLINE_FRAME_BYTES,
|
|
1009
3135
|
MESH_MAX_REASSEMBLED_BYTES,
|
|
3136
|
+
MESH_MISSION_SOURCES,
|
|
3137
|
+
MESH_MISSION_STATUSES,
|
|
3138
|
+
MESH_P2P_SIGNAL_TYPES,
|
|
3139
|
+
MESH_RECORD_PAYLOAD_KEYS,
|
|
3140
|
+
MESH_SESSION_CLEANUP_MODES,
|
|
1010
3141
|
MESH_TASK_DIFFICULTIES,
|
|
3142
|
+
MESH_TASK_MODES,
|
|
3143
|
+
MESH_TASK_PRIORITIES,
|
|
3144
|
+
MESH_TASK_STATUSES,
|
|
3145
|
+
MESH_TERMINAL_TASK_STATUSES,
|
|
3146
|
+
MESH_THINKING_LEVELS,
|
|
3147
|
+
MESH_TOPIC_ENTRY_KINDS,
|
|
3148
|
+
MESH_TOPIC_PROTOCOL_VERSION,
|
|
3149
|
+
MISSION_BRIEF_RENDER_MAX_CHARS,
|
|
3150
|
+
MODEL_AXIS_SOURCES,
|
|
3151
|
+
MODEL_SELECTION_HISTORY_LIMIT,
|
|
1011
3152
|
MeshChunkAssembler,
|
|
3153
|
+
NATIVE_TURN_OUTCOMES,
|
|
3154
|
+
NOTIFY_KINDS,
|
|
3155
|
+
NO_PROGRESS_OBSERVED_STATUSES,
|
|
3156
|
+
NPM_UPDATE_TAGS,
|
|
3157
|
+
OPERATING_NOTE_CATEGORIES,
|
|
3158
|
+
OPERATOR_STATUSES,
|
|
3159
|
+
OPERATOR_STATUS_REASONS,
|
|
3160
|
+
OPERATOR_STATUS_REASON_VALUES,
|
|
3161
|
+
OPERATOR_STATUS_VALUES,
|
|
3162
|
+
OUTBOUND_MESSAGE_ORIGINS,
|
|
3163
|
+
P2P_SIGNAL_TYPES,
|
|
3164
|
+
PROVIDER_FAILURES,
|
|
1012
3165
|
QUOTA_SUPPORTED_PROVIDERS,
|
|
3166
|
+
RECENT_SESSION_BUCKETS,
|
|
3167
|
+
RECLAIMING_SEND_REFUSALS,
|
|
3168
|
+
RELEASE_CHANNELS,
|
|
3169
|
+
SEND_POLICY_MODES,
|
|
3170
|
+
SEND_REFUSAL_REASONS,
|
|
3171
|
+
SERVER_STATUS_EVENT_NAMES,
|
|
3172
|
+
SERVER_TO_DAEMON_CONTROL_TYPES,
|
|
1013
3173
|
SERVER_TO_DAEMON_WS_MSGS,
|
|
3174
|
+
SESSION_ERROR_REASONS,
|
|
3175
|
+
SESSION_LAUNCHED_BY,
|
|
3176
|
+
SESSION_REBOUND_REASONS,
|
|
3177
|
+
SESSION_STATUSES,
|
|
3178
|
+
SESSION_STATUS_ALIASES,
|
|
3179
|
+
SESSION_STATUS_CLASS,
|
|
3180
|
+
SHARED_SESSION_TO_VIEWER_TYPES,
|
|
1014
3181
|
STATUS_PROBE_ARG_KEY,
|
|
3182
|
+
SUSPENSION_MODALS,
|
|
3183
|
+
SUSPENSION_RESOLUTIONS,
|
|
3184
|
+
SUSPENSION_RESOLUTION_VIAS,
|
|
3185
|
+
SYSTEM_ANNOUNCEMENT_TYPES,
|
|
3186
|
+
TERMINAL_CLASS_EVIDENCE_KINDS,
|
|
3187
|
+
TOOL_CALLER_ROLES,
|
|
3188
|
+
TURN_END_BLOCK_REASONS,
|
|
3189
|
+
TURN_END_STRENGTHS,
|
|
3190
|
+
TURN_EVIDENCE_FIELD_SPECS,
|
|
3191
|
+
TURN_EVIDENCE_FLAGS,
|
|
3192
|
+
TURN_EVIDENCE_KINDS,
|
|
3193
|
+
TURN_IPC_COMMANDS,
|
|
3194
|
+
TURN_IPC_ERROR_CODES,
|
|
3195
|
+
TURN_IPC_PROTOCOL_VERSION,
|
|
3196
|
+
TURN_OBSERVE_VERDICTS,
|
|
3197
|
+
TURN_OUTCOMES,
|
|
3198
|
+
TURN_REASONS,
|
|
3199
|
+
TURN_SCOPES,
|
|
1015
3200
|
UNKNOWN_CLI_SLOT_RECIPE,
|
|
3201
|
+
USER_SESSION_TO_DASHBOARD_TYPES,
|
|
3202
|
+
VERSION_UPDATE_REASONS,
|
|
3203
|
+
VIEWER_TO_SHARED_SESSION_TYPES,
|
|
3204
|
+
WORKER_BRANCH_STATES,
|
|
3205
|
+
WORKER_PROTOCOL_FOOTER_MARKER,
|
|
3206
|
+
WORKER_REPORT_OUTCOMES,
|
|
3207
|
+
WORKER_TOOLS,
|
|
3208
|
+
appendWorkerProtocolFooter,
|
|
1016
3209
|
argsCarryStatusProbeMarker,
|
|
1017
3210
|
buildMagiPanelProposal,
|
|
1018
3211
|
buildSlotProposal,
|
|
1019
3212
|
canonicalDaemonId,
|
|
3213
|
+
classifySessionStatus,
|
|
1020
3214
|
compareSemver,
|
|
1021
3215
|
daemonIdsEquivalent,
|
|
3216
|
+
decodeActiveWorkQueryRequest,
|
|
3217
|
+
decodeActiveWorkQueryResponse,
|
|
3218
|
+
decodeDaemonToDashboardP2P,
|
|
3219
|
+
decodeDaemonToServer,
|
|
3220
|
+
decodeDashboardToDaemonP2P,
|
|
3221
|
+
decodeDashboardToDaemonP2PChunk,
|
|
3222
|
+
decodeDashboardToUserSession,
|
|
3223
|
+
decodeDirectDispatchRecordRequest,
|
|
3224
|
+
decodeDirectDispatchRecordResponse,
|
|
3225
|
+
decodeGraphAuditRecordRequest,
|
|
3226
|
+
decodeGraphAuditRecordResponse,
|
|
3227
|
+
decodeGraphGateAbandonRequest,
|
|
3228
|
+
decodeGraphGateAbandonResponse,
|
|
3229
|
+
decodeGraphGateClaimRequest,
|
|
3230
|
+
decodeGraphGateClaimResponse,
|
|
3231
|
+
decodeGraphGateReleaseRequest,
|
|
3232
|
+
decodeGraphGateReleaseResponse,
|
|
3233
|
+
decodeGraphNodePatchRequest,
|
|
3234
|
+
decodeGraphNodePatchResponse,
|
|
3235
|
+
decodeGraphViewQueryRequest,
|
|
3236
|
+
decodeGraphViewQueryResponse,
|
|
3237
|
+
decodeLedgerQueryRequest,
|
|
3238
|
+
decodeLedgerQueryResponse,
|
|
3239
|
+
decodeMeshIndexQueryRequest,
|
|
3240
|
+
decodeMeshIndexQueryResponse,
|
|
3241
|
+
decodeMeshRecordRequest,
|
|
3242
|
+
decodeMeshRecordResponse,
|
|
3243
|
+
decodeMissionListQueryRequest,
|
|
3244
|
+
decodeMissionListQueryResponse,
|
|
3245
|
+
decodeMissionQueryRequest,
|
|
3246
|
+
decodeMissionQueryResponse,
|
|
3247
|
+
decodeMissionUpsertRequest,
|
|
3248
|
+
decodeMissionUpsertResponse,
|
|
3249
|
+
decodeNoteForgetRequest,
|
|
3250
|
+
decodeNoteForgetResponse,
|
|
3251
|
+
decodeNoteUpsertRequest,
|
|
3252
|
+
decodeNoteUpsertResponse,
|
|
3253
|
+
decodeOperatorStatusRequest,
|
|
3254
|
+
decodeOperatorStatusResponse,
|
|
3255
|
+
decodeOrphanedPinNotifyRequest,
|
|
3256
|
+
decodeOrphanedPinNotifyResponse,
|
|
3257
|
+
decodePruneStaleDirectRequest,
|
|
3258
|
+
decodePruneStaleDirectResponse,
|
|
3259
|
+
decodeQueueCancelRequest,
|
|
3260
|
+
decodeQueueCancelResponse,
|
|
3261
|
+
decodeQueueEnqueueGraphRequest,
|
|
3262
|
+
decodeQueueEnqueueGraphResponse,
|
|
3263
|
+
decodeQueueEnqueueRequest,
|
|
3264
|
+
decodeQueueEnqueueResponse,
|
|
3265
|
+
decodeQueueQueryRequest,
|
|
3266
|
+
decodeQueueQueryResponse,
|
|
3267
|
+
decodeQueueRequeueRequest,
|
|
3268
|
+
decodeQueueRequeueResponse,
|
|
3269
|
+
decodeRecordLocalRequest,
|
|
3270
|
+
decodeRecordLocalResponse,
|
|
3271
|
+
decodeRecoveryContextQueryRequest,
|
|
3272
|
+
decodeRecoveryContextQueryResponse,
|
|
3273
|
+
decodeServerToDaemon,
|
|
3274
|
+
decodeTaskStatsQueryRequest,
|
|
3275
|
+
decodeTaskStatsQueryResponse,
|
|
3276
|
+
decodeToolCallRecordRequest,
|
|
3277
|
+
decodeToolCallRecordResponse,
|
|
3278
|
+
decodeTurnCancelRequest,
|
|
3279
|
+
decodeTurnCancelResponse,
|
|
3280
|
+
decodeTurnObserveRequest,
|
|
3281
|
+
decodeTurnObserveResponse,
|
|
3282
|
+
decodeTurnQueryRequest,
|
|
3283
|
+
decodeTurnQueryResponse,
|
|
3284
|
+
decodeTypeField,
|
|
3285
|
+
decodeUserSessionToDashboard,
|
|
3286
|
+
decodeViewerToSharedSession,
|
|
1022
3287
|
deriveProviderPriorityFromSlots,
|
|
1023
3288
|
deriveSlotsFromLegacy,
|
|
3289
|
+
describeModelSelection,
|
|
3290
|
+
effectiveModelSelectionValue,
|
|
3291
|
+
enumOf,
|
|
1024
3292
|
expandDaemonIdForms,
|
|
3293
|
+
findOwnershipConflicts,
|
|
1025
3294
|
formatQuotaAccount,
|
|
1026
3295
|
hasGitStatusEvidence,
|
|
3296
|
+
hasWorkerProtocolFooter,
|
|
1027
3297
|
interpolateArgs,
|
|
1028
3298
|
interpolateString,
|
|
3299
|
+
isActiveWorkQueryRequest,
|
|
3300
|
+
isActiveWorkQueryResponse,
|
|
3301
|
+
isBlockedStatus,
|
|
3302
|
+
isBusyStatus,
|
|
3303
|
+
isChunkType,
|
|
3304
|
+
isCommitStrength,
|
|
3305
|
+
isDaemonDirectCommandType,
|
|
3306
|
+
isDaemonP2PSignalType,
|
|
3307
|
+
isDaemonStatusEventName,
|
|
3308
|
+
isDaemonToDashboardP2PType,
|
|
3309
|
+
isDaemonToServerType,
|
|
1029
3310
|
isDaemonToServerWsMsg,
|
|
3311
|
+
isDashboardP2PSignalType,
|
|
3312
|
+
isDashboardStatusEventName,
|
|
3313
|
+
isDashboardToDaemonChunkType,
|
|
3314
|
+
isDashboardToDaemonP2PType,
|
|
3315
|
+
isDashboardToUserSessionType,
|
|
3316
|
+
isDeadStatus,
|
|
3317
|
+
isDirectDispatchRecordRequest,
|
|
3318
|
+
isDirectDispatchRecordResponse,
|
|
1030
3319
|
isDowngrade,
|
|
3320
|
+
isEvidenceIdentifier,
|
|
3321
|
+
isEvidenceSourceId,
|
|
3322
|
+
isFiniteNumber,
|
|
3323
|
+
isGraphAuditEvent,
|
|
3324
|
+
isGraphAuditRecordRequest,
|
|
3325
|
+
isGraphAuditRecordResponse,
|
|
3326
|
+
isGraphGateAbandonRequest,
|
|
3327
|
+
isGraphGateAbandonResponse,
|
|
3328
|
+
isGraphGateClaimRequest,
|
|
3329
|
+
isGraphGateClaimResponse,
|
|
3330
|
+
isGraphGateReleaseRequest,
|
|
3331
|
+
isGraphGateReleaseResponse,
|
|
3332
|
+
isGraphNodePatchRequest,
|
|
3333
|
+
isGraphNodePatchResponse,
|
|
3334
|
+
isGraphViewQueryRequest,
|
|
3335
|
+
isGraphViewQueryResponse,
|
|
3336
|
+
isHoldReason,
|
|
3337
|
+
isInputEnvelopeWire,
|
|
3338
|
+
isLedgerQueryRequest,
|
|
3339
|
+
isLedgerQueryResponse,
|
|
3340
|
+
isMeshDeliveryMode,
|
|
3341
|
+
isMeshIndexQueryRequest,
|
|
3342
|
+
isMeshIndexQueryResponse,
|
|
3343
|
+
isMeshIndexQueryWriterScope,
|
|
3344
|
+
isMeshMissionSourceValue,
|
|
3345
|
+
isMeshMissionStatusValue,
|
|
3346
|
+
isMeshP2PSignalType,
|
|
3347
|
+
isMeshRecordPayload,
|
|
3348
|
+
isMeshRecordRequest,
|
|
3349
|
+
isMeshRecordResponse,
|
|
3350
|
+
isMeshSessionCleanupMode,
|
|
1031
3351
|
isMeshTaskDifficulty,
|
|
3352
|
+
isMeshTaskMode,
|
|
3353
|
+
isMeshTaskPriority,
|
|
3354
|
+
isMeshTaskStatus,
|
|
3355
|
+
isMeshTerminalTaskStatus,
|
|
3356
|
+
isMeshThinkingLevel,
|
|
3357
|
+
isMeshTopicEntry,
|
|
3358
|
+
isMeshTopicEntryKind,
|
|
3359
|
+
isMessageId,
|
|
3360
|
+
isMissionListQueryRequest,
|
|
3361
|
+
isMissionListQueryResponse,
|
|
3362
|
+
isMissionQueryRequest,
|
|
3363
|
+
isMissionQueryResponse,
|
|
3364
|
+
isMissionUpsertRequest,
|
|
3365
|
+
isMissionUpsertResponse,
|
|
3366
|
+
isModelAxisSource,
|
|
3367
|
+
isNonEmptyString,
|
|
3368
|
+
isNoteForgetRequest,
|
|
3369
|
+
isNoteForgetResponse,
|
|
3370
|
+
isNoteUpsertRequest,
|
|
3371
|
+
isNoteUpsertResponse,
|
|
3372
|
+
isNotifyKind,
|
|
3373
|
+
isOperatingNoteCategory,
|
|
3374
|
+
isOperatorStatusReasonValue,
|
|
3375
|
+
isOperatorStatusRequest,
|
|
3376
|
+
isOperatorStatusResponse,
|
|
3377
|
+
isOperatorStatusValue,
|
|
3378
|
+
isOrphanedPinNotifyRequest,
|
|
3379
|
+
isOrphanedPinNotifyResponse,
|
|
3380
|
+
isOutboundMessage,
|
|
3381
|
+
isOutboundMessageOrigin,
|
|
3382
|
+
isP2PSignalType,
|
|
1032
3383
|
isPhantomDaemonEntry,
|
|
3384
|
+
isPruneStaleDirectRequest,
|
|
3385
|
+
isPruneStaleDirectResponse,
|
|
3386
|
+
isQueueCancelRequest,
|
|
3387
|
+
isQueueCancelResponse,
|
|
3388
|
+
isQueueEnqueueGraphRequest,
|
|
3389
|
+
isQueueEnqueueGraphResponse,
|
|
3390
|
+
isQueueEnqueueRequest,
|
|
3391
|
+
isQueueEnqueueResponse,
|
|
3392
|
+
isQueueQueryRequest,
|
|
3393
|
+
isQueueQueryResponse,
|
|
3394
|
+
isQueueRequeueRequest,
|
|
3395
|
+
isQueueRequeueResponse,
|
|
1033
3396
|
isRawDaemonDoId,
|
|
3397
|
+
isReadyStatus,
|
|
3398
|
+
isRecord,
|
|
3399
|
+
isRecordLocalRequest,
|
|
3400
|
+
isRecordLocalResponse,
|
|
3401
|
+
isRecoveryContextQueryRequest,
|
|
3402
|
+
isRecoveryContextQueryResponse,
|
|
3403
|
+
isSendPolicy,
|
|
3404
|
+
isSendPolicyMode,
|
|
3405
|
+
isSendRefusal,
|
|
3406
|
+
isServerDirectCommandMsg,
|
|
3407
|
+
isServerToDaemonControlType,
|
|
1034
3408
|
isServerToDaemonWsMsg,
|
|
3409
|
+
isSessionLaunchedBy,
|
|
3410
|
+
isSessionStatus,
|
|
3411
|
+
isSharedSessionToViewerType,
|
|
3412
|
+
isSubmitOutcome,
|
|
3413
|
+
isSummaryRef,
|
|
3414
|
+
isTaskStatsQueryRequest,
|
|
3415
|
+
isTaskStatsQueryResponse,
|
|
3416
|
+
isTerminalClassEvidenceKind,
|
|
3417
|
+
isToolCallRecordRequest,
|
|
3418
|
+
isToolCallRecordResponse,
|
|
3419
|
+
isToolCallerRole,
|
|
3420
|
+
isTurnAttemptRef,
|
|
3421
|
+
isTurnCancelRequest,
|
|
3422
|
+
isTurnCancelResponse,
|
|
3423
|
+
isTurnEvidence,
|
|
3424
|
+
isTurnEvidenceKind,
|
|
3425
|
+
isTurnIpcCommand,
|
|
3426
|
+
isTurnIpcError,
|
|
3427
|
+
isTurnIpcErrorCode,
|
|
3428
|
+
isTurnObserveRequest,
|
|
3429
|
+
isTurnObserveResponse,
|
|
3430
|
+
isTurnObserveVerdict,
|
|
3431
|
+
isTurnOutcome,
|
|
3432
|
+
isTurnQueryRequest,
|
|
3433
|
+
isTurnQueryResponse,
|
|
3434
|
+
isTurnReason,
|
|
3435
|
+
isUserSessionToDashboardType,
|
|
3436
|
+
isViewerToSharedSessionType,
|
|
3437
|
+
isWorkerBranchState,
|
|
3438
|
+
isWorkerReportOutcome,
|
|
3439
|
+
isWorkerTool,
|
|
3440
|
+
isWorkingStatus,
|
|
1035
3441
|
joinRepoPath,
|
|
3442
|
+
launchModelSelectionValue,
|
|
1036
3443
|
machineCoreFromDaemonId,
|
|
3444
|
+
makeTypeGuard,
|
|
1037
3445
|
measureWorstCaseChunkEnvelopeBytes,
|
|
1038
3446
|
meshFrameNeedsChunking,
|
|
1039
3447
|
meshNodeIdMatches,
|
|
1040
3448
|
meshUtf8ByteLength,
|
|
1041
3449
|
meshWorkspacesEquivalent,
|
|
3450
|
+
mintMessageId,
|
|
3451
|
+
normalizeAuthOkLimits,
|
|
1042
3452
|
normalizeBrainSlot,
|
|
1043
3453
|
normalizeDifficultyBrainMap,
|
|
1044
3454
|
normalizeGitStatus,
|
|
@@ -1046,25 +3456,39 @@ export {
|
|
|
1046
3456
|
normalizeMeshNodeId,
|
|
1047
3457
|
normalizeMeshSessionRecord,
|
|
1048
3458
|
normalizeMeshWorkspaceForCompare,
|
|
3459
|
+
normalizeMissionBrief,
|
|
1049
3460
|
normalizeNodeCapabilitySlot,
|
|
1050
3461
|
normalizeNodeCapabilitySlots,
|
|
3462
|
+
normalizeOwnedPaths,
|
|
3463
|
+
normalizeSessionStatus,
|
|
1051
3464
|
normalizeThinkingLevel,
|
|
1052
3465
|
parseJsonRecord,
|
|
1053
3466
|
parseSemver,
|
|
3467
|
+
parseSessionLaunchRecord,
|
|
3468
|
+
pathsOverlap,
|
|
1054
3469
|
pickBestTransitGitStatus,
|
|
3470
|
+
projectTurnEvidenceEntry,
|
|
1055
3471
|
readBoolean,
|
|
3472
|
+
readEnvelopeFields,
|
|
1056
3473
|
readGitSubmodules,
|
|
1057
3474
|
readNumber,
|
|
1058
3475
|
readRecord,
|
|
1059
3476
|
readString,
|
|
1060
3477
|
readStringArray,
|
|
3478
|
+
renderCoordinatorWorkerSection,
|
|
3479
|
+
renderMissionBriefBlock,
|
|
3480
|
+
renderWorkerProtocolFooter,
|
|
3481
|
+
sanitizeModelIdentifier,
|
|
1061
3482
|
scoreGitStatusCandidate,
|
|
1062
3483
|
scoreGitUpstreamFreshness,
|
|
1063
3484
|
sessionIdsEquivalent,
|
|
1064
3485
|
splitMeshFrame,
|
|
3486
|
+
statusesOfClass,
|
|
1065
3487
|
stripStatusProbeMarker,
|
|
3488
|
+
stripWorkerProtocolFooter,
|
|
1066
3489
|
summarizeGitShape,
|
|
1067
3490
|
supportsQuota,
|
|
3491
|
+
touchedFilesOutsideOwnership,
|
|
1068
3492
|
withStatusProbeMarker
|
|
1069
3493
|
};
|
|
1070
3494
|
//# sourceMappingURL=index.mjs.map
|