mcard-studio 0.0.1 → 0.0.3

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 (212) hide show
  1. package/README.md +3 -0
  2. package/astro.config.mjs +46 -2
  3. package/bin/mcard-studio.mjs +1 -1
  4. package/cli/lib/runtimeContext.mjs +6 -3
  5. package/dist/client/_astro/{ChartAnalyticsViewlet.Cevj0EOs.js → ChartAnalyticsViewlet.CBW-JyA3.js} +1 -1
  6. package/dist/client/_astro/ClmPcardViewlet.cvKsR2ng.js +3 -0
  7. package/dist/client/_astro/D3GraphViewlet.8YEIrCGL.js +2 -0
  8. package/dist/client/_astro/DockviewSpatialWorkbench.BTd66LPl.js +12 -0
  9. package/dist/client/_astro/DocumentViewlets.KY1HcNka.js +2 -0
  10. package/dist/client/_astro/DxfViewlet.B3N5zpZR.js +1 -0
  11. package/dist/client/_astro/ExcalidrawWhiteboardViewlet.CMJGCQN4.js +1 -0
  12. package/dist/client/_astro/{FaroVCardSpanInstrumenter.BIk2NhJY.js → FaroVCardSpanInstrumenter.ClIqZujq.js} +1 -1
  13. package/dist/client/_astro/{FontSpecimenViewlet.CpONhJh0.js → FontSpecimenViewlet.ChIyr0B8.js} +1 -1
  14. package/dist/client/_astro/HeadMeta.astro_astro_type_script_index_0_lang.D3FSc061.js +1 -0
  15. package/dist/client/_astro/{ImageViewlet.CHeNvX6L.js → ImageViewlet.Cs-u7-wt.js} +1 -1
  16. package/dist/client/_astro/{KatexFormulaViewlet.Cy_InWOK.js → KatexFormulaViewlet.0nOzV_qD.js} +1 -1
  17. package/dist/client/_astro/KoishiChatViewlet.DLsMmwdb.js +16 -0
  18. package/dist/client/_astro/MCardLibraryHarness.WBT9W10S.js +2 -0
  19. package/dist/client/_astro/{MarkdownViewlet.qoPlM-TZ.js → MarkdownViewlet.BIolkNXf.js} +25 -25
  20. package/dist/client/_astro/{MermaidDiagramViewlet.RnwDfQl6.js → MermaidDiagramViewlet.CkRk7QsS.js} +1 -1
  21. package/dist/client/_astro/PCardRendererBridge.DhaRSprd.js +1 -0
  22. package/dist/client/_astro/RendererPCardRegistry.brM2KiQs.js +1 -0
  23. package/dist/client/_astro/{SchemaYamlViewlet.D6HVdmrq.js → SchemaYamlViewlet.Bc7nkK4M.js} +1 -1
  24. package/dist/client/_astro/{ShellContainer.astro_astro_type_script_index_0_lang.2oi8fhQo.js → ShellContainer.astro_astro_type_script_index_0_lang.5q1gCLvf.js} +1 -1
  25. package/dist/client/_astro/{Spatial3dViewlet.CCYBSSib.js → Spatial3dViewlet.C-jjhr0A.js} +1 -1
  26. package/dist/client/_astro/{StudioLayout.CBgiVbeb.css → StudioLayout.CX8XGtZV.css} +1 -1
  27. package/dist/client/_astro/StudioWorkbench.B1QwGHWM.js +7 -0
  28. package/dist/client/_astro/{SvgViewlet.BxlWQ-JX.js → SvgViewlet.uGxvb06H.js} +1 -1
  29. package/dist/client/_astro/{TerminalView.DWZR-hUa.js → TerminalView.DP7G7E1m.js} +4 -4
  30. package/dist/client/_astro/{ThemeSettingsViewlet.Cb1r8fWw.js → ThemeSettingsViewlet.UaTHcGnF.js} +1 -1
  31. package/dist/client/_astro/{TikzDiagramViewlet.CqY7VTeP.js → TikzDiagramViewlet.O8MJyXfT.js} +1 -1
  32. package/dist/client/_astro/VideoPlayerViewlet.-ycmo3kY.js +1 -0
  33. package/dist/client/_astro/WebappZenViewlet.PNce4u2T.js +1 -0
  34. package/dist/client/_astro/{WelcomeViewport.LwKTA6h7.js → WelcomeViewport.CZ6RxGSw.js} +1 -1
  35. package/dist/client/_astro/{agentIdentityCredentialService.BtKVsl2C.js → agentIdentityCredentialService.BEtZzBlO.js} +5 -5
  36. package/dist/client/_astro/cardTypeDetector.C2HH5RnU.js +1 -0
  37. package/dist/client/_astro/disposable.BmlxZrDf.js +1 -0
  38. package/dist/client/_astro/{markdownService.D-tM2RYx.js → markdownService.CpuKl0vp.js} +1 -1
  39. package/dist/client/_astro/{mcardStore.BiAvqM-D.js → mcardStore.nSWnzeLg.js} +2 -2
  40. package/dist/client/_astro/mcardVfs.BSdys1Y7.js +3 -0
  41. package/dist/client/_astro/pathsConfig.CSBBSzwH.js +2 -0
  42. package/dist/client/_astro/polyfills.Bi7kO8cu.js +1 -0
  43. package/dist/client/_astro/rendererEventBus.DirFDmGw.js +1 -0
  44. package/dist/client/_astro/themeStore.BajxvCga.js +1 -0
  45. package/dist/client/_astro/{tikzCompiler.DFojjdxR.js → tikzCompiler.-fXMNQpz.js} +1 -1
  46. package/dist/client/_astro/{useMCardHydration.Co47OH3D.js → useMCardHydration.Bjj_N5Gv.js} +1 -1
  47. package/dist/client/_astro/vendor-ai.D6NcJ6lu.js +69 -0
  48. package/dist/client/_astro/vendor-clm-kernel.B0kxq3g4.js +108 -0
  49. package/dist/client/_astro/vfsHandles.D4Pq18pW.js +1 -0
  50. package/dist/client/_astro/vfsPersistence.DVrd1BZj.js +1 -0
  51. package/dist/client/_astro/vfsTransactions.DBNtFuRz.js +1 -0
  52. package/dist/client/_astro/{workspaceStore.CXakha4Y.js → workspaceStore.DUHW2YBc.js} +1 -1
  53. package/dist/client/js/buffer-polyfill.js +14 -0
  54. package/dist/server/chunks/{StudioLayout_D163irJ0.mjs → StudioLayout_taayQJ5b.mjs} +2 -2
  55. package/dist/server/chunks/{_.._ZXsz792-.mjs → _.._CoQKwo62.mjs} +137 -91
  56. package/dist/server/chunks/{_handle__D_cIJYrU.mjs → _handle__D8dKQPUS.mjs} +3 -3
  57. package/dist/server/chunks/{cardTypeDetector_CyW1Xnmy.mjs → cardTypeDetector_C55M_HWS.mjs} +9 -0
  58. package/dist/server/chunks/{cards_B89BvF6W.mjs → cards_rVOc8K6H.mjs} +2 -2
  59. package/dist/server/chunks/cas_DTxlZ4Le.mjs +68 -0
  60. package/dist/server/chunks/{dispatch_DOwSKukU.mjs → dispatch_BTW4E_BJ.mjs} +8 -7
  61. package/dist/server/chunks/{dispatch_CxWKiHpn.mjs → dispatch_MbkljUxD.mjs} +8 -8
  62. package/dist/server/chunks/{export_DRouradA.mjs → export_DkEwDE2T.mjs} +3 -3
  63. package/dist/server/chunks/{health_Dfa5I0-X.mjs → health_cRt0M0yu.mjs} +1 -1
  64. package/dist/server/chunks/{mcard-library_DvPPUs9_.mjs → mcard-library_CLHvyslV.mjs} +1 -1
  65. package/dist/server/chunks/{mcardVfs_CeezzRvt.mjs → mcardVfs_DvNburKb.mjs} +5 -30
  66. package/dist/server/chunks/{move__RFvIDkq.mjs → move_DYcaXBLV.mjs} +6 -6
  67. package/dist/server/chunks/{pathsConfig_CgNYYLVm.mjs → pathsConfig_Dack-p2f.mjs} +13 -3
  68. package/dist/server/chunks/{proxy_CrWJQIBe.mjs → proxy_CMbbdBPW.mjs} +2 -2
  69. package/dist/server/chunks/{raw_DzNDaDVP.mjs → raw_C97sJWhg.mjs} +59 -26
  70. package/dist/server/chunks/{serverBootstrap_XKo2s6Ha.mjs → serverBootstrap_BDdSRIu5.mjs} +2 -2
  71. package/dist/server/chunks/tree_BwmO-pTe.mjs +186 -0
  72. package/dist/server/chunks/vfsCore_DIKpk-pk.mjs +98 -0
  73. package/dist/server/chunks/{vfsTreeScan_CKp7kMt9.mjs → vfsTreeScan_CRoCluPB.mjs} +18 -10
  74. package/dist/server/chunks/workspaceRoot_CRx3taID.mjs +157 -0
  75. package/dist/server/chunks/{write_popiFsO7.mjs → write_BLsmsTIx.mjs} +6 -5
  76. package/dist/server/chunks/{ws-server-init_CkcgcI5V.mjs → ws-server-init_Cfft7U5u.mjs} +343 -298
  77. package/dist/server/entry.mjs +8 -4
  78. package/dist/server/entry2.mjs +67 -28
  79. package/dist/server/virtual_astro_middleware.mjs +2 -2
  80. package/package.json +2 -2
  81. package/public/js/buffer-polyfill.js +14 -0
  82. package/src/components/studio/views/cardViewlets/ClmRegistryComponentViewlet.tsx +133 -0
  83. package/src/components/studio/views/cardViewlets/DxfViewlet.tsx +230 -0
  84. package/src/components/studio/views/cardViewlets/VideoPlayerViewlet.tsx +4 -4
  85. package/src/components/studio/views/cardViewlets/coreViewletDefs.ts +2 -2
  86. package/src/components/studio/views/cardViewlets/documents/AudioPlayerViewlet.tsx +15 -3
  87. package/src/components/studio/views/cardViewlets/documents/PdfViewlet.tsx +25 -7
  88. package/src/components/studio/views/cardViewlets/markdown/stages/wikilinkStage.ts +2 -1
  89. package/src/components/studio/views/cardViewlets/mediaViewletDefs.ts +21 -1
  90. package/src/components/studio/views/cardViewlets/webapp/WebappCanvas.tsx +40 -15
  91. package/src/components/studio/views/cardViewlets/webapp/WebappDevicePresetBar.tsx +108 -0
  92. package/src/components/studio/views/cardViewlets/webapp/WebappZenViewlet.tsx +23 -30
  93. package/src/components/studio/views/fileTree/MCardFileTree.tsx +71 -54
  94. package/src/components/studio/views/fileTree/hooks/useFileTreeSync.ts +0 -1
  95. package/src/components/studio/views/fileTree/hooks/usePartitionedTrees.ts +68 -23
  96. package/src/components/studio/views/fileTree/hooks/useSectionAccordion.ts +21 -11
  97. package/src/components/studio/views/functions/UnifiedFunctionExplorerViewlet.tsx +168 -0
  98. package/src/components/studio/views/history/HistoryPanel.tsx +110 -0
  99. package/src/components/studio/views/lineage/LineagePanel.tsx +152 -0
  100. package/src/components/studio/views/navigation/HandleLineageDrawer.tsx +89 -0
  101. package/src/components/studio/views/navigation/MultiCardCollectionBrowser.tsx +154 -0
  102. package/src/components/studio/views/pills/HashPill.tsx +101 -0
  103. package/src/components/studio/views/residency/ResidencyIndicator.tsx +82 -0
  104. package/src/config/app_config.json +3 -3
  105. package/src/core/projection/catalog.ts +105 -0
  106. package/src/core/projection/collection.ts +148 -0
  107. package/src/core/projection/handleSubscription.ts +132 -0
  108. package/src/core/projection/index.ts +4 -0
  109. package/src/core/projection/selectors.ts +29 -0
  110. package/src/core/projection/views.ts +242 -0
  111. package/src/core/refinement/designMetrics.ts +104 -0
  112. package/src/core/refinement/fibrationProjector.ts +142 -0
  113. package/src/core/refinement/lagrangianEngine.ts +137 -0
  114. package/src/core/refinement/refinementCommands.ts +82 -0
  115. package/src/core/viewport/deviceArchetypeRegistry.ts +177 -0
  116. package/src/core/viewport/viewportAudit.ts +150 -0
  117. package/src/edge/storeFilter.d.ts +4 -0
  118. package/src/edge/storeFilter.js +54 -0
  119. package/src/edge/storeFilter.ts +52 -0
  120. package/src/layouts/StudioLayout.astro +1 -0
  121. package/src/lib/cryptoPolyfill.js +77 -1
  122. package/src/lib/fsPolyfill.js +65 -0
  123. package/src/lib/urlPolyfill.js +21 -0
  124. package/src/lib/zlibPolyfill.js +35 -0
  125. package/src/packages/mcard-studio/package.json +2 -2
  126. package/src/packages/mcard-studio/type/legacyMapping.ts +5 -0
  127. package/src/packages/mcard-studio/viewlets/manifests.ts +2 -0
  128. package/src/packages/mcard-studio/viewlets/moduleMap.ts +12 -0
  129. package/src/packages/mcard-studio/viewlets/refinementManifests.ts +114 -0
  130. package/src/pages/api/dispatch.ts +3 -2
  131. package/src/pages/api/vfs/cas.ts +114 -0
  132. package/src/pages/api/vfs/move.ts +5 -5
  133. package/src/pages/api/vfs/raw.ts +72 -27
  134. package/src/pages/api/vfs/tree.ts +130 -11
  135. package/src/pages/api/vfs/write.ts +5 -4
  136. package/src/pages/index.astro +75 -0
  137. package/src/server/api/kernelDispatch.ts +8 -8
  138. package/src/server/artifactCollectionService.ts +4 -7
  139. package/src/server/artifactRepository.ts +4 -3
  140. package/src/server/clmRunner.mjs +1 -1
  141. package/src/server/collectionOwner.mjs +5 -5
  142. package/src/server/effects/executionPersistenceService.mjs +11 -11
  143. package/src/server/effects/resultSealingService.mjs +2 -2
  144. package/src/server/fileIngestService.mjs +21 -9
  145. package/src/server/fileWatcherService.mjs +4 -1
  146. package/src/server/handlers/fileChangeHandler.mjs +18 -10
  147. package/src/server/handlers/saveExecutionLogHandler.mjs +6 -6
  148. package/src/server/notificationService.mjs +14 -1
  149. package/src/server/scripts/buildSeedingMemory.mjs +3 -3
  150. package/src/server/serverMemoryRepository.ts +41 -59
  151. package/src/server/vfsTreeScan.ts +16 -10
  152. package/src/server/workspaceRoot.ts +143 -5
  153. package/src/services/cardTypeDetector.ts +4 -0
  154. package/src/services/databaseSyncService.ts +30 -46
  155. package/src/services/inBrowserLlm/engines/litertEngine.ts +1 -1
  156. package/src/services/namespaceProtocolClient.ts +221 -0
  157. package/src/services/renderers/pcard/RendererPCardRegistry.ts +4 -66
  158. package/src/services/renderers/pcard/modalitySpecs.ts +125 -0
  159. package/src/services/renderers/pcard/types.ts +7 -1
  160. package/src/services/renderers/rendererEventBus.ts +5 -3
  161. package/src/services/unifiedFunctionExecutionService.ts +145 -0
  162. package/src/services/vfs/vfsCore.ts +12 -1
  163. package/src/services/vfs/vfsMigration.ts +95 -0
  164. package/src/services/vfs/vfsMutations.ts +17 -35
  165. package/src/services/vfs/vfsPersistence.ts +19 -24
  166. package/src/services/vfs/vfsSync.ts +55 -17
  167. package/src/services/vfs/vfsVersions.ts +23 -34
  168. package/src/services/workbenchExecutionPolicy.ts +183 -0
  169. package/src/stores/mcardCollectionStore.ts +2 -0
  170. package/src/styles/dockview.css +34 -0
  171. package/src/ui/viewlets/FibrationRefinementViewlet.tsx +155 -0
  172. package/src/ui/viewlets/PetriConformanceViewlet.tsx +166 -0
  173. package/src/ui/viewlets/ResponsiveViewportLabViewlet.tsx +175 -0
  174. package/src/ui/viewlets/SprintGovernanceViewlet.tsx +176 -0
  175. package/src/ui/viewlets/viewletFocus.ts +35 -0
  176. package/src/ui/viewlets/viewportLabParts.tsx +190 -0
  177. package/dist/client/_astro/ClmPcardViewlet.DW5Yft0E.js +0 -3
  178. package/dist/client/_astro/D3GraphViewlet.DAjPz1DP.js +0 -2
  179. package/dist/client/_astro/DockviewSpatialWorkbench.DyQjSoHd.js +0 -12
  180. package/dist/client/_astro/DocumentViewlets.Dm_GL3AL.js +0 -2
  181. package/dist/client/_astro/ExcalidrawWhiteboardViewlet.DrlW7B6G.js +0 -1
  182. package/dist/client/_astro/HeadMeta.astro_astro_type_script_index_0_lang.DGXU-3Lu.js +0 -1
  183. package/dist/client/_astro/KoishiChatViewlet.B0eDEMnT.js +0 -16
  184. package/dist/client/_astro/MCardLibraryHarness.CUJLJFBt.js +0 -2
  185. package/dist/client/_astro/PCardRendererBridge.BnyaE05I.js +0 -1
  186. package/dist/client/_astro/RendererPCardRegistry.CLr4j1Ub.js +0 -1
  187. package/dist/client/_astro/StudioWorkbench.CF0SOYwy.js +0 -7
  188. package/dist/client/_astro/VideoPlayerViewlet.DoSYmmoQ.js +0 -1
  189. package/dist/client/_astro/WebappZenViewlet.CQW50OhX.js +0 -1
  190. package/dist/client/_astro/cardTypeDetector.C9kGObMh.js +0 -1
  191. package/dist/client/_astro/disposable.66apX1Q2.js +0 -1
  192. package/dist/client/_astro/empty.DOwCrGXH.js +0 -1
  193. package/dist/client/_astro/mcardVfs.Bj-RA0p7.js +0 -2
  194. package/dist/client/_astro/path.CR60mj9W.js +0 -1
  195. package/dist/client/_astro/pathsConfig.D0hV34p7.js +0 -2
  196. package/dist/client/_astro/polyfills.DcBkS56X.js +0 -1
  197. package/dist/client/_astro/rendererEventBus.CyFnSRLk.js +0 -1
  198. package/dist/client/_astro/themeStore.zUMFLo3Q.js +0 -1
  199. package/dist/client/_astro/vendor-ai.CZe7UVVK.js +0 -69
  200. package/dist/client/_astro/vfsHandles.B-nczBRy.js +0 -1
  201. package/dist/client/_astro/vfsPersistence.D6zRzVML.js +0 -1
  202. package/dist/client/_astro/vfsTransactions.04mkEHxD.js +0 -1
  203. package/dist/server/chunks/cryptoPolyfill_99rxUwYC.mjs +0 -180
  204. package/dist/server/chunks/kernelHash_DRaj51hY.mjs +0 -5
  205. package/dist/server/chunks/tree_CE2BhvyJ.mjs +0 -76
  206. package/dist/server/chunks/vfsCore_B6nCiBl5.mjs +0 -21
  207. package/dist/server/chunks/workspaceRoot_DVSUbYkd.mjs +0 -71
  208. package/src/server/kernelHash.ts +0 -22
  209. package/src/server/storage/cardCollection.ts +0 -94
  210. package/src/server/storage/index.ts +0 -3
  211. package/src/server/storage/mcard.ts +0 -99
  212. package/src/server/storage/sqliteNodeEngine.ts +0 -121
