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.
- package/README.md +3 -0
- package/astro.config.mjs +46 -2
- package/bin/mcard-studio.mjs +1 -1
- package/cli/lib/runtimeContext.mjs +6 -3
- package/dist/client/_astro/{ChartAnalyticsViewlet.Cevj0EOs.js → ChartAnalyticsViewlet.CBW-JyA3.js} +1 -1
- package/dist/client/_astro/ClmPcardViewlet.cvKsR2ng.js +3 -0
- package/dist/client/_astro/D3GraphViewlet.8YEIrCGL.js +2 -0
- package/dist/client/_astro/DockviewSpatialWorkbench.BTd66LPl.js +12 -0
- package/dist/client/_astro/DocumentViewlets.KY1HcNka.js +2 -0
- package/dist/client/_astro/DxfViewlet.B3N5zpZR.js +1 -0
- package/dist/client/_astro/ExcalidrawWhiteboardViewlet.CMJGCQN4.js +1 -0
- package/dist/client/_astro/{FaroVCardSpanInstrumenter.BIk2NhJY.js → FaroVCardSpanInstrumenter.ClIqZujq.js} +1 -1
- package/dist/client/_astro/{FontSpecimenViewlet.CpONhJh0.js → FontSpecimenViewlet.ChIyr0B8.js} +1 -1
- package/dist/client/_astro/HeadMeta.astro_astro_type_script_index_0_lang.D3FSc061.js +1 -0
- package/dist/client/_astro/{ImageViewlet.CHeNvX6L.js → ImageViewlet.Cs-u7-wt.js} +1 -1
- package/dist/client/_astro/{KatexFormulaViewlet.Cy_InWOK.js → KatexFormulaViewlet.0nOzV_qD.js} +1 -1
- package/dist/client/_astro/KoishiChatViewlet.DLsMmwdb.js +16 -0
- package/dist/client/_astro/MCardLibraryHarness.WBT9W10S.js +2 -0
- package/dist/client/_astro/{MarkdownViewlet.qoPlM-TZ.js → MarkdownViewlet.BIolkNXf.js} +25 -25
- package/dist/client/_astro/{MermaidDiagramViewlet.RnwDfQl6.js → MermaidDiagramViewlet.CkRk7QsS.js} +1 -1
- package/dist/client/_astro/PCardRendererBridge.DhaRSprd.js +1 -0
- package/dist/client/_astro/RendererPCardRegistry.brM2KiQs.js +1 -0
- package/dist/client/_astro/{SchemaYamlViewlet.D6HVdmrq.js → SchemaYamlViewlet.Bc7nkK4M.js} +1 -1
- 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
- package/dist/client/_astro/{Spatial3dViewlet.CCYBSSib.js → Spatial3dViewlet.C-jjhr0A.js} +1 -1
- package/dist/client/_astro/{StudioLayout.CBgiVbeb.css → StudioLayout.CX8XGtZV.css} +1 -1
- package/dist/client/_astro/StudioWorkbench.B1QwGHWM.js +7 -0
- package/dist/client/_astro/{SvgViewlet.BxlWQ-JX.js → SvgViewlet.uGxvb06H.js} +1 -1
- package/dist/client/_astro/{TerminalView.DWZR-hUa.js → TerminalView.DP7G7E1m.js} +4 -4
- package/dist/client/_astro/{ThemeSettingsViewlet.Cb1r8fWw.js → ThemeSettingsViewlet.UaTHcGnF.js} +1 -1
- package/dist/client/_astro/{TikzDiagramViewlet.CqY7VTeP.js → TikzDiagramViewlet.O8MJyXfT.js} +1 -1
- package/dist/client/_astro/VideoPlayerViewlet.-ycmo3kY.js +1 -0
- package/dist/client/_astro/WebappZenViewlet.PNce4u2T.js +1 -0
- package/dist/client/_astro/{WelcomeViewport.LwKTA6h7.js → WelcomeViewport.CZ6RxGSw.js} +1 -1
- package/dist/client/_astro/{agentIdentityCredentialService.BtKVsl2C.js → agentIdentityCredentialService.BEtZzBlO.js} +5 -5
- package/dist/client/_astro/cardTypeDetector.C2HH5RnU.js +1 -0
- package/dist/client/_astro/disposable.BmlxZrDf.js +1 -0
- package/dist/client/_astro/{markdownService.D-tM2RYx.js → markdownService.CpuKl0vp.js} +1 -1
- package/dist/client/_astro/{mcardStore.BiAvqM-D.js → mcardStore.nSWnzeLg.js} +2 -2
- package/dist/client/_astro/mcardVfs.BSdys1Y7.js +3 -0
- package/dist/client/_astro/pathsConfig.CSBBSzwH.js +2 -0
- package/dist/client/_astro/polyfills.Bi7kO8cu.js +1 -0
- package/dist/client/_astro/rendererEventBus.DirFDmGw.js +1 -0
- package/dist/client/_astro/themeStore.BajxvCga.js +1 -0
- package/dist/client/_astro/{tikzCompiler.DFojjdxR.js → tikzCompiler.-fXMNQpz.js} +1 -1
- package/dist/client/_astro/{useMCardHydration.Co47OH3D.js → useMCardHydration.Bjj_N5Gv.js} +1 -1
- package/dist/client/_astro/vendor-ai.D6NcJ6lu.js +69 -0
- package/dist/client/_astro/vendor-clm-kernel.B0kxq3g4.js +108 -0
- package/dist/client/_astro/vfsHandles.D4Pq18pW.js +1 -0
- package/dist/client/_astro/vfsPersistence.DVrd1BZj.js +1 -0
- package/dist/client/_astro/vfsTransactions.DBNtFuRz.js +1 -0
- package/dist/client/_astro/{workspaceStore.CXakha4Y.js → workspaceStore.DUHW2YBc.js} +1 -1
- package/dist/client/js/buffer-polyfill.js +14 -0
- package/dist/server/chunks/{StudioLayout_D163irJ0.mjs → StudioLayout_taayQJ5b.mjs} +2 -2
- package/dist/server/chunks/{_.._ZXsz792-.mjs → _.._CoQKwo62.mjs} +137 -91
- package/dist/server/chunks/{_handle__D_cIJYrU.mjs → _handle__D8dKQPUS.mjs} +3 -3
- package/dist/server/chunks/{cardTypeDetector_CyW1Xnmy.mjs → cardTypeDetector_C55M_HWS.mjs} +9 -0
- package/dist/server/chunks/{cards_B89BvF6W.mjs → cards_rVOc8K6H.mjs} +2 -2
- package/dist/server/chunks/cas_DTxlZ4Le.mjs +68 -0
- package/dist/server/chunks/{dispatch_DOwSKukU.mjs → dispatch_BTW4E_BJ.mjs} +8 -7
- package/dist/server/chunks/{dispatch_CxWKiHpn.mjs → dispatch_MbkljUxD.mjs} +8 -8
- package/dist/server/chunks/{export_DRouradA.mjs → export_DkEwDE2T.mjs} +3 -3
- package/dist/server/chunks/{health_Dfa5I0-X.mjs → health_cRt0M0yu.mjs} +1 -1
- package/dist/server/chunks/{mcard-library_DvPPUs9_.mjs → mcard-library_CLHvyslV.mjs} +1 -1
- package/dist/server/chunks/{mcardVfs_CeezzRvt.mjs → mcardVfs_DvNburKb.mjs} +5 -30
- package/dist/server/chunks/{move__RFvIDkq.mjs → move_DYcaXBLV.mjs} +6 -6
- package/dist/server/chunks/{pathsConfig_CgNYYLVm.mjs → pathsConfig_Dack-p2f.mjs} +13 -3
- package/dist/server/chunks/{proxy_CrWJQIBe.mjs → proxy_CMbbdBPW.mjs} +2 -2
- package/dist/server/chunks/{raw_DzNDaDVP.mjs → raw_C97sJWhg.mjs} +59 -26
- package/dist/server/chunks/{serverBootstrap_XKo2s6Ha.mjs → serverBootstrap_BDdSRIu5.mjs} +2 -2
- package/dist/server/chunks/tree_BwmO-pTe.mjs +186 -0
- package/dist/server/chunks/vfsCore_DIKpk-pk.mjs +98 -0
- package/dist/server/chunks/{vfsTreeScan_CKp7kMt9.mjs → vfsTreeScan_CRoCluPB.mjs} +18 -10
- package/dist/server/chunks/workspaceRoot_CRx3taID.mjs +157 -0
- package/dist/server/chunks/{write_popiFsO7.mjs → write_BLsmsTIx.mjs} +6 -5
- package/dist/server/chunks/{ws-server-init_CkcgcI5V.mjs → ws-server-init_Cfft7U5u.mjs} +343 -298
- package/dist/server/entry.mjs +8 -4
- package/dist/server/entry2.mjs +67 -28
- package/dist/server/virtual_astro_middleware.mjs +2 -2
- package/package.json +2 -2
- package/public/js/buffer-polyfill.js +14 -0
- package/src/components/studio/views/cardViewlets/ClmRegistryComponentViewlet.tsx +133 -0
- package/src/components/studio/views/cardViewlets/DxfViewlet.tsx +230 -0
- package/src/components/studio/views/cardViewlets/VideoPlayerViewlet.tsx +4 -4
- package/src/components/studio/views/cardViewlets/coreViewletDefs.ts +2 -2
- package/src/components/studio/views/cardViewlets/documents/AudioPlayerViewlet.tsx +15 -3
- package/src/components/studio/views/cardViewlets/documents/PdfViewlet.tsx +25 -7
- package/src/components/studio/views/cardViewlets/markdown/stages/wikilinkStage.ts +2 -1
- package/src/components/studio/views/cardViewlets/mediaViewletDefs.ts +21 -1
- package/src/components/studio/views/cardViewlets/webapp/WebappCanvas.tsx +40 -15
- package/src/components/studio/views/cardViewlets/webapp/WebappDevicePresetBar.tsx +108 -0
- package/src/components/studio/views/cardViewlets/webapp/WebappZenViewlet.tsx +23 -30
- package/src/components/studio/views/fileTree/MCardFileTree.tsx +71 -54
- package/src/components/studio/views/fileTree/hooks/useFileTreeSync.ts +0 -1
- package/src/components/studio/views/fileTree/hooks/usePartitionedTrees.ts +68 -23
- package/src/components/studio/views/fileTree/hooks/useSectionAccordion.ts +21 -11
- package/src/components/studio/views/functions/UnifiedFunctionExplorerViewlet.tsx +168 -0
- package/src/components/studio/views/history/HistoryPanel.tsx +110 -0
- package/src/components/studio/views/lineage/LineagePanel.tsx +152 -0
- package/src/components/studio/views/navigation/HandleLineageDrawer.tsx +89 -0
- package/src/components/studio/views/navigation/MultiCardCollectionBrowser.tsx +154 -0
- package/src/components/studio/views/pills/HashPill.tsx +101 -0
- package/src/components/studio/views/residency/ResidencyIndicator.tsx +82 -0
- package/src/config/app_config.json +3 -3
- package/src/core/projection/catalog.ts +105 -0
- package/src/core/projection/collection.ts +148 -0
- package/src/core/projection/handleSubscription.ts +132 -0
- package/src/core/projection/index.ts +4 -0
- package/src/core/projection/selectors.ts +29 -0
- package/src/core/projection/views.ts +242 -0
- package/src/core/refinement/designMetrics.ts +104 -0
- package/src/core/refinement/fibrationProjector.ts +142 -0
- package/src/core/refinement/lagrangianEngine.ts +137 -0
- package/src/core/refinement/refinementCommands.ts +82 -0
- package/src/core/viewport/deviceArchetypeRegistry.ts +177 -0
- package/src/core/viewport/viewportAudit.ts +150 -0
- package/src/edge/storeFilter.d.ts +4 -0
- package/src/edge/storeFilter.js +54 -0
- package/src/edge/storeFilter.ts +52 -0
- package/src/layouts/StudioLayout.astro +1 -0
- package/src/lib/cryptoPolyfill.js +77 -1
- package/src/lib/fsPolyfill.js +65 -0
- package/src/lib/urlPolyfill.js +21 -0
- package/src/lib/zlibPolyfill.js +35 -0
- package/src/packages/mcard-studio/package.json +2 -2
- package/src/packages/mcard-studio/type/legacyMapping.ts +5 -0
- package/src/packages/mcard-studio/viewlets/manifests.ts +2 -0
- package/src/packages/mcard-studio/viewlets/moduleMap.ts +12 -0
- package/src/packages/mcard-studio/viewlets/refinementManifests.ts +114 -0
- package/src/pages/api/dispatch.ts +3 -2
- package/src/pages/api/vfs/cas.ts +114 -0
- package/src/pages/api/vfs/move.ts +5 -5
- package/src/pages/api/vfs/raw.ts +72 -27
- package/src/pages/api/vfs/tree.ts +130 -11
- package/src/pages/api/vfs/write.ts +5 -4
- package/src/pages/index.astro +75 -0
- package/src/server/api/kernelDispatch.ts +8 -8
- package/src/server/artifactCollectionService.ts +4 -7
- package/src/server/artifactRepository.ts +4 -3
- package/src/server/clmRunner.mjs +1 -1
- package/src/server/collectionOwner.mjs +5 -5
- package/src/server/effects/executionPersistenceService.mjs +11 -11
- package/src/server/effects/resultSealingService.mjs +2 -2
- package/src/server/fileIngestService.mjs +21 -9
- package/src/server/fileWatcherService.mjs +4 -1
- package/src/server/handlers/fileChangeHandler.mjs +18 -10
- package/src/server/handlers/saveExecutionLogHandler.mjs +6 -6
- package/src/server/notificationService.mjs +14 -1
- package/src/server/scripts/buildSeedingMemory.mjs +3 -3
- package/src/server/serverMemoryRepository.ts +41 -59
- package/src/server/vfsTreeScan.ts +16 -10
- package/src/server/workspaceRoot.ts +143 -5
- package/src/services/cardTypeDetector.ts +4 -0
- package/src/services/databaseSyncService.ts +30 -46
- package/src/services/inBrowserLlm/engines/litertEngine.ts +1 -1
- package/src/services/namespaceProtocolClient.ts +221 -0
- package/src/services/renderers/pcard/RendererPCardRegistry.ts +4 -66
- package/src/services/renderers/pcard/modalitySpecs.ts +125 -0
- package/src/services/renderers/pcard/types.ts +7 -1
- package/src/services/renderers/rendererEventBus.ts +5 -3
- package/src/services/unifiedFunctionExecutionService.ts +145 -0
- package/src/services/vfs/vfsCore.ts +12 -1
- package/src/services/vfs/vfsMigration.ts +95 -0
- package/src/services/vfs/vfsMutations.ts +17 -35
- package/src/services/vfs/vfsPersistence.ts +19 -24
- package/src/services/vfs/vfsSync.ts +55 -17
- package/src/services/vfs/vfsVersions.ts +23 -34
- package/src/services/workbenchExecutionPolicy.ts +183 -0
- package/src/stores/mcardCollectionStore.ts +2 -0
- package/src/styles/dockview.css +34 -0
- package/src/ui/viewlets/FibrationRefinementViewlet.tsx +155 -0
- package/src/ui/viewlets/PetriConformanceViewlet.tsx +166 -0
- package/src/ui/viewlets/ResponsiveViewportLabViewlet.tsx +175 -0
- package/src/ui/viewlets/SprintGovernanceViewlet.tsx +176 -0
- package/src/ui/viewlets/viewletFocus.ts +35 -0
- package/src/ui/viewlets/viewportLabParts.tsx +190 -0
- package/dist/client/_astro/ClmPcardViewlet.DW5Yft0E.js +0 -3
- package/dist/client/_astro/D3GraphViewlet.DAjPz1DP.js +0 -2
- package/dist/client/_astro/DockviewSpatialWorkbench.DyQjSoHd.js +0 -12
- package/dist/client/_astro/DocumentViewlets.Dm_GL3AL.js +0 -2
- package/dist/client/_astro/ExcalidrawWhiteboardViewlet.DrlW7B6G.js +0 -1
- package/dist/client/_astro/HeadMeta.astro_astro_type_script_index_0_lang.DGXU-3Lu.js +0 -1
- package/dist/client/_astro/KoishiChatViewlet.B0eDEMnT.js +0 -16
- package/dist/client/_astro/MCardLibraryHarness.CUJLJFBt.js +0 -2
- package/dist/client/_astro/PCardRendererBridge.BnyaE05I.js +0 -1
- package/dist/client/_astro/RendererPCardRegistry.CLr4j1Ub.js +0 -1
- package/dist/client/_astro/StudioWorkbench.CF0SOYwy.js +0 -7
- package/dist/client/_astro/VideoPlayerViewlet.DoSYmmoQ.js +0 -1
- package/dist/client/_astro/WebappZenViewlet.CQW50OhX.js +0 -1
- package/dist/client/_astro/cardTypeDetector.C9kGObMh.js +0 -1
- package/dist/client/_astro/disposable.66apX1Q2.js +0 -1
- package/dist/client/_astro/empty.DOwCrGXH.js +0 -1
- package/dist/client/_astro/mcardVfs.Bj-RA0p7.js +0 -2
- package/dist/client/_astro/path.CR60mj9W.js +0 -1
- package/dist/client/_astro/pathsConfig.D0hV34p7.js +0 -2
- package/dist/client/_astro/polyfills.DcBkS56X.js +0 -1
- package/dist/client/_astro/rendererEventBus.CyFnSRLk.js +0 -1
- package/dist/client/_astro/themeStore.zUMFLo3Q.js +0 -1
- package/dist/client/_astro/vendor-ai.CZe7UVVK.js +0 -69
- package/dist/client/_astro/vfsHandles.B-nczBRy.js +0 -1
- package/dist/client/_astro/vfsPersistence.D6zRzVML.js +0 -1
- package/dist/client/_astro/vfsTransactions.04mkEHxD.js +0 -1
- package/dist/server/chunks/cryptoPolyfill_99rxUwYC.mjs +0 -180
- package/dist/server/chunks/kernelHash_DRaj51hY.mjs +0 -5
- package/dist/server/chunks/tree_CE2BhvyJ.mjs +0 -76
- package/dist/server/chunks/vfsCore_B6nCiBl5.mjs +0 -21
- package/dist/server/chunks/workspaceRoot_DVSUbYkd.mjs +0 -71
- package/src/server/kernelHash.ts +0 -22
- package/src/server/storage/cardCollection.ts +0 -94
- package/src/server/storage/index.ts +0 -3
- package/src/server/storage/mcard.ts +0 -99
- package/src/server/storage/sqliteNodeEngine.ts +0 -121
|
@@ -1,19 +1,16 @@
|
|
|
1
|
-
import { a as resolveServerConfig, i as PENDING_NOTIFICATION_LIMIT, r as CLM_RUNNER_TIMEOUT_MS } from "./
|
|
2
|
-
import { t as PATHS } from "./
|
|
3
|
-
import
|
|
4
|
-
import { n as cryptoPolyfill } from "./cryptoPolyfill_99rxUwYC.mjs";
|
|
5
|
-
import fs from "node:fs";
|
|
1
|
+
import { a as resolveServerConfig, i as PENDING_NOTIFICATION_LIMIT, r as CLM_RUNNER_TIMEOUT_MS } from "./serverBootstrap_BDdSRIu5.mjs";
|
|
2
|
+
import { t as PATHS } from "./pathsConfig_Dack-p2f.mjs";
|
|
3
|
+
import "node:fs";
|
|
6
4
|
import path from "node:path";
|
|
7
5
|
import { cpSync, existsSync as existsSync$1, mkdirSync as mkdirSync$1, watch } from "fs";
|
|
8
6
|
import path$1 from "path";
|
|
9
|
-
import { NodeSqliteBackend } from "clm-kernel";
|
|
7
|
+
import { GATEWAY_METHODS, MCard, MCardCollection, NodeSqliteBackend, computeHash, createRecord, formatNotification, qualify } from "clm-kernel";
|
|
10
8
|
import fs$2 from "node:fs/promises";
|
|
11
9
|
import { execFile } from "node:child_process";
|
|
12
10
|
import "dotenv/config";
|
|
13
11
|
import { WebSocketServer } from "ws";
|
|
14
12
|
import webpush from "web-push";
|
|
15
13
|
import http, { createServer } from "http";
|
|
16
|
-
import { DatabaseSync } from "node:sqlite";
|
|
17
14
|
import os from "os";
|
|
18
15
|
import { promisify } from "node:util";
|
|
19
16
|
import vm from "node:vm";
|
|
@@ -207,6 +204,13 @@ function createNotificationService({ clients, pushSubscriptions, pendingNotifica
|
|
|
207
204
|
}
|
|
208
205
|
return results;
|
|
209
206
|
}
|
|
207
|
+
function broadcastRaw(rawMessage) {
|
|
208
|
+
for (const [clientId, client] of clients) if (client && client.ws && client.ws.readyState === 1) try {
|
|
209
|
+
client.ws.send(rawMessage);
|
|
210
|
+
} catch (e) {
|
|
211
|
+
console.error("[Notify] broadcastRaw error:", e);
|
|
212
|
+
}
|
|
213
|
+
}
|
|
210
214
|
return {
|
|
211
215
|
NotificationPriority,
|
|
212
216
|
sendNotification,
|
|
@@ -214,261 +218,11 @@ function createNotificationService({ clients, pushSubscriptions, pendingNotifica
|
|
|
214
218
|
storePendingNotification,
|
|
215
219
|
deliverPendingNotifications,
|
|
216
220
|
broadcastToAll,
|
|
217
|
-
broadcastToChannel
|
|
221
|
+
broadcastToChannel,
|
|
222
|
+
broadcastRaw
|
|
218
223
|
};
|
|
219
224
|
}
|
|
220
225
|
//#endregion
|
|
221
|
-
//#region src/server/storage/mcard.ts
|
|
222
|
-
/**
|
|
223
|
-
* Sovereign MCard Data Container (Layer 0 Monad)
|
|
224
|
-
* Backed by canonical clm-kernel cryptographic hashing and domain contracts.
|
|
225
|
-
*/
|
|
226
|
-
var MCard = class MCard {
|
|
227
|
-
content;
|
|
228
|
-
hash;
|
|
229
|
-
g_time;
|
|
230
|
-
contentType;
|
|
231
|
-
hashFunction;
|
|
232
|
-
constructor(content, hash, g_time, contentType = "text/plain", hashFunction = "sha256") {
|
|
233
|
-
this.content = content;
|
|
234
|
-
this.hash = hash;
|
|
235
|
-
this.g_time = g_time;
|
|
236
|
-
this.contentType = contentType;
|
|
237
|
-
this.hashFunction = hashFunction;
|
|
238
|
-
Object.freeze(this);
|
|
239
|
-
}
|
|
240
|
-
static async create(content, hashAlgorithm = "sha256") {
|
|
241
|
-
let bytes;
|
|
242
|
-
let isText = false;
|
|
243
|
-
if (typeof content === "string") {
|
|
244
|
-
bytes = new TextEncoder().encode(content);
|
|
245
|
-
isText = true;
|
|
246
|
-
} else if (Buffer.isBuffer(content)) bytes = new Uint8Array(content.buffer, content.byteOffset, content.byteLength);
|
|
247
|
-
else if (content instanceof Uint8Array) bytes = content;
|
|
248
|
-
else {
|
|
249
|
-
bytes = new TextEncoder().encode(String(content ?? ""));
|
|
250
|
-
isText = true;
|
|
251
|
-
}
|
|
252
|
-
const hash = computeSha256(bytes);
|
|
253
|
-
const g_time = (/* @__PURE__ */ new Date()).toISOString();
|
|
254
|
-
return new MCard(bytes, hash, g_time, isText ? "text/plain" : "application/octet-stream", hashAlgorithm);
|
|
255
|
-
}
|
|
256
|
-
static fromData(content, hash, g_time) {
|
|
257
|
-
let bytes;
|
|
258
|
-
if (typeof content === "string") bytes = new TextEncoder().encode(content);
|
|
259
|
-
else if (Buffer.isBuffer(content)) bytes = new Uint8Array(content.buffer, content.byteOffset, content.byteLength);
|
|
260
|
-
else if (content instanceof Uint8Array) bytes = content;
|
|
261
|
-
else bytes = new TextEncoder().encode(String(content ?? ""));
|
|
262
|
-
return new MCard(bytes, hash, g_time);
|
|
263
|
-
}
|
|
264
|
-
getContent() {
|
|
265
|
-
return this.content;
|
|
266
|
-
}
|
|
267
|
-
getContentAsText() {
|
|
268
|
-
return new TextDecoder().decode(this.content);
|
|
269
|
-
}
|
|
270
|
-
toObject() {
|
|
271
|
-
return {
|
|
272
|
-
hash: this.hash,
|
|
273
|
-
content: this.getContentAsText(),
|
|
274
|
-
g_time: this.g_time,
|
|
275
|
-
contentType: this.contentType,
|
|
276
|
-
hashFunction: this.hashFunction
|
|
277
|
-
};
|
|
278
|
-
}
|
|
279
|
-
toJSON() {
|
|
280
|
-
return {
|
|
281
|
-
hash: this.hash,
|
|
282
|
-
content: this.getContentAsText(),
|
|
283
|
-
g_time: this.g_time
|
|
284
|
-
};
|
|
285
|
-
}
|
|
286
|
-
};
|
|
287
|
-
//#endregion
|
|
288
|
-
//#region src/server/storage/sqliteNodeEngine.ts
|
|
289
|
-
/**
|
|
290
|
-
* Sovereign Native SQLite Engine for Node.js
|
|
291
|
-
* Backed by canonical clm-kernel NodeSqliteBackend over Node 22 DatabaseSync.
|
|
292
|
-
*/
|
|
293
|
-
var SqliteNodeEngine = class SqliteNodeEngine {
|
|
294
|
-
backend;
|
|
295
|
-
rawDb;
|
|
296
|
-
dbPath;
|
|
297
|
-
constructor(dbPath = ":memory:", dbInstance) {
|
|
298
|
-
this.dbPath = dbPath;
|
|
299
|
-
if (dbInstance) this.rawDb = dbInstance;
|
|
300
|
-
else {
|
|
301
|
-
if (dbPath !== ":memory:") {
|
|
302
|
-
const dir = path.dirname(dbPath);
|
|
303
|
-
if (!fs.existsSync(dir)) fs.mkdirSync(dir, { recursive: true });
|
|
304
|
-
}
|
|
305
|
-
this.rawDb = new DatabaseSync(dbPath);
|
|
306
|
-
}
|
|
307
|
-
this.backend = new NodeSqliteBackend(this.rawDb);
|
|
308
|
-
}
|
|
309
|
-
static async create(dbPath = ":memory:") {
|
|
310
|
-
return new SqliteNodeEngine(dbPath);
|
|
311
|
-
}
|
|
312
|
-
getDbPath() {
|
|
313
|
-
return this.dbPath;
|
|
314
|
-
}
|
|
315
|
-
getBackend() {
|
|
316
|
-
return this.backend;
|
|
317
|
-
}
|
|
318
|
-
getRawDb() {
|
|
319
|
-
return this.rawDb;
|
|
320
|
-
}
|
|
321
|
-
async add(card) {
|
|
322
|
-
const content = card.content instanceof Uint8Array ? card.content : Buffer.from(card.content);
|
|
323
|
-
const gTime = card.g_time || (/* @__PURE__ */ new Date()).toISOString();
|
|
324
|
-
this.rawDb.prepare("INSERT OR REPLACE INTO card (hash, content, g_time) VALUES (?, ?, ?)").run(card.hash, content, gTime);
|
|
325
|
-
return card.hash;
|
|
326
|
-
}
|
|
327
|
-
async get(hash) {
|
|
328
|
-
const row = this.rawDb.prepare("SELECT hash, content, g_time FROM card WHERE hash = ?").get(hash);
|
|
329
|
-
if (!row) return null;
|
|
330
|
-
const raw = row.content;
|
|
331
|
-
const bytes = Buffer.isBuffer(raw) ? new Uint8Array(raw.buffer, raw.byteOffset, raw.byteLength) : raw;
|
|
332
|
-
return MCard.fromData(bytes, String(row.hash), String(row.g_time));
|
|
333
|
-
}
|
|
334
|
-
async delete(hash) {
|
|
335
|
-
this.rawDb.prepare("DELETE FROM card WHERE hash = ?").run(hash);
|
|
336
|
-
}
|
|
337
|
-
async count() {
|
|
338
|
-
return this.backend.count();
|
|
339
|
-
}
|
|
340
|
-
async registerHandle(handle, hash) {
|
|
341
|
-
this.backend.registerHandle(handle, hash);
|
|
342
|
-
}
|
|
343
|
-
async resolveHandle(handle) {
|
|
344
|
-
const resolved = this.backend.resolveHandle(handle);
|
|
345
|
-
return resolved ? resolved.asHex ? resolved.asHex() : String(resolved) : null;
|
|
346
|
-
}
|
|
347
|
-
async getByHandle(handle) {
|
|
348
|
-
const hash = await this.resolveHandle(handle);
|
|
349
|
-
return hash ? this.get(hash) : null;
|
|
350
|
-
}
|
|
351
|
-
async updateHandle(handle, newHashOrCard) {
|
|
352
|
-
let newHash;
|
|
353
|
-
if (typeof newHashOrCard === "string") newHash = newHashOrCard;
|
|
354
|
-
else {
|
|
355
|
-
newHash = newHashOrCard.hash;
|
|
356
|
-
await this.add(newHashOrCard);
|
|
357
|
-
}
|
|
358
|
-
this.backend.registerHandle(handle, newHash);
|
|
359
|
-
return newHash;
|
|
360
|
-
}
|
|
361
|
-
async removeHandle(handle) {
|
|
362
|
-
this.rawDb.prepare("DELETE FROM handle_history WHERE handle = ?").run(handle);
|
|
363
|
-
this.rawDb.prepare("DELETE FROM handle_registry WHERE handle = ?").run(handle);
|
|
364
|
-
}
|
|
365
|
-
async getAllHandles() {
|
|
366
|
-
return this.rawDb.prepare("SELECT handle, current_hash as hash FROM handle_registry").all().map((r) => ({
|
|
367
|
-
handle: String(r.handle),
|
|
368
|
-
hash: String(r.hash)
|
|
369
|
-
}));
|
|
370
|
-
}
|
|
371
|
-
async getHandleHistory(handle) {
|
|
372
|
-
return this.rawDb.prepare("SELECT previous_hash as previousHash, changed_at as changedAt FROM handle_history WHERE handle = ? ORDER BY changed_at DESC").all(handle).map((r) => ({
|
|
373
|
-
previousHash: String(r.previousHash),
|
|
374
|
-
changedAt: String(r.changedAt)
|
|
375
|
-
}));
|
|
376
|
-
}
|
|
377
|
-
async deleteHistoryEntry(handle, previousHash) {
|
|
378
|
-
this.rawDb.prepare("DELETE FROM handle_history WHERE rowid IN (SELECT rowid FROM handle_history WHERE handle = ? AND previous_hash = ? ORDER BY changed_at DESC LIMIT 1)").run(handle, previousHash);
|
|
379
|
-
}
|
|
380
|
-
async renameHandle(oldHandle, newHandle) {
|
|
381
|
-
this.rawDb.exec("BEGIN TRANSACTION;");
|
|
382
|
-
try {
|
|
383
|
-
this.rawDb.prepare("UPDATE handle_registry SET handle = ? WHERE handle = ?").run(newHandle, oldHandle);
|
|
384
|
-
this.rawDb.prepare("UPDATE handle_history SET handle = ? WHERE handle = ?").run(newHandle, oldHandle);
|
|
385
|
-
this.rawDb.exec("COMMIT;");
|
|
386
|
-
} catch (err) {
|
|
387
|
-
this.rawDb.exec("ROLLBACK;");
|
|
388
|
-
throw err;
|
|
389
|
-
}
|
|
390
|
-
}
|
|
391
|
-
close() {
|
|
392
|
-
this.backend.close();
|
|
393
|
-
}
|
|
394
|
-
};
|
|
395
|
-
//#endregion
|
|
396
|
-
//#region src/server/storage/cardCollection.ts
|
|
397
|
-
/**
|
|
398
|
-
* Sovereign CardCollection
|
|
399
|
-
*
|
|
400
|
-
* Provides a high-level MCard & Handle collection API over a SqliteNodeEngine backend.
|
|
401
|
-
* Replaces mcard-js CardCollection with zero external dependencies.
|
|
402
|
-
*/
|
|
403
|
-
var CardCollection = class {
|
|
404
|
-
engine;
|
|
405
|
-
constructor(engine) {
|
|
406
|
-
this.engine = engine;
|
|
407
|
-
}
|
|
408
|
-
getEngine() {
|
|
409
|
-
return this.engine;
|
|
410
|
-
}
|
|
411
|
-
async add(card) {
|
|
412
|
-
return this.engine.add(card);
|
|
413
|
-
}
|
|
414
|
-
async get(hash) {
|
|
415
|
-
return this.engine.get(hash);
|
|
416
|
-
}
|
|
417
|
-
async delete(hash) {
|
|
418
|
-
return this.engine.delete(hash);
|
|
419
|
-
}
|
|
420
|
-
async count() {
|
|
421
|
-
return this.engine.count();
|
|
422
|
-
}
|
|
423
|
-
/**
|
|
424
|
-
* Store an MCard and register its handle in handle_registry.
|
|
425
|
-
* Supports flexible argument ordering (card, handle) or (handle, card).
|
|
426
|
-
*/
|
|
427
|
-
async addWithHandle(arg1, arg2) {
|
|
428
|
-
let card;
|
|
429
|
-
let handle;
|
|
430
|
-
if (arg1 && typeof arg1 === "object" && ("hash" in arg1 || arg1 instanceof MCard)) {
|
|
431
|
-
card = arg1;
|
|
432
|
-
handle = String(arg2);
|
|
433
|
-
} else if (arg2 && typeof arg2 === "object" && ("hash" in arg2 || arg2 instanceof MCard)) {
|
|
434
|
-
handle = String(arg1);
|
|
435
|
-
card = arg2;
|
|
436
|
-
} else if (typeof arg1 === "string" && (typeof arg2 === "string" || arg2 instanceof Uint8Array || Buffer.isBuffer(arg2))) {
|
|
437
|
-
handle = arg1;
|
|
438
|
-
card = await MCard.create(arg2);
|
|
439
|
-
} else {
|
|
440
|
-
card = await MCard.create(arg1);
|
|
441
|
-
handle = String(arg2);
|
|
442
|
-
}
|
|
443
|
-
await this.engine.add(card);
|
|
444
|
-
await this.engine.registerHandle(handle, card.hash);
|
|
445
|
-
}
|
|
446
|
-
async resolveHandle(handle) {
|
|
447
|
-
return this.engine.resolveHandle(handle);
|
|
448
|
-
}
|
|
449
|
-
async updateHandle(handle, cardOrHash) {
|
|
450
|
-
return this.engine.updateHandle(handle, cardOrHash);
|
|
451
|
-
}
|
|
452
|
-
async removeHandle(handle) {
|
|
453
|
-
return this.engine.removeHandle(handle);
|
|
454
|
-
}
|
|
455
|
-
async getAllHandles() {
|
|
456
|
-
return this.engine.getAllHandles();
|
|
457
|
-
}
|
|
458
|
-
async getHandleHistory(handle) {
|
|
459
|
-
return this.engine.getHandleHistory(handle);
|
|
460
|
-
}
|
|
461
|
-
async getByHandle(handle) {
|
|
462
|
-
return this.engine.getByHandle(handle);
|
|
463
|
-
}
|
|
464
|
-
async renameHandle(oldHandle, newHandle) {
|
|
465
|
-
return this.engine.renameHandle(oldHandle, newHandle);
|
|
466
|
-
}
|
|
467
|
-
async deleteHistoryEntry(handle, previousHash) {
|
|
468
|
-
return this.engine.deleteHistoryEntry(handle, previousHash);
|
|
469
|
-
}
|
|
470
|
-
};
|
|
471
|
-
//#endregion
|
|
472
226
|
//#region src/server/collectionOwner.mjs
|
|
473
227
|
function createCollectionOwner(dbPath) {
|
|
474
228
|
let collection = null;
|
|
@@ -479,10 +233,10 @@ function createCollectionOwner(dbPath) {
|
|
|
479
233
|
if (useMock) return null;
|
|
480
234
|
console.log(`[WS] Initializing Storage at ${dbPath}`);
|
|
481
235
|
try {
|
|
482
|
-
engine =
|
|
483
|
-
console.log(`[WS]
|
|
236
|
+
engine = new NodeSqliteBackend(dbPath);
|
|
237
|
+
console.log(`[WS] NodeSqliteBackend created OK for ${dbPath}`);
|
|
484
238
|
} catch (err) {
|
|
485
|
-
console.error(`[WS]
|
|
239
|
+
console.error(`[WS] NodeSqliteBackend FAILED for ${dbPath}:`, err);
|
|
486
240
|
console.warn("[WS] Falling back to mock storage (no persistence)");
|
|
487
241
|
useMock = true;
|
|
488
242
|
return null;
|
|
@@ -539,7 +293,7 @@ function createCollectionOwner(dbPath) {
|
|
|
539
293
|
};
|
|
540
294
|
}
|
|
541
295
|
};
|
|
542
|
-
collection = new
|
|
296
|
+
collection = new MCardCollection(e);
|
|
543
297
|
return collection;
|
|
544
298
|
}
|
|
545
299
|
return {
|
|
@@ -577,7 +331,7 @@ var envMaxBytes = typeof import.meta !== "undefined" && Object.assign({
|
|
|
577
331
|
VITE_WS_PORT: "5321",
|
|
578
332
|
VLLM_BASE_URL: "http://10.40.14.68:11437",
|
|
579
333
|
USER: "bkoo",
|
|
580
|
-
PATH: "/Users/bkoo/Documents/Development/GovTech/MCard_TDD/mcard-studio/node_modules/.bin:/Users/bkoo/Documents/Development/GovTech/MCard_TDD/node_modules/.bin:/Users/bkoo/Documents/Development/GovTech/node_modules/.bin:/Users/bkoo/Documents/Development/node_modules/.bin:/Users/bkoo/Documents/node_modules/.bin:/Users/bkoo/node_modules/.bin:/Users/node_modules/.bin:/node_modules/.bin:/
|
|
334
|
+
PATH: "/Users/bkoo/Documents/Development/GovTech/MCard_TDD/mcard-studio/node_modules/.bin:/Users/bkoo/Documents/Development/GovTech/MCard_TDD/node_modules/.bin:/Users/bkoo/Documents/Development/GovTech/node_modules/.bin:/Users/bkoo/Documents/Development/node_modules/.bin:/Users/bkoo/Documents/node_modules/.bin:/Users/bkoo/node_modules/.bin:/Users/node_modules/.bin:/node_modules/.bin:/opt/homebrew/lib/node_modules/npm/node_modules/@npmcli/run-script/lib/node-gyp-bin:/opt/homebrew/bin:/opt/homebrew/sbin:/Users/bkoo/.local/bin:/Users/bkoo/.gemini/antigravity-ide/bin:/Users/bkoo/Library/pnpm/bin:/Users/bkoo/.codeium/windsurf/bin:/Users/bkoo/.nvm/versions/node/v24.21.0/bin:/Users/bkoo/.antigravity-ide/antigravity-ide/bin:/Users/bkoo/.antigravity-ide/antigravity-ide/bin:/Users/bkoo/.opencode/bin:/Users/bkoo/.antigravity-ide/antigravity-ide/bin:/Users/bkoo/.antigravity/antigravity/bin:/Users/bkoo/.opencode/bin:/Users/bkoo/.rd/bin:/Users/bkoo/.antigravity/antigravity/bin:/opt/homebrew/opt/python@3.9/bin:/Users/bkoo/.ghcup/bin:/Users/bkoo/.ghcup/bin:/Users/bkoo/.ghcup/bin:/Users/bkoo/.ghcup/bin:/Users/bkoo/.ghcup/bin:/Users/bkoo/.opam/4.14.1/bin:/opt/homebrew/Caskroom/miniconda/base/condabin:/opt/homebrew/bin:/Users/bkoo/.elan/bin:/opt/homebrew/bin:/opt/homebrew/sbin:/usr/local/bin:/System/Cryptexes/App/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/local/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/appleinternal/bin:/pkg/env/global/bin:/Library/Apple/usr/bin:/Library/TeX/texbin:/opt/homebrew/bin:/opt/homebrew/sbin:/Users/bkoo/.local/bin:/Users/bkoo/.cargo/bin",
|
|
581
335
|
_: "/Users/bkoo/Documents/Development/GovTech/MCard_TDD/node_modules/.bin/astro"
|
|
582
336
|
}) && Object.assign({
|
|
583
337
|
"ASSETS_PREFIX": void 0,
|
|
@@ -606,7 +360,7 @@ var envMaxBytes = typeof import.meta !== "undefined" && Object.assign({
|
|
|
606
360
|
VITE_WS_PORT: "5321",
|
|
607
361
|
VLLM_BASE_URL: "http://10.40.14.68:11437",
|
|
608
362
|
USER: "bkoo",
|
|
609
|
-
PATH: "/Users/bkoo/Documents/Development/GovTech/MCard_TDD/mcard-studio/node_modules/.bin:/Users/bkoo/Documents/Development/GovTech/MCard_TDD/node_modules/.bin:/Users/bkoo/Documents/Development/GovTech/node_modules/.bin:/Users/bkoo/Documents/Development/node_modules/.bin:/Users/bkoo/Documents/node_modules/.bin:/Users/bkoo/node_modules/.bin:/Users/node_modules/.bin:/node_modules/.bin:/
|
|
363
|
+
PATH: "/Users/bkoo/Documents/Development/GovTech/MCard_TDD/mcard-studio/node_modules/.bin:/Users/bkoo/Documents/Development/GovTech/MCard_TDD/node_modules/.bin:/Users/bkoo/Documents/Development/GovTech/node_modules/.bin:/Users/bkoo/Documents/Development/node_modules/.bin:/Users/bkoo/Documents/node_modules/.bin:/Users/bkoo/node_modules/.bin:/Users/node_modules/.bin:/node_modules/.bin:/opt/homebrew/lib/node_modules/npm/node_modules/@npmcli/run-script/lib/node-gyp-bin:/opt/homebrew/bin:/opt/homebrew/sbin:/Users/bkoo/.local/bin:/Users/bkoo/.gemini/antigravity-ide/bin:/Users/bkoo/Library/pnpm/bin:/Users/bkoo/.codeium/windsurf/bin:/Users/bkoo/.nvm/versions/node/v24.21.0/bin:/Users/bkoo/.antigravity-ide/antigravity-ide/bin:/Users/bkoo/.antigravity-ide/antigravity-ide/bin:/Users/bkoo/.opencode/bin:/Users/bkoo/.antigravity-ide/antigravity-ide/bin:/Users/bkoo/.antigravity/antigravity/bin:/Users/bkoo/.opencode/bin:/Users/bkoo/.rd/bin:/Users/bkoo/.antigravity/antigravity/bin:/opt/homebrew/opt/python@3.9/bin:/Users/bkoo/.ghcup/bin:/Users/bkoo/.ghcup/bin:/Users/bkoo/.ghcup/bin:/Users/bkoo/.ghcup/bin:/Users/bkoo/.ghcup/bin:/Users/bkoo/.opam/4.14.1/bin:/opt/homebrew/Caskroom/miniconda/base/condabin:/opt/homebrew/bin:/Users/bkoo/.elan/bin:/opt/homebrew/bin:/opt/homebrew/sbin:/usr/local/bin:/System/Cryptexes/App/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/local/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/appleinternal/bin:/pkg/env/global/bin:/Library/Apple/usr/bin:/Library/TeX/texbin:/opt/homebrew/bin:/opt/homebrew/sbin:/Users/bkoo/.local/bin:/Users/bkoo/.cargo/bin",
|
|
610
364
|
_: "/Users/bkoo/Documents/Development/GovTech/MCard_TDD/node_modules/.bin/astro"
|
|
611
365
|
}).PUBLIC_MCARD_MAX_SIZE_BYTES ? parseInt(Object.assign({
|
|
612
366
|
"ASSETS_PREFIX": void 0,
|
|
@@ -635,7 +389,7 @@ var envMaxBytes = typeof import.meta !== "undefined" && Object.assign({
|
|
|
635
389
|
VITE_WS_PORT: "5321",
|
|
636
390
|
VLLM_BASE_URL: "http://10.40.14.68:11437",
|
|
637
391
|
USER: "bkoo",
|
|
638
|
-
PATH: "/Users/bkoo/Documents/Development/GovTech/MCard_TDD/mcard-studio/node_modules/.bin:/Users/bkoo/Documents/Development/GovTech/MCard_TDD/node_modules/.bin:/Users/bkoo/Documents/Development/GovTech/node_modules/.bin:/Users/bkoo/Documents/Development/node_modules/.bin:/Users/bkoo/Documents/node_modules/.bin:/Users/bkoo/node_modules/.bin:/Users/node_modules/.bin:/node_modules/.bin:/
|
|
392
|
+
PATH: "/Users/bkoo/Documents/Development/GovTech/MCard_TDD/mcard-studio/node_modules/.bin:/Users/bkoo/Documents/Development/GovTech/MCard_TDD/node_modules/.bin:/Users/bkoo/Documents/Development/GovTech/node_modules/.bin:/Users/bkoo/Documents/Development/node_modules/.bin:/Users/bkoo/Documents/node_modules/.bin:/Users/bkoo/node_modules/.bin:/Users/node_modules/.bin:/node_modules/.bin:/opt/homebrew/lib/node_modules/npm/node_modules/@npmcli/run-script/lib/node-gyp-bin:/opt/homebrew/bin:/opt/homebrew/sbin:/Users/bkoo/.local/bin:/Users/bkoo/.gemini/antigravity-ide/bin:/Users/bkoo/Library/pnpm/bin:/Users/bkoo/.codeium/windsurf/bin:/Users/bkoo/.nvm/versions/node/v24.21.0/bin:/Users/bkoo/.antigravity-ide/antigravity-ide/bin:/Users/bkoo/.antigravity-ide/antigravity-ide/bin:/Users/bkoo/.opencode/bin:/Users/bkoo/.antigravity-ide/antigravity-ide/bin:/Users/bkoo/.antigravity/antigravity/bin:/Users/bkoo/.opencode/bin:/Users/bkoo/.rd/bin:/Users/bkoo/.antigravity/antigravity/bin:/opt/homebrew/opt/python@3.9/bin:/Users/bkoo/.ghcup/bin:/Users/bkoo/.ghcup/bin:/Users/bkoo/.ghcup/bin:/Users/bkoo/.ghcup/bin:/Users/bkoo/.ghcup/bin:/Users/bkoo/.opam/4.14.1/bin:/opt/homebrew/Caskroom/miniconda/base/condabin:/opt/homebrew/bin:/Users/bkoo/.elan/bin:/opt/homebrew/bin:/opt/homebrew/sbin:/usr/local/bin:/System/Cryptexes/App/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/local/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/appleinternal/bin:/pkg/env/global/bin:/Library/Apple/usr/bin:/Library/TeX/texbin:/opt/homebrew/bin:/opt/homebrew/sbin:/Users/bkoo/.local/bin:/Users/bkoo/.cargo/bin",
|
|
639
393
|
_: "/Users/bkoo/Documents/Development/GovTech/MCard_TDD/node_modules/.bin/astro"
|
|
640
394
|
}).PUBLIC_MCARD_MAX_SIZE_BYTES, 10) : 157286400;
|
|
641
395
|
var SIZE_LIMITS = {
|
|
@@ -698,6 +452,258 @@ function classifyNetwork(ip) {
|
|
|
698
452
|
return "public";
|
|
699
453
|
}
|
|
700
454
|
//#endregion
|
|
455
|
+
//#region src/lib/cryptoPolyfill.js
|
|
456
|
+
/**
|
|
457
|
+
* Browser-safe isomorphic crypto polyfill for Vite & Rollup client bundles.
|
|
458
|
+
* Provides createHash, randomUUID, randomBytes, and getRandomValues in browser context.
|
|
459
|
+
*/
|
|
460
|
+
function sha256Bytes(input) {
|
|
461
|
+
const bytes = typeof input === "string" ? new TextEncoder().encode(input) : input;
|
|
462
|
+
const K = [
|
|
463
|
+
1116352408,
|
|
464
|
+
1899447441,
|
|
465
|
+
3049323471,
|
|
466
|
+
3921009573,
|
|
467
|
+
961987163,
|
|
468
|
+
1508970993,
|
|
469
|
+
2453635748,
|
|
470
|
+
2870763221,
|
|
471
|
+
3624381080,
|
|
472
|
+
310598401,
|
|
473
|
+
607225278,
|
|
474
|
+
1426881987,
|
|
475
|
+
1925078388,
|
|
476
|
+
2162078206,
|
|
477
|
+
2614888103,
|
|
478
|
+
3248222580,
|
|
479
|
+
3835390401,
|
|
480
|
+
4022224774,
|
|
481
|
+
264347078,
|
|
482
|
+
604807628,
|
|
483
|
+
770255983,
|
|
484
|
+
1249150122,
|
|
485
|
+
1555081692,
|
|
486
|
+
1996064986,
|
|
487
|
+
2554220882,
|
|
488
|
+
2821834349,
|
|
489
|
+
2952996808,
|
|
490
|
+
3210313671,
|
|
491
|
+
3336571891,
|
|
492
|
+
3584528711,
|
|
493
|
+
113926993,
|
|
494
|
+
338241895,
|
|
495
|
+
666307205,
|
|
496
|
+
773529912,
|
|
497
|
+
1294757372,
|
|
498
|
+
1396182291,
|
|
499
|
+
1695183700,
|
|
500
|
+
1986661051,
|
|
501
|
+
2177026350,
|
|
502
|
+
2456956037,
|
|
503
|
+
2730485921,
|
|
504
|
+
2820302411,
|
|
505
|
+
3259730800,
|
|
506
|
+
3345764771,
|
|
507
|
+
3516065817,
|
|
508
|
+
3600352804,
|
|
509
|
+
4094571909,
|
|
510
|
+
275423344,
|
|
511
|
+
430227734,
|
|
512
|
+
506948616,
|
|
513
|
+
659060556,
|
|
514
|
+
883997877,
|
|
515
|
+
958139571,
|
|
516
|
+
1322822218,
|
|
517
|
+
1537002063,
|
|
518
|
+
1747873779,
|
|
519
|
+
1955562222,
|
|
520
|
+
2024104815,
|
|
521
|
+
2227730452,
|
|
522
|
+
2361852424,
|
|
523
|
+
2428436474,
|
|
524
|
+
2756734187,
|
|
525
|
+
3204031479,
|
|
526
|
+
3329325298
|
|
527
|
+
];
|
|
528
|
+
let h0 = 1779033703, h1 = 3144134277, h2 = 1013904242, h3 = 2773480762, h4 = 1359893119, h5 = 2600822924, h6 = 528734635, h7 = 1541459225;
|
|
529
|
+
const len = bytes.length;
|
|
530
|
+
const bitLen = len * 8;
|
|
531
|
+
const totalLen = len + (len % 64 < 56 ? 56 - len % 64 : 120 - len % 64) + 8;
|
|
532
|
+
const padded = new Uint8Array(totalLen);
|
|
533
|
+
padded.set(bytes);
|
|
534
|
+
padded[len] = 128;
|
|
535
|
+
const view = new DataView(padded.buffer);
|
|
536
|
+
view.setBigUint64(totalLen - 8, BigInt(bitLen), false);
|
|
537
|
+
const w = /* @__PURE__ */ new Uint32Array(64);
|
|
538
|
+
const rotr = (x, n) => x >>> n | x << 32 - n;
|
|
539
|
+
for (let i = 0; i < totalLen; i += 64) {
|
|
540
|
+
for (let t = 0; t < 16; t++) w[t] = view.getUint32(i + t * 4, false);
|
|
541
|
+
for (let t = 16; t < 64; t++) {
|
|
542
|
+
const s0 = rotr(w[t - 15], 7) ^ rotr(w[t - 15], 18) ^ w[t - 15] >>> 3;
|
|
543
|
+
const s1 = rotr(w[t - 2], 17) ^ rotr(w[t - 2], 19) ^ w[t - 2] >>> 10;
|
|
544
|
+
w[t] = w[t - 16] + s0 + w[t - 7] + s1 | 0;
|
|
545
|
+
}
|
|
546
|
+
let a = h0, b = h1, c = h2, d = h3, e = h4, f = h5, g = h6, h = h7;
|
|
547
|
+
for (let t = 0; t < 64; t++) {
|
|
548
|
+
const S1 = rotr(e, 6) ^ rotr(e, 11) ^ rotr(e, 25);
|
|
549
|
+
const ch = e & f ^ ~e & g;
|
|
550
|
+
const temp1 = h + S1 + ch + K[t] + w[t] | 0;
|
|
551
|
+
const temp2 = (rotr(a, 2) ^ rotr(a, 13) ^ rotr(a, 22)) + (a & b ^ a & c ^ b & c) | 0;
|
|
552
|
+
h = g;
|
|
553
|
+
g = f;
|
|
554
|
+
f = e;
|
|
555
|
+
e = d + temp1 | 0;
|
|
556
|
+
d = c;
|
|
557
|
+
c = b;
|
|
558
|
+
b = a;
|
|
559
|
+
a = temp1 + temp2 | 0;
|
|
560
|
+
}
|
|
561
|
+
h0 = h0 + a | 0;
|
|
562
|
+
h1 = h1 + b | 0;
|
|
563
|
+
h2 = h2 + c | 0;
|
|
564
|
+
h3 = h3 + d | 0;
|
|
565
|
+
h4 = h4 + e | 0;
|
|
566
|
+
h5 = h5 + f | 0;
|
|
567
|
+
h6 = h6 + g | 0;
|
|
568
|
+
h7 = h7 + h | 0;
|
|
569
|
+
}
|
|
570
|
+
const out = /* @__PURE__ */ new Uint8Array(32);
|
|
571
|
+
const outView = new DataView(out.buffer);
|
|
572
|
+
outView.setUint32(0, h0, false);
|
|
573
|
+
outView.setUint32(4, h1, false);
|
|
574
|
+
outView.setUint32(8, h2, false);
|
|
575
|
+
outView.setUint32(12, h3, false);
|
|
576
|
+
outView.setUint32(16, h4, false);
|
|
577
|
+
outView.setUint32(20, h5, false);
|
|
578
|
+
outView.setUint32(24, h6, false);
|
|
579
|
+
outView.setUint32(28, h7, false);
|
|
580
|
+
return out;
|
|
581
|
+
}
|
|
582
|
+
var Hash = class {
|
|
583
|
+
constructor(algorithm) {
|
|
584
|
+
this.algorithm = algorithm;
|
|
585
|
+
this.chunks = [];
|
|
586
|
+
}
|
|
587
|
+
update(data) {
|
|
588
|
+
if (typeof data === "string") this.chunks.push(new TextEncoder().encode(data));
|
|
589
|
+
else if (data instanceof Uint8Array) this.chunks.push(data);
|
|
590
|
+
else if (ArrayBuffer.isView(data)) this.chunks.push(new Uint8Array(data.buffer, data.byteOffset, data.byteLength));
|
|
591
|
+
return this;
|
|
592
|
+
}
|
|
593
|
+
digest(encoding) {
|
|
594
|
+
let totalLen = 0;
|
|
595
|
+
for (const c of this.chunks) totalLen += c.length;
|
|
596
|
+
const merged = new Uint8Array(totalLen);
|
|
597
|
+
let offset = 0;
|
|
598
|
+
for (const c of this.chunks) {
|
|
599
|
+
merged.set(c, offset);
|
|
600
|
+
offset += c.length;
|
|
601
|
+
}
|
|
602
|
+
const hashBytes = sha256Bytes(merged);
|
|
603
|
+
if (encoding === "hex") return Array.from(hashBytes).map((b) => b.toString(16).padStart(2, "0")).join("");
|
|
604
|
+
if (typeof Buffer !== "undefined" && typeof Buffer.from === "function") return Buffer.from(hashBytes);
|
|
605
|
+
return hashBytes;
|
|
606
|
+
}
|
|
607
|
+
};
|
|
608
|
+
function createHash(algorithm) {
|
|
609
|
+
return new Hash(algorithm);
|
|
610
|
+
}
|
|
611
|
+
function randomUUID() {
|
|
612
|
+
if (typeof globalThis !== "undefined" && globalThis.crypto && typeof globalThis.crypto.randomUUID === "function") return globalThis.crypto.randomUUID();
|
|
613
|
+
return "10000000-1000-4000-8000-100000000000".replace(/[018]/g, (c) => (c ^ crypto.getRandomValues(/* @__PURE__ */ new Uint8Array(1))[0] & 15 >> c / 4).toString(16));
|
|
614
|
+
}
|
|
615
|
+
function getRandomValues(array) {
|
|
616
|
+
if (typeof globalThis !== "undefined" && globalThis.crypto && typeof globalThis.crypto.getRandomValues === "function") return globalThis.crypto.getRandomValues(array);
|
|
617
|
+
for (let i = 0; i < array.length; i++) array[i] = Math.floor(Math.random() * 256);
|
|
618
|
+
return array;
|
|
619
|
+
}
|
|
620
|
+
function randomBytes(size) {
|
|
621
|
+
const bytes = new Uint8Array(size);
|
|
622
|
+
getRandomValues(bytes);
|
|
623
|
+
if (typeof Buffer !== "undefined" && typeof Buffer.from === "function") return Buffer.from(bytes);
|
|
624
|
+
return bytes;
|
|
625
|
+
}
|
|
626
|
+
var webcrypto = typeof globalThis !== "undefined" ? globalThis.crypto : void 0;
|
|
627
|
+
function createPrivateKey(key) {
|
|
628
|
+
return {
|
|
629
|
+
export: () => "",
|
|
630
|
+
type: "private",
|
|
631
|
+
...typeof key === "object" ? key : {}
|
|
632
|
+
};
|
|
633
|
+
}
|
|
634
|
+
function createPublicKey(key) {
|
|
635
|
+
return {
|
|
636
|
+
export: () => "",
|
|
637
|
+
type: "public",
|
|
638
|
+
...typeof key === "object" ? key : {}
|
|
639
|
+
};
|
|
640
|
+
}
|
|
641
|
+
function diffieHellman() {
|
|
642
|
+
return {
|
|
643
|
+
computeSecret: () => /* @__PURE__ */ new Uint8Array(32),
|
|
644
|
+
generateKeys: () => /* @__PURE__ */ new Uint8Array(32)
|
|
645
|
+
};
|
|
646
|
+
}
|
|
647
|
+
function generateKeyPairSync(type, options) {
|
|
648
|
+
return {
|
|
649
|
+
publicKey: createPublicKey({ type }),
|
|
650
|
+
privateKey: createPrivateKey({ type })
|
|
651
|
+
};
|
|
652
|
+
}
|
|
653
|
+
function sign(algorithm, data, key) {
|
|
654
|
+
return /* @__PURE__ */ new Uint8Array(64);
|
|
655
|
+
}
|
|
656
|
+
function verify(algorithm, data, key, signature) {
|
|
657
|
+
return false;
|
|
658
|
+
}
|
|
659
|
+
function createCipheriv() {
|
|
660
|
+
return {
|
|
661
|
+
update: () => /* @__PURE__ */ new Uint8Array(0),
|
|
662
|
+
final: () => /* @__PURE__ */ new Uint8Array(0),
|
|
663
|
+
setAAD: () => {},
|
|
664
|
+
getAuthTag: () => /* @__PURE__ */ new Uint8Array(16)
|
|
665
|
+
};
|
|
666
|
+
}
|
|
667
|
+
function createDecipheriv() {
|
|
668
|
+
return {
|
|
669
|
+
update: () => /* @__PURE__ */ new Uint8Array(0),
|
|
670
|
+
final: () => /* @__PURE__ */ new Uint8Array(0),
|
|
671
|
+
setAAD: () => {},
|
|
672
|
+
setAuthTag: () => {}
|
|
673
|
+
};
|
|
674
|
+
}
|
|
675
|
+
function hkdfSync(digest, ikm, salt, info, keylen) {
|
|
676
|
+
return new Uint8Array(keylen || 32);
|
|
677
|
+
}
|
|
678
|
+
function randomFillSync(buffer, offset = 0, size) {
|
|
679
|
+
const len = size !== void 0 ? size : buffer.length - offset;
|
|
680
|
+
getRandomValues(new Uint8Array(buffer.buffer, buffer.byteOffset + offset, len));
|
|
681
|
+
return buffer;
|
|
682
|
+
}
|
|
683
|
+
var KeyObject = class {
|
|
684
|
+
constructor(type) {
|
|
685
|
+
this.type = type || "secret";
|
|
686
|
+
}
|
|
687
|
+
};
|
|
688
|
+
var cryptoPolyfill = {
|
|
689
|
+
createCipheriv,
|
|
690
|
+
createDecipheriv,
|
|
691
|
+
createHash,
|
|
692
|
+
createPrivateKey,
|
|
693
|
+
createPublicKey,
|
|
694
|
+
diffieHellman,
|
|
695
|
+
generateKeyPairSync,
|
|
696
|
+
getRandomValues,
|
|
697
|
+
hkdfSync,
|
|
698
|
+
KeyObject,
|
|
699
|
+
randomBytes,
|
|
700
|
+
randomFillSync,
|
|
701
|
+
randomUUID,
|
|
702
|
+
sign,
|
|
703
|
+
verify,
|
|
704
|
+
webcrypto
|
|
705
|
+
};
|
|
706
|
+
//#endregion
|
|
701
707
|
//#region src/server/wsConnectionService.mjs
|
|
702
708
|
function createConnectionHandler({ clients, pushSubscriptions, pendingNotifications, notificationService, handleMessage }) {
|
|
703
709
|
return function handleConnection(ws, req) {
|
|
@@ -1288,15 +1294,15 @@ function createSaveExecutionLogHandler({ logsCollectionOwner, clients }) {
|
|
|
1288
1294
|
clientId,
|
|
1289
1295
|
...payload
|
|
1290
1296
|
};
|
|
1291
|
-
const
|
|
1292
|
-
await logsColl.add(
|
|
1293
|
-
console.log(`[WS] Execution log saved as MCard: ${
|
|
1297
|
+
const record = createRecord(JSON.stringify(logData, null, 2));
|
|
1298
|
+
await logsColl.add(record);
|
|
1299
|
+
console.log(`[WS] Execution log saved as MCard: ${record.hash}`);
|
|
1294
1300
|
if (payload.governance_telemetry && clients) {
|
|
1295
1301
|
const gt = payload.governance_telemetry;
|
|
1296
1302
|
const telemetryUpdate = JSON.stringify({
|
|
1297
1303
|
type: WS_MESSAGE_TYPES.TELEMETRY_UPDATE,
|
|
1298
1304
|
data: {
|
|
1299
|
-
id:
|
|
1305
|
+
id: record.hash,
|
|
1300
1306
|
timestamp: Date.now(),
|
|
1301
1307
|
possibilityMagnitude: gt.M ?? 0,
|
|
1302
1308
|
governanceNarrowing: gt.N ?? 0,
|
|
@@ -1313,7 +1319,7 @@ function createSaveExecutionLogHandler({ logsCollectionOwner, clients }) {
|
|
|
1313
1319
|
return {
|
|
1314
1320
|
type: WS_MESSAGE_TYPES.EXECUTION_LOG_SAVED,
|
|
1315
1321
|
success: true,
|
|
1316
|
-
hash:
|
|
1322
|
+
hash: record.hash
|
|
1317
1323
|
};
|
|
1318
1324
|
};
|
|
1319
1325
|
}
|
|
@@ -1835,7 +1841,7 @@ function sealExecutionResult(vCardContent, { parentHash = null } = {}) {
|
|
|
1835
1841
|
}
|
|
1836
1842
|
/** @param {string} data */
|
|
1837
1843
|
function sha256(data) {
|
|
1838
|
-
return
|
|
1844
|
+
return computeHash("sha256", data);
|
|
1839
1845
|
}
|
|
1840
1846
|
//#endregion
|
|
1841
1847
|
//#region src/server/effects/executionPersistenceService.mjs
|
|
@@ -1874,10 +1880,10 @@ async function persistSealedResult({ collectionOwner, sealExecutionResult, runRe
|
|
|
1874
1880
|
success: runResult.success
|
|
1875
1881
|
};
|
|
1876
1882
|
const sealed = sealExecutionResult(vCardContent);
|
|
1877
|
-
const
|
|
1878
|
-
await collection.add(
|
|
1883
|
+
const record = createRecord(JSON.stringify(sealed.original, null, 2));
|
|
1884
|
+
await collection.add(record);
|
|
1879
1885
|
return {
|
|
1880
|
-
hash:
|
|
1886
|
+
hash: record.hash,
|
|
1881
1887
|
vCardContent
|
|
1882
1888
|
};
|
|
1883
1889
|
}
|
|
@@ -1903,8 +1909,8 @@ async function persistLLMInteractionEvents({ collectionOwner, notificationServic
|
|
|
1903
1909
|
content: String(request.input || ""),
|
|
1904
1910
|
vcard_policy_hash: request.handle || "unknown-context"
|
|
1905
1911
|
};
|
|
1906
|
-
const
|
|
1907
|
-
if (!await collection.get(
|
|
1912
|
+
const userRecord = createRecord(JSON.stringify(userPromptContent, null, 2));
|
|
1913
|
+
if (!await collection.get(userRecord.hash)) await collection.add(userRecord);
|
|
1908
1914
|
if (notificationService && request.clientId) notificationService.sendNotification(request.clientId, {
|
|
1909
1915
|
type: WS_MESSAGE_TYPES.INTERACTION_EVENT,
|
|
1910
1916
|
payload: userPromptContent
|
|
@@ -1916,11 +1922,11 @@ async function persistLLMInteractionEvents({ collectionOwner, notificationServic
|
|
|
1916
1922
|
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
1917
1923
|
contentType: "text/markdown",
|
|
1918
1924
|
content: runResult.result,
|
|
1919
|
-
pre_condition_hash:
|
|
1925
|
+
pre_condition_hash: userRecord.hash,
|
|
1920
1926
|
trace_execution_hash: parentExecutionHash
|
|
1921
1927
|
};
|
|
1922
|
-
const
|
|
1923
|
-
if (!await collection.get(
|
|
1928
|
+
const llmRecord = createRecord(JSON.stringify(llmResponseContent, null, 2));
|
|
1929
|
+
if (!await collection.get(llmRecord.hash)) await collection.add(llmRecord);
|
|
1924
1930
|
if (notificationService && request.clientId) notificationService.sendNotification(request.clientId, {
|
|
1925
1931
|
type: WS_MESSAGE_TYPES.INTERACTION_EVENT,
|
|
1926
1932
|
payload: llmResponseContent
|
|
@@ -2035,6 +2041,34 @@ function createClientRegistryService({ clients, pushSubscriptions }) {
|
|
|
2035
2041
|
};
|
|
2036
2042
|
}
|
|
2037
2043
|
//#endregion
|
|
2044
|
+
//#region src/edge/storeFilter.js
|
|
2045
|
+
/**
|
|
2046
|
+
* src/edge/storeFilter.js
|
|
2047
|
+
*
|
|
2048
|
+
* Store-file exclusion filter for disk watchers and ingestion (INV-CAS-12, DoD-08-2).
|
|
2049
|
+
* Writes to *-wal, *-shm, *-journal and PATHS.stores produce NO transition and NO notification.
|
|
2050
|
+
*/
|
|
2051
|
+
var STORE_EXTENSIONS = [
|
|
2052
|
+
"-wal",
|
|
2053
|
+
"-shm",
|
|
2054
|
+
"-journal"
|
|
2055
|
+
];
|
|
2056
|
+
var STORE_FILENAMES = new Set(Object.values(PATHS.stores || {}));
|
|
2057
|
+
/**
|
|
2058
|
+
* Checks whether a given relative or absolute file path corresponds to an internal
|
|
2059
|
+
* storage file (database file, WAL, SHM, or rollback journal).
|
|
2060
|
+
*
|
|
2061
|
+
* @param {string} filepathOrFilename - Path or filename to check
|
|
2062
|
+
* @returns {boolean} true if the file should be excluded from watchers and transitions
|
|
2063
|
+
*/
|
|
2064
|
+
function isStoreFile(filepathOrFilename) {
|
|
2065
|
+
if (!filepathOrFilename || typeof filepathOrFilename !== "string") return false;
|
|
2066
|
+
const base = path$1.basename(filepathOrFilename);
|
|
2067
|
+
for (const ext of STORE_EXTENSIONS) if (base.endsWith(ext)) return true;
|
|
2068
|
+
if (STORE_FILENAMES.has(base)) return true;
|
|
2069
|
+
return false;
|
|
2070
|
+
}
|
|
2071
|
+
//#endregion
|
|
2038
2072
|
//#region src/server/fileWatcherService.mjs
|
|
2039
2073
|
var DEBOUNCE_MS = PATHS.ingest.watch_debounce_ms;
|
|
2040
2074
|
var IGNORED_PATTERNS = PATHS.ingest.ignore.patterns;
|
|
@@ -2050,7 +2084,9 @@ function createFileWatcherService(artifactsDir) {
|
|
|
2050
2084
|
/** Per-filename debounce timers — ensures concurrent multi-file changes each fire. */
|
|
2051
2085
|
const debounceTimers = /* @__PURE__ */ new Map();
|
|
2052
2086
|
function shouldIgnore(filename) {
|
|
2053
|
-
|
|
2087
|
+
if (IGNORED_PATTERNS.some((pattern) => filename.includes(pattern))) return true;
|
|
2088
|
+
if (isStoreFile(filename)) return true;
|
|
2089
|
+
return false;
|
|
2054
2090
|
}
|
|
2055
2091
|
function start() {
|
|
2056
2092
|
console.log(`[FileWatcher] Watching ${artifactsDir} for changes...`);
|
|
@@ -2107,6 +2143,7 @@ var SERVER_FS_PREFIX = PATHS.handles.server_fs;
|
|
|
2107
2143
|
* @returns {Promise<{ action: 'created' | 'updated' | 'unchanged' | 'deleted'; handle: string; hash?: string } | null>}
|
|
2108
2144
|
*/
|
|
2109
2145
|
async function ingestFileChange(artifactsDir, filename, collectionOwner) {
|
|
2146
|
+
if (isStoreFile(filename)) return null;
|
|
2110
2147
|
const fullPath = path$1.join(artifactsDir, filename);
|
|
2111
2148
|
const handle = buildServerFsHandle(filename);
|
|
2112
2149
|
try {
|
|
@@ -2124,27 +2161,29 @@ async function ingestFileChange(artifactsDir, filename, collectionOwner) {
|
|
|
2124
2161
|
if (filename.endsWith(".yaml") || filename.endsWith(".yml")) try {
|
|
2125
2162
|
ClmChapterLoader.loadFromString(buf.toString("utf8"));
|
|
2126
2163
|
} catch {}
|
|
2127
|
-
const
|
|
2164
|
+
const record = createRecord(buf);
|
|
2165
|
+
const qualifiedHash = qualify(record);
|
|
2128
2166
|
const collection = await collectionOwner.getCollection();
|
|
2129
2167
|
const existingHash = await collection.resolveHandle(handle);
|
|
2130
|
-
|
|
2168
|
+
const bareHex = record.hash.includes(":") ? record.hash.split(":")[1] : record.hash;
|
|
2169
|
+
if ((existingHash && typeof existingHash === "object" && "asHex" in existingHash ? existingHash.asHex() : String(existingHash || "").includes(":") ? String(existingHash).split(":")[1] : String(existingHash || "")) === bareHex) return {
|
|
2131
2170
|
action: "unchanged",
|
|
2132
2171
|
handle,
|
|
2133
|
-
hash:
|
|
2172
|
+
hash: qualifiedHash
|
|
2134
2173
|
};
|
|
2135
2174
|
if (existingHash) {
|
|
2136
|
-
await collection.updateHandle(handle,
|
|
2175
|
+
await collection.updateHandle(handle, record);
|
|
2137
2176
|
return {
|
|
2138
2177
|
action: "updated",
|
|
2139
2178
|
handle,
|
|
2140
|
-
hash:
|
|
2179
|
+
hash: qualifiedHash
|
|
2141
2180
|
};
|
|
2142
2181
|
}
|
|
2143
|
-
await collection.addWithHandle(
|
|
2182
|
+
await collection.addWithHandle(record, handle);
|
|
2144
2183
|
return {
|
|
2145
2184
|
action: "created",
|
|
2146
2185
|
handle,
|
|
2147
|
-
hash:
|
|
2186
|
+
hash: qualifiedHash
|
|
2148
2187
|
};
|
|
2149
2188
|
}
|
|
2150
2189
|
/**
|
|
@@ -2193,6 +2232,7 @@ async function ingestDirectory(artifactsDir, collectionOwner, options = {}) {
|
|
|
2193
2232
|
await walkDir(fullPath, relativePath);
|
|
2194
2233
|
continue;
|
|
2195
2234
|
}
|
|
2235
|
+
if (isStoreFile(entry.name)) continue;
|
|
2196
2236
|
const ext = path$1.extname(entry.name).toLowerCase();
|
|
2197
2237
|
if (IGNORED_EXT_SET.has(ext)) continue;
|
|
2198
2238
|
if (SKIP_DOTFILES && entry.name.startsWith(".") || IGNORED_FILENAMES.has(entry.name)) continue;
|
|
@@ -2277,14 +2317,6 @@ function signalCacheInvalidate() {
|
|
|
2277
2317
|
//#endregion
|
|
2278
2318
|
//#region src/server/handlers/fileChangeHandler.mjs
|
|
2279
2319
|
/**
|
|
2280
|
-
* File watcher event handler.
|
|
2281
|
-
*
|
|
2282
|
-
* Encapsulates the side-effects triggered when the file system watcher detects
|
|
2283
|
-
* changes in the artifacts directory:
|
|
2284
|
-
* 1. Broadcasts ARTIFACTS_CHANGED to all connected WS clients
|
|
2285
|
-
* 2. Auto-ingests changes into servermemory.db for version tracking
|
|
2286
|
-
*/
|
|
2287
|
-
/**
|
|
2288
2320
|
* Create a handler for file watcher 'change' events.
|
|
2289
2321
|
*
|
|
2290
2322
|
* @param {object} deps
|
|
@@ -2296,7 +2328,20 @@ function createFileChangeHandler({ artifactsDir, notificationService, serverMemo
|
|
|
2296
2328
|
return async ({ eventType, filename }) => {
|
|
2297
2329
|
try {
|
|
2298
2330
|
const result = await ingestFileChange(artifactsDir, filename, serverMemoryOwner);
|
|
2299
|
-
if (!result) return;
|
|
2331
|
+
if (!result || result.action === "unchanged") return;
|
|
2332
|
+
const transitionKind = result.action === "deleted" ? "DELETE" : result.action === "created" ? "CREATE" : "UPDATE";
|
|
2333
|
+
const qualifiedHashStr = result.hash ? String(result.hash) : "";
|
|
2334
|
+
const transitionPayload = {
|
|
2335
|
+
hash: qualifiedHashStr,
|
|
2336
|
+
handle: result.handle,
|
|
2337
|
+
kind: transitionKind,
|
|
2338
|
+
from: null,
|
|
2339
|
+
to: result.action === "deleted" ? null : qualifiedHashStr,
|
|
2340
|
+
author: "did:clm:agent:watcher",
|
|
2341
|
+
clock: { watcher: Date.now() }
|
|
2342
|
+
};
|
|
2343
|
+
const notificationJson = formatNotification(GATEWAY_METHODS.NAME_TRANSITION, transitionPayload);
|
|
2344
|
+
notificationService.broadcastRaw?.(notificationJson);
|
|
2300
2345
|
await notificationService.broadcastToAll({
|
|
2301
2346
|
type: WS_MESSAGE_TYPES.ARTIFACTS_CHANGED,
|
|
2302
2347
|
title: "Server files changed",
|
|
@@ -2307,7 +2352,7 @@ function createFileChangeHandler({ artifactsDir, notificationService, serverMemo
|
|
|
2307
2352
|
hash: result.hash,
|
|
2308
2353
|
filename
|
|
2309
2354
|
});
|
|
2310
|
-
console.log(`[WS] Broadcasted ARTIFACTS_CHANGED to all clients for ${result.handle} (${result.action})`);
|
|
2355
|
+
console.log(`[WS] Broadcasted clm.name.transition & ARTIFACTS_CHANGED to all clients for ${result.handle} (${result.action})`);
|
|
2311
2356
|
if (result.action !== "unchanged" && result.action !== "deleted") console.log(`[WS] Ingested ${result.action} for ${filename} (handle: ${result.handle}, hash: ${result.hash})`);
|
|
2312
2357
|
signalCacheInvalidate();
|
|
2313
2358
|
} catch (err) {
|