@artenx/dshb 0.1.39 → 0.1.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.
Files changed (75) hide show
  1. package/lib/auth/gate.d.ts +9 -1
  2. package/lib/auth/gate.js +12 -5
  3. package/lib/auth/gate.js.map +1 -1
  4. package/lib/auth/index.js +42 -9
  5. package/lib/auth/index.js.map +1 -1
  6. package/lib/catalog-BPkswHoz.js +121 -0
  7. package/lib/catalog-BPkswHoz.js.map +1 -0
  8. package/lib/client.js +482 -45
  9. package/lib/client.js.map +1 -1
  10. package/lib/{connection-sIX25pkS.d.ts → connection-CDJM9aUw.d.ts} +10 -3
  11. package/lib/core/index.js +480 -4
  12. package/lib/core/index.js.map +1 -1
  13. package/lib/core/routes.d.ts +1 -1
  14. package/lib/core/sync/coordinator.d.ts +5 -5
  15. package/lib/core/sync/coordinator.js +39 -6
  16. package/lib/core/sync/coordinator.js.map +1 -1
  17. package/lib/core/sync/host-key.d.ts +1 -1
  18. package/lib/core/sync/internal-routes.d.ts +3 -3
  19. package/lib/core/sync/internal-routes.js +36 -3
  20. package/lib/core/sync/internal-routes.js.map +1 -1
  21. package/lib/core/sync/model.d.ts +2 -2
  22. package/lib/core/sync/model.js +62 -1
  23. package/lib/core/sync/model.js.map +1 -1
  24. package/lib/core/sync/node-sync.d.ts +1 -1
  25. package/lib/core/sync/offline-archive.d.ts +6 -4
  26. package/lib/core/sync/offline-archive.js +31 -8
  27. package/lib/core/sync/offline-archive.js.map +1 -1
  28. package/lib/core/sync/offline-routes.js +29 -3
  29. package/lib/core/sync/offline-routes.js.map +1 -1
  30. package/lib/core/sync/peer-manager.d.ts +2 -2
  31. package/lib/core/sync/peer-manager.js +2 -0
  32. package/lib/core/sync/peer-manager.js.map +1 -1
  33. package/lib/core/sync/protocol.d.ts +2 -2
  34. package/lib/core/sync/protocol.js +2 -1
  35. package/lib/core/sync/protocol.js.map +1 -1
  36. package/lib/core/sync/remote-helper.js +4 -2
  37. package/lib/core/sync/remote-helper.js.map +1 -1
  38. package/lib/core/sync/routes.d.ts +1 -1
  39. package/lib/core/sync/routes.js +26 -1
  40. package/lib/core/sync/routes.js.map +1 -1
  41. package/lib/core/sync/session-journal.d.ts +1 -1
  42. package/lib/core/sync/session-routes.d.ts +1 -1
  43. package/lib/core/sync/session-routes.js +1 -1
  44. package/lib/core/sync/session-routes.js.map +1 -1
  45. package/lib/core/sync/session-sync.d.ts +1 -1
  46. package/lib/core/sync/session-sync.js +1 -1
  47. package/lib/core/sync/ssh-transport.d.ts +1 -1
  48. package/lib/core/sync/ssh-transport.js +73 -3
  49. package/lib/core/sync/ssh-transport.js.map +1 -1
  50. package/lib/core/sync/stores.d.ts +1 -1
  51. package/lib/core/sync/stores.js +8 -2
  52. package/lib/core/sync/stores.js.map +1 -1
  53. package/lib/core/workspaces.d.ts +1 -1
  54. package/lib/exec-ssh/connection-pool.d.ts +1 -1
  55. package/lib/exec-ssh/connection.d.ts +2 -2
  56. package/lib/exec-ssh/connection.js +29 -12
  57. package/lib/exec-ssh/connection.js.map +1 -1
  58. package/lib/exec-ssh/executor.d.ts +10 -1
  59. package/lib/exec-ssh/executor.js +91 -42
  60. package/lib/exec-ssh/executor.js.map +1 -1
  61. package/lib/exec-ssh/index.d.ts +1 -1
  62. package/lib/{host-key-CSnpIrjq.d.ts → host-key-CjO13Ds4.d.ts} +2 -2
  63. package/lib/{model-CKTBf-Pl.d.ts → model-CX2TlH2E.d.ts} +70 -6
  64. package/lib/{node-sync-C3Ym-HDu.d.ts → node-sync-qnJ7u0TU.d.ts} +3 -3
  65. package/lib/{protocol-DJ0zyVlB.d.ts → protocol-DyPDIJWa.d.ts} +3 -2
  66. package/lib/selection-BABQH1Rt.js +48 -0
  67. package/lib/selection-BABQH1Rt.js.map +1 -0
  68. package/lib/{session-journal-VE_1tA2-.d.ts → session-journal-lum5L2ip.d.ts} +2 -2
  69. package/lib/{session-sync-BBCm_ou2.js → session-sync-BV1CSYic.js} +85 -2
  70. package/lib/session-sync-BV1CSYic.js.map +1 -0
  71. package/lib/{session-sync-Bw0cZ4oa.d.ts → session-sync-Be5wuYHJ.d.ts} +12 -6
  72. package/lib/{ssh-transport-COZe0BDr.d.ts → ssh-transport-Cevwfre9.d.ts} +25 -6
  73. package/lib/{stores-puyTC075.d.ts → stores-BwQLabuJ.d.ts} +2 -2
  74. package/package.json +3 -1
  75. package/lib/session-sync-BBCm_ou2.js.map +0 -1
