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,21 +1,141 @@
1
1
  import type { APIRoute } from 'astro';
2
- import { join } from 'node:path';
2
+ import { join, dirname } from 'node:path';
3
+ import { existsSync, readdirSync, statSync, readFileSync } from 'node:fs';
3
4
  import { json, error } from '../../../lib/apiUtils';
4
- import { repoRoot, workspaceRoot } from '../../../server/workspaceRoot';
5
+ import { repoRoot, workspaceRoot, dataRoot } from '../../../server/workspaceRoot';
5
6
  import { PATHS, getWhitelistedDirectoryProjections } from '../../../config/pathsConfig.js';
6
7
  import { scanRoots, toTreeFiles, type ScanRoot } from '../../../server/vfsTreeScan';
8
+ import { ContentHash, buildMerkleTreeFromEntries } from 'clm-kernel';
9
+
10
+ function scanSubdirEntries(dir: string, rel = ''): Array<{ path: string; data: Uint8Array }> {
11
+ let entries: Array<{ path: string; data: Uint8Array }> = [];
12
+ for (const item of readdirSync(dir, { withFileTypes: true })) {
13
+ const full = join(dir, item.name);
14
+ const sub = rel ? `${rel}/${item.name}` : item.name;
15
+ if (item.isDirectory()) {
16
+ entries.push(...scanSubdirEntries(full, sub));
17
+ } else {
18
+ entries.push({ path: sub, data: readFileSync(full) });
19
+ }
20
+ }
21
+ return entries;
22
+ }
7
23
 
8
24
  /**
9
25
  * VFS tree federation endpoint.
10
- * Supports ?scope=<id> to return strictly bounded read-only subtrees (INV-WS-02).
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).
11
29
  */
