@adhdev/mesh-shared 1.0.60-rc.70 → 1.0.60-rc.71
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 +0 -1
- package/dist/index.js +96 -217
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +91 -205
- package/dist/index.mjs.map +1 -1
- package/dist/interpolation.d.ts +0 -9
- package/dist/keyed-doc-delta.d.ts +39 -17
- package/dist/mesh-vocabulary.d.ts +0 -3
- package/dist/protocol/daemon-server.d.ts +2 -4
- package/dist/protocol/dashboard-daemon-p2p.d.ts +7 -10
- package/dist/protocol/dashboard-server.d.ts +2 -2
- package/dist/protocol/dashboard-wire-version.d.ts +21 -0
- package/dist/protocol/index.d.ts +1 -0
- package/dist/session-status.d.ts +14 -0
- package/dist/turn-evidence.d.ts +0 -4
- package/dist/ws-protocol.d.ts +0 -2
- package/package.json +1 -1
- package/src/index.ts +0 -1
- package/src/interpolation.ts +0 -18
- package/src/keyed-doc-delta.ts +94 -29
- package/src/mesh-vocabulary.ts +0 -3
- package/src/protocol/daemon-server.ts +0 -4
- package/src/protocol/dashboard-daemon-p2p.ts +7 -14
- package/src/protocol/dashboard-wire-version.ts +27 -0
- package/src/protocol/index.ts +1 -0
- package/src/session-status.ts +24 -0
- package/src/turn-evidence.ts +0 -6
- package/src/turn-ipc.ts +1 -2
- package/src/ws-protocol.ts +0 -4
- package/dist/keyed-status-delta.d.ts +0 -76
- package/src/keyed-status-delta.ts +0 -239
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -29,6 +29,7 @@ __export(index_exports, {
|
|
|
29
29
|
COMMIT_STRENGTHS: () => COMMIT_STRENGTHS,
|
|
30
30
|
CONSUME_PROFILES: () => CONSUME_PROFILES,
|
|
31
31
|
COORDINATOR_ACK_OUTCOMES: () => COORDINATOR_ACK_OUTCOMES,
|
|
32
|
+
DAEMON_METADATA_DOC_SPEC: () => DAEMON_METADATA_DOC_SPEC,
|
|
32
33
|
DAEMON_P2P_SIGNAL_TYPES: () => DAEMON_P2P_SIGNAL_TYPES,
|
|
33
34
|
DAEMON_STATUS_EVENT_NAMES: () => DAEMON_STATUS_EVENT_NAMES,
|
|
34
35
|
DAEMON_TO_DASHBOARD_P2P_TYPES: () => DAEMON_TO_DASHBOARD_P2P_TYPES,
|
|
@@ -39,6 +40,7 @@ __export(index_exports, {
|
|
|
39
40
|
DASHBOARD_STATUS_EVENT_NAMES: () => DASHBOARD_STATUS_EVENT_NAMES,
|
|
40
41
|
DASHBOARD_TO_DAEMON_P2P_TYPES: () => DASHBOARD_TO_DAEMON_P2P_TYPES,
|
|
41
42
|
DASHBOARD_TO_USER_SESSION_TYPES: () => DASHBOARD_TO_USER_SESSION_TYPES,
|
|
43
|
+
DASHBOARD_WIRE_VERSION: () => DASHBOARD_WIRE_VERSION,
|
|
42
44
|
DEFAULT_DIFFICULTY_BRAINS: () => DEFAULT_DIFFICULTY_BRAINS,
|
|
43
45
|
DELIVERY_OUTCOMES: () => DELIVERY_OUTCOMES,
|
|
44
46
|
DELIVERY_VIAS: () => DELIVERY_VIAS,
|
|
@@ -112,6 +114,7 @@ __export(index_exports, {
|
|
|
112
114
|
SUSPENSION_RESOLUTION_VIAS: () => SUSPENSION_RESOLUTION_VIAS,
|
|
113
115
|
SYSTEM_ANNOUNCEMENT_TYPES: () => SYSTEM_ANNOUNCEMENT_TYPES,
|
|
114
116
|
TERMINAL_CLASS_EVIDENCE_KINDS: () => TERMINAL_CLASS_EVIDENCE_KINDS,
|
|
117
|
+
TERMINAL_SESSION_RECORD_STATUSES: () => TERMINAL_SESSION_RECORD_STATUSES,
|
|
115
118
|
TOOL_CALLER_ROLES: () => TOOL_CALLER_ROLES,
|
|
116
119
|
TURN_END_BLOCK_REASONS: () => TURN_END_BLOCK_REASONS,
|
|
117
120
|
TURN_END_STRENGTHS: () => TURN_END_STRENGTHS,
|
|
@@ -139,6 +142,7 @@ __export(index_exports, {
|
|
|
139
142
|
buildSlotProposal: () => buildSlotProposal,
|
|
140
143
|
canonicalDaemonId: () => canonicalDaemonId,
|
|
141
144
|
classifySessionStatus: () => classifySessionStatus,
|
|
145
|
+
compareDashboardWireVersion: () => compareDashboardWireVersion,
|
|
142
146
|
compareSemver: () => compareSemver,
|
|
143
147
|
daemonIdsEquivalent: () => daemonIdsEquivalent,
|
|
144
148
|
decodeActiveWorkQueryRequest: () => decodeActiveWorkQueryRequest,
|
|
@@ -216,19 +220,15 @@ __export(index_exports, {
|
|
|
216
220
|
deriveSlotsFromLegacy: () => deriveSlotsFromLegacy,
|
|
217
221
|
describeModelSelection: () => describeModelSelection,
|
|
218
222
|
diffKeyedDoc: () => diffKeyedDoc,
|
|
219
|
-
diffKeyedStatus: () => diffKeyedStatus,
|
|
220
223
|
digestKeyedDoc: () => digestKeyedDoc,
|
|
221
|
-
digestKeyedStatus: () => digestKeyedStatus,
|
|
222
224
|
effectiveModelSelectionValue: () => effectiveModelSelectionValue,
|
|
223
225
|
enumOf: () => enumOf,
|
|
224
226
|
expandDaemonIdForms: () => expandDaemonIdForms,
|
|
225
227
|
findOwnershipConflicts: () => findOwnershipConflicts,
|
|
226
228
|
foldKeyedDoc: () => foldKeyedDoc,
|
|
227
|
-
foldKeyedStatus: () => foldKeyedStatus,
|
|
228
229
|
formatQuotaAccount: () => formatQuotaAccount,
|
|
229
230
|
hasGitStatusEvidence: () => hasGitStatusEvidence,
|
|
230
231
|
hasWorkerProtocolFooter: () => hasWorkerProtocolFooter,
|
|
231
|
-
interpolateArgs: () => interpolateArgs,
|
|
232
232
|
interpolateString: () => interpolateString,
|
|
233
233
|
isActiveWorkQueryRequest: () => isActiveWorkQueryRequest,
|
|
234
234
|
isActiveWorkQueryResponse: () => isActiveWorkQueryResponse,
|
|
@@ -241,7 +241,6 @@ __export(index_exports, {
|
|
|
241
241
|
isDaemonStatusEventName: () => isDaemonStatusEventName,
|
|
242
242
|
isDaemonToDashboardP2PType: () => isDaemonToDashboardP2PType,
|
|
243
243
|
isDaemonToServerType: () => isDaemonToServerType,
|
|
244
|
-
isDaemonToServerWsMsg: () => isDaemonToServerWsMsg,
|
|
245
244
|
isDashboardP2PSignalType: () => isDashboardP2PSignalType,
|
|
246
245
|
isDashboardStatusEventName: () => isDashboardStatusEventName,
|
|
247
246
|
isDashboardToDaemonChunkType: () => isDashboardToDaemonChunkType,
|
|
@@ -252,7 +251,6 @@ __export(index_exports, {
|
|
|
252
251
|
isDirectDispatchRecordResponse: () => isDirectDispatchRecordResponse,
|
|
253
252
|
isDowngrade: () => isDowngrade,
|
|
254
253
|
isEvidenceIdentifier: () => isEvidenceIdentifier,
|
|
255
|
-
isEvidenceSourceId: () => isEvidenceSourceId,
|
|
256
254
|
isFiniteNumber: () => isFiniteNumber,
|
|
257
255
|
isGraphAuditEvent: () => isGraphAuditEvent,
|
|
258
256
|
isGraphAuditRecordRequest: () => isGraphAuditRecordRequest,
|
|
@@ -267,7 +265,7 @@ __export(index_exports, {
|
|
|
267
265
|
isGraphNodePatchResponse: () => isGraphNodePatchResponse,
|
|
268
266
|
isGraphViewQueryRequest: () => isGraphViewQueryRequest,
|
|
269
267
|
isGraphViewQueryResponse: () => isGraphViewQueryResponse,
|
|
270
|
-
|
|
268
|
+
isIdleSessionState: () => isIdleSessionState,
|
|
271
269
|
isInputEnvelopeWire: () => isInputEnvelopeWire,
|
|
272
270
|
isLedgerQueryRequest: () => isLedgerQueryRequest,
|
|
273
271
|
isLedgerQueryResponse: () => isLedgerQueryResponse,
|
|
@@ -281,15 +279,12 @@ __export(index_exports, {
|
|
|
281
279
|
isMeshRecordPayload: () => isMeshRecordPayload,
|
|
282
280
|
isMeshRecordRequest: () => isMeshRecordRequest,
|
|
283
281
|
isMeshRecordResponse: () => isMeshRecordResponse,
|
|
284
|
-
isMeshSessionCleanupMode: () => isMeshSessionCleanupMode,
|
|
285
282
|
isMeshTaskDifficulty: () => isMeshTaskDifficulty,
|
|
286
283
|
isMeshTaskMode: () => isMeshTaskMode,
|
|
287
284
|
isMeshTaskPriority: () => isMeshTaskPriority,
|
|
288
285
|
isMeshTaskStatus: () => isMeshTaskStatus,
|
|
289
286
|
isMeshTerminalTaskStatus: () => isMeshTerminalTaskStatus,
|
|
290
|
-
isMeshThinkingLevel: () => isMeshThinkingLevel,
|
|
291
287
|
isMeshTopicEntry: () => isMeshTopicEntry,
|
|
292
|
-
isMeshTopicEntryKind: () => isMeshTopicEntryKind,
|
|
293
288
|
isMessageId: () => isMessageId,
|
|
294
289
|
isMissionListQueryRequest: () => isMissionListQueryRequest,
|
|
295
290
|
isMissionListQueryResponse: () => isMissionListQueryResponse,
|
|
@@ -339,7 +334,6 @@ __export(index_exports, {
|
|
|
339
334
|
isSendRefusal: () => isSendRefusal,
|
|
340
335
|
isServerDirectCommandMsg: () => isServerDirectCommandMsg,
|
|
341
336
|
isServerToDaemonControlType: () => isServerToDaemonControlType,
|
|
342
|
-
isServerToDaemonWsMsg: () => isServerToDaemonWsMsg,
|
|
343
337
|
isSessionLaunchedBy: () => isSessionLaunchedBy,
|
|
344
338
|
isSessionStatus: () => isSessionStatus,
|
|
345
339
|
isSharedSessionToViewerType: () => isSharedSessionToViewerType,
|
|
@@ -347,7 +341,7 @@ __export(index_exports, {
|
|
|
347
341
|
isSummaryRef: () => isSummaryRef,
|
|
348
342
|
isTaskStatsQueryRequest: () => isTaskStatsQueryRequest,
|
|
349
343
|
isTaskStatsQueryResponse: () => isTaskStatsQueryResponse,
|
|
350
|
-
|
|
344
|
+
isTerminalSessionRecordStatus: () => isTerminalSessionRecordStatus,
|
|
351
345
|
isToolCallRecordRequest: () => isToolCallRecordRequest,
|
|
352
346
|
isToolCallRecordResponse: () => isToolCallRecordResponse,
|
|
353
347
|
isToolCallerRole: () => isToolCallerRole,
|
|
@@ -368,7 +362,6 @@ __export(index_exports, {
|
|
|
368
362
|
isTurnReason: () => isTurnReason,
|
|
369
363
|
isUserSessionToDashboardType: () => isUserSessionToDashboardType,
|
|
370
364
|
isViewerToSharedSessionType: () => isViewerToSharedSessionType,
|
|
371
|
-
isWorkerBranchState: () => isWorkerBranchState,
|
|
372
365
|
isWorkerReportOutcome: () => isWorkerReportOutcome,
|
|
373
366
|
isWorkerTool: () => isWorkerTool,
|
|
374
367
|
isWorkingStatus: () => isWorkingStatus,
|
|
@@ -1069,13 +1062,6 @@ function buildMagiPanelProposal(detected, opts = {}) {
|
|
|
1069
1062
|
}
|
|
1070
1063
|
|
|
1071
1064
|
// src/interpolation.ts
|
|
1072
|
-
function interpolateArgs(args, context) {
|
|
1073
|
-
const result = {};
|
|
1074
|
-
for (const [k, v] of Object.entries(args)) {
|
|
1075
|
-
result[k] = typeof v === "string" ? interpolateString(v, context) : v;
|
|
1076
|
-
}
|
|
1077
|
-
return result;
|
|
1078
|
-
}
|
|
1079
1065
|
function interpolateString(template, ctx) {
|
|
1080
1066
|
return template.replace(/\{\{(\w+)\}\}/g, (_, key) => {
|
|
1081
1067
|
const val = ctx[key];
|
|
@@ -1441,9 +1427,7 @@ var DAEMON_STATUS_EVENT_NAMES = [
|
|
|
1441
1427
|
"agent:waiting_choice",
|
|
1442
1428
|
"agent:generating_completed",
|
|
1443
1429
|
"agent:stopped",
|
|
1444
|
-
"monitor:no_progress"
|
|
1445
|
-
/** Legacy alias for `monitor:no_progress`, still emitted by older daemons. */
|
|
1446
|
-
"monitor:long_generating"
|
|
1430
|
+
"monitor:no_progress"
|
|
1447
1431
|
];
|
|
1448
1432
|
var isDaemonStatusEventName = makeTypeGuard(DAEMON_STATUS_EVENT_NAMES);
|
|
1449
1433
|
var RELEASE_CHANNELS = ["stable", "preview"];
|
|
@@ -1673,9 +1657,6 @@ var DAEMON_TO_DASHBOARD_P2P_TYPES = [
|
|
|
1673
1657
|
var isDaemonToDashboardP2PType = makeTypeGuard(DAEMON_TO_DASHBOARD_P2P_TYPES);
|
|
1674
1658
|
function decodeDaemonToDashboardP2P(raw) {
|
|
1675
1659
|
if (!isRecord(raw)) return null;
|
|
1676
|
-
if (raw.type === void 0 && isNonEmptyString(raw.id) && typeof raw.success === "boolean") {
|
|
1677
|
-
return { ...raw, type: "response" };
|
|
1678
|
-
}
|
|
1679
1660
|
if (!isDaemonToDashboardP2PType(raw.type)) return null;
|
|
1680
1661
|
switch (raw.type) {
|
|
1681
1662
|
case "ping":
|
|
@@ -1711,11 +1692,17 @@ var DASHBOARD_P2P_MESSAGE_KINDS = [
|
|
|
1711
1692
|
.../* @__PURE__ */ new Set([...DASHBOARD_TO_DAEMON_P2P_TYPES, ...DAEMON_TO_DASHBOARD_P2P_TYPES])
|
|
1712
1693
|
];
|
|
1713
1694
|
|
|
1695
|
+
// src/protocol/dashboard-wire-version.ts
|
|
1696
|
+
var DASHBOARD_WIRE_VERSION = 2;
|
|
1697
|
+
function compareDashboardWireVersion(pageVersion, daemonVersion) {
|
|
1698
|
+
const daemon = typeof daemonVersion === "number" && Number.isFinite(daemonVersion) ? daemonVersion : 1;
|
|
1699
|
+
if (daemon === pageVersion) return "ok";
|
|
1700
|
+
return daemon > pageVersion ? "reload_required" : "daemon_update_required";
|
|
1701
|
+
}
|
|
1702
|
+
|
|
1714
1703
|
// src/ws-protocol.ts
|
|
1715
1704
|
var DAEMON_TO_SERVER_WS_MSGS = DAEMON_TO_SERVER_TYPES;
|
|
1716
1705
|
var SERVER_TO_DAEMON_WS_MSGS = SERVER_TO_DAEMON_CONTROL_TYPES;
|
|
1717
|
-
var isDaemonToServerWsMsg = isDaemonToServerType;
|
|
1718
|
-
var isServerToDaemonWsMsg = isServerToDaemonControlType;
|
|
1719
1706
|
function normalizeAuthOkLimits(raw) {
|
|
1720
1707
|
if (!raw || typeof raw !== "object") return null;
|
|
1721
1708
|
const src = raw;
|
|
@@ -1811,6 +1798,16 @@ function isBusyStatus(raw) {
|
|
|
1811
1798
|
function statusesOfClass(cls) {
|
|
1812
1799
|
return SESSION_STATUSES.filter((status) => SESSION_STATUS_CLASS[status] === cls);
|
|
1813
1800
|
}
|
|
1801
|
+
var TERMINAL_SESSION_RECORD_STATUSES = ["stopped", "failed", "terminated", "exited", "closed"];
|
|
1802
|
+
function isTerminalSessionRecordStatus(raw) {
|
|
1803
|
+
return typeof raw === "string" && TERMINAL_SESSION_RECORD_STATUSES.includes(raw.trim().toLowerCase());
|
|
1804
|
+
}
|
|
1805
|
+
function isIdleSessionState(state) {
|
|
1806
|
+
const record = state && typeof state === "object" ? state : {};
|
|
1807
|
+
const status = typeof record.status === "string" ? record.status.trim().toLowerCase() : "";
|
|
1808
|
+
if (isTerminalSessionRecordStatus(status) || isDeadStatus(status)) return false;
|
|
1809
|
+
return isReadyStatus(status) || record.activeChat?.status === "waiting_input";
|
|
1810
|
+
}
|
|
1814
1811
|
|
|
1815
1812
|
// src/mesh-vocabulary.ts
|
|
1816
1813
|
var MESH_TASK_STATUSES = ["pending", "assigned", "completed", "failed", "cancelled"];
|
|
@@ -1836,11 +1833,8 @@ var isMeshTaskStatus = makeGuard(MESH_TASK_STATUSES);
|
|
|
1836
1833
|
var isMeshTerminalTaskStatus = makeGuard(MESH_TERMINAL_TASK_STATUSES);
|
|
1837
1834
|
var isMeshTaskMode = makeGuard(MESH_TASK_MODES);
|
|
1838
1835
|
var isMeshTaskPriority = makeGuard(MESH_TASK_PRIORITIES);
|
|
1839
|
-
var isMeshThinkingLevel = makeGuard(MESH_THINKING_LEVELS);
|
|
1840
1836
|
var isMeshDeliveryMode = makeGuard(MESH_DELIVERY_MODES);
|
|
1841
|
-
var isMeshSessionCleanupMode = makeGuard(MESH_SESSION_CLEANUP_MODES);
|
|
1842
1837
|
var isWorkerReportOutcome = makeGuard(WORKER_REPORT_OUTCOMES);
|
|
1843
|
-
var isWorkerBranchState = makeGuard(WORKER_BRANCH_STATES);
|
|
1844
1838
|
function enumOf(values, description) {
|
|
1845
1839
|
return {
|
|
1846
1840
|
type: "string",
|
|
@@ -2303,11 +2297,9 @@ function makeGuard2(values) {
|
|
|
2303
2297
|
const set = new Set(values);
|
|
2304
2298
|
return (value) => typeof value === "string" && set.has(value);
|
|
2305
2299
|
}
|
|
2306
|
-
var isEvidenceSourceId = makeGuard2(EVIDENCE_SOURCE_IDS);
|
|
2307
2300
|
var isTurnEvidenceKind = makeGuard2(TURN_EVIDENCE_KINDS);
|
|
2308
2301
|
var isTurnReason = makeGuard2(TURN_REASONS);
|
|
2309
2302
|
var isNotifyKind = makeGuard2(NOTIFY_KINDS);
|
|
2310
|
-
var isHoldReason = makeGuard2(HOLD_REASONS);
|
|
2311
2303
|
var isTurnOutcome = makeGuard2(TURN_OUTCOMES);
|
|
2312
2304
|
var isCommitStrength = makeGuard2(COMMIT_STRENGTHS);
|
|
2313
2305
|
function isRecord2(value) {
|
|
@@ -2381,12 +2373,8 @@ function isTurnEvidence(value) {
|
|
|
2381
2373
|
}
|
|
2382
2374
|
return true;
|
|
2383
2375
|
}
|
|
2384
|
-
function isTerminalClassEvidenceKind(kind) {
|
|
2385
|
-
return TERMINAL_CLASS_EVIDENCE_KINDS.includes(kind);
|
|
2386
|
-
}
|
|
2387
2376
|
var TURN_EVIDENCE_FLAGS = ["hollow", "afterFinalizationTimeout", "nativeMarker", "selfAttributing"];
|
|
2388
2377
|
var MESH_TOPIC_ENTRY_KINDS = ["turn.evidence", "turn.committed", "turn.notify", "mesh.record"];
|
|
2389
|
-
var isMeshTopicEntryKind = makeGuard2(MESH_TOPIC_ENTRY_KINDS);
|
|
2390
2378
|
function isOptionalId(value) {
|
|
2391
2379
|
return value === void 0 || isEvidenceIdentifier(value);
|
|
2392
2380
|
}
|
|
@@ -3600,155 +3588,8 @@ function touchedFilesOutsideOwnership(touched, owned) {
|
|
|
3600
3588
|
return { undeclaredTouched, unusedDeclarations };
|
|
3601
3589
|
}
|
|
3602
3590
|
|
|
3603
|
-
// src/keyed-status-delta.ts
|
|
3604
|
-
function sig(value) {
|
|
3605
|
-
if (value === void 0) return void 0;
|
|
3606
|
-
try {
|
|
3607
|
-
return JSON.stringify(value);
|
|
3608
|
-
} catch {
|
|
3609
|
-
return void 0;
|
|
3610
|
-
}
|
|
3611
|
-
}
|
|
3612
|
-
function digestFields(source, ignore) {
|
|
3613
|
-
const sigs = /* @__PURE__ */ new Map();
|
|
3614
|
-
const values = {};
|
|
3615
|
-
for (const [key, value] of Object.entries(source)) {
|
|
3616
|
-
if (ignore.has(key)) continue;
|
|
3617
|
-
const s = sig(value);
|
|
3618
|
-
if (s === void 0) continue;
|
|
3619
|
-
sigs.set(key, s);
|
|
3620
|
-
values[key] = value;
|
|
3621
|
-
}
|
|
3622
|
-
return { sigs, values };
|
|
3623
|
-
}
|
|
3624
|
-
function sessionSignature(session, volatile) {
|
|
3625
|
-
if (volatile.size === 0) return sig(session) ?? "";
|
|
3626
|
-
const stable = {};
|
|
3627
|
-
for (const [key, value] of Object.entries(session)) {
|
|
3628
|
-
if (!volatile.has(key)) stable[key] = value;
|
|
3629
|
-
}
|
|
3630
|
-
return sig(stable) ?? "";
|
|
3631
|
-
}
|
|
3632
|
-
function fieldSigsOf(digest) {
|
|
3633
|
-
if (!digest.fieldSigs) {
|
|
3634
|
-
const sigs = /* @__PURE__ */ new Map();
|
|
3635
|
-
for (const [key, value] of Object.entries(digest.value)) {
|
|
3636
|
-
const s = sig(value);
|
|
3637
|
-
if (s !== void 0) sigs.set(key, s);
|
|
3638
|
-
}
|
|
3639
|
-
digest.fieldSigs = sigs;
|
|
3640
|
-
}
|
|
3641
|
-
return digest.fieldSigs;
|
|
3642
|
-
}
|
|
3643
|
-
function digestKeyedStatus(body, options = {}) {
|
|
3644
|
-
const volatile = new Set(options.volatileSessionFields ?? []);
|
|
3645
|
-
const top = digestFields(body, /* @__PURE__ */ new Set(["status", ...options.ignoreTopLevel ?? []]));
|
|
3646
|
-
const status = digestFields(body.status, /* @__PURE__ */ new Set(["sessions", ...options.ignoreStatus ?? []]));
|
|
3647
|
-
const sessions = /* @__PURE__ */ new Map();
|
|
3648
|
-
const order = [];
|
|
3649
|
-
for (const session of Array.isArray(body.status?.sessions) ? body.status.sessions : []) {
|
|
3650
|
-
if (!session || typeof session.id !== "string" || !session.id) continue;
|
|
3651
|
-
if (sessions.has(session.id)) continue;
|
|
3652
|
-
sessions.set(session.id, { value: session, sig: sessionSignature(session, volatile) });
|
|
3653
|
-
order.push(session.id);
|
|
3654
|
-
}
|
|
3655
|
-
return { top: top.sigs, topValues: top.values, status: status.sigs, statusValues: status.values, sessions, order, volatile };
|
|
3656
|
-
}
|
|
3657
|
-
function diffFieldMaps(prev, next, nextValues) {
|
|
3658
|
-
let set;
|
|
3659
|
-
let unset;
|
|
3660
|
-
for (const [key, s] of next) {
|
|
3661
|
-
if (prev.get(key) === s) continue;
|
|
3662
|
-
(set ??= {})[key] = nextValues[key];
|
|
3663
|
-
}
|
|
3664
|
-
for (const key of prev.keys()) {
|
|
3665
|
-
if (!next.has(key)) (unset ??= []).push(key);
|
|
3666
|
-
}
|
|
3667
|
-
return { ...set ? { set } : {}, ...unset ? { unset } : {} };
|
|
3668
|
-
}
|
|
3669
|
-
function sameOrder(a, b) {
|
|
3670
|
-
if (a.length !== b.length) return false;
|
|
3671
|
-
for (let i = 0; i < a.length; i += 1) if (a[i] !== b[i]) return false;
|
|
3672
|
-
return true;
|
|
3673
|
-
}
|
|
3674
|
-
function diffKeyedStatus(prev, next) {
|
|
3675
|
-
const delta = {};
|
|
3676
|
-
const top = diffFieldMaps(prev.top, next.top, next.topValues);
|
|
3677
|
-
if (top.set) delta.set = top.set;
|
|
3678
|
-
if (top.unset) delta.unset = top.unset;
|
|
3679
|
-
const status = diffFieldMaps(prev.status, next.status, next.statusValues);
|
|
3680
|
-
if (status.set) delta.statusSet = status.set;
|
|
3681
|
-
if (status.unset) delta.statusUnset = status.unset;
|
|
3682
|
-
for (const [id2, nextSession] of next.sessions) {
|
|
3683
|
-
const prevSession = prev.sessions.get(id2);
|
|
3684
|
-
if (!prevSession) {
|
|
3685
|
-
;
|
|
3686
|
-
(delta.sessions ??= []).push(nextSession.value);
|
|
3687
|
-
continue;
|
|
3688
|
-
}
|
|
3689
|
-
if (prevSession.sig === nextSession.sig) continue;
|
|
3690
|
-
const prevSigs = fieldSigsOf(prevSession);
|
|
3691
|
-
const nextSigs = fieldSigsOf(nextSession);
|
|
3692
|
-
const change = { id: id2 };
|
|
3693
|
-
let changed = false;
|
|
3694
|
-
for (const [key, s] of nextSigs) {
|
|
3695
|
-
if (key === "id" || prevSigs.get(key) === s) continue;
|
|
3696
|
-
change[key] = nextSession.value[key];
|
|
3697
|
-
changed = true;
|
|
3698
|
-
}
|
|
3699
|
-
const gone = [];
|
|
3700
|
-
for (const key of prevSigs.keys()) {
|
|
3701
|
-
if (!nextSigs.has(key)) gone.push(key);
|
|
3702
|
-
}
|
|
3703
|
-
if (changed) (delta.sessions ??= []).push(change);
|
|
3704
|
-
if (gone.length > 0) (delta.sessionUnset ??= {})[id2] = gone;
|
|
3705
|
-
}
|
|
3706
|
-
for (const id2 of prev.sessions.keys()) {
|
|
3707
|
-
if (!next.sessions.has(id2)) (delta.removedSessionIds ??= []).push(id2);
|
|
3708
|
-
}
|
|
3709
|
-
if (!sameOrder(prev.order, next.order)) delta.sessionOrder = [...next.order];
|
|
3710
|
-
return Object.keys(delta).length > 0 ? delta : null;
|
|
3711
|
-
}
|
|
3712
|
-
function foldKeyedStatus(held, delta) {
|
|
3713
|
-
const next = { ...held };
|
|
3714
|
-
for (const key of delta.unset ?? []) delete next[key];
|
|
3715
|
-
Object.assign(next, delta.set ?? {});
|
|
3716
|
-
const status = { ...held.status };
|
|
3717
|
-
for (const key of delta.statusUnset ?? []) delete status[key];
|
|
3718
|
-
Object.assign(status, delta.statusSet ?? {});
|
|
3719
|
-
const byId = /* @__PURE__ */ new Map();
|
|
3720
|
-
for (const session of held.status.sessions ?? []) byId.set(session.id, session);
|
|
3721
|
-
for (const id2 of delta.removedSessionIds ?? []) byId.delete(id2);
|
|
3722
|
-
for (const change of delta.sessions ?? []) {
|
|
3723
|
-
const base = byId.get(change.id);
|
|
3724
|
-
byId.set(change.id, base ? { ...base, ...change } : { ...change });
|
|
3725
|
-
}
|
|
3726
|
-
for (const [id2, keys] of Object.entries(delta.sessionUnset ?? {})) {
|
|
3727
|
-
const base = byId.get(id2);
|
|
3728
|
-
if (!base) continue;
|
|
3729
|
-
const trimmed = { ...base };
|
|
3730
|
-
for (const key of keys) delete trimmed[key];
|
|
3731
|
-
byId.set(id2, trimmed);
|
|
3732
|
-
}
|
|
3733
|
-
const order = delta.sessionOrder ?? (held.status.sessions ?? []).map((session) => session.id);
|
|
3734
|
-
const sessions = [];
|
|
3735
|
-
const placed = /* @__PURE__ */ new Set();
|
|
3736
|
-
for (const id2 of order) {
|
|
3737
|
-
const session = byId.get(id2);
|
|
3738
|
-
if (!session || placed.has(id2)) continue;
|
|
3739
|
-
sessions.push(session);
|
|
3740
|
-
placed.add(id2);
|
|
3741
|
-
}
|
|
3742
|
-
for (const [id2, session] of byId) {
|
|
3743
|
-
if (!placed.has(id2)) sessions.push(session);
|
|
3744
|
-
}
|
|
3745
|
-
status.sessions = sessions;
|
|
3746
|
-
next.status = status;
|
|
3747
|
-
return next;
|
|
3748
|
-
}
|
|
3749
|
-
|
|
3750
3591
|
// src/keyed-doc-delta.ts
|
|
3751
|
-
function
|
|
3592
|
+
function sig(value) {
|
|
3752
3593
|
if (value === void 0) return void 0;
|
|
3753
3594
|
try {
|
|
3754
3595
|
return JSON.stringify(value);
|
|
@@ -3785,11 +3626,11 @@ function stripCollections(doc, spec) {
|
|
|
3785
3626
|
}
|
|
3786
3627
|
return out;
|
|
3787
3628
|
}
|
|
3788
|
-
function
|
|
3629
|
+
function fieldSigsOf(digest) {
|
|
3789
3630
|
if (!digest.fieldSigs) {
|
|
3790
3631
|
const sigs = /* @__PURE__ */ new Map();
|
|
3791
3632
|
for (const [key, value] of Object.entries(digest.stable)) {
|
|
3792
|
-
const s =
|
|
3633
|
+
const s = sig(value);
|
|
3793
3634
|
if (s !== void 0) sigs.set(key, s);
|
|
3794
3635
|
}
|
|
3795
3636
|
digest.fieldSigs = sigs;
|
|
@@ -3799,11 +3640,21 @@ function fieldSigsOf2(digest) {
|
|
|
3799
3640
|
function digestKeyedDoc(doc, spec) {
|
|
3800
3641
|
const top = /* @__PURE__ */ new Map();
|
|
3801
3642
|
const topValues = {};
|
|
3643
|
+
const ignore = new Set(spec.ignore ?? []);
|
|
3644
|
+
const split = new Set(spec.splitObjects ?? []);
|
|
3645
|
+
const add = (path, value) => {
|
|
3646
|
+
if (ignore.has(path)) return;
|
|
3647
|
+
const s = sig(value);
|
|
3648
|
+
if (s === void 0) return;
|
|
3649
|
+
top.set(path, s);
|
|
3650
|
+
topValues[path] = value;
|
|
3651
|
+
};
|
|
3802
3652
|
for (const [key, value] of Object.entries(stripCollections(doc, spec))) {
|
|
3803
|
-
|
|
3804
|
-
|
|
3805
|
-
|
|
3806
|
-
|
|
3653
|
+
if (split.has(key) && isRecord3(value)) {
|
|
3654
|
+
for (const [field, fieldValue] of Object.entries(value)) add(`${key}.${field}`, fieldValue);
|
|
3655
|
+
continue;
|
|
3656
|
+
}
|
|
3657
|
+
add(key, value);
|
|
3807
3658
|
}
|
|
3808
3659
|
const collections = /* @__PURE__ */ new Map();
|
|
3809
3660
|
for (const [path, idField] of Object.entries(spec.collections)) {
|
|
@@ -3816,14 +3667,14 @@ function digestKeyedDoc(doc, spec) {
|
|
|
3816
3667
|
const id2 = row[idField];
|
|
3817
3668
|
if (typeof id2 !== "string" || !id2 || rows.has(id2)) continue;
|
|
3818
3669
|
const stable = spec.stableRow ? spec.stableRow(path, row) : row;
|
|
3819
|
-
rows.set(id2, { value: row, stable, sig:
|
|
3670
|
+
rows.set(id2, { value: row, stable, sig: sig(stable) ?? "" });
|
|
3820
3671
|
order.push(id2);
|
|
3821
3672
|
}
|
|
3822
3673
|
collections.set(path, { rows, order });
|
|
3823
3674
|
}
|
|
3824
3675
|
return { top, topValues, collections, volatile: new Set(spec.volatileTopLevel ?? []) };
|
|
3825
3676
|
}
|
|
3826
|
-
function
|
|
3677
|
+
function sameOrder(a, b) {
|
|
3827
3678
|
if (a.length !== b.length) return false;
|
|
3828
3679
|
for (let i = 0; i < a.length; i += 1) if (a[i] !== b[i]) return false;
|
|
3829
3680
|
return true;
|
|
@@ -3841,8 +3692,8 @@ function diffCollection(prev, next, idField) {
|
|
|
3841
3692
|
continue;
|
|
3842
3693
|
}
|
|
3843
3694
|
if (prevRow.sig === nextRow.sig) continue;
|
|
3844
|
-
const prevSigs =
|
|
3845
|
-
const nextSigs =
|
|
3695
|
+
const prevSigs = fieldSigsOf(prevRow);
|
|
3696
|
+
const nextSigs = fieldSigsOf(nextRow);
|
|
3846
3697
|
const change = { [idField]: id2 };
|
|
3847
3698
|
let changed = false;
|
|
3848
3699
|
for (const [key, s] of nextSigs) {
|
|
@@ -3850,6 +3701,12 @@ function diffCollection(prev, next, idField) {
|
|
|
3850
3701
|
change[key] = nextRow.value[key];
|
|
3851
3702
|
changed = true;
|
|
3852
3703
|
}
|
|
3704
|
+
if (changed) {
|
|
3705
|
+
for (const [key, value] of Object.entries(nextRow.value)) {
|
|
3706
|
+
if (key in nextRow.stable || key in change) continue;
|
|
3707
|
+
if (sig(prevRow.value[key]) !== sig(value)) change[key] = value;
|
|
3708
|
+
}
|
|
3709
|
+
}
|
|
3853
3710
|
const gone = [];
|
|
3854
3711
|
for (const key of prevSigs.keys()) if (!nextSigs.has(key) && !(key in nextRow.value)) gone.push(key);
|
|
3855
3712
|
if (changed) (delta.upsert ??= []).push(change);
|
|
@@ -3858,7 +3715,7 @@ function diffCollection(prev, next, idField) {
|
|
|
3858
3715
|
for (const id2 of prevRows.keys()) {
|
|
3859
3716
|
if (!nextRows.has(id2)) (delta.removed ??= []).push(id2);
|
|
3860
3717
|
}
|
|
3861
|
-
if (!
|
|
3718
|
+
if (!sameOrder(prev?.order ?? [], next?.order ?? [])) delta.order = [...next?.order ?? []];
|
|
3862
3719
|
return Object.keys(delta).length > 0 ? delta : null;
|
|
3863
3720
|
}
|
|
3864
3721
|
function diffKeyedDoc(prev, next, spec) {
|
|
@@ -3866,15 +3723,27 @@ function diffKeyedDoc(prev, next, spec) {
|
|
|
3866
3723
|
let meaningful = false;
|
|
3867
3724
|
let set;
|
|
3868
3725
|
let unset;
|
|
3869
|
-
|
|
3870
|
-
|
|
3871
|
-
(
|
|
3872
|
-
|
|
3726
|
+
const split = spec.splitObjects ?? [];
|
|
3727
|
+
const objectOf = (path) => {
|
|
3728
|
+
for (const object of split) {
|
|
3729
|
+
if (path.startsWith(`${object}.`)) return [object, path.slice(object.length + 1)];
|
|
3730
|
+
}
|
|
3731
|
+
return null;
|
|
3732
|
+
};
|
|
3733
|
+
const objects = {};
|
|
3734
|
+
for (const [path, s] of next.top) {
|
|
3735
|
+
if (prev.top.get(path) === s) continue;
|
|
3736
|
+
const inObject = objectOf(path);
|
|
3737
|
+
if (inObject) ((objects[inObject[0]] ??= {}).set ??= {})[inObject[1]] = next.topValues[path];
|
|
3738
|
+
else (set ??= {})[path] = next.topValues[path];
|
|
3739
|
+
if (!next.volatile.has(path)) meaningful = true;
|
|
3873
3740
|
}
|
|
3874
|
-
for (const
|
|
3875
|
-
if (next.top.has(
|
|
3876
|
-
|
|
3877
|
-
if (
|
|
3741
|
+
for (const path of prev.top.keys()) {
|
|
3742
|
+
if (next.top.has(path)) continue;
|
|
3743
|
+
const inObject = objectOf(path);
|
|
3744
|
+
if (inObject) ((objects[inObject[0]] ??= {}).unset ??= []).push(inObject[1]);
|
|
3745
|
+
else (unset ??= []).push(path);
|
|
3746
|
+
if (!next.volatile.has(path)) meaningful = true;
|
|
3878
3747
|
}
|
|
3879
3748
|
for (const [path, idField] of Object.entries(spec.collections)) {
|
|
3880
3749
|
const change = diffCollection(prev.collections.get(path), next.collections.get(path), idField);
|
|
@@ -3885,6 +3754,7 @@ function diffKeyedDoc(prev, next, spec) {
|
|
|
3885
3754
|
if (!meaningful) return null;
|
|
3886
3755
|
if (set) delta.set = set;
|
|
3887
3756
|
if (unset) delta.unset = unset;
|
|
3757
|
+
if (Object.keys(objects).length > 0) delta.objects = objects;
|
|
3888
3758
|
return delta;
|
|
3889
3759
|
}
|
|
3890
3760
|
function foldCollection(held, change, idField) {
|
|
@@ -3927,6 +3797,12 @@ function foldKeyedDoc(held, delta, spec) {
|
|
|
3927
3797
|
const next = stripCollections(held, spec);
|
|
3928
3798
|
for (const key of delta.unset ?? []) delete next[key];
|
|
3929
3799
|
Object.assign(next, delta.set ?? {});
|
|
3800
|
+
for (const [object, change] of Object.entries(delta.objects ?? {})) {
|
|
3801
|
+
const folded = isRecord3(next[object]) ? { ...next[object] } : {};
|
|
3802
|
+
for (const key of change.unset ?? []) delete folded[key];
|
|
3803
|
+
Object.assign(folded, change.set ?? {});
|
|
3804
|
+
next[object] = folded;
|
|
3805
|
+
}
|
|
3930
3806
|
for (const [path, idField] of Object.entries(spec.collections)) {
|
|
3931
3807
|
const change = delta.collections?.[path];
|
|
3932
3808
|
const heldList = heldCollections.get(path);
|
|
@@ -3948,6 +3824,16 @@ function foldKeyedDoc(held, delta, spec) {
|
|
|
3948
3824
|
}
|
|
3949
3825
|
return next;
|
|
3950
3826
|
}
|
|
3827
|
+
var DAEMON_METADATA_DOC_SPEC = {
|
|
3828
|
+
collections: { "status.sessions": "id" },
|
|
3829
|
+
splitObjects: ["status"],
|
|
3830
|
+
ignore: ["daemonId", "status.timestamp"],
|
|
3831
|
+
stableRow: (_collection, row) => {
|
|
3832
|
+
if (!("lastUpdated" in row)) return row;
|
|
3833
|
+
const { lastUpdated: _stamp, ...stable } = row;
|
|
3834
|
+
return stable;
|
|
3835
|
+
}
|
|
3836
|
+
};
|
|
3951
3837
|
var MESH_STATUS_DOC_SPEC = {
|
|
3952
3838
|
collections: { nodes: "nodeId", "queue.tasks": "id", missions: "id" },
|
|
3953
3839
|
volatileTopLevel: [
|
|
@@ -3997,6 +3883,7 @@ function stableMeshNodeRow(row) {
|
|
|
3997
3883
|
COMMIT_STRENGTHS,
|
|
3998
3884
|
CONSUME_PROFILES,
|
|
3999
3885
|
COORDINATOR_ACK_OUTCOMES,
|
|
3886
|
+
DAEMON_METADATA_DOC_SPEC,
|
|
4000
3887
|
DAEMON_P2P_SIGNAL_TYPES,
|
|
4001
3888
|
DAEMON_STATUS_EVENT_NAMES,
|
|
4002
3889
|
DAEMON_TO_DASHBOARD_P2P_TYPES,
|
|
@@ -4007,6 +3894,7 @@ function stableMeshNodeRow(row) {
|
|
|
4007
3894
|
DASHBOARD_STATUS_EVENT_NAMES,
|
|
4008
3895
|
DASHBOARD_TO_DAEMON_P2P_TYPES,
|
|
4009
3896
|
DASHBOARD_TO_USER_SESSION_TYPES,
|
|
3897
|
+
DASHBOARD_WIRE_VERSION,
|
|
4010
3898
|
DEFAULT_DIFFICULTY_BRAINS,
|
|
4011
3899
|
DELIVERY_OUTCOMES,
|
|
4012
3900
|
DELIVERY_VIAS,
|
|
@@ -4080,6 +3968,7 @@ function stableMeshNodeRow(row) {
|
|
|
4080
3968
|
SUSPENSION_RESOLUTION_VIAS,
|
|
4081
3969
|
SYSTEM_ANNOUNCEMENT_TYPES,
|
|
4082
3970
|
TERMINAL_CLASS_EVIDENCE_KINDS,
|
|
3971
|
+
TERMINAL_SESSION_RECORD_STATUSES,
|
|
4083
3972
|
TOOL_CALLER_ROLES,
|
|
4084
3973
|
TURN_END_BLOCK_REASONS,
|
|
4085
3974
|
TURN_END_STRENGTHS,
|
|
@@ -4107,6 +3996,7 @@ function stableMeshNodeRow(row) {
|
|
|
4107
3996
|
buildSlotProposal,
|
|
4108
3997
|
canonicalDaemonId,
|
|
4109
3998
|
classifySessionStatus,
|
|
3999
|
+
compareDashboardWireVersion,
|
|
4110
4000
|
compareSemver,
|
|
4111
4001
|
daemonIdsEquivalent,
|
|
4112
4002
|
decodeActiveWorkQueryRequest,
|
|
@@ -4184,19 +4074,15 @@ function stableMeshNodeRow(row) {
|
|
|
4184
4074
|
deriveSlotsFromLegacy,
|
|
4185
4075
|
describeModelSelection,
|
|
4186
4076
|
diffKeyedDoc,
|
|
4187
|
-
diffKeyedStatus,
|
|
4188
4077
|
digestKeyedDoc,
|
|
4189
|
-
digestKeyedStatus,
|
|
4190
4078
|
effectiveModelSelectionValue,
|
|
4191
4079
|
enumOf,
|
|
4192
4080
|
expandDaemonIdForms,
|
|
4193
4081
|
findOwnershipConflicts,
|
|
4194
4082
|
foldKeyedDoc,
|
|
4195
|
-
foldKeyedStatus,
|
|
4196
4083
|
formatQuotaAccount,
|
|
4197
4084
|
hasGitStatusEvidence,
|
|
4198
4085
|
hasWorkerProtocolFooter,
|
|
4199
|
-
interpolateArgs,
|
|
4200
4086
|
interpolateString,
|
|
4201
4087
|
isActiveWorkQueryRequest,
|
|
4202
4088
|
isActiveWorkQueryResponse,
|
|
@@ -4209,7 +4095,6 @@ function stableMeshNodeRow(row) {
|
|
|
4209
4095
|
isDaemonStatusEventName,
|
|
4210
4096
|
isDaemonToDashboardP2PType,
|
|
4211
4097
|
isDaemonToServerType,
|
|
4212
|
-
isDaemonToServerWsMsg,
|
|
4213
4098
|
isDashboardP2PSignalType,
|
|
4214
4099
|
isDashboardStatusEventName,
|
|
4215
4100
|
isDashboardToDaemonChunkType,
|
|
@@ -4220,7 +4105,6 @@ function stableMeshNodeRow(row) {
|
|
|
4220
4105
|
isDirectDispatchRecordResponse,
|
|
4221
4106
|
isDowngrade,
|
|
4222
4107
|
isEvidenceIdentifier,
|
|
4223
|
-
isEvidenceSourceId,
|
|
4224
4108
|
isFiniteNumber,
|
|
4225
4109
|
isGraphAuditEvent,
|
|
4226
4110
|
isGraphAuditRecordRequest,
|
|
@@ -4235,7 +4119,7 @@ function stableMeshNodeRow(row) {
|
|
|
4235
4119
|
isGraphNodePatchResponse,
|
|
4236
4120
|
isGraphViewQueryRequest,
|
|
4237
4121
|
isGraphViewQueryResponse,
|
|
4238
|
-
|
|
4122
|
+
isIdleSessionState,
|
|
4239
4123
|
isInputEnvelopeWire,
|
|
4240
4124
|
isLedgerQueryRequest,
|
|
4241
4125
|
isLedgerQueryResponse,
|
|
@@ -4249,15 +4133,12 @@ function stableMeshNodeRow(row) {
|
|
|
4249
4133
|
isMeshRecordPayload,
|
|
4250
4134
|
isMeshRecordRequest,
|
|
4251
4135
|
isMeshRecordResponse,
|
|
4252
|
-
isMeshSessionCleanupMode,
|
|
4253
4136
|
isMeshTaskDifficulty,
|
|
4254
4137
|
isMeshTaskMode,
|
|
4255
4138
|
isMeshTaskPriority,
|
|
4256
4139
|
isMeshTaskStatus,
|
|
4257
4140
|
isMeshTerminalTaskStatus,
|
|
4258
|
-
isMeshThinkingLevel,
|
|
4259
4141
|
isMeshTopicEntry,
|
|
4260
|
-
isMeshTopicEntryKind,
|
|
4261
4142
|
isMessageId,
|
|
4262
4143
|
isMissionListQueryRequest,
|
|
4263
4144
|
isMissionListQueryResponse,
|
|
@@ -4307,7 +4188,6 @@ function stableMeshNodeRow(row) {
|
|
|
4307
4188
|
isSendRefusal,
|
|
4308
4189
|
isServerDirectCommandMsg,
|
|
4309
4190
|
isServerToDaemonControlType,
|
|
4310
|
-
isServerToDaemonWsMsg,
|
|
4311
4191
|
isSessionLaunchedBy,
|
|
4312
4192
|
isSessionStatus,
|
|
4313
4193
|
isSharedSessionToViewerType,
|
|
@@ -4315,7 +4195,7 @@ function stableMeshNodeRow(row) {
|
|
|
4315
4195
|
isSummaryRef,
|
|
4316
4196
|
isTaskStatsQueryRequest,
|
|
4317
4197
|
isTaskStatsQueryResponse,
|
|
4318
|
-
|
|
4198
|
+
isTerminalSessionRecordStatus,
|
|
4319
4199
|
isToolCallRecordRequest,
|
|
4320
4200
|
isToolCallRecordResponse,
|
|
4321
4201
|
isToolCallerRole,
|
|
@@ -4336,7 +4216,6 @@ function stableMeshNodeRow(row) {
|
|
|
4336
4216
|
isTurnReason,
|
|
4337
4217
|
isUserSessionToDashboardType,
|
|
4338
4218
|
isViewerToSharedSessionType,
|
|
4339
|
-
isWorkerBranchState,
|
|
4340
4219
|
isWorkerReportOutcome,
|
|
4341
4220
|
isWorkerTool,
|
|
4342
4221
|
isWorkingStatus,
|