@lmctl-ai/lmctl 0.1.277 → 0.1.279

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/cli/index.js CHANGED
@@ -14,7 +14,7 @@ var ux=Object.defineProperty;var E=(t,e)=>()=>(t&&(e=t(t=0)),e);var ae=(t,e)=>{f
14
14
  `)),note:null}}catch(r){return r.code==="ENOENT"?{source_path:e,tail_lines:0,tail:"",note:"no intent log present (status never run on this host)"}:{source_path:e,tail_lines:0,tail:"",note:`intent log unreadable: ${r instanceof Error?r.message:String(r)}`}}}var Mi,Ax,Jl,hs=E(()=>{"use strict";$i();Mi=["serve","db","runs","jobs","attentions","env","intents"];Ax=["LMCTL_DB","LMCTL_API_URL","LMCTL_API_TOKEN","LMCTL_PID_FILE","LMCTL_SERVE_LOG","LMCTL_SESSIONDIR","LMCTL_DAEMON_INTERVAL_MS","LMCTL_SESSION_SIZE_DISABLED","NODE_ENV","PATH"];Jl=["id","job_id","workflow_id","team_id","current_state","terminal_state","started_at","ended_at","paused_at","parent_run_id","blocker"].join(", ")});import{readFileSync as Hp,appendFileSync as jx,mkdirSync as Px,existsSync as H3,readdirSync as X3,unlinkSync as J3}from"node:fs";import{join as ji,dirname as Fx}from"node:path";import{homedir as Ux}from"node:os";function Kl(){return ji(Ux(),".lmctl")}function Xp(){gr=!0,process.env.LMCTL_DEBUG="1"}function Jp(){return{cliDebug:gr,lmctlDebugEnv:process.env.LMCTL_DEBUG}}function Gp(t){gr=t.cliDebug,t.lmctlDebugEnv===void 0?delete process.env.LMCTL_DEBUG:process.env.LMCTL_DEBUG=t.lmctlDebugEnv}function ce(){if(gr||process.env.LMCTL_DEBUG==="1")return!0;let t=Date.now();return t-Bp>=Wx&&(qp=Hx(),Bp=t),qp}function Kp(){return gr||process.env.LMCTL_DEBUG==="1"}function qx(){let t=new Date,e=t.getTimezoneOffset(),n=e<=0?"+":"-",r=String(Math.floor(Math.abs(e)/60)).padStart(2,"0"),s=String(Math.abs(e)%60).padStart(2,"0");return new Date(t.getTime()-e*6e4).toISOString().replace("Z",`${n}${r}:${s}`)}function Me(t,e){if(e?.verbose){if(!gr)return}else if(!e?.always&&!ce())return;try{Bx();let n={ts:new Date().toISOString(),pid:process.pid,vti:process.env.LMCTL_VTI??null,autocode_run_id:process.env.LMCTL_AUTOCODE_RUN_ID??void 0,...t};jx(Di,JSON.stringify(n)+`
15
15
  `)}catch{}}function Bx(){if(!Di){let e=qx().slice(0,13).replace("T","-");Di=ji(Kl(),`debug-${e}.log`)}Px(Fx(Di),{recursive:!0})}function $e(...t){Me({event:"legacy",msg:t.join(" ")})}function Ge(...t){Me({event:"legacy",msg:t.join(" ")},{verbose:!0})}function D(t){Me(t,{always:!0})}function Hx(){return Xx()||Jx()}function Xx(){try{let t=Hp(ji(Kl(),"config.toml"),"utf-8");for(let e of t.split(`
16
16
  `)){let n=e.trim();if(!n||n.startsWith("#"))continue;if(n.startsWith("["))break;let r=/^debug\s*=\s*(.+)$/.exec(n);if(r){let s=r[1].trim().toLowerCase().replace(/^["']|["']$/g,"");return s==="true"||s==="1"}}}catch{}return!1}function Jx(){try{let t=Hp(ji(Kl(),"config.json"),"utf-8"),e=JSON.parse(t);return e!==null&&typeof e=="object"&&!Array.isArray(e)&&e.debug===!0}catch{}return!1}var gr,qp,Bp,Wx,Di,de=E(()=>{"use strict";gr=!1,qp=!1,Bp=0,Wx=5e3;Di=null});var e_={};ae(e_,{INFRA_CLI_CONTRACT_EXPECTED:()=>u0,INFRA_FLAT_COMMANDS:()=>Qp,INFRA_NAMESPACE_COMMAND:()=>Yl,infraCliEnabled:()=>Pi,isInfraCommand:()=>Fi,runInfraCommand:()=>m0});function Pi(t=process.env){return t.LMCTL_INFRA_CLI==="1"||t.LMCTL_INFRA_CLI==="true"}function Fi(t){return Qp.includes(t)||t===Yl}async function m0(t,e,n,r=p0){let s;try{s=await r()}catch{return n.stderr.write(f0),1}if(s.INFRA_CLI_CONTRACT!==1)return n.stderr.write(`lmctl: infra command library contract version ${s.INFRA_CLI_CONTRACT} does not match the version this lmctl build expects (1).
17
- `),1;let i=t===Yl?e:[t,...e],o=s.createRuntime();return s.dispatch(i,o)}async function p0(){throw new Error("@lmctl-ai/lmt is not yet available as an internal dependency (lmt P1 not landed)")}var u0,Qp,Yl,f0,zl=E(()=>{"use strict";u0=1,Qp=["lmchat","lmmail","lmnote","lmsheet","lmtext","lmsound","login","whoami","exec","tell","peers","site"],Yl="auto";f0=`lmctl: infra commands (site/auto/exec/tell/peers/login/whoami/lmchat/lmmail/lmnote/lmsheet/lmtext/lmsound) are not available in this build.
17
+ `),1;let i=t===Yl?e:[t,...e],o=s.createRuntime();return s.dispatch(i,o)}async function p0(){return import("@lmctl-ai/lmt")}var u0,Qp,Yl,f0,zl=E(()=>{"use strict";u0=1,Qp=["lmchat","lmmail","lmnote","lmsheet","lmtext","lmsound","login","whoami","exec","tell","peers","site"],Yl="auto";f0=`lmctl: infra commands (site/auto/exec/tell/peers/login/whoami/lmchat/lmmail/lmnote/lmsheet/lmtext/lmsound) are not available in this build.
18
18
  `});import{existsSync as _0}from"node:fs";import{createRequire as h0}from"node:module";function g0(){return Zl===null&&(Zl=h0(import.meta.url)("node:sqlite").DatabaseSync),Zl}function Ql(t){return t.length===1&&y0(t[0])?[t[0]]:t}function y0(t){if(!nc(t))return!1;let e=Object.getPrototypeOf(t);return e===Object.prototype||e===null}function nc(t){return t!==null&&typeof t=="object"&&!Array.isArray(t)}var Zl,ec,gs,tc,rc=E(()=>{"use strict";Zl=null;ec=class{name;handle;transactionDepth=0;savepointId=0;constructor(e,n={}){if(n.fileMustExist===!0&&e!==":memory:"&&!_0(e))throw new Error("unable to open database file");this.name=e,this.handle=new(g0())(e,{readOnly:n.readonly===!0}),this.exec("PRAGMA busy_timeout = 5000")}prepare(e){return new tc(this.handle.prepare(e))}exec(e){this.handle.exec(e),this.updateTransactionDepth(e)}pragma(e,n){let r=`PRAGMA ${e}`;if(e.includes("=")){this.exec(r);return}let s=this.prepare(r).get();return n?.simple===!0?s===void 0?void 0:Object.values(s)[0]:s}transaction(e){return(...n)=>{if(this.transactionDepth===0){this.exec("BEGIN");try{let s=e(...n);return this.exec("COMMIT"),s}catch(s){throw this.inTransaction&&this.exec("ROLLBACK"),s}}let r=`lmctl_sp_${this.savepointId+=1}`;this.exec(`SAVEPOINT ${r}`);try{let s=e(...n);return this.exec(`RELEASE ${r}`),s}catch(s){throw this.inTransaction&&(this.exec(`ROLLBACK TO ${r}`),this.exec(`RELEASE ${r}`)),s}}}get inTransaction(){return this.transactionDepth>0}close(){this.handle.close()}updateTransactionDepth(e){let n=e.trim().match(/^([A-Za-z]+)/)?.[1]?.toUpperCase();if(n!==void 0){if(n==="BEGIN"||n==="SAVEPOINT"){this.transactionDepth+=1;return}if(n==="COMMIT"){this.transactionDepth=Math.max(0,this.transactionDepth-1);return}if(n==="RELEASE"){this.transactionDepth=Math.max(0,this.transactionDepth-1);return}n==="ROLLBACK"&&!/^ROLLBACK\s+TO\b/i.test(e.trim())&&(this.transactionDepth=0)}}},gs=ec,tc=class{handle;rawMode=!1;constructor(e){this.handle=e,this.handle.setAllowBareNamedParameters(!0)}get(...e){let n=this.handle.get(...Ql(e));return this.normalizeRow(n)}all(...e){return this.handle.all(...Ql(e)).map(n=>this.normalizeRow(n))}run(...e){let n=this.handle.run(...Ql(e));return{changes:Number(n.changes),lastInsertRowid:Number(n.lastInsertRowid)}}raw(){return this.rawMode=!0,this}normalizeRow(e){return e==null?e:this.rawMode&&nc(e)?Object.values(e):nc(e)?{...e}:e}}});import{createHash as w0}from"node:crypto";function E0(t,e,n){return w0("sha256").update(`${t}\0${e}\0${n}`).digest("hex")}function We(t,e,n){let r=E0(e.stream_id,e.intentKey??e.event_type,e.observedLastSeq),s=t.prepare(`INSERT INTO message_event (event_id, ts, stream_id, event_type, payload)
19
19
  VALUES (?, ?, ?, ?, ?)
20
20
  ON CONFLICT(event_id) DO NOTHING`),i=t.prepare("SELECT seq FROM message_event WHERE event_id = ?");return t.transaction(()=>{let a=s.run(r,e.ts??new Date().toISOString(),e.stream_id,e.event_type,JSON.stringify(e.payload));if(a.changes===0)return{appended:!1,seq:i.get(r).seq,event_id:r};let l=Number(a.lastInsertRowid);return n(l),{appended:!0,seq:l,event_id:r}})()}var Ui=E(()=>{"use strict"});var n_={};ae(n_,{backfillEventLog:()=>sc,rebuildProjections:()=>t_});import{createHash as T0}from"node:crypto";function Gn(t,e){return t==null?null:{teamfile:t,alias:e??""}}function S0(t,e,n){return`lease_${T0("sha256").update(`${t}\0${e}\0${n}`).digest("hex").slice(0,16)}`}function Wi(t,e,n,r){n.forEach((s,i)=>{We(t,{stream_id:e,event_type:s.event_type,payload:s.payload,observedLastSeq:i,ts:s.ts},()=>{}).appended?r.appended+=1:r.skipped+=1})}function v0(t){let e=`msg_tcl_${t.id}`,n=Gn(t.sender_teamfile,t.sender_alias),r=Gn(t.receiver_teamfile,t.receiver_alias),s={table:"team_chat_log",id:t.id},i={message_id:e,sender:n,receiver:r,root_teamfile:t.root_teamfile,legacy:s},o=[{event_type:oe.CREATE,ts:t.created_at,payload:{...i,message_type:"request",content:t.message,origin:t.origin,correlation_status:"legacy-unavailable"}}];return t.status!=="running"&&o.push({event_type:oe.HANDLED,ts:t.created_at,payload:{...i,outcome:t.status,receipt:t.response,error:t.error_detail,truncated:t.truncated===1}}),{streamId:e,events:o}}function b0(t){let e=`msg_mbx_${t.id}`,n=Gn(t.sender_teamfile,t.sender_alias),r=Gn(t.receiver_teamfile,t.receiver_alias),s={table:"agent_mailbox",id:t.id},i={message_id:e,sender:n,receiver:r,root_teamfile:t.root_teamfile,legacy:s},o=[];if(t.message_type==="response"){let a=t.request_mailbox_id!==null?`msg_mbx_${t.request_mailbox_id}`:null;return o.push({event_type:oe.RESPONSE_CREATE,ts:t.created_at,payload:{...i,message_type:"response",content:t.payload,in_reply_to_message_id:a,correlation_status:"legacy-unavailable"}}),o.push({event_type:oe.RESPONSE_ENQUEUE,ts:t.created_at,payload:{...i,message_type:"response",in_reply_to_message_id:a}}),t.delivered_at!==null&&o.push({event_type:oe.RESPONSE_DELIVERED,ts:t.delivered_at,payload:{...i,message_type:"response",receipt:t.receipt}}),{streamId:e,events:o}}return o.push({event_type:oe.CREATE,ts:t.created_at,payload:{...i,message_type:"request",content:t.payload,correlation_status:"legacy-unavailable"}}),o.push({event_type:oe.ENQUEUE,ts:t.created_at,payload:{...i,message_type:"request"}}),t.waited_at!==null&&o.push({event_type:oe.WAIT_REGISTER,ts:t.waited_at,payload:{...i,waited_by:t.waited_by}}),(t.delivering_at!==null||t.delivery_holder_pid!==null)&&o.push({event_type:oe.DELIVER_CLAIM,ts:t.delivering_at??t.created_at,payload:{...i,pid:t.delivery_holder_pid,host:t.delivery_holder_host}}),t.delivered_at!==null&&o.push({event_type:oe.DELIVERED,ts:t.delivered_at,payload:{...i,receipt:t.receipt}}),{streamId:e,events:o}}function k0(t){let e=`inv_${t.id}`,n=Gn(t.target_teamfile,t.target_alias),r={table:"tracked_invocation",id:t.id},s=[{event_type:oe.INVOCATION_START,ts:t.started_at,payload:{invocation_id:e,kind:t.kind,origin:t.origin,launch_source:t.launch_source,from_identity:t.from_identity,target:n,root_teamfile:t.root_teamfile,scope_teamfile:t.scope_teamfile,cwd:t.cwd,command:t.command,request_payload:t.request_payload,started_at:t.started_at,request_message_id:t.team_chat_log_id!==null?`msg_tcl_${t.team_chat_log_id}`:null,holder_pid:t.holder_pid,holder_host:t.holder_host,legacy:r}}];return t.notified_by!==null&&s.push({event_type:oe.INVOCATION_NOTIFY_CLAIM,ts:t.notified_at??t.started_at,payload:{invocation_id:e,notified_by:t.notified_by,notified_at:t.notified_at,legacy:r}}),t.status!=="running"&&s.push({event_type:oe.INVOCATION_FINISH,ts:t.ended_at??t.started_at,payload:{invocation_id:e,status:t.status,ended_at:t.ended_at,exit_code:t.exit_code,signal:t.signal,result_summary:t.result_summary,error:t.error,legacy:r}}),{streamId:e,events:s}}function I0(t){let e=S0(t.receiver_teamfile,t.receiver_alias,t.started_at),n=Gn(t.receiver_teamfile,t.receiver_alias),r=Gn(t.sender_teamfile,t.sender_alias);return{streamId:e,events:[{event_type:oe.INFLIGHT_TAKE,ts:t.started_at,payload:{lease_id:e,receiver:n,sender:r,holder_pid:t.holder_pid,holder_host:null,started_at:t.started_at,legacy:{table:"agent_inflight",receiver_teamfile:t.receiver_teamfile,receiver_alias:t.receiver_alias}}}]}}function qi(t,e){return t.prepare("SELECT name FROM sqlite_master WHERE type = 'table' AND name = ?").get(e)!==void 0}function sc(t){let e={appended:0,skipped:0},n={team_chat_log:0,agent_mailbox:0,tracked_invocation:0,agent_inflight:0};t.transaction(()=>{if(qi(t,"team_chat_log"))for(let i of t.prepare("SELECT * FROM team_chat_log ORDER BY id").all()){let o=e.appended+e.skipped,{streamId:a,events:l}=v0(i);Wi(t,a,l,e),n.team_chat_log+=e.appended+e.skipped-o}if(qi(t,"agent_mailbox"))for(let i of t.prepare("SELECT * FROM agent_mailbox ORDER BY id").all()){let o=e.appended+e.skipped,{streamId:a,events:l}=b0(i);Wi(t,a,l,e),n.agent_mailbox+=e.appended+e.skipped-o}if(qi(t,"tracked_invocation"))for(let i of t.prepare("SELECT * FROM tracked_invocation ORDER BY id").all()){let o=e.appended+e.skipped,{streamId:a,events:l}=k0(i);Wi(t,a,l,e),n.tracked_invocation+=e.appended+e.skipped-o}if(qi(t,"agent_inflight"))for(let i of t.prepare("SELECT * FROM agent_inflight ORDER BY receiver_teamfile, receiver_alias").all()){let o=e.appended+e.skipped,{streamId:a,events:l}=I0(i);Wi(t,a,l,e),n.agent_inflight+=e.appended+e.skipped-o}t_(t)})();let s=i=>t.prepare(`SELECT count(*) AS n FROM ${i}`).get().n;return{appended:e.appended,skipped:e.skipped,bySource:n,projections:{agent_state:s("agent_state"),message_pending:s("message_pending"),invocation_state:s("invocation_state")}}}function t_(t){t.exec("DELETE FROM agent_state"),t.exec("DELETE FROM message_pending"),t.exec("DELETE FROM invocation_state");let e=t.prepare("SELECT seq, stream_id, event_type, payload FROM message_event ORDER BY seq").all();for(let n of e){let r=JSON.parse(n.payload);N0(t,n.seq,n.stream_id,n.event_type,r)}}function Ne(t,e,n){let r=t[e];return r!=null?r[n]??null:null}function N0(t,e,n,r,s){switch(r){case oe.ENQUEUE:case oe.RESPONSE_ENQUEUE:{let i=r===oe.RESPONSE_ENQUEUE;t.prepare(`INSERT INTO message_pending
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lmctl-ai/lmctl",
3
- "version": "0.1.277",
3
+ "version": "0.1.279",
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",