12
30
  export const GET: APIRoute = async (context) => {
13
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
+
37
+ // Lazy Collection Manifest Endpoint (CAS-06 §2.3, DoD-06-4)
38
+ if (handleParam && dRoot) {
39
+ const cleanHandle = handleParam.replace(/^mcard:/, '').replace(/^\/+/, '').replace(/\/+$/, '');
40
+ const targetDir = cleanHandle ? join(dRoot, cleanHandle) : dRoot;
41
+ if (!existsSync(targetDir) || !statSync(targetDir).isDirectory()) {
42
+ return error(`Collection handle not found: ${handleParam}`, 404);
43
+ }
44
+
45
+ const items = readdirSync(targetDir, { withFileTypes: true });
46
+ const entries = items.map((item) => {
47
+ const itemRel = cleanHandle ? `${cleanHandle}/${item.name}` : item.name;
48
+ const itemFull = join(targetDir, item.name);
49
+ const isDir = item.isDirectory();
50
+ let sizeBytes = 0;
51
+ let qualifiedHash = '';
52
+ if (isDir) {
53
+ const sub = scanSubdirEntries(itemFull, itemRel);
54
+ const subTree = buildMerkleTreeFromEntries(sub);
55
+ qualifiedHash = subTree.hash.asPrefixed();
56
+ sizeBytes = subTree.sizeBytes;
57
+ } else {
58
+ const data = readFileSync(itemFull);
59
+ qualifiedHash = ContentHash.compute(data).asPrefixed();
60
+ sizeBytes = data.byteLength;
61
+ }
62
+ return {
63
+ name: item.name,
64
+ path: itemRel,
65
+ hash: qualifiedHash,
66
+ isDirectory: isDir,
67
+ sizeBytes,
68
+ };
69
+ });
70
+
71
+ entries.sort((a, b) => a.name.localeCompare(b.name));
72
+ const manifestLines = entries.map((e) => `${e.name}:${e.hash}:${e.isDirectory ? 'dir' : 'file'}:${e.sizeBytes}`);
73
+ const manifestBytes = new TextEncoder().encode(manifestLines.join('\n') + (manifestLines.length > 0 ? '\n' : ''));
74
+ const manifestHash = ContentHash.compute(manifestBytes).asPrefixed();
75
+
76
+ return json(
77
+ {
78
+ success: true,
79
+ handle: handleParam,
80
+ manifestHash,
81
+ entries,
82
+ scannedAt: Date.now(),
83
+ },
84
+ 200,
85
+ {
86
+ 'Cache-Control': 'private, max-age=31536000, immutable',
87
+ 'ETag': `"${manifestHash}"`,
88
+ }
89
+ );
90
+ }
91
+
92
+ if (dRoot) {
93
+ if (scope && scope.trim() !== '') {
94
+ const subDir = join(dRoot, scope);
95
+ const roots: ScanRoot[] = [{ dir: subDir, baseDir: dRoot }];
96
+ const rawFiles = toTreeFiles(scanRoots(roots));
97
+ const files = rawFiles.map((file) => ({
98
+ ...file,
99
+ scope,
100
+ readOnly: false,
101
+ }));
102
+ return json(
103
+ { success: true, scope, readOnly: false, files, scannedAt: Date.now() },
104
+ 200,
105
+ {
106
+ 'Cache-Control': 'no-cache, no-store, must-revalidate',
107
+ 'Pragma': 'no-cache',
108
+ 'Expires': '0',
109
+ }
110
+ );
111
+ }
112
+
113
+ const roots: ScanRoot[] = [{ dir: dRoot, baseDir: dRoot }];
114
+ const rawFiles = toTreeFiles(scanRoots(roots));
115
+ const files = rawFiles.map((file) => {
116
+ const parts = file.path.split('/');
117
+ const fileScope = parts.length > 1 ? parts[0] : 'root';
118
+ return {
119
+ ...file,
120
+ scope: fileScope,
121
+ readOnly: false,
122
+ };
123
+ });
124
+
125
+ return json(
126
+ { success: true, readOnly: false, files, scannedAt: Date.now() },
127
+ 200,
128
+ {
129
+ 'Cache-Control': 'no-cache, no-store, must-revalidate',
130
+ 'Pragma': 'no-cache',
131
+ 'Expires': '0',
132
+ }
133
+ );
134
+ }
135
+
14
136
  const root = repoRoot();
15
137
  const projections = getWhitelistedDirectoryProjections();
16
138
  const allowedScopes = projections.map((p) => p.id);
17
- const searchParams = context?.url?.searchParams ?? (context?.request ? new URL(context.request.url).searchParams : null);
18
- const scope = searchParams?.get('scope') ?? null;
19
139
 
20
140
  if (scope && scope.trim() !== '') {
21
141
  const projection = projections.find((p) => p.id === scope);
@@ -26,11 +146,10 @@ export const GET: APIRoute = async (context) => {
26
146
  );
27
147
  }
28
148
 
29
- const dir =
30
- projection.id === PATHS.paths.workspace_dirname
31
- ? workspaceRoot()
32
- : join(root, projection.path);
33
- const roots: ScanRoot[] = [{ dir, baseDir: root }];
149
+ const isWs = projection.id === PATHS.paths.workspace_dirname;
150
+ const dir = isWs ? workspaceRoot() : join(root, projection.path);
151
+ const baseDir = isWs ? dirname(workspaceRoot()) : root;
152
+ const roots: ScanRoot[] = [{ dir, baseDir }];
34
153
  const rawFiles = toTreeFiles(scanRoots(roots));
35
154
  const files = rawFiles.map((file) => ({
36
155
  ...file,
@@ -51,7 +170,7 @@ export const GET: APIRoute = async (context) => {
51
170
 
52
171
  const roots: ScanRoot[] = PATHS.vfs.scan_roots.map((scanRoot) =>
53
172
  scanRoot === PATHS.paths.workspace_dirname
54
- ? { dir: workspaceRoot(), baseDir: root }
173
+ ? { dir: workspaceRoot(), baseDir: dirname(workspaceRoot()) }
55
174
  : { dir: join(root, scanRoot), baseDir: root },
56
175
  );
57
176
 
@@ -7,9 +7,9 @@
7
7
  import type { APIRoute } from 'astro';
8
8
  import { resolve, dirname } from 'node:path';
9
9
  import { writeFileSync, mkdirSync } from 'node:fs';
10
- import { createHash } from 'node:crypto';
10
+ import { createRecord, qualify } from 'clm-kernel';
11
11
  import { json, error } from '../../../lib/apiUtils';
12
- import { repoRoot, isPathWritable } from '../../../server/workspaceRoot';
12
+ import { repoRoot, isPathWritable, resolveHostPath } from '../../../server/workspaceRoot';
13
13
 
14
14
  export const POST: APIRoute = async ({ request }) => {
15
15
  try {
@@ -31,7 +31,7 @@ export const POST: APIRoute = async ({ request }) => {
31
31
  return error('Access denied: Target path is in a read-only projection', 403);
32
32
  }
33
33
 
34
- const absolutePath = resolve(root, targetPath);
34
+ const absolutePath = resolveHostPath(targetPath, root);
35
35
  mkdirSync(dirname(absolutePath), { recursive: true });
36
36
 
37
37
  let bytes: Buffer;
@@ -47,7 +47,8 @@ export const POST: APIRoute = async ({ request }) => {
47
47
 
48
48
  writeFileSync(absolutePath, bytes);
49
49
 
50
- const hash = createHash('sha256').update(bytes).digest('hex');
50
+ const record = createRecord(bytes);
51
+ const hash = qualify(record).asPrefixed();
51
52
 
52
53
  return json({
53
54
  success: true,
@@ -7,5 +7,80 @@ import StudioLayout from '../layouts/StudioLayout.astro';
7
7
  import StudioWorkbench from '../components/studio/StudioWorkbench';
8
8
  ---
9
9
  <StudioLayout layoutVariant="workbench">
10
+ <div id="hydration-watchdog" class="hydration-loading-state" aria-live="polite">
11
+ <div class="hydration-spinner"></div>
12
+ <p class="hydration-label">Initializing MCard Studio Spatial Workbench...</p>
13
+ <noscript>
14
+ <div class="noscript-card">
15
+ <h3>JavaScript Required</h3>
16
+ <p>MCard Studio requires JavaScript to run the spatial IDE workbench.</p>
17
+ </div>
18
+ </noscript>
19
+ </div>
10
20
  <StudioWorkbench client:only="react" />
11
21
  </StudioLayout>
22
+
23
+ <script>
24
+ // Hydration Watchdog: Remove fallback when React island mounts, or show error diagnostic if hydration fails
25
+ const watchdog = document.getElementById('hydration-watchdog');
26
+ if (watchdog) {
27
+ const observer = new MutationObserver(() => {
28
+ const island = document.querySelector('astro-island');
29
+ if (island && island.children.length > 0) {
30
+ watchdog.style.opacity = '0';
31
+ setTimeout(() => watchdog.remove(), 300);
32
+ observer.disconnect();
33
+ }
34
+ });
35
+ observer.observe(document.body, { childList: true, subtree: true });
36
+
37
+ // Fallback error watchdog after 4000ms
38
+ setTimeout(() => {
39
+ const island = document.querySelector('astro-island');
40
+ if (!island || island.children.length === 0) {
41
+ const label = watchdog.querySelector('.hydration-label');
42
+ if (label) {
43
+ label.innerHTML = '<strong>Hydration notice:</strong> Loading workbench modules... Check browser console if view remains blank.';
44
+ }
45
+ }
46
+ }, 4000);
47
+ }
48
+ </script>
49
+
50
+ <style>
51
+ .hydration-loading-state {
52
+ position: absolute;
53
+ inset: 0;
54
+ display: flex;
55
+ flex-direction: column;
56
+ align-items: center;
57
+ justify-content: center;
58
+ background-color: var(--color-bg-canvas, #1e1e1e);
59
+ color: var(--color-fg-muted, #999);
60
+ font-family: system-ui, -apple-system, sans-serif;
61
+ z-index: 1;
62
+ transition: opacity 0.3s ease;
63
+ pointer-events: none;
64
+ }
65
+ .hydration-spinner {
66
+ width: 32px;
67
+ height: 32px;
68
+ border: 3px solid rgba(255, 255, 255, 0.1);
69
+ border-top-color: var(--color-accent, #3b82f6);
70
+ border-radius: 50%;
71
+ animation: spin 0.8s linear infinite;
72
+ margin-bottom: 16px;
73
+ }
74
+ @keyframes spin {
75
+ to { transform: rotate(360deg); }
76
+ }
77
+ .noscript-card {
78
+ margin-top: 16px;
79
+ padding: 16px;
80
+ background: #2a2a2a;
81
+ border: 1px solid #444;
82
+ border-radius: 6px;
83
+ color: #fff;
84
+ text-align: center;
85
+ }
86
+ </style>
@@ -10,7 +10,7 @@
10
10
 
11
11
  import type { Intent } from '../../core/intents/types';
12
12
  import type { KernelEvent } from '../../core/events/kernelEvents';
13
- import { computeSha256 } from '../kernelHash';
13
+ import { createRecord, qualify } from 'clm-kernel';
14
14
 
15
15
  export interface DispatchResult {
16
16
  readonly status: number;
@@ -42,12 +42,12 @@ export async function handleKernelDispatch(
42
42
  switch (intent.kind) {
43
43
  case 'TouchMCard': {
44
44
  const content = (intent.payload && (intent.payload as any).content) || '';
45
- const hash = computeSha256(content);
45
+ const hash = qualify(createRecord(content)).asPrefixed();
46
46
  const event: KernelEvent = {
47
47
  kind: 'MCardTouched',
48
48
  intentId: intent.id,
49
49
  uri: intent.uri,
50
- hash: `sha256:${hash}`,
50
+ hash,
51
51
  };
52
52
  return {
53
53
  status: 200,
@@ -56,7 +56,7 @@ export async function handleKernelDispatch(
56
56
  }
57
57
 
58
58
  case 'ReadMCard': {
59
- const hash = intent.ref.kind === 'hash' ? intent.ref.hash : `sha256:${computeSha256(intent.ref.handle)}`;
59
+ const hash = intent.ref.kind === 'hash' ? intent.ref.hash : qualify(createRecord(intent.ref.handle)).asPrefixed();
60
60
  const event: KernelEvent = {
61
61
  kind: 'MCardRead',
62
62
  intentId: intent.id,
@@ -73,8 +73,8 @@ export async function handleKernelDispatch(
73
73
  const event: KernelEvent = {
74
74
  kind: 'ExecutionReceipt',
75
75
  intentId: intent.id,
76
- receiptHash: `sha256:${computeSha256(intent.pcardRef)}`,
77
- outputHash: `sha256:${computeSha256(intent.inputRef || '')}`,
76
+ receiptHash: qualify(createRecord(intent.pcardRef)).asPrefixed(),
77
+ outputHash: qualify(createRecord(intent.inputRef || '')).asPrefixed(),
78
78
  fiberId: `fiber:${intent.id}`,
79
79
  };
80
80
  return {
@@ -88,7 +88,7 @@ export async function handleKernelDispatch(
88
88
  kind: 'ContinuationResumed',
89
89
  intentId: intent.id,
90
90
  token: intent.token,
91
- receiptHash: `sha256:${computeSha256(intent.token)}`,
91
+ receiptHash: qualify(createRecord(intent.token)).asPrefixed(),
92
92
  };
93
93
  return {
94
94
  status: 200,
@@ -100,7 +100,7 @@ export async function handleKernelDispatch(
100
100
  const event: KernelEvent = {
101
101
  kind: 'ActionApplied',
102
102
  intentId: intent.id,
103
- postHash: `sha256:${computeSha256(intent.action.type)}`,
103
+ postHash: qualify(createRecord(intent.action.type)).asPrefixed(),
104
104
  };
105
105
  return {
106
106
  status: 200,
@@ -39,6 +39,10 @@ import { registerCacheInvalidator } from './serverMemoryCacheSignal.mjs';
39
39
  const fileSystemRepository = new FileSystemArtifactRepository(DEFAULT_ARTIFACTS_PUBLIC_DIR);
40
40
  const collectionRepository = new ServerMemoryArtifactRepository();
41
41
 
42
+ export function getCollectionRepository(): ServerMemoryArtifactRepository {
43
+ return collectionRepository;
44
+ }
45
+
42
46
  // Register so the .mjs WS layer can invalidate our in-memory cache
43
47
  registerCacheInvalidator(() => {
44
48
  collectionRepository.invalidateCache();
@@ -320,13 +324,6 @@ export async function deleteArtifact(handle: string): Promise<void> {
320
324
  }
321
325
  }
322
326
 
323
- /**
324
- * Delete a single version history entry for an artifact.
325
- */
326
- export async function deleteHistoryEntry(handle: string, previousHash: string): Promise<void> {
327
- // Always operate on servermemory.db — the single source of truth for history.
328
- await (collectionRepository as any).deleteHistoryEntry(handle, previousHash);
329
- }
330
327
 
331
328
  /**
332
329
  * Revert the latest version of an artifact: roll handle_registry.current_hash back
@@ -1,6 +1,6 @@
1
1
  import fs from 'fs/promises';
2
2
  import path from 'path';
3
- import crypto from 'crypto';
3
+ import { createRecord, qualify } from 'clm-kernel';
4
4
  import { buildServerFsHandle, artifactFetchPathFromPath, artifactPathFromHandle, LEGACY_LOCAL_PREFIX_SLASH } from '../utils/artifactHandles';
5
5
  import { inferArtifactType } from '../domain/artifactClassification';
6
6
  import type { ArtifactMeta } from '../domain/artifacts';
@@ -141,8 +141,9 @@ export class FileSystemArtifactRepository implements ArtifactRepository {
141
141
  throw new Error(`Failed to save or find artifact metadata for ${handle}`);
142
142
  }
143
143
 
144
- // Compute content hash for MinIO CAS upload
145
- const hash = crypto.createHash('sha256').update(content).digest('hex');
144
+ // Compute content hash via kernel record
145
+ const record = createRecord(content);
146
+ const hash = qualify(record).asPrefixed();
146
147
  meta.hash = hash;
147
148
 
148
149
  return meta;
@@ -7,7 +7,7 @@ import vm from 'node:vm';
7
7
  import YAML from 'yaml';
8
8
  import { CLM_RUNNER_TIMEOUT_MS, resolveServerConfig } from './serverConfig.js';
9
9
  import { LEGACY_LOCAL_PREFIX_SLASH, SERVER_FS_PREFIX_SLASH, SERVER_COL_PREFIX_SLASH } from '../shared/handleConstants.js';
10
- import { MCard } from './storage/index.ts';
10
+ import { MCard } from 'clm-kernel';
11
11
 
12
12
  const execFileAsync = promisify(execFile);
13
13
  const { artifactsDir: ARTIFACTS_DIR } = resolveServerConfig(process.env);
@@ -1,4 +1,4 @@
1
- import { CardCollection, SqliteNodeEngine } from './storage/index.ts';
1
+ import { MCardCollection, NodeSqliteBackend } from 'clm-kernel';
2
2
 
3
3
  export function createCollectionOwner(dbPath) {
4
4
  let collection = null;
@@ -11,10 +11,10 @@ export function createCollectionOwner(dbPath) {
11
11
 
12
12
  console.log(`[WS] Initializing Storage at ${dbPath}`);
13
13
  try {
14
- engine = await SqliteNodeEngine.create(dbPath);
15
- console.log(`[WS] SqliteNodeEngine created OK for ${dbPath}`);
14
+ engine = new NodeSqliteBackend(dbPath);
15
+ console.log(`[WS] NodeSqliteBackend created OK for ${dbPath}`);
16
16
  } catch (err) {
17
- console.error(`[WS] SqliteNodeEngine FAILED for ${dbPath}:`, err);
17
+ console.error(`[WS] NodeSqliteBackend FAILED for ${dbPath}:`, err);
18
18
  console.warn('[WS] Falling back to mock storage (no persistence)');
19
19
  useMock = true;
20
20
  return null;
@@ -46,7 +46,7 @@ export function createCollectionOwner(dbPath) {
46
46
  };
47
47
  }
48
48
 
49
- collection = new CardCollection(e);
49
+ collection = new MCardCollection(e);
50
50
  return collection;
51
51
  }
52
52
 
@@ -1,4 +1,4 @@
1
- import { MCard } from '../storage/index.ts';
1
+ import { createRecord } from 'clm-kernel';
2
2
  import { WS_MESSAGE_TYPES } from '../../shared/wsProtocol.js';
3
3
 
4
4
  /**
@@ -39,10 +39,10 @@ export async function persistSealedResult({ collectionOwner, sealExecutionResult
39
39
  };
40
40
 
41
41
  const sealed = sealExecutionResult(vCardContent);
42
- const vCard = await MCard.create(JSON.stringify(sealed.original, null, 2));
43
- await collection.add(vCard);
42
+ const record = createRecord(JSON.stringify(sealed.original, null, 2));
43
+ await collection.add(record);
44
44
 
45
- return { hash: vCard.hash, vCardContent };
45
+ return { hash: record.hash, vCardContent };
46
46
  }
47
47
 
48
48
  /**
@@ -71,11 +71,11 @@ export async function persistLLMInteractionEvents({ collectionOwner, notificatio
71
71
  vcard_policy_hash: request.handle || 'unknown-context'
72
72
  };
73
73
 
74
- const userMCard = await MCard.create(JSON.stringify(userPromptContent, null, 2));
75
- const existingUserCard = await collection.get(userMCard.hash);
74
+ const userRecord = createRecord(JSON.stringify(userPromptContent, null, 2));
75
+ const existingUserCard = await collection.get(userRecord.hash);
76
76
 
77
77
  if (!existingUserCard) {
78
- await collection.add(userMCard);
78
+ await collection.add(userRecord);
79
79
  }
80
80
 
81
81
  if (notificationService && request.clientId) {
@@ -93,15 +93,15 @@ export async function persistLLMInteractionEvents({ collectionOwner, notificatio
93
93
  timestamp: new Date().toISOString(),
94
94
  contentType: 'text/markdown',
95
95
  content: runResult.result,
96
- pre_condition_hash: userMCard.hash,
96
+ pre_condition_hash: userRecord.hash,
97
97
  trace_execution_hash: parentExecutionHash
98
98
  };
99
99
 
100
- const llmMCard = await MCard.create(JSON.stringify(llmResponseContent, null, 2));
101
- const existingLlmCard = await collection.get(llmMCard.hash);
100
+ const llmRecord = createRecord(JSON.stringify(llmResponseContent, null, 2));
101
+ const existingLlmCard = await collection.get(llmRecord.hash);
102
102
 
103
103
  if (!existingLlmCard) {
104
- await collection.add(llmMCard);
104
+ await collection.add(llmRecord);
105
105
  }
106
106
 
107
107
  if (notificationService && request.clientId) {
@@ -1,4 +1,4 @@
1
- import { computeSha256 } from '../kernelHash.ts';
1
+ import { computeHash } from 'clm-kernel';
2
2
 
3
3
  /**
4
4
  * Result Sealing Service — VCard provenance layer.
@@ -94,5 +94,5 @@ export function verifySeal(sealedContent) {
94
94
 
95
95
  /** @param {string} data */
96
96
  function sha256(data) {
97
- return computeSha256(data);
97
+ return computeHash('sha256', data);
98
98
  }
@@ -1,9 +1,10 @@
1
1
  import path from 'path';
2
2
  import { access, readFile, readdir, stat } from 'fs/promises';
3
3
  import { ClmChapterLoader } from 'clm-kernel/layer0';
4
- import { MCard } from './storage/index.ts';
4
+ import { createRecord, qualify } from 'clm-kernel';
5
5
  import { buildServerFsHandle } from '../shared/handleConstants.js';
6
6
  import { PATHS } from '../config/pathsConfig.js';
7
+ import { isStoreFile } from '../edge/storeFilter.js';
7
8
 
8
9
  /** Ignore semantics resolve from the single `ingest.ignore` source (INV-PC-03). */
9
10
  const IGNORED_EXT_SET = new Set(PATHS.ingest.ignore.extensions);
@@ -12,7 +13,6 @@ const IGNORED_FILENAMES = new Set(PATHS.ingest.ignore.filenames);
12
13
  const SKIP_DOTFILES = PATHS.ingest.ignore.skip_dotfiles;
13
14
  const SERVER_FS_PREFIX = PATHS.handles.server_fs;
14
15
 
15
-
16
16
  /**
17
17
  * File Ingest Service — Filesystem → Collection Importer.
18
18
  *
@@ -34,6 +34,9 @@ const SERVER_FS_PREFIX = PATHS.handles.server_fs;
34
34
  * @returns {Promise<{ action: 'created' | 'updated' | 'unchanged' | 'deleted'; handle: string; hash?: string } | null>}
35
35
  */
36
36
  export async function ingestFileChange(artifactsDir, filename, collectionOwner) {
37
+ if (isStoreFile(filename)) {
38
+ return null;
39
+ }
37
40
  const fullPath = path.join(artifactsDir, filename);
38
41
  const handle = buildServerFsHandle(filename);
39
42
 
@@ -59,21 +62,27 @@ export async function ingestFileChange(artifactsDir, filename, collectionOwner)
59
62
  }
60
63
  }
61
64
 
62
- const card = await MCard.create(buf);
65
+ const record = createRecord(buf);
66
+ const qualifiedHash = qualify(record);
63
67
  const collection = await collectionOwner.getCollection();
64
68
  const existingHash = await collection.resolveHandle(handle);
65
69
 
66
- if (existingHash === card.hash) {
67
- return { action: 'unchanged', handle, hash: card.hash };
70
+ const bareHex = record.hash.includes(':') ? record.hash.split(':')[1] : record.hash;
71
+ const existingHex = (existingHash && typeof existingHash === 'object' && 'asHex' in existingHash)
72
+ ? existingHash.asHex()
73
+ : (String(existingHash || '').includes(':') ? String(existingHash).split(':')[1] : String(existingHash || ''));
74
+
75
+ if (existingHex === bareHex) {
76
+ return { action: 'unchanged', handle, hash: qualifiedHash };
68
77
  }
69
78
 
70
79
  if (existingHash) {
71
- await collection.updateHandle(handle, card);
72
- return { action: 'updated', handle, hash: card.hash };
80
+ await collection.updateHandle(handle, record);
81
+ return { action: 'updated', handle, hash: qualifiedHash };
73
82
  }
74
83
 
75
- await collection.addWithHandle(card, handle);
76
- return { action: 'created', handle, hash: card.hash };
84
+ await collection.addWithHandle(record, handle);
85
+ return { action: 'created', handle, hash: qualifiedHash };
77
86
  }
78
87
 
79
88
  /**
@@ -126,6 +135,9 @@ export async function ingestDirectory(artifactsDir, collectionOwner, options = {
126
135
  }
127
136
 
128
137
  // Skip non-artifact files
138
+ if (isStoreFile(entry.name)) {
139
+ continue;
140
+ }
129
141
  const ext = path.extname(entry.name).toLowerCase();
130
142
  if (IGNORED_EXT_SET.has(ext)) continue;
131
143
  if ((SKIP_DOTFILES && entry.name.startsWith('.')) || IGNORED_FILENAMES.has(entry.name)) continue;
@@ -2,6 +2,7 @@ import { watch } from 'fs';
2
2
  import path from 'path';
3
3
  import { EventEmitter } from 'events';
4
4
  import { PATHS } from '../config/pathsConfig.js';
5
+ import { isStoreFile } from '../edge/storeFilter.js';
5
6
 
6
7
  const DEBOUNCE_MS = PATHS.ingest.watch_debounce_ms;
7
8
  const IGNORED_PATTERNS = PATHS.ingest.ignore.patterns;
@@ -19,7 +20,9 @@ export function createFileWatcherService(artifactsDir) {
19
20
  const debounceTimers = new Map();
20
21
 
21
22
  function shouldIgnore(filename) {
22
- return IGNORED_PATTERNS.some(pattern => filename.includes(pattern));
23
+ if (IGNORED_PATTERNS.some(pattern => filename.includes(pattern))) return true;
24
+ if (isStoreFile(filename)) return true;
25
+ return false;
23
26
  }
24
27
 
25
28
  function start() {
@@ -1,14 +1,7 @@
1
- /**
2
- * File watcher event handler.
3
- *
4
- * Encapsulates the side-effects triggered when the file system watcher detects
5
- * changes in the artifacts directory:
6
- * 1. Broadcasts ARTIFACTS_CHANGED to all connected WS clients
7
- * 2. Auto-ingests changes into servermemory.db for version tracking
8
- */
9
1
  import { WS_MESSAGE_TYPES } from '../../shared/wsProtocol.js';
10
2
  import { ingestFileChange } from '../fileIngestService.mjs';
11
3
  import { signalCacheInvalidate } from '../serverMemoryCacheSignal.mjs';
4
+ import { formatNotification, GATEWAY_METHODS } from 'clm-kernel';
12
5
 
13
6
  /**
14
7
  * Create a handler for file watcher 'change' events.
@@ -22,10 +15,25 @@ export function createFileChangeHandler({ artifactsDir, notificationService, ser
22
15
  return async ({ eventType, filename }) => {
23
16
  try {
24
17
  const result = await ingestFileChange(artifactsDir, filename, serverMemoryOwner);
25
- if (!result) {
18
+ if (!result || result.action === 'unchanged') {
26
19
  return;
27
20
  }
28
21
 
22
+ // Sprint CAS-05 / R9: Emit clm.name.transition notification with kernel's formatNotification
23
+ const transitionKind = result.action === 'deleted' ? 'DELETE' : (result.action === 'created' ? 'CREATE' : 'UPDATE');
24
+ const qualifiedHashStr = result.hash ? String(result.hash) : '';
25
+ const transitionPayload = {
26
+ hash: qualifiedHashStr,
27
+ handle: result.handle,
28
+ kind: transitionKind,
29
+ from: null,
30
+ to: result.action === 'deleted' ? null : qualifiedHashStr,
31
+ author: 'did:clm:agent:watcher',
32
+ clock: { watcher: Date.now() },
33
+ };
34
+ const notificationJson = formatNotification(GATEWAY_METHODS.NAME_TRANSITION, transitionPayload);
35
+ notificationService.broadcastRaw?.(notificationJson);
36
+
29
37
  await notificationService.broadcastToAll({
30
38
  type: WS_MESSAGE_TYPES.ARTIFACTS_CHANGED,
31
39
  title: 'Server files changed',
@@ -36,7 +44,7 @@ export function createFileChangeHandler({ artifactsDir, notificationService, ser
36
44
  hash: result.hash,
37
45
  filename
38
46
  });
39
- console.log(`[WS] Broadcasted ARTIFACTS_CHANGED to all clients for ${result.handle} (${result.action})`);
47
+ console.log(`[WS] Broadcasted clm.name.transition & ARTIFACTS_CHANGED to all clients for ${result.handle} (${result.action})`);
40
48
 
41
49
  if (result.action !== 'unchanged' && result.action !== 'deleted') {
42
50
  console.log(`[WS] Ingested ${result.action} for ${filename} (handle: ${result.handle}, hash: ${result.hash})`);