@lmctl-ai/lmctl 0.2.233 → 0.2.235
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/CHANGELOG.md +1 -1
- package/build-info.json +1 -1
- package/dist/cli/lmscript.js +3 -3
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
|
|
12
12
|
- Script properties accept a leading --pref FILE for per-property TOML refinement, including new slots, without changing strict lmctl init/profile validation. Nested scripts share effective values; runtime edits remain in memory.
|
|
13
13
|
|
|
14
|
-
- Schema calls have no default timeout. Run cancellation
|
|
14
|
+
- Schema calls have no default timeout or output cap. Run cancellation remains; SDK timeoutMs and maxOutputBytes are honored only when explicitly supplied.
|
|
15
15
|
|
|
16
16
|
- Schema tools now use the caller’s PATH through normal OS launching, including empty, dot and relative entries; no custom executable filter.
|
|
17
17
|
|
package/build-info.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"sha": "
|
|
1
|
+
{"sha": "0f50642832feb340221af8321d3f9d039b742bf0", "dirty": false, "builtAt": "2026-10-11T23:50:57.000Z"}
|
package/dist/cli/lmscript.js
CHANGED
|
@@ -33,9 +33,9 @@ try {
|
|
|
33
33
|
} finally {
|
|
34
34
|
clearTimeout(timer);
|
|
35
35
|
}
|
|
36
|
-
`,r=My(process.execPath,["--input-type=module","-e",n,t],{encoding:"utf8",shell:!1,timeout:35e3,maxBuffer:yd+4096,windowsHide:!0});if(r.error)throw r.error.code==="ETIMEDOUT"?new Error("http_get() request timed out"):new Error(`http_get() failed: ${r.error.message}`);if(r.status!==0)throw new Error(`http_get() failed: ${String(r.stderr||"child process exited")}`.trim());return String(r.stdout||"")}async function UC(t){if(typeof t!="string"||!t.trim())throw new Error("http_get() requires a non-empty URL string");let e;try{e=new URL(t)}catch{throw new Error("http_get() requires a valid HTTP(S) URL")}if(e.protocol!=="http:"&&e.protocol!=="https:"||e.username||e.password)throw new Error("http_get() only permits HTTP(S) URLs without embedded credentials");let n=new AbortController,r=setTimeout(()=>n.abort(),3e4),s;try{let i=await fetch(e.toString(),{method:"GET",redirect:"follow",signal:n.signal});if(!i.ok)throw n.abort(),new Error("HTTP "+i.status+" "+i.statusText);s=i.body?.getReader();let o=[],a=0;if(s)for(;;){let l=await s.read();if(l.done)break;if(a+=l.value.byteLength,a>yd)throw await s.cancel().catch(()=>{}),n.abort(),new Error("response exceeds 10 MiB limit");o.push(l.value)}return Buffer.concat(o).toString("utf-8")}catch(i){if(n.abort(),s)try{await s.cancel().catch(()=>{})}catch{}throw i.name==="AbortError"?new Error("http_get() request timed out"):new Error(`http_get() failed: ${i?.message||String(i)}`)}finally{clearTimeout(r)}}function Ha(t,e,n,r=null,s=!1,i=0,o=null){return{stdout:t,stderr:e,code:n,signal:r,timed_out:s,duration_ms:i,pid:o}}function jy(t){if(!Array.isArray(t))throw new Error("command: argv must be a list of strings or numbers");return Array.from(t,e=>{if(typeof e!="string"&&typeof e!="number")throw new Error("command: argv elements must be strings or numbers");let n=String(e);if(n.includes("\0"))throw new Error("command: NUL is not allowed in argv");return n})}function Dd(t,e,n){if(!Number.isSafeInteger(e)||e<0||e>2147483647)throw new Error("system() timeout must be a non-negative safe integer from 0 to 2147483647 milliseconds (0 disables the deadline)");if(!Array.isArray(t))throw new Error(HC);let r=jy(t);if(!r.length)throw new Error("system() argv array must not be empty");if(!r[0])throw new Error("command: a non-empty program is required");if(n==="win32"&&/\.(cmd|bat)$/i.test(r[0]))throw new Error("command: .cmd/.bat shims need cmd.exe; invoke the underlying executable, e.g. node with its script");return r}function Ba(t,e){let n=t instanceof Error?t:new Error(String(t));return e==="win32"&&n.code==="EINVAL"?Object.assign(new Error("command: Windows refused this program; .cmd/.bat shims need cmd.exe; invoke the underlying executable, e.g. node with its script",{cause:n}),{code:"EINVAL"}):n}function Fd(t,e,n=process.platform){if(e=e===void 0?n==="win32"?"windows":"posix":e,!["posix","windows","powershell"].includes(e))throw new Error("cmd_render: unknown dialect '"+e+"'; choose posix, windows, powershell");return jy(t).map(s=>{if(e==="posix")return s&&/^[A-Za-z0-9_./@=-]+$/.test(s)?s:"'"+s.replaceAll("'","'\\''")+"'";if(e==="powershell")return"'"+s.replace(/['\u2018-\u201b]/g,a=>a+a)+"'";if(s&&!/[ \t"]/.test(s))return s;let i='"',o=0;for(let a of s){if(a==="\\"){o++;continue}a==='"'?i+="\\".repeat(2*o+1)+'"':i+="\\".repeat(o)+a,o=0}return i+"\\".repeat(2*o)+'"'}).join(" ")}function ud(t,e,n,r=process.platform){if(typeof t!="string"||!t||t.includes("\0"))throw Error("which: expected a nonempty executable name without NUL");let s=r==="win32",i=/[\\/]/.test(t)?[e]:(n.PATH??"").split(s?";":pe.delimiter),o=s?(n.PATHEXT??".COM;.EXE;.BAT;.CMD").split(";").filter(Boolean):[""];for(let a of i){let l=pe.resolve(e,a||".",t);for(let c of s&&o.some(u=>t.toLowerCase().endsWith(u.toLowerCase()))?[""]:o){let u=l+c;try{if(!W.statSync(u).isFile())continue;return s||W.accessSync(u,W.constants.X_OK),u}catch{}}}return null}function _d(t,e=6e4,n=process.platform,r){let s=Dd(t,e,n),i=performance.now(),o;try{let p={...r,shell:!1,encoding:"utf-8",timeout:e>0?e:void 0,detached:process.platform!=="win32",maxBuffer:10485760,killSignal:"SIGKILL"};o=My(s[0],s.slice(1),p)}catch(p){throw Ba(p,n)}let a=Math.max(0,Math.round(performance.now()-i)),l=typeof o.pid=="number"?o.pid:null;if(o.error){if(process.platform!=="win32"&&l)try{process.kill(-l,"SIGKILL")}catch{}if(o.error.code==="ETIMEDOUT"){let p=o.stdout!=null?String(o.stdout):"",f=o.stderr!=null?String(o.stderr):"";return Ha(p,f,null,o.signal||"SIGKILL",!0,a,l)}throw Ba(o.error,n)}let c=o.stdout!=null?String(o.stdout):"",u=o.stderr!=null?String(o.stderr):"",d=o.status!==null?o.status:null,m=o.signal!==null?String(o.signal):null;return Ha(c,u,d,m,!1,a,l)}function Ki(t,e=6e4,n=process.platform,r,s,i){return new Promise((o,a)=>{let l;try{l=Dd(t,e,n)}catch(u){a(u);return}if(r?.aborted){a(new Error("Aborted"));return}let c=performance.now();try{let u=process.platform!=="win32",d=PC(l[0],l.slice(1),{...s,shell:!1,detached:u,stdio:["ignore","pipe","pipe"]});Ua.add(d);let m="",p="",f=null,g=null,h=0,y=!1,E=!1,_,v=!1,w,I=()=>{if(v)return;v=!0,Ua.delete(d),w&&clearTimeout(w),r?.removeEventListener("abort",T);try{d.stdout?.destroy(),d.stderr?.destroy()}catch{}let N=Math.max(0,Math.round(performance.now()-c)),C=typeof d.pid=="number"?d.pid:null;if(_){a(_);return}if(E){o(Ha(m,p,null,g||"SIGKILL",!0,N,C));return}o(Ha(m,p,f,g,!1,N,C))},T=()=>{if(!v){_=new Error("Aborted");try{if(u&&d.pid)try{process.kill(-d.pid,"SIGKILL")}catch{d.kill("SIGKILL")}else d.kill("SIGKILL")}catch{}I()}};e>0&&(w=setTimeout(()=>{E=!0,g="SIGKILL";try{if(u&&d.pid)try{process.kill(-d.pid,"SIGKILL")}catch{d.kill("SIGKILL")}else d.kill("SIGKILL")}catch{}I()},e));let k=i?.maxOutputBytes??10*1024*1024;d.stdout?.setEncoding("utf-8"),d.stderr?.setEncoding("utf-8"),d.stdout?.on("data",N=>{let C=Buffer.byteLength(N,"utf-8");if(h+C>k){if(!y){y=!0;try{if(u&&d.pid)try{process.kill(-d.pid,"SIGKILL")}catch{d.kill("SIGKILL")}else d.kill("SIGKILL")}catch{}p+=(p&&!p.endsWith(`
|
|
36
|
+
`,r=My(process.execPath,["--input-type=module","-e",n,t],{encoding:"utf8",shell:!1,timeout:35e3,maxBuffer:yd+4096,windowsHide:!0});if(r.error)throw r.error.code==="ETIMEDOUT"?new Error("http_get() request timed out"):new Error(`http_get() failed: ${r.error.message}`);if(r.status!==0)throw new Error(`http_get() failed: ${String(r.stderr||"child process exited")}`.trim());return String(r.stdout||"")}async function UC(t){if(typeof t!="string"||!t.trim())throw new Error("http_get() requires a non-empty URL string");let e;try{e=new URL(t)}catch{throw new Error("http_get() requires a valid HTTP(S) URL")}if(e.protocol!=="http:"&&e.protocol!=="https:"||e.username||e.password)throw new Error("http_get() only permits HTTP(S) URLs without embedded credentials");let n=new AbortController,r=setTimeout(()=>n.abort(),3e4),s;try{let i=await fetch(e.toString(),{method:"GET",redirect:"follow",signal:n.signal});if(!i.ok)throw n.abort(),new Error("HTTP "+i.status+" "+i.statusText);s=i.body?.getReader();let o=[],a=0;if(s)for(;;){let l=await s.read();if(l.done)break;if(a+=l.value.byteLength,a>yd)throw await s.cancel().catch(()=>{}),n.abort(),new Error("response exceeds 10 MiB limit");o.push(l.value)}return Buffer.concat(o).toString("utf-8")}catch(i){if(n.abort(),s)try{await s.cancel().catch(()=>{})}catch{}throw i.name==="AbortError"?new Error("http_get() request timed out"):new Error(`http_get() failed: ${i?.message||String(i)}`)}finally{clearTimeout(r)}}function Ha(t,e,n,r=null,s=!1,i=0,o=null){return{stdout:t,stderr:e,code:n,signal:r,timed_out:s,duration_ms:i,pid:o}}function jy(t){if(!Array.isArray(t))throw new Error("command: argv must be a list of strings or numbers");return Array.from(t,e=>{if(typeof e!="string"&&typeof e!="number")throw new Error("command: argv elements must be strings or numbers");let n=String(e);if(n.includes("\0"))throw new Error("command: NUL is not allowed in argv");return n})}function Dd(t,e,n){if(!Number.isSafeInteger(e)||e<0||e>2147483647)throw new Error("system() timeout must be a non-negative safe integer from 0 to 2147483647 milliseconds (0 disables the deadline)");if(!Array.isArray(t))throw new Error(HC);let r=jy(t);if(!r.length)throw new Error("system() argv array must not be empty");if(!r[0])throw new Error("command: a non-empty program is required");if(n==="win32"&&/\.(cmd|bat)$/i.test(r[0]))throw new Error("command: .cmd/.bat shims need cmd.exe; invoke the underlying executable, e.g. node with its script");return r}function Ba(t,e){let n=t instanceof Error?t:new Error(String(t));return e==="win32"&&n.code==="EINVAL"?Object.assign(new Error("command: Windows refused this program; .cmd/.bat shims need cmd.exe; invoke the underlying executable, e.g. node with its script",{cause:n}),{code:"EINVAL"}):n}function Fd(t,e,n=process.platform){if(e=e===void 0?n==="win32"?"windows":"posix":e,!["posix","windows","powershell"].includes(e))throw new Error("cmd_render: unknown dialect '"+e+"'; choose posix, windows, powershell");return jy(t).map(s=>{if(e==="posix")return s&&/^[A-Za-z0-9_./@=-]+$/.test(s)?s:"'"+s.replaceAll("'","'\\''")+"'";if(e==="powershell")return"'"+s.replace(/['\u2018-\u201b]/g,a=>a+a)+"'";if(s&&!/[ \t"]/.test(s))return s;let i='"',o=0;for(let a of s){if(a==="\\"){o++;continue}a==='"'?i+="\\".repeat(2*o+1)+'"':i+="\\".repeat(o)+a,o=0}return i+"\\".repeat(2*o)+'"'}).join(" ")}function ud(t,e,n,r=process.platform){if(typeof t!="string"||!t||t.includes("\0"))throw Error("which: expected a nonempty executable name without NUL");let s=r==="win32",i=/[\\/]/.test(t)?[e]:(n.PATH??"").split(s?";":pe.delimiter),o=s?(n.PATHEXT??".COM;.EXE;.BAT;.CMD").split(";").filter(Boolean):[""];for(let a of i){let l=pe.resolve(e,a||".",t);for(let c of s&&o.some(u=>t.toLowerCase().endsWith(u.toLowerCase()))?[""]:o){let u=l+c;try{if(!W.statSync(u).isFile())continue;return s||W.accessSync(u,W.constants.X_OK),u}catch{}}}return null}function _d(t,e=6e4,n=process.platform,r){let s=Dd(t,e,n),i=performance.now(),o;try{let p={...r,shell:!1,encoding:"utf-8",timeout:e>0?e:void 0,detached:process.platform!=="win32",maxBuffer:10485760,killSignal:"SIGKILL"};o=My(s[0],s.slice(1),p)}catch(p){throw Ba(p,n)}let a=Math.max(0,Math.round(performance.now()-i)),l=typeof o.pid=="number"?o.pid:null;if(o.error){if(process.platform!=="win32"&&l)try{process.kill(-l,"SIGKILL")}catch{}if(o.error.code==="ETIMEDOUT"){let p=o.stdout!=null?String(o.stdout):"",f=o.stderr!=null?String(o.stderr):"";return Ha(p,f,null,o.signal||"SIGKILL",!0,a,l)}throw Ba(o.error,n)}let c=o.stdout!=null?String(o.stdout):"",u=o.stderr!=null?String(o.stderr):"",d=o.status!==null?o.status:null,m=o.signal!==null?String(o.signal):null;return Ha(c,u,d,m,!1,a,l)}function Ki(t,e=6e4,n=process.platform,r,s,i){return new Promise((o,a)=>{let l;try{l=Dd(t,e,n)}catch(u){a(u);return}if(r?.aborted){a(new Error("Aborted"));return}let c=performance.now();try{let u=process.platform!=="win32",d=PC(l[0],l.slice(1),{...s,shell:!1,detached:u,stdio:["ignore","pipe","pipe"]});Ua.add(d);let m="",p="",f=null,g=null,h=0,y=!1,E=!1,_,v=!1,w,I=()=>{if(v)return;v=!0,Ua.delete(d),w&&clearTimeout(w),r?.removeEventListener("abort",T);try{d.stdout?.destroy(),d.stderr?.destroy()}catch{}let N=Math.max(0,Math.round(performance.now()-c)),C=typeof d.pid=="number"?d.pid:null;if(_){a(_);return}if(E){o(Ha(m,p,null,g||"SIGKILL",!0,N,C));return}o(Ha(m,p,f,g,!1,N,C))},T=()=>{if(!v){_=new Error("Aborted");try{if(u&&d.pid)try{process.kill(-d.pid,"SIGKILL")}catch{d.kill("SIGKILL")}else d.kill("SIGKILL")}catch{}I()}};e>0&&(w=setTimeout(()=>{E=!0,g="SIGKILL";try{if(u&&d.pid)try{process.kill(-d.pid,"SIGKILL")}catch{d.kill("SIGKILL")}else d.kill("SIGKILL")}catch{}I()},e));let k=i?.maxOutputBytes??10*1024*1024;d.stdout?.setEncoding("utf-8"),d.stderr?.setEncoding("utf-8"),d.stdout?.on("data",N=>{let C=Buffer.byteLength(N,"utf-8");if(k>0&&h+C>k){if(!y){y=!0;try{if(u&&d.pid)try{process.kill(-d.pid,"SIGKILL")}catch{d.kill("SIGKILL")}else d.kill("SIGKILL")}catch{}p+=(p&&!p.endsWith(`
|
|
37
37
|
`)?`
|
|
38
|
-
`:"")+"system() output exceeds "+(k===10*1024*1024?"10 MiB":k+" byte")+" limit",_=Object.assign(new Error("system() output exceeds "+(k===10*1024*1024?"10 MiB":k+" byte")+" limit"),{code:"ERR_OUTPUT_LIMIT"}),I()}return}h+=C,m+=N}),d.stderr?.on("data",N=>{let C=Buffer.byteLength(N,"utf-8");if(h+C>k){if(!y){y=!0;try{if(u&&d.pid)try{process.kill(-d.pid,"SIGKILL")}catch{d.kill("SIGKILL")}else d.kill("SIGKILL")}catch{}p+=(p&&!p.endsWith(`
|
|
38
|
+
`:"")+"system() output exceeds "+(k===10*1024*1024?"10 MiB":k+" byte")+" limit",_=Object.assign(new Error("system() output exceeds "+(k===10*1024*1024?"10 MiB":k+" byte")+" limit"),{code:"ERR_OUTPUT_LIMIT"}),I()}return}h+=C,m+=N}),d.stderr?.on("data",N=>{let C=Buffer.byteLength(N,"utf-8");if(k>0&&h+C>k){if(!y){y=!0;try{if(u&&d.pid)try{process.kill(-d.pid,"SIGKILL")}catch{d.kill("SIGKILL")}else d.kill("SIGKILL")}catch{}p+=(p&&!p.endsWith(`
|
|
39
39
|
`)?`
|
|
40
40
|
`:"")+"system() output exceeds "+(k===10*1024*1024?"10 MiB":k+" byte")+" limit",_=Object.assign(new Error("system() output exceeds "+(k===10*1024*1024?"10 MiB":k+" byte")+" limit"),{code:"ERR_OUTPUT_LIMIT"}),I()}return}h+=C,p+=N}),d.on("error",N=>{_||(_=Ba(N,n))}),d.on("close",(N,C)=>{N!==null?(f=N,g=null):(f=null,g=C?String(C):null),I()}),r?.addEventListener("abort",T,{once:!0}),r?.aborted&&T()}catch(u){a(Ba(u,n))}})}function BC(t,e=null){if(typeof t!="string")return t??e;let n=t.trim();if(n.length===0)return e;try{return JSON.parse(n)}catch{}let r=n.match(/```(?:json)?\s*\n?([\s\S]*?)\n?```/);if(r&&r[1])try{return JSON.parse(r[1].trim())}catch{}let s=n.indexOf("{"),i=n.lastIndexOf("}");if(s!==-1&&i>s)try{return JSON.parse(n.slice(s,i+1))}catch{}let o=n.indexOf("["),a=n.lastIndexOf("]");if(o!==-1&&a>o)try{return JSON.parse(n.slice(o,a+1))}catch{}return e}function Uy(t){if(typeof process>"u"||!process.stdin||!process.stdin.isTTY)return null;t!=null&&process.stdout&&typeof process.stdout.write=="function"&&process.stdout.write(String(t));try{let e=Buffer.alloc(1024),n="";for(;;){let r=0;try{r=W.readSync(0,e,0,1,null)}catch{return n.length>0?n:null}if(r===0)return n.length>0?n:null;let s=e.toString("utf-8",0,r);if(s===`
|
|
41
41
|
`)return n.endsWith("\r")&&(n=n.slice(0,-1)),n;n+=s}}catch{return null}}function Qa(t,e=typeof process<"u"?process.stdin:null,n=typeof process<"u"?process.stdout:null,r){return new Promise(s=>{if(r?.aborted||!e||typeof e.on!="function"){s(null);return}if(e.destroyed||e.readableEnded){s(null);return}if(e.isTTY===!1||typeof process<"u"&&e===process.stdin&&!process.stdin.isTTY){s(null);return}t!=null&&n&&typeof n.write=="function"&&n.write(String(t));let i=Py.createInterface({input:e,output:n,terminal:!!e.isTTY}),o=!1,a=()=>i.close(),l=()=>{r?.removeEventListener("abort",a),i.close()};if(i.on("close",()=>{r?.removeEventListener("abort",a),o||(o=!0,s(null))}),i.on("error",()=>{o||(o=!0,l(),s(null))}),r?.addEventListener("abort",a,{once:!0}),r?.aborted){l();return}i.question("",c=>{o||(o=!0,l(),s(c))})})}async function Hy(t,e){let n=pe.resolve(String(e.dir));W.mkdirSync(n,{recursive:!0});let r=e.sessionId??`prompt_${Date.now()}_${Math.random().toString(36).slice(2,8)}`,s=r.replace(/[/\\?%*:|"<>]/g,"_"),i=pe.join(n,`${s}.out`),o=pe.join(n,`${s}.out_state`),a=pe.join(n,`${s}.in`),l=pe.join(n,`${s}.in_state`);try{W.existsSync(l)&&W.unlinkSync(l)}catch{}try{W.existsSync(a)&&W.unlinkSync(a)}catch{}W.writeFileSync(i,t!=null?String(t):"","utf-8"),W.writeFileSync(o,JSON.stringify({sessionId:r,status:"waiting",timestamp:Date.now()})+`
|
|
@@ -2399,7 +2399,7 @@ To experiment with it manually: https://lmctl.com/lmctl/docs/manual-invocation`}
|
|
|
2399
2399
|
FOREIGN KEY (local_scope, conversationid) REFERENCES workflow_jobs(local_scope, conversationid)
|
|
2400
2400
|
)`)}function hA(t,e,n){if(!qh(t)||n&&!Object.keys(t).length)throw new Ve("Expected a nonempty column map");let r={};for(let[s,i]of Object.entries(t)){if(!N2[e].includes(s))throw new Ve(`Unknown ${e} column: ${s}`);if(s==="payload"){let o;try{o=JSON.stringify(i)}catch{throw new Ve("payload must be JSON")}if(o===void 0)throw new Ve("payload must be JSON");r[s]=o}else if(["pid","claimed_ms","attempts"].includes(s)){if(!(i===null&&s!=="attempts")&&!(typeof i=="number"&&Number.isSafeInteger(i)&&i>=0))throw new Ve(`${s} must be a nonnegative safe integer${s==="attempts"?"":" or null"}`);r[s]=i}else{if(!(typeof i=="string"||s==="answer_text"&&i===null))throw new Ve(`${s} must be a string${s==="answer_text"?" or null":""}`);r[s]=i}}return r}function yA(t){return Object.hasOwn(t,"escalationid")?{...t,payload:JSON.parse(t.payload),answer_present:t.answer_text!==null}:t}function _A(t,e,n){let r,s=!1;try{if(t.signal?.aborted)return Rt("cancelled","cancelled");let i=ba.find(v=>v.name===e);if(!i)throw new Error(`Unknown storage operation: ${e}`);if(!qh(n))throw new Ve("options must be a map");for(let v of Object.keys(n))if(!i.keys.some(w=>w.name===v))throw new Ve(`Unknown option: ${v}`);for(let v of i.keys){let w=n[v.name];if(!(w===void 0&&!v.required)){if(v.type==="string"?typeof w!="string"||v.name!=="state"&&!w.length:!qh(w))throw new Ve(`Invalid ${v.name}`);if("values"in v&&v.values&&!v.values.includes(w))throw new Ve(`Invalid ${v.name}`)}}let o=n,a=e==="lmbee_job_claim"?"escalation":o.row;if(a==="job"&&o.escalationid!==void 0)throw new Ve("job selection cannot include escalationid");if(s=e!=="lmbee_job_read",e==="lmbee_job_write"&&a==="escalation"&&!o.escalationid)throw new Ve("child write requires escalationid");let l=e==="lmbee_job_write"?hA(o.values,a,!0):{},c=o.where===void 0?{}:hA(o.where,a,e==="lmbee_job_claim");if(e==="lmbee_job_write"&&o.operation==="insert"){if(o.where!==void 0)throw new Ve("insert does not accept where");for(let v of a==="job"?["status"]:["payload","state"])if(!Object.hasOwn(l,v))throw new Ve(`insert requires ${v}`)}if(o.db.startsWith("~")||o.db===":memory:")throw new Ve("db must select an explicit durable database path");let u=C2(o.db)?o.db:A2(t.cwd,o.db);if(mA(u),r=new Bh(u,{readonly:!s,fileMustExist:!0}),pA(r),fA(r),s)Xh(r);else if(!r.prepare("SELECT name FROM sqlite_master WHERE type='table' AND name='workflow_jobs'").get())return Rt("no_rows");let d=r,m=[o.local_scope,o.conversationid],p=a==="job"?"workflow_jobs":"workflow_escalations",f="local_scope = ? AND conversationid = ?"+(o.escalationid?" AND escalationid = ?":""),g=[...m,...o.escalationid?[o.escalationid]:[]],h=()=>d.prepare(`SELECT * FROM ${p} WHERE ${f} ORDER BY ${a==="job"?"conversationid":"escalationid"}`).all(...g).map(yA),y=()=>d.prepare("SELECT 1 FROM workflow_jobs WHERE local_scope = ? AND conversationid = ?").get(...m),E=Object.keys(c).map(v=>`${v} IS ?`).join(" AND "),_=E?` AND ${E}`:"";if(!s){let v=h();return o.escalationid&&!v.length&&y()?Rt("error","selection_failed",[],!1,"No child matches this parent/child pair"):Rt(v.length?"ok":"no_rows",void 0,v)}return d.transaction(()=>{if(t.signal?.aborted)return Rt("cancelled","cancelled");if(a==="escalation"&&!y())return Rt("no_rows");if(e==="lmbee_job_write"&&o.operation==="insert"){let I={local_scope:o.local_scope,conversationid:o.conversationid,...a==="escalation"?{escalationid:o.escalationid}:{},...l};return d.prepare(`INSERT INTO ${p} (${Object.keys(I).join(", ")}) VALUES (${Object.keys(I).map(()=>"?").join(", ")})`).run(...Object.values(I)),Rt("ok","ok",h(),!0)}if(o.escalationid&&!h().length)return Rt("error","selection_failed",[],!1,"No child matches this parent/child pair");if(e==="lmbee_job_write")return d.prepare(`UPDATE ${p} SET ${Object.keys(l).map(T=>`${T} = ?`).join(", ")} WHERE ${f}${_}`).run(...Object.values(l),...g,...Object.values(c)).changes?Rt("ok","ok",h(),!0):Rt(h().length?"not_applied":"no_rows");let v=d.prepare(`SELECT escalationid FROM workflow_escalations WHERE ${f} AND pid IS NULL${_} ORDER BY escalationid LIMIT 1`).get(...g,...Object.values(c));if(!v)return Rt("no_rows");d.prepare("UPDATE workflow_escalations SET pid = ?, claimed_ms = ?, state = ?, attempts = attempts + 1 WHERE local_scope = ? AND conversationid = ? AND escalationid = ?").run(t.pid,t.now(),o.state,...m,v.escalationid);let w=d.prepare("SELECT * FROM workflow_escalations WHERE local_scope = ? AND conversationid = ? AND escalationid = ?").get(...m,v.escalationid);return Rt("ok","ok",[yA(w)],!0)}).immediate()}catch(i){if(i instanceof Ve)return Rt("error","invalid_argument",[],!1,i.message);if(!i.code?.startsWith("SQLITE_")&&!(i instanceof Error&&/Refusing|refus|database/i.test(i.message)))throw i;return Rt("error",s&&r?"write_rejected":"database_unavailable",[],!1,i instanceof Error?i.message:String(i))}finally{r?.close()}}var Ve,Rt,qh,N2,vA=L(()=>{"use strict";Wh();gA();$h();Ve=class extends Error{},Rt=(t,e=t,n=[],r=!1,s=null)=>({status:t,code:e,rows:n,applied:r,error:s}),qh=t=>t!==null&&typeof t=="object"&&!Array.isArray(t),N2={job:["status"],escalation:["payload","answer_text","pid","claimed_ms","state","attempts"]}});var EA={};On(EA,{ensureJobSchema:()=>Xh,jobOperation:()=>_A});var bA=L(()=>{"use strict";vA()});var wA={};On(wA,{createLmbeeHostModule:()=>O2});function O2(){return{name:"lmbee",declarations:{globals:[],functions:ba.map(t=>({name:t.name,arity:1,params:[{name:"options",type:"map",keys:t.keys}],doc:{name:t.name,module:"lmbee",category:"Storage",signature:`${t.name}(options)`,description:`${t.description} ${Fh}`,returns:{type:"map",description:Fh}}}))},async activate(t){let{jobOperation:e}=await Promise.resolve().then(()=>(bA(),EA)),n={cwd:t.cwd,env:t.env,signal:t.signal,pid:process.pid,now:Date.now};return{globals:{},functions:Object.fromEntries(ba.map(r=>[r.name,s=>e(n,r.name,s)])),dispose(){}}}}}var TA=L(()=>{"use strict";$h()});function It(t){return SA.has(t)}var SA,wa=L(()=>{SA=new Set(["__proto__","constructor","prototype"])});function Ns(t){return t.replace(/[A-Z]/g,e=>`-${e.toLowerCase()}`)}function Gh(t){return t.replace(/-([a-z0-9])/g,(e,n)=>n.toUpperCase())}function Qu(t){return t.occurs==="1"||t.occurs==="+"||t.occurs===void 0}function Jh(t){let e=`--${Ns(t.name)}`,n=t.type==="array"?t.items??"string":t.type,r=t.type==="boolean"?"":` <${n}${t.items?` of ${t.items}`:""}>`,s=t.enum&&t.enum.length>0?` one of: ${t.enum.join(", ")}`:"";return`${e}${r}${s}`}function Ta(t,e){let n=[];e&&n.push(e),n.push(t.name);for(let r of t.params)r.positional===!0&&n.push(`[<${r.name}>]`);return n.push("[flags]"),n.join(" ")}var Os=L(()=>{});function RA(t,e){let n=Array.from({length:e.length+1},(r,s)=>s);for(let r=1;r<=t.length;r++){let s=n[0];n[0]=r;for(let i=1;i<=e.length;i++){let o=n[i];n[i]=Math.min(n[i]+1,n[i-1]+1,s+(t[r-1]===e[i-1]?0:1)),s=o}}return n[e.length]}function L2(t,e){let n=Gh(t.replace(/^--/,"")),r,s=3;for(let i of e){let o=RA(n,i.name),a=RA(Ns(n),Ns(i.name)),l=Math.min(o,a);l<s&&(s=l,r=i.name)}return r}function xA(t){if(Array.isArray(t))return t;if(typeof t=="string"){let e=t.trim();if(e.startsWith("[")&&e.endsWith("]"))try{let n=JSON.parse(e);if(Array.isArray(n))return n}catch{}return[t]}if(typeof t=="number"||typeof t=="boolean")return[t]}function IA(t,e){switch(t){case"boolean":return typeof e=="boolean"?{ok:!0,value:e}:e==="true"?{ok:!0,value:!0}:e==="false"?{ok:!0,value:!1}:{ok:!1,received:e};case"number":{if(typeof e=="number")return Number.isFinite(e)?{ok:!0,value:e}:{ok:!1,received:e};if(typeof e=="string"){if(e.trim()==="")return{ok:!1,received:e};if(/^-?\d+$/.test(e))return{ok:!0,value:Number.parseInt(e,10)};if(/^-?(?:\d+\.?\d*|\d*\.\d+)(?:[eE][+-]?\d+)?$/.test(e)){let n=Number(e);if(Number.isFinite(n))return{ok:!0,value:n}}}return{ok:!1,received:e}}case"string":return typeof e=="string"?{ok:!0,value:e}:typeof e=="number"||typeof e=="boolean"?{ok:!0,value:String(e)}:{ok:!1,received:e};case"object":{if(e!==null&&typeof e=="object"&&!Array.isArray(e))return{ok:!0,value:e};if(typeof e=="string")try{let n=JSON.parse(e);if(n!==null&&typeof n=="object"&&!Array.isArray(n))return{ok:!0,value:n}}catch{}return{ok:!1,received:e}}case"json":return{ok:!0,value:e};default:return{ok:!0,value:e}}}function Vh(t,e,n){let r=[],s=Object.create(null),i=Ta(t);It(t.name)&&r.push({code:"RESERVED_NAME",message:`operation name "${t.name}" is a reserved name. Expected: ${i}`,op:t.name,synopsis:i,usage:i});for(let a of t.params)if(It(a.name)&&r.push({code:"RESERVED_NAME",message:`param "${a.name}" is a reserved name. Expected: ${i}`,op:t.name,param:a.name,synopsis:i,usage:i}),a.aliases)for(let l of a.aliases)It(l)&&r.push({code:"RESERVED_NAME",message:`param "${a.name}" alias "${l}" is a reserved name. Expected: ${i}`,op:t.name,param:l,synopsis:i,usage:i});let o=new Map;for(let a of t.params){It(a.name)||o.set(a.name,a);for(let l of a.aliases??[])It(l)||o.set(l,a)}for(let a of Object.keys(e))if(a.startsWith("--")||!o.has(a))if(!a.startsWith("--")&&t.additionalParams===!0&&!It(a))s[a]=e[a];else{let l=L2(a,t.params);r.push({code:"UNKNOWN_PARAM",message:`unknown param: ${a}. Expected: ${i}`,param:a,synopsis:i,usage:i,received:e[a],...l!==void 0?{suggestion:l}:{}})}for(let a of t.params){if(It(a.name))continue;let l=Jh(a),c,u=kA(e,a.name);if(u&&(c=e[a.name]),(!u||c===void 0)&&a.aliases){for(let f of a.aliases)if(kA(e,f)&&e[f]!==void 0){c=e[f],u=!0;break}}let d=Qu(a);if(n?.form&&c!==void 0){if(a.cliOnly===!0&&(n.form==="json"||n.form==="graphql")){r.push({code:"FORM_NOT_ALLOWED",message:`param "${a.name}" is CLI-only and not allowed in ${n.form} form. Expected: ${l}`,param:a.name,synopsis:l,usage:i,received:c});continue}if(a.docOnly===!0&&n.form==="flags"){r.push({code:"FORM_NOT_ALLOWED",message:`param "${a.name}" is doc-only and not allowed in flags form. Expected: ${l}`,param:a.name,synopsis:l,usage:i,received:c});continue}}if(c===null)if(d){r.push({code:"TYPE_MISMATCH",message:`expected ${a.type} for param "${a.name}", received null. Expected: ${l}`,param:a.name,synopsis:l,usage:i,received:null});continue}else c=void 0;if(c===void 0){if(a.default!==void 0){s[a.name]=a.default;continue}d&&r.push({code:"MISSING_REQUIRED",message:`missing required param: ${a.name}. Expected: ${l}`,param:a.name,synopsis:l,usage:i});continue}if(a.occurs==="+"||a.occurs==="*"||a.type==="array"){let f=xA(c);if(f===void 0){r.push({code:"TYPE_MISMATCH",message:`expected array for param "${a.name}". Expected: ${l}`,param:a.name,synopsis:l,usage:i,received:c});continue}if(a.occurs==="+"&&f.length===0){r.push({code:"MISSING_REQUIRED",message:`param "${a.name}" requires at least one item. Expected: ${l}`,param:a.name,synopsis:l,usage:i,received:c});continue}if(f.length===0){s[a.name]=[];continue}let g=a.type==="array"?a.items??"string":a.type,h=[],y=!1;for(let E of f){let _=IA(g,E);if(!_.ok){r.push({code:"TYPE_MISMATCH",message:`expected ${g} item for param "${a.name}". Expected: ${l}`,param:a.name,synopsis:l,usage:i,received:E}),y=!0;break}if(a.enum&&a.enum.length>0&&!a.enum.includes(_.value)){r.push({code:"ENUM_VIOLATION",message:`invalid value for param "${a.name}": ${JSON.stringify(_.value)}; allowed: ${a.enum.join(", ")}. Expected: ${l}`,param:a.name,synopsis:l,usage:i,received:_.value,allowed:a.enum}),y=!0;break}h.push(_.value)}y||(s[a.name]=h);continue}let p=IA(a.type,c);if(!p.ok){r.push({code:"TYPE_MISMATCH",message:`expected ${a.type} for param "${a.name}". Expected: ${l}`,param:a.name,synopsis:l,usage:i,received:c});continue}if(a.enum&&a.enum.length>0&&!a.enum.includes(p.value)){r.push({code:"ENUM_VIOLATION",message:`invalid value for param "${a.name}": ${JSON.stringify(p.value)}; allowed: ${a.enum.join(", ")}. Expected: ${l}`,param:a.name,synopsis:l,usage:i,received:p.value,allowed:a.enum});continue}s[a.name]=p.value}return r.length>0?{ok:!1,issues:r}:{ok:!0,value:s}}var kA,Sa=L(()=>{wa();Os();kA=(t,e)=>Object.prototype.hasOwnProperty.call(t,e)});var CA=L(()=>{Sa();Os();wa()});var NA=L(()=>{Sa();Os()});function OA(t){if(typeof t!="string")return!1;let e=t.trim().split(/\s+/).filter(Boolean);if(e.length===0||e.length>4)return!1;for(let n of e)if(!D2.test(n))return!1;return!0}function PA(t){if(typeof t!="string"||t.length>200)return-1;try{let n=new RegExp(t+"|()").exec("");return n?n.length-2:-1}catch{return-1}}var D2,LA,MA,Kh=L(()=>{D2=/^(>=|>|<=|<|=)(\d+\.\d+\.\d+)$/;LA=/^[a-z][a-z0-9_.-]{0,63}$/,MA=/^[a-z][a-z0-9_.-]*$/});function j2(t,e,n,r,s){if(t===void 0)return!0;let i=o=>!s||s.length===0||s.includes(o);if(r==="+"||r==="*"||e==="array"){if(!Array.isArray(t))return!1;let o=n??(e==="array"?"string":e);return t.every(a=>i(a)&&BA(a,o))}return i(t)&&BA(t,e)}function BA(t,e){switch(e){case"string":return typeof t=="string";case"number":return typeof t=="number"&&!Number.isNaN(t);case"boolean":return typeof t=="boolean";case"object":return typeof t=="object"&&t!==null&&!Array.isArray(t);case"array":return Array.isArray(t);case"json":return t!==void 0;default:return!1}}function ka(t){let e=[],n=(o,a,l={})=>{let c=l.usage??(l.op?`${l.op} [flags]`:"<unknown> [flags]"),u=l.synopsis??c;e.push({code:o,message:`${a}. Expected: ${u}`,...l.op?{op:l.op}:{},...l.param?{param:l.param}:{},synopsis:u,usage:c,...l.received!==void 0?{received:l.received}:{},...l.allowed!==void 0?{allowed:l.allowed}:{}})};if(t===null||typeof t!="object"||Array.isArray(t))return n("DOCUMENT_PARSE","cli.schema.v1: document must be an object",{received:t}),{ok:!1,issues:e};let r=t;r.schema!=="cli.schema.v1"&&n("DOCUMENT_PARSE",`cli.schema.v1: unsupported schema tag: ${JSON.stringify(r.schema)}`,{received:r.schema,allowed:["cli.schema.v1"]});let s=r.tool;if(typeof s!="string"||!UA.test(s)?n("DOCUMENT_PARSE",`cli.schema.v1: tool must be a string matching ^[a-z][a-z0-9_]*$, received ${JSON.stringify(s)}`,{received:s}):It(s)&&n("RESERVED_NAME",`cli.schema.v1: tool cannot be named "${s}" (reserved name)`,{received:s}),r.version!==void 0&&typeof r.version!="string"&&n("TYPE_MISMATCH",`cli.schema.v1: version must be a string, received ${typeof r.version}`,{received:r.version}),r.policy!==void 0)if(r.policy===null||typeof r.policy!="object"||Array.isArray(r.policy))n("TYPE_MISMATCH","cli.schema.v1: policy must be an object",{received:r.policy});else{let o=r.policy;(typeof o.dryrun!="boolean"||typeof o.readonly!="boolean")&&n("TYPE_MISMATCH","cli.schema.v1: policy must contain boolean dryrun and readonly properties",{received:r.policy})}if(r.inputs!==void 0)if(!Array.isArray(r.inputs))n("TYPE_MISMATCH","cli.schema.v1: inputs must be an array",{received:r.inputs});else for(let o of r.inputs)["flags","json","graphql"].includes(o)||n("ENUM_VIOLATION",`cli.schema.v1: inputs contains unsupported form "${String(o)}"`,{received:o,allowed:["flags","json","graphql"]});let i=(o,a,l=!1)=>{if(o===null||typeof o!="object"||Array.isArray(o)){n("TYPE_MISMATCH",`cli.schema.v1: param${a?` in "${a}"`:""} must be an object`,{op:a,received:o});return}let c=o,u=c.name;if(typeof u!="string"){n("TYPE_MISMATCH",`cli.schema.v1: param${a?` in "${a}"`:""} needs a string name`,{op:a,received:u});return}for(let y of Object.keys(c))HA.has(y)||n("UNKNOWN_PARAM",`cli.schema.v1: param "${u}"${a?` in "${a}"`:""} has unknown property "${y}"`,{op:a,param:u,received:y,allowed:Array.from(HA)});(l?$2:F2).test(u)?It(u)&&n("RESERVED_NAME",`cli.schema.v1: ${l?"global ":""}param "${u}"${a?` in "${a}"`:""} is a reserved name`,{op:a,param:u,received:u}):n("DOCUMENT_PARSE",`cli.schema.v1: param "${u}"${a?` in "${a}"`:""} name must match ${l?"^[A-Za-z_][A-Za-z0-9_-]*$":"^[A-Za-z_]\\w*$"}`,{op:a,param:u,received:u}),!l&&u==="dryrun"&&n("DOCUMENT_PARSE",'cli.schema.v1: param cannot be named "dryrun" (reserved global policy flag)',{op:a,param:u,received:u});let m=c.aliases;if(m!==void 0&&Array.isArray(m))for(let y of m)typeof y=="string"&&It(y)&&n("RESERVED_NAME",`cli.schema.v1: param "${u}"${a?` in "${a}"`:""} alias "${y}" is a reserved name`,{op:a,param:u,received:y});let p=c.type;(typeof p!="string"||!zh.has(p))&&n("ENUM_VIOLATION",`cli.schema.v1: param "${u}"${a?` in "${a}"`:""} has invalid type: ${JSON.stringify(p)}`,{op:a,param:u,received:p,allowed:Array.from(zh)});let f=c.occurs;f!==void 0&&!DA.has(f)&&n("ENUM_VIOLATION",`cli.schema.v1: param "${u}"${a?` in "${a}"`:""} has invalid occurs: ${JSON.stringify(f)}`,{op:a,param:u,received:f,allowed:Array.from(DA)});let g=c.enum;g!==void 0&&(!Array.isArray(g)||!g.every(y=>typeof y=="string"||typeof y=="number"))&&n("TYPE_MISMATCH",`cli.schema.v1: param "${u}"${a?` in "${a}"`:""} enum must be an array of strings or numbers`,{op:a,param:u,received:g});let h=c.items;if(h!==void 0&&!FA.has(h)&&n("ENUM_VIOLATION",`cli.schema.v1: param "${u}"${a?` in "${a}"`:""} has invalid items type: ${JSON.stringify(h)}`,{op:a,param:u,received:h,allowed:Array.from(FA)}),c.default!==void 0&&zh.has(p)){let y=Array.isArray(g)?g:void 0;j2(c.default,p,h,f,y)||n("TYPE_MISMATCH",`cli.schema.v1: param "${u}"${a?` in "${a}"`:""} default value does not match declared type "${p}"`,{op:a,param:u,received:c.default})}};if(r.globals!==void 0)if(!Array.isArray(r.globals))n("TYPE_MISMATCH","cli.schema.v1: globals must be an array",{received:r.globals});else for(let o of r.globals)i(o,void 0,!0);if(!Array.isArray(r.operations))n("DOCUMENT_PARSE","cli.schema.v1: operations must be an array",{received:r.operations});else{let o=new Set;for(let a of r.operations){if(a===null||typeof a!="object"||Array.isArray(a)){n("DOCUMENT_PARSE","cli.schema.v1: every operation must be an object",{received:a});continue}let l=a,c=l.name;if(typeof c!="string"){n("DOCUMENT_PARSE","cli.schema.v1: every operation needs a string name",{received:c});continue}if(UA.test(c)?It(c)&&n("RESERVED_NAME",`cli.schema.v1: operation cannot be named "${c}" (reserved name)`,{op:c,received:c}):n("DOCUMENT_PARSE",`cli.schema.v1: operation name "${c}" must match ^[a-z][a-z0-9_]*$`,{op:c,received:c}),o.has(c)&&n("DOCUMENT_PARSE",`cli.schema.v1: duplicate operation name "${c}"`,{op:c}),o.add(c),l.access!==void 0&&($A.has(l.access)||n("ENUM_VIOLATION",`cli.schema.v1: operation "${c}" has invalid access: ${JSON.stringify(l.access)}`,{op:c,received:l.access,allowed:Array.from($A)})),l.returns!==void 0&&(jA.has(l.returns)||n("ENUM_VIOLATION",`cli.schema.v1: operation "${c}" has invalid returns: ${JSON.stringify(l.returns)}`,{op:c,received:l.returns,allowed:Array.from(jA)})),!Array.isArray(l.params))n("DOCUMENT_PARSE",`cli.schema.v1: operation "${c}" needs a params array`,{op:c,received:l.params});else for(let u of l.params)i(u,c,!1)}}if(r.product!==void 0){let o=r.product;if(o===null||typeof o!="object"||Array.isArray(o))n("TYPE_MISMATCH","cli.schema.v1: product must be an object",{received:o});else{let a=o,l=new Set(["name","supported","detect"]);for(let d of Object.keys(a))l.has(d)||n("UNKNOWN_PARAM",`cli.schema.v1: unknown product property "${d}"`,{received:d,allowed:Array.from(l)});let c=a.name;typeof c!="string"?n("TYPE_MISMATCH","cli.schema.v1: product.name must be a string",{received:c}):LA.test(c)||n("DOCUMENT_PARSE",`cli.schema.v1: product.name must match ^[a-z][a-z0-9_.-]{0,63}$, received ${JSON.stringify(c)}`,{received:c});let u=a.supported;if(typeof u!="string"?n("TYPE_MISMATCH","cli.schema.v1: product.supported must be a string",{received:u}):OA(u)||n("DOCUMENT_PARSE",`cli.schema.v1: product.supported must be a conjunction of 1 to 4 comparators (>=, >, <=, <, = followed by numeric x.y.z), received ${JSON.stringify(u)}`,{received:u}),a.detect!==void 0){let d=a.detect;if(d===null||typeof d!="object"||Array.isArray(d))n("TYPE_MISMATCH","cli.schema.v1: product.detect must be an object",{received:d});else{let m=d,p=new Set(["argv","pattern"]);for(let h of Object.keys(m))p.has(h)||n("UNKNOWN_PARAM",`cli.schema.v1: unknown product.detect property "${h}"`,{received:h,allowed:Array.from(p)});let f=m.argv;if(!Array.isArray(f)||f.length<1||f.length>8||!f.every(h=>typeof h=="string"&&h.length>0))n("DOCUMENT_PARSE","cli.schema.v1: product.detect.argv must be an array of 1 to 8 non-empty strings",{received:f});else{let h=f[0];MA.test(h)||n("DOCUMENT_PARSE",`cli.schema.v1: product.detect.argv[0] must match ^[a-z][a-z0-9_.-]*$ (no slashes), received ${JSON.stringify(h)}`,{received:h})}let g=m.pattern;if(typeof g!="string")n("TYPE_MISMATCH","cli.schema.v1: product.detect.pattern must be a string",{received:g});else if(g.length>200)n("DOCUMENT_PARSE",`cli.schema.v1: product.detect.pattern exceeds maximum length of 200 characters (${g.length})`,{received:g});else{let h=PA(g);h!==1&&n("DOCUMENT_PARSE",`cli.schema.v1: product.detect.pattern must be a valid RegExp with exactly one capture group, found ${h}`,{received:g})}}}}}return e.length>0?{ok:!1,issues:e}:{ok:!0,value:t}}var zh,DA,FA,$A,jA,UA,F2,$2,HA,Yh=L(()=>{wa();Sa();Kh();zh=new Set(["string","number","boolean","object","array","json"]),DA=new Set(["1","?","+","*"]),FA=new Set(["string","number","boolean","object"]),$A=new Set(["read","write","dynamic"]),jA=new Set(["object","array","string","number","boolean","null"]),UA=/^[a-z][a-z0-9_]*$/,F2=/^[A-Za-z_]\w*$/,$2=/^[A-Za-z_][A-Za-z0-9_-]*$/,HA=new Set(["name","type","occurs","default","enum","positional","items","description","aliases","cliOnly","docOnly","derived"])});var WA=L(()=>{Os();Os()});function qA(t,e){let n=Object.create(null);for(let[r,s]of Object.entries(e))s!==void 0&&(n[r]=s);return JSON.stringify({op:t.name,params:n})}var XA=L(()=>{});var GA=L(()=>{wa();Os();Sa();CA();NA();Yh();WA();XA();Kh()});var ZA={};On(ZA,{INLINE_DOCUMENT_LIMIT:()=>KA,createSchemaModule:()=>QA,createSchemaModuleFactory:()=>z2,parseSchemaDocument:()=>Qh,schemaToDeclarations:()=>YA});import{mkdtempSync as U2,writeFileSync as H2,rmSync as B2}from"node:fs";import{tmpdir as W2}from"node:os";import{join as JA}from"node:path";function Qh(t){let e;try{e=JSON.parse(t)}catch(s){throw Error("not valid JSON: "+(s instanceof Error?s.message:String(s)))}let n=ka(e);if(!n.ok){let s=n.issues[0];throw Error(s.message+(n.issues.length>1?` (and ${n.issues.length-1} more issue${n.issues.length>2?"s":""})`:""))}let r=n.value;for(let s of r.operations)for(let i of s.params)if(Zh.includes(i.name))throw Error(`${r.tool} ${s.name}: param '${i.name}' collides with a runner global`);return r}function Zu(t){return G2(t)?"list":{string:"string",number:"number",boolean:"boolean",object:"map",array:"list",json:"any"}[t.type]??"any"}function zA(t,e){let n=e.params.filter(a=>!a.cliOnly),r=n.filter(a=>a.positional===!0),s=n.filter(a=>a.positional!==!0),i=s.some(Jr),o=r.findIndex(a=>!Jr(a));if(o>=0&&(r.slice(o).some(Jr)||i))throw Error(`${t} ${e.name}: a required argument follows an optional positional`);return{positionals:r,options:s,optsRequired:i}}function V2(t){let e=[t.default!==void 0?"default: "+JSON.stringify(t.default):"",t.enum?.length?"one of: "+t.enum.join(", "):"",t.derived?"loosely typed":""].filter(Boolean),n=t.occurs==="+"?"+":t.occurs==="*"?"*":Jr(t)?"":"?";return Zu(t)+n+(t.description?" \u2014 "+t.description:"")+(e.length?" ("+e.join("; ")+")":"")}function YA(t,e=t.tool){return{functions:t.operations.map(r=>{let s=e+"."+r.name,{positionals:i,options:o,optsRequired:a}=zA(t.tool,r),l=[...o.map(m=>({name:m.name,type:Zu(m),...Jr(m)?{required:!0}:{},...m.enum?.length?{values:[...m.enum]}:{}})),...Zh.map(m=>({name:m,type:"boolean"}))],c=[...i.map(m=>({name:m.name,type:Zu(m),checkLiteral:!0,...m.enum?.length?{values:[...m.enum]}:{},...Jr(m)?{}:{optional:!0}})),{name:"opts",type:"map",keys:l,...r.additionalParams?{open:!0}:{},...a?{}:{optional:!0}},{name:"dryrun",type:"boolean",optional:!0}],u=i.filter(Jr).length+(a?1:0),d={name:s,module:e,category:J2[r.access??"write"]??"Write operations",signature:s+"(...)",description:(r.description??`${t.tool} ${r.name}`)+(r.params.some(m=>m.derived)?" (derived schema: params loosely typed)":""),parameters:[...i,...o].map(m=>({name:m.name,type:Zu(m)+(Jr(m)?"":"?"),description:V2(m)})).concat([{name:"readonly",type:"boolean?",description:`boolean? \u2014 pass --readonly to ${t.tool}`},{name:"confirm",type:"boolean?",description:`boolean? \u2014 pass --confirm to ${t.tool} (attests a dangerous write)`}]),returns:{type:"map",description:`{status:"ok", result} with the parsed JSON of ${t.tool} ${r.name}; {status:"error", error:{code, message}}; {status:"simulated"} in the dry pass`}};return{name:s,arity:{min:u,max:i.length+2},params:c,returnType:"map",readonly:!1,doc:d}}),globals:[]}}function VA(t){return t.trimEnd().split(`
|
|
2401
2401
|
`).slice(-X2).join(`
|
|
2402
|
-
`)}function K2(t){return t.map(e=>`${e.code}${e.param?` '${e.param}'`:""}${e.suggestion?` (did you mean '${e.suggestion}'?)`:""}: ${e.message}`).join("; ")}function QA(t,e={}){let n=Qh(t.text),r=t.alias??n.tool;if(!q2.test(r))throw Error(`namespace ${JSON.stringify(r)} is not an identifier`);let s=e.timeoutMs??0,i=YA(n,r);return{name:"schema:"+r,nativeNamespace:r,declarations:i,async activate(o){let a=Qh(t.text),l={};for(let c of a.operations){let u=r+"."+c.name,{positionals:d}=zA(a.tool,c);l[u]=async(...m)=>{let p=m[d.length+1]===!0,f=m[d.length]??{};if(!Ra(f))throw Error(`${u}: options must be a map`);if(Object.hasOwn(f,"dryrun"))throw Error(`${u}: dryrun is supplied by the language; omit it`);let g=[],h=Object.create(null);for(let[C,O]of d.entries())m[C]!==void 0&&(h[O.name]=m[C]);for(let[C,O]of Object.entries(f)){if(Zh.includes(C)){if(typeof O!="boolean")throw Error(`${u}: option '${C}' must be boolean`);O&&g.push("--"+C);continue}if(Object.hasOwn(h,C))throw Error(`${u}: '${C}' given both positionally and as an option`);h[C]=O}if(p)return{status:"simulated",simulated:u};let y=Vh(c,h,{form:"json"});if(!y.ok)return Gr({code:"validation",message:`${u}: ${K2(y.issues)}`,issues:[...y.issues]});let E=o.platform??process.platform,_=a.tool,v=qA(c,h),w=()=>{},I,T;try{let C=[_,c.name,"--input-json",v,...g];if(Buffer.byteLength(v)>KA){let O=U2(JA(W2(),"lmscript-"+a.tool+"-")),b=JA(O,"input.json");w=()=>B2(O,{recursive:!0,force:!0}),H2(b,v,{mode:384}),C=[_,c.name,"--input-file",b,...g]}T=await Ki(C,s,E,o.signal,{cwd:o.cwd,env:o.env},
|
|
2402
|
+
`)}function K2(t){return t.map(e=>`${e.code}${e.param?` '${e.param}'`:""}${e.suggestion?` (did you mean '${e.suggestion}'?)`:""}: ${e.message}`).join("; ")}function QA(t,e={}){let n=Qh(t.text),r=t.alias??n.tool;if(!q2.test(r))throw Error(`namespace ${JSON.stringify(r)} is not an identifier`);let s=e.timeoutMs??0,i=YA(n,r);return{name:"schema:"+r,nativeNamespace:r,declarations:i,async activate(o){let a=Qh(t.text),l={};for(let c of a.operations){let u=r+"."+c.name,{positionals:d}=zA(a.tool,c);l[u]=async(...m)=>{let p=m[d.length+1]===!0,f=m[d.length]??{};if(!Ra(f))throw Error(`${u}: options must be a map`);if(Object.hasOwn(f,"dryrun"))throw Error(`${u}: dryrun is supplied by the language; omit it`);let g=[],h=Object.create(null);for(let[C,O]of d.entries())m[C]!==void 0&&(h[O.name]=m[C]);for(let[C,O]of Object.entries(f)){if(Zh.includes(C)){if(typeof O!="boolean")throw Error(`${u}: option '${C}' must be boolean`);O&&g.push("--"+C);continue}if(Object.hasOwn(h,C))throw Error(`${u}: '${C}' given both positionally and as an option`);h[C]=O}if(p)return{status:"simulated",simulated:u};let y=Vh(c,h,{form:"json"});if(!y.ok)return Gr({code:"validation",message:`${u}: ${K2(y.issues)}`,issues:[...y.issues]});let E=o.platform??process.platform,_=a.tool,v=qA(c,h),w=()=>{},I,T;try{let C=[_,c.name,"--input-json",v,...g];if(Buffer.byteLength(v)>KA){let O=U2(JA(W2(),"lmscript-"+a.tool+"-")),b=JA(O,"input.json");w=()=>B2(O,{recursive:!0,force:!0}),H2(b,v,{mode:384}),C=[_,c.name,"--input-file",b,...g]}T=await Ki(C,s,E,o.signal,{cwd:o.cwd,env:o.env},{maxOutputBytes:e.maxOutputBytes??0})}catch(C){let O=C;if(O?.code==="ERR_OUTPUT_LIMIT")return Gr({code:"output_limit",message:`${u}: ${a.tool} ${O.message}`});if(O?.message==="Aborted")throw C;return Gr({code:"launch",message:`${u}: cannot run ${a.tool}: ${O?.message??String(C)}`})}finally{try{w()}catch(C){I=C}}if(T.timed_out)return Gr({code:"timeout",message:`${u}: ${a.tool} timed out after ${s} ms`,...T.stderr.trim()?{stderr_tail:VA(T.stderr)}:{}});let k,N=!1;try{k=JSON.parse(T.stdout),N=!0}catch{}if(N&&Ra(k)&&k.success===!1&&Ra(k.error)){let C=k.error,O=Ra(C.data)?C.data:{},b=Ra(O.details)?O.details:O,S=Array.isArray(b.issues)?[...b.issues]:[],R=C.code==="VALIDATION_ERROR"?` (the input passed client validation; schema ${a.version??"unversioned"} may be stale)`:"";return Gr({code:"envelope",message:`${u}: ${String(C.code??"ERROR")}: ${String(C.message??"")}${R}`,tool_code:String(C.code??"ERROR"),...S.length?{issues:S}:{},exit:T.code})}return T.code!==0||T.signal!==null?Gr({code:"exit",message:`${u}: ${a.tool} exit ${T.code??"none"}${T.signal?` (signal ${T.signal})`:""}`,exit:T.code,signal:T.signal,...T.stderr.trim()?{stderr_tail:VA(T.stderr)}:{}}):N?I!==void 0?Gr({code:"launch",message:`${u}: cannot remove temporary input: ${I instanceof Error?I.message:String(I)}`}):{status:"ok",result:k}:Gr({code:"parse",message:`${u}: ${a.tool} ${c.name} printed invalid JSON${T.stdout.trim()?": "+T.stdout.trim().slice(0,200):" (empty stdout)"}`})}}return{functions:l,globals:{},dispose(){}}}}}function z2(t={}){return e=>QA(e,t)}var Zh,q2,X2,KA,Jr,G2,J2,Ra,Gr,eC=L(()=>{"use strict";GA();$s();Zh=["readonly","confirm"],q2=/^[A-Za-z_]\w*$/,X2=12,KA=100*1024;Jr=t=>t.default===void 0&&(t.occurs===void 0||t.occurs==="1"||t.occurs==="+"),G2=t=>t.type==="array"||t.occurs==="+"||t.occurs==="*";J2={read:"Read operations",write:"Write operations",dynamic:"Dynamic operations"};Ra=t=>t!==null&&typeof t=="object"&&!Array.isArray(t);Gr=t=>({status:"error",error:t})});function Re(t){return{ok:!0,value:t}}function le(t,e,n={}){return{ok:!1,error:{code:t,message:e,...n},code:t,message:e,...n.file?{file:n.file}:{},...n.issues?{issues:n.issues}:{},...n.details?{details:n.details}:{}}}var ed=L(()=>{});function Ia(t){if(typeof t!="string"||t.trim()==="")return le("SPEC_SYNTAX","Module spec must be a non-empty string");let e=t.indexOf("#");if(e!==-1){let a=t.slice(0,e),l=t.slice(e+1),c=tC.exec(a);if(!c)return le("SPEC_SYNTAX",`Invalid module spec syntax: "${t}" (expected @owner/repo[#(latest|dev)])`);let u=c[1],d=c[2];if(u==="."||u===".."||d==="."||d==="..")return le("SPEC_SYNTAX",`Invalid owner or repo name: "${t}"`);if(l!=="latest"&&l!=="dev")return le("SPEC_CHANNEL","only the latest and dev channels are supported");let m=l,p=`@${u}/${d}#${m}`;return Re({owner:u,repo:d,channel:m,key:p,requested:t})}let n=tC.exec(t);if(!n)return le("SPEC_SYNTAX",`Invalid module spec syntax: "${t}" (expected @owner/repo[#(latest|dev)])`);let r=n[1],s=n[2];if(r==="."||r===".."||s==="."||s==="..")return le("SPEC_SYNTAX",`Invalid owner or repo name: "${t}"`);let i="latest",o=`@${r}/${s}#${i}`;return Re({owner:r,repo:s,channel:i,key:o,requested:t})}var tC,ey=L(()=>{ed();tC=/^@([A-Za-z0-9][A-Za-z0-9._-]*)\/([A-Za-z0-9][A-Za-z0-9._-]*)$/});import{homedir as Y2}from"node:os";import{isAbsolute as nC,join as rC,relative as sC,resolve as ty}from"node:path";function Fi(t=process.env){let e=t.LMCTL_HOME&&t.LMCTL_HOME.trim()!==""?t.LMCTL_HOME:rC(t.HOME??Y2(),".lmctl");return rC(e,"modules")}function ny(t,e){let n=ty(t),r=ty(n,"github.com"),s=ty(r,e.owner,e.repo,e.channel),i=sC(n,s),o=sC(r,s);if(i.startsWith("..")||nC(i)||o.startsWith("..")||nC(o))throw new Error(`Path traversal detected: entry directory "${s}" escapes cache root "${n}"`);return s}function td(t){return`cli.schema.${t}.json`}var ry=L(()=>{});import{createHash as oC,randomUUID as nd}from"node:crypto";import{existsSync as rd,promises as Bt}from"node:fs";import{dirname as Dse,isAbsolute as Fse,join as cn,relative as $se,resolve as jse}from"node:path";async function eX(t){let e=cn(t,lC);if(!rd(e))return Re(t);try{let n=(await Bt.readFile(e,"utf8")).trim();if(!Q2.test(n)||n==="."||n==="..")return le("CACHE_CORRUPT",`Invalid ${e}`);let r=cn(t,"generations",n);return rd(r)?Re(r):le("CACHE_CORRUPT",`Missing cache generation ${n}`)}catch(n){return le("CACHE_CORRUPT",`Failed to read ${e}: ${n?.message??String(n)}`)}}function oy(t){return typeof t=="string"?Ia(t):Re(t)}async function Ls(t,e){let n=oy(t);if(!n.ok)return le(n.code,n.message);let r=n.value,s=e?.root??Fi(),i;try{i=ny(s,r)}catch(h){return le("PATH_TRAVERSAL",h?.message??String(h))}let o=td(r.channel),a=await eX(i);if(!a.ok)return a;let l=a.value,c=cn(l,o),u=cn(l,"meta.json");if(!rd(c)||!rd(u))return le(l===i?"NOT_INSTALLED":"CACHE_CORRUPT",`Module ${r.key} is missing cache files`);let d,m;try{d=await Bt.readFile(c)}catch(h){return le("CACHE_CORRUPT",`Failed to read ${c}: ${h?.message??String(h)}; run: lmbee module install ${r.key} --force`,{file:c})}try{let h=await Bt.readFile(u,"utf-8");m=JSON.parse(h)}catch(h){return le("CACHE_CORRUPT",`Failed to read or parse ${u}: ${h?.message??String(h)}; run: lmbee module install ${r.key} --force`,{file:u})}let p=oC("sha256").update(d).digest("hex");if(p!==m.sha256)return le("CACHE_CORRUPT",`Cached schema hash mismatch in ${c}: expected ${m.sha256}, got ${p}; run: lmbee module install ${r.key} --force`,{file:c});let f;try{f=JSON.parse(d.toString("utf-8"))}catch(h){return le("BAD_JSON",`Failed to parse ${c} as JSON: ${h?.message??String(h)}`,{file:c})}let g=ka(f);return g.ok?Re({spec:r,dir:i,path:c,sha256:p,fetchedAt:m.fetched_at,lastChecked:m.last_checked??m.fetched_at,etag:m.etag,channel:r.channel,tool:g.value.tool,version:g.value.version,document:g.value}):le("INVALID_SCHEMA",`Cached schema in ${c} is invalid: ${g.issues[0]?.message}`,{file:c,issues:g.issues})}async function cC(t,e){let{timeoutMs:n,fetchImpl:r,etag:s}=e,i;try{let o=AbortSignal.timeout(n),a={};if(s&&(a["If-None-Match"]=s),i=await r(t,{signal:o,headers:a,redirect:"manual"}),i.status>=300&&i.status<400&&i.status!==304){let l=i.headers.get("location");if(!l)return le("FETCH_FAILED",`Redirect response from ${t} missing Location header`);let c=new URL(l,t);if(c.protocol!=="https:"||c.hostname!=="raw.githubusercontent.com")return le("FETCH_FAILED",`Cross-host or non-HTTPS redirect to "${l}" refused (must stay on raw.githubusercontent.com)`);i=await r(c.href,{signal:o,headers:a,redirect:"manual"})}}catch(o){return o?.name==="TimeoutError"||o?.name==="AbortError"?le("FETCH_FAILED",`Fetch timed out after ${n}ms for ${t}`):le("FETCH_FAILED",`Network error fetching ${t}: ${o?.message??String(o)}`)}return Re(i)}async function uC(t,e,n,r,s,i){let o;try{if(t.body&&typeof t.body.getReader=="function"){let u=t.body.getReader(),d=[],m=0;for(;;){let{done:p,value:f}=await u.read();if(p)break;if(m+=f.length,m>e)return await u.cancel(),le("OUTPUT_LIMIT",`Schema exceeds maximum size limit of ${e} bytes`);d.push(f)}o=Buffer.concat(d)}else{let u=await t.arrayBuffer();if(u.byteLength>e)return le("OUTPUT_LIMIT",`Schema exceeds maximum size limit of ${e} bytes`);o=Buffer.from(u)}}catch(u){return u?.name==="TimeoutError"||u?.name==="AbortError"?le("FETCH_FAILED",`Fetch stream timed out after ${n}ms`):le("FETCH_FAILED",`Error reading response stream: ${u?.message??String(u)}`)}let a;try{a=JSON.parse(o.toString("utf-8"))}catch(u){return le("BAD_JSON",`Failed to parse ${s} from ${i} as JSON: ${u?.message??String(u)}`)}let l=ka(a);if(!l.ok){let u=l.issues[0]?.message??"Schema validation failed";return le("INVALID_SCHEMA",`Invalid schema for ${r}: ${u}`,{issues:l.issues})}let c=oC("sha256").update(o).digest("hex");return Re({buffer:o,sha256:c,schema:l.value})}async function iy(t,e,n,r){let s=`gen-${Date.now()}-${nd()}`,i=cn(t,"generations",s),o=cn(i,`.tmp.schema.${nd()}`),a=cn(i,`.tmp.meta.${nd()}`),l=cn(i,e),c=cn(i,"meta.json"),u=cn(t,`.tmp.current.${nd()}`);try{await Bt.mkdir(i,{recursive:!0,mode:448}),await Bt.writeFile(o,n,{mode:384}),await Bt.rename(o,l),await iC(l,384),await Bt.writeFile(a,JSON.stringify(r,null,2)+`
|
|
2403
2403
|
`,{mode:384}),await Bt.rename(a,c),await iC(c,384),await Bt.writeFile(u,s+`
|
|
2404
2404
|
`,{mode:384}),await Bt.rename(u,cn(t,lC))}catch(d){return await sy(o),await sy(a),await sy(u),le("ATOMIC_WRITE_FAILED",`Failed to write cached module files: ${d?.message??String(d)}`)}return Re(void 0)}async function dC(t,e){let n=oy(t);if(!n.ok)return le(n.code,n.message);let r=n.value,s=e?.root??Fi(),i=e?.ttlMs??6*60*60*1e3,o=e?.now??(()=>new Date),a=e?.fetchImpl??globalThis.fetch,l=e?.install??!0,c=e?.update??!0,u=e?.timeoutMs??3e3,d=e?.maxBytes??1048576,m=await Ls(r,{root:s});if(!m.ok){if(m.code==="CACHE_CORRUPT")return m;if(m.code==="NOT_INSTALLED"){if(!l)return le("NOT_INSTALLED",`Module ${r.key} is not installed; run: lmbee module install ${r.key}`);let P=await tX(r,{root:s,fetchImpl:a,now:o,timeoutMs:u,maxBytes:d});return P.ok?Re({module:P.value.entry,source:"installed"}):le(P.code,P.message,{file:P.file,issues:P.issues,details:P.details})}return m}let p=m.value,f=o().getTime(),g=p.lastChecked?new Date(p.lastChecked).getTime():NaN,h=!isNaN(g)&&g>f,y=isNaN(g),E=f-g;if(!y&&!h&&E>=0&&E<i||!c)return Re({module:p,source:"cache"});let v=td(r.channel),w=`${aC}/${r.owner}/${r.repo}/HEAD/${v}`,I=await cC(w,{timeoutMs:u,fetchImpl:a,etag:p.etag});if(!I.ok)return Re({module:p,source:"stale-cache",warning:I.message});let T=I.value;if(T.status===304){let P=o().toISOString(),j=T.headers.get("etag")??T.headers.get("ETag")??p.etag,F;try{F=await Bt.readFile(p.path)}catch(te){return Re({module:p,source:"stale-cache",warning:`Failed to read cached schema: ${te?.message??String(te)}`})}let ee={spec:r.key,url:w,sha256:p.sha256,fetched_at:p.fetchedAt,last_checked:P,etag:j,channel:r.channel,tool:p.tool,version:p.version,bytes:F.length},q=await iy(p.dir,v,F,ee);if(!q.ok)return Re({module:p,source:"stale-cache",warning:q.message});let Y=await Ls(r,{root:s});return Y.ok?Re({module:Y.value,source:"network"}):Re({module:p,source:"stale-cache",warning:Y.message})}if(T.status!==200)return Re({module:p,source:"stale-cache",warning:`Failed to refresh ${r.key}: HTTP ${T.status} ${T.statusText}`});let k=await uC(T,d,u,r.key,v,w);if(!k.ok)return Re({module:p,source:"stale-cache",warning:k.message});let{buffer:N,sha256:C,schema:O}=k.value,b=T.headers.get("etag")??T.headers.get("ETag")??void 0,S=o().toISOString(),R=S,x={spec:r.key,url:w,sha256:C,fetched_at:S,last_checked:R,etag:b,channel:r.channel,tool:O.tool,version:O.version??"unknown",bytes:N.length},A=await iy(p.dir,v,N,x);if(!A.ok)return Re({module:p,source:"stale-cache",warning:A.message});let M=await Ls(r,{root:s});return M.ok?Re({module:M.value,source:"network"}):Re({module:p,source:"stale-cache",warning:M.message})}async function tX(t,e){let n=oy(t);if(!n.ok)return le(n.code,n.message);let r=n.value,s=e?.root??Fi(),i=e?.fetchImpl??globalThis.fetch,o=e?.now??(()=>new Date),a=e?.timeoutMs??1e4,l=e?.maxBytes??Z2,c=e?.force??!1,u;try{u=ny(s,r)}catch(C){return le("PATH_TRAVERSAL",C?.message??String(C))}let d=td(r.channel),m=`${aC}/${r.owner}/${r.repo}/HEAD/${d}`,p=await Ls(r,{root:s});if(!c&&p.ok)return Re({action:"unchanged",entry:p.value});let f=await cC(m,{timeoutMs:a,fetchImpl:i});if(!f.ok)return f;let g=f.value;if(g.status===404)return le("FETCH_FAILED",`Module ${r.key} not found: expected ${d} at the root of the default branch for ${r.owner}/${r.repo}`,{details:{status:404,url:m,file:d}});if(!g.ok)return le("FETCH_FAILED",`Failed to fetch ${m}: HTTP ${g.status} ${g.statusText}`,{details:{status:g.status,url:m}});let h=await uC(g,l,a,r.key,d,m);if(!h.ok)return h;let{buffer:y,sha256:E,schema:_}=h.value;if(!c&&p.ok&&p.value.sha256===E)return Re({action:"unchanged",entry:p.value});let v=g.headers.get("etag")??g.headers.get("ETag")??void 0,w=o().toISOString(),I=w,T={spec:r.key,url:m,sha256:E,fetched_at:w,last_checked:I,etag:v,channel:r.channel,tool:_.tool,version:_.version??"unknown",bytes:y.length},k=await iy(u,d,y,T);if(!k.ok)return k;let N=await Ls(r,{root:s});return N.ok?Re({action:p.ok?"replaced":"installed",entry:N.value}):N}async function iC(t,e){try{await Bt.chmod(t,e)}catch{}}async function sy(t){try{await Bt.unlink(t)}catch{}}var aC,Q2,Z2,lC,mC=L(()=>{Yh();ry();ey();ed();aC="https://raw.githubusercontent.com",Q2=/^[A-Za-z0-9][A-Za-z0-9._-]*$/,Z2=2*1024*1024,lC="CURRENT"});var pC=L(()=>{ed();ey();ry();mC()});var yC={};On(yC,{createModuleResolver:()=>iX,isModuleSpecifier:()=>sX,normalizeModuleSpec:()=>gC,parseModuleOverrides:()=>hC});import{readFileSync as nX}from"node:fs";import{resolve as rX}from"node:path";function sX(t){return t.startsWith("@")}function gC(t){let e=Ia(t);if(!e.ok)throw Error(`${t}: ${e.message}`);return e.value.key}function hC(t,e){let n=new Map;for(let r of t){let s=r.indexOf("=");if(s<1||s===r.length-1)throw Error(`--module expects @owner/repo=<file> (a schema module override), got ${JSON.stringify(r)}; the retired --module NAME host-module loader no longer exists`);n.set(gC(r.slice(0,s)),rX(e,r.slice(s+1)))}return n}function fC(t,e,n){return{key:t.spec.key,channel:t.channel,origin:e,file:t.path,...t.version!==void 0?{version:t.version}:{},sha256:t.sha256,fetchedAt:t.fetchedAt,lastChecked:t.lastChecked,...n?{warning:n}:{}}}function iX(t){let e=hC(t.overrides??[],t.cwd??process.cwd()),n=t.root??Fi({...t.env}),r=new Map;return{resolve:async i=>{let o=Ia(i);if(!o.ok)throw Error(`${i}: ${o.message}`);let a=o.value.key,l=e.get(a);if(l!==void 0){let u;try{u=nX(l,"utf8")}catch(d){throw Error(`--module ${a}=${l}: ${d instanceof Error?d.message:String(d)}`)}return r.set(a,{key:a,channel:o.value.channel,origin:"override",file:l}),{key:a,source:u}}if(t.mode==="cache"){let u=await Ls(o.value,{root:n});if(!u.ok)throw u.code==="NOT_INSTALLED"?Error(`module ${a} is not installed; run the script once to install it, or: lmbee module install @${o.value.owner}/${o.value.repo}${o.value.channel==="latest"?"":"#"+o.value.channel}`):Error(`module ${a}: ${u.message}`);return r.set(a,fC(u.value,"cache")),{key:a,source:JSON.stringify(u.value.document)}}let c=await dC(o.value,{root:n,install:!0,update:!0,...t.fetchImpl?{fetchImpl:t.fetchImpl}:{},...t.now?{now:t.now}:{}});if(!c.ok)throw Error(`module ${a}: ${c.message}`);return r.set(a,fC(c.value.module,c.value.source,c.value.warning)),{key:a,source:JSON.stringify(c.value.module.document)}},provenance:r}}var _C=L(()=>{"use strict";pC()});var t_={};On(t_,{runCli:()=>ly,stableDiagnostic:()=>Aa});import{readFileSync as vC,fstatSync as EC,writeSync as oX}from"node:fs";import{Socket as aX}from"node:net";import{resolve as xa,dirname as lX}from"node:path";function Aa(t,e="<inline>"){return`${t.severity}:${t.file&&t.file!=="<main>"?t.file:e}:${t.line}:${t.column}: ${t.message}
|
|
2405
2405
|
`}function cX(t){let e=Buffer.from(t),n=0,r;for(;n<e.length;)try{let s=oX(2,e,n,e.length-n);if(s===0)return;n+=s}catch(s){let i=s.code;if(i==="EPIPE"||i==="EBADF")return;if(i==="EINTR")continue;if(i==="EAGAIN"||i==="EWOULDBLOCK"){r??=new Int32Array(new SharedArrayBuffer(4)),Atomics.wait(r,0,0,1);continue}throw s}}async function ly(t,e={}){if(t.length===1&&["--version","-v"].includes(t[0]))return(e.stdout??($=>process.stdout.write($)))("lmscript "+e_()+`
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lmctl-ai/lmctl",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.235",
|
|
4
4
|
"description": "A provider-agnostic control plane for teams of AI coding agents — across providers, with independent review and durable memory.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"homepage": "https://lmctl.com",
|