@stkxp/cli 0.1.4 → 0.1.5

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 CHANGED
@@ -18,7 +18,9 @@ expected: `langfuse-langchain` still declares a peer range capped at
18
18
  `langchain <0.4.0`, one release behind LangChain's v1 line that the rest of
19
19
  this package's dependency tree is on. npm resolves it by hoisting a single
20
20
  `@langchain/core` for everyone (verify with `npm ls @langchain/core` — there's
21
- only one copy), so it's safe to ignore.
21
+ only one copy), so it's safe to ignore. You may see the same pattern for
22
+ `dotenv` (via `@browserbasehq/stagehand`, an optional transitive dep of
23
+ `@langchain/community`) — same cause, same non-issue.
22
24
 
23
25
  Four commands, two machines:
24
26
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stkxp/cli",
3
- "version": "0.1.4",
3
+ "version": "0.1.5",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "description": "Export a Stack Expert Team as an encrypted, standalone-deployable bundle, and redeploy it on any Elasticsearch cluster.",
@@ -1,6 +1,6 @@
1
- import p from"isolated-vm";async function f(e){try{const s=await e.getHeapStatistics();return{wallTimeMs:Number(e.wallTime)/1e6,cpuTimeMs:Number(e.cpuTime)/1e6,heapUsedMb:s.used_heap_size/(1024*1024)}}catch{return}}function b(e){const s=e.split("."),o=/^[A-Za-z_$][A-Za-z0-9_$]*$/;for(const a of s)if(!o.test(a))throw new Error(`Invalid host function jsPath segment "${a}" in "${e}"`)}function w(e){const s=["const tools = {};"];return e.forEach((o,a)=>{b(o.jsPath);const l=o.jsPath.split(".");let i="tools";for(let n=0;n<l.length-1;n++)i+=`.${l[n]}`,s.push(`${i} = ${i} || {};`);const u=`tools.${o.jsPath}`;s.push(`${u} = function(args) {`,` return __hostRef_${a}.apply(undefined, [JSON.stringify(args)], { arguments: { copy: true }, result: { promise: true, copy: true } })`," .then((json) => json === undefined ? undefined : JSON.parse(json));","};")}),s.join(`
2
- `)}async function $(e){const{scriptBody:s,hostFunctions:o,timeoutMs:a,maxMemoryMb:l,extraGlobals:i}=e,u=[];let n;try{n=new p.Isolate({memoryLimit:l});const g=await n.createContext(),c=g.global;await c.set("global",c.derefInto());const y=new p.Reference((...t)=>{u.push(t.map(r=>typeof r=="string"?r:JSON.stringify(r)).join(" "))});await c.set("__consoleLog",y);for(let t=0;t<o.length;t++){const r=o[t],m=new p.Reference(async S=>await r.call(S));await c.set(`__hostRef_${t}`,m)}if(i)for(const[t,r]of Object.entries(i))await c.set(t,r,{copy:!0});const h=`${["const console = { log: (...args) => __hostLogWrapper(...args) };",'function __hostLogWrapper(...args) { __consoleLog.applySync(undefined, args.map(a => typeof a === "string" ? a : JSON.stringify(a)), { arguments: { copy: true } }); }',w(o)].join(`
1
+ async function b(){const e=await import("isolated-vm");return e.default??e}async function g(e){try{const n=await e.getHeapStatistics();return{wallTimeMs:Number(e.wallTime)/1e6,cpuTimeMs:Number(e.cpuTime)/1e6,heapUsedMb:n.used_heap_size/(1024*1024)}}catch{return}}function w(e){const n=e.split("."),s=/^[A-Za-z_$][A-Za-z0-9_$]*$/;for(const r of n)if(!s.test(r))throw new Error(`Invalid host function jsPath segment "${r}" in "${e}"`)}function x(e){const n=["const tools = {};"];return e.forEach((s,r)=>{w(s.jsPath);const l=s.jsPath.split(".");let i="tools";for(let a=0;a<l.length-1;a++)i+=`.${l[a]}`,n.push(`${i} = ${i} || {};`);const u=`tools.${s.jsPath}`;n.push(`${u} = function(args) {`,` return __hostRef_${r}.apply(undefined, [JSON.stringify(args)], { arguments: { copy: true }, result: { promise: true, copy: true } })`," .then((json) => json === undefined ? undefined : JSON.parse(json));","};")}),n.join(`
2
+ `)}async function v(e){const{scriptBody:n,hostFunctions:s,timeoutMs:r,maxMemoryMb:l,extraGlobals:i}=e,u=[],a=await b();let c;try{c=new a.Isolate({memoryLimit:l});const f=await c.createContext(),m=f.global;await m.set("global",m.derefInto());const y=new a.Reference((...t)=>{u.push(t.map(o=>typeof o=="string"?o:JSON.stringify(o)).join(" "))});await m.set("__consoleLog",y);for(let t=0;t<s.length;t++){const o=s[t],p=new a.Reference(async S=>await o.call(S));await m.set(`__hostRef_${t}`,p)}if(i)for(const[t,o]of Object.entries(i))await m.set(t,o,{copy:!0});const h=`${["const console = { log: (...args) => __hostLogWrapper(...args) };",'function __hostLogWrapper(...args) { __consoleLog.applySync(undefined, args.map(a => typeof a === "string" ? a : JSON.stringify(a)), { arguments: { copy: true } }); }',x(s)].join(`
3
3
  `)}
4
4
  (async () => {
5
- ${s}
6
- })()`;let d;try{d=await n.compileScript(h)}catch(t){return{ok:!1,consoleLogs:u,error:{kind:"syntax",message:t.message}}}try{return{ok:!0,value:await d.run(g,{timeout:a,promise:!0,copy:!0}),consoleLogs:u,stats:await f(n)}}catch(t){const r=/timed? ?out/i.test(t.message??""),m=/isolate.*disposed|memory/i.test(t.message??"");return{ok:!1,consoleLogs:u,error:{kind:r?"timeout":m?"memory":"runtime",message:t.message??String(t)},stats:await f(n)}}}finally{n?.dispose()}}export{$ as runInSandbox};
5
+ ${n}
6
+ })()`;let d;try{d=await c.compileScript(h)}catch(t){return{ok:!1,consoleLogs:u,error:{kind:"syntax",message:t.message}}}try{return{ok:!0,value:await d.run(f,{timeout:r,promise:!0,copy:!0}),consoleLogs:u,stats:await g(c)}}catch(t){const o=/timed? ?out/i.test(t.message??""),p=/isolate.*disposed|memory/i.test(t.message??"");return{ok:!1,consoleLogs:u,error:{kind:o?"timeout":p?"memory":"runtime",message:t.message??String(t)},stats:await g(c)}}}finally{c?.dispose()}}export{v as runInSandbox};