mcard-studio 0.0.1 → 0.0.2

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 (83) hide show
  1. package/astro.config.mjs +6 -1
  2. package/bin/mcard-studio.mjs +1 -1
  3. package/dist/client/_astro/{ChartAnalyticsViewlet.Cevj0EOs.js → ChartAnalyticsViewlet.jrwIemvb.js} +1 -1
  4. package/dist/client/_astro/ClmPcardViewlet.C-fU7oZf.js +3 -0
  5. package/dist/client/_astro/D3GraphViewlet.BCZl0b2U.js +2 -0
  6. package/dist/client/_astro/DockviewSpatialWorkbench.B_I1GJHw.js +12 -0
  7. package/dist/client/_astro/{DocumentViewlets.Dm_GL3AL.js → DocumentViewlets.B53IqmpY.js} +1 -1
  8. package/dist/client/_astro/ExcalidrawWhiteboardViewlet.CFpPYSdn.js +1 -0
  9. package/dist/client/_astro/{FaroVCardSpanInstrumenter.BIk2NhJY.js → FaroVCardSpanInstrumenter.un8kDMWv.js} +1 -1
  10. package/dist/client/_astro/{FontSpecimenViewlet.CpONhJh0.js → FontSpecimenViewlet.D7Aw2xBZ.js} +1 -1
  11. package/dist/client/_astro/HeadMeta.astro_astro_type_script_index_0_lang.VDRYJCM-.js +1 -0
  12. package/dist/client/_astro/{ImageViewlet.CHeNvX6L.js → ImageViewlet.D4FN87n_.js} +1 -1
  13. package/dist/client/_astro/{KatexFormulaViewlet.Cy_InWOK.js → KatexFormulaViewlet.CzhdIOw8.js} +1 -1
  14. package/dist/client/_astro/KoishiChatViewlet.5mepQvLX.js +16 -0
  15. package/dist/client/_astro/MCardLibraryHarness.DE8KeghO.js +2 -0
  16. package/dist/client/_astro/{MarkdownViewlet.qoPlM-TZ.js → MarkdownViewlet.CRuuXXmF.js} +1 -1
  17. package/dist/client/_astro/{MermaidDiagramViewlet.RnwDfQl6.js → MermaidDiagramViewlet.eW6sk-rF.js} +1 -1
  18. package/dist/client/_astro/PCardRendererBridge.oxVKc0gN.js +1 -0
  19. package/dist/client/_astro/RendererPCardRegistry.CWjYZs2H.js +1 -0
  20. package/dist/client/_astro/{SchemaYamlViewlet.D6HVdmrq.js → SchemaYamlViewlet.ZJBvxItR.js} +1 -1
  21. package/dist/client/_astro/{ShellContainer.astro_astro_type_script_index_0_lang.2oi8fhQo.js → ShellContainer.astro_astro_type_script_index_0_lang.j_ELcN5d.js} +1 -1
  22. package/dist/client/_astro/{Spatial3dViewlet.CCYBSSib.js → Spatial3dViewlet.DnVMBENJ.js} +1 -1
  23. package/dist/client/_astro/StudioWorkbench.Blo5oSIw.js +7 -0
  24. package/dist/client/_astro/{SvgViewlet.BxlWQ-JX.js → SvgViewlet.BCje7Qqb.js} +1 -1
  25. package/dist/client/_astro/{TerminalView.DWZR-hUa.js → TerminalView.C_Ksz6lT.js} +4 -4
  26. package/dist/client/_astro/{ThemeSettingsViewlet.Cb1r8fWw.js → ThemeSettingsViewlet.DJpjQQ0Z.js} +1 -1
  27. package/dist/client/_astro/{TikzDiagramViewlet.CqY7VTeP.js → TikzDiagramViewlet.CXb1A8nf.js} +1 -1
  28. package/dist/client/_astro/{VideoPlayerViewlet.DoSYmmoQ.js → VideoPlayerViewlet.CmECt7yT.js} +1 -1
  29. package/dist/client/_astro/{WebappZenViewlet.CQW50OhX.js → WebappZenViewlet.whCmGVHR.js} +1 -1
  30. package/dist/client/_astro/{WelcomeViewport.LwKTA6h7.js → WelcomeViewport.BiYwLh6l.js} +1 -1
  31. package/dist/client/_astro/__vite-browser-external.CQZnr-r3.js +1 -0
  32. package/dist/client/_astro/{agentIdentityCredentialService.BtKVsl2C.js → agentIdentityCredentialService.UzMMwBwv.js} +5 -5
  33. package/dist/client/_astro/cardTypeDetector.Ci4APwhX.js +1 -0
  34. package/dist/client/_astro/disposable.Dsb0sbRP.js +1 -0
  35. package/dist/client/_astro/{markdownService.D-tM2RYx.js → markdownService.BgWjyJ57.js} +1 -1
  36. package/dist/client/_astro/{mcardStore.BiAvqM-D.js → mcardStore.CT-ollfl.js} +2 -2
  37. package/dist/client/_astro/mcardVfs.2UOw9Z-r.js +3 -0
  38. package/dist/client/_astro/polyfills._3wYPjZf.js +1 -0
  39. package/dist/client/_astro/rendererEventBus.DMH9afq9.js +1 -0
  40. package/dist/client/_astro/themeStore.CEt0e54l.js +1 -0
  41. package/dist/client/_astro/{tikzCompiler.DFojjdxR.js → tikzCompiler.fe3qomFY.js} +1 -1
  42. package/dist/client/_astro/{useMCardHydration.Co47OH3D.js → useMCardHydration.7Z-HfBh5.js} +1 -1
  43. package/dist/client/_astro/vendor-ai.D6NcJ6lu.js +69 -0
  44. package/dist/client/_astro/vendor-clm-kernel.Bvk3XHk2.js +116 -0
  45. package/dist/client/_astro/vfsHandles.IX_wTpw_.js +1 -0
  46. package/dist/client/_astro/vfsPersistence.BuhXYeSb.js +1 -0
  47. package/dist/client/_astro/vfsTransactions.C_IQQg0s.js +1 -0
  48. package/dist/client/_astro/{workspaceStore.CXakha4Y.js → workspaceStore.CD0kAVAl.js} +1 -1
  49. package/dist/client/js/buffer-polyfill.js +14 -0
  50. package/dist/server/chunks/{StudioLayout_D163irJ0.mjs → StudioLayout_B5ZnlqjF.mjs} +2 -2
  51. package/dist/server/chunks/{_.._ZXsz792-.mjs → _.._5gPhVOLM.mjs} +1 -1
  52. package/dist/server/chunks/{mcard-library_DvPPUs9_.mjs → mcard-library_7Wzoihkm.mjs} +1 -1
  53. package/dist/server/chunks/{ws-server-init_CkcgcI5V.mjs → ws-server-init_DUjuR2-o.mjs} +3 -3
  54. package/dist/server/entry.mjs +8 -4
  55. package/dist/server/entry2.mjs +3 -3
  56. package/dist/server/virtual_astro_middleware.mjs +1 -1
  57. package/package.json +1 -1
  58. package/public/js/buffer-polyfill.js +14 -0
  59. package/src/layouts/StudioLayout.astro +1 -0
  60. package/src/pages/index.astro +75 -0
  61. package/src/services/inBrowserLlm/engines/litertEngine.ts +1 -1
  62. package/dist/client/_astro/ClmPcardViewlet.DW5Yft0E.js +0 -3
  63. package/dist/client/_astro/D3GraphViewlet.DAjPz1DP.js +0 -2
  64. package/dist/client/_astro/DockviewSpatialWorkbench.DyQjSoHd.js +0 -12
  65. package/dist/client/_astro/ExcalidrawWhiteboardViewlet.DrlW7B6G.js +0 -1
  66. package/dist/client/_astro/HeadMeta.astro_astro_type_script_index_0_lang.DGXU-3Lu.js +0 -1
  67. package/dist/client/_astro/KoishiChatViewlet.B0eDEMnT.js +0 -16
  68. package/dist/client/_astro/MCardLibraryHarness.CUJLJFBt.js +0 -2
  69. package/dist/client/_astro/PCardRendererBridge.BnyaE05I.js +0 -1
  70. package/dist/client/_astro/RendererPCardRegistry.CLr4j1Ub.js +0 -1
  71. package/dist/client/_astro/StudioWorkbench.CF0SOYwy.js +0 -7
  72. package/dist/client/_astro/cardTypeDetector.C9kGObMh.js +0 -1
  73. package/dist/client/_astro/disposable.66apX1Q2.js +0 -1
  74. package/dist/client/_astro/empty.DOwCrGXH.js +0 -1
  75. package/dist/client/_astro/mcardVfs.Bj-RA0p7.js +0 -2
  76. package/dist/client/_astro/path.CR60mj9W.js +0 -1
  77. package/dist/client/_astro/polyfills.DcBkS56X.js +0 -1
  78. package/dist/client/_astro/rendererEventBus.CyFnSRLk.js +0 -1
  79. package/dist/client/_astro/themeStore.zUMFLo3Q.js +0 -1
  80. package/dist/client/_astro/vendor-ai.CZe7UVVK.js +0 -69
  81. package/dist/client/_astro/vfsHandles.B-nczBRy.js +0 -1
  82. package/dist/client/_astro/vfsPersistence.D6zRzVML.js +0 -1
  83. package/dist/client/_astro/vfsTransactions.04mkEHxD.js +0 -1
