@crewx/memory 0.1.24 → 0.9.1-dev.1
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/dist/src/mindmap.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
"use strict";var $=exports&&exports.__importDefault||function(s){return s&&s.__esModule?s:{"default":s}};Object.defineProperty(exports,"__esModule",{value:true});exports.MindmapEngine=void 0;exports.loadAllEntries=x;exports.buildGraph=k;exports.saveGraph=
|
|
1
|
+
"use strict";var $=exports&&exports.__importDefault||function(s){return s&&s.__esModule?s:{"default":s}};Object.defineProperty(exports,"__esModule",{value:true});exports.MindmapEngine=void 0;exports.loadAllEntries=x;exports.buildGraph=k;exports.saveGraph=v;exports.loadGraph=p;exports.generateHtml=E;exports.filterGraphByPeriod=P;exports.renderMermaid=T;exports.renderText=O;const g=$(require("fs"));const f=$(require("path"));const w=require("child_process");const A=require("./parser");const L=require("./storage");const R=require("@crewx/knowledge-core");const b=require("./native-adapter");const M=24;const N=7;const D=30;const C={stm:{label:`STM ${M}h`,ms:M*60*60*1e3},mtm:{label:`MTM ${N}d`,ms:N*24*60*60*1e3},ltm:{label:`LTM ${D}d`,ms:D*24*60*60*1e3}};const F=["#6366f1","#8b5cf6","#ec4899","#f43f5e","#f97316","#eab308","#22c55e","#14b8a6","#06b6d4","#3b82f6"];function x(s){return(0,L.withRecoveredAgentReadSync)(f.default.dirname(s),()=>_(s))}function _(s){if(!g.default.existsSync(s))return[];const t=g.default.readdirSync(s).filter(i=>i.endsWith(".md"));const n=[];for(const i of t){const o=g.default.readFileSync(f.default.join(s,i),"utf-8");const{data:a,content:r}=(0,A.parseFrontmatter)(o);n.push({file:i,content:r,...a})}return n}function k(s,t={}){const{edgeThreshold:n=.3,includeSameDay:i=false}=t;const o=x(s);if(o.length===0){return null}const a=o.map(e=>({id:e.id,type:e["type"]||"memory",category:e.category||"general",tags:e.tags||[],date:e.date||"",summary:e.summary||"",body:e.content||""}));const r=(0,R.buildGraph)(a,{edgeThreshold:n,includeSameDay:i});return{nodes:r.nodes.map(e=>({...e,important:o.find(l=>l.id===e.id)?.important})),edges:r.edges,stats:r.stats,updated:new Date().toISOString()}}function v(s,t){t.updated=new Date().toISOString();g.default.writeFileSync(s,JSON.stringify(t,null,2),"utf-8")}function p(s){if(!g.default.existsSync(s)){return{nodes:[],edges:[],stats:{nodeCount:0,edgeCount:0},updated:null}}return JSON.parse(g.default.readFileSync(s,"utf-8"))}function E(s,t={}){const{colors:n=F,title:i="Memory Graph"}=t;if(Object.keys(s).length===0){return null}const o={};for(const[r,e]of Object.entries(s)){if(!e||!e.nodes||e.nodes.length===0){continue}const l=[...new Set(e.nodes.map(c=>c.tags?.[0]||"general"))];const d={};l.forEach((c,m)=>{d[c]=n[m%n.length]});const u=e.nodes.map(c=>{const m=c.summary?String(c.summary):c.id?String(c.id):"Unknown";const S=c.tags?.[0]||"general";return{id:c.id||"unknown",label:m.slice(0,40),fullLabel:m,topic:S,date:c.date||"-",color:d[S]}});const h=e.edges.map(c=>({source:c.from,target:c.to,weight:c.weight,type:c.type}));o[r]={nodes:u,links:h,topics:l,topicColors:d,updated:e.updated}}const a=Object.keys(o).map(r=>`<option value="${r}">${r}</option>`).join("");return`<!DOCTYPE html>
|
|
2
2
|
<html lang="en">
|
|
3
3
|
<head>
|
|
4
4
|
<meta charset="UTF-8">
|
|
5
5
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
6
|
-
<title>${
|
|
6
|
+
<title>${i}</title>
|
|
7
7
|
<script src="https://d3js.org/d3.v7.min.js"><\/script>
|
|
8
8
|
<style>
|
|
9
9
|
* { margin: 0; padding: 0; box-sizing: border-box; }
|
|
@@ -110,7 +110,7 @@
|
|
|
110
110
|
<div id="graph"></div>
|
|
111
111
|
|
|
112
112
|
<div class="controls">
|
|
113
|
-
<h3>\u{1F4CA} ${
|
|
113
|
+
<h3>\u{1F4CA} ${i}</h3>
|
|
114
114
|
<select id="agentSelect">${a}</select>
|
|
115
115
|
<select id="periodSelect">
|
|
116
116
|
<option value="all">All</option>
|
|
@@ -325,14 +325,14 @@
|
|
|
325
325
|
});
|
|
326
326
|
<\/script>
|
|
327
327
|
</body>
|
|
328
|
-
</html>`}function
|
|
328
|
+
</html>`}function G(s){if(!s)return null;const t=String(s);const n=t.includes("T")?new Date(t):new Date(`${t}T00:00:00Z`);return Number.isNaN(n.getTime())?null:n}function P(s,t){if(!t||t===true||t==="all"){return{graph:s,label:null,invalid:false}}const n=String(t).toLowerCase();const i=C[n];if(!i){return{graph:s,label:null,invalid:true}}const o=Date.now()-i.ms;const a=(s.nodes||[]).filter(l=>{const d=G(l.date);return d&&d.getTime()>=o});const r=new Set(a.map(l=>l.id));const e=(s.edges||[]).filter(l=>r.has(l.from)&&r.has(l.to));return{graph:{...s,nodes:a,edges:e,stats:{nodeCount:a.length,edgeCount:e.length}},label:i.label,invalid:false}}function z(s,t=30){const n=s?String(s):"";if(n.length<=t)return n;return n.slice(0,t)}function U(s){return String(s).replace(/\\/g,"\\\\").replace(/"/g,'\\"').replace(/\r?\n/g," ")}function y(s){return String(s||"").replace(/[^a-zA-Z0-9_-]/g,"_")}function B(s,t){if(!t||t.length===0)return s;const n=new Map;for(const o of t){if(o&&o.id){n.set(o.id,Boolean(o.important))}}if(n.size===0)return s;const i=(s.nodes||[]).map(o=>{if(n.has(o.id)){return{...o,important:n.get(o.id)}}return o});return{...s,nodes:i}}function T(s){const t=[];t.push("```mermaid");t.push("graph LR");const n={};for(const a of s.nodes||[]){const r=a.tags?.[0]||"general";if(!n[r])n[r]=[];n[r].push(a)}const i=Object.keys(n).sort((a,r)=>a.localeCompare(r));for(const a of i){const r=y(a||"general");t.push(` subgraph ${r}`);const e=n[a].slice().sort((l,d)=>{const u=String(l.id||"");const h=String(d.id||"");return u.localeCompare(h)});for(const l of e){const d=z(l.summary||l.id||"Unknown",30);const u=l.important?`\u2B50 ${d}`:d;const h=U(u);const c=y(l.id);t.push(` ${c}["${h}"]`)}t.push(" end")}const o=(s.edges||[]).filter(a=>Number(a.weight)>=.5);for(const a of o){const r=y(a.from);const e=y(a.to);const l=Number.isFinite(a.weight)?a.weight:Number(a.weight);const d=Number.isFinite(l)?l:a.weight;t.push(` ${r} -->|${d}| ${e}`)}t.push("```");return t.join("\n")}function O(s,t,n){console.log(`# ${t} relation graph
|
|
329
329
|
`);if(n.label&&!n.invalid){console.log(`> (Period filter: ${n.label})`)}console.log(`> Last updated: ${s.updated||"-"}`);console.log(`> Nodes: ${s.nodes.length} items | Edges: ${s.edges.length} items
|
|
330
|
-
`);if(s.nodes.length===0){console.log("No nodes match this period.");return}const
|
|
331
|
-
`);for(const[
|
|
332
|
-
`);const
|
|
333
|
-
`);const
|
|
334
|
-
\u{1F4CA} Top relations (top 10 by weight):`);const a=o.edges.sort((e,l)=>l.weight-e.weight).slice(0,10);const
|
|
330
|
+
`);if(s.nodes.length===0){console.log("No nodes match this period.");return}const i={};for(const r of s.nodes){const e=r.tags?.[0]||"general";if(!i[e])i[e]=[];i[e].push(r)}console.log(`## Clusters by tag
|
|
331
|
+
`);for(const[r,e]of Object.entries(i).sort((l,d)=>d[1].length-l[1].length)){console.log(`### ${r} (${e.length} items)`);for(const l of e.slice(0,5)){const d=s.edges.filter(u=>u.from===l.id||u.to===l.id).length;console.log(`- [${l.id}] ${l.summary} (Relations: ${d})`)}if(e.length>5){console.log(`- ... plus ${e.length-5} items`)}console.log("")}const o={};for(const r of s.edges){o[r.from]=(o[r.from]||0)+1;o[r.to]=(o[r.to]||0)+1}const a=Object.entries(o).sort((r,e)=>e[1]-r[1]).slice(0,5);if(a.length>0){console.log(`## Hub nodes (highly connected memories)
|
|
332
|
+
`);const r={};s.nodes.forEach(e=>r[e.id]=e);for(const[e,l]of a){const d=r[e];if(d){console.log(`- [${e}] ${d.summary} - ${l} relations`)}}}}class H{constructor(t){this.dataDir=t}useNative(){const t=(0,b.nativeRuntimeMode)();if(t==="node")return false;if(t==="go")return true;return(0,b.isNativeAdapterAvailable)()}runNative(t,n={}){const i=(0,b.nativeRunCommand)(this.dataDir,"mindmap",t,n);(0,b.writeNativeOutput)(i);if(i.exitCode!==0){throw new Error(i.stderr.trim()||i.stdout.trim()||`native graph command failed (exit ${i.exitCode})`)}}getAgentDir(t){return f.default.join(this.dataDir,t)}getEntriesDir(t){return f.default.join(this.getAgentDir(t),"entries")}getGraphPath(t){return f.default.join(this.getAgentDir(t),"graph.json")}getHtmlPath(){return f.default.join(this.dataDir,"mindmap.html")}build(t,n={}){if(this.useNative()){this.runNative(["build",t],{...n});return}console.log(`\u{1F528} Building graph for ${t}...
|
|
333
|
+
`);const i=this.getEntriesDir(t);const o=k(i,{edgeThreshold:.3,...n});if(!o){console.log("No memories found.");return}v(this.getGraphPath(t),o);console.log(`\u2705 Graph build complete!`);console.log(` Nodes: ${o.stats.nodeCount} items`);console.log(` Edges: ${o.stats.edgeCount} items`);console.log(` File: ${t}/graph.json`);if(o.edges.length>0){console.log(`
|
|
334
|
+
\u{1F4CA} Top relations (top 10 by weight):`);const a=o.edges.sort((e,l)=>l.weight-e.weight).slice(0,10);const r={};o.nodes.forEach(e=>r[e.id]=e.summary);for(const e of a){const l=(r[e.from]||e.from).slice(0,25);const d=(r[e.to]||e.to).slice(0,25);console.log(` [${e.weight}] ${l}... \u2194 ${d}...`)}}}show(t,n={}){if(this.useNative()){this.runNative(["show",t],{period:n.period,format:n.format});return}const i=p(this.getGraphPath(t));if(!i.nodes||i.nodes.length===0){console.log("No graph found. Run the build command first.");return}const o=P(i,n.period);if(o.invalid){console.log(`\u26A0\uFE0F Unknown period: ${n.period} (stm|mtm|ltm)`)}let a=o.invalid?i:o.graph;const r=x(this.getEntriesDir(t));a=B(a,r);const e=q(n.format);if(e==="text"){O(a,t,o);return}if(!a.nodes||a.nodes.length===0){console.log("No nodes match this period.");return}if(o.label&&!o.invalid){console.log(`(Period filter: ${o.label})`)}console.log(T(a))}related(t,n){if(this.useNative()){this.runNative(["related",t,n]);return}const i=p(this.getGraphPath(t));if(!i.nodes||i.nodes.length===0){console.log("No graph found. Run the build command first.");return}const o=i.nodes.find(e=>e.id===n);if(!o){console.log(`ID '${n}' not found.`);return}console.log(`## \u{1F517} [${n}] ${o.summary}
|
|
335
335
|
`);console.log(`- Date: ${o.date||"-"}`);console.log(`- Tags: ${(o.tags||[]).join(", ")||"-"}
|
|
336
|
-
`);const a=
|
|
337
|
-
`);const
|
|
338
|
-
Open in browser: open ${
|
|
336
|
+
`);const a=i.edges.filter(e=>e.from===n||e.to===n);if(a.length===0){console.log("No related memories found.");return}console.log(`### Related memories (${a.length} items)
|
|
337
|
+
`);const r={};i.nodes.forEach(e=>r[e.id]=e);a.sort((e,l)=>l.weight-e.weight);for(const e of a){const l=e.from===n?e.to:e.from;const d=r[l];if(d){const u=e.reasons.join(", ");console.log(`[${e.weight}] [${l}] ${d.summary}`);console.log(` \u2514\u2500 Relation reason: ${u}`)}}}add(t,n,i,o="manual"){if(this.useNative()){this.runNative(["add",t,n,i,o]);return}const a=p(this.getGraphPath(t));if(!a.nodes||a.nodes.length===0){console.log("No graph found. Run the build command first.");return}const r=a.nodes.find(d=>d.id===n);const e=a.nodes.find(d=>d.id===i);if(!r){console.log(`ID '${n}' not found.`);return}if(!e){console.log(`ID '${i}' not found.`);return}const l=a.edges.find(d=>d.from===n&&d.to===i||d.from===i&&d.to===n);if(l){console.log(`Already related: weight ${l.weight}`);return}a.edges.push({from:n,to:i,type:o,weight:1,reasons:[o],manual:true});v(this.getGraphPath(t),a);console.log(`\u2705 Relation added!`);console.log(` ${(r.summary||"").slice(0,30)}...`);console.log(` \u2194`);console.log(` ${(e.summary||"").slice(0,30)}...`)}remove(t,n,i){if(this.useNative()){this.runNative(["remove",t,n,i]);return}const o=p(this.getGraphPath(t));if(!o.edges||o.edges.length===0){console.log("No relations found.");return}const a=o.edges.findIndex(r=>r.from===n&&r.to===i||r.from===i&&r.to===n);if(a===-1){console.log("Relation not found.");return}o.edges.splice(a,1);v(this.getGraphPath(t),o);console.log(`\u{1F5D1}\uFE0F Relation removed: ${n} \u2194 ${i}`)}html(){if(this.useNative()){this.runNative(["html"]);return}if(!g.default.existsSync(this.dataDir)){console.log("Data directory not found.");return}const t=g.default.readdirSync(this.dataDir).filter(e=>{const l=f.default.join(this.dataDir,e);try{return g.default.statSync(l).isDirectory()}catch{return false}});const n={};let i=0;let o=0;for(const e of t){const l=p(this.getGraphPath(e));if(l.nodes&&l.nodes.length>0){n[e]=l;i+=l.nodes.length;o+=l.edges.length}}if(Object.keys(n).length===0){console.log("No graph found. Run the build command first.");return}const a=E(n,{title:"Memory Graph - All Agents"});if(!a){console.log("HTML generation failed");return}const r=this.getHtmlPath();g.default.writeFileSync(r,a,"utf-8");console.log(`\u2705 Shared graph visualization generated!`);console.log(` File: ${r}`);console.log(` Agents: ${Object.keys(n).length} items`);console.log(` all Nodes: ${i} items | all Edges: ${o} items`);console.log(`
|
|
338
|
+
Open in browser: open ${r}`)}open(t){const n=this.getHtmlPath();if(!g.default.existsSync(n)){console.log("mindmap.html not found. Run the html command first.");return}const i=`file://${n}${t?"?agent="+t:""}`;const o=t||"all";if(process.platform==="darwin"){try{j("Google Chrome",i);console.log(`\u2705 Opening graph in Chrome: ${o}`)}catch{try{j("Safari",i);console.log(`\u2705 Opening graph in Safari: ${o}`)}catch{(0,w.execFileSync)("open",[i]);console.log(`\u2705 Opening graph in the default browser: ${o}`)}}return}const a=process.platform==="win32"?"explorer.exe":"xdg-open";const r=(0,w.spawn)(a,[i],{detached:true,stdio:"ignore",windowsHide:true});r.on("error",e=>console.log(`Could not start ${a}: ${e.message}`));r.unref();console.log(`\u2705 Opening graph in the default browser: ${o}`)}}exports.MindmapEngine=H;function j(s,t){(0,w.execFileSync)("osascript",["-e","on run argv","-e",`tell application "${s}" to open location (item 1 of argv)`,"-e","end run",t])}function q(s){if(!s||s===true)return"mermaid";return String(s).toLowerCase()}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var
|
|
1
|
+
"use strict";var b=exports&&exports.__createBinding||(Object.create?(function(e,r,i,t){if(t===void 0)t=i;var n=Object.getOwnPropertyDescriptor(r,i);if(!n||("get"in n?!r.__esModule:n.writable||n.configurable)){n={enumerable:true,get:function(){return r[i]}}}Object.defineProperty(e,t,n)}):(function(e,r,i,t){if(t===void 0)t=i;e[t]=r[i]}));var g=exports&&exports.__setModuleDefault||(Object.create?(function(e,r){Object.defineProperty(e,"default",{enumerable:true,value:r})}):function(e,r){e["default"]=r});var y=exports&&exports.__importStar||(function(){var e=function(r){e=Object.getOwnPropertyNames||function(i){var t=[];for(var n in i)if(Object.prototype.hasOwnProperty.call(i,n))t[t.length]=n;return t};return e(r)};return function(r){if(r&&r.__esModule)return r;var i={};if(r!=null){for(var t=e(r),n=0;n<t.length;n++)if(t[n]!=="default")b(i,r,t[n])}g(i,r);return i}})();Object.defineProperty(exports,"__esModule",{value:true});exports.NATIVE_API_CAPABILITY=void 0;exports.getNativeMemoryArtifact=v;exports.nativeRuntimeMode=h;exports.isNativeAdapterAvailable=P;exports.callNativeRpc=u;exports.writeNativeOutput=M;exports.hostFor=m;exports.nativeLoadAllEntries=B;exports.nativeGetRecentEntries=j;exports.nativeRunCommand=C;exports.nativeRunHostCommand=T;exports.nativeGenerateSummary=$;const o=y(require("fs"));const s=y(require("path"));const A=require("child_process");const _=require("./native-host");exports.NATIVE_API_CAPABILITY="memory.api.v1";const N=5;const E=512*1024*1024;let l;function I(){const e=[];if(process.env.CREWX_SHELL_NATIVE_DIR){e.push(s.join(process.env.CREWX_SHELL_NATIVE_DIR,"@crewx","memory"))}const r=process.resourcesPath;if(typeof r==="string"){e.push(s.join(r,"shell-native","node_modules","@crewx","memory"))}let i=__dirname;for(let t=0;t<4;t++){e.push(i);const n=s.dirname(i);if(n===i)break;i=n}return e}function R(e){try{return JSON.parse(o.readFileSync(s.join(e,"package.json"),"utf8"))}catch{return null}}function O(e){const r=R(e);if(!r||r.name!=="@crewx/memory")return null;const i=s.join(e,"go","native-manifest.json");if(!o.existsSync(i))return null;const t=JSON.parse(o.readFileSync(i,"utf8"));if(typeof t.nativeBuildId!=="string"||!/^[0-9a-f]{64}$/u.test(t.nativeBuildId))return null;const n=Number(t.protocol);if(n!==N)return null;if(!Array.isArray(t.capabilities)||!t.capabilities.includes(exports.NATIVE_API_CAPABILITY))return null;const a={darwin:"darwin",linux:"linux",win32:"windows"}[process.platform];const p={arm64:"arm64",x64:"amd64"}[process.arch];if(!a||!p)return null;const c=t.targets?.[`${a}-${p}`];if(!c||typeof c.file!=="string")return null;const f=s.resolve(e,...c.file.split("/"));if(!o.existsSync(f))return null;if(process.platform!=="win32"){try{const d=o.statSync(f);if((d.mode&73)===0)o.chmodSync(f,d.mode|493)}catch{}}const w=Array.isArray(c.capabilities)?c.capabilities.filter(d=>typeof d==="string"):t.capabilities;return{executablePath:f,packageRoot:e,nativeBuildId:t.nativeBuildId,protocol:n,capabilities:w}}function v(){if(l!==void 0)return l;l=null;for(const e of I()){try{const r=O(e);if(r){l=r;break}}catch{}}return l}function h(){const e=process.env.CREWX_MEMORY_RUNTIME??"auto";return e==="go"||e==="node"?e:"auto"}function P(){if(h()==="node")return false;return v()!==null}function S(){const e=v();if(!e){throw new Error("Native memory executable is unavailable. Reinstall @crewx/memory, or set CREWX_MEMORY_RUNTIME=node to use the existing implementation.")}return e}function u(e,r={}){const i=S();const t=(0,A.spawnSync)(i.executablePath,[`--crewx-memory-protocol=${i.protocol}`,`--crewx-memory-build=${i.nativeBuildId}`,"api","rpc"],{input:JSON.stringify({version:1,...e}),encoding:"utf8",env:(0,_.withResolvedMemoryConfigEnv)(r.env??process.env),maxBuffer:E,windowsHide:true});if(t.error)throw t.error;const n=(t.stderr??"").trim();let a;try{a=JSON.parse(t.stdout??"")}catch{if(t.status===null){throw new Error(`Native memory was terminated${t.signal?` (${t.signal})`:""}.`)}throw new Error(`Native memory returned an invalid response (exit ${t.status})${n?`: ${n}`:""}`)}if(t.status!==0||!a.ok){throw new Error(a.error??(n||`Native memory failed (exit ${t.status})`))}return a}function M(e){if(e.stdout)process.stdout.write(e.stdout);if(e.stderr)process.stderr.write(e.stderr)}function m(e){return(0,_.prepareNativeHost)(e)}function B(e,r,i=false){const t=u({op:"entries",dataDir:e,args:[r],includeBody:i});return t.result??[]}function j(e,r,i=30,t={}){const n=u({op:"recent",dataDir:e,args:[r],days:i,includeBody:Boolean(t.includeBody)});return n.result??[]}function C(e,r,i,t={},n={}){return u({op:"command",dataDir:e,command:r,args:i,flags:t,...n.body===void 0?{}:{body:n.body},...n.rawSave?{rawSave:true}:{}})}function T(e,r,i,t={}){const n=m(e);return u({op:"command",dataDir:e.dataDir,command:r,args:i,flags:t,host:n.request},{env:n.env})}function $(e,r,i){const t=m(e);const n=u({op:"summary",dataDir:e.dataDir,args:[r],flags:{force:i},host:t.request},{env:t.env});if(n.stderr)process.stderr.write(n.stderr);return n.result}
|
|
@@ -29,6 +29,7 @@ interface ResolvedCrewxChild {
|
|
|
29
29
|
windowsHide: boolean;
|
|
30
30
|
}
|
|
31
31
|
export declare function resolveCrewxChild(env?: NodeJS.ProcessEnv, cwd?: string): ResolvedCrewxChild;
|
|
32
|
+
export declare function withResolvedMemoryConfigEnv(env?: NodeJS.ProcessEnv, cwd?: string): NodeJS.ProcessEnv;
|
|
32
33
|
export declare function prepareNativeHost(settings: MemoryEngineSettings, env?: NodeJS.ProcessEnv): PreparedNativeHost;
|
|
33
34
|
export declare function prepareCliHostRequest(env?: NodeJS.ProcessEnv): PreparedNativeHost;
|
|
34
35
|
export {};
|
package/dist/src/native-host.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var
|
|
1
|
+
"use strict";var v=exports&&exports.__createBinding||(Object.create?(function(r,e,n,t){if(t===void 0)t=n;var i=Object.getOwnPropertyDescriptor(e,n);if(!i||("get"in i?!e.__esModule:i.writable||i.configurable)){i={enumerable:true,get:function(){return e[n]}}}Object.defineProperty(r,t,i)}):(function(r,e,n,t){if(t===void 0)t=n;r[t]=e[n]}));var w=exports&&exports.__setModuleDefault||(Object.create?(function(r,e){Object.defineProperty(r,"default",{enumerable:true,value:e})}):function(r,e){r["default"]=e});var u=exports&&exports.__importStar||(function(){var r=function(e){r=Object.getOwnPropertyNames||function(n){var t=[];for(var i in n)if(Object.prototype.hasOwnProperty.call(n,i))t[t.length]=i;return t};return r(e)};return function(e){if(e&&e.__esModule)return e;var n={};if(e!=null){for(var t=r(e),i=0;i<t.length;i++)if(t[i]!=="default")v(n,e,t[i])}w(n,e);return n}})();Object.defineProperty(exports,"__esModule",{value:true});exports.resolveCrewxChild=d;exports.withResolvedMemoryConfigEnv=f;exports.prepareNativeHost=m;exports.prepareCliHostRequest=_;const l=u(require("fs"));const s=u(require("path"));const a=require("@crewx/sdk");const h=require("./settings");function d(r=process.env,e=process.cwd()){const n=(0,a.resolveCrewxExecutable)({env:r,cwd:e});if(!n.ok){const c=new Error((0,a.formatCrewxExecutableFailure)(n));Object.assign(c,{code:"CLI_UNRESOLVABLE"});throw c}const t=(0,a.createCrewxChildInvocation)(n,{baseEnv:r});const i=(0,a.resolveWindowsSpawnProgram)({command:t.command,env:t.env,cwd:e,packageName:"crewx",allowShellFallback:true});const o=(0,a.materializeWindowsSpawnProgram)(i,t.args);return{command:o.command,args:o.argv,env:t.env,shell:o.shell===true,windowsHide:o.windowsHide===true}}function f(r=process.env,e=process.cwd()){if(r.CREWX_CONFIG!==void 0)return r;const n=s.join(g(s.resolve(e)),"crewx.yaml");return{...r,CREWX_CONFIG:l.existsSync(n)?n:""}}function g(r){let e=r;for(;;){if(l.existsSync(s.join(e,".git")))return e;const n=s.dirname(e);if(n===e)return r;e=n}}function m(r,e=process.env){let n=null;let t;let i={...e};try{const o=d(e);n={command:o.command,args:o.args,shell:o.shell,windowsHide:o.windowsHide};i={...o.env}}catch(o){t=o instanceof Error?o.message:String(o)}i=f(i);if(process.versions.electron)i.ELECTRON_RUN_AS_NODE="1";return{env:i,request:{crewx:n,...t===void 0?{}:{crewxError:t},classifier:{command:process.execPath,args:[s.join(__dirname,"host-classifier.js")],shell:false,windowsHide:true},summary:{summaryDays:r.summaryDays,summarizerAgent:r.summarizerAgent,summarizerTimeoutMs:r.summarizerTimeout,searcherAgent:r.searcherAgent,searcherTimeoutMs:r.searcherTimeout}}}}function _(r=process.env){return m((0,h.resolveEngineSettings)({}),r)}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@crewx/memory",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.9.1-dev.1",
|
|
4
4
|
"description": "Memory engine for CrewX - markdown + frontmatter based long-term memory",
|
|
5
5
|
"type": "commonjs",
|
|
6
6
|
"main": "dist/src/engine.js",
|
|
@@ -42,9 +42,9 @@
|
|
|
42
42
|
"gray-matter": "^4.0.3",
|
|
43
43
|
"js-yaml": "^4.1.0",
|
|
44
44
|
"nanoid": "^3.3.11",
|
|
45
|
-
"@crewx/
|
|
46
|
-
"@crewx/
|
|
47
|
-
"@crewx/knowledge-core": "0.1.
|
|
45
|
+
"@crewx/shared": "0.9.1-dev.1",
|
|
46
|
+
"@crewx/sdk": "0.9.1-dev.1",
|
|
47
|
+
"@crewx/knowledge-core": "0.9.1-dev.1"
|
|
48
48
|
},
|
|
49
49
|
"devDependencies": {
|
|
50
50
|
"@types/js-yaml": "^4.0.9",
|