@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
|
-
|
|
2
|
-
`)}async function
|
|
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
|
-
${
|
|
6
|
-
})()`;let d;try{d=await
|
|
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};
|