@@ -1 +0,0 @@
1
- import{h as e}from"./themeStore.zUMFLo3Q.js";import{y as t}from"./mcardStore.BiAvqM-D.js";import{n}from"./pathsConfig.D0hV34p7.js";import{n as r,t as i}from"./cardTypeDetector.C9kGObMh.js";import{routeHandle as a}from"clm-kernel";function o(e){let t=(e||``).trim(),n=t,r=`raw`;n.startsWith(`mcard://`)?(r=`mcard`,n=n.slice(8)):n.startsWith(`mcard:`)?(r=`mcard`,n=n.slice(6)):n.startsWith(`pcard://`)?(r=`pcard`,n=n.slice(8)):n.startsWith(`pcard:`)&&(r=`pcard`,n=n.slice(6));let[i,a]=n.split(`#`),[o,s]=i.split(`?`),c={};if(s)try{new URLSearchParams(s).forEach((e,t)=>{c[t]=e})}catch{s.split(`&`).forEach(e=>{let[t,n]=e.split(`=`);t&&(c[decodeURIComponent(t)]=decodeURIComponent(n||``))})}return{cleanHandle:o.trim(),scheme:r,params:c,anchor:a?a.trim():void 0,rawTarget:t}}function s(e,t){let r=(e||``).trim();r.startsWith(`mcard://`)&&(r=r.replace(/^mcard:\/\//,``));let i=r.replace(/:/g,`/`).replace(/^[\/\\]+/,``);return i.toLowerCase().endsWith(`.md`)?n({b64:i,versionHash:t,cacheBust:!t}):n({path:i,versionHash:t,cacheBust:!t})}function c(e,n,r){if(!e)return null;let i=r||t.get();if(!i)return null;let a=o(e).cleanHandle;if(!a)return null;if(i[a])return i[a];let s=a.replace(/\//g,`:`);if(i[s])return i[s];let c=a.replace(/:/g,`/`);if(i[c])return i[c];if(!s.endsWith(`.md`)&&i[`${s}.md`])return i[`${s}.md`];let l=Object.values(i),u=l.find(e=>e.handle===a||e.handle===s||e.handle===c||e.path===a||e.path===c||e.path.replace(/\//g,`:`)===s);if(u)return u;if(!a.endsWith(`.md`)){let e=`${a}.md`,t=`${s}.md`;if(u=l.find(n=>n.handle===t||n.path===e||n.name===e),u)return u}let d=a.toLowerCase(),f=d.endsWith(`.md`)?d:`${d}.md`;if(u=l.find(e=>{let t=e.name.toLowerCase(),n=t.replace(/\.[^.]+$/,``);return t===d||t===f||n===d}),u)return u;if(n&&n.path){let e=n.path.substring(0,n.path.lastIndexOf(`/`));if(e){let t=`${e}/${a}`.replace(/\/+/g,`/`),n=t.replace(/\//g,`:`);if(i[n])return i[n];if(!n.endsWith(`.md`)&&i[`${n}.md`])return i[`${n}.md`];if(u=l.find(e=>e.path===t||e.path===`${t}.md`),u)return u}}return u=l.find(e=>e.path.endsWith(`/${a}`)||e.path.endsWith(`/${a}.md`)||e.handle.endsWith(`:${s}`)||e.handle.endsWith(`:${s}.md`)),u||null}async function l(n){if(!n)return null;try{let o=await a({uri:n,backend:e.storageBackend,fallback:`stale`,cache:!0});if(o.content){let e=r(n),a=i({path:n,mimeType:e}),s={handle:n,hash:o.hash,path:n.replace(/:/g,`/`),name:n.split(`:`).pop()||n,mimeType:e,detectedType:a.detectedType,epistemicStatus:`definition`,readOnly:!0,content:o.content,subclass:a.subclass};return t.setKey(n,s),s}}catch(e){console.warn(`[MCardVFS] Remote resolution failed for ${n}:`,e)}return null}export{s as n,l as r,c as t};
@@ -1 +0,0 @@
1
- import{n as e}from"./rolldown-runtime.Dd_uD5pT.js";import{h as t}from"./themeStore.zUMFLo3Q.js";import{a as n,y as r}from"./mcardStore.BiAvqM-D.js";import{t as i}from"./pathsConfig.D0hV34p7.js";import{AgentDid as a}from"clm-kernel";var o=class{options;isFlushing=!1;flushPromise=null;currentGeneration=0;retryAttempts=0;debounceTimer=null;state=`idle`;constructor(e){this.options=e}scheduleFlush(e=300){this.debounceTimer&&clearTimeout(this.debounceTimer),this.debounceTimer=setTimeout(()=>{this.flush().catch(e=>console.error(`[StorageSupervisor] Flush error:`,e))},e)}async flush(){return this.isFlushing&&this.flushPromise?this.flushPromise:(this.isFlushing=!0,this.transition(`saving`),this.flushPromise=(async()=>{try{await this.options.flush(),this.currentGeneration++,this.retryAttempts=0,this.transition(`persistent`)}catch(e){throw this.transition(`error`),e}finally{this.isFlushing=!1,this.flushPromise=null}})(),this.flushPromise)}handleStaleConflict(e,t){this.transition(`stale`),console.warn(`[StorageSupervisor] Stale writer conflict: expected gen ${e}, found ${t}`)}async retryFlush(){try{return await this.flush(),!0}catch{return this.retryAttempts++,!1}}getState(){return this.state}getCurrentGeneration(){return this.currentGeneration}getRetryAttempts(){return this.retryAttempts}dispose(){this.debounceTimer&&=(clearTimeout(this.debounceTimer),null),this.isFlushing=!1,this.flushPromise=null}transition(e){this.state=e,this.options.onStateChange?.(e)}},s=e({STORE_CAS:()=>d,STORE_HANDLES:()=>f,STORE_HISTORY:()=>p,STORE_SNAPSHOTS:()=>m,getSqliteBytesFromIndexedDb:()=>T,hydrateFromIndexedDb:()=>C,idbGet:()=>_,idbGetAll:()=>v,idbPut:()=>y,loadCardsFromIndexedDb:()=>E,openIndexedDb:()=>g,saveSqliteBytesToIndexedDb:()=>w,triggerIndexedDbSync:()=>S,vfsStorageSupervisor:()=>x}),c=i.paths.workspace_dirname,l=`clm_workbench_db`,u=2,d=`clm_cas_blobs`,f=`clm_handle_registry`,p=`clm_handle_history`,m=`clm_sqlite_snapshots`,h=`clm_content_memory_db`;function g(){return new Promise((e,t)=>{if(typeof window>`u`||!window.indexedDB)return t(Error(`IndexedDB not available`));let n=window.indexedDB.open(l,u);n.onupgradeneeded=()=>{let e=n.result;e.objectStoreNames.contains(`clm_cas_blobs`)||e.createObjectStore(d,{keyPath:`hash`}),e.objectStoreNames.contains(`clm_handle_registry`)||e.createObjectStore(f,{keyPath:`handle`}),e.objectStoreNames.contains(`clm_handle_history`)||e.createObjectStore(p,{keyPath:`id`,autoIncrement:!0}),e.objectStoreNames.contains(`clm_sqlite_snapshots`)||e.createObjectStore(m,{keyPath:`id`}),e.objectStoreNames.contains(h)||e.createObjectStore(h)},n.onsuccess=()=>e(n.result),n.onerror=()=>t(n.error)})}async function _(e,t){try{let n=await g();return new Promise((r,i)=>{let a=n.transaction(e,`readonly`).objectStore(e).get(t);a.onsuccess=()=>r(a.result),a.onerror=()=>i(a.error)})}catch{return}}async function v(e){try{let t=await g();return new Promise((n,r)=>{let i=t.transaction(e,`readonly`).objectStore(e).getAll();i.onsuccess=()=>n(i.result||[]),i.onerror=()=>r(i.error)})}catch{return[]}}async function y(e,t,n){try{let r=await g();return new Promise((i,a)=>{let o=r.transaction(e,`readwrite`).objectStore(e),s=n===void 0?o.put(t):o.put(t,n);s.onsuccess=()=>i(),s.onerror=()=>a(s.error)})}catch{}}async function b(){if(typeof window>`u`||!window.indexedDB)return;let e=r.get(),n=Object.values(e),i=`${c}:`,a=n.filter(e=>e.handle.startsWith(i)||e.scope===c||e.path.startsWith(`${c}/`)),o=(await g()).transaction([d,f,p,m,h],`readwrite`),s=o.objectStore(d),l=o.objectStore(f);for(let e of a)e.hash&&e.content!==void 0&&s.put({hash:e.hash,content:e.content,mimeType:e.mimeType,size:typeof e.content==`string`?e.content.length:e.content?.byteLength||0}),l.put({handle:e.handle,scope:c,path:e.path,name:e.name,hash:e.hash,detectedType:e.detectedType,epistemicStatus:e.epistemicStatus,mtime:e.mtime||Date.now()});let u=t.storageBackend;if(u&&typeof u.exportBinary==`function`){let e=u.exportBinary();e&&o.objectStore(m).put({id:`latest`,bytes:e,mtime:Date.now()})}let _=a.map(e=>({handle:e.handle,hash:e.hash,path:e.path,name:e.name,mimeType:e.mimeType,detectedType:e.detectedType,epistemicStatus:e.epistemicStatus,readOnly:e.readOnly,subclass:e.subclass,content:e.content}));o.objectStore(h).put(_,`clm_cards`)}var x=new o({flush:b,onStateChange:e=>{n({isPersistent:e===`persistent`,lastSavedIso:new Date().toISOString(),supervisorState:e})}});function S(){let e=r.get(),i=Object.values(e),a=0;for(let e of i)typeof e.content==`string`?a+=e.content.length:e.content instanceof Uint8Array&&(a+=e.content.byteLength);let o=t.storageBackend.constructor.name,s=o.includes(`Sqlite`)?`sqlite`:o.includes(`SqlJs`)?`sqljs`:`memory`;n({backendType:s,cardCount:i.length,totalBytes:a,isPersistent:!0,lastSavedIso:new Date().toISOString()}),x.scheduleFlush(300)}async function C(){if(typeof window>`u`||!window.indexedDB)return!1;try{let e=await v(f),i=`${c}:`,o=e.filter(e=>e.scope===c||e.handle&&e.handle.startsWith(i)),s=r.get(),l=a.create(`did:clm:agent:idb`),u=0,p=0;if(o.length>0)for(let e of o){let n=``;if(e.hash){let t=await _(d,e.hash);t&&t.content!==void 0&&(n=t.content)}if(!s[e.handle]||!s[e.handle].content){let r=t.writeFile(e.path,n||``,l);s[e.handle]={...e,content:n,coreCard:r},u++}typeof n==`string`&&(p+=n.length)}else{let e=await _(h,`clm_cards`);if(Array.isArray(e)&&e.length>0){for(let n of e)if((n.path.startsWith(`${c}/`)||n.handle.startsWith(i))&&(!s[n.handle]||!s[n.handle].content)){let e=t.writeFile(n.path,n.content||``,l);s[n.handle]={...n,coreCard:e},u++}}}return u>0&&(r.set({...s}),n({cardCount:Object.keys(s).length,totalBytes:p,isPersistent:!0,lastSavedIso:new Date().toISOString()}),!0)}catch(e){return console.warn(`[MCardVFS] Failed to hydrate from IndexedDB:`,e),!1}}async function w(e){typeof window<`u`&&window.indexedDB&&await y(m,{id:`latest`,bytes:e,mtime:Date.now()})}async function T(){if(typeof window<`u`&&window.indexedDB)return(await _(m,`latest`))?.bytes}async function E(){if(typeof window<`u`&&window.indexedDB)return _(h,`clm_cards`)}export{s as i,w as n,S as r,C as t};
@@ -1 +0,0 @@
1
- import{h as e}from"./themeStore.zUMFLo3Q.js";import{y as t}from"./mcardStore.BiAvqM-D.js";import{r as n}from"./pathsConfig.D0hV34p7.js";import{n as r,t as i}from"./cardTypeDetector.C9kGObMh.js";import{r as a}from"./vfsPersistence.D6zRzVML.js";import{AgentDid as o,detectEpistemicStatus as s}from"clm-kernel";async function c(n){let c=o.create(`did:clm:agent:user`),l=[];for(let a of n){let n=a.name.replace(/^[/\\]+/,``),o=`uploads/${n}`,u=o.replace(/\//g,`:`),d=a.mimeType||r(n),f=i({path:o,mimeType:d}),p=e.writeFile(o,a.content,c),m={handle:u,hash:p.hash.asHex(),path:o,name:n,mimeType:d,detectedType:f.detectedType,epistemicStatus:s(o),readOnly:!1,scope:`local-db`,subclass:f.subclass,content:a.content,coreCard:p};t.setKey(u,m),l.push(m)}return a(),l}async function l(r){let i=n(`vfs_tree`),s=await fetch(`${i}?scope=${encodeURIComponent(r)}`);if(!s.ok)throw Error(`Failed to fetch scope ${r} for forking: HTTP ${s.status}`);let c=await s.json();if(!c.success||!Array.isArray(c.files))throw Error(`Malformed tree response for fork`);let l=o.create(`did:clm:agent:user`),u=0;for(let n of c.files){let i=`forked/${r}/${n.path}`,a=i.replace(/\//g,`:`),o=n.content??``,s=e.writeFile(i,o,l),c={...n,handle:a,hash:s.hash.asHex(),path:i,name:n.name,readOnly:!1,scope:`local-db`,content:o,coreCard:s};t.setKey(a,c),u++}return a(),u}export{c as executeFileUploadTransaction,l as executeForkDirectoryTransaction};