@@ -1,4 +1,4 @@
1
- import { r as SyncImportMethod } from "./model-CKTBf-Pl.js";
1
+ import { s as SyncImportMethod } from "./model-CX2TlH2E.js";
2
2
  //#region src/core/sync/session-journal.d.ts
3
3
  declare class SyncSessionJournalStore {
4
4
  private readonly home;
@@ -43,4 +43,4 @@ declare class SyncSessionJournalStore {
43
43
  }
44
44
  //#endregion
45
45
  export { SyncSessionJournalStore as t };
46
- //# sourceMappingURL=session-journal-VE_1tA2-.d.ts.map
46
+ //# sourceMappingURL=session-journal-lum5L2ip.d.ts.map
@@ -1738,6 +1738,7 @@ var SyncSessionService = class SyncSessionService {
1738
1738
  instructions;
1739
1739
  journal;
1740
1740
  now;
1741
+ getSessionTitle;
1741
1742
  operationTail = Promise.resolve();
1742
1743
  exportCache = /* @__PURE__ */ new Map();
1743
1744
  exportCacheStore;
@@ -1747,7 +1748,7 @@ var SyncSessionService = class SyncSessionService {
1747
1748
  objectInbox;
1748
1749
  /** 工作区级指令存储:导入采纳写入,驱动该工作区新会话的指令注入。 */
1749
1750
  workspaceInstructions;
1750
- constructor(state, nodes, registry, bindings, getWorkspaces, getPersistence, getAttachments, getSpills, instructions, journal = new SyncSessionJournalStore(), now = Date.now, home, workspaceInstructions) {
1751
+ constructor(state, nodes, registry, bindings, getWorkspaces, getPersistence, getAttachments, getSpills, instructions, journal = new SyncSessionJournalStore(), now = Date.now, home, workspaceInstructions, getSessionTitle) {
1751
1752
  this.state = state;
1752
1753
  this.nodes = nodes;
1753
1754
  this.registry = registry;
@@ -1759,6 +1760,7 @@ var SyncSessionService = class SyncSessionService {
1759
1760
  this.instructions = instructions;
1760
1761
  this.journal = journal;
1761
1762
  this.now = now;
1763
+ this.getSessionTitle = getSessionTitle;
1762
1764
  this.exportCacheStore = new SyncSessionExportCacheStore(home);
1763
1765
  this.objectInbox = new SyncSessionObjectInbox(home);
1764
1766
  this.workspaceInstructions = workspaceInstructions ?? sharedWorkspaceInstructionStore();
@@ -1901,6 +1903,36 @@ var SyncSessionService = class SyncSessionService {
1901
1903
  listArchives() {
1902
1904
  return Object.values(this.state.read().archives).sort((a, b) => a.archivedAt.localeCompare(b.archivedAt));
1903
1905
  }
1906
+ exportCatalog() {
1907
+ return this.serializeMutation(async () => {
1908
+ const catalog = {
1909
+ workspaces: /* @__PURE__ */ new Map(),
1910
+ sessions: []
1911
+ };
1912
+ for (const mapping of Object.values(this.state.read().workspaces)) {
1913
+ const nodeOrigin = this.nodes.originForLocalNode(mapping.localNodeId);
1914
+ if (!nodeOrigin) continue;
1915
+ const workspace = {
1916
+ origin: {
1917
+ originInstanceId: mapping.originInstanceId,
1918
+ originEntityId: mapping.originWorkspaceId
1919
+ },
1920
+ nodeOrigin,
1921
+ remotePath: mapping.remotePath,
1922
+ title: mapping.title
1923
+ };
1924
+ catalog.workspaces.set(syncWorkspaceKey(mapping.originInstanceId, mapping.originWorkspaceId, mapping.remotePath), workspace);
1925
+ }
1926
+ await this.exportBundleNow({
1927
+ manifestOnly: true,
1928
+ catalog
1929
+ });
1930
+ return {
1931
+ workspaces: [...catalog.workspaces.values()],
1932
+ sessions: catalog.sessions
1933
+ };
1934
+ });
1935
+ }
1904
1936
  restoreArchive(branchId) {
1905
1937
  return this.serializeMutation(() => this.restoreArchiveNow(branchId));
1906
1938
  }
@@ -1981,6 +2013,43 @@ var SyncSessionService = class SyncSessionService {
1981
2013
  descriptorCache.set(key, descriptor);
1982
2014
  return descriptor;
1983
2015
  };
2016
+ const catalogWorkspacesByOrigin = /* @__PURE__ */ new Map();
2017
+ for (const workspace of options.catalog?.workspaces.values() ?? []) catalogWorkspacesByOrigin.set(JSON.stringify([workspace.origin.originInstanceId, workspace.origin.originEntityId]), workspace);
2018
+ const collectWorkspace = (descriptor) => {
2019
+ if (!options.catalog) return void 0;
2020
+ const origin = {
2021
+ originInstanceId: descriptor.originInstanceId,
2022
+ originEntityId: descriptor.originWorkspaceId
2023
+ };
2024
+ const workspace = {
2025
+ origin,
2026
+ nodeOrigin: descriptor.nodeOrigin,
2027
+ remotePath: descriptor.remotePath,
2028
+ title: descriptor.title
2029
+ };
2030
+ options.catalog.workspaces.set(syncWorkspaceKey(origin.originInstanceId, origin.originEntityId, descriptor.remotePath), workspace);
2031
+ catalogWorkspacesByOrigin.set(JSON.stringify([origin.originInstanceId, origin.originEntityId]), workspace);
2032
+ return workspace;
2033
+ };
2034
+ const collectSession = (metadata, workspace, sessionId, sizeBytes, extra = {}) => {
2035
+ if (!options.catalog) return;
2036
+ options.catalog.sessions.push({
2037
+ origin: {
2038
+ originInstanceId: metadata.originInstanceId,
2039
+ originEntityId: metadata.originEntityId
2040
+ },
2041
+ ...workspace ? {
2042
+ workspaceOrigin: workspace.origin,
2043
+ workspaceRemotePath: workspace.remotePath,
2044
+ nodeOrigin: workspace.nodeOrigin
2045
+ } : metadata.workspaceOrigin ? { workspaceOrigin: metadata.workspaceOrigin } : {},
2046
+ sessionId,
2047
+ ...extra.title ? { title: extra.title } : {},
2048
+ ...isNonNegativeSafeInteger(sizeBytes) ? { sizeBytes } : {},
2049
+ ...extra.branchId ? { branchId: extra.branchId } : {},
2050
+ ...extra.deleted ? { deleted: true } : {}
2051
+ });
2052
+ };
1984
2053
  for (const workspace of workspaces) {
1985
2054
  workspaceById.set(String(workspace.id), workspace);
1986
2055
  const binding = bindingByMirrorPath.get(workspaceCandidateKey(workspace));
@@ -1989,6 +2058,7 @@ var SyncSessionService = class SyncSessionService {
1989
2058
  if (!node || !isNodeRemoteType(node.type)) continue;
1990
2059
  const nodeOrigin = this.nodes.originForLocalNode(node.id);
1991
2060
  if (!nodeOrigin) continue;
2061
+ if (workspace.sessionIds.length > 0) collectWorkspace(getWorkspaceDescriptor(workspace, binding, nodeOrigin));
1992
2062
  for (let position = 0; position < workspace.sessionIds.length; position += 1) {
1993
2063
  const sessionId = String(workspace.sessionIds[position]);
1994
2064
  if (archivedBranchSessionIds.has(sessionId)) continue;
@@ -2000,6 +2070,7 @@ var SyncSessionService = class SyncSessionService {
2000
2070
  });
2001
2071
  if (selectedKeys && !selectedKeys.has(localKey)) continue;
2002
2072
  const descriptor = getWorkspaceDescriptor(workspace, binding, nodeOrigin, currentSession?.workspaceOrigin);
2073
+ const catalogWorkspace = collectWorkspace(descriptor);
2003
2074
  const snapshot = await persistence.stat(SessionId(sessionId));
2004
2075
  if (!snapshot) continue;
2005
2076
  if (snapshot.formatStatus === "migration-required") throw new SyncSessionError("session-format", "会话格式需要由当前 DSH 版本迁移");
@@ -2007,6 +2078,8 @@ var SyncSessionService = class SyncSessionService {
2007
2078
  const cached = await this.reuseCachedManifestEntry(persistence, workspace, descriptor, position, SessionId(sessionId), snapshot, pinnedIds.has(sessionId), currentSession, stateIndex);
2008
2079
  if (cached) {
2009
2080
  entries.push(cached);
2081
+ const title = this.getSessionTitle?.(snapshot.header);
2082
+ collectSession(cached.metadata, catalogWorkspace, sessionId, snapshot.sizeBytes, { ...title ? { title } : {} });
2010
2083
  eligibleLocalIds.add(sessionId);
2011
2084
  continue;
2012
2085
  }
@@ -2025,6 +2098,8 @@ var SyncSessionService = class SyncSessionService {
2025
2098
  }
2026
2099
  if (exported) {
2027
2100
  const { entry } = exported;
2101
+ const title = this.getSessionTitle?.(snapshot.header);
2102
+ collectSession(entry.metadata, catalogWorkspace, sessionId, snapshot.sizeBytes, { ...title ? { title } : {} });
2028
2103
  if (manifestOnly && options.payloadCache) {
2029
2104
  const key = syncSessionEntryKey(entry);
2030
2105
  const size = estimateJsonBytes(entry, MAX_MANIFEST_PAYLOAD_CACHE_BYTES - options.payloadCache.bytes);
@@ -2053,6 +2128,8 @@ var SyncSessionService = class SyncSessionService {
2053
2128
  if (selectedKeys && !selectedKeys.has(syncSessionEntryKey({ metadata }))) continue;
2054
2129
  if (metadata.deleted) {
2055
2130
  entries.push({ metadata });
2131
+ const workspaceOrigin = metadata.workspaceOrigin;
2132
+ collectSession(metadata, workspaceOrigin ? catalogWorkspacesByOrigin.get(JSON.stringify([workspaceOrigin.originInstanceId, workspaceOrigin.originEntityId])) : void 0, metadata.localEntityId, void 0, { deleted: true });
2056
2133
  const tombstoneKey = sessionExportCacheKey(metadata.localEntityId);
2057
2134
  this.exportCache.delete(tombstoneKey);
2058
2135
  this.exportCacheStore.delete(tombstoneKey);
@@ -2085,6 +2162,7 @@ var SyncSessionService = class SyncSessionService {
2085
2162
  const nodeOrigin = this.nodes.originForLocalNode(node.id);
2086
2163
  if (!nodeOrigin) continue;
2087
2164
  const descriptor = getWorkspaceDescriptor(workspace, binding, nodeOrigin, stateIndex.archivesByLocalSessionId.get(archive.localSessionId)?.workspaceOrigin);
2165
+ const catalogWorkspace = collectWorkspace(descriptor);
2088
2166
  const snapshot = await persistence.stat(SessionId(archive.localSessionId));
2089
2167
  if (!snapshot) continue;
2090
2168
  let exported;
@@ -2101,6 +2179,11 @@ var SyncSessionService = class SyncSessionService {
2101
2179
  }
2102
2180
  if (exported) {
2103
2181
  const { entry } = exported;
2182
+ const title = this.getSessionTitle?.(snapshot.header);
2183
+ collectSession(entry.metadata, catalogWorkspace, archive.localSessionId, snapshot.sizeBytes, {
2184
+ branchId: archive.branchId,
2185
+ ...title ? { title } : {}
2186
+ });
2104
2187
  if (manifestOnly && options.payloadCache) {
2105
2188
  const key = syncSessionEntryKey(entry);
2106
2189
  const size = estimateJsonBytes(entry, MAX_MANIFEST_PAYLOAD_CACHE_BYTES - options.payloadCache.bytes);
@@ -3413,4 +3496,4 @@ var SyncSessionService = class SyncSessionService {
3413
3496
  //#endregion
3414
3497
  export { estimateJsonBytes as a, planSessionTransfers as c, validateObjectPayload as d, validateSyncSessionBundle as f, SyncSessionService as i, sessionEventListDigest as l, SyncSessionError as n, makeSyncSessionBundle as o, validateSyncSessionManifest as p, SyncSessionObjectInbox as r, makeSyncSessionManifest as s, ExportObjectCache as t, syncSessionEntryKey as u };
3415
3498
 
3416
- //# sourceMappingURL=session-sync-BBCm_ou2.js.map
3499
+ //# sourceMappingURL=session-sync-BV1CSYic.js.map