agentix-cli 0.111.1 → 0.113.0
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/{App-T4Q7SW6M.js → App-5ZI475WY.js} +2 -2
- package/dist/{ChatApp-BKUJUIDL.js → ChatApp-PLR7J5D3.js} +2 -2
- package/dist/agent-GRX75ANW.js +2 -0
- package/dist/{board-dashboard-MZVUQ2YO.js → board-dashboard-EKJHQKPH.js} +574 -288
- package/dist/board-dashboard-EKJHQKPH.js.map +1 -0
- package/dist/{chunk-WXQQO2PD.js → chunk-22LO3GBP.js} +2 -2
- package/dist/{chunk-5MUJZODV.js → chunk-2PJKGZWP.js} +32 -32
- package/dist/chunk-2PJKGZWP.js.map +1 -0
- package/dist/{chunk-DTQQ4DAY.js → chunk-37EDS7SZ.js} +8 -8
- package/dist/{chunk-M2L6S3Z5.js → chunk-4QCYSKPD.js} +2 -2
- package/dist/{chunk-3RHFEKFX.js → chunk-6FJ44HYY.js} +2 -2
- package/dist/{chunk-GQMUFSKB.js → chunk-74CQWVHE.js} +2 -2
- package/dist/{chunk-QJP37VVA.js → chunk-A6B5JRUG.js} +2 -2
- package/dist/{chunk-K24MYJFP.js → chunk-B37WAFT5.js} +219 -219
- package/dist/chunk-B37WAFT5.js.map +1 -0
- package/dist/{chunk-DXWDVKMX.js → chunk-DVJW3IWI.js} +2 -2
- package/dist/{chunk-U52IS3AF.js → chunk-EEOQ5C5N.js} +2 -2
- package/dist/{chunk-RS2T53EC.js → chunk-JBE4H7PL.js} +5 -5
- package/dist/{chunk-RS2T53EC.js.map → chunk-JBE4H7PL.js.map} +1 -1
- package/dist/{chunk-7UNS34CN.js → chunk-MEXXGNNN.js} +2 -2
- package/dist/{chunk-3RTOS727.js → chunk-OZDSQVHU.js} +4 -4
- package/dist/{chunk-3RTOS727.js.map → chunk-OZDSQVHU.js.map} +1 -1
- package/dist/{chunk-HCTWKWS3.js → chunk-QF377BDS.js} +6 -6
- package/dist/{chunk-LWYKS5JU.js → chunk-QWI3FM5R.js} +2 -2
- package/dist/{chunk-Z7L74GGT.js → chunk-R43TE2XX.js} +2 -2
- package/dist/{chunk-FBODSJU6.js → chunk-RXQ2XCKP.js} +2 -2
- package/dist/{chunk-53OS4TDU.js → chunk-THRWE4Y3.js} +2 -2
- package/dist/{chunk-SIOWVLZG.js → chunk-TXX5W3SH.js} +12 -12
- package/dist/chunk-TXX5W3SH.js.map +1 -0
- package/dist/{chunk-C245D4BZ.js → chunk-UG2OF2EI.js} +2 -2
- package/dist/{chunk-4NFDDTGA.js → chunk-V3C2BOYR.js} +2 -2
- package/dist/{chunk-XEOT2F4C.js → chunk-X7E27RYS.js} +2 -2
- package/dist/{chunk-WSKQUKCF.js → chunk-XG2XVGSL.js} +2 -2
- package/dist/{chunk-23A5K5UW.js → chunk-Y5MFVVTM.js} +2 -2
- package/dist/cli.js +1 -1
- package/dist/{client-O7SPKO5X.js → client-DBQ5QNJJ.js} +2 -2
- package/dist/{compaction-MECSN36J.js → compaction-FS6XNRLM.js} +3 -3
- package/dist/config-4T62LT27.js +2 -0
- package/dist/config-mutator-ARUEJ6V5.js +2 -0
- package/dist/{context-planner-JU7CNXCB.js → context-planner-BKHPKDX5.js} +2 -2
- package/dist/{doctor-XP7O45RC.js → doctor-M32NIOZH.js} +2 -2
- package/dist/heal-U67X6NIN.js +2 -0
- package/dist/index.d.ts +185 -0
- package/dist/index.js +1 -1
- package/dist/memory-extract-ATD6YLRK.js +2 -0
- package/dist/{program-YK3YR2CQ.js → program-7MG42JKO.js} +169 -169
- package/dist/program-7MG42JKO.js.map +1 -0
- package/dist/{promote-UGWANGI2.js → promote-DAEKJVWN.js} +2 -2
- package/dist/{providers-ES5KVLI4.js → providers-55NC2SFN.js} +2 -2
- package/dist/{query-ZET7Z5FT.js → query-MCJYD66I.js} +2 -2
- package/dist/{registry-UXWOY52B.js → registry-AYPPHZ3Z.js} +2 -2
- package/dist/{request-planner-W5YLKCGG.js → request-planner-7NKKLY7C.js} +2 -2
- package/dist/{review-candidates-GU4S5VQH.js → review-candidates-QG2U5YID.js} +2 -2
- package/dist/{routing-GJ4VXKIC.js → routing-HBNYDAGE.js} +2 -2
- package/dist/schedule-tool-6S35TPJJ.js +2 -0
- package/dist/scheduler-KZ6VVZZA.js +2 -0
- package/dist/{seat-L6XJ2BFA.js → seat-PQ7AMPMT.js} +2 -2
- package/dist/{select-T7CKKLC2.js → select-J6TO7RED.js} +2 -2
- package/dist/{set-enabled-U2HGNY2O.js → set-enabled-WXRUHFWW.js} +2 -2
- package/dist/{tool-2FMWZB4N.js → tool-I3OGQKAD.js} +2 -2
- package/dist/{tool-TX622HEB.js → tool-KN2QEPDO.js} +2 -2
- package/dist/wiki-2IKLQ6PO.js +2 -0
- package/package.json +1 -1
- package/dist/agent-YZVEXFE7.js +0 -2
- package/dist/board-dashboard-MZVUQ2YO.js.map +0 -1
- package/dist/chunk-5MUJZODV.js.map +0 -1
- package/dist/chunk-K24MYJFP.js.map +0 -1
- package/dist/chunk-SIOWVLZG.js.map +0 -1
- package/dist/config-ZHQYXFOJ.js +0 -2
- package/dist/config-mutator-RS2NTDNO.js +0 -2
- package/dist/heal-CMQL5SG4.js +0 -2
- package/dist/memory-extract-YCNCARZ2.js +0 -2
- package/dist/program-YK3YR2CQ.js.map +0 -1
- package/dist/schedule-tool-HD4LWKVC.js +0 -2
- package/dist/scheduler-3LEHZHWJ.js +0 -2
- package/dist/wiki-MYJBOJSM.js +0 -2
- /package/dist/{App-T4Q7SW6M.js.map → App-5ZI475WY.js.map} +0 -0
- /package/dist/{ChatApp-BKUJUIDL.js.map → ChatApp-PLR7J5D3.js.map} +0 -0
- /package/dist/{agent-YZVEXFE7.js.map → agent-GRX75ANW.js.map} +0 -0
- /package/dist/{chunk-WXQQO2PD.js.map → chunk-22LO3GBP.js.map} +0 -0
- /package/dist/{chunk-DTQQ4DAY.js.map → chunk-37EDS7SZ.js.map} +0 -0
- /package/dist/{chunk-M2L6S3Z5.js.map → chunk-4QCYSKPD.js.map} +0 -0
- /package/dist/{chunk-3RHFEKFX.js.map → chunk-6FJ44HYY.js.map} +0 -0
- /package/dist/{chunk-GQMUFSKB.js.map → chunk-74CQWVHE.js.map} +0 -0
- /package/dist/{chunk-QJP37VVA.js.map → chunk-A6B5JRUG.js.map} +0 -0
- /package/dist/{chunk-DXWDVKMX.js.map → chunk-DVJW3IWI.js.map} +0 -0
- /package/dist/{chunk-U52IS3AF.js.map → chunk-EEOQ5C5N.js.map} +0 -0
- /package/dist/{chunk-7UNS34CN.js.map → chunk-MEXXGNNN.js.map} +0 -0
- /package/dist/{chunk-HCTWKWS3.js.map → chunk-QF377BDS.js.map} +0 -0
- /package/dist/{chunk-LWYKS5JU.js.map → chunk-QWI3FM5R.js.map} +0 -0
- /package/dist/{chunk-Z7L74GGT.js.map → chunk-R43TE2XX.js.map} +0 -0
- /package/dist/{chunk-FBODSJU6.js.map → chunk-RXQ2XCKP.js.map} +0 -0
- /package/dist/{chunk-53OS4TDU.js.map → chunk-THRWE4Y3.js.map} +0 -0
- /package/dist/{chunk-C245D4BZ.js.map → chunk-UG2OF2EI.js.map} +0 -0
- /package/dist/{chunk-4NFDDTGA.js.map → chunk-V3C2BOYR.js.map} +0 -0
- /package/dist/{chunk-XEOT2F4C.js.map → chunk-X7E27RYS.js.map} +0 -0
- /package/dist/{chunk-WSKQUKCF.js.map → chunk-XG2XVGSL.js.map} +0 -0
- /package/dist/{chunk-23A5K5UW.js.map → chunk-Y5MFVVTM.js.map} +0 -0
- /package/dist/{client-O7SPKO5X.js.map → client-DBQ5QNJJ.js.map} +0 -0
- /package/dist/{compaction-MECSN36J.js.map → compaction-FS6XNRLM.js.map} +0 -0
- /package/dist/{config-ZHQYXFOJ.js.map → config-4T62LT27.js.map} +0 -0
- /package/dist/{config-mutator-RS2NTDNO.js.map → config-mutator-ARUEJ6V5.js.map} +0 -0
- /package/dist/{context-planner-JU7CNXCB.js.map → context-planner-BKHPKDX5.js.map} +0 -0
- /package/dist/{doctor-XP7O45RC.js.map → doctor-M32NIOZH.js.map} +0 -0
- /package/dist/{heal-CMQL5SG4.js.map → heal-U67X6NIN.js.map} +0 -0
- /package/dist/{memory-extract-YCNCARZ2.js.map → memory-extract-ATD6YLRK.js.map} +0 -0
- /package/dist/{promote-UGWANGI2.js.map → promote-DAEKJVWN.js.map} +0 -0
- /package/dist/{providers-ES5KVLI4.js.map → providers-55NC2SFN.js.map} +0 -0
- /package/dist/{query-ZET7Z5FT.js.map → query-MCJYD66I.js.map} +0 -0
- /package/dist/{registry-UXWOY52B.js.map → registry-AYPPHZ3Z.js.map} +0 -0
- /package/dist/{request-planner-W5YLKCGG.js.map → request-planner-7NKKLY7C.js.map} +0 -0
- /package/dist/{review-candidates-GU4S5VQH.js.map → review-candidates-QG2U5YID.js.map} +0 -0
- /package/dist/{routing-GJ4VXKIC.js.map → routing-HBNYDAGE.js.map} +0 -0
- /package/dist/{schedule-tool-HD4LWKVC.js.map → schedule-tool-6S35TPJJ.js.map} +0 -0
- /package/dist/{scheduler-3LEHZHWJ.js.map → scheduler-KZ6VVZZA.js.map} +0 -0
- /package/dist/{seat-L6XJ2BFA.js.map → seat-PQ7AMPMT.js.map} +0 -0
- /package/dist/{select-T7CKKLC2.js.map → select-J6TO7RED.js.map} +0 -0
- /package/dist/{set-enabled-U2HGNY2O.js.map → set-enabled-WXRUHFWW.js.map} +0 -0
- /package/dist/{tool-2FMWZB4N.js.map → tool-I3OGQKAD.js.map} +0 -0
- /package/dist/{tool-TX622HEB.js.map → tool-KN2QEPDO.js.map} +0 -0
- /package/dist/{wiki-MYJBOJSM.js.map → wiki-2IKLQ6PO.js.map} +0 -0
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{q as Xt}from"./chunk-S2GAEH2F.js";import{a as Re}from"./chunk-GTJIKXDB.js";import{a as re,b as w}from"./chunk-DG5I6PPM.js";import{t as Gt,u as Kt}from"./chunk-
|
|
1
|
+
import{q as Xt}from"./chunk-S2GAEH2F.js";import{a as Re}from"./chunk-GTJIKXDB.js";import{a as re,b as w}from"./chunk-DG5I6PPM.js";import{t as Gt,u as Kt}from"./chunk-QWI3FM5R.js";import{d as zt,e as qt}from"./chunk-AQASR6KR.js";import{b as Jt,c as Ie,e as B,f as H,h as Yt}from"./chunk-JIT5GPTX.js";import{A as Ae,b as ve,v as Lt,x as ne,y as $e}from"./chunk-THRWE4Y3.js";import{a as Mt,b as Nt}from"./chunk-SHEUCITK.js";import{a as Ut,b as Bt,d as Ht}from"./chunk-Y4CYQV7G.js";import{g as Ot,h as jt,i as Vt,k as Wt,l as Ft}from"./chunk-22LO3GBP.js";import{q as Et}from"./chunk-4QCYSKPD.js";import{a as Pt,b as Tt}from"./chunk-A6B5JRUG.js";import{A as Xr,ba as Se,ia as _t,ja as Ct,ma as Dt,n as te,o as vt,p as $t,q as qr,y as It,z as Rt}from"./chunk-TXX5W3SH.js";import{f as At,n as Kr}from"./chunk-UIBUZ2N3.js";import{a as xe,h as Gr}from"./chunk-BRK6M6LA.js";import{existsSync as Jr,readdirSync as Yr,readFileSync as Zr,statSync as Qr}from"fs";import{resolve as ei}from"path";function Zt(t,e,n=Date.now(),r=7){let i=r*864e5,s=new Map;for(let o of e){let a=s.get(o.workflowId);a?a.push(o):s.set(o.workflowId,[o])}return t.map(o=>{let a=s.get(o.id)??[],c=a.filter(f=>n-f.at<=i),l=a.filter(f=>n-f.at>i&&n-f.at<=i*2),u=c.filter(f=>f.status==="failed").length,d=a.filter(f=>f.status==="paused").length,p=a.length?Math.max(...a.map(f=>f.at)):null,g=a.length?l.length>0&&c.length===0?"dormant":c.length>0&&u*2>=c.length?"failing":c.length>0?"active":"quiet":"never";return{id:o.id,name:o.name||o.id,state:g,lastRunAt:p,recent:c.length,prior:l.length,failed:u,paused:d}}).sort((o,a)=>{let c={dormant:0,failing:1,active:2,quiet:3,never:4};return c[o.state]-c[a.state]||(a.lastRunAt??0)-(o.lastRunAt??0)})}var ie=new Map;function _a(t,e=1e3){if(!Jr(t))return[];let n=Yr(t).filter(s=>s.endsWith(".jsonl")).map(s=>{let o=ei(t,s);return{path:o,mtime:Qr(o).mtimeMs}}).sort((s,o)=>o.mtime-s.mtime).slice(0,e),r=new Set(n.map(s=>s.path));for(let s of ie.keys())r.has(s)||ie.delete(s);let i=[];for(let{path:s,mtime:o}of n){let a=ie.get(s);if(a&&a.mtime===o){a.summary&&i.push(a.summary);continue}let c=ti(s,o);ie.set(s,{mtime:o,summary:c}),c&&i.push(c)}return i}function ti(t,e){try{let n=Zr(t,"utf-8").split(`
|
|
2
2
|
`).filter(Boolean);if(!n.length)return null;let r=JSON.parse(n[0]),i=r.run?.workflowId;if(!i)return null;let s=r.run?.status??"unknown";for(let o=n.length-1;o>=0;o--){let a=JSON.parse(n[o]),c=a.status??a.run?.status;if(c){s=c;break}}return{workflowId:i,status:s,at:e}}catch{return null}}var ni={failStreak:3,disabledDays:30,missedFires:2,graceMs:15*6e4},k={routines:200,summary:160,filters:6,filterValue:60,text:120},ri=(t,e,n)=>{try{return Et(t,e,n)}catch{return null}},Qt=864e5;function Ta(t){let e=t.now??Date.now(),n={...ni,...t.thresholds},r=t.nextFire??ri,i=[];for(let a of t.crons){let c=t.cronRuns.get(a.id)??[],l=a.timezone||"UTC",u=c.map(g=>({at:Date.parse(g.startedAt),status:g.status})),d=c[0],p={id:`cron:${a.id}`,source:"cron",kind:"schedule",name:$(a.id,k.text),trigger:{schedule:$(a.schedule,k.text),timezone:l},agent:a.agent||null,enabled:a.enabled,state:a.enabled?"enabled":"disabled",nextRunAt:a.enabled?_e(a.nextRun)??_e(r(a.schedule,new Date(e),l)):null,lastRun:d?{at:d.startedAt,status:d.status,summary:li(d.status==="success"?void 0:d.errorSummary,k.summary)}:null,lastSuccessAt:c.find(g=>g.status==="success")?.startedAt??null,consecutiveFailures:en(u),sampledRuns:c.length,flags:[],attention:null};p.flags=tn(p,u,a.schedule,l,null,e,n,r),i.push(nn(p))}let s=new Map(Zt(t.workflows.map(a=>({id:a.id,name:a.title})),t.workflowRuns,e).map(a=>[a.id,a])),o=new Map;for(let a of t.workflowRuns){let c=o.get(a.workflowId);c?c.push(a):o.set(a.workflowId,[a])}for(let a of t.workflows){let c=a.nodes.find(_=>_.type.startsWith("trigger."));if(!c||c.type!=="trigger.cron"&&c.type!=="trigger.hook")continue;let l=c.config??{},u=a.state||"active",d=u==="active",p=(o.get(a.id)??[]).slice().sort((_,ke)=>ke.at-_.at),g=p.map(_=>({at:_.at,status:oi(_.status)})),f=g[0],m=c.type==="trigger.cron",y=typeof l.spec=="string"?l.spec:"",P=typeof l.timezone=="string"?l.timezone:"UTC",j={id:`workflow:${a.id}`,source:"workflow",kind:m?"schedule":"event",name:$(a.title||a.id,k.text),trigger:m?{schedule:$(y,k.text),timezone:P}:{event:$(typeof l.event=="string"?l.event:"",k.text),filters:ci(l.filter,a)},agent:ai(a),enabled:d,state:u,nextRunAt:m&&d&&y?_e(r(y,new Date(e),P)):null,lastRun:f?{at:new Date(f.at).toISOString(),status:f.status}:null,lastSuccessAt:(()=>{let _=g.find(ke=>ke.status==="success");return _?new Date(_.at).toISOString():null})(),consecutiveFailures:en(g),sampledRuns:p.length,flags:[],attention:null},ee=Date.parse(a.updated||a.created||"");j.flags=m?tn(j,g,y,P,Number.isFinite(ee)?ee:null,e,n,r):ii(j,s.get(a.id)?.state==="dormant",Number.isFinite(ee)?ee:null,e,n),i.push(nn(j))}return i.sort(si).slice(0,k.routines)}function en(t){let e=0;for(let n of t)if(!(n.status==="running"||n.status==="paused"||n.status==="unknown"))if(n.status==="failed"||n.status==="timeout")e++;else break;return e}function tn(t,e,n,r,i,s,o,a){let c=[],l=e.length?e[0].at:null;if(!t.enabled){let p=sn(l,i,s,o);return p&&c.push(p),c}if(t.consecutiveFailures>=o.failStreak&&c.push({reason:"failing",detail:`${t.consecutiveFailures} failed attempts in a row`}),l===null)return c.push({reason:"never-ran",detail:"No persisted attempt"}),c;let u=new Date(l),d=null;for(let p=0;p<o.missedFires&&(d=a(n,u,r),!!d);p++)u=d;return d&&s>d.getTime()+o.graceMs&&c.push({reason:"overdue",detail:`No attempt since ${new Date(l).toISOString()}; ${o.missedFires} scheduled fires missed`}),c}function ii(t,e,n,r,i){let s=[],o=t.lastRun?Date.parse(t.lastRun.at):null;if(!t.enabled){let a=sn(o,n,r,i);return a&&s.push(a),s}return t.consecutiveFailures>=i.failStreak&&s.push({reason:"failing",detail:`${t.consecutiveFailures} failed runs in a row`}),o===null?s.push({reason:"never-ran",detail:"No run recorded for this trigger"}):e&&s.push({reason:"dormant",detail:"Fired in the prior week, silent in the last one"}),s}function sn(t,e,n,r){let i=Math.max(t??0,e??0);return i&&n-i<r.disabledDays*Qt?null:{reason:"disabled-long",detail:i?`Disabled; no activity for ${Math.floor((n-i)/Qt)} days`:"Disabled and never ran"}}function nn(t){let e=new Set(t.flags.map(n=>n.reason));return t.attention=e.has("failing")?"critical":e.has("overdue")||e.has("dormant")||e.has("never-ran")?"warning":e.has("disabled-long")?"info":null,t}var rn={critical:0,warning:1,info:2};function si(t,e){let n=t.attention?rn[t.attention]:3,r=e.attention?rn[e.attention]:3;return n-r||Number(e.enabled)-Number(t.enabled)||t.name.localeCompare(e.name)}function oi(t){switch(t){case"completed":case"ok":return"success";case"failed":return"failed";case"timeout":return"timeout";case"canceled":return"canceled";case"running":return"running";case"paused":return"paused";default:return"unknown"}}function ai(t){if(t.ownerAgent)return $(t.ownerAgent,k.text);let e=t.nodes.find(n=>n.type==="agent"&&typeof n.config?.agentId=="string"&&n.config.agentId);return e?$(String(e.config.agentId),k.text):null}function ci(t,e){let n=[],r=e?.project;if(r&&n.push($(`project=${r}`,k.filterValue)),t&&typeof t=="object"&&!Array.isArray(t))for(let[i,s]of Object.entries(t)){let o=Array.isArray(s)?s.map(String):s==null?[]:[String(s)];o.length&&n.push($(`${i}=${o.join(",")}`,k.filterValue))}return n.slice(0,k.filters)}function _e(t){if(!t)return null;let e=t instanceof Date?t:new Date(t);return Number.isFinite(e.getTime())?e.toISOString():null}function $(t,e){return t.length<=e?t:t.slice(0,e-3)+"..."}function li(t,e){return t===void 0?void 0:$(t,e)}import{existsSync as ae,readdirSync as Ri,readFileSync as _i}from"fs";import{resolve as T}from"path";import{randomBytes as cn}from"crypto";import{existsSync as di,mkdirSync as pi,readdirSync as gi,readFileSync as fi,renameSync as ln,unlinkSync as mi,writeFileSync as hi}from"fs";import{resolve as un}from"path";function on(t){return[...t.account?["--account",t.account]:[],...t.store?["--store",t.store]:[]]}var ui=t=>t.trim().split(`
|
|
3
3
|
`).pop()?.slice(0,300)||"no output";async function an(t,e,n,r=Re){let i=await r(t.bin,[...on(t),"send","text","--to",e,"--message",n,"--no-preview"],{timeoutMs:6e4});return i.code===0?{ok:!0}:{ok:!1,error:`wacli send failed: ${ui(i.stderr||i.stdout)}`}}async function Ma(t,e,n,r,i=Re){return(await i(t.bin,[...on(t),"--read-only","media","download","--chat",e,"--id",n,"--output",r],{timeoutMs:12e4})).code===0}var yi=2e3,bi=t=>an(t.wacli,t.to,t.text);function Ce(t){return un(t,".agentx","whatsapp-triage","drafts")}var wi=t=>/^[a-z0-9-]{8,64}$/.test(t),se=(t,e)=>un(Ce(t),`${e}.json`);function dn(t,e){pi(Ce(t),{recursive:!0});let n=se(t,e.id),r=`${n}.${process.pid}.tmp`;hi(r,JSON.stringify(e,null,2)+`
|
|
4
4
|
`,{mode:384}),ln(r,n)}function Fa(t,e,n=Date.now()){let r=e.text.trim().slice(0,yi);if(!r)throw new Error("empty draft");let i={...e,text:r,id:`${n.toString(36)}-${cn(4).toString("hex")}`,status:"pending",created_at:new Date(n).toISOString()};return dn(t,i),i}function oe(t,e){if(!wi(e))return null;try{return JSON.parse(fi(se(t,e),"utf-8"))}catch{return null}}function pn(t,e){let n=Ce(t);return di(n)?gi(n).filter(r=>r.endsWith(".json")).map(r=>oe(t,r.slice(0,-5))).filter(r=>!!r&&(!e||r.status===e)).sort((r,i)=>r.created_at.localeCompare(i.created_at)):[]}async function gn(t,e,n,r={}){let i=oe(t,e);if(!i||i.status!=="pending")return{ok:!1,error:`no reply draft "${e}" is waiting`};let s=`${se(t,e)}.${process.pid}.${cn(3).toString("hex")}.claim`;try{ln(se(t,e),s)}catch{return{ok:!1,error:`reply draft "${e}" is already being decided`}}let o={...i,decided_by:r.by??"operator",decided_at:new Date(r.now??Date.now()).toISOString()};if(n==="no")o.status="rejected";else{let a=await(r.send??bi)(i).catch(c=>({ok:!1,error:String(c?.message??c)}));a.ok?o.status="sent":(o.status="failed",o.error=a.error)}dn(t,o);try{mi(s)}catch{}return o.status==="failed"?{ok:!1,error:o.error??"send failed"}:{ok:!0,draft:o}}import{mkdirSync as ki,readFileSync as xi,renameSync as Si,writeFileSync as vi}from"fs";import{resolve as $i}from"path";function fn(t){return $i(Ie(t),"_state.json")}function A(t){try{let e=JSON.parse(xi(fn(t),"utf-8"));return{snoozed:e&&typeof e.snoozed=="object"&&e.snoozed?e.snoozed:{},...typeof e?.lastDigest=="string"?{lastDigest:e.lastDigest}:{},...e?.popped&&typeof e.popped=="object"?{popped:e.popped}:{},...typeof e?.passAt=="string"?{passAt:e.passAt}:{},...Array.isArray(e?.wanted)?{wanted:e.wanted.filter(n=>typeof n=="string")}:{}}}catch{return{snoozed:{}}}}function z(t,e){ki(Ie(t),{recursive:!0});let n=fn(t),r=`${n}.${process.pid}.tmp`;vi(r,JSON.stringify(e,null,2)+`
|
|
@@ -462,8 +462,8 @@ Message (edit it if you like):`:`${at(t)}
|
|
|
462
462
|
Message (edit it if you like):`,d=await n("/usr/bin/osascript",hr(s,l,o?["Cancel","Send"]:["Not now","No","Send"],r,Ht(t.draft,o)),i),p=d.ok?yr(d.stdout):null;if(p?.button==="Send"){let g=p.text.trim();return g?{action:"yes",...o?{choice:o}:{},text:g}:{action:"dismiss"}}return p?.button==="No"?{action:"no"}:{action:"dismiss"}}let a=await n("/usr/bin/osascript",hr(s,at(t),["Not now","No","Yes"],r),i),c=a.ok?yr(a.stdout):null;return c?.button==="Yes"?{action:"yes"}:c?.button==="No"?{action:"no"}:{action:"dismiss"}}var lt=24*36e5,ct=!1,To=10*6e4,kr=-1/0;function xr(t){let e=t.now??Date.now(),{popped:n={},snoozed:r,passAt:i,wanted:s=[]}=A(t.root),o=i?Date.parse(i):NaN,a=H(t.root,"pending").filter(l=>Date.parse(l.expires)>e),c=a.find(l=>s.includes(`card:${l.id}`));if(c)return c;for(let l of a){let u=`card:${l.id}`;if(n[u])continue;let d=r[u];if(d&&Date.parse(d)>e)continue;let p=Date.parse(l.created_at);if(!(e-p>lt&&!(p<=o)))return l}return null}function Sr(t){try{return q(t)?.listByState("needs_attention")??[]}catch{return[]}}function Eo(t){let e=t.now??Date.now(),{popped:n={},snoozed:r}=A(t.root);return Sr(t).find(i=>{let s=`request:${i.id}`,o=r[s];return!n[s]&&!(o&&Date.parse(o)>e)&&e-i.updatedAt<=lt})??null}function Lo(t,e){return{id:t.id,title:rt(t.text,Jt.title),context:t.attentionReason??"It is not finished and nothing is retrying it.",ask:`Hand it back to ${t.agentId}, or drop it?`,say:"A request you made is not finished.",recommend:"",if_silent:"keep",expires:new Date(e+lt).toISOString(),raised_by:t.agentId,created_at:new Date(t.createdAt).toISOString(),status:"pending",origin:{kind:"request",id:t.id}}}async function Xl(t){let{ctx:e,settings:n,log:r}=t;if(!n.enabled||(t.platform??process.platform)!=="darwin")return"off";if(ct)return"busy";let i=xr(e)?null:Eo(e),s=i?Lo(i,e.now??Date.now()):xr(e);if(!s)return"none";let o=(t.focus??Mt)();if(o.active)return"held";ct=!0;let a=`${i?"request":"card"}:${s.id}`;try{let c=[...H(e.root,"pending").map(m=>`card:${m.id}`),...Sr(e).map(m=>`request:${m.id}`)];hn(e.root,a,c,e.now),r(`[approvals] popup: showing ${a} from ${s.raised_by}`);let l=e.now??Date.now(),u=!!i&&l-kr<To;i&&n.speak&&(kr=l);let d=t.agentName?.(s.raised_by)??(s.node?`${s.raised_by} on ${s.node}`:void 0),p=await(t.show??wr)(s,u?{...n,speak:!1}:n,{from:d,speak:t.speak});if(p.action==="dismiss")return r(`[approvals] popup: ${a} left waiting: ${p.why??"no answer"} (${Nt(o)} when shown)`),"shown";if(!(i?q(e)?.get(i.id)?.state==="needs_attention":B(e.root,s.id)?.status==="pending"))return r(`[approvals] popup: ${a} was answered elsewhere; popup answer ignored`),"shown";let f=await vn(e,a,p.action,{by:"operator (popup)",...p.action==="yes"?{choice:p.choice,text:p.text}:{}});return r(f.ok?`[approvals] popup: ${f.message}`:`[approvals] popup: ${a} not recorded: ${f.error}`),"shown"}catch(c){return r(`[approvals] popup failed for ${a}: ${c?.message??c}`),"shown"}finally{ct=!1}}function Jl(t,e,n){if(!n)return{ok:!1,error:"the Mac popup is off; turn it on with `agentx approvals settings --popup on`"};let r=e.startsWith("card:")?B(t.root,e.slice(5)):null;return r?r.status!=="pending"?{ok:!1,error:`${e} is already ${r.status}`}:(yn(t.root,e),{ok:!0,message:`${e} will show on the Mac within a minute`}):{ok:!1,error:`no card "${e}"; the popup shows decision cards only`}}import{closeSync as J,createReadStream as Mo,fstatSync as No,openSync as Oo,realpathSync as vr}from"fs";import{isAbsolute as jo,resolve as $r,sep as Ar}from"path";var nu="/app-files",Vo=/^[A-Za-z0-9_.:-]{1,64}$/;function Wo(t,e,n=process.cwd()){if(!e||e.length>ne.pathChars||e.includes("\0"))return{ok:!1,status:400,error:"bad file path"};if(e.split(/[\\/]/).includes(".."))return{ok:!1,status:403,error:`the path leaves the workspace: copy the file into ${Ae}/ first`};if(!$e(e))return{ok:!1,status:415,error:"this type of file is not served"};let r;try{r=vr($r(n,t))}catch{return{ok:!1,status:404,error:"the agent's workspace is missing"}}let i;try{i=vr(jo(e)?e:$r(r,e))}catch{return{ok:!1,status:404,error:"file not found"}}if(!i.startsWith(r+Ar))return{ok:!1,status:403,error:`the file is outside the agent's workspace: copy it into ${Ae}/ first`};let s=$e(i);return s?{ok:!0,path:i,...s}:{ok:!1,status:415,error:"this type of file is not served"}}function Fo(t,e){let n=t.replace(/[^\x20-\x7e]/g,"_").replace(/["\\;]/g,"_").slice(0,120)||"file";return`${e==="file"?"attachment":"inline"}; filename="${n}"; filename*=UTF-8''${encodeURIComponent(t.slice(0,120))}`}function Uo(t,e,n){return{"Content-Type":t,"Content-Disposition":Fo(e,n),"X-Content-Type-Options":"nosniff","Content-Security-Policy":"default-src 'none'; img-src 'self'; media-src 'self'; sandbox","Cache-Control":"private, max-age=3600","Accept-Ranges":"bytes"}}function Bo(t,e){let n=/^bytes=(\d*)-(\d*)$/.exec(String(t||"").trim());if(!n||!n[1]&&!n[2])return null;let r,i;return n[1]?(r=Number(n[1]),i=n[2]?Math.min(Number(n[2]),e-1):e-1):(r=Math.max(0,e-Number(n[2])),i=e-1),r>i||r>=e?"unsatisfiable":{start:r,end:i}}function ru(t,e,n,r){let i=(P,j)=>{e.writeHead(P,{"Content-Type":"application/json","Cache-Control":"no-store","X-Content-Type-Options":"nosniff"}),e.end(JSON.stringify(j))};if(t.method!=="GET"&&t.method!=="HEAD")return i(405,{error:"GET only"});let s=n.searchParams.get("agent")||"",o=n.searchParams.get("file")||"";if(!Vo.test(s))return i(400,{error:"bad agent id"});let a=r.workspaceOf(s);if(!a)return i(404,{error:`no agent "${s}" on this computer`});let c=Wo(a,o,r.cwd);if(!c.ok)return r.log?.(`[app-files] refused ${JSON.stringify(o.slice(0,200))} from ${s}: ${c.error}`),i(c.status,{error:c.error});let l;try{l=Oo(c.path,"r")}catch{return i(404,{error:"file not found"})}let u;try{let P=No(l);if(!P.isFile())return J(l),i(404,{error:"not a file"});u=P.size}catch{return J(l),i(404,{error:"file not found"})}if(u>ne.bytes)return J(l),i(413,{error:`the file is larger than ${ne.bytes/1024/1024} MB`});let d=c.path.split(Ar).pop()||"file",p=Uo(c.mime,d,c.kind),g=Bo(t.headers.range,u);if(g==="unsatisfiable"){J(l),e.writeHead(416,{...p,"Content-Range":`bytes */${u}`}),e.end();return}let{start:f,end:m}=g??{start:0,end:u-1};if(e.writeHead(g?206:200,{...p,"Content-Length":String(u?m-f+1:0),...g?{"Content-Range":`bytes ${f}-${m}/${u}`}:{}}),t.method==="HEAD"||u===0){J(l),e.end();return}let y=Mo("",{fd:l,start:f,end:m,autoClose:!0});y.on("error",()=>e.destroy()),e.on("close",()=>y.destroy()),y.pipe(e)}import{spawn as Y}from"child_process";import{readFileSync as Ho,writeFileSync as zo}from"fs";import{tmpdir as qo}from"os";import{join as Go}from"path";vt();var Ir=t=>t&&t!==1?Math.round(175*t):null,ye=t=>t&&t!==1?Math.min(1.2,Math.max(.7,t)):null;function Ko(){if(process.env.ELEVENLABS_API_KEY)return process.env.ELEVENLABS_API_KEY;for(let t of[`${process.env.HOME}/.elevenlabs/key`,`${process.env.HOME}/.agentx/elevenlabs-key.txt`])try{let e=Ho(t,"utf8").trim();if(e)return e}catch{}return null}function pu(t=Ko()){let e=0;return async(n,r)=>{if(n.voice.provider==="system")return null;if(!t){if(n.voice.fallback)return null;throw new Error("ElevenLabs is the voice provider but no key is set")}try{let i=await fetch(`https://api.elevenlabs.io/v1/text-to-speech/${n.voice.elevenlabs}/stream?output_format=mp3_44100_128`,{method:"POST",headers:{"xi-api-key":t,"Content-Type":"application/json"},body:JSON.stringify({text:n.text,model_id:"eleven_flash_v2_5",...ye(n.voice.rate)?{voice_settings:{speed:ye(n.voice.rate)}}:{}}),signal:r});if(!i.ok)throw new Error(`ElevenLabs ${i.status}: ${(await i.text()).slice(0,160)}`);let s=Go(qo(),`agentx-say-${process.pid}-${++e}.mp3`);return zo(s,Buffer.from(await i.arrayBuffer())),s}catch(i){if(r.aborted||!n.voice.fallback)throw i;return N(`elevenlabs:${String(i?.message??i).slice(0,40)}`,`[voice] ElevenLabs failed (${String(i?.message??i).slice(0,160)}); speaking with the system voice`),null}}}function Rr(t,e){let n=t.languages&&te(e);return n&&t.languages&&n in t.languages?t.languages[n]:t.system}var Xo=(t,e="")=>{let n=Rr(t,e),r=Ir(t.rate);return[...n&&!Dn(n)?["-v",n]:[],...r?["-r",String(r)]:[]]};function Jo(t,e,n){if(!n)return["say",Xo(t,e)];let r=Rr(t,e);return["/bin/sh",[n,...r?[r]:[]]]}function gu(t){let e=t.split(/\s+/).filter(Boolean).length;return Math.min(300,5+Math.floor(e*6/10))*1e3}function fu(t=ut()){if(t)try{Y("/bin/sh",[t,"--stop"],{stdio:"ignore"}).on("error",()=>{})}catch{}}function mu(t=ut()){if(t)try{Y("/bin/sh",[t,"--restore"],{stdio:"ignore"}).on("error",()=>{})}catch{}}function ut(t={},e){if(!Le(t))return null;try{return En(e)}catch(n){return N("siri-say",`[voice] could not write the Siri voice script (${String(n?.message??n).split(`
|
|
463
463
|
`)[0]}); Siri voices will not switch`),null}}var hu=(t,e)=>{if(!t){let[n,r]=Jo(e.voice,e.text,ut()),i=Ir(e.voice.rate),s=i?{...process.env,AGENTX_SAY_RATE:String(i)}:process.env,o=Y(n,r,{stdio:["pipe","ignore","ignore"],env:s});return o.stdin?.on("error",()=>{}),o.stdin?.end(e.text),o}return process.platform==="darwin"?Y("afplay",[t],{stdio:"ignore"}):Y("mpg123",["-q",t],{stdio:"ignore"})};import{spawn as _r}from"child_process";import{accessSync as Yo,constants as Zo,readFileSync as Cr}from"fs";import{homedir as Qo}from"os";import{basename as F,delimiter as Dr,dirname as ea,extname as ta,join as dt}from"path";var L={ms:2*60*1e3,bitsPerSecond:64e3,bytes:2*1024*1024};function Pr(t){let e=Array.isArray(t)?t[0]:t;return!e||!/^\d{1,9}$/.test(e.trim())?{status:400,error:"Say how long the recording is (X-Audio-Duration-Ms)."}:Number(e)>L.ms+2e3?{status:413,error:gt()}:null}var gt=()=>`The recording is longer than ${L.ms/6e4} minutes.`,na={"audio/webm":"webm","video/webm":"webm","audio/ogg":"ogg","audio/mp4":"m4a","video/mp4":"m4a","audio/x-m4a":"m4a","audio/aac":"aac","audio/mpeg":"mp3","audio/wav":"wav","audio/x-wav":"wav","audio/wave":"wav"};function Tr(t){let e=String(t||"").split(";")[0].trim().toLowerCase();return na[e]??null}function Er(t,e){let n=[];return t!=="local"&&e.key&&n.push("elevenlabs"),e.ffmpeg&&(e.mlx?n.push("mlx-whisper"):e.whisper&&n.push("whisper")),n}function ft(t,e){return t==="local"&&e.key&&!e.ffmpeg?"Speech to text is set to local, and this computer has no ffmpeg.":(e.mlx||e.whisper)&&!e.ffmpeg?"This computer has Whisper but no ffmpeg to read the recording.":"Add an ElevenLabs key on this computer, or install mlx-whisper and ffmpeg."}function pt(t,e,n=process.env.PATH??""){let r=Qo(),i=[dt(r,".local","bin"),"/opt/homebrew/bin","/usr/local/bin",...n.split(Dr).filter(Boolean)];for(let s of[e,...i.map(o=>dt(o,t))])if(s)try{return Yo(s,Zo.X_OK),s}catch{}return null}function Su(t){return{key:t,mlx:pt("mlx_whisper",process.env.AGENTX_MLX_WHISPER),whisper:pt("whisper",process.env.AGENTX_WHISPER),ffmpeg:ra()}}var ra=()=>pt("ffmpeg",process.env.AGENTX_FFMPEG);async function Lr(t,e){return e?ia(t,e):null}async function ia(t,e){let n=String(L.ms/1e3+5);try{let i=[...(await sa(e,["-nostdin","-hide_banner","-t",n,"-i",t,"-f","null","-"],3e4)).matchAll(/time=(\d+):(\d+):(\d+(?:\.\d+)?)/g)],s=i[i.length-1];return s?Number(s[1])*3600+Number(s[2])*60+Number(s[3]):null}catch{return null}}async function Mr(t,e,n,r){let i=new FormData;i.set("model_id",process.env.AGENTX_STT_MODEL||"scribe_v1"),i.set("file",new Blob([Cr(t)],{type:e}),F(t));let s=await fetch("https://api.elevenlabs.io/v1/speech-to-text",{method:"POST",headers:{"xi-api-key":n},body:i,signal:r??AbortSignal.timeout(6e4)});if(!s.ok)throw new Error(`ElevenLabs ${s.status}: ${(await s.text().catch(()=>"")).slice(0,160)}`);let o=await s.json();if(typeof o.text!="string")throw new Error("ElevenLabs returned no text");return o.text.trim()}async function Nr(t,e,n,r,i){let s=t==="mlx-whisper"?["--model",process.env.AGENTX_MLX_MODEL||"mlx-community/whisper-large-v3-turbo","--output-format","txt","--output-dir",i,n]:[n,"--model",process.env.AGENTX_WHISPER_MODEL||"base","--output_format","txt","--output_dir",i,"--fp16","False"],o={...process.env,PATH:`${ea(r)}${Dr}${process.env.PATH??""}`};await oa(e,s,12e4,o);try{return Cr(dt(i,F(n,ta(n))+".txt"),"utf8").trim()}catch{throw new Error(`${t} wrote no transcript`)}}function sa(t,e,n){return new Promise((r,i)=>{let s=_r(t,e,{stdio:["ignore","ignore","pipe"]}),o="",a=setTimeout(()=>{s.kill("SIGKILL"),i(new Error(`${F(t)} took too long`))},n);s.stderr.on("data",c=>{o=(o+c).slice(-8192)}),s.on("error",c=>{clearTimeout(a),i(c)}),s.on("exit",c=>{clearTimeout(a),c===0?r(o):i(new Error(`${F(t)} exited ${c}`))})})}function oa(t,e,n,r=process.env){return new Promise((i,s)=>{let o=_r(t,e,{stdio:["ignore","pipe","pipe"],env:r}),a="",c="",l=setTimeout(()=>{o.kill("SIGKILL"),s(new Error(`${F(t)} took longer than ${n/1e3}s`))},n);o.stdout.on("data",u=>{a.length<4096&&(a+=u)}),o.stderr.on("data",u=>{c.length<4096&&(c+=u)}),o.on("error",u=>{clearTimeout(l),s(u)}),o.on("exit",u=>{clearTimeout(l),u===0?i(a):s(new Error(`${F(t)} exited ${u}: ${c.trim().split(`
|
|
464
464
|
`).pop()?.slice(0,160)??""}`))})})}import{mkdtemp as aa,rm as ca,writeFile as la}from"fs/promises";import{tmpdir as ua}from"os";import{join as Or}from"path";qr();var da=64*1024,pa=2,mt=0;function Eu(t){return t==="/voice/transcribe"||t==="/voice/speak"}async function Lu(t,e,n,r){return t.method!=="POST"?b(e,405,{error:"POST"}):n==="/voice/transcribe"?ga(t,e,r):ha(t,e,r)}async function ga(t,e,n){let r=String(t.headers["content-type"]||""),i=Tr(r);if(!i)return b(e,415,{error:"Send the recording as audio (webm, mp4, ogg, mp3 or wav)."});let s=Pr(t.headers["x-audio-duration-ms"]);if(s)return t.resume(),b(e,s.status,{error:s.error});let o=await jr(t,L.bytes);if(!o)return b(e,413,{error:wa()});if(!o.length)return b(e,400,{error:"The recording is empty."});if(mt>=pa)return b(e,429,{error:"This computer is already writing down other recordings. Try again in a moment."});let a=n.stt(),c=n.host(),l=Er(a,c);if(!c.ffmpeg&&!n.allowUnmeasured?.()){let d=n.nodeName?`on ${n.nodeName}`:"on this computer",p=l.length?"":" "+ft(a,c);return b(e,503,{error:"Voice input isn't set up on this computer.",hint:`Install ffmpeg ${d} for voice input from the phone.${p}`,setup:!1})}if(!l.length)return b(e,503,{error:"Voice input isn't set up on this computer.",hint:ft(a,c),setup:!1});mt++;let u;try{let d=await aa(Or(ua(),"agentx-phone-voice-"));try{u=await fa(d,`speech.${i}`,o,r,c,l,n)}finally{await ca(d,{recursive:!0,force:!0}).catch(()=>{})}}finally{mt--}b(e,u[0],u[1])}async function fa(t,e,n,r,i,s,o){let a=Or(t,e);if(await la(a,n,{mode:384}),i.ffmpeg){let l=await(o.measure??Lr)(a,i.ffmpeg);if(l==null)return[422,{error:"This computer couldn't read the recording. Try again."}];if(l*1e3>L.ms+2e3)return[413,{error:gt()}]}let c=[];for(let l of s)try{let u=await ma(l,a,r,i,t,o);return o.log(`[voice] phone recording transcribed with ${l} (${Math.round(n.length/1024)} KB)`),u?[200,{text:u,engine:l}]:[422,{error:"No words were heard. Hold the orb and speak, then let go.",engine:l}]}catch(u){let d=String(u?.message??u).split(`
|
|
465
|
-
`)[0].slice(0,200);c.push(`${l}: ${d}`),o.log(`[voice] phone transcription with ${l} failed: ${d}`)}return[502,{error:"Speech to text failed on this computer.",detail:c.join("; ")}]}function ma(t,e,n,r,i,s){let o=s.engines?.[t];if(o)return o(e,n,r,i);if(t==="elevenlabs")return Mr(e,n,r.key);let a=t==="mlx-whisper"?r.mlx:r.whisper;return Nr(t,a,e,r.ffmpeg,i)}async function ha(t,e,n){let r=await jr(t,da);if(!r)return b(e,413,{error:"request too large"});let i;try{i=JSON.parse(r.toString("utf8")||"{}")}catch{return b(e,400,{error:"expected JSON"})}let s=typeof i?.agent=="string"?i.agent:"",o=typeof i?.peer=="string"&&i.peer?i.peer:void 0;if(!s)return b(e,400,{error:"agent is required"});let a=ya(typeof i?.text=="string"?i.text:"",n.spokenMaxChars?.());if(!a)return b(e,422,{error:"Nothing in this answer can be said aloud."});let c=n.voiceOf(s,o);if(!
|
|
466
|
-
`)[0].slice(0,160)}`),
|
|
465
|
+
`)[0].slice(0,200);c.push(`${l}: ${d}`),o.log(`[voice] phone transcription with ${l} failed: ${d}`)}return[502,{error:"Speech to text failed on this computer.",detail:c.join("; ")}]}function ma(t,e,n,r,i,s){let o=s.engines?.[t];if(o)return o(e,n,r,i);if(t==="elevenlabs")return Mr(e,n,r.key);let a=t==="mlx-whisper"?r.mlx:r.whisper;return Nr(t,a,e,r.ffmpeg,i)}async function ha(t,e,n){let r=await jr(t,da);if(!r)return b(e,413,{error:"request too large"});let i;try{i=JSON.parse(r.toString("utf8")||"{}")}catch{return b(e,400,{error:"expected JSON"})}let s=typeof i?.agent=="string"?i.agent:"",o=typeof i?.peer=="string"&&i.peer?i.peer:void 0;if(!s)return b(e,400,{error:"agent is required"});let a=ya(typeof i?.text=="string"?i.text:"",n.spokenMaxChars?.());if(!a)return b(e,422,{error:"Nothing in this answer can be said aloud."});let c=n.pronounce?n.pronounce(a):a,l=n.voiceOf(s,o);if(!l)return b(e,404,{error:`Unknown agent: ${s}`});let u=(p,g=200)=>b(e,g,{fallback:"browser",reason:p,text:c});if(l.provider!=="elevenlabs")return u("This agent speaks with a system voice, which only plays on the computer.");let d=n.elevenLabsKey();if(!d)return u("No ElevenLabs key is set on this computer.");try{let p=await(n.synth??ba)(d,l,c);e.writeHead(200,{"Content-Type":"audio/mpeg","Content-Length":p.length,"Cache-Control":"no-store","X-Spoken-Chars":String(c.length)}),e.end(p)}catch(p){return n.log(`[voice] phone answer synthesis failed: ${String(p?.message??p).split(`
|
|
466
|
+
`)[0].slice(0,160)}`),u("ElevenLabs could not speak this answer.",502)}}function ya(t,e){let n=rr(Lt(t).text).cleanText.replace(/!\[[^\]\n]*\]\([^)\n]*\)/g,"");return $t(n,e)}async function ba(t,e,n){let r=ye(e.rate),i=await fetch(`https://api.elevenlabs.io/v1/text-to-speech/${encodeURIComponent(e.elevenlabs)}?output_format=mp3_44100_128`,{method:"POST",headers:{"xi-api-key":t,"Content-Type":"application/json"},body:JSON.stringify({text:n,model_id:"eleven_flash_v2_5",...r?{voice_settings:{speed:r}}:{}}),signal:AbortSignal.timeout(6e4)});if(!i.ok)throw new Error(`ElevenLabs ${i.status}: ${(await i.text().catch(()=>"")).slice(0,160)}`);return Buffer.from(await i.arrayBuffer())}var wa=()=>`The recording is larger than ${L.bytes/1024/1024} MB, more than ${L.ms/6e4} minutes of speech.`;function Mu(t,e,n,r){if(e)return r.speakerOn(e,t,!1)?.voice??null;let i=n.agents??{};return i[t]?He(Fe(t,i,n.voice)):null}function jr(t,e){return Number(t.headers["content-length"])>e?(t.resume(),Promise.resolve(null)):new Promise((n,r)=>{let i=[],s=0;t.on("data",o=>{if(!(s>e)){if(s+=o.length,s>e){i.length=0,n(null);return}i.push(o)}}),t.on("end",()=>{s<=e&&n(Buffer.concat(i))}),t.on("error",r)})}function b(t,e,n){t.writeHead(e,{"Content-Type":"application/json","Cache-Control":"no-store"}),t.end(JSON.stringify(n))}import{existsSync as v,readFileSync as wt,writeFileSync as kt,mkdirSync as be,readdirSync as bt,rmSync as ka,statSync as R}from"fs";import{resolve as Vr,relative as xa,dirname as xt,join as O,extname as Z,basename as St}from"path";var x=200*1024,Wr=new Set([".md",".markdown",".txt"]),U=new Set([".md",".markdown",".txt",".json",".jsonc",".yaml",".yml",".toml",".sh",".bash",".zsh",".py",".js",".mjs",".ts",".tsx",".jsx",".css",".html",".lock",".cfg",".ini",".env",".gitignore"]),Sa=6,va=new Set(["CLAUDE.md","SOUL.md","IDENTITY.md","PERSONA.md","AGENT.md","BOOTSTRAP.md"]);function D(t,e){if(!t)throw new Error("Agent workspace is not configured.");let n=Vr(t);if(v(n)||be(n,{recursive:!0}),!e||e.startsWith("/")||e.match(/^[a-zA-Z]:/))throw new Error(`Path must be relative to the workspace: ${e}`);let r=Vr(n,e);if(xa(n,r).startsWith(".."))throw new Error(`Path escapes the workspace: ${e}`);return r}function Fr(t){let e=Z(t).toLowerCase();if(!Wr.has(e))throw new Error(`Only text files (.md, .markdown, .txt) can be edited from the admin panel (got ${e}).`)}function ht(t,e){let n=t.split(/\r?\n/).find(r=>r.trim().startsWith("#"));return n&&n.replace(/^#+\s*/,"").trim().slice(0,120)||e}function Vu(t){let e=D(t,"."),n=[],r=new Set,i=[];try{i=bt(e)}catch{}for(let a of va){let c=O(e,a);if(v(c)&&R(c).isFile()){let l=R(c).size,u=l>0&&l<x?yt(c):"";n.push({path:a,title:ht(u,a),size:l,exists:!0}),r.add(a)}else n.push({path:a,title:a,size:0,exists:!1}),r.add(a)}for(let a of i){if(r.has(a))continue;let c=O(e,a);try{let l=R(c);if(!l.isFile()||!Wr.has(Z(a).toLowerCase()))continue;let u=l.size>0&&l.size<x?yt(c):"";n.push({path:a,title:ht(u,a),size:l.size,exists:!0})}catch{}}let s=[],o=O(e,".claude","skills");if(v(o))try{for(let a of bt(o)){let c=O(o,a),l;try{l=R(c)}catch{continue}if(!l.isDirectory())continue;let u=O(c,"SKILL.md");if(!v(u))continue;let d=R(u),p=d.size<x?yt(u):"";s.push({slug:a,title:ht(p,a),size:d.size,path:`.claude/skills/${a}/SKILL.md`})}}catch{}return s.sort((a,c)=>a.slug.localeCompare(c.slug)),{identity:n,skills:s,workspace:e}}function yt(t){try{return wt(t,"utf-8")}catch{return""}}function Wu(t,e){let n=D(t,e);if(Fr(n),!v(n))return{path:e,content:""};if(R(n).size>x)throw new Error(`File is too large to edit in the admin panel (> ${x/1024} KB).`);return{path:e,content:wt(n,"utf-8")}}function Fu(t,e,n){let r=D(t,e);Fr(r);let i=Buffer.from(n,"utf-8");if(i.length>x)throw new Error(`File too large (${i.length} > ${x} bytes).`);return be(xt(r),{recursive:!0}),kt(r,i),{path:e,bytes:i.length}}function Uu(t,e,n={}){if(!/^[a-z0-9][a-z0-9_-]*$/.test(e))throw new Error("Skill slug must be lowercase (letters, digits, -, _) and start with a letter or digit.");let r=`.claude/skills/${e}/SKILL.md`,i=D(t,r);if(v(i))throw new Error(`Skill "${e}" already exists.`);be(xt(i),{recursive:!0});let s=n.content?.trim()?n.content:$a(e,n.title);return kt(i,s),{slug:e,path:r}}function Bu(t,e){if(!/^[a-z0-9][a-z0-9_-]*$/.test(e))throw new Error(`Invalid skill slug: ${e}`);let n=D(t,`.claude/skills/${e}`);if(!v(n))throw new Error(`Skill "${e}" not found.`);if(!R(n).isDirectory())throw new Error(`Skill path is not a directory: ${e}`);return ka(n,{recursive:!0,force:!0}),{slug:e}}function Hu(t,e){if(!/^[a-z0-9][a-z0-9_-]*$/.test(e))throw new Error(`Invalid skill slug: ${e}`);let n=D(t,`.claude/skills/${e}`);if(!v(n))throw new Error(`Skill "${e}" not found.`);let r=[];return i(n,"",0,r),r.sort((s,o)=>s.kind!==o.kind?s.kind==="dir"?-1:1:s.path.localeCompare(o.path)),r;function i(s,o,a,c){if(a>Sa)return;let l=[];try{l=bt(s)}catch{return}for(let u of l){if(u==="node_modules"||u===".git")continue;let d=O(s,u),p=o?`${o}/${u}`:u,g;try{g=R(d)}catch{continue}if(g.isDirectory())c.push({path:`${p}/`,kind:"dir",size:0,editable:!1}),i(d,p,a+1,c);else if(g.isFile()){let f=Z(u).toLowerCase(),m=U.has(f)||U.has(u.toLowerCase());c.push({path:p,kind:"file",size:g.size,editable:m&&g.size<x})}}}}function zu(t,e,n){if(!/^[a-z0-9][a-z0-9_-]*$/.test(e))throw new Error(`Invalid skill slug: ${e}`);if(!n||n.includes(".."))throw new Error(`Invalid file path: ${n}`);let r=D(t,`.claude/skills/${e}/${n}`);if(!v(r)||!R(r).isFile())throw new Error(`File not found: ${n}`);let i=Z(r).toLowerCase(),s=St(r).toLowerCase();if(!U.has(i)&&!U.has(s))throw new Error(`File type not editable: ${n}`);if(R(r).size>x)throw new Error(`File too large to edit (> ${x/1024} KB): ${n}`);return{path:n,content:wt(r,"utf-8")}}function qu(t,e,n,r){if(!/^[a-z0-9][a-z0-9_-]*$/.test(e))throw new Error(`Invalid skill slug: ${e}`);if(!n||n.includes(".."))throw new Error(`Invalid file path: ${n}`);let i=D(t,`.claude/skills/${e}/${n}`),s=Z(i).toLowerCase(),o=St(i).toLowerCase();if(!U.has(s)&&!U.has(o))throw new Error(`File type not editable: ${n}`);let a=Buffer.from(r,"utf-8");if(a.length>x)throw new Error(`File too large (${a.length} > ${x} bytes).`);return be(xt(i),{recursive:!0}),kt(i,a),{path:n,bytes:a.length}}function Gu(t,e){if(!/^[a-z0-9][a-z0-9_-]*$/.test(e))throw new Error(`Invalid skill slug: ${e}`);let n=D(t,`.claude/skills/${e}`);if(!v(n))throw new Error(`Skill "${e}" not found.`);let r=i=>v(O(n,i));return r("pnpm-lock.yaml")?{manager:"pnpm",file:"pnpm-lock.yaml",command:"pnpm install"}:r("yarn.lock")?{manager:"yarn",file:"yarn.lock",command:"yarn install"}:r("package.json")?{manager:"npm",file:"package.json",command:"npm install"}:r("requirements.txt")?{manager:"pip",file:"requirements.txt",command:"pip install -r requirements.txt"}:r("Gemfile")?{manager:"bundle",file:"Gemfile",command:"bundle install"}:{manager:null,file:null,command:null}}function $a(t,e){return`# ${e?.trim()||t}
|
|
467
467
|
|
|
468
468
|
Describe what this skill does and when the agent should use it. Keep it under ~5 lines \u2014 the agent reads this to decide whether to invoke the skill.
|
|
469
469
|
|
|
@@ -479,4 +479,4 @@ Document the arguments, commands, or files the skill expects. Example:
|
|
|
479
479
|
claude-code ${St(t)} --arg value
|
|
480
480
|
\`\`\`
|
|
481
481
|
`}Dt();var Ur={maxPixels:12e5,timeoutMs:5e3,intervalMs:100,changeThreshold:.015,stableMs:400,regions:{},buffer:{enabled:!1,seconds:10,fps:2,region:"screen",maxPixels:3e5}};function Br(t){return{...Ur,...t??{},regions:{...t?.regions??{}},buffer:{...Ur.buffer,...t?.buffer??{}}}}function Ju(t){try{return Br(Ct(t).screen)}catch{return Br(void 0)}}var Aa=/^[a-z][\w-]*$/,Hr=["window","screen","menubar","notifications"];function Q(t,e,n,r){let i=Number(t);if(t===""||t===null||!Number.isFinite(i)||!n(i))throw new Error(`${e} must be ${r}`);return i}var we=(t,e)=>Q(t,e,n=>Number.isInteger(n)&&n>0,"a whole number above 0");function zr(t){let e=typeof t=="string"?t.split(",").map(Number):[t?.x,t?.y,t?.width,t?.height].map(Number);if(e.length!==4||!e.every(Number.isFinite)||e[2]<=0||e[3]<=0)throw new Error("a region is x,y,width,height in screen points, with width and height above 0");return{x:e[0],y:e[1],width:e[2],height:e[3]}}function Yu(t,e){let n={...t??{}};if("maxPixels"in e&&(n.maxPixels=we(e.maxPixels,"maxPixels")),"timeoutMs"in e&&(n.timeoutMs=we(e.timeoutMs,"timeoutMs")),"intervalMs"in e&&(n.intervalMs=we(e.intervalMs,"intervalMs")),"stableMs"in e&&(n.stableMs=Q(e.stableMs,"stableMs",i=>Number.isInteger(i)&&i>=0,"a whole number, 0 or more")),"changeThreshold"in e&&(n.changeThreshold=Q(e.changeThreshold,"changeThreshold",i=>i>=0&&i<=1,"between 0 and 1")),e.regions&&typeof e.regions=="object"){let i={...n.regions??{}};for(let[s,o]of Object.entries(e.regions)){if(!Aa.test(s))throw new Error(`region name "${s}" must be lowercase letters, digits, - or _`);o===null?delete i[s]:i[s]=zr(o)}n.regions=i}if(e.buffer&&typeof e.buffer=="object"){let i=e.buffer,s={...n.buffer??{}};"enabled"in i&&(s.enabled=!!i.enabled),"seconds"in i&&(s.seconds=Q(i.seconds,"buffer.seconds",o=>o>0&&o<=120,"above 0 and at most 120")),"fps"in i&&(s.fps=Q(i.fps,"buffer.fps",o=>o>0&&o<=10,"above 0 and at most 10")),"maxPixels"in i&&(s.maxPixels=we(i.maxPixels,"buffer.maxPixels")),"region"in i&&(s.region=String(i.region).trim()),n.buffer=s}let r=n.buffer?.region;if(r!==void 0&&!Hr.includes(r)&&!n.regions?.[r])try{zr(r)}catch{throw new Error(`buffer.region "${r}" is not a region \u2014 use ${[...Hr,...Object.keys(n.regions??{})].join(", ")}, or x,y,w,h`)}return n}export{Zt as a,_a as b,tt as c,Bs as d,Hs as e,cl as f,ll as g,ul as h,rr as i,pl as j,fl as k,E as l,ir as m,k as n,Ta as o,Ma as p,bi as q,Fa as r,gn as s,A as t,qa as u,Ga as v,bn as w,Qa as x,q as y,gc as z,vn as A,hl as B,nt as C,sr as D,wl as E,Sl as F,wr as G,Xl as H,Jl as I,nu as J,Uo as K,ru as L,mc as M,hc as N,yc as O,bc as P,wc as Q,kc as R,Sc as S,vc as T,Tc as U,Oe as V,Ec as W,Lc as X,G as Y,K as Z,Ko as _,pu as $,gu as aa,fu as ba,mu as ca,ut as da,hu as ea,We as fa,Fe as ga,ge as ha,ls as ia,ds as ja,Vc as ka,Be as la,He as ma,ps as na,gs as oa,Bn as pa,Gn as qa,Wc as ra,hs as sa,Fc as ta,$s as ua,Rs as va,ze as wa,Cs as xa,Kn as ya,L as za,Pr as Aa,Tr as Ba,Er as Ca,Su as Da,ra as Ea,Mr as Fa,Nr as Ga,Eu as Ha,Lu as Ia,wa as Ja,Mu as Ka,jr as La,fe as Ma,Qc as Na,er as Oa,qe as Pa,Qe as Qa,ol as Ra,Vu as Sa,Wu as Ta,Fu as Ua,Uu as Va,Bu as Wa,Hu as Xa,zu as Ya,qu as Za,Gu as _a,Ur as $a,Br as ab,Ju as bb,Hr as cb,Yu as db};
|
|
482
|
-
//# sourceMappingURL=chunk-
|
|
482
|
+
//# sourceMappingURL=chunk-OZDSQVHU.js.map
|