@artenx/dshb 0.1.53 → 0.1.55
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/README.md +22 -7
- package/lib/auth/decorate-webserver.js +4 -4
- package/lib/auth/decorate-webserver.js.map +1 -1
- package/lib/auth/gate.d.ts +11 -3
- package/lib/auth/gate.js +14 -2
- package/lib/auth/gate.js.map +1 -1
- package/lib/auth/index.js +22 -3
- package/lib/auth/index.js.map +1 -1
- package/lib/auth/webserver.js +4 -4
- package/lib/auth/webserver.js.map +1 -1
- package/lib/{catalog-BPkswHoz.js → catalog-B6Qvy7bH.js} +8 -4
- package/lib/catalog-B6Qvy7bH.js.map +1 -0
- package/lib/client.js +421 -29
- package/lib/client.js.map +1 -1
- package/lib/core/index.js +132 -202
- package/lib/core/index.js.map +1 -1
- package/lib/core/node-registry.js +1 -1
- package/lib/core/routes.d.ts +1 -1
- package/lib/core/sync/coordinator.d.ts +5 -5
- package/lib/core/sync/coordinator.js +1 -1
- package/lib/core/sync/host-key.d.ts +1 -1
- package/lib/core/sync/internal-routes.d.ts +3 -3
- package/lib/core/sync/internal-routes.js +52 -2
- package/lib/core/sync/internal-routes.js.map +1 -1
- package/lib/core/sync/model.d.ts +1 -1
- package/lib/core/sync/model.js.map +1 -1
- package/lib/core/sync/node-sync.d.ts +1 -1
- package/lib/core/sync/offline-archive.d.ts +4 -4
- package/lib/core/sync/offline-archive.js +2 -2
- package/lib/core/sync/offline-routes.js +1 -1
- package/lib/core/sync/peer-manager.d.ts +2 -2
- package/lib/core/sync/routes.d.ts +9 -4
- package/lib/core/sync/routes.js +31 -4
- package/lib/core/sync/routes.js.map +1 -1
- package/lib/core/sync/session-journal.d.ts +1 -1
- package/lib/core/sync/session-open-routes.d.ts +32 -0
- package/lib/core/sync/session-open-routes.js +239 -0
- package/lib/core/sync/session-open-routes.js.map +1 -0
- package/lib/core/sync/session-routes.d.ts +1 -1
- package/lib/core/sync/session-routes.js +1 -1
- package/lib/core/sync/session-sync.d.ts +1 -1
- package/lib/core/sync/session-sync.js +1 -1
- package/lib/core/sync/ssh-transport.d.ts +1 -1
- package/lib/core/sync/ssh-transport.js +44 -1
- package/lib/core/sync/ssh-transport.js.map +1 -1
- package/lib/core/sync/stores.d.ts +1 -1
- package/lib/core/workspace-instruction-context.d.ts +1 -1
- package/lib/core/workspace-instructions.js +9 -1
- package/lib/core/workspace-instructions.js.map +1 -1
- package/lib/core/workspaces.d.ts +1 -1
- package/lib/{host-key-hIj6EY1x.d.ts → host-key-kbG50cnS.d.ts} +2 -2
- package/lib/{index-VF8bcBeX.d.ts → index-D6KDknUV.d.ts} +3 -309
- package/lib/{model-ByASrkzO.d.ts → model-zRfOihS3.d.ts} +4 -1
- package/lib/{node-sync-Cv1Amudy.d.ts → node-sync-Ba4yARei.d.ts} +3 -3
- package/lib/relay-auth-CtwES4Xn.js +240 -0
- package/lib/relay-auth-CtwES4Xn.js.map +1 -0
- package/lib/{session-journal-BnpGWLo2.d.ts → session-journal-BKjaO_1l.d.ts} +2 -2
- package/lib/{session-sync-Bn5ZXU8H.d.ts → session-sync-B5MCI0TW.d.ts} +31 -8
- package/lib/{session-sync-Dwz4dp4U.js → session-sync-Bsv3Qnof.js} +156 -96
- package/lib/session-sync-Bsv3Qnof.js.map +1 -0
- package/lib/{ssh-transport-CcGpOVy5.d.ts → ssh-transport-Uii7j8la.d.ts} +14 -5
- package/lib/{stores-BfruQqD-.d.ts → stores-DnyrIi4h.d.ts} +2 -2
- package/package.json +6 -2
- package/lib/catalog-BPkswHoz.js.map +0 -1
- package/lib/session-sync-Dwz4dp4U.js.map +0 -1
|
@@ -10,6 +10,7 @@ import { basename, dirname, join, normalize, posix, resolve } from "node:path";
|
|
|
10
10
|
import { createHash, randomBytes } from "node:crypto";
|
|
11
11
|
import "@deepseek-ai/cordis";
|
|
12
12
|
import { access, lstat, mkdir, open, readdir, realpath, rename, stat, unlink } from "node:fs/promises";
|
|
13
|
+
import { assertContiguous, validateStoredEvents } from "@deepseek-ai/dsh-session-persistence";
|
|
13
14
|
//#region ../../node_modules/@deepseek-ai/dsh-session/lib/index.js
|
|
14
15
|
/**
|
|
15
16
|
* Brand a string as a {@link SessionId}.
|
|
@@ -310,88 +311,6 @@ function hasProviderModel(value) {
|
|
|
310
311
|
return typeof pair["provider"] === "string" && pair["provider"].length > 0 && typeof pair["model"] === "string" && pair["model"].length > 0;
|
|
311
312
|
}
|
|
312
313
|
//#endregion
|
|
313
|
-
//#region ../../node_modules/@deepseek-ai/dsh-session-persistence/lib/index.js
|
|
314
|
-
/** Durable session contents failed validation after a successful backend read. */
|
|
315
|
-
var SessionPersistenceCorruptionError = class extends Error {
|
|
316
|
-
/**
|
|
317
|
-
* @param message - stable corruption context.
|
|
318
|
-
* @param options - original validation failure.
|
|
319
|
-
*/
|
|
320
|
-
constructor(message, options) {
|
|
321
|
-
super(message, options);
|
|
322
|
-
this.name = "SessionPersistenceCorruptionError";
|
|
323
|
-
}
|
|
324
|
-
};
|
|
325
|
-
/**
|
|
326
|
-
* The stored log is intact but this runtime cannot faithfully interpret it:
|
|
327
|
-
* the header carries an unsupported format version, or an event's type is
|
|
328
|
-
* unknown to this build. Distinct from {@link SessionPersistenceCorruptionError}
|
|
329
|
-
* — nothing is damaged; the raw log remains readable at {@link location} when
|
|
330
|
-
* the backend keeps one artifact per session.
|
|
331
|
-
*/
|
|
332
|
-
var SessionFormatUnsupportedError = class extends Error {
|
|
333
|
-
location;
|
|
334
|
-
/**
|
|
335
|
-
* @param message - stable reason the log cannot be interpreted, already
|
|
336
|
-
* including the raw-log path when one exists.
|
|
337
|
-
* @param location - the backend's artifact location, when one exists.
|
|
338
|
-
*/
|
|
339
|
-
constructor(message, location) {
|
|
340
|
-
super(message);
|
|
341
|
-
this.location = location;
|
|
342
|
-
this.name = "SessionFormatUnsupportedError";
|
|
343
|
-
}
|
|
344
|
-
};
|
|
345
|
-
/**
|
|
346
|
-
* Backend-shared storage validation: the version gate, the fail-closed event
|
|
347
|
-
* vocabulary, append-batch materialization, and contiguity — one place so
|
|
348
|
-
* every backend refuses the same inputs identically.
|
|
349
|
-
* @module @deepseek-ai/dsh-session-persistence/storage-contract
|
|
350
|
-
*/
|
|
351
|
-
/** Build a format refusal that points at the raw artifact when the backend has one. */
|
|
352
|
-
function unsupported(reason, location) {
|
|
353
|
-
return new SessionFormatUnsupportedError(location === void 0 ? reason : `${reason} (raw log: ${location.path})`, location);
|
|
354
|
-
}
|
|
355
|
-
/**
|
|
356
|
-
* Validate one exclusively owned stored event array in place: adopt each
|
|
357
|
-
* record (validating and freezing it) and refuse any event type this build
|
|
358
|
-
* does not know, unless its writer marked it `ignorable: true` — silently
|
|
359
|
-
* skipping an unknown required event could reconstruct a wrong session (the
|
|
360
|
-
* envelope contract on `SessionEvent.ignorable`). Unknown required types and
|
|
361
|
-
* retired pre-release shapes refuse here; this validator performs no migration.
|
|
362
|
-
* @param meta - the stored header the events belong to.
|
|
363
|
-
* @param events - exclusively owned decoded events; validated in place.
|
|
364
|
-
* @param location - the backend's artifact location for refusals, when one exists.
|
|
365
|
-
* @returns the same array, validated and frozen.
|
|
366
|
-
* @throws {SessionFormatUnsupportedError} for unknown event types.
|
|
367
|
-
* @throws {SessionPersistenceCorruptionError} for records that fail validation.
|
|
368
|
-
*/
|
|
369
|
-
function validateStoredEvents(meta, events, location) {
|
|
370
|
-
for (const event of events) {
|
|
371
|
-
if (!KNOWN_SESSION_EVENT_TYPES.has(event.type) && event.ignorable !== true) throw unsupported(`session "${meta.id}" contains event type "${event.type}" (seq ${event.seq}) unknown to this harness and not marked ignorable; refusing to interpret the log — it was likely written by a newer harness`, location);
|
|
372
|
-
if (event.type === "request/header") {
|
|
373
|
-
const data = event.data;
|
|
374
|
-
if (typeof data === "object" && data !== null && data["reason"] === "fallback") throw unsupported(`session "${meta.id}" contains a request/header event (seq ${event.seq}) with the unsupported legacy reason "fallback"; refusing to interpret the log — it was written by a retired pre-release harness`, location);
|
|
375
|
-
}
|
|
376
|
-
}
|
|
377
|
-
try {
|
|
378
|
-
for (const [index, event] of events.entries()) events[index] = adoptSessionEvent(event);
|
|
379
|
-
} catch (error) {
|
|
380
|
-
if (error instanceof SessionFormatUnsupportedError) throw error;
|
|
381
|
-
throw new SessionPersistenceCorruptionError(`stored session "${meta.id}" failed validation: ${String(error)}`, { cause: error });
|
|
382
|
-
}
|
|
383
|
-
return events;
|
|
384
|
-
}
|
|
385
|
-
/**
|
|
386
|
-
* Refuse a batch that does not contiguously continue the stored log.
|
|
387
|
-
* @param id - the session the batch belongs to.
|
|
388
|
-
* @param events - the batch, in seq order.
|
|
389
|
-
* @param cursor - the stored next-seq.
|
|
390
|
-
*/
|
|
391
|
-
function assertContiguous(id, events, cursor) {
|
|
392
|
-
for (const [index, event] of events.entries()) if (event.seq !== cursor + index) throw new Error(`append seq mismatch for "${id}": expected ${cursor + index} at index ${index}, got ${event.seq}`);
|
|
393
|
-
}
|
|
394
|
-
//#endregion
|
|
395
314
|
//#region src/core/sync/export-cache.ts
|
|
396
315
|
const MAX_EXPORT_CACHE_FILE_BYTES = 8388608;
|
|
397
316
|
function cacheHome(home) {
|
|
@@ -1738,7 +1657,7 @@ var SyncSessionService = class SyncSessionService {
|
|
|
1738
1657
|
instructions;
|
|
1739
1658
|
journal;
|
|
1740
1659
|
now;
|
|
1741
|
-
|
|
1660
|
+
getSessionProjection;
|
|
1742
1661
|
operationTail = Promise.resolve();
|
|
1743
1662
|
exportCache = /* @__PURE__ */ new Map();
|
|
1744
1663
|
exportCacheStore;
|
|
@@ -1748,7 +1667,7 @@ var SyncSessionService = class SyncSessionService {
|
|
|
1748
1667
|
objectInbox;
|
|
1749
1668
|
/** 工作区级指令存储:导入采纳写入,驱动该工作区新会话的指令注入。 */
|
|
1750
1669
|
workspaceInstructions;
|
|
1751
|
-
constructor(state, nodes, registry, bindings, getWorkspaces, getPersistence, getAttachments, getSpills, instructions, journal = new SyncSessionJournalStore(), now = Date.now, home, workspaceInstructions,
|
|
1670
|
+
constructor(state, nodes, registry, bindings, getWorkspaces, getPersistence, getAttachments, getSpills, instructions, journal = new SyncSessionJournalStore(), now = Date.now, home, workspaceInstructions, getSessionProjection) {
|
|
1752
1671
|
this.state = state;
|
|
1753
1672
|
this.nodes = nodes;
|
|
1754
1673
|
this.registry = registry;
|
|
@@ -1760,7 +1679,7 @@ var SyncSessionService = class SyncSessionService {
|
|
|
1760
1679
|
this.instructions = instructions;
|
|
1761
1680
|
this.journal = journal;
|
|
1762
1681
|
this.now = now;
|
|
1763
|
-
this.
|
|
1682
|
+
this.getSessionProjection = getSessionProjection;
|
|
1764
1683
|
this.exportCacheStore = new SyncSessionExportCacheStore(home);
|
|
1765
1684
|
this.objectInbox = new SyncSessionObjectInbox(home);
|
|
1766
1685
|
this.workspaceInstructions = workspaceInstructions ?? sharedWorkspaceInstructionStore();
|
|
@@ -1882,6 +1801,58 @@ var SyncSessionService = class SyncSessionService {
|
|
|
1882
1801
|
}
|
|
1883
1802
|
return discarded;
|
|
1884
1803
|
}
|
|
1804
|
+
/**
|
|
1805
|
+
* 超限会话整文件迁移后的收尾:把已落盘的本地会话挂到工作区并写 membership。
|
|
1806
|
+
* 只做 membership(不重放事件);供 open-session 的 file 迁移路径调用。
|
|
1807
|
+
*/
|
|
1808
|
+
async adoptMigratedSession(metadata, localSessionId, workspaceId, sourceName) {
|
|
1809
|
+
const registry = this.getWorkspaces();
|
|
1810
|
+
if (!registry) {
|
|
1811
|
+
this.pendingMigratedAdoptions.push({
|
|
1812
|
+
metadata,
|
|
1813
|
+
localSessionId,
|
|
1814
|
+
workspaceId,
|
|
1815
|
+
sourceName
|
|
1816
|
+
});
|
|
1817
|
+
return false;
|
|
1818
|
+
}
|
|
1819
|
+
const mapping = Object.values(this.state.read().workspaces).find((item) => item.localWorkspaceId === workspaceId);
|
|
1820
|
+
let workspace = registry.get(workspaceId);
|
|
1821
|
+
if (!workspace && mapping) workspace = registry.list().find((item) => normalize(item.path) === normalize(mapping.localPath));
|
|
1822
|
+
if (!workspace) return false;
|
|
1823
|
+
const sessionId = SessionId(localSessionId);
|
|
1824
|
+
if (!await this.requirePersistence().stat(sessionId)) throw new SyncSessionError("session-format", "迁移后的会话文件不可读");
|
|
1825
|
+
const entry = {
|
|
1826
|
+
metadata,
|
|
1827
|
+
workspace: {
|
|
1828
|
+
originInstanceId: metadata.workspaceOrigin?.originInstanceId ?? "",
|
|
1829
|
+
originWorkspaceId: metadata.workspaceOrigin?.originEntityId ?? "",
|
|
1830
|
+
remotePath: workspace.path,
|
|
1831
|
+
title: workspace.title,
|
|
1832
|
+
nodeOrigin: {
|
|
1833
|
+
originInstanceId: metadata.originInstanceId,
|
|
1834
|
+
originEntityId: ""
|
|
1835
|
+
},
|
|
1836
|
+
contentDigest: "sha256:" + "0".repeat(64)
|
|
1837
|
+
},
|
|
1838
|
+
workspacePosition: 0,
|
|
1839
|
+
archived: registry.archivedSessionIds.includes(sessionId),
|
|
1840
|
+
pinned: false,
|
|
1841
|
+
events: [],
|
|
1842
|
+
objects: []
|
|
1843
|
+
};
|
|
1844
|
+
await this.applyMembershipOnly(entry, metadata, sourceName, workspace, "peer");
|
|
1845
|
+
return true;
|
|
1846
|
+
}
|
|
1847
|
+
/** registry 注入后补挂迁移会话(由 index.ts 的 inject 回调调用)。 */
|
|
1848
|
+
pendingMigratedAdoptions = [];
|
|
1849
|
+
async flushPendingMigratedAdoptions() {
|
|
1850
|
+
const pending = this.pendingMigratedAdoptions;
|
|
1851
|
+
this.pendingMigratedAdoptions = [];
|
|
1852
|
+
for (const item of pending) try {
|
|
1853
|
+
await this.adoptMigratedSession(item.metadata, item.localSessionId, item.workspaceId, item.sourceName);
|
|
1854
|
+
} catch {}
|
|
1855
|
+
}
|
|
1885
1856
|
async recoverPending() {
|
|
1886
1857
|
const failures = [];
|
|
1887
1858
|
for (const batch of this.journal.pendingBatches()) try {
|
|
@@ -1933,6 +1904,62 @@ var SyncSessionService = class SyncSessionService {
|
|
|
1933
1904
|
};
|
|
1934
1905
|
});
|
|
1935
1906
|
}
|
|
1907
|
+
/**
|
|
1908
|
+
* Detach metadata-mode imports when their peer is removed. DSH persistence is append-only,
|
|
1909
|
+
* so imported sessions are archived (hidden from active workspaces and still recoverable)
|
|
1910
|
+
* rather than physically erased. Full-sync peers deliberately do not call this method.
|
|
1911
|
+
*/
|
|
1912
|
+
removeMetadataPeerImports(peerInstanceId, trackedLocalSessionIds = [], fallbackSourceName) {
|
|
1913
|
+
return this.serializeMutation(async () => {
|
|
1914
|
+
const registry = this.getWorkspaces();
|
|
1915
|
+
if (!registry) throw new SyncSessionError("workspace-unavailable", "工作区注册表不可用");
|
|
1916
|
+
const snapshot = this.state.read();
|
|
1917
|
+
const trackedIds = new Set(trackedLocalSessionIds);
|
|
1918
|
+
const directlyOwnedRecords = Object.entries(snapshot.records).filter(([, metadata]) => metadata.kind === "session" && metadata.importedVia === "peer" && !metadata.deleted && (trackedIds.has(metadata.localEntityId) || peerInstanceId !== void 0 && metadata.originInstanceId === peerInstanceId || fallbackSourceName !== void 0 && metadata.sourceName === fallbackSourceName));
|
|
1919
|
+
const workspaceOriginKeys = /* @__PURE__ */ new Set();
|
|
1920
|
+
for (const [, metadata] of directlyOwnedRecords) if (metadata.workspaceOrigin) workspaceOriginKeys.add(JSON.stringify([metadata.workspaceOrigin.originInstanceId, metadata.workspaceOrigin.originEntityId]));
|
|
1921
|
+
const peerWorkspaceEntries = Object.entries(snapshot.workspaces).filter(([, mapping]) => peerInstanceId !== void 0 && mapping.originInstanceId === peerInstanceId || workspaceOriginKeys.has(JSON.stringify([mapping.originInstanceId, mapping.originWorkspaceId])));
|
|
1922
|
+
for (const [, mapping] of peerWorkspaceEntries) workspaceOriginKeys.add(JSON.stringify([mapping.originInstanceId, mapping.originWorkspaceId]));
|
|
1923
|
+
const peerWorkspaceKeys = new Set(peerWorkspaceEntries.map(([key]) => key));
|
|
1924
|
+
const peerRecords = directlyOwnedRecords;
|
|
1925
|
+
const localSessionIds = new Set(peerRecords.map(([, metadata]) => metadata.localEntityId));
|
|
1926
|
+
const alreadyArchived = new Set(registry.archivedSessionIds.map(String));
|
|
1927
|
+
let sessionsArchived = 0;
|
|
1928
|
+
for (const localId of localSessionIds) {
|
|
1929
|
+
if (alreadyArchived.has(localId)) continue;
|
|
1930
|
+
await registry.archiveSession(SessionId(localId), { stopActivity: true });
|
|
1931
|
+
await registry.unpinSession?.(SessionId(localId));
|
|
1932
|
+
sessionsArchived += 1;
|
|
1933
|
+
}
|
|
1934
|
+
let workspacesRemoved = 0;
|
|
1935
|
+
let workspacesDetached = 0;
|
|
1936
|
+
const checkedWorkspaceIds = /* @__PURE__ */ new Set();
|
|
1937
|
+
for (const [, mapping] of peerWorkspaceEntries) {
|
|
1938
|
+
if (checkedWorkspaceIds.has(mapping.localWorkspaceId)) continue;
|
|
1939
|
+
checkedWorkspaceIds.add(mapping.localWorkspaceId);
|
|
1940
|
+
const workspace = registry.get(mapping.localWorkspaceId);
|
|
1941
|
+
if (!workspace) continue;
|
|
1942
|
+
if (workspace.sessionIds.every((id) => localSessionIds.has(String(id))) && typeof registry.delete === "function" && await registry.delete(workspace.id)) {
|
|
1943
|
+
this.bindings.remove(workspace.path);
|
|
1944
|
+
workspacesRemoved += 1;
|
|
1945
|
+
} else workspacesDetached += 1;
|
|
1946
|
+
}
|
|
1947
|
+
const removedRecordKeys = new Set(peerRecords.map(([key]) => key));
|
|
1948
|
+
this.state.update((draft) => {
|
|
1949
|
+
for (const key of removedRecordKeys) delete draft.records[key];
|
|
1950
|
+
for (const key of peerWorkspaceKeys) delete draft.workspaces[key];
|
|
1951
|
+
for (const [branchId, archive] of Object.entries(draft.archives)) {
|
|
1952
|
+
const workspaceMatches = archive.workspaceOrigin && workspaceOriginKeys.has(JSON.stringify([archive.workspaceOrigin.originInstanceId, archive.workspaceOrigin.originEntityId]));
|
|
1953
|
+
if (archive.originInstanceId === peerInstanceId || workspaceMatches) delete draft.archives[branchId];
|
|
1954
|
+
}
|
|
1955
|
+
});
|
|
1956
|
+
return {
|
|
1957
|
+
sessionsArchived,
|
|
1958
|
+
workspacesRemoved,
|
|
1959
|
+
workspacesDetached
|
|
1960
|
+
};
|
|
1961
|
+
});
|
|
1962
|
+
}
|
|
1936
1963
|
restoreArchive(branchId) {
|
|
1937
1964
|
return this.serializeMutation(() => this.restoreArchiveNow(branchId));
|
|
1938
1965
|
}
|
|
@@ -1990,6 +2017,11 @@ var SyncSessionService = class SyncSessionService {
|
|
|
1990
2017
|
const preservedLocalIds = /* @__PURE__ */ new Set();
|
|
1991
2018
|
const workspaceById = /* @__PURE__ */ new Map();
|
|
1992
2019
|
const archivedBranchSessionIds = new Set(Object.values(stateIndex.state.archives).map((archive) => archive.localSessionId));
|
|
2020
|
+
const archivedOriginKeys = new Set(Object.values(stateIndex.state.archives).filter((archive) => String(archive.localSessionId) !== archive.originSessionId).map((archive) => syncRecordKey("session", {
|
|
2021
|
+
originInstanceId: archive.originInstanceId,
|
|
2022
|
+
originEntityId: archive.originSessionId
|
|
2023
|
+
})));
|
|
2024
|
+
const isArchivedForCatalog = (localId, metadata) => archivedIds.has(localId) || archivedOriginKeys.has(sessionOriginKey(metadata));
|
|
1993
2025
|
const objectCache = new ExportObjectCache();
|
|
1994
2026
|
const descriptorCache = /* @__PURE__ */ new Map();
|
|
1995
2027
|
const getWorkspaceDescriptor = (workspace, binding, nodeOrigin, preferredOrigin) => {
|
|
@@ -2045,9 +2077,11 @@ var SyncSessionService = class SyncSessionService {
|
|
|
2045
2077
|
} : metadata.workspaceOrigin ? { workspaceOrigin: metadata.workspaceOrigin } : {},
|
|
2046
2078
|
sessionId,
|
|
2047
2079
|
...extra.title ? { title: extra.title } : {},
|
|
2080
|
+
...extra.blank ? { blank: true } : {},
|
|
2048
2081
|
...isNonNegativeSafeInteger(sizeBytes) ? { sizeBytes } : {},
|
|
2049
2082
|
...extra.branchId ? { branchId: extra.branchId } : {},
|
|
2050
|
-
...extra.deleted ? { deleted: true } : {}
|
|
2083
|
+
...extra.deleted ? { deleted: true } : {},
|
|
2084
|
+
...extra.archived ? { archived: true } : {}
|
|
2051
2085
|
});
|
|
2052
2086
|
};
|
|
2053
2087
|
for (const workspace of workspaces) {
|
|
@@ -2078,15 +2112,19 @@ var SyncSessionService = class SyncSessionService {
|
|
|
2078
2112
|
const cached = await this.reuseCachedManifestEntry(persistence, workspace, descriptor, position, SessionId(sessionId), snapshot, pinnedIds.has(sessionId), currentSession, stateIndex);
|
|
2079
2113
|
if (cached) {
|
|
2080
2114
|
entries.push(cached);
|
|
2081
|
-
const
|
|
2082
|
-
collectSession(cached.metadata, catalogWorkspace, sessionId, snapshot.sizeBytes, {
|
|
2115
|
+
const projection = this.getSessionProjection?.(snapshot.header);
|
|
2116
|
+
collectSession(cached.metadata, catalogWorkspace, sessionId, snapshot.sizeBytes, {
|
|
2117
|
+
...projection?.title ? { title: projection.title } : {},
|
|
2118
|
+
...projection?.blank ? { blank: true } : {},
|
|
2119
|
+
...isArchivedForCatalog(sessionId, cached.metadata) ? { archived: true } : {}
|
|
2120
|
+
});
|
|
2083
2121
|
eligibleLocalIds.add(sessionId);
|
|
2084
2122
|
continue;
|
|
2085
2123
|
}
|
|
2086
2124
|
}
|
|
2087
2125
|
let exported;
|
|
2088
2126
|
try {
|
|
2089
|
-
exported = await this.exportSessionEntry(persistence, workspace, descriptor, position, SessionId(sessionId), snapshot, archivedIds.has(sessionId), pinnedIds.has(sessionId), void 0, stateIndex, objectCache, options.deferredObjects === true);
|
|
2127
|
+
exported = await this.exportSessionEntry(persistence, workspace, descriptor, position, SessionId(sessionId), snapshot, archivedIds.has(sessionId), pinnedIds.has(sessionId), void 0, stateIndex, objectCache, options.deferredObjects === true, manifestOnly);
|
|
2090
2128
|
} catch (error) {
|
|
2091
2129
|
if (!(error instanceof SyncSessionError && error.code === "session-too-large")) throw error;
|
|
2092
2130
|
skipped.push({
|
|
@@ -2094,12 +2132,32 @@ var SyncSessionService = class SyncSessionService {
|
|
|
2094
2132
|
reason: "session-payload-too-large"
|
|
2095
2133
|
});
|
|
2096
2134
|
preservedLocalIds.add(sessionId);
|
|
2135
|
+
if (options.catalog || manifestOnly) {
|
|
2136
|
+
const projection = this.getSessionProjection?.(snapshot.header);
|
|
2137
|
+
const archivedForCatalog = archivedIds.has(sessionId) || currentSession !== void 0 && archivedOriginKeys.has(sessionOriginKey(currentSession));
|
|
2138
|
+
if (manifestOnly) entries.push({ metadata: currentSession ?? {
|
|
2139
|
+
originInstanceId: instanceId,
|
|
2140
|
+
originEntityId: sessionId
|
|
2141
|
+
} });
|
|
2142
|
+
if (options.catalog) collectSession(currentSession ?? {
|
|
2143
|
+
originInstanceId: instanceId,
|
|
2144
|
+
originEntityId: sessionId
|
|
2145
|
+
}, catalogWorkspace, sessionId, snapshot.sizeBytes, {
|
|
2146
|
+
...projection?.title ? { title: projection.title } : {},
|
|
2147
|
+
...projection?.blank ? { blank: true } : {},
|
|
2148
|
+
...archivedForCatalog ? { archived: true } : {}
|
|
2149
|
+
});
|
|
2150
|
+
}
|
|
2097
2151
|
continue;
|
|
2098
2152
|
}
|
|
2099
2153
|
if (exported) {
|
|
2100
2154
|
const { entry } = exported;
|
|
2101
|
-
const
|
|
2102
|
-
collectSession(entry.metadata, catalogWorkspace, sessionId, snapshot.sizeBytes, {
|
|
2155
|
+
const projection = this.getSessionProjection?.(snapshot.header);
|
|
2156
|
+
collectSession(entry.metadata, catalogWorkspace, sessionId, snapshot.sizeBytes, {
|
|
2157
|
+
...projection?.title ? { title: projection.title } : {},
|
|
2158
|
+
...projection?.blank ? { blank: true } : {},
|
|
2159
|
+
...isArchivedForCatalog(sessionId, entry.metadata) ? { archived: true } : {}
|
|
2160
|
+
});
|
|
2103
2161
|
if (manifestOnly && options.payloadCache) {
|
|
2104
2162
|
const key = syncSessionEntryKey(entry);
|
|
2105
2163
|
const size = estimateJsonBytes(entry, MAX_MANIFEST_PAYLOAD_CACHE_BYTES - options.payloadCache.bytes);
|
|
@@ -2179,10 +2237,11 @@ var SyncSessionService = class SyncSessionService {
|
|
|
2179
2237
|
}
|
|
2180
2238
|
if (exported) {
|
|
2181
2239
|
const { entry } = exported;
|
|
2182
|
-
const
|
|
2240
|
+
const projection = this.getSessionProjection?.(snapshot.header);
|
|
2183
2241
|
collectSession(entry.metadata, catalogWorkspace, archive.localSessionId, snapshot.sizeBytes, {
|
|
2184
2242
|
branchId: archive.branchId,
|
|
2185
|
-
|
|
2243
|
+
archived: true,
|
|
2244
|
+
...projection?.title ? { title: projection.title } : {}
|
|
2186
2245
|
});
|
|
2187
2246
|
if (manifestOnly && options.payloadCache) {
|
|
2188
2247
|
const key = syncSessionEntryKey(entry);
|
|
@@ -2433,7 +2492,8 @@ var SyncSessionService = class SyncSessionService {
|
|
|
2433
2492
|
}
|
|
2434
2493
|
}
|
|
2435
2494
|
const objectMap = await this.importObjects(entry.objects, sessionId, attachmentImportCache, inboxConsumed);
|
|
2436
|
-
const
|
|
2495
|
+
const events = this.rewriteEvents(entry.events, entry.objects, objectMap, sessionId, String(entry.header.id));
|
|
2496
|
+
const validatedEvents = validateStoredEvents(header, events);
|
|
2437
2497
|
assertContiguous(sessionId, validatedEvents, 0);
|
|
2438
2498
|
const instructionWorkspaceId = entry.instructionSnapshot?.workspaceOrigin ? this.localWorkspaceIdForOrigin(entry.instructionSnapshot.workspaceOrigin, entry.instructionSnapshot.workspaceRemotePath) : void 0;
|
|
2439
2499
|
const instructionSnapshot = entry.instructionSnapshot ? {
|
|
@@ -3043,7 +3103,7 @@ var SyncSessionService = class SyncSessionService {
|
|
|
3043
3103
|
contentDigest: digest
|
|
3044
3104
|
};
|
|
3045
3105
|
}
|
|
3046
|
-
async exportSessionEntry(persistence, workspace, descriptor, workspacePosition, sessionId, firstSnapshot, archived, pinned, archive, stateIndex, objectCache, deferredObjects = false) {
|
|
3106
|
+
async exportSessionEntry(persistence, workspace, descriptor, workspacePosition, sessionId, firstSnapshot, archived, pinned, archive, stateIndex, objectCache, deferredObjects = false, manifestOnly = false) {
|
|
3047
3107
|
const { header, inheritedEventCount, events, revision: sourceRevision } = await this.readStableSession(persistence, sessionId, firstSnapshot);
|
|
3048
3108
|
const localSessionId = String(sessionId);
|
|
3049
3109
|
const cacheKey = sessionExportCacheKey(localSessionId);
|
|
@@ -3496,4 +3556,4 @@ var SyncSessionService = class SyncSessionService {
|
|
|
3496
3556
|
//#endregion
|
|
3497
3557
|
export { estimateJsonBytes as a, planSessionTransfers as c, sessionStateDigest as d, syncSessionEntryKey as f, workspaceDigest as g, validateSyncSessionManifest as h, SyncSessionService as i, sessionEventDigest as l, validateSyncSessionBundle as m, SyncSessionError as n, makeSyncSessionBundle as o, validateObjectPayload as p, SyncSessionObjectInbox as r, makeSyncSessionManifest as s, ExportObjectCache as t, sessionEventListDigest as u };
|
|
3498
3558
|
|
|
3499
|
-
//# sourceMappingURL=session-sync-
|
|
3559
|
+
//# sourceMappingURL=session-sync-Bsv3Qnof.js.map
|