@@ -1,7 +1,7 @@
1
1
  import { t as __exportAll } from "./rolldown-runtime_8H4AJuhK.mjs";
2
2
  import { f as renderTemplate, o as renderComponent } from "./server_DQgO1z9H.mjs";
3
3
  import { t as createComponent } from "./compiler_jjPF-nBO.mjs";
4
- import { t as $$StudioLayout } from "./StudioLayout_D163irJ0.mjs";
4
+ import { t as $$StudioLayout } from "./StudioLayout_taayQJ5b.mjs";
5
5
  //#region src/pages/mcard-library.astro
6
6
  var mcard_library_exports = /* @__PURE__ */ __exportAll({
7
7
  default: () => $$McardLibrary,
@@ -1,6 +1,6 @@
1
- import { n as getWhitelistedDirectoryProjections, t as PATHS } from "./pathsConfig_CgNYYLVm.mjs";
2
- import { t as studioMCardFs } from "./vfsCore_B6nCiBl5.mjs";
3
- import "./cardTypeDetector_CyW1Xnmy.mjs";
1
+ import { n as getWhitelistedDirectoryProjections, t as PATHS } from "./pathsConfig_Dack-p2f.mjs";
2
+ import { a as STORE_HISTORY, c as openMigrationIndexedDb, i as STORE_HANDLES, o as STORE_LEGACY, r as STORE_CAS, s as STORE_SNAPSHOTS, t as studioMCardFs } from "./vfsCore_DIKpk-pk.mjs";
3
+ import "./cardTypeDetector_C55M_HWS.mjs";
4
4
  import "clm-kernel";
5
5
  import { atom, computed, map } from "nanostores";
6
6
  import { initializeFaro } from "@grafana/faro-web-sdk";
@@ -417,39 +417,13 @@ var PersistenceFlushScheduler = class {
417
417
  * Contract D budget: <= 250 LOC
418
418
  */
419
419
  var WS_DIR$1 = PATHS.paths.workspace_dirname;
420
- var DB_NAME = "clm_workbench_db";
421
- var DB_VERSION = 2;
422
- var STORE_CAS = "clm_cas_blobs";
423
- var STORE_HANDLES = "clm_handle_registry";
424
- var STORE_HISTORY = "clm_handle_history";
425
- var STORE_SNAPSHOTS = "clm_sqlite_snapshots";
426
- var STORE_LEGACY = "clm_content_memory_db";
427
- function openIndexedDb() {
428
- return new Promise((resolve, reject) => {
429
- if (typeof window === "undefined" || !window.indexedDB) return reject(/* @__PURE__ */ new Error("IndexedDB not available"));
430
- const req = window.indexedDB.open(DB_NAME, DB_VERSION);
431
- req.onupgradeneeded = () => {
432
- const db = req.result;
433
- if (!db.objectStoreNames.contains("clm_cas_blobs")) db.createObjectStore(STORE_CAS, { keyPath: "hash" });
434
- if (!db.objectStoreNames.contains("clm_handle_registry")) db.createObjectStore(STORE_HANDLES, { keyPath: "handle" });
435
- if (!db.objectStoreNames.contains("clm_handle_history")) db.createObjectStore(STORE_HISTORY, {
436
- keyPath: "id",
437
- autoIncrement: true
438
- });
439
- if (!db.objectStoreNames.contains("clm_sqlite_snapshots")) db.createObjectStore(STORE_SNAPSHOTS, { keyPath: "id" });
440
- if (!db.objectStoreNames.contains(STORE_LEGACY)) db.createObjectStore(STORE_LEGACY);
441
- };
442
- req.onsuccess = () => resolve(req.result);
443
- req.onerror = () => reject(req.error);
444
- });
445
- }
446
420
  async function performPersistenceFlush() {
447
421
  if (typeof window === "undefined" || !window.indexedDB) return;
448
422
  const tree = $mcardTree.get();
449
423
  const entries = Object.values(tree);
450
424
  const prefix = `${WS_DIR$1}:`;
451
425
  const wsEntries = entries.filter((n) => n.handle.startsWith(prefix) || n.scope === WS_DIR$1 || n.path.startsWith(`${WS_DIR$1}/`));
452
- const tx = (await openIndexedDb()).transaction([
426
+ const tx = (await openMigrationIndexedDb()).transaction([
453
427
  STORE_CAS,
454
428
  STORE_HANDLES,
455
429
  STORE_HISTORY,
@@ -458,6 +432,7 @@ async function performPersistenceFlush() {
458
432
  ], "readwrite");
459
433
  const casStore = tx.objectStore(STORE_CAS);
460
434
  const handleStore = tx.objectStore(STORE_HANDLES);
435
+ handleStore.clear();
461
436
  for (const n of wsEntries) {
462
437
  if (n.hash && n.content !== void 0) casStore.put({
463
438
  hash: n.hash,
@@ -1,9 +1,9 @@
1
1
  import { t as __exportAll } from "./rolldown-runtime_8H4AJuhK.mjs";
2
- import { n as isPathWritable, r as repoRoot } from "./workspaceRoot_DVSUbYkd.mjs";
2
+ import { a as resolveHostPath, i as repoRoot, r as isPathWritable } from "./workspaceRoot_CRx3taID.mjs";
3
3
  import { r as json, t as error } from "./apiUtils_B3BX89fM.mjs";
4
- import { t as createHash } from "./cryptoPolyfill_99rxUwYC.mjs";
5
4
  import { existsSync, mkdirSync, readFileSync, renameSync, statSync } from "node:fs";
6
- import { dirname, resolve } from "node:path";
5
+ import { dirname } from "node:path";
6
+ import { createRecord, qualify } from "clm-kernel";
7
7
  //#region src/pages/api/vfs/move.ts
8
8
  var move_exports = /* @__PURE__ */ __exportAll({ POST: () => POST });
9
9
  var POST = async ({ request }) => {
@@ -17,8 +17,8 @@ var POST = async ({ request }) => {
17
17
  const root = repoRoot();
18
18
  if (!isPathWritable(sourcePath, root)) return error("Access denied: Source path is in a read-only projection", 403);
19
19
  if (!isPathWritable(targetPath, root)) return error("Access denied: Target path is in a read-only projection", 403);
20
- const sourceAbs = resolve(root, sourcePath);
21
- const targetAbs = resolve(root, targetPath);
20
+ const sourceAbs = resolveHostPath(sourcePath, root);
21
+ const targetAbs = resolveHostPath(targetPath, root);
22
22
  if (sourceAbs === targetAbs) return error("Source and target paths are identical", 400);
23
23
  if (!existsSync(sourceAbs)) return error(`Source path does not exist: ${sourcePath}`, 404);
24
24
  if (existsSync(targetAbs) && !overwrite) return error(`Target path already exists: ${targetPath}`, 409);
@@ -29,7 +29,7 @@ var POST = async ({ request }) => {
29
29
  success: true,
30
30
  sourcePath,
31
31
  targetPath,
32
- hash: bytes ? createHash("sha256").update(bytes).digest("hex") : null,
32
+ hash: bytes ? qualify(createRecord(bytes)).asPrefixed() : null,
33
33
  bytesMoved: bytes ? bytes.byteLength : 0
34
34
  });
35
35
  } catch (err) {
@@ -73,7 +73,12 @@ var app_config_default = {
73
73
  ".git",
74
74
  "__pycache__",
75
75
  "node_modules",
76
- ".DS_Store"
76
+ ".DS_Store",
77
+ "-wal",
78
+ "-shm",
79
+ "-journal",
80
+ "servermemory.db",
81
+ "server_log.db"
77
82
  ],
78
83
  "filenames": ["__init__.py"],
79
84
  "skip_dotfiles": true
@@ -121,7 +126,11 @@ var app_config_default = {
121
126
  "extra_ignore_paths": [
122
127
  "dist",
123
128
  ".turbo",
124
- "dev-dist"
129
+ "dev-dist",
130
+ "servermemory.db",
131
+ "servermemory.db-wal",
132
+ "servermemory.db-shm",
133
+ "server_log.db"
125
134
  ],
126
135
  "hash_max_bytes": 1048576,
127
136
  "inline_max_bytes": 262144,
@@ -147,7 +156,8 @@ var app_config_default = {
147
156
  ".tikz",
148
157
  ".tikzcd",
149
158
  ".tikz-cd",
150
- ".tex"
159
+ ".tex",
160
+ ".dxf"
151
161
  ],
152
162
  "default_tabs": ["clm", "workspace"]
153
163
  },
@@ -1,7 +1,7 @@
1
1
  import { t as __exportAll } from "./rolldown-runtime_8H4AJuhK.mjs";
2
2
  import { t as error } from "./apiUtils_B3BX89fM.mjs";
3
- import { t as studioMCardFs } from "./vfsCore_B6nCiBl5.mjs";
4
- import "./mcardVfs_CeezzRvt.mjs";
3
+ import { t as studioMCardFs } from "./vfsCore_DIKpk-pk.mjs";
4
+ import "./mcardVfs_DvNburKb.mjs";
5
5
  import { routeHandle } from "clm-kernel";
6
6
  //#region src/pages/api/vfs/proxy.ts
7
7
  var proxy_exports = /* @__PURE__ */ __exportAll({ GET: () => GET });
@@ -1,9 +1,9 @@
1
1
  import { t as __exportAll } from "./rolldown-runtime_8H4AJuhK.mjs";
2
- import { r as repoRoot, t as isPathAllowed } from "./workspaceRoot_DVSUbYkd.mjs";
2
+ import { a as resolveHostPath, i as repoRoot, n as isPathAllowed } from "./workspaceRoot_CRx3taID.mjs";
3
3
  import { t as error } from "./apiUtils_B3BX89fM.mjs";
4
- import { n as sniffMimeType } from "./cardTypeDetector_CyW1Xnmy.mjs";
5
- import { existsSync, readFileSync, statSync } from "node:fs";
6
- import { basename, resolve } from "node:path";
4
+ import { n as sniffMimeType } from "./cardTypeDetector_C55M_HWS.mjs";
5
+ import { closeSync, existsSync, openSync, readFileSync, readSync, statSync } from "node:fs";
6
+ import { basename } from "node:path";
7
7
  //#region src/pages/api/vfs/raw.ts
8
8
  var raw_exports = /* @__PURE__ */ __exportAll({
9
9
  GET: () => GET,
@@ -22,7 +22,7 @@ var GET = async ({ request, url }) => {
22
22
  let cleanRel = relPath.trim();
23
23
  if (cleanRel.startsWith("mcard://")) cleanRel = cleanRel.replace(/^mcard:\/\//, "");
24
24
  const normalizedRel = cleanRel.replace(/:/g, "/").replace(/^(\.\.(\/|\\|$))+/, "").replace(/^[/\\]+/, "");
25
- const targetPath = resolve(root, normalizedRel);
25
+ const targetPath = resolveHostPath(normalizedRel, root);
26
26
  if (!isPathAllowed(targetPath, root)) return error("Access denied: path outside allowed boundaries", 403);
27
27
  if (!existsSync(targetPath)) return error(`File not found: ${normalizedRel}`, 404);
28
28
  try {
@@ -38,26 +38,29 @@ var GET = async ({ request, url }) => {
38
38
  "Cache-Control": "no-cache, must-revalidate"
39
39
  }
40
40
  });
41
+ const filename = basename(targetPath);
42
+ const disposition = url.searchParams.get("download") === "1" || url.searchParams.get("download") === "true" ? `attachment; filename="${encodeURIComponent(filename)}"` : "inline";
41
43
  const requestedHash = url.searchParams.get("v");
42
44
  if (requestedHash) try {
43
- const { studioMCardFs } = await import("./vfsCore_B6nCiBl5.mjs").then((n) => n.n);
45
+ const { studioMCardFs } = await import("./vfsCore_DIKpk-pk.mjs").then((n) => n.n);
44
46
  const card = studioMCardFs.readFileByHash(requestedHash);
45
47
  if (card) {
46
48
  const mime = sniffMimeType(targetPath);
47
- const filename = basename(targetPath);
48
- const disposition = url.searchParams.get("download") === "1" || url.searchParams.get("download") === "true" ? "attachment" : "inline";
49
+ const isBinaryMedia = mime.startsWith("image/") && mime !== "image/svg+xml" || mime.startsWith("audio/") || mime.startsWith("video/") || mime.startsWith("font/") || mime === "application/pdf";
49
50
  if (card.payload.kind === "text") {
50
- const textBuf = Buffer.from(card.payload.value, "utf8");
51
- return new Response(textBuf, {
52
- status: 200,
53
- headers: {
54
- "Content-Type": `${mime}; charset=utf-8`,
55
- "Content-Length": textBuf.length.toString(),
56
- "Content-Disposition": `${disposition}; filename="${encodeURIComponent(filename)}"`,
57
- "ETag": `W/"${requestedHash}"`,
58
- "Cache-Control": "public, max-age=31536000, immutable"
59
- }
60
- });
51
+ if (!isBinaryMedia) {
52
+ const textBuf = Buffer.from(card.payload.value, "utf8");
53
+ return new Response(textBuf, {
54
+ status: 200,
55
+ headers: {
56
+ "Content-Type": `${mime}; charset=utf-8`,
57
+ "Content-Length": textBuf.length.toString(),
58
+ "Content-Disposition": disposition,
59
+ "ETag": `W/"${requestedHash}"`,
60
+ "Cache-Control": "no-store"
61
+ }
62
+ });
63
+ }
61
64
  } else if (card.payload.kind === "binary" || card.payload.data) {
62
65
  const binData = card.payload.data;
63
66
  const binBuf = Buffer.isBuffer(binData) ? binData : Buffer.from(binData);
@@ -66,28 +69,58 @@ var GET = async ({ request, url }) => {
66
69
  headers: {
67
70
  "Content-Type": card.payload.mimeType || mime,
68
71
  "Content-Length": binBuf.length.toString(),
69
- "Content-Disposition": `${disposition}; filename="${encodeURIComponent(filename)}"`,
72
+ "Content-Disposition": disposition,
70
73
  "ETag": `W/"${requestedHash}"`,
71
- "Cache-Control": "public, max-age=31536000, immutable"
74
+ "Cache-Control": "no-store"
72
75
  }
73
76
  });
74
77
  }
75
78
  }
76
79
  } catch {}
77
80
  const mime = sniffMimeType(targetPath);
78
- const contentType = mime.startsWith("text/") || mime === "application/json" || mime === "application/xml" || mime === "application/x-yaml" || mime === "image/svg+xml" || mime === "model/gltf+json" ? `${mime}; charset=utf-8` : mime;
81
+ const contentType = mime.startsWith("text/") || mime === "application/json" || mime === "application/xml" || mime === "application/x-yaml" || mime === "image/svg+xml" || mime === "model/gltf+json" || mime === "image/vnd.dxf" ? `${mime}; charset=utf-8` : mime;
82
+ const rangeHeader = request.headers.get("range");
83
+ if (rangeHeader && rangeHeader.startsWith("bytes=")) {
84
+ const parts = rangeHeader.replace(/bytes=/, "").split("-");
85
+ const start = parseInt(parts[0], 10);
86
+ const end = parts[1] ? parseInt(parts[1], 10) : stat.size - 1;
87
+ if (isNaN(start) || isNaN(end) || start >= stat.size || end >= stat.size || start > end) return new Response(null, {
88
+ status: 416,
89
+ headers: {
90
+ "Content-Range": `bytes */${stat.size}`,
91
+ "Accept-Ranges": "bytes"
92
+ }
93
+ });
94
+ const chunkSize = end - start + 1;
95
+ const fd = openSync(targetPath, "r");
96
+ const chunkBuffer = Buffer.alloc(chunkSize);
97
+ readSync(fd, chunkBuffer, 0, chunkSize, start);
98
+ closeSync(fd);
99
+ return new Response(chunkBuffer, {
100
+ status: 206,
101
+ headers: {
102
+ "Content-Type": contentType,
103
+ "Content-Range": `bytes ${start}-${end}/${stat.size}`,
104
+ "Content-Length": chunkSize.toString(),
105
+ "Accept-Ranges": "bytes",
106
+ "Content-Disposition": disposition,
107
+ "ETag": etag,
108
+ "Last-Modified": stat.mtime.toUTCString(),
109
+ "Cache-Control": "no-store"
110
+ }
111
+ });
112
+ }
79
113
  const fileBuffer = readFileSync(targetPath);
80
- const filename = basename(targetPath);
81
- const disposition = url.searchParams.get("download") === "1" || url.searchParams.get("download") === "true" ? "attachment" : "inline";
82
114
  return new Response(fileBuffer, {
83
115
  status: 200,
84
116
  headers: {
85
117
  "Content-Type": contentType,
86
118
  "Content-Length": stat.size.toString(),
87
- "Content-Disposition": `${disposition}; filename="${encodeURIComponent(filename)}"`,
119
+ "Accept-Ranges": "bytes",
120
+ "Content-Disposition": disposition,
88
121
  "ETag": etag,
89
122
  "Last-Modified": stat.mtime.toUTCString(),
90
- "Cache-Control": "no-cache, must-revalidate"
123
+ "Cache-Control": "no-store"
91
124
  }
92
125
  });
93
126
  } catch (err) {
@@ -1,5 +1,5 @@
1
- import { i as app_config_default, t as PATHS } from "./pathsConfig_CgNYYLVm.mjs";
2
- import { r as repoRoot } from "./workspaceRoot_DVSUbYkd.mjs";
1
+ import { i as app_config_default, t as PATHS } from "./pathsConfig_Dack-p2f.mjs";
2
+ import { i as repoRoot } from "./workspaceRoot_CRx3taID.mjs";
3
3
  import { Context } from "cordis";
4
4
  import fs from "fs";
5
5
  import path from "path";
@@ -0,0 +1,186 @@
1
+ import { t as __exportAll } from "./rolldown-runtime_8H4AJuhK.mjs";
2
+ import { n as getWhitelistedDirectoryProjections, t as PATHS } from "./pathsConfig_Dack-p2f.mjs";
3
+ import { i as repoRoot, o as workspaceRoot, t as dataRoot } from "./workspaceRoot_CRx3taID.mjs";
4
+ import { r as json, t as error } from "./apiUtils_B3BX89fM.mjs";
5
+ import { n as toTreeFiles, t as scanRoots } from "./vfsTreeScan_CRoCluPB.mjs";
6
+ import { existsSync, readFileSync, readdirSync, statSync } from "node:fs";
7
+ import { dirname, join } from "node:path";
8
+ import { ContentHash, buildMerkleTreeFromEntries } from "clm-kernel";
9
+ //#region src/pages/api/vfs/tree.ts
10
+ var tree_exports = /* @__PURE__ */ __exportAll({ GET: () => GET });
11
+ function scanSubdirEntries(dir, rel = "") {
12
+ let entries = [];
13
+ for (const item of readdirSync(dir, { withFileTypes: true })) {
14
+ const full = join(dir, item.name);
15
+ const sub = rel ? `${rel}/${item.name}` : item.name;
16
+ if (item.isDirectory()) entries.push(...scanSubdirEntries(full, sub));
17
+ else entries.push({
18
+ path: sub,
19
+ data: readFileSync(full)
20
+ });
21
+ }
22
+ return entries;
23
+ }
24
+ /**
25
+ * VFS tree federation endpoint.
26
+ * Supports:
27
+ * - ?handle=<collection>: returns manifest of that collection (children with hashes and sizes) lazily (DoD-06-4).
28
+ * - ?scope=<id>: returns strictly bounded read-only subtrees (INV-WS-02).
29
+ */
30
+ var GET = async (context) => {
31
+ try {
32
+ const searchParams = context?.url?.searchParams ?? (context?.request ? new URL(context.request.url).searchParams : null);
33
+ const handleParam = searchParams?.get("handle")?.trim();
34
+ const scope = searchParams?.get("scope") ?? null;
35
+ const dRoot = dataRoot();
36
+ if (handleParam && dRoot) {
37
+ const cleanHandle = handleParam.replace(/^mcard:/, "").replace(/^\/+/, "").replace(/\/+$/, "");
38
+ const targetDir = cleanHandle ? join(dRoot, cleanHandle) : dRoot;
39
+ if (!existsSync(targetDir) || !statSync(targetDir).isDirectory()) return error(`Collection handle not found: ${handleParam}`, 404);
40
+ const entries = readdirSync(targetDir, { withFileTypes: true }).map((item) => {
41
+ const itemRel = cleanHandle ? `${cleanHandle}/${item.name}` : item.name;
42
+ const itemFull = join(targetDir, item.name);
43
+ const isDir = item.isDirectory();
44
+ let sizeBytes = 0;
45
+ let qualifiedHash = "";
46
+ if (isDir) {
47
+ const sub = scanSubdirEntries(itemFull, itemRel);
48
+ const subTree = buildMerkleTreeFromEntries(sub);
49
+ qualifiedHash = subTree.hash.asPrefixed();
50
+ sizeBytes = subTree.sizeBytes;
51
+ } else {
52
+ const data = readFileSync(itemFull);
53
+ qualifiedHash = ContentHash.compute(data).asPrefixed();
54
+ sizeBytes = data.byteLength;
55
+ }
56
+ return {
57
+ name: item.name,
58
+ path: itemRel,
59
+ hash: qualifiedHash,
60
+ isDirectory: isDir,
61
+ sizeBytes
62
+ };
63
+ });
64
+ entries.sort((a, b) => a.name.localeCompare(b.name));
65
+ const manifestLines = entries.map((e) => `${e.name}:${e.hash}:${e.isDirectory ? "dir" : "file"}:${e.sizeBytes}`);
66
+ const manifestBytes = new TextEncoder().encode(manifestLines.join("\n") + (manifestLines.length > 0 ? "\n" : ""));
67
+ const manifestHash = ContentHash.compute(manifestBytes).asPrefixed();
68
+ return json({
69
+ success: true,
70
+ handle: handleParam,
71
+ manifestHash,
72
+ entries,
73
+ scannedAt: Date.now()
74
+ }, 200, {
75
+ "Cache-Control": "private, max-age=31536000, immutable",
76
+ "ETag": `"${manifestHash}"`
77
+ });
78
+ }
79
+ if (dRoot) {
80
+ if (scope && scope.trim() !== "") {
81
+ const roots = [{
82
+ dir: join(dRoot, scope),
83
+ baseDir: dRoot
84
+ }];
85
+ const files = toTreeFiles(scanRoots(roots)).map((file) => ({
86
+ ...file,
87
+ scope,
88
+ readOnly: false
89
+ }));
90
+ return json({
91
+ success: true,
92
+ scope,
93
+ readOnly: false,
94
+ files,
95
+ scannedAt: Date.now()
96
+ }, 200, {
97
+ "Cache-Control": "no-cache, no-store, must-revalidate",
98
+ "Pragma": "no-cache",
99
+ "Expires": "0"
100
+ });
101
+ }
102
+ const files = toTreeFiles(scanRoots([{
103
+ dir: dRoot,
104
+ baseDir: dRoot
105
+ }])).map((file) => {
106
+ const parts = file.path.split("/");
107
+ const fileScope = parts.length > 1 ? parts[0] : "root";
108
+ return {
109
+ ...file,
110
+ scope: fileScope,
111
+ readOnly: false
112
+ };
113
+ });
114
+ return json({
115
+ success: true,
116
+ readOnly: false,
117
+ files,
118
+ scannedAt: Date.now()
119
+ }, 200, {
120
+ "Cache-Control": "no-cache, no-store, must-revalidate",
121
+ "Pragma": "no-cache",
122
+ "Expires": "0"
123
+ });
124
+ }
125
+ const root = repoRoot();
126
+ const projections = getWhitelistedDirectoryProjections();
127
+ const allowedScopes = projections.map((p) => p.id);
128
+ if (scope && scope.trim() !== "") {
129
+ const projection = projections.find((p) => p.id === scope);
130
+ if (!projection) return error(`Invalid directory projection scope: '${scope}'. Allowed scopes: ${allowedScopes.join(", ")}`, 400);
131
+ const isWs = projection.id === PATHS.paths.workspace_dirname;
132
+ const roots = [{
133
+ dir: isWs ? workspaceRoot() : join(root, projection.path),
134
+ baseDir: isWs ? dirname(workspaceRoot()) : root
135
+ }];
136
+ const files = toTreeFiles(scanRoots(roots)).map((file) => ({
137
+ ...file,
138
+ scope: projection.id,
139
+ readOnly: true
140
+ }));
141
+ return json({
142
+ success: true,
143
+ scope: projection.id,
144
+ readOnly: true,
145
+ files,
146
+ scannedAt: Date.now()
147
+ }, 200, {
148
+ "Cache-Control": "no-cache, no-store, must-revalidate",
149
+ "Pragma": "no-cache",
150
+ "Expires": "0"
151
+ });
152
+ }
153
+ const roots = PATHS.vfs.scan_roots.map((scanRoot) => scanRoot === PATHS.paths.workspace_dirname ? {
154
+ dir: workspaceRoot(),
155
+ baseDir: dirname(workspaceRoot())
156
+ } : {
157
+ dir: join(root, scanRoot),
158
+ baseDir: root
159
+ });
160
+ const files = toTreeFiles(scanRoots(roots)).map((file) => {
161
+ const matched = projections.find((p) => file.path.startsWith(p.path + "/") || file.path === p.path);
162
+ return {
163
+ ...file,
164
+ scope: matched?.id || projections[0]?.id || PATHS.paths.assets_dirname,
165
+ readOnly: true
166
+ };
167
+ });
168
+ return json({
169
+ success: true,
170
+ readOnly: true,
171
+ files,
172
+ scannedAt: Date.now()
173
+ }, 200, {
174
+ "Cache-Control": "no-cache, no-store, must-revalidate",
175
+ "Pragma": "no-cache",
176
+ "Expires": "0"
177
+ });
178
+ } catch (err) {
179
+ return error(err instanceof Error ? err.message : "Failed to scan VFS", 500, { success: false });
180
+ }
181
+ };
182
+ //#endregion
183
+ //#region \0virtual:astro:page:src/pages/api/vfs/tree@_@ts
184
+ var page = () => tree_exports;
185
+ //#endregion
186
+ export { page };
@@ -0,0 +1,98 @@
1
+ import { t as __exportAll } from "./rolldown-runtime_8H4AJuhK.mjs";
2
+ import { ContentHash, MCardFileSystem, registerIndexedDbPlugin } from "clm-kernel";
3
+ //#region src/services/vfs/vfsMigration.ts
4
+ /**
5
+ * VFS Migration — One-time retirement migration for legacy clm_workbench_db (DoD-05-3, D7, R7)
6
+ * Canonical Path: src/services/vfs/vfsMigration.ts
7
+ * NOTE: Migration file scheduled for deletion after replica retirement.
8
+ *
9
+ * Reads legacy clm_cas_blobs, clm_handle_registry, clm_handle_history and clm_sqlite_snapshots
10
+ * into kernel-owned CAS driver, then deletes clm_workbench_db.
11
+ */
12
+ var DB_NAME = "clm_workbench_db";
13
+ var DB_VERSION = 2;
14
+ var STORE_CAS = "clm_cas_blobs";
15
+ var STORE_HANDLES = "clm_handle_registry";
16
+ var STORE_HISTORY = "clm_handle_history";
17
+ var STORE_SNAPSHOTS = "clm_sqlite_snapshots";
18
+ var STORE_LEGACY = "clm_content_memory_db";
19
+ /**
20
+ * Migration-only IndexedDB opener.
21
+ * Scheduled for deletion once all client replicas migrate to kernel CAS driver.
22
+ */
23
+ function openMigrationIndexedDb() {
24
+ return new Promise((resolve, reject) => {
25
+ if (typeof window === "undefined" || !window.indexedDB) return reject(/* @__PURE__ */ new Error("IndexedDB not available"));
26
+ const req = window.indexedDB.open(DB_NAME, DB_VERSION);
27
+ req.onupgradeneeded = () => {
28
+ const db = req.result;
29
+ if (!db.objectStoreNames.contains("clm_cas_blobs")) db.createObjectStore(STORE_CAS, { keyPath: "hash" });
30
+ if (!db.objectStoreNames.contains("clm_handle_registry")) db.createObjectStore(STORE_HANDLES, { keyPath: "handle" });
31
+ if (!db.objectStoreNames.contains("clm_handle_history")) db.createObjectStore(STORE_HISTORY, {
32
+ keyPath: "id",
33
+ autoIncrement: true
34
+ });
35
+ if (!db.objectStoreNames.contains("clm_sqlite_snapshots")) db.createObjectStore(STORE_SNAPSHOTS, { keyPath: "id" });
36
+ if (!db.objectStoreNames.contains("clm_content_memory_db")) db.createObjectStore(STORE_LEGACY);
37
+ };
38
+ req.onsuccess = () => resolve(req.result);
39
+ req.onerror = () => reject(req.error);
40
+ });
41
+ }
42
+ /**
43
+ * Executes one-time migration from legacy clm_workbench_db to kernel driver, then deletes database.
44
+ */
45
+ async function migrateAndRetireLegacyIndexedDb(targetFs) {
46
+ if (typeof window === "undefined" || !window.indexedDB) return false;
47
+ try {
48
+ const db = await openMigrationIndexedDb();
49
+ if (Array.from(db.objectStoreNames).includes("clm_cas_blobs")) {
50
+ const req = db.transaction([STORE_CAS], "readonly").objectStore(STORE_CAS).getAll();
51
+ await new Promise((resolve) => {
52
+ req.onsuccess = () => {
53
+ const items = req.result || [];
54
+ for (const item of items) if (item.hash && item.content) try {
55
+ ContentHash.parse(item.hash);
56
+ const bytes = typeof item.content === "string" ? new TextEncoder().encode(item.content) : item.content instanceof Uint8Array ? item.content : new Uint8Array(item.content);
57
+ if (targetFs && typeof targetFs.writeFile === "function") targetFs.writeFile(item.handle || item.hash, bytes);
58
+ } catch {}
59
+ resolve();
60
+ };
61
+ req.onerror = () => resolve();
62
+ });
63
+ }
64
+ db.close();
65
+ await new Promise((resolve, reject) => {
66
+ const delReq = window.indexedDB.deleteDatabase(DB_NAME);
67
+ delReq.onsuccess = () => resolve();
68
+ delReq.onerror = () => reject(delReq.error);
69
+ delReq.onblocked = () => resolve();
70
+ });
71
+ return true;
72
+ } catch (err) {
73
+ console.warn("[VFS Migration] Migration completed or database already retired:", err);
74
+ return false;
75
+ }
76
+ }
77
+ //#endregion
78
+ //#region src/services/vfs/vfsCore.ts
79
+ /**
80
+ * VFS Core — CAS Singleton (SSOT)
81
+ * Canonical Path: src/services/vfs/vfsCore.ts
82
+ * Deliverable: DEL-294-01 / DEL-294-04 (Sprint 294)
83
+ *
84
+ * Owns the single MCardFileSystem instance for the Studio Workbench
85
+ * (INV-294-03 SSOT Singleton Singularity). Every other VFS module
86
+ * consumes this instance via import; callers outside the VFS tree
87
+ * consume it via the mcardVfs facade re-export.
88
+ */
89
+ var vfsCore_exports = /* @__PURE__ */ __exportAll({ studioMCardFs: () => studioMCardFs });
90
+ if (typeof window !== "undefined") registerIndexedDbPlugin();
91
+ /**
92
+ * Universal Content-Addressable MCard Virtual Filesystem for Studio Workbench (INV-04, INV-05, INV-09).
93
+ * Instantiates the optimal storage backend across server (NodeSqliteBackend) and browser environments.
94
+ */
95
+ var studioMCardFs = MCardFileSystem.createOptimal({ dbPath: ".clm/content_memory.db" });
96
+ if (typeof window !== "undefined") migrateAndRetireLegacyIndexedDb(studioMCardFs).catch(() => {});
97
+ //#endregion
98
+ export { STORE_HISTORY as a, openMigrationIndexedDb as c, STORE_HANDLES as i, vfsCore_exports as n, STORE_LEGACY as o, STORE_CAS as r, STORE_SNAPSHOTS as s, studioMCardFs as t };
@@ -1,9 +1,8 @@
1
- import { r as resolveEpistemicStatus, t as PATHS } from "./pathsConfig_CgNYYLVm.mjs";
2
- import { n as sniffMimeType, t as detectCardType } from "./cardTypeDetector_CyW1Xnmy.mjs";
3
- import { t as createHash } from "./cryptoPolyfill_99rxUwYC.mjs";
1
+ import { r as resolveEpistemicStatus, t as PATHS } from "./pathsConfig_Dack-p2f.mjs";
2
+ import { n as sniffMimeType, t as detectCardType } from "./cardTypeDetector_C55M_HWS.mjs";
4
3
  import { existsSync, readFileSync, readdirSync, statSync } from "node:fs";
5
4
  import { join, relative } from "node:path";
6
- import { detectEpistemicStatus } from "clm-kernel";
5
+ import { createRecord, detectEpistemicStatus, qualify } from "clm-kernel";
7
6
  //#region src/server/vfsTreeScan.ts
8
7
  /**
9
8
  * VFS Tree Scanner — Config-Driven Server-to-Browser Federation Scan
@@ -21,8 +20,10 @@ import { detectEpistemicStatus } from "clm-kernel";
21
20
  /** Unified ignore semantics: `ingest.ignore.patterns` + `vfs.extra_ignore_paths` (INV-PC-03). */
22
21
  function shouldIgnorePath(relPath, name, config = PATHS) {
23
22
  if (config.ingest.ignore.skip_dotfiles && name.startsWith(".")) return true;
23
+ if (name.endsWith("-wal") || name.endsWith("-shm") || name.endsWith("-journal")) return true;
24
+ if (config.stores && Object.values(config.stores).includes(name)) return true;
24
25
  const ignored = [...config.ingest.ignore.patterns, ...config.vfs.extra_ignore_paths];
25
- for (const ign of ignored) if (relPath === ign || relPath.startsWith(ign + "/") || name === ign) return true;
26
+ for (const ign of ignored) if (relPath === ign || relPath.startsWith(ign + "/") || name === ign || name.includes(ign)) return true;
26
27
  return false;
27
28
  }
28
29
  /** Recursively scan a directory, honouring configured thresholds and text extensions. */
@@ -38,25 +39,31 @@ function scanDir(dir, baseDir, config = PATHS) {
38
39
  if (f.isDirectory()) entries.push(...scanDir(fullPath, baseDir, config));
39
40
  else if (f.isFile()) try {
40
41
  const stat = statSync(fullPath);
41
- let hash;
42
+ let hash = void 0;
43
+ let hashDeferred = void 0;
42
44
  let content;
43
45
  if (stat.size <= config.vfs.hash_max_bytes) try {
44
46
  const buf = readFileSync(fullPath);
45
- hash = createHash("sha256").update(buf).digest("hex");
47
+ const record = createRecord(buf);
48
+ hash = qualify(record).asPrefixed();
46
49
  const ext = "." + (f.name.split(".").pop() || "").toLowerCase();
47
50
  const isTextExt = textExts.has(ext) || f.name.toLowerCase().endsWith(".tikz-cd");
48
51
  const mime = sniffMimeType(relPath);
49
52
  if (stat.size <= config.vfs.inline_max_bytes && (isTextExt || mime.startsWith("text/"))) content = buf.toString("utf8");
50
53
  } catch {
51
- hash = createHash("sha256").update(`${relPath}:${stat.size}:${stat.mtimeMs}`).digest("hex");
54
+ hash = void 0;
55
+ }
56
+ else {
57
+ hash = void 0;
58
+ hashDeferred = true;
52
59
  }
53
- else hash = createHash("sha256").update(`${relPath}:${stat.size}:${stat.mtimeMs}`).digest("hex");
54
60
  entries.push({
55
61
  path: relPath,
56
62
  name: f.name,
57
63
  size: stat.size,
58
64
  mtime: stat.mtimeMs,
59
65
  hash,
66
+ hashDeferred,
60
67
  content
61
68
  });
62
69
  } catch {}
@@ -99,7 +106,8 @@ function toTreeFiles(entries, config = PATHS) {
99
106
  });
100
107
  return {
101
108
  handle: entry.path.replace(/\//g, separator),
102
- hash: entry.hash,
109
+ hash: entry.hash ?? "",
110
+ hashDeferred: entry.hashDeferred,
103
111
  path: entry.path,
104
112
  name: entry.name,
105
113
  mimeType: mime,