@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.mjs
CHANGED
|
@@ -638,13 +638,6 @@ function buildMagiPanelProposal(detected, opts = {}) {
|
|
|
638
638
|
}
|
|
639
639
|
|
|
640
640
|
// src/interpolation.ts
|
|
641
|
-
function interpolateArgs(args, context) {
|
|
642
|
-
const result = {};
|
|
643
|
-
for (const [k, v] of Object.entries(args)) {
|
|
644
|
-
result[k] = typeof v === "string" ? interpolateString(v, context) : v;
|
|
645
|
-
}
|
|
646
|
-
return result;
|
|
647
|
-
}
|
|
648
641
|
function interpolateString(template, ctx) {
|
|
649
642
|
return template.replace(/\{\{(\w+)\}\}/g, (_, key) => {
|
|
650
643
|
const val = ctx[key];
|
|
@@ -1010,9 +1003,7 @@ var DAEMON_STATUS_EVENT_NAMES = [
|
|
|
1010
1003
|
"agent:waiting_choice",
|
|
1011
1004
|
"agent:generating_completed",
|
|
1012
1005
|
"agent:stopped",
|
|
1013
|
-
"monitor:no_progress"
|
|
1014
|
-
/** Legacy alias for `monitor:no_progress`, still emitted by older daemons. */
|
|
1015
|
-
"monitor:long_generating"
|
|
1006
|
+
"monitor:no_progress"
|
|
1016
1007
|
];
|
|
1017
1008
|
var isDaemonStatusEventName = makeTypeGuard(DAEMON_STATUS_EVENT_NAMES);
|
|
1018
1009
|
var RELEASE_CHANNELS = ["stable", "preview"];
|
|
@@ -1242,9 +1233,6 @@ var DAEMON_TO_DASHBOARD_P2P_TYPES = [
|
|
|
1242
1233
|
var isDaemonToDashboardP2PType = makeTypeGuard(DAEMON_TO_DASHBOARD_P2P_TYPES);
|
|
1243
1234
|
function decodeDaemonToDashboardP2P(raw) {
|
|
1244
1235
|
if (!isRecord(raw)) return null;
|
|
1245
|
-
if (raw.type === void 0 && isNonEmptyString(raw.id) && typeof raw.success === "boolean") {
|
|
1246
|
-
return { ...raw, type: "response" };
|
|
1247
|
-
}
|
|
1248
1236
|
if (!isDaemonToDashboardP2PType(raw.type)) return null;
|
|
1249
1237
|
switch (raw.type) {
|
|
1250
1238
|
case "ping":
|
|
@@ -1280,11 +1268,17 @@ var DASHBOARD_P2P_MESSAGE_KINDS = [
|
|
|
1280
1268
|
.../* @__PURE__ */ new Set([...DASHBOARD_TO_DAEMON_P2P_TYPES, ...DAEMON_TO_DASHBOARD_P2P_TYPES])
|
|
1281
1269
|
];
|
|
1282
1270
|
|
|
1271
|
+
// src/protocol/dashboard-wire-version.ts
|
|
1272
|
+
var DASHBOARD_WIRE_VERSION = 2;
|
|
1273
|
+
function compareDashboardWireVersion(pageVersion, daemonVersion) {
|
|
1274
|
+
const daemon = typeof daemonVersion === "number" && Number.isFinite(daemonVersion) ? daemonVersion : 1;
|
|
1275
|
+
if (daemon === pageVersion) return "ok";
|
|
1276
|
+
return daemon > pageVersion ? "reload_required" : "daemon_update_required";
|
|
1277
|
+
}
|
|
1278
|
+
|
|
1283
1279
|
// src/ws-protocol.ts
|
|
1284
1280
|
var DAEMON_TO_SERVER_WS_MSGS = DAEMON_TO_SERVER_TYPES;
|
|
1285
1281
|
var SERVER_TO_DAEMON_WS_MSGS = SERVER_TO_DAEMON_CONTROL_TYPES;
|
|
1286
|
-
var isDaemonToServerWsMsg = isDaemonToServerType;
|
|
1287
|
-
var isServerToDaemonWsMsg = isServerToDaemonControlType;
|
|
1288
1282
|
function normalizeAuthOkLimits(raw) {
|
|
1289
1283
|
if (!raw || typeof raw !== "object") return null;
|
|
1290
1284
|
const src = raw;
|
|
@@ -1380,6 +1374,16 @@ function isBusyStatus(raw) {
|
|
|
1380
1374
|
function statusesOfClass(cls) {
|
|
1381
1375
|
return SESSION_STATUSES.filter((status) => SESSION_STATUS_CLASS[status] === cls);
|
|
1382
1376
|
}
|
|
1377
|
+
var TERMINAL_SESSION_RECORD_STATUSES = ["stopped", "failed", "terminated", "exited", "closed"];
|
|
1378
|
+
function isTerminalSessionRecordStatus(raw) {
|
|
1379
|
+
return typeof raw === "string" && TERMINAL_SESSION_RECORD_STATUSES.includes(raw.trim().toLowerCase());
|
|
1380
|
+
}
|
|
1381
|
+
function isIdleSessionState(state) {
|
|
1382
|
+
const record = state && typeof state === "object" ? state : {};
|
|
1383
|
+
const status = typeof record.status === "string" ? record.status.trim().toLowerCase() : "";
|
|
1384
|
+
if (isTerminalSessionRecordStatus(status) || isDeadStatus(status)) return false;
|
|
1385
|
+
return isReadyStatus(status) || record.activeChat?.status === "waiting_input";
|
|
1386
|
+
}
|
|
1383
1387
|
|
|
1384
1388
|
// src/mesh-vocabulary.ts
|
|
1385
1389
|
var MESH_TASK_STATUSES = ["pending", "assigned", "completed", "failed", "cancelled"];
|
|
@@ -1405,11 +1409,8 @@ var isMeshTaskStatus = makeGuard(MESH_TASK_STATUSES);
|
|
|
1405
1409
|
var isMeshTerminalTaskStatus = makeGuard(MESH_TERMINAL_TASK_STATUSES);
|
|
1406
1410
|
var isMeshTaskMode = makeGuard(MESH_TASK_MODES);
|
|
1407
1411
|
var isMeshTaskPriority = makeGuard(MESH_TASK_PRIORITIES);
|
|
1408
|
-
var isMeshThinkingLevel = makeGuard(MESH_THINKING_LEVELS);
|
|
1409
1412
|
var isMeshDeliveryMode = makeGuard(MESH_DELIVERY_MODES);
|
|
1410
|
-
var isMeshSessionCleanupMode = makeGuard(MESH_SESSION_CLEANUP_MODES);
|
|
1411
1413
|
var isWorkerReportOutcome = makeGuard(WORKER_REPORT_OUTCOMES);
|
|
1412
|
-
var isWorkerBranchState = makeGuard(WORKER_BRANCH_STATES);
|
|
1413
1414
|
function enumOf(values, description) {
|
|
1414
1415
|
return {
|
|
1415
1416
|
type: "string",
|
|
@@ -1872,11 +1873,9 @@ function makeGuard2(values) {
|
|
|
1872
1873
|
const set = new Set(values);
|
|
1873
1874
|
return (value) => typeof value === "string" && set.has(value);
|
|
1874
1875
|
}
|
|
1875
|
-
var isEvidenceSourceId = makeGuard2(EVIDENCE_SOURCE_IDS);
|
|
1876
1876
|
var isTurnEvidenceKind = makeGuard2(TURN_EVIDENCE_KINDS);
|
|
1877
1877
|
var isTurnReason = makeGuard2(TURN_REASONS);
|
|
1878
1878
|
var isNotifyKind = makeGuard2(NOTIFY_KINDS);
|
|
1879
|
-
var isHoldReason = makeGuard2(HOLD_REASONS);
|
|
1880
1879
|
var isTurnOutcome = makeGuard2(TURN_OUTCOMES);
|
|
1881
1880
|
var isCommitStrength = makeGuard2(COMMIT_STRENGTHS);
|
|
1882
1881
|
function isRecord2(value) {
|
|
@@ -1950,12 +1949,8 @@ function isTurnEvidence(value) {
|
|
|
1950
1949
|
}
|
|
1951
1950
|
return true;
|
|
1952
1951
|
}
|
|
1953
|
-
function isTerminalClassEvidenceKind(kind) {
|
|
1954
|
-
return TERMINAL_CLASS_EVIDENCE_KINDS.includes(kind);
|
|
1955
|
-
}
|
|
1956
1952
|
var TURN_EVIDENCE_FLAGS = ["hollow", "afterFinalizationTimeout", "nativeMarker", "selfAttributing"];
|
|
1957
1953
|
var MESH_TOPIC_ENTRY_KINDS = ["turn.evidence", "turn.committed", "turn.notify", "mesh.record"];
|
|
1958
|
-
var isMeshTopicEntryKind = makeGuard2(MESH_TOPIC_ENTRY_KINDS);
|
|
1959
1954
|
function isOptionalId(value) {
|
|
1960
1955
|
return value === void 0 || isEvidenceIdentifier(value);
|
|
1961
1956
|
}
|
|
@@ -3169,155 +3164,8 @@ function touchedFilesOutsideOwnership(touched, owned) {
|
|
|
3169
3164
|
return { undeclaredTouched, unusedDeclarations };
|
|
3170
3165
|
}
|
|
3171
3166
|
|
|
3172
|
-
// src/keyed-status-delta.ts
|
|
3173
|
-
function sig(value) {
|
|
3174
|
-
if (value === void 0) return void 0;
|
|
3175
|
-
try {
|
|
3176
|
-
return JSON.stringify(value);
|
|
3177
|
-
} catch {
|
|
3178
|
-
return void 0;
|
|
3179
|
-
}
|
|
3180
|
-
}
|
|
3181
|
-
function digestFields(source, ignore) {
|
|
3182
|
-
const sigs = /* @__PURE__ */ new Map();
|
|
3183
|
-
const values = {};
|
|
3184
|
-
for (const [key, value] of Object.entries(source)) {
|
|
3185
|
-
if (ignore.has(key)) continue;
|
|
3186
|
-
const s = sig(value);
|
|
3187
|
-
if (s === void 0) continue;
|
|
3188
|
-
sigs.set(key, s);
|
|
3189
|
-
values[key] = value;
|
|
3190
|
-
}
|
|
3191
|
-
return { sigs, values };
|
|
3192
|
-
}
|
|
3193
|
-
function sessionSignature(session, volatile) {
|
|
3194
|
-
if (volatile.size === 0) return sig(session) ?? "";
|
|
3195
|
-
const stable = {};
|
|
3196
|
-
for (const [key, value] of Object.entries(session)) {
|
|
3197
|
-
if (!volatile.has(key)) stable[key] = value;
|
|
3198
|
-
}
|
|
3199
|
-
return sig(stable) ?? "";
|
|
3200
|
-
}
|
|
3201
|
-
function fieldSigsOf(digest) {
|
|
3202
|
-
if (!digest.fieldSigs) {
|
|
3203
|
-
const sigs = /* @__PURE__ */ new Map();
|
|
3204
|
-
for (const [key, value] of Object.entries(digest.value)) {
|
|
3205
|
-
const s = sig(value);
|
|
3206
|
-
if (s !== void 0) sigs.set(key, s);
|
|
3207
|
-
}
|
|
3208
|
-
digest.fieldSigs = sigs;
|
|
3209
|
-
}
|
|
3210
|
-
return digest.fieldSigs;
|
|
3211
|
-
}
|
|
3212
|
-
function digestKeyedStatus(body, options = {}) {
|
|
3213
|
-
const volatile = new Set(options.volatileSessionFields ?? []);
|
|
3214
|
-
const top = digestFields(body, /* @__PURE__ */ new Set(["status", ...options.ignoreTopLevel ?? []]));
|
|
3215
|
-
const status = digestFields(body.status, /* @__PURE__ */ new Set(["sessions", ...options.ignoreStatus ?? []]));
|
|
3216
|
-
const sessions = /* @__PURE__ */ new Map();
|
|
3217
|
-
const order = [];
|
|
3218
|
-
for (const session of Array.isArray(body.status?.sessions) ? body.status.sessions : []) {
|
|
3219
|
-
if (!session || typeof session.id !== "string" || !session.id) continue;
|
|
3220
|
-
if (sessions.has(session.id)) continue;
|
|
3221
|
-
sessions.set(session.id, { value: session, sig: sessionSignature(session, volatile) });
|
|
3222
|
-
order.push(session.id);
|
|
3223
|
-
}
|
|
3224
|
-
return { top: top.sigs, topValues: top.values, status: status.sigs, statusValues: status.values, sessions, order, volatile };
|
|
3225
|
-
}
|
|
3226
|
-
function diffFieldMaps(prev, next, nextValues) {
|
|
3227
|
-
let set;
|
|
3228
|
-
let unset;
|
|
3229
|
-
for (const [key, s] of next) {
|
|
3230
|
-
if (prev.get(key) === s) continue;
|
|
3231
|
-
(set ??= {})[key] = nextValues[key];
|
|
3232
|
-
}
|
|
3233
|
-
for (const key of prev.keys()) {
|
|
3234
|
-
if (!next.has(key)) (unset ??= []).push(key);
|
|
3235
|
-
}
|
|
3236
|
-
return { ...set ? { set } : {}, ...unset ? { unset } : {} };
|
|
3237
|
-
}
|
|
3238
|
-
function sameOrder(a, b) {
|
|
3239
|
-
if (a.length !== b.length) return false;
|
|
3240
|
-
for (let i = 0; i < a.length; i += 1) if (a[i] !== b[i]) return false;
|
|
3241
|
-
return true;
|
|
3242
|
-
}
|
|
3243
|
-
function diffKeyedStatus(prev, next) {
|
|
3244
|
-
const delta = {};
|
|
3245
|
-
const top = diffFieldMaps(prev.top, next.top, next.topValues);
|
|
3246
|
-
if (top.set) delta.set = top.set;
|
|
3247
|
-
if (top.unset) delta.unset = top.unset;
|
|
3248
|
-
const status = diffFieldMaps(prev.status, next.status, next.statusValues);
|
|
3249
|
-
if (status.set) delta.statusSet = status.set;
|
|
3250
|
-
if (status.unset) delta.statusUnset = status.unset;
|
|
3251
|
-
for (const [id2, nextSession] of next.sessions) {
|
|
3252
|
-
const prevSession = prev.sessions.get(id2);
|
|
3253
|
-
if (!prevSession) {
|
|
3254
|
-
;
|
|
3255
|
-
(delta.sessions ??= []).push(nextSession.value);
|
|
3256
|
-
continue;
|
|
3257
|
-
}
|
|
3258
|
-
if (prevSession.sig === nextSession.sig) continue;
|
|
3259
|
-
const prevSigs = fieldSigsOf(prevSession);
|
|
3260
|
-
const nextSigs = fieldSigsOf(nextSession);
|
|
3261
|
-
const change = { id: id2 };
|
|
3262
|
-
let changed = false;
|
|
3263
|
-
for (const [key, s] of nextSigs) {
|
|
3264
|
-
if (key === "id" || prevSigs.get(key) === s) continue;
|
|
3265
|
-
change[key] = nextSession.value[key];
|
|
3266
|
-
changed = true;
|
|
3267
|
-
}
|
|
3268
|
-
const gone = [];
|
|
3269
|
-
for (const key of prevSigs.keys()) {
|
|
3270
|
-
if (!nextSigs.has(key)) gone.push(key);
|
|
3271
|
-
}
|
|
3272
|
-
if (changed) (delta.sessions ??= []).push(change);
|
|
3273
|
-
if (gone.length > 0) (delta.sessionUnset ??= {})[id2] = gone;
|
|
3274
|
-
}
|
|
3275
|
-
for (const id2 of prev.sessions.keys()) {
|
|
3276
|
-
if (!next.sessions.has(id2)) (delta.removedSessionIds ??= []).push(id2);
|
|
3277
|
-
}
|
|
3278
|
-
if (!sameOrder(prev.order, next.order)) delta.sessionOrder = [...next.order];
|
|
3279
|
-
return Object.keys(delta).length > 0 ? delta : null;
|
|
3280
|
-
}
|
|
3281
|
-
function foldKeyedStatus(held, delta) {
|
|
3282
|
-
const next = { ...held };
|
|
3283
|
-
for (const key of delta.unset ?? []) delete next[key];
|
|
3284
|
-
Object.assign(next, delta.set ?? {});
|
|
3285
|
-
const status = { ...held.status };
|
|
3286
|
-
for (const key of delta.statusUnset ?? []) delete status[key];
|
|
3287
|
-
Object.assign(status, delta.statusSet ?? {});
|
|
3288
|
-
const byId = /* @__PURE__ */ new Map();
|
|
3289
|
-
for (const session of held.status.sessions ?? []) byId.set(session.id, session);
|
|
3290
|
-
for (const id2 of delta.removedSessionIds ?? []) byId.delete(id2);
|
|
3291
|
-
for (const change of delta.sessions ?? []) {
|
|
3292
|
-
const base = byId.get(change.id);
|
|
3293
|
-
byId.set(change.id, base ? { ...base, ...change } : { ...change });
|
|
3294
|
-
}
|
|
3295
|
-
for (const [id2, keys] of Object.entries(delta.sessionUnset ?? {})) {
|
|
3296
|
-
const base = byId.get(id2);
|
|
3297
|
-
if (!base) continue;
|
|
3298
|
-
const trimmed = { ...base };
|
|
3299
|
-
for (const key of keys) delete trimmed[key];
|
|
3300
|
-
byId.set(id2, trimmed);
|
|
3301
|
-
}
|
|
3302
|
-
const order = delta.sessionOrder ?? (held.status.sessions ?? []).map((session) => session.id);
|
|
3303
|
-
const sessions = [];
|
|
3304
|
-
const placed = /* @__PURE__ */ new Set();
|
|
3305
|
-
for (const id2 of order) {
|
|
3306
|
-
const session = byId.get(id2);
|
|
3307
|
-
if (!session || placed.has(id2)) continue;
|
|
3308
|
-
sessions.push(session);
|
|
3309
|
-
placed.add(id2);
|
|
3310
|
-
}
|
|
3311
|
-
for (const [id2, session] of byId) {
|
|
3312
|
-
if (!placed.has(id2)) sessions.push(session);
|
|
3313
|
-
}
|
|
3314
|
-
status.sessions = sessions;
|
|
3315
|
-
next.status = status;
|
|
3316
|
-
return next;
|
|
3317
|
-
}
|
|
3318
|
-
|
|
3319
3167
|
// src/keyed-doc-delta.ts
|
|
3320
|
-
function
|
|
3168
|
+
function sig(value) {
|
|
3321
3169
|
if (value === void 0) return void 0;
|
|
3322
3170
|
try {
|
|
3323
3171
|
return JSON.stringify(value);
|
|
@@ -3354,11 +3202,11 @@ function stripCollections(doc, spec) {
|
|
|
3354
3202
|
}
|
|
3355
3203
|
return out;
|
|
3356
3204
|
}
|
|
3357
|
-
function
|
|
3205
|
+
function fieldSigsOf(digest) {
|
|
3358
3206
|
if (!digest.fieldSigs) {
|
|
3359
3207
|
const sigs = /* @__PURE__ */ new Map();
|
|
3360
3208
|
for (const [key, value] of Object.entries(digest.stable)) {
|
|
3361
|
-
const s =
|
|
3209
|
+
const s = sig(value);
|
|
3362
3210
|
if (s !== void 0) sigs.set(key, s);
|
|
3363
3211
|
}
|
|
3364
3212
|
digest.fieldSigs = sigs;
|
|
@@ -3368,11 +3216,21 @@ function fieldSigsOf2(digest) {
|
|
|
3368
3216
|
function digestKeyedDoc(doc, spec) {
|
|
3369
3217
|
const top = /* @__PURE__ */ new Map();
|
|
3370
3218
|
const topValues = {};
|
|
3219
|
+
const ignore = new Set(spec.ignore ?? []);
|
|
3220
|
+
const split = new Set(spec.splitObjects ?? []);
|
|
3221
|
+
const add = (path, value) => {
|
|
3222
|
+
if (ignore.has(path)) return;
|
|
3223
|
+
const s = sig(value);
|
|
3224
|
+
if (s === void 0) return;
|
|
3225
|
+
top.set(path, s);
|
|
3226
|
+
topValues[path] = value;
|
|
3227
|
+
};
|
|
3371
3228
|
for (const [key, value] of Object.entries(stripCollections(doc, spec))) {
|
|
3372
|
-
|
|
3373
|
-
|
|
3374
|
-
|
|
3375
|
-
|
|
3229
|
+
if (split.has(key) && isRecord3(value)) {
|
|
3230
|
+
for (const [field, fieldValue] of Object.entries(value)) add(`${key}.${field}`, fieldValue);
|
|
3231
|
+
continue;
|
|
3232
|
+
}
|
|
3233
|
+
add(key, value);
|
|
3376
3234
|
}
|
|
3377
3235
|
const collections = /* @__PURE__ */ new Map();
|
|
3378
3236
|
for (const [path, idField] of Object.entries(spec.collections)) {
|
|
@@ -3385,14 +3243,14 @@ function digestKeyedDoc(doc, spec) {
|
|
|
3385
3243
|
const id2 = row[idField];
|
|
3386
3244
|
if (typeof id2 !== "string" || !id2 || rows.has(id2)) continue;
|
|
3387
3245
|
const stable = spec.stableRow ? spec.stableRow(path, row) : row;
|
|
3388
|
-
rows.set(id2, { value: row, stable, sig:
|
|
3246
|
+
rows.set(id2, { value: row, stable, sig: sig(stable) ?? "" });
|
|
3389
3247
|
order.push(id2);
|
|
3390
3248
|
}
|
|
3391
3249
|
collections.set(path, { rows, order });
|
|
3392
3250
|
}
|
|
3393
3251
|
return { top, topValues, collections, volatile: new Set(spec.volatileTopLevel ?? []) };
|
|
3394
3252
|
}
|
|
3395
|
-
function
|
|
3253
|
+
function sameOrder(a, b) {
|
|
3396
3254
|
if (a.length !== b.length) return false;
|
|
3397
3255
|
for (let i = 0; i < a.length; i += 1) if (a[i] !== b[i]) return false;
|
|
3398
3256
|
return true;
|
|
@@ -3410,8 +3268,8 @@ function diffCollection(prev, next, idField) {
|
|
|
3410
3268
|
continue;
|
|
3411
3269
|
}
|
|
3412
3270
|
if (prevRow.sig === nextRow.sig) continue;
|
|
3413
|
-
const prevSigs =
|
|
3414
|
-
const nextSigs =
|
|
3271
|
+
const prevSigs = fieldSigsOf(prevRow);
|
|
3272
|
+
const nextSigs = fieldSigsOf(nextRow);
|
|
3415
3273
|
const change = { [idField]: id2 };
|
|
3416
3274
|
let changed = false;
|
|
3417
3275
|
for (const [key, s] of nextSigs) {
|
|
@@ -3419,6 +3277,12 @@ function diffCollection(prev, next, idField) {
|
|
|
3419
3277
|
change[key] = nextRow.value[key];
|
|
3420
3278
|
changed = true;
|
|
3421
3279
|
}
|
|
3280
|
+
if (changed) {
|
|
3281
|
+
for (const [key, value] of Object.entries(nextRow.value)) {
|
|
3282
|
+
if (key in nextRow.stable || key in change) continue;
|
|
3283
|
+
if (sig(prevRow.value[key]) !== sig(value)) change[key] = value;
|
|
3284
|
+
}
|
|
3285
|
+
}
|
|
3422
3286
|
const gone = [];
|
|
3423
3287
|
for (const key of prevSigs.keys()) if (!nextSigs.has(key) && !(key in nextRow.value)) gone.push(key);
|
|
3424
3288
|
if (changed) (delta.upsert ??= []).push(change);
|
|
@@ -3427,7 +3291,7 @@ function diffCollection(prev, next, idField) {
|
|
|
3427
3291
|
for (const id2 of prevRows.keys()) {
|
|
3428
3292
|
if (!nextRows.has(id2)) (delta.removed ??= []).push(id2);
|
|
3429
3293
|
}
|
|
3430
|
-
if (!
|
|
3294
|
+
if (!sameOrder(prev?.order ?? [], next?.order ?? [])) delta.order = [...next?.order ?? []];
|
|
3431
3295
|
return Object.keys(delta).length > 0 ? delta : null;
|
|
3432
3296
|
}
|
|
3433
3297
|
function diffKeyedDoc(prev, next, spec) {
|
|
@@ -3435,15 +3299,27 @@ function diffKeyedDoc(prev, next, spec) {
|
|
|
3435
3299
|
let meaningful = false;
|
|
3436
3300
|
let set;
|
|
3437
3301
|
let unset;
|
|
3438
|
-
|
|
3439
|
-
|
|
3440
|
-
(
|
|
3441
|
-
|
|
3442
|
-
|
|
3443
|
-
|
|
3444
|
-
|
|
3445
|
-
|
|
3446
|
-
|
|
3302
|
+
const split = spec.splitObjects ?? [];
|
|
3303
|
+
const objectOf = (path) => {
|
|
3304
|
+
for (const object of split) {
|
|
3305
|
+
if (path.startsWith(`${object}.`)) return [object, path.slice(object.length + 1)];
|
|
3306
|
+
}
|
|
3307
|
+
return null;
|
|
3308
|
+
};
|
|
3309
|
+
const objects = {};
|
|
3310
|
+
for (const [path, s] of next.top) {
|
|
3311
|
+
if (prev.top.get(path) === s) continue;
|
|
3312
|
+
const inObject = objectOf(path);
|
|
3313
|
+
if (inObject) ((objects[inObject[0]] ??= {}).set ??= {})[inObject[1]] = next.topValues[path];
|
|
3314
|
+
else (set ??= {})[path] = next.topValues[path];
|
|
3315
|
+
if (!next.volatile.has(path)) meaningful = true;
|
|
3316
|
+
}
|
|
3317
|
+
for (const path of prev.top.keys()) {
|
|
3318
|
+
if (next.top.has(path)) continue;
|
|
3319
|
+
const inObject = objectOf(path);
|
|
3320
|
+
if (inObject) ((objects[inObject[0]] ??= {}).unset ??= []).push(inObject[1]);
|
|
3321
|
+
else (unset ??= []).push(path);
|
|
3322
|
+
if (!next.volatile.has(path)) meaningful = true;
|
|
3447
3323
|
}
|
|
3448
3324
|
for (const [path, idField] of Object.entries(spec.collections)) {
|
|
3449
3325
|
const change = diffCollection(prev.collections.get(path), next.collections.get(path), idField);
|
|
@@ -3454,6 +3330,7 @@ function diffKeyedDoc(prev, next, spec) {
|
|
|
3454
3330
|
if (!meaningful) return null;
|
|
3455
3331
|
if (set) delta.set = set;
|
|
3456
3332
|
if (unset) delta.unset = unset;
|
|
3333
|
+
if (Object.keys(objects).length > 0) delta.objects = objects;
|
|
3457
3334
|
return delta;
|
|
3458
3335
|
}
|
|
3459
3336
|
function foldCollection(held, change, idField) {
|
|
@@ -3496,6 +3373,12 @@ function foldKeyedDoc(held, delta, spec) {
|
|
|
3496
3373
|
const next = stripCollections(held, spec);
|
|
3497
3374
|
for (const key of delta.unset ?? []) delete next[key];
|
|
3498
3375
|
Object.assign(next, delta.set ?? {});
|
|
3376
|
+
for (const [object, change] of Object.entries(delta.objects ?? {})) {
|
|
3377
|
+
const folded = isRecord3(next[object]) ? { ...next[object] } : {};
|
|
3378
|
+
for (const key of change.unset ?? []) delete folded[key];
|
|
3379
|
+
Object.assign(folded, change.set ?? {});
|
|
3380
|
+
next[object] = folded;
|
|
3381
|
+
}
|
|
3499
3382
|
for (const [path, idField] of Object.entries(spec.collections)) {
|
|
3500
3383
|
const change = delta.collections?.[path];
|
|
3501
3384
|
const heldList = heldCollections.get(path);
|
|
@@ -3517,6 +3400,16 @@ function foldKeyedDoc(held, delta, spec) {
|
|
|
3517
3400
|
}
|
|
3518
3401
|
return next;
|
|
3519
3402
|
}
|
|
3403
|
+
var DAEMON_METADATA_DOC_SPEC = {
|
|
3404
|
+
collections: { "status.sessions": "id" },
|
|
3405
|
+
splitObjects: ["status"],
|
|
3406
|
+
ignore: ["daemonId", "status.timestamp"],
|
|
3407
|
+
stableRow: (_collection, row) => {
|
|
3408
|
+
if (!("lastUpdated" in row)) return row;
|
|
3409
|
+
const { lastUpdated: _stamp, ...stable } = row;
|
|
3410
|
+
return stable;
|
|
3411
|
+
}
|
|
3412
|
+
};
|
|
3520
3413
|
var MESH_STATUS_DOC_SPEC = {
|
|
3521
3414
|
collections: { nodes: "nodeId", "queue.tasks": "id", missions: "id" },
|
|
3522
3415
|
volatileTopLevel: [
|
|
@@ -3565,6 +3458,7 @@ export {
|
|
|
3565
3458
|
COMMIT_STRENGTHS,
|
|
3566
3459
|
CONSUME_PROFILES,
|
|
3567
3460
|
COORDINATOR_ACK_OUTCOMES,
|
|
3461
|
+
DAEMON_METADATA_DOC_SPEC,
|
|
3568
3462
|
DAEMON_P2P_SIGNAL_TYPES,
|
|
3569
3463
|
DAEMON_STATUS_EVENT_NAMES,
|
|
3570
3464
|
DAEMON_TO_DASHBOARD_P2P_TYPES,
|
|
@@ -3575,6 +3469,7 @@ export {
|
|
|
3575
3469
|
DASHBOARD_STATUS_EVENT_NAMES,
|
|
3576
3470
|
DASHBOARD_TO_DAEMON_P2P_TYPES,
|
|
3577
3471
|
DASHBOARD_TO_USER_SESSION_TYPES,
|
|
3472
|
+
DASHBOARD_WIRE_VERSION,
|
|
3578
3473
|
DEFAULT_DIFFICULTY_BRAINS,
|
|
3579
3474
|
DELIVERY_OUTCOMES,
|
|
3580
3475
|
DELIVERY_VIAS,
|
|
@@ -3648,6 +3543,7 @@ export {
|
|
|
3648
3543
|
SUSPENSION_RESOLUTION_VIAS,
|
|
3649
3544
|
SYSTEM_ANNOUNCEMENT_TYPES,
|
|
3650
3545
|
TERMINAL_CLASS_EVIDENCE_KINDS,
|
|
3546
|
+
TERMINAL_SESSION_RECORD_STATUSES,
|
|
3651
3547
|
TOOL_CALLER_ROLES,
|
|
3652
3548
|
TURN_END_BLOCK_REASONS,
|
|
3653
3549
|
TURN_END_STRENGTHS,
|
|
@@ -3675,6 +3571,7 @@ export {
|
|
|
3675
3571
|
buildSlotProposal,
|
|
3676
3572
|
canonicalDaemonId,
|
|
3677
3573
|
classifySessionStatus,
|
|
3574
|
+
compareDashboardWireVersion,
|
|
3678
3575
|
compareSemver,
|
|
3679
3576
|
daemonIdsEquivalent,
|
|
3680
3577
|
decodeActiveWorkQueryRequest,
|
|
@@ -3752,19 +3649,15 @@ export {
|
|
|
3752
3649
|
deriveSlotsFromLegacy,
|
|
3753
3650
|
describeModelSelection,
|
|
3754
3651
|
diffKeyedDoc,
|
|
3755
|
-
diffKeyedStatus,
|
|
3756
3652
|
digestKeyedDoc,
|
|
3757
|
-
digestKeyedStatus,
|
|
3758
3653
|
effectiveModelSelectionValue,
|
|
3759
3654
|
enumOf,
|
|
3760
3655
|
expandDaemonIdForms,
|
|
3761
3656
|
findOwnershipConflicts,
|
|
3762
3657
|
foldKeyedDoc,
|
|
3763
|
-
foldKeyedStatus,
|
|
3764
3658
|
formatQuotaAccount,
|
|
3765
3659
|
hasGitStatusEvidence,
|
|
3766
3660
|
hasWorkerProtocolFooter,
|
|
3767
|
-
interpolateArgs,
|
|
3768
3661
|
interpolateString,
|
|
3769
3662
|
isActiveWorkQueryRequest,
|
|
3770
3663
|
isActiveWorkQueryResponse,
|
|
@@ -3777,7 +3670,6 @@ export {
|
|
|
3777
3670
|
isDaemonStatusEventName,
|
|
3778
3671
|
isDaemonToDashboardP2PType,
|
|
3779
3672
|
isDaemonToServerType,
|
|
3780
|
-
isDaemonToServerWsMsg,
|
|
3781
3673
|
isDashboardP2PSignalType,
|
|
3782
3674
|
isDashboardStatusEventName,
|
|
3783
3675
|
isDashboardToDaemonChunkType,
|
|
@@ -3788,7 +3680,6 @@ export {
|
|
|
3788
3680
|
isDirectDispatchRecordResponse,
|
|
3789
3681
|
isDowngrade,
|
|
3790
3682
|
isEvidenceIdentifier,
|
|
3791
|
-
isEvidenceSourceId,
|
|
3792
3683
|
isFiniteNumber,
|
|
3793
3684
|
isGraphAuditEvent,
|
|
3794
3685
|
isGraphAuditRecordRequest,
|
|
@@ -3803,7 +3694,7 @@ export {
|
|
|
3803
3694
|
isGraphNodePatchResponse,
|
|
3804
3695
|
isGraphViewQueryRequest,
|
|
3805
3696
|
isGraphViewQueryResponse,
|
|
3806
|
-
|
|
3697
|
+
isIdleSessionState,
|
|
3807
3698
|
isInputEnvelopeWire,
|
|
3808
3699
|
isLedgerQueryRequest,
|
|
3809
3700
|
isLedgerQueryResponse,
|
|
@@ -3817,15 +3708,12 @@ export {
|
|
|
3817
3708
|
isMeshRecordPayload,
|
|
3818
3709
|
isMeshRecordRequest,
|
|
3819
3710
|
isMeshRecordResponse,
|
|
3820
|
-
isMeshSessionCleanupMode,
|
|
3821
3711
|
isMeshTaskDifficulty,
|
|
3822
3712
|
isMeshTaskMode,
|
|
3823
3713
|
isMeshTaskPriority,
|
|
3824
3714
|
isMeshTaskStatus,
|
|
3825
3715
|
isMeshTerminalTaskStatus,
|
|
3826
|
-
isMeshThinkingLevel,
|
|
3827
3716
|
isMeshTopicEntry,
|
|
3828
|
-
isMeshTopicEntryKind,
|
|
3829
3717
|
isMessageId,
|
|
3830
3718
|
isMissionListQueryRequest,
|
|
3831
3719
|
isMissionListQueryResponse,
|
|
@@ -3875,7 +3763,6 @@ export {
|
|
|
3875
3763
|
isSendRefusal,
|
|
3876
3764
|
isServerDirectCommandMsg,
|
|
3877
3765
|
isServerToDaemonControlType,
|
|
3878
|
-
isServerToDaemonWsMsg,
|
|
3879
3766
|
isSessionLaunchedBy,
|
|
3880
3767
|
isSessionStatus,
|
|
3881
3768
|
isSharedSessionToViewerType,
|
|
@@ -3883,7 +3770,7 @@ export {
|
|
|
3883
3770
|
isSummaryRef,
|
|
3884
3771
|
isTaskStatsQueryRequest,
|
|
3885
3772
|
isTaskStatsQueryResponse,
|
|
3886
|
-
|
|
3773
|
+
isTerminalSessionRecordStatus,
|
|
3887
3774
|
isToolCallRecordRequest,
|
|
3888
3775
|
isToolCallRecordResponse,
|
|
3889
3776
|
isToolCallerRole,
|
|
@@ -3904,7 +3791,6 @@ export {
|
|
|
3904
3791
|
isTurnReason,
|
|
3905
3792
|
isUserSessionToDashboardType,
|
|
3906
3793
|
isViewerToSharedSessionType,
|
|
3907
|
-
isWorkerBranchState,
|
|
3908
3794
|
isWorkerReportOutcome,
|
|
3909
3795
|
isWorkerTool,
|
|
3910
3796
|
isWorkingStatus,
|