agentix-cli 0.145.0 → 0.146.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-MYHUCIKZ.js → App-EU2AJWW5.js} +2 -2
- package/dist/{ChatApp-D6QN6HJP.js → ChatApp-ORR3U3AN.js} +2 -2
- package/dist/{absorb-eval-UAGD42BG.js → absorb-eval-3VGPDRWS.js} +2 -2
- package/dist/{agent-HEGEDDUE.js → agent-NVJNOK5L.js} +2 -2
- package/dist/{board-dashboard-4KIFLAFO.js → board-dashboard-JV2JNRWD.js} +31 -18
- package/dist/board-dashboard-JV2JNRWD.js.map +1 -0
- package/dist/{chunk-5E37FADJ.js → chunk-3BMIZY6X.js} +2 -2
- package/dist/{chunk-YUY35PY7.js → chunk-5TFXFLMN.js} +3 -3
- package/dist/{chunk-VDJZ2Q3M.js → chunk-5YAUENDI.js} +2 -2
- package/dist/{chunk-TM3I6C4V.js → chunk-7O7VDA3J.js} +2 -2
- package/dist/{chunk-OFJKTKRM.js → chunk-DTWBB7B7.js} +2 -2
- package/dist/{chunk-EV76NT3E.js → chunk-GECGRCYC.js} +2 -2
- package/dist/{chunk-4NKPVTVP.js → chunk-IBK7AG4S.js} +8 -8
- package/dist/chunk-IBK7AG4S.js.map +1 -0
- package/dist/{chunk-42BEORFZ.js → chunk-J723FL3J.js} +2 -2
- package/dist/{chunk-VMMCT27Z.js → chunk-K3QDK4BX.js} +2 -2
- package/dist/{chunk-VXBL2DET.js → chunk-MO7DH5L6.js} +3 -3
- package/dist/chunk-MO7DH5L6.js.map +1 -0
- package/dist/chunk-MOCKFVYE.js +128 -0
- package/dist/chunk-MOCKFVYE.js.map +1 -0
- package/dist/{chunk-HCSIM2QW.js → chunk-NBDYBTI6.js} +279 -278
- package/dist/chunk-NBDYBTI6.js.map +1 -0
- package/dist/{chunk-P42M6CYF.js → chunk-O7ZJS33Z.js} +2 -2
- package/dist/{chunk-HSRNH4NR.js → chunk-OEB6RTRA.js} +2 -2
- package/dist/{chunk-KAGLCJA3.js → chunk-OT5KLHUT.js} +2 -2
- package/dist/{chunk-GMVWDQFF.js → chunk-QNS3WHGU.js} +2 -2
- package/dist/{chunk-YEFEUSB2.js → chunk-SK24JFEK.js} +2 -2
- package/dist/{chunk-YWDXRGVC.js → chunk-SNCRLEH3.js} +78 -78
- package/dist/chunk-SNCRLEH3.js.map +1 -0
- package/dist/{chunk-JTDQO4LI.js → chunk-TYONASHA.js} +2 -2
- package/dist/{chunk-SH5TNMS5.js → chunk-TZVJP4H3.js} +2 -2
- package/dist/{chunk-VTVEJ3RA.js → chunk-UFX6INNI.js} +2 -2
- package/dist/{chunk-SANYTBHX.js → chunk-USTNT7P7.js} +2 -2
- package/dist/{chunk-BPOMIEEE.js → chunk-UTYNYG7M.js} +2 -2
- package/dist/{chunk-HP2NWDCS.js → chunk-UVJLIHLL.js} +2 -2
- package/dist/{chunk-QXPMWP4R.js → chunk-UYLVSS6I.js} +2 -2
- package/dist/{chunk-WUBSX6S5.js → chunk-WCOT35YG.js} +2 -2
- package/dist/cli.js +1 -1
- package/dist/{client-ZU5AWBXQ.js → client-6KZZKCN2.js} +2 -2
- package/dist/{config-Q4MNOHRI.js → config-W6JNVPBY.js} +2 -2
- package/dist/{config-mutate-DVARJ4KM.js → config-mutate-57YT7BNB.js} +2 -2
- package/dist/config-mutator-6NWQPE7K.js +2 -0
- package/dist/{contributions-HKWDGIQV.js → contributions-Y6B6LG7X.js} +2 -2
- package/dist/{doctor-RTVGZP3X.js → doctor-ZP4KADAD.js} +2 -2
- package/dist/{follow-up-tool-2T4SIFY2.js → follow-up-tool-5AMZKVI4.js} +2 -2
- package/dist/{hub-3LDKRLTH.js → hub-BZF3ZYQ5.js} +2 -2
- package/dist/index.d.ts +106 -0
- package/dist/index.js +1 -1
- package/dist/{program-MAM4NX5P.js → program-MO7HLAP5.js} +190 -190
- package/dist/program-MO7HLAP5.js.map +1 -0
- package/dist/{promote-YOV5ELNF.js → promote-IJANZNQK.js} +2 -2
- package/dist/{query-LTKK3M2Y.js → query-DC74NB3R.js} +2 -2
- package/dist/{query-settings-ACXSGMDU.js → query-settings-RXFOATOZ.js} +2 -2
- package/dist/{registry-NIAPKDQF.js → registry-24IXRDWX.js} +2 -2
- package/dist/{request-planner-433C7M3L.js → request-planner-33CWWCJU.js} +2 -2
- package/dist/{review-candidates-SI3QBYNH.js → review-candidates-ENWB6LHD.js} +2 -2
- package/dist/{routing-CXT77HBF.js → routing-AUFJ4MNP.js} +2 -2
- package/dist/schedule-tool-NAMOBMZE.js +2 -0
- package/dist/{scheduler-SFHWPWCA.js → scheduler-KWSBBZKW.js} +2 -2
- package/dist/{seat-CJVTUIM2.js → seat-YGMLJ6KS.js} +2 -2
- package/dist/{select-JHGDG4H2.js → select-JJGBM6ZT.js} +2 -2
- package/dist/{set-enabled-NOJGCJAL.js → set-enabled-THE7QIGQ.js} +2 -2
- package/dist/{tool-ERK543LL.js → tool-4ACTSFKC.js} +2 -2
- package/dist/{tool-YOSMTSJM.js → tool-6LR6VORJ.js} +4 -4
- package/dist/tool-6LR6VORJ.js.map +1 -0
- package/dist/{wiki-2LLXQUEP.js → wiki-YAW7UEOQ.js} +2 -2
- package/dist/wiki-enrich-6ANFA2VB.js +2 -0
- package/package.json +1 -1
- package/dist/board-dashboard-4KIFLAFO.js.map +0 -1
- package/dist/chunk-4NKPVTVP.js.map +0 -1
- package/dist/chunk-HCSIM2QW.js.map +0 -1
- package/dist/chunk-LJ62ABOZ.js +0 -128
- package/dist/chunk-LJ62ABOZ.js.map +0 -1
- package/dist/chunk-VXBL2DET.js.map +0 -1
- package/dist/chunk-YWDXRGVC.js.map +0 -1
- package/dist/config-mutator-5NYGSUJD.js +0 -2
- package/dist/program-MAM4NX5P.js.map +0 -1
- package/dist/schedule-tool-3R4ISM5R.js +0 -2
- package/dist/tool-YOSMTSJM.js.map +0 -1
- package/dist/wiki-enrich-6C2O2MNV.js +0 -2
- /package/dist/{App-MYHUCIKZ.js.map → App-EU2AJWW5.js.map} +0 -0
- /package/dist/{ChatApp-D6QN6HJP.js.map → ChatApp-ORR3U3AN.js.map} +0 -0
- /package/dist/{absorb-eval-UAGD42BG.js.map → absorb-eval-3VGPDRWS.js.map} +0 -0
- /package/dist/{agent-HEGEDDUE.js.map → agent-NVJNOK5L.js.map} +0 -0
- /package/dist/{chunk-5E37FADJ.js.map → chunk-3BMIZY6X.js.map} +0 -0
- /package/dist/{chunk-YUY35PY7.js.map → chunk-5TFXFLMN.js.map} +0 -0
- /package/dist/{chunk-VDJZ2Q3M.js.map → chunk-5YAUENDI.js.map} +0 -0
- /package/dist/{chunk-TM3I6C4V.js.map → chunk-7O7VDA3J.js.map} +0 -0
- /package/dist/{chunk-OFJKTKRM.js.map → chunk-DTWBB7B7.js.map} +0 -0
- /package/dist/{chunk-EV76NT3E.js.map → chunk-GECGRCYC.js.map} +0 -0
- /package/dist/{chunk-42BEORFZ.js.map → chunk-J723FL3J.js.map} +0 -0
- /package/dist/{chunk-VMMCT27Z.js.map → chunk-K3QDK4BX.js.map} +0 -0
- /package/dist/{chunk-P42M6CYF.js.map → chunk-O7ZJS33Z.js.map} +0 -0
- /package/dist/{chunk-HSRNH4NR.js.map → chunk-OEB6RTRA.js.map} +0 -0
- /package/dist/{chunk-KAGLCJA3.js.map → chunk-OT5KLHUT.js.map} +0 -0
- /package/dist/{chunk-GMVWDQFF.js.map → chunk-QNS3WHGU.js.map} +0 -0
- /package/dist/{chunk-YEFEUSB2.js.map → chunk-SK24JFEK.js.map} +0 -0
- /package/dist/{chunk-JTDQO4LI.js.map → chunk-TYONASHA.js.map} +0 -0
- /package/dist/{chunk-SH5TNMS5.js.map → chunk-TZVJP4H3.js.map} +0 -0
- /package/dist/{chunk-VTVEJ3RA.js.map → chunk-UFX6INNI.js.map} +0 -0
- /package/dist/{chunk-SANYTBHX.js.map → chunk-USTNT7P7.js.map} +0 -0
- /package/dist/{chunk-BPOMIEEE.js.map → chunk-UTYNYG7M.js.map} +0 -0
- /package/dist/{chunk-HP2NWDCS.js.map → chunk-UVJLIHLL.js.map} +0 -0
- /package/dist/{chunk-QXPMWP4R.js.map → chunk-UYLVSS6I.js.map} +0 -0
- /package/dist/{chunk-WUBSX6S5.js.map → chunk-WCOT35YG.js.map} +0 -0
- /package/dist/{client-ZU5AWBXQ.js.map → client-6KZZKCN2.js.map} +0 -0
- /package/dist/{config-Q4MNOHRI.js.map → config-W6JNVPBY.js.map} +0 -0
- /package/dist/{config-mutate-DVARJ4KM.js.map → config-mutate-57YT7BNB.js.map} +0 -0
- /package/dist/{config-mutator-5NYGSUJD.js.map → config-mutator-6NWQPE7K.js.map} +0 -0
- /package/dist/{contributions-HKWDGIQV.js.map → contributions-Y6B6LG7X.js.map} +0 -0
- /package/dist/{doctor-RTVGZP3X.js.map → doctor-ZP4KADAD.js.map} +0 -0
- /package/dist/{follow-up-tool-2T4SIFY2.js.map → follow-up-tool-5AMZKVI4.js.map} +0 -0
- /package/dist/{hub-3LDKRLTH.js.map → hub-BZF3ZYQ5.js.map} +0 -0
- /package/dist/{promote-YOV5ELNF.js.map → promote-IJANZNQK.js.map} +0 -0
- /package/dist/{query-LTKK3M2Y.js.map → query-DC74NB3R.js.map} +0 -0
- /package/dist/{query-settings-ACXSGMDU.js.map → query-settings-RXFOATOZ.js.map} +0 -0
- /package/dist/{registry-NIAPKDQF.js.map → registry-24IXRDWX.js.map} +0 -0
- /package/dist/{request-planner-433C7M3L.js.map → request-planner-33CWWCJU.js.map} +0 -0
- /package/dist/{review-candidates-SI3QBYNH.js.map → review-candidates-ENWB6LHD.js.map} +0 -0
- /package/dist/{routing-CXT77HBF.js.map → routing-AUFJ4MNP.js.map} +0 -0
- /package/dist/{schedule-tool-3R4ISM5R.js.map → schedule-tool-NAMOBMZE.js.map} +0 -0
- /package/dist/{scheduler-SFHWPWCA.js.map → scheduler-KWSBBZKW.js.map} +0 -0
- /package/dist/{seat-CJVTUIM2.js.map → seat-YGMLJ6KS.js.map} +0 -0
- /package/dist/{select-JHGDG4H2.js.map → select-JJGBM6ZT.js.map} +0 -0
- /package/dist/{set-enabled-NOJGCJAL.js.map → set-enabled-THE7QIGQ.js.map} +0 -0
- /package/dist/{tool-ERK543LL.js.map → tool-4ACTSFKC.js.map} +0 -0
- /package/dist/{wiki-2LLXQUEP.js.map → wiki-YAW7UEOQ.js.map} +0 -0
- /package/dist/{wiki-enrich-6C2O2MNV.js.map → wiki-enrich-6ANFA2VB.js.map} +0 -0
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import{f as j,i as x,p as O,r as I}from"./chunk-S2GAEH2F.js";import{a as R}from"./chunk-JXF54PT7.js";import{La as S,Ta as L}from"./chunk-
|
|
1
|
+
import{f as j,i as x,p as O,r as I}from"./chunk-S2GAEH2F.js";import{a as R}from"./chunk-JXF54PT7.js";import{La as S,Ta as L}from"./chunk-IBK7AG4S.js";L();import{Command as z}from"commander";import f from"chalk";import{execFileSync as h}from"child_process";import{accessSync as T,constants as H,existsSync as y,readFileSync as b,readdirSync as $,statSync as X}from"fs";import{join as E,resolve as m}from"path";import{homedir as B}from"os";import{createRequire as F}from"module";import{execFile as M}from"child_process";var q=(t,n)=>new Promise(e=>{try{M(t,n,{timeout:5e3},(i,s)=>e(i?null:String(s)))}catch{e(null)}}),N="Open System Settings \u203A Notifications \u203A AgentX Helper, turn on Allow notifications and choose Banners.";async function P(t={}){if((t.platform??process.platform)!=="darwin")return{state:"unsupported",message:"Desktop banners are only shown on a Mac."};let n=t.helper===void 0?I():t.helper;if(!n)return{state:"missing",message:"AgentX Helper is not installed, so banners come from Script Editor and show its icon.",fix:'Run agentx desktop install, then run agentx notify "Hello" --title "Test" and click Allow.'};let e=await(t.run??q)(n,["notify-status"]),i=null;try{i=e?JSON.parse(e):null}catch{i=null}return i?i.authorization==="notDetermined"?{state:"not-asked",path:n,message:"macOS has not asked yet whether AgentX Helper may notify; banners show the Script Editor icon until it does.",fix:'Run agentx notify "Hello" --title "Test" and click Allow when macOS asks.'}:i.authorization==="denied"?{state:"not-allowed",path:n,message:"macOS does not allow AgentX Helper to notify, so banners show the Script Editor icon.",fix:N}:i.alertStyle==="none"?{state:"hidden",path:n,message:"AgentX Helper may notify, but its banner style is None, so nothing appears on screen.",fix:N}:{state:"ready",path:n,message:"AgentX Helper posts banners with the AgentX icon."}:{state:"outdated",path:n,message:"AgentX Helper is too old to report whether it may notify.",fix:"Run agentx desktop install to update it."}}async function J(t={}){let n=[];await Z(n),U(n);let e=K(n);return e&&Q(n,e),e&&Y(n,e),e&&ee(n,e),e&&te(n,e),e&&oe(n,e),e&&await G(n,e),e&&V(n,e),t.running!==!1&&e&&await ie(n,e),{checks:n,summary:W(n)}}var ke=new z().name("doctor").description("pre-flight health check: Node, config, credentials, daemon").option("--no-running","skip the live daemon probe").option("--json","emit machine-readable JSON (stable shape for CI)").action(async t=>{let{checks:n,summary:e}=await J({running:t.running!==!1});t.json?process.stdout.write(JSON.stringify({checks:n,summary:e},null,2)+`
|
|
2
2
|
`):se(n),process.exit(e.errors>0?1:0)});async function G(t,n,e=P){if(!O(n.notifications?.local).banner)return;let i=await e();i.state!=="unsupported"&&t.push({severity:i.state==="ready"?"ok":"warn",group:"Notifications",title:i.message,detail:i.path,fix:i.fix})}function V(t,n,e=process.platform,i=s=>{try{return T(s,H.X_OK),!0}catch{return!1}}){let s=n.reminders;if(!s?.enabled)return;if(e!=="darwin"){t.push({severity:"warn",group:"Reminders",title:"Reminders hand-back unavailable on this machine",detail:"reminders.enabled is set, but Apple Reminders exists only on macOS. The daemon starts without it.",fix:"Set reminders.enabled to false here, or enable it on the Mac node instead."});return}let r=s.command||"remindctl",a=r.includes("/")?i(r)?r:null:x(r,process.env.PATH||"",i);t.push(a?{severity:"ok",group:"Reminders",title:`Watching ${(s.lists||[]).join(", ")} for due reminders`,detail:a}:{severity:"fail",group:"Reminders",title:`${r} not found`,detail:"The daemon reads Apple Reminders through remindctl.",fix:"brew install steipete/tap/remindctl, or set reminders.command to its full path."})}async function Z(t){let n=R(process.versions.node);t.push({severity:n?"ok":"fail",group:"Environment",title:`Node.js ${process.versions.node}`,detail:n?void 0:"AgentX requires Node 22.19 or newer, up to Node 26.",fix:n?void 0:"Install Node 22 (nvm install 22 && nvm use 22)"});let e=l=>{try{return h(process.platform==="win32"?"where":"which",[l],{encoding:"utf-8"}).trim().split(`
|
|
3
3
|
`)[0]}catch{return null}},i=e("npm");t.push({severity:i?"ok":"fail",group:"Environment",title:i?"npm on PATH":"npm not found",detail:i||void 0});let s=e("claude");if(s){let l;try{l=h("claude",["--version"],{encoding:"utf-8",timeout:3e3}).trim()}catch{}t.push({severity:"ok",group:"Environment",title:`claude CLI ${l||"installed"}`,detail:s})}else t.push({severity:"warn",group:"Environment",title:"claude CLI not on PATH",detail:"Only required for agents on the claude-code tier.",fix:"See https://docs.anthropic.com/en/docs/claude-code"});let r=e("codex");if(r){let l;try{l=h("codex",["--version"],{encoding:"utf-8",timeout:3e3}).trim()}catch{}t.push({severity:"ok",group:"Environment",title:`codex CLI ${l||"installed"}`,detail:r})}else t.push({severity:"warn",group:"Environment",title:"codex CLI not on PATH",detail:"Only required for agents on the codex-cli tier.",fix:"Install with `npm i -g @openai/codex`."});let a=e("opencode");if(a){let l;try{l=h("opencode",["--version"],{encoding:"utf-8",timeout:3e3}).trim()}catch{}t.push({severity:"ok",group:"Environment",title:`opencode CLI ${l||"installed"}`,detail:a})}else t.push({severity:"warn",group:"Environment",title:"opencode CLI not on PATH",detail:"Only required for agents on the opencode tier.",fix:"Install from https://opencode.ai/docs/."});try{F(import.meta.url)("better-sqlite3"),t.push({severity:"ok",group:"Environment",title:`better-sqlite3 loads for Node ${process.version}`,detail:`NODE_MODULE_VERSION ${process.versions.modules}`})}catch(l){t.push({severity:"fail",group:"Environment",title:"better-sqlite3 native binding does not load",detail:l?.message??String(l),fix:`Run "pnpm rebuild better-sqlite3" with the same Node used by the daemon (${process.version}, modules ${process.versions.modules}).`})}}function U(t){if(process.platform!=="darwin")return;let n=E(B(),"Library/LaunchAgents"),e=[];try{e=$(n).filter(s=>/agentx\.voice.*\.plist$/.test(s))}catch{return}let i=s=>{try{return T(s,H.X_OK),!0}catch{return!1}};for(let s of e){let r=j(b(E(n,s),"utf-8")),a=x("ffmpeg",r,i);t.push(a?{severity:"ok",group:"Desktop",title:"ffmpeg reachable by the desktop app",detail:`${a} (${s})`}:{severity:"warn",group:"Desktop",title:"ffmpeg not reachable by the desktop app",detail:`Local Whisper transcription fails without it. ${s} sets PATH to ${r}.`,fix:"Install ffmpeg (brew install ffmpeg), then rerun agentx desktop install."})}}function K(t){let n=m(process.cwd(),"agentx.json");if(!y(n))return t.push({severity:"fail",group:"Config",title:"agentx.json not found",detail:`Looked in ${n}`,fix:"Run `agentx setup` to create one via the web wizard."}),null;let e;try{e=JSON.parse(b(n,"utf-8"))}catch(a){return t.push({severity:"fail",group:"Config",title:"agentx.json is not valid JSON",detail:a.message}),null}try{S(n),t.push({severity:"ok",group:"Config",title:`agentx.json valid (${Object.keys(e.agents||{}).length} agents, ${Object.keys(e.crons||{}).length} schedules)`})}catch(a){t.push({severity:"fail",group:"Config",title:"agentx.json failed schema validation",detail:a.message,fix:"Open /admin \u2192 Advanced tab to edit and re-save."})}let i=Object.entries(e.agents||{}).filter(([,a])=>a.tier==="claude-code");i.length>0&&((()=>{try{return h(process.platform==="win32"?"where":"which",["claude"],{stdio:"ignore"}),!0}catch{return!1}})()||t.push({severity:"fail",group:"Config",title:`${i.length} agent(s) use claude-code tier but claude CLI is missing`,detail:i.map(([l])=>l).join(", "),fix:"Install Claude Code (https://docs.anthropic.com/en/docs/claude-code) or switch these agents to tier=sdk."}));let s=Object.entries(e.agents||{}).filter(([,a])=>a.tier==="codex-cli");s.length>0&&((()=>{try{return h(process.platform==="win32"?"where":"which",["codex"],{stdio:"ignore"}),!0}catch{return!1}})()||t.push({severity:"fail",group:"Config",title:`${s.length} agent(s) use codex-cli tier but codex CLI is missing`,detail:s.map(([l])=>l).join(", "),fix:"Install Codex CLI with `npm i -g @openai/codex` or switch these agents to tier=claude-code."}));let r=Object.entries(e.agents||{}).filter(([,a])=>a.tier==="opencode");return r.length>0&&((()=>{try{return h(process.platform==="win32"?"where":"which",["opencode"],{stdio:"ignore"}),!0}catch{return!1}})()||t.push({severity:"fail",group:"Config",title:`${r.length} agent(s) use opencode tier but OpenCode CLI is missing`,detail:r.map(([l])=>l).join(", "),fix:"Install OpenCode from https://opencode.ai/docs/ or switch these agents to another tier."})),e}function Q(t,n){let e=new Set;if(C(n,e),e.size===0){t.push({severity:"ok",group:"Secrets",title:"No ${VAR} references in agentx.json"});return}let i=m(process.cwd(),".env"),s={};if(y(i))for(let l of b(i,"utf-8").split(/\r?\n/)){let u=l.match(/^\s*([A-Z_][A-Z0-9_]*)\s*=\s*(.*)$/i);u&&(s[u[1]]=u[2])}let r=[],a=[];for(let l of e){let u=process.env[l]??s[l];u===void 0?r.push(l):(!u.trim()||/^["']?\s*["']?$/.test(u))&&a.push(l)}r.length===0&&a.length===0?t.push({severity:"ok",group:"Secrets",title:`${e.size} env reference(s) resolved`}):(r.length>0&&t.push({severity:"fail",group:"Secrets",title:`${r.length} env var(s) referenced in agentx.json but missing`,detail:r.join(", "),fix:`Add to .env \u2014 e.g. ${r[0]}=<value>`}),a.length>0&&t.push({severity:"warn",group:"Secrets",title:`${a.length} env var(s) set but empty`,detail:a.join(", ")}))}function C(t,n){if(typeof t=="string")for(let e of t.matchAll(/\$\{([A-Z_][A-Z0-9_]*)\}/g))n.add(e[1]);else if(Array.isArray(t))for(let e of t)C(e,n);else if(t&&typeof t=="object")for(let e of Object.values(t))C(e,n)}function Y(t,n){let e=[];for(let[i,s]of Object.entries(n.agents||{})){if(!s.workspace)continue;let r=s.workspace.startsWith("/")?s.workspace:m(process.cwd(),s.workspace);try{X(r).isDirectory()||e.push(`${i}: ${r} (exists but not a directory)`)}catch{e.push(`${i}: ${r}`)}}e.length===0?t.push({severity:"ok",group:"Workspaces",title:"All agent workspace folders exist"}):t.push({severity:"warn",group:"Workspaces",title:`${e.length} agent workspace(s) missing`,detail:e.join(`
|
|
4
4
|
`),fix:"The daemon will create missing folders on first task, but you won't see CLAUDE.md / skills until you populate them."})}function ee(t,n){let e=/\$\{[A-Za-z_][A-Za-z0-9_]*\}/g,i=[];for(let[s,r]of Object.entries(n.agents||{})){if(!r.workspace)continue;let a=r.workspace.startsWith("/")?r.workspace:m(process.cwd(),r.workspace);for(let l of["settings.json","settings.local.json"]){let u=m(a,".claude",l);if(!y(u))continue;let w;try{w=JSON.parse(b(u,"utf-8"))}catch(d){i.push({severity:"fail",agent:s,msg:`${l}: JSON parse error \u2014 ${d.message}`});continue}let k=w.env||{};for(let[d,p]of Object.entries(k)){if(typeof p!="string")continue;let g=p.match(e);g&&i.push({severity:"fail",agent:s,msg:`${l} env.${d} contains unexpanded ${[...new Set(g)].join(",")} \u2014 Claude Code does NOT expand \${VAR} in settings.json (use a fully-literal value)`})}let o=k.PATH;if(typeof o=="string"){let d=o.split(":").filter(Boolean);d.includes("/usr/bin")||i.push({severity:"fail",agent:s,msg:`${l} env.PATH missing /usr/bin \u2014 cat/head/sh/which will fail`}),d.includes("/bin")||i.push({severity:"fail",agent:s,msg:`${l} env.PATH missing /bin \u2014 ls/cp/mv will fail`})}let c=w.permissions;if(c&&typeof c=="object"&&"allow"in c){let d=c.allow,p=c.deny;Array.isArray(d)&&d.length===0&&Array.isArray(p)&&p.length>0&&i.push({severity:"warn",agent:s,msg:`${l} permissions.allow is explicitly [] with ${p.length} deny rules \u2014 agent may be locked out (omit the key to use defaults instead)`})}}}if(i.length===0){t.push({severity:"ok",group:"Workspace settings",title:`All ${Object.keys(n.agents||{}).length} agent .claude/settings.json files clean`});return}for(let s of i)t.push({severity:s.severity,group:"Workspace settings",title:`${s.agent}: ${s.msg}`,fix:s.severity==="fail"?"Edit .claude/settings.json \u2014 replace ${VAR} with the literal value or omit the key to inherit.":"Either remove the empty allow list or populate it."})}function te(t,n){let e=n.webhooks??[],i=[],s=m(process.cwd(),n.workflows?.dir||".agentx/workflows"),r=new Set;try{if(y(s))for(let o of $(s))o.endsWith(".json")&&!o.startsWith("_")&&!o.endsWith(".disabled.json")&&r.add(o.replace(/\.json$/,""))}catch{}let a=new Set(["github","gitlab"]);for(let o of e){if(!o.enabled||!a.has(o.source))continue;!(o.triggers&&Object.keys(o.triggers).length>0)&&!o.defaultWorkflow&&i.push({severity:"warn",title:`webhook "${o.id}" (${o.source} -> ${o.agentId}) has no triggers map; every event-type collapses to the bound agent`,fix:'Add a triggers map: { "issues.opened": "wf-id", "pull_request.synchronize": "wf-id" } \u2014 or set defaultWorkflow.'})}for(let o of e)if(!(!o.enabled||!o.triggers)){for(let[c,d]of Object.entries(o.triggers))r.size>0&&!r.has(d)&&i.push({severity:"fail",title:`webhook "${o.id}".triggers["${c}"] -> "${d}" \u2014 no such workflow under ${n.workflows?.dir||".agentx/workflows"}`,fix:"Create the workflow file or fix the id in agentx.json"});o.defaultWorkflow&&r.size>0&&!r.has(o.defaultWorkflow)&&i.push({severity:"fail",title:`webhook "${o.id}".defaultWorkflow -> "${o.defaultWorkflow}" \u2014 no such workflow`,fix:"Create the workflow file or fix the id in agentx.json"})}try{if(y(s)){for(let o of $(s))if(!(!o.endsWith(".json")||o.startsWith("_")||o.endsWith(".disabled.json")))try{let c=JSON.parse(b(m(s,o),"utf-8"));c?.status==="active"&&c?.state==="quarantined"&&i.push({severity:"warn",title:`workflow "${c.id??o}" is status=active but state=quarantined \u2014 it looks live but will never dispatch`,fix:'Resolve the conflict the detector flagged, then set state back to "active" (or set status to "review" while parked).'})}catch{}}}catch{}let l=new Set((n.mesh?.peers??[]).map(o=>o.name));for(let o of e)!o.enabled||!o.node||l.has(o.node)||i.push({severity:"fail",title:`webhook "${o.id}" routes to mesh peer "${o.node}" which is not in mesh.peers`,fix:"Add the peer to mesh.peers or remove the node field on the webhook."});let u=new Map;for(let o of e){if(!o.enabled)continue;let c=`${o.source}:${o.agentId}`,d=u.get(c);d?i.push({severity:"warn",title:`webhook entries "${d}" and "${o.id}" both enabled for ${o.source} -> ${o.agentId}; only the first is dispatched`,fix:"Disable one entry, or merge their triggers maps into a single entry."}):u.set(c,o.id)}let w=new Set(Object.keys(n.agents??{}));for(let o of n.channels?.gitlab?.agentMappings??[])if(o?.agentId){if(o.node){l.has(o.node)||i.push({severity:"fail",title:`gitlab.agentMappings entry agentId="${o.agentId}" routes to mesh peer "${o.node}" which is not in mesh.peers`,fix:"Add the peer to mesh.peers or drop the node field on the mapping."});continue}w.has(o.agentId)||i.push({severity:"warn",title:`gitlab.agentMappings entry agentId="${o.agentId}" \u2014 no such agent in agents.* (and no node field, so it's not a cross-mesh route)`,fix:'Add the agent to agents.*, set node:"<peer>" if the agent lives remotely, or remove the mapping.'})}for(let[o,c]of Object.entries(n.channels?.telegram?.accounts??{}))c.agentBinding?w.has(c.agentBinding)||i.push({severity:"fail",title:`telegram account "${o}".agentBinding -> "${c.agentBinding}" \u2014 no such agent in agents.*`,fix:"Fix the agentBinding or define the agent in agents.*."}):i.push({severity:"fail",title:`telegram account "${o}" has no agentBinding; every DM to this bot will drop`,fix:"Set agentBinding to a valid agent id."});let k=new Set(["telegram-bot","whatsapp","slack-bot","discord-bot","gitlab-user","github-user","gmail","hotmail","smtp","hubspot","salesforce","pipedrive","odoo","trello","linear","asana","jira","notion","stripe","sentry","vercel","twilio","custom"]);for(let[o,c]of Object.entries(n.agents??{})){let d=c.integrations??[];if(!d.length)continue;let p=new Set;for(let g of d){let A=`${g.kind}::${g.label}`;p.has(A)&&i.push({severity:"warn",title:`agents.${o}.integrations: duplicate (${g.kind}, ${g.label})`,fix:"Remove the duplicate or rename one. (kind, label) must be unique per agent."}),p.add(A),k.has(g.kind)||i.push({severity:"warn",title:`agents.${o}.integrations: unknown kind "${g.kind}" on integration "${g.label}"`,fix:'Use a canonical kind from INTEGRATION_KINDS, or "custom" for ad-hoc services.'});let D=g.credentials||{};for(let[_,v]of Object.entries(D))typeof v=="string"&&/^[A-Z][A-Z0-9_]*$/.test(v)&&!process.env[v]&&i.push({severity:"warn",title:`agents.${o}.integrations[${g.kind}/${g.label}].${_} -> $${v} but env var is unset (in this shell)`,fix:`Set ${v} on the daemon environment. The daemon's process.env is what matters; this warning fires from your local shell.`})}}if(i.length===0){t.push({severity:"ok",group:"Routing",title:`${e.length} webhook(s), ${Object.keys(n.channels?.telegram?.accounts??{}).length} telegram account(s) \u2014 all routing references resolve`});return}for(let o of i)t.push({severity:o.severity,group:"Routing",title:o.title,fix:o.fix})}function ne(t){return typeof t?.canMeasure!="boolean"?null:t.canMeasure?{severity:"ok",group:"Runtime",title:"Daemon finds ffmpeg to measure phone recordings"}:{severity:"warn",group:"Runtime",title:t.allowUnmeasured?"Daemon can't find ffmpeg: phone recordings go unmeasured (voice.allowUnmeasured)":"Daemon can't find ffmpeg: phone voice input is refused",fix:"Install ffmpeg (brew install ffmpeg / sudo apt install ffmpeg), or set AGENTX_FFMPEG in the service's environment. The daemon's PATH is shorter than your shell's."}}async function ie(t,n){let e=n.dashboard?.daemonUrl?.replace(/\/+$/,"")||"http://127.0.0.1:18800",i={};n.dashboard?.token&&(i.Authorization=`Bearer ${n.dashboard.token}`);try{let s=new AbortController,r=setTimeout(()=>s.abort(),2e3),a=await fetch(e+"/health",{headers:i,signal:s.signal});if(clearTimeout(r),!a.ok){t.push({severity:"warn",group:"Runtime",title:`Daemon responded ${a.status}`,detail:e});return}let l=await a.json();t.push({severity:"ok",group:"Runtime",title:`Daemon healthy \u2014 ${l.agents?.length??0} agents live, uptime ${Math.round((l.uptime??0)/60)}m`,detail:e});let u=ne(l.voice);u&&t.push(u)}catch{t.push({severity:"warn",group:"Runtime",title:"Daemon not reachable (not running?)",detail:e,fix:"Run `agentx daemon start`. Skip this check with `agentx doctor --no-running`."})}}function oe(t,n){let e=Object.entries(n.agents||{}).filter(([,s])=>s?.codegraph===!0&&(s.tier==="claude-code"||s.tier==="codex-cli"));if(e.length===0)return;let i=null;try{i=h(process.platform==="win32"?"where":"which",["codegraph"],{encoding:"utf-8"}).trim().split(`
|
|
5
5
|
`)[0]||null}catch{i=null}if(i){let s;try{s=h("codegraph",["--version"],{encoding:"utf-8",timeout:3e3}).trim()}catch{}t.push({severity:"ok",group:"CodeGraph",title:`codegraph CLI ${s||"installed"}`,detail:i})}else t.push({severity:"fail",group:"CodeGraph",title:"codegraph CLI not on PATH",detail:`${e.length} agent(s) have codegraph:true but the binary isn't available.`,fix:"Install with `npm i -g @colbymchenry/codegraph`."});for(let[s,r]of e){if(!r.workspace||!y(r.workspace)){t.push({severity:"warn",group:"CodeGraph",title:`${s}: workspace missing`,detail:`Workspace path ${r.workspace} does not exist \u2014 codegraph will skip this agent.`});continue}let a=m(r.workspace,".codegraph","codegraph.db");y(a)?t.push({severity:"ok",group:"CodeGraph",title:`${s}: index present`,detail:a}):t.push({severity:"warn",group:"CodeGraph",title:`${s}: index not built yet`,detail:".codegraph/ missing \u2014 daemon will background-index this workspace on next boot.",fix:`Run \`codegraph init --index ${r.workspace}\` to build it now.`})}}function W(t){return{errors:t.filter(n=>n.severity==="fail").length,warnings:t.filter(n=>n.severity==="warn").length,ok:t.filter(n=>n.severity==="ok").length}}function se(t){console.log(),console.log(f.bold(" agentx doctor")),console.log();let n=new Map;for(let i of t)n.has(i.group)||n.set(i.group,[]),n.get(i.group).push(i);for(let[i,s]of n){console.log(f.bold(" "+i));for(let r of s){let a=r.severity==="ok"?f.green("\u2713"):r.severity==="warn"?f.yellow("!"):f.red("\u2717");console.log(` ${a} ${r.title}`),r.detail&&console.log(f.dim(" "+r.detail.replace(/\n/g,`
|
|
6
6
|
`))),r.fix&&console.log(f.dim(" \u2192 "+r.fix))}console.log()}let e=W(t);e.errors>0?console.log(f.red.bold(` ${e.errors} error${e.errors===1?"":"s"}`)+(e.warnings?f.yellow(`, ${e.warnings} warning${e.warnings===1?"":"s"}`):"")+`. Fix the error${e.errors===1?"":"s"} and rerun.`):e.warnings>0?console.log(f.yellow.bold(` ${e.warnings} warning${e.warnings===1?"":"s"}.`)+f.dim(" Review but not blocking.")):console.log(f.green.bold(` All checks passed (${e.ok}).`)),console.log()}export{P as a,J as b,ke as c,G as d,V as e,ne as f};
|
|
7
|
-
//# sourceMappingURL=chunk-
|
|
7
|
+
//# sourceMappingURL=chunk-J723FL3J.js.map
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import{Ja as m,Ka as $,Ta as x}from"./chunk-
|
|
1
|
+
import{Ja as m,Ka as $,Ta as x}from"./chunk-IBK7AG4S.js";x();import{readFileSync as S,writeFileSync as P,existsSync as b}from"fs";import{resolve as f}from"path";function w(r){if(r)return f(r);let e=[f(process.cwd(),"agentx.json"),f(process.cwd(),".agentx/config.json")];for(let n of e)if(b(n))return n;return e[0]}function v(r){return JSON.parse(JSON.stringify(r))}async function O(r){try{let e=await fetch(`${r.replace(/\/$/,"")}/reload`,{method:"POST",signal:AbortSignal.timeout(3e3)});return e.ok?{ok:!0}:{ok:!1,reason:`HTTP ${e.status}`}}catch(e){return{ok:!1,reason:e?.cause?.code||e?.message||"unreachable"}}}async function J(r,e={}){let{validate:n=!0,dryRun:t=!1,reload:s=!0,configPath:u,daemonUrl:c}=e,o=w(u);if(!b(o))return{success:!1,path:o,error:`Config not found at ${o}. Run \`agentx init\` first.`};let d;try{d=S(o,"utf-8")}catch(a){return{success:!1,path:o,error:`Cannot read ${o}: ${a.message}`}}let g;try{g=JSON.parse(d)}catch(a){return{success:!1,path:o,error:`Invalid JSON in ${o}: ${a.message}`}}let i=v(g);try{await r(i)}catch(a){return{success:!1,path:o,error:`Mutator threw: ${a.message}`}}if(n){let a=$(i),l=m.safeParse(a);if(!l.success){let k=l.error.issues.map(y=>` ${y.path.join(".")||"<root>"}: ${y.message}`).join(`
|
|
2
2
|
`);return{success:!1,path:o,error:`Validation failed:
|
|
3
3
|
${k}`,after:i}}}if(t)return{success:!0,path:o,after:i,dryRun:!0};try{P(o,JSON.stringify(i,null,2)+`
|
|
4
4
|
`)}catch(a){return{success:!1,path:o,error:`Write failed: ${a.message}`,after:i}}let p=!1,h;if(s){let a=c||R(i),l=await O(a);l.ok?p=!0:h=l.reason}return{success:!0,path:o,after:i,reloaded:p,reloadSkipped:h}}function R(r){let e=r?.node?.bind;if(!e)return"http://127.0.0.1:18800";let[n,t]=e.split(":");return`http://${n==="0.0.0.0"||n==="::"?"127.0.0.1":n}:${t}`}function N(r,e,n){let t=e.split("."),s=r;for(let u=0;u<t.length-1;u++){let c=t[u];(s[c]===void 0||s[c]===null)&&(s[c]={}),s=s[c]}s[t[t.length-1]]=n}function j(r,e){let n=e.split("."),t=r;for(let s of n){if(t==null)return;t=t[s]}return t}function A(r,e){let n=e.split("."),t=r;for(let s=0;s<n.length-1;s++){if(t==null)return;t=t[n[s]]}t!=null&&delete t[n[n.length-1]]}export{w as a,J as b,N as c,j as d,A as e};
|
|
5
|
-
//# sourceMappingURL=chunk-
|
|
5
|
+
//# sourceMappingURL=chunk-K3QDK4BX.js.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{a as Ie}from"./chunk-GTJIKXDB.js";import{q as sn}from"./chunk-S2GAEH2F.js";import{a as w}from"./chunk-7LN4VKDU.js";import{a as re}from"./chunk-IMLAPB7G.js";import{e as an,g as ln,i as cn,j as _e,l as q,m as W,o as un}from"./chunk-TJZGAKIB.js";import{t as nn,u as rn}from"./chunk-
|
|
1
|
+
import{a as Ie}from"./chunk-GTJIKXDB.js";import{q as sn}from"./chunk-S2GAEH2F.js";import{a as w}from"./chunk-7LN4VKDU.js";import{a as re}from"./chunk-IMLAPB7G.js";import{e as an,g as ln,i as cn,j as _e,l as q,m as W,o as un}from"./chunk-TJZGAKIB.js";import{t as nn,u as rn}from"./chunk-UYLVSS6I.js";import{d as en,e as tn}from"./chunk-AQASR6KR.js";import{b as on}from"./chunk-YMX3QCV7.js";import{a as Yt,b as Zt,d as Qt}from"./chunk-VY7TBMJU.js";import{a as Bt,b as Ht}from"./chunk-WBG6NA7R.js";import{g as zt,h as Xt,i as Gt,k as Kt,l as Jt}from"./chunk-USTNT7P7.js";import{X as qt,Z as ne,_ as Ae,aa as Re,b as $e}from"./chunk-O7ZJS33Z.js";import{q as Vt}from"./chunk-MOCKFVYE.js";import{a as Ft,b as Ut}from"./chunk-K3QDK4BX.js";import{Ca as ve,I as Tt,J as Ct,K as Dt,Ka as Mt,L as Pt,La as Wt,P as te,Q as Lt,R as Nt,S as Ot,T as xe,Ta as jt,n as ee,o as It,p as Et,q as ci}from"./chunk-IBK7AG4S.js";import{a as ke,h as ui}from"./chunk-BRK6M6LA.js";import{f as Se,n as di}from"./chunk-UIBUZ2N3.js";import{existsSync as pi,readdirSync as gi,readFileSync as fi,statSync as mi}from"fs";import{resolve as hi}from"path";function dn(t,e,n=Date.now(),i=7){let r=i*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)??[],l=a.filter(f=>n-f.at<=r),c=a.filter(f=>n-f.at>r&&n-f.at<=r*2),u=l.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?c.length>0&&l.length===0?"dormant":l.length>0&&u*2>=l.length?"failing":l.length>0?"active":"quiet":"never";return{id:o.id,name:o.name||o.id,state:g,lastRunAt:p,recent:l.length,prior:c.length,failed:u,paused:d}}).sort((o,a)=>{let l={dormant:0,failing:1,active:2,quiet:3,never:4};return l[o.state]-l[a.state]||(a.lastRunAt??0)-(o.lastRunAt??0)})}var ie=new Map;function el(t,e=1e3){if(!pi(t))return[];let n=gi(t).filter(s=>s.endsWith(".jsonl")).map(s=>{let o=hi(t,s);return{path:o,mtime:mi(o).mtimeMs}}).sort((s,o)=>o.mtime-s.mtime).slice(0,e),i=new Set(n.map(s=>s.path));for(let s of ie.keys())i.has(s)||ie.delete(s);let r=[];for(let{path:s,mtime:o}of n){let a=ie.get(s);if(a&&a.mtime===o){a.summary&&r.push(a.summary);continue}let l=yi(s,o);ie.set(s,{mtime:o,summary:l}),l&&r.push(l)}return r}function yi(t,e){try{let n=fi(t,"utf-8").split(`
|
|
2
2
|
`).filter(Boolean);if(!n.length)return null;let i=JSON.parse(n[0]),r=i.run?.workflowId;if(!r)return null;let s=i.run?.status??"unknown";for(let o=n.length-1;o>=0;o--){let a=JSON.parse(n[o]),l=a.status??a.run?.status;if(l){s=l;break}}return{workflowId:r,status:s,at:e}}catch{return null}}var bi={failStreak:3,disabledDays:30,missedFires:2,graceMs:15*6e4},k={routines:200,summary:160,filters:6,filterValue:60,text:120},wi=(t,e,n)=>{try{return Vt(t,e,n)}catch{return null}},pn=864e5;function il(t){let e=t.now??Date.now(),n={...bi,...t.thresholds},i=t.nextFire??wi,r=[];for(let a of t.crons){let l=t.cronRuns.get(a.id)??[],c=a.timezone||"UTC",u=l.map(g=>({at:Date.parse(g.startedAt),status:g.status})),d=l[0],p={id:`cron:${a.id}`,source:"cron",kind:"schedule",name:A(a.id,k.text),trigger:{schedule:A(a.schedule,k.text),timezone:c},agent:a.agent||null,enabled:a.enabled,state:a.enabled?"enabled":"disabled",nextRunAt:a.enabled?Ee(a.nextRun)??Ee(i(a.schedule,new Date(e),c)):null,lastRun:d?{at:d.startedAt,status:d.status,summary:Ai(d.status==="success"?void 0:d.errorSummary,k.summary)}:null,lastSuccessAt:l.find(g=>g.status==="success")?.startedAt??null,consecutiveFailures:gn(u),sampledRuns:l.length,flags:[],attention:null};p.flags=fn(p,u,a.schedule,c,null,e,n,i),r.push(mn(p))}let s=new Map(dn(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 l=o.get(a.workflowId);l?l.push(a):o.set(a.workflowId,[a])}for(let a of t.workflows){let l=a.nodes.find(I=>I.type.startsWith("trigger."));if(!l||l.type!=="trigger.cron"&&l.type!=="trigger.hook")continue;let c=l.config??{},u=a.state||"active",d=u==="active",p=(o.get(a.id)??[]).slice().sort((I,we)=>we.at-I.at),g=p.map(I=>({at:I.at,status:xi(I.status)})),f=g[0],h=l.type==="trigger.cron",y=typeof c.spec=="string"?c.spec:"",C=typeof c.timezone=="string"?c.timezone:"UTC",M={id:`workflow:${a.id}`,source:"workflow",kind:h?"schedule":"event",name:A(a.title||a.id,k.text),trigger:h?{schedule:A(y,k.text),timezone:C}:{event:A(typeof c.event=="string"?c.event:"",k.text),filters:$i(c.filter,a)},agent:vi(a),enabled:d,state:u,nextRunAt:h&&d&&y?Ee(i(y,new Date(e),C)):null,lastRun:f?{at:new Date(f.at).toISOString(),status:f.status}:null,lastSuccessAt:(()=>{let I=g.find(we=>we.status==="success");return I?new Date(I.at).toISOString():null})(),consecutiveFailures:gn(g),sampledRuns:p.length,flags:[],attention:null},Q=Date.parse(a.updated||a.created||"");M.flags=h?fn(M,g,y,C,Number.isFinite(Q)?Q:null,e,n,i):ki(M,s.get(a.id)?.state==="dormant",Number.isFinite(Q)?Q:null,e,n),r.push(mn(M))}return r.sort(Si).slice(0,k.routines)}function gn(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 fn(t,e,n,i,r,s,o,a){let l=[],c=e.length?e[0].at:null;if(!t.enabled){let p=yn(c,r,s,o);return p&&l.push(p),l}if(t.consecutiveFailures>=o.failStreak&&l.push({reason:"failing",detail:`${t.consecutiveFailures} failed attempts in a row`}),c===null)return l.push({reason:"never-ran",detail:"No persisted attempt"}),l;let u=new Date(c),d=null;for(let p=0;p<o.missedFires&&(d=a(n,u,i),!!d);p++)u=d;return d&&s>d.getTime()+o.graceMs&&l.push({reason:"overdue",detail:`No attempt since ${new Date(c).toISOString()}; ${o.missedFires} scheduled fires missed`}),l}function ki(t,e,n,i,r){let s=[],o=t.lastRun?Date.parse(t.lastRun.at):null;if(!t.enabled){let a=yn(o,n,i,r);return a&&s.push(a),s}return t.consecutiveFailures>=r.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 yn(t,e,n,i){let r=Math.max(t??0,e??0);return r&&n-r<i.disabledDays*pn?null:{reason:"disabled-long",detail:r?`Disabled; no activity for ${Math.floor((n-r)/pn)} days`:"Disabled and never ran"}}function mn(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 hn={critical:0,warning:1,info:2};function Si(t,e){let n=t.attention?hn[t.attention]:3,i=e.attention?hn[e.attention]:3;return n-i||Number(e.enabled)-Number(t.enabled)||t.name.localeCompare(e.name)}function xi(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 vi(t){if(t.ownerAgent)return A(t.ownerAgent,k.text);let e=t.nodes.find(n=>n.type==="agent"&&typeof n.config?.agentId=="string"&&n.config.agentId);return e?A(String(e.config.agentId),k.text):null}function $i(t,e){let n=[],i=e?.project;if(i&&n.push(A(`project=${i}`,k.filterValue)),t&&typeof t=="object"&&!Array.isArray(t))for(let[r,s]of Object.entries(t)){let o=Array.isArray(s)?s.map(String):s==null?[]:[String(s)];o.length&&n.push(A(`${r}=${o.join(",")}`,k.filterValue))}return n.slice(0,k.filters)}function Ee(t){if(!t)return null;let e=t instanceof Date?t:new Date(t);return Number.isFinite(e.getTime())?e.toISOString():null}function A(t,e){return t.length<=e?t:t.slice(0,e-3)+"..."}function Ai(t,e){return t===void 0?void 0:A(t,e)}import{mkdirSync as Ri,readFileSync as _i,renameSync as Ii,writeFileSync as Ei}from"fs";import{resolve as Ti}from"path";function bn(t){return Ti(_e(t),"_state.json")}function x(t){try{let e=JSON.parse(_i(bn(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 B(t,e){Ri(_e(t),{recursive:!0});let n=bn(t),i=`${n}.${process.pid}.tmp`;Ei(i,JSON.stringify(e,null,2)+`
|
|
3
3
|
`),Ii(i,n)}function wn(t,e,n,i=Date.now()){let r=x(t),s={};for(let[o,a]of Object.entries(r.snoozed))Date.parse(a)>i&&(s[o]=a);s[e]=n.toISOString(),B(t,{...r,snoozed:s})}function cl(t,e){B(t,{...x(t),lastDigest:e})}function Te(t,e,n,i=Date.now()){let r=x(t),s=new Set(n),o={};for(let[l,c]of Object.entries(r.popped??{}))s.has(l)&&(o[l]=c);o[e]=new Date(i).toISOString();let a=(r.wanted??[]).filter(l=>l!==e&&s.has(l));B(t,{...r,popped:o,wanted:a})}function kn(t,e){let n=x(t);B(t,{...n,wanted:[...(n.wanted??[]).filter(i=>i!==e),e]})}function ul(t,e=Date.now()){B(t,{...x(t),popped:{},passAt:new Date(e).toISOString()})}import{existsSync as H,readdirSync as zi,readFileSync as Xi}from"fs";import{resolve as R}from"path";import{randomBytes as vn}from"crypto";import{existsSync as Di,mkdirSync as Pi,readdirSync as Li,readFileSync as Ni,renameSync as $n,unlinkSync as Oi,writeFileSync as Mi}from"fs";import{resolve as An}from"path";function Sn(t){return[...t.account?["--account",t.account]:[],...t.store?["--store",t.store]:[]]}var Ci=t=>t.trim().split(`
|
|
4
4
|
`).pop()?.slice(0,300)||"no output";async function xn(t,e,n,i=Ie){let r=await i(t.bin,[...Sn(t),"send","text","--to",e,"--message",n,"--no-preview"],{timeoutMs:6e4});return r.code===0?{ok:!0}:{ok:!1,error:`wacli send failed: ${Ci(r.stderr||r.stdout)}`}}async function gl(t,e,n,i,r=Ie){return(await r(t.bin,[...Sn(t),"--read-only","media","download","--chat",e,"--id",n,"--output",i],{timeoutMs:12e4})).code===0}var Wi=2e3,ji=t=>xn(t.wacli,t.to,t.text);function Ce(t){return An(t,".agentx","whatsapp-triage","drafts")}var Fi=t=>/^[a-z0-9-]{8,64}$/.test(t),se=(t,e)=>An(Ce(t),`${e}.json`);function Rn(t,e){Pi(Ce(t),{recursive:!0});let n=se(t,e.id),i=`${n}.${process.pid}.tmp`;Mi(i,JSON.stringify(e,null,2)+`
|
|
@@ -52,7 +52,7 @@ import{a as Ie}from"./chunk-GTJIKXDB.js";import{q as sn}from"./chunk-S2GAEH2F.js
|
|
|
52
52
|
CREATE INDEX IF NOT EXISTS idx_request_plan_events ON request_plan_events(request_id, at);
|
|
53
53
|
`)}function Tn(t){return!!t.prepare("SELECT 1 FROM sqlite_master WHERE type = 'table' AND name = 'request_plans'").get()}function De(t){return{requestId:t.request_id,createdBy:t.created_by,createdAt:t.created_at,state:t.state,finishedAt:t.finished_at??null,notifiedAt:t.notified_at??null}}function En(t){return{requestId:t.request_id,idx:t.idx,name:t.name,kind:t.kind,agentId:t.agent_id,doneWhen:t.done_when,state:t.state,needsApproval:!!t.needs_approval,approval:t.approval,cardId:t.card_id??null,message:t.message??null,toChannel:t.to_channel??null,toChat:t.to_chat??null,toAccount:t.to_account??null,checkUrl:t.check_url??null,checkContains:t.check_contains??null,stallMinutes:t.stall_minutes??null,evidence:t.evidence??null,note:t.note??null,dispatchedAt:t.dispatched_at??null,updatedAt:t.updated_at,nudges:t.nudges,lastNudgeAt:t.last_nudge_at??null,notifiedAt:t.notified_at??null}}var qi={state:"state",approval:"approval",cardId:"card_id",message:"message",evidence:"evidence",note:"note",dispatchedAt:"dispatched_at",updatedAt:"updated_at",nudges:"nudges",lastNudgeAt:"last_nudge_at",notifiedAt:"notified_at"},ae=class{constructor(e){this.db=e;Vi(e)}create(e,n,i,r){let s=this.db.prepare("INSERT INTO request_plans (request_id, created_by, created_at, state) VALUES (?, ?, ?, 'active')"),o=this.db.prepare(`INSERT INTO request_plan_steps (request_id, idx, name, kind, agent_id, done_when, state, needs_approval, message,
|
|
54
54
|
to_channel, to_chat, to_account, check_url, check_contains, stall_minutes, dispatched_at, updated_at)
|
|
55
|
-
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`);this.db.transaction(()=>{s.run(e,n,r),i.forEach((a,l)=>{let c=l===0,u=c&&a.agentId===n&&a.kind!=="message";o.run(e,l+1,a.name,a.kind,a.agentId,a.doneWhen,c?"active":"pending",a.needsApproval?1:0,a.message??null,a.toChannel??null,a.toChat??null,a.toAccount??null,a.checkUrl??null,a.checkContains??null,a.stallMinutes??null,u?r:null,r)}),this.event(e,null,"created",`${i.length} steps, written by ${n}`,r)})()}get(e){let n=this.db.prepare("SELECT * FROM request_plans WHERE request_id = ?").get(e);return n?De(n):null}steps(e){return this.db.prepare("SELECT * FROM request_plan_steps WHERE request_id = ? ORDER BY idx").all(e).map(En)}step(e,n){let i=this.db.prepare("SELECT * FROM request_plan_steps WHERE request_id = ? AND idx = ?").get(e,n);return i?En(i):null}listActive(){return this.db.prepare("SELECT * FROM request_plans WHERE state = 'active' ORDER BY created_at, rowid").all().map(De)}updateStep(e,n,i){let r=[],s=[];for(let[o,a]of Object.entries(i)){let l=qi[o];!l||a===void 0||(r.push(`${l} = ?`),s.push(typeof a=="boolean"?a?1:0:a))}r.length&&this.db.prepare(`UPDATE request_plan_steps SET ${r.join(", ")} WHERE request_id = ? AND idx = ?`).run(...s,e,n)}finish(e,n,i){return this.db.prepare("UPDATE request_plans SET state = ?, finished_at = ? WHERE request_id = ? AND state = 'active'").run(n,i,e).changes>0}markNotified(e,n){this.db.prepare("UPDATE request_plans SET notified_at = ? WHERE request_id = ?").run(n,e)}awaitingSummary(){return this.db.prepare("SELECT * FROM request_plans WHERE state = 'done' AND notified_at IS NULL ORDER BY finished_at").all().map(De)}event(e,n,i,r,s){this.db.prepare("INSERT INTO request_plan_events (request_id, step, at, kind, detail) VALUES (?, ?, ?, ?, ?)").run(e,n,s,i,r.replace(/\s+/g," ").trim().slice(0,Ui))}events(e,n=200){return this.db.prepare("SELECT request_id, step, at, kind, detail FROM request_plan_events WHERE request_id = ? ORDER BY at, rowid LIMIT ?").all(e,n).map(i=>({requestId:i.request_id,step:i.step??null,at:i.at,kind:i.kind,detail:i.detail}))}},vl=Lt;import{existsSync as Bi,readFileSync as Hi}from"fs";jt();ui();function Cn(t){let e=Ft(t),n={};if(Bi(e))try{n=Mt(JSON.parse(Hi(e,"utf-8")))}catch{n={}}let i=ve.safeParse(n?.requests);return i.success?i.data:ve.parse(void 0)}async function El(t,e={}){let n=(t.channels??[]).filter(i=>!ke.has(i.toLowerCase().split("@")[0]));return n.length?{success:!1,error:`unknown channel ${n.map(i=>`"${i}"`).join(", ")}: use ${[...ke].join(", ")}`}:Ut(i=>{let r=i.requests??={};for(let s of["enabled","channels","from","staleAfterHours","retentionDays"])t[s]!==void 0&&(r[s]=t[s]);if(t.plans){let s=r.plans??={};for(let o of["enabled","stallMinutes","maxNudges","approveKinds","disabledAgents"])t.plans[o]!==void 0&&(s[o]=t.plans[o])}if(t.checkers){let s=r.checkers??={};for(let o of["enabled","checkEveryMinutes"])t.checkers[o]!==void 0&&(s[o]=t.checkers[o])}},{configPath:e.configPath,reload:e.reload})}var Ln=["card","schedule","memory","wiki","whatsapp","request"],Gi=280;function L(t,e=Gi){let n=t.replace(/\s+/g," ").trim();return n.length>e?`${n.slice(0,e-1)}\u2026`:n}function Pe(t){if(t.configPath)return R(t.configPath);let e=[R(t.root,"agentx.json"),R(t.root,".agentx","config.json")];return e.find(n=>H(n))??e[0]}function Le(t){return t.wikiDir?R(t.wikiDir):R(t.root,".agentx","wiki")}function Ki(t){return W(t.root,"pending").map(Ji)}function Ji(t){return{key:`card:${t.id}`,kind:"card",title:t.title,ask:t.ask,yes:`tell ${t.raised_by} yes`,no:`tell ${t.raised_by} no`,recommend:t.recommend,if_silent:t.if_silent,expires:t.expires,...t.source?{source:t.source}:{},raised_by:t.raised_by,...t.node?{node:t.node}:{},created_at:t.created_at,...t.choices?{choices:t.choices,more:`agentx approvals popup card:${t.id}`}:{},...t.draft?{draft:t.draft}:{},...t.context||t.draft?{detail:L([t.context,t.draft?`Suggested message: ${t.draft}`:""].filter(Boolean).join(" \xB7 "))}:{}}}function Yi(t){let e=Pe(t);if(!H(e))return[];let n;try{n=JSON.parse(Xi(e,"utf-8"))}catch{return[]}let i=new Date(t.now??Date.now()),r=[];for(let[s,o]of Object.entries(n?.crons??{})){let a=o?.approval;if(!a||a.action!=="create"&&a.action!=="delete")continue;let l=o.timezone||"UTC",c=o.schedule?zt(o.schedule):"",u=o.schedule?`${c.charAt(0).toLowerCase()}${c.slice(1)} (${o.schedule})`:"no schedule",d=String(o.prompt??o.command??""),p=a.action==="create";r.push({key:`schedule:${s}`,kind:"schedule",title:p?`New schedule "${s}" for ${o.agent??"an agent"}`:`Delete schedule "${s}"`,ask:p?`Let ${o.agent??"the agent"} run this ${u}?`:`Remove the schedule "${s}" (${u})?`,yes:p?"enable it":"remove it",no:p?"drop the request":"keep the schedule",raised_by:String(a.requestedBy??"unknown"),created_at:String(a.requestedAt??""),detail:L(`${d}${p&&o.schedule?` \xB7 first run ${Gt(Xt(o.schedule,l,i),l)}`:""}`),more:"agentx schedule list"})}return r}function Nn(t){let e=R(t,".agentx","memory");return H(e)?zi(e).filter(n=>n.endsWith(".jsonl")).map(n=>n.slice(0,-6)).sort():[]}function Zi(t){let e=Nn(t.root);if(e.length===0)return[];let n=new $e(t.root),i=[];for(let r of e)for(let s of n.held(r))i.push({key:`memory:${r}/${s.id}`,kind:"memory",title:`Fact ${r} learned from ${s.source.channel}`,ask:`Let ${r} use this fact in its prompts?`,yes:"use it",no:"keep it out for good",raised_by:r,created_at:s.createdAt,detail:L(s.content),more:`agentx memory facts held --agent ${r}`});return i}function Qi(t){let e=t.sources.filter(n=>n.failure);return e.length?e.map(n=>`Recurring failure: ${n.agentId}'s ${n.failure.tool} fails with "${n.failure.errorClass}" in ${n.occurrences??1} sessions (${n.failure.runs} runs).`).join(" "):`${t.sources.length} source(s)${t.occurrences>1?`, seen in ${t.occurrences} sessions`:""}.`}function es(t){return tn(Le(t),"pending").map(e=>{let n=e.evidence;return{key:`wiki:${e.id}`,kind:"wiki",title:e.article.title,ask:e.replaces?`Update "${e.article.path}" in the shared wiki?`:`Add "${e.article.path}" to the shared wiki?`,yes:"write the article",no:"decline it",raised_by:n.agents.join(", ")||"wiki promote",created_at:e.createdAt,detail:L(`${Qi(n)} ${e.article.content}`),more:`agentx wiki proposals show ${e.id}`}})}function ts(t){return _n(t.root,"pending").map(e=>({key:`whatsapp:${e.id}`,kind:"whatsapp",title:`WhatsApp reply to ${e.chat_name||e.to}`,ask:`Send this to ${e.chat_name||e.to}? "${e.text}"`,yes:"send it on WhatsApp",no:"drop the draft",raised_by:e.agent,created_at:e.created_at,detail:L(`${e.triage}: ${e.summary}`),more:"agentx whatsapp triage log"}))}function z(t){if(t.requests)return t.requests;if(R(t.root)!==process.cwd()||!H(R(t.root,".agentx","db.sqlite")))return null;let e=Se({quiet:!0});if(!e)return null;let n=Dn.get(e);return!n&&!Nt(e)?null:(n||Dn.set(e,n=new Ot(e)),n)}var Dn=new WeakMap;function Bl(t){if(t.plans)return t.plans;if(t.requests||R(t.root)!==process.cwd()||!H(R(t.root,".agentx","db.sqlite")))return null;let e=Se({quiet:!0});if(!e||!Tn(e))return null;let n=Pn.get(e);return n||Pn.set(e,n=new ae(e)),n}var Pn=new WeakMap;function ns(t){let e=z(t);return e?e.listByState("needs_attention").map(n=>({key:`request:${n.id}`,kind:"request",title:`Request not finished: ${L(n.text,80)}`,ask:`Ask ${n.agentId} to pick it up again?`,yes:`hand it back to ${n.agentId}`,no:"drop the request",raised_by:n.agentId,created_at:new Date(n.createdAt).toISOString(),detail:L(`${n.attentionReason??"It needs attention"}. Asked on ${n.channel}: ${n.text}`),more:`agentx requests show ${n.id}`})):[]}var On={card:Ki,schedule:Yi,memory:Zi,wiki:es,whatsapp:ts,request:ns};function rs(t,e){let n=t.expires?Date.parse(t.expires):1/0,i=e.expires?Date.parse(e.expires):1/0;return n!==i?n-i:(Date.parse(t.created_at)||0)-(Date.parse(e.created_at)||0)}function Hl(t,e={}){let n=t.now??Date.now(),{snoozed:i}=x(t.root),r=[],s=[],o=0;for(let a of e.kinds??Ln){let l;try{l=On[a](t)}catch(c){s.push({kind:a,error:String(c?.message??c).slice(0,200)});continue}for(let c of l){let u=i[c.key];if(u&&Date.parse(u)>n){if(!e.includeSnoozed){o++;continue}c.snoozed_until=u}r.push(c)}}return r.sort(rs),{items:r,snoozed:o,errors:s}}function is(t){let e=t.indexOf(":");if(e<=0)return null;let n=t.slice(0,e),i=t.slice(e+1);return!Ln.includes(n)||!i?null:{kind:n,ref:i}}function ss(t,e,n){switch(e){case"card":return q(t.root,n)?.status==="pending";case"wiki":return en(Le(t),n)?.status==="pending";case"whatsapp":return oe(t.root,n)?.status==="pending";default:return On[e](t).some(i=>i.key===`${e}:${n}`)}}async function Mn(t,e,n,i={}){let r=is(e);if(!r)return{ok:!1,error:`unknown item "${e}": use a key from \`agentx approvals list\``};let{kind:s,ref:o}=r,a=t.now??Date.now(),l=i.by??"operator";if(n==="later"){if(!ss(t,s,o))return{ok:!1,error:`nothing waiting for "${e}"`};let u=i.laterHours&&i.laterHours>0?i.laterHours:24,d=new Date(a+u*36e5);return wn(t.root,e,d,a),{ok:!0,message:`${e} put off until ${d.toISOString()}`}}let c=n==="yes";switch(s){case"card":{let u=un(t.root,o,c?"yes":"no",{by:l,note:i.note,now:a,choice:i.choice,text:i.text});return u.ok?{ok:!0,message:`${e}: ${u.card.raised_by} will be told ${c?"yes":"no"}${u.card.choice?` (${u.card.choice})`:""}`}:u}case"schedule":{let u=await(c?Kt:Jt)(o,{configPath:Pe(t),reload:t.reload});return u.success?{ok:!0,message:u.message}:{ok:!1,error:u.message}}case"memory":{let u=o.indexOf("/");if(u<=0)return{ok:!1,error:"memory keys look like memory:<agent>/<fact-id>"};let d=o.slice(0,u),p=o.slice(u+1);if(!Nn(t.root).includes(d))return{ok:!1,error:`no memory for agent "${d}"`};let g=new $e(t.root);return g.held(d).some(f=>f.id===p)?(g.review(d,p,c?"approved":"rejected",l),{ok:!0,message:`${e} ${c?"approved: the agent may use it":"rejected: it stays out of prompts"}`}):{ok:!1,error:`fact "${p}" isn't waiting for review`}}case"wiki":{let u=Le(t),d=c?nn(u,o,{by:l,force:i.force,now:a}):rn(u,o,{by:l,reason:i.note,now:a});return d.ok?{ok:!0,message:c?`${d.proposal.article.path} written to the shared wiki`:`${e} rejected`}:d}case"whatsapp":{let u=await In(t.root,o,c?"yes":"no",{by:l,now:a,send:t.sendWhatsApp});return u.ok?{ok:!0,message:c?`${e}: sent to ${u.draft.chat_name||u.draft.to}`:`${e}: dropped, nothing sent`}:u}case"request":{let u=z(t),d=u?.get(o);return!u||!d||d.state!=="needs_attention"?{ok:!1,error:`nothing waiting for "${e}"`}:c?Cn(Pe(t)).enabled?(u.requestPickup(o,a),{ok:!0,message:`${e}: ${d.agentId} will be asked to pick it up again`}):{ok:!1,error:"Requests are off, so nothing would hand it back. Turn them on (agentx requests settings --enabled on), or answer no to drop it."}:(u.close(o,"dropped",i.note?.trim()||`dropped by ${l}`,a),{ok:!0,message:`${e}: dropped`})}}}var Wn=new Set(["127.0.0.1","::1","::ffff:127.0.0.1"]);function Xl(t){return t==="/api/memory"||t.startsWith("/api/memory/")||t==="/approvals"||t.startsWith("/approvals/")||t==="/requests"||t.startsWith("/requests/")||t==="/watchers"||t.startsWith("/watchers/")||t==="/follow-up"||t.startsWith("/follow-up/")||t==="/events/recent"||/^\/agents\/[^/]+\/events$/.test(t)||t==="/a2a/delegations"||t.startsWith("/a2a/delegations/")||t==="/traces"||t.startsWith("/traces/")||t==="/voice/history"||t.startsWith("/voice/history/")||t==="/voice/transcribe"||t==="/voice/speak"||t==="/app-files"||t==="/calls"||t.startsWith("/calls/")||t==="/webrtc/camera"||t.startsWith("/webrtc/camera/")||t==="/mesh/guests"||t.startsWith("/mesh/guests/")||t==="/wiki/agents"||t==="/wiki/entries"||t==="/wiki/articles"||t==="/wiki/article"||t==="/wiki/notes"||t==="/api/wiki/curate"||t==="/api/wiki/curate/restore"||t==="/api/signals/stopped"||t.startsWith("/api/signals/stopped/")||t==="/api/review-gate/reviews"}function Gl(t){return t==="/reload"||t==="/api/processes/kill"||t==="/send"||t==="/send/agent"||t==="/send/contact"||t==="/mesh/announce"||t==="/voice/settings"||t==="/voice/preview"||/^\/api\/tasks\/[^/]+\/(cancel|followup)$/.test(t)||/^\/mesh\/guests\/[^/]+\/(pause|resume|end|update)$/.test(t)||/^\/crons\/[^/]+\/enabled$/.test(t)||/^\/workflow-runs\/[^/]+\/cancel$/.test(t)||t==="/api/signals/stop"||t==="/api/signals/resume"||t==="/api/signals/drop"||t==="/api/review-gate/replay"}function Kl(t){return Wn.has(t)}function Jl(t){if(t.foreignBrowser)return{allowed:!1,reason:"foreign-browser-origin"};if(t.enforcementDisabled)return{allowed:!0,reason:"disabled"};if(Wn.has(t.remoteAddress))return{allowed:!0,reason:"loopback"};if(t.acceptedTokens.size===0)return{allowed:!0,reason:"no-tokens-configured"};let e=t.authorizationHeader||"",n=e.startsWith("Bearer ")?e.slice(7).trim():"";return n&&t.acceptedTokens.has(n)?{allowed:!0,reason:"token"}:{allowed:!1,reason:"missing-or-invalid-token"}}function Yl(t,e=process.env){let n=new Set;e.MESH_TOKEN&&n.add(e.MESH_TOKEN);for(let i of t.mesh?.peers||[])i.token&&n.add(i.token);return n}function Zl(t,e,n=process.env){let i=s=>s.replace(/\/+$/,"");return(e===i(t.daemonUrl)?t.token:t.daemons.find(s=>i(s.url)===e)?.token)||n.MESH_TOKEN||void 0}function le(t){return(Array.isArray(t)?t[0]:t)?.trim()??""}function os(t){try{return new URL(t).host.toLowerCase()}catch{return null}}function as(t=process.env){return new Set((t.AGENTX_ALLOWED_ORIGINS||"").split(",").map(e=>e.trim().replace(/\/+$/,"").toLowerCase()).filter(Boolean))}function ec(t,e=as()){let n=le(t.origin);if(n){if(e.has(n.replace(/\/+$/,"").toLowerCase()))return"same-origin";let r=os(n),s=[le(t.host),le(t["x-forwarded-host"])].filter(Boolean).map(o=>o.toLowerCase());return r&&s.includes(r)?"same-origin":"foreign"}let i=le(t["sec-fetch-site"]).toLowerCase();return i==="cross-site"||i==="same-site"?"foreign":"none"}function tc(t){let e=(t||"GET").toUpperCase();return e!=="GET"&&e!=="HEAD"}import{existsSync as cr,mkdirSync as Os,readFileSync as Ms,renameSync as Ws,writeFileSync as js}from"fs";import{homedir as Fs}from"os";import{dirname as Us,join as Vs}from"path";import{execFile as bs,execFileSync as ws}from"child_process";import{execFileSync as ls}from"child_process";import{existsSync as Fn,mkdirSync as cs,readdirSync as us,readFileSync as Un,renameSync as ds,writeFileSync as ps}from"fs";import{homedir as Vn}from"os";import{join as Oe}from"path";var v="siri:",qn="com.apple.ttsbundle.gryphon-neural_",Bn=t=>!!t&&t.startsWith(qn),gs=["/usr/bin/say","/usr/bin/defaults","/usr/bin/plutil"],fs=()=>{try{return ls("/usr/bin/defaults",["read","com.apple.Accessibility"],{stdio:"ignore",timeout:5e3}),!0}catch{return!1}},Ne;function Me(t={}){let e=t.platform!==void 0||t.exists!==void 0||t.prefDomain!==void 0;if(!e&&Ne!==void 0)return Ne;let{platform:n=process.platform,exists:i=Fn,prefDomain:r=fs}=t,s=n==="darwin"&&gs.every(o=>i(o))&&r();return e||(Ne=s),s}var Hn=["/System/Library/AssetsV2/com_apple_MobileAsset_Trial_Siri_SiriTextToSpeech/purpose_auto","/System/Library/AssetsV2/com_apple_MobileAsset_UAF_Siri_TextToSpeech/purpose_auto"],zn={aaron:"male",damon:"male",daniel:"male",pierre:"male",samer:"male",arthur:"male",gordon:"male",martin:"male",nora:"female",simone:"female",marie:"female",soha:"female",martha:"female",catherine:"female",helena:"female",nicky:"female"},We=t=>zn[t.toLowerCase()]??null;function ce(t){let e=/^com\.apple\.ttsbundle\.gryphon-neural_([a-z]+)_([a-z]{2}-[A-Z]{2})_premium$/.exec(t);return e?{name:e[1],locale:e[2]}:null}var ms=/com\.apple\.siri\.tts\.voice\.([a-z]{2})_([A-Z]{2})\.([a-z]+)\.neural\.premium/g;function hs(t){let e=new Map;for(let n of t)for(let[,i,r,s]of n.matchAll(ms)){let o=`${i}-${r}`,a=`${qn}${s}_${o}_premium`;e.has(a)||e.set(a,{id:a,name:s[0].toUpperCase()+s.slice(1),locale:o,quality:"premium",gender:zn[s]??null,siri:!0})}return[...e.values()]}function ue(t=Hn,e={}){if(!Me(e))return[];let n=[];for(let i of t){let r;try{r=us(i)}catch{continue}for(let s of r)try{n.push(Un(Oe(i,s,"Info.plist"),"latin1"))}catch{}}return hs(n)}var jn=`#!/bin/sh
|
|
55
|
+
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`);this.db.transaction(()=>{s.run(e,n,r),i.forEach((a,l)=>{let c=l===0,u=c&&a.agentId===n&&a.kind!=="message";o.run(e,l+1,a.name,a.kind,a.agentId,a.doneWhen,c?"active":"pending",a.needsApproval?1:0,a.message??null,a.toChannel??null,a.toChat??null,a.toAccount??null,a.checkUrl??null,a.checkContains??null,a.stallMinutes??null,u?r:null,r)}),this.event(e,null,"created",`${i.length} steps, written by ${n}`,r)})()}get(e){let n=this.db.prepare("SELECT * FROM request_plans WHERE request_id = ?").get(e);return n?De(n):null}steps(e){return this.db.prepare("SELECT * FROM request_plan_steps WHERE request_id = ? ORDER BY idx").all(e).map(En)}step(e,n){let i=this.db.prepare("SELECT * FROM request_plan_steps WHERE request_id = ? AND idx = ?").get(e,n);return i?En(i):null}listActive(){return this.db.prepare("SELECT * FROM request_plans WHERE state = 'active' ORDER BY created_at, rowid").all().map(De)}updateStep(e,n,i){let r=[],s=[];for(let[o,a]of Object.entries(i)){let l=qi[o];!l||a===void 0||(r.push(`${l} = ?`),s.push(typeof a=="boolean"?a?1:0:a))}r.length&&this.db.prepare(`UPDATE request_plan_steps SET ${r.join(", ")} WHERE request_id = ? AND idx = ?`).run(...s,e,n)}finish(e,n,i){return this.db.prepare("UPDATE request_plans SET state = ?, finished_at = ? WHERE request_id = ? AND state = 'active'").run(n,i,e).changes>0}markNotified(e,n){this.db.prepare("UPDATE request_plans SET notified_at = ? WHERE request_id = ?").run(n,e)}awaitingSummary(){return this.db.prepare("SELECT * FROM request_plans WHERE state = 'done' AND notified_at IS NULL ORDER BY finished_at").all().map(De)}event(e,n,i,r,s){this.db.prepare("INSERT INTO request_plan_events (request_id, step, at, kind, detail) VALUES (?, ?, ?, ?, ?)").run(e,n,s,i,r.replace(/\s+/g," ").trim().slice(0,Ui))}events(e,n=200){return this.db.prepare("SELECT request_id, step, at, kind, detail FROM request_plan_events WHERE request_id = ? ORDER BY at, rowid LIMIT ?").all(e,n).map(i=>({requestId:i.request_id,step:i.step??null,at:i.at,kind:i.kind,detail:i.detail}))}},vl=Lt;import{existsSync as Bi,readFileSync as Hi}from"fs";jt();ui();function Cn(t){let e=Ft(t),n={};if(Bi(e))try{n=Mt(JSON.parse(Hi(e,"utf-8")))}catch{n={}}let i=ve.safeParse(n?.requests);return i.success?i.data:ve.parse(void 0)}async function El(t,e={}){let n=(t.channels??[]).filter(i=>!ke.has(i.toLowerCase().split("@")[0]));return n.length?{success:!1,error:`unknown channel ${n.map(i=>`"${i}"`).join(", ")}: use ${[...ke].join(", ")}`}:Ut(i=>{let r=i.requests??={};for(let s of["enabled","channels","from","staleAfterHours","retentionDays"])t[s]!==void 0&&(r[s]=t[s]);if(t.plans){let s=r.plans??={};for(let o of["enabled","stallMinutes","maxNudges","approveKinds","disabledAgents","requireForWork","requireOverMinutes"])t.plans[o]!==void 0&&(s[o]=t.plans[o])}if(t.checkers){let s=r.checkers??={};for(let o of["enabled","checkEveryMinutes"])t.checkers[o]!==void 0&&(s[o]=t.checkers[o])}},{configPath:e.configPath,reload:e.reload})}var Ln=["card","schedule","memory","wiki","whatsapp","request"],Gi=280;function L(t,e=Gi){let n=t.replace(/\s+/g," ").trim();return n.length>e?`${n.slice(0,e-1)}\u2026`:n}function Pe(t){if(t.configPath)return R(t.configPath);let e=[R(t.root,"agentx.json"),R(t.root,".agentx","config.json")];return e.find(n=>H(n))??e[0]}function Le(t){return t.wikiDir?R(t.wikiDir):R(t.root,".agentx","wiki")}function Ki(t){return W(t.root,"pending").map(Ji)}function Ji(t){return{key:`card:${t.id}`,kind:"card",title:t.title,ask:t.ask,yes:`tell ${t.raised_by} yes`,no:`tell ${t.raised_by} no`,recommend:t.recommend,if_silent:t.if_silent,expires:t.expires,...t.source?{source:t.source}:{},raised_by:t.raised_by,...t.node?{node:t.node}:{},created_at:t.created_at,...t.choices?{choices:t.choices,more:`agentx approvals popup card:${t.id}`}:{},...t.draft?{draft:t.draft}:{},...t.context||t.draft?{detail:L([t.context,t.draft?`Suggested message: ${t.draft}`:""].filter(Boolean).join(" \xB7 "))}:{}}}function Yi(t){let e=Pe(t);if(!H(e))return[];let n;try{n=JSON.parse(Xi(e,"utf-8"))}catch{return[]}let i=new Date(t.now??Date.now()),r=[];for(let[s,o]of Object.entries(n?.crons??{})){let a=o?.approval;if(!a||a.action!=="create"&&a.action!=="delete")continue;let l=o.timezone||"UTC",c=o.schedule?zt(o.schedule):"",u=o.schedule?`${c.charAt(0).toLowerCase()}${c.slice(1)} (${o.schedule})`:"no schedule",d=String(o.prompt??o.command??""),p=a.action==="create";r.push({key:`schedule:${s}`,kind:"schedule",title:p?`New schedule "${s}" for ${o.agent??"an agent"}`:`Delete schedule "${s}"`,ask:p?`Let ${o.agent??"the agent"} run this ${u}?`:`Remove the schedule "${s}" (${u})?`,yes:p?"enable it":"remove it",no:p?"drop the request":"keep the schedule",raised_by:String(a.requestedBy??"unknown"),created_at:String(a.requestedAt??""),detail:L(`${d}${p&&o.schedule?` \xB7 first run ${Gt(Xt(o.schedule,l,i),l)}`:""}`),more:"agentx schedule list"})}return r}function Nn(t){let e=R(t,".agentx","memory");return H(e)?zi(e).filter(n=>n.endsWith(".jsonl")).map(n=>n.slice(0,-6)).sort():[]}function Zi(t){let e=Nn(t.root);if(e.length===0)return[];let n=new $e(t.root),i=[];for(let r of e)for(let s of n.held(r))i.push({key:`memory:${r}/${s.id}`,kind:"memory",title:`Fact ${r} learned from ${s.source.channel}`,ask:`Let ${r} use this fact in its prompts?`,yes:"use it",no:"keep it out for good",raised_by:r,created_at:s.createdAt,detail:L(s.content),more:`agentx memory facts held --agent ${r}`});return i}function Qi(t){let e=t.sources.filter(n=>n.failure);return e.length?e.map(n=>`Recurring failure: ${n.agentId}'s ${n.failure.tool} fails with "${n.failure.errorClass}" in ${n.occurrences??1} sessions (${n.failure.runs} runs).`).join(" "):`${t.sources.length} source(s)${t.occurrences>1?`, seen in ${t.occurrences} sessions`:""}.`}function es(t){return tn(Le(t),"pending").map(e=>{let n=e.evidence;return{key:`wiki:${e.id}`,kind:"wiki",title:e.article.title,ask:e.replaces?`Update "${e.article.path}" in the shared wiki?`:`Add "${e.article.path}" to the shared wiki?`,yes:"write the article",no:"decline it",raised_by:n.agents.join(", ")||"wiki promote",created_at:e.createdAt,detail:L(`${Qi(n)} ${e.article.content}`),more:`agentx wiki proposals show ${e.id}`}})}function ts(t){return _n(t.root,"pending").map(e=>({key:`whatsapp:${e.id}`,kind:"whatsapp",title:`WhatsApp reply to ${e.chat_name||e.to}`,ask:`Send this to ${e.chat_name||e.to}? "${e.text}"`,yes:"send it on WhatsApp",no:"drop the draft",raised_by:e.agent,created_at:e.created_at,detail:L(`${e.triage}: ${e.summary}`),more:"agentx whatsapp triage log"}))}function z(t){if(t.requests)return t.requests;if(R(t.root)!==process.cwd()||!H(R(t.root,".agentx","db.sqlite")))return null;let e=Se({quiet:!0});if(!e)return null;let n=Dn.get(e);return!n&&!Nt(e)?null:(n||Dn.set(e,n=new Ot(e)),n)}var Dn=new WeakMap;function Bl(t){if(t.plans)return t.plans;if(t.requests||R(t.root)!==process.cwd()||!H(R(t.root,".agentx","db.sqlite")))return null;let e=Se({quiet:!0});if(!e||!Tn(e))return null;let n=Pn.get(e);return n||Pn.set(e,n=new ae(e)),n}var Pn=new WeakMap;function ns(t){let e=z(t);return e?e.listByState("needs_attention").map(n=>({key:`request:${n.id}`,kind:"request",title:`Request not finished: ${L(n.text,80)}`,ask:`Ask ${n.agentId} to pick it up again?`,yes:`hand it back to ${n.agentId}`,no:"drop the request",raised_by:n.agentId,created_at:new Date(n.createdAt).toISOString(),detail:L(`${n.attentionReason??"It needs attention"}. Asked on ${n.channel}: ${n.text}`),more:`agentx requests show ${n.id}`})):[]}var On={card:Ki,schedule:Yi,memory:Zi,wiki:es,whatsapp:ts,request:ns};function rs(t,e){let n=t.expires?Date.parse(t.expires):1/0,i=e.expires?Date.parse(e.expires):1/0;return n!==i?n-i:(Date.parse(t.created_at)||0)-(Date.parse(e.created_at)||0)}function Hl(t,e={}){let n=t.now??Date.now(),{snoozed:i}=x(t.root),r=[],s=[],o=0;for(let a of e.kinds??Ln){let l;try{l=On[a](t)}catch(c){s.push({kind:a,error:String(c?.message??c).slice(0,200)});continue}for(let c of l){let u=i[c.key];if(u&&Date.parse(u)>n){if(!e.includeSnoozed){o++;continue}c.snoozed_until=u}r.push(c)}}return r.sort(rs),{items:r,snoozed:o,errors:s}}function is(t){let e=t.indexOf(":");if(e<=0)return null;let n=t.slice(0,e),i=t.slice(e+1);return!Ln.includes(n)||!i?null:{kind:n,ref:i}}function ss(t,e,n){switch(e){case"card":return q(t.root,n)?.status==="pending";case"wiki":return en(Le(t),n)?.status==="pending";case"whatsapp":return oe(t.root,n)?.status==="pending";default:return On[e](t).some(i=>i.key===`${e}:${n}`)}}async function Mn(t,e,n,i={}){let r=is(e);if(!r)return{ok:!1,error:`unknown item "${e}": use a key from \`agentx approvals list\``};let{kind:s,ref:o}=r,a=t.now??Date.now(),l=i.by??"operator";if(n==="later"){if(!ss(t,s,o))return{ok:!1,error:`nothing waiting for "${e}"`};let u=i.laterHours&&i.laterHours>0?i.laterHours:24,d=new Date(a+u*36e5);return wn(t.root,e,d,a),{ok:!0,message:`${e} put off until ${d.toISOString()}`}}let c=n==="yes";switch(s){case"card":{let u=un(t.root,o,c?"yes":"no",{by:l,note:i.note,now:a,choice:i.choice,text:i.text});return u.ok?{ok:!0,message:`${e}: ${u.card.raised_by} will be told ${c?"yes":"no"}${u.card.choice?` (${u.card.choice})`:""}`}:u}case"schedule":{let u=await(c?Kt:Jt)(o,{configPath:Pe(t),reload:t.reload});return u.success?{ok:!0,message:u.message}:{ok:!1,error:u.message}}case"memory":{let u=o.indexOf("/");if(u<=0)return{ok:!1,error:"memory keys look like memory:<agent>/<fact-id>"};let d=o.slice(0,u),p=o.slice(u+1);if(!Nn(t.root).includes(d))return{ok:!1,error:`no memory for agent "${d}"`};let g=new $e(t.root);return g.held(d).some(f=>f.id===p)?(g.review(d,p,c?"approved":"rejected",l),{ok:!0,message:`${e} ${c?"approved: the agent may use it":"rejected: it stays out of prompts"}`}):{ok:!1,error:`fact "${p}" isn't waiting for review`}}case"wiki":{let u=Le(t),d=c?nn(u,o,{by:l,force:i.force,now:a}):rn(u,o,{by:l,reason:i.note,now:a});return d.ok?{ok:!0,message:c?`${d.proposal.article.path} written to the shared wiki`:`${e} rejected`}:d}case"whatsapp":{let u=await In(t.root,o,c?"yes":"no",{by:l,now:a,send:t.sendWhatsApp});return u.ok?{ok:!0,message:c?`${e}: sent to ${u.draft.chat_name||u.draft.to}`:`${e}: dropped, nothing sent`}:u}case"request":{let u=z(t),d=u?.get(o);return!u||!d||d.state!=="needs_attention"?{ok:!1,error:`nothing waiting for "${e}"`}:c?Cn(Pe(t)).enabled?(u.requestPickup(o,a),{ok:!0,message:`${e}: ${d.agentId} will be asked to pick it up again`}):{ok:!1,error:"Requests are off, so nothing would hand it back. Turn them on (agentx requests settings --enabled on), or answer no to drop it."}:(u.close(o,"dropped",i.note?.trim()||`dropped by ${l}`,a),{ok:!0,message:`${e}: dropped`})}}}var Wn=new Set(["127.0.0.1","::1","::ffff:127.0.0.1"]);function Xl(t){return t==="/api/memory"||t.startsWith("/api/memory/")||t==="/approvals"||t.startsWith("/approvals/")||t==="/requests"||t.startsWith("/requests/")||t==="/watchers"||t.startsWith("/watchers/")||t==="/follow-up"||t.startsWith("/follow-up/")||t==="/events/recent"||/^\/agents\/[^/]+\/events$/.test(t)||t==="/a2a/delegations"||t.startsWith("/a2a/delegations/")||t==="/traces"||t.startsWith("/traces/")||t==="/voice/history"||t.startsWith("/voice/history/")||t==="/voice/transcribe"||t==="/voice/speak"||t==="/app-files"||t==="/calls"||t.startsWith("/calls/")||t==="/webrtc/camera"||t.startsWith("/webrtc/camera/")||t==="/mesh/guests"||t.startsWith("/mesh/guests/")||t==="/wiki/agents"||t==="/wiki/entries"||t==="/wiki/articles"||t==="/wiki/article"||t==="/wiki/notes"||t==="/api/wiki/curate"||t==="/api/wiki/curate/restore"||t==="/api/signals/stopped"||t.startsWith("/api/signals/stopped/")||t==="/api/review-gate/reviews"}function Gl(t){return t==="/reload"||t==="/api/processes/kill"||t==="/send"||t==="/send/agent"||t==="/send/contact"||t==="/mesh/announce"||t==="/voice/settings"||t==="/voice/preview"||/^\/api\/tasks\/[^/]+\/(cancel|followup)$/.test(t)||/^\/mesh\/guests\/[^/]+\/(pause|resume|end|update)$/.test(t)||/^\/crons\/[^/]+\/enabled$/.test(t)||/^\/workflow-runs\/[^/]+\/cancel$/.test(t)||t==="/api/signals/stop"||t==="/api/signals/resume"||t==="/api/signals/drop"||t==="/api/review-gate/replay"}function Kl(t){return Wn.has(t)}function Jl(t){if(t.foreignBrowser)return{allowed:!1,reason:"foreign-browser-origin"};if(t.enforcementDisabled)return{allowed:!0,reason:"disabled"};if(Wn.has(t.remoteAddress))return{allowed:!0,reason:"loopback"};if(t.acceptedTokens.size===0)return{allowed:!0,reason:"no-tokens-configured"};let e=t.authorizationHeader||"",n=e.startsWith("Bearer ")?e.slice(7).trim():"";return n&&t.acceptedTokens.has(n)?{allowed:!0,reason:"token"}:{allowed:!1,reason:"missing-or-invalid-token"}}function Yl(t,e=process.env){let n=new Set;e.MESH_TOKEN&&n.add(e.MESH_TOKEN);for(let i of t.mesh?.peers||[])i.token&&n.add(i.token);return n}function Zl(t,e,n=process.env){let i=s=>s.replace(/\/+$/,"");return(e===i(t.daemonUrl)?t.token:t.daemons.find(s=>i(s.url)===e)?.token)||n.MESH_TOKEN||void 0}function le(t){return(Array.isArray(t)?t[0]:t)?.trim()??""}function os(t){try{return new URL(t).host.toLowerCase()}catch{return null}}function as(t=process.env){return new Set((t.AGENTX_ALLOWED_ORIGINS||"").split(",").map(e=>e.trim().replace(/\/+$/,"").toLowerCase()).filter(Boolean))}function ec(t,e=as()){let n=le(t.origin);if(n){if(e.has(n.replace(/\/+$/,"").toLowerCase()))return"same-origin";let r=os(n),s=[le(t.host),le(t["x-forwarded-host"])].filter(Boolean).map(o=>o.toLowerCase());return r&&s.includes(r)?"same-origin":"foreign"}let i=le(t["sec-fetch-site"]).toLowerCase();return i==="cross-site"||i==="same-site"?"foreign":"none"}function tc(t){let e=(t||"GET").toUpperCase();return e!=="GET"&&e!=="HEAD"}import{existsSync as cr,mkdirSync as Os,readFileSync as Ms,renameSync as Ws,writeFileSync as js}from"fs";import{homedir as Fs}from"os";import{dirname as Us,join as Vs}from"path";import{execFile as bs,execFileSync as ws}from"child_process";import{execFileSync as ls}from"child_process";import{existsSync as Fn,mkdirSync as cs,readdirSync as us,readFileSync as Un,renameSync as ds,writeFileSync as ps}from"fs";import{homedir as Vn}from"os";import{join as Oe}from"path";var v="siri:",qn="com.apple.ttsbundle.gryphon-neural_",Bn=t=>!!t&&t.startsWith(qn),gs=["/usr/bin/say","/usr/bin/defaults","/usr/bin/plutil"],fs=()=>{try{return ls("/usr/bin/defaults",["read","com.apple.Accessibility"],{stdio:"ignore",timeout:5e3}),!0}catch{return!1}},Ne;function Me(t={}){let e=t.platform!==void 0||t.exists!==void 0||t.prefDomain!==void 0;if(!e&&Ne!==void 0)return Ne;let{platform:n=process.platform,exists:i=Fn,prefDomain:r=fs}=t,s=n==="darwin"&&gs.every(o=>i(o))&&r();return e||(Ne=s),s}var Hn=["/System/Library/AssetsV2/com_apple_MobileAsset_Trial_Siri_SiriTextToSpeech/purpose_auto","/System/Library/AssetsV2/com_apple_MobileAsset_UAF_Siri_TextToSpeech/purpose_auto"],zn={aaron:"male",damon:"male",daniel:"male",pierre:"male",samer:"male",arthur:"male",gordon:"male",martin:"male",nora:"female",simone:"female",marie:"female",soha:"female",martha:"female",catherine:"female",helena:"female",nicky:"female"},We=t=>zn[t.toLowerCase()]??null;function ce(t){let e=/^com\.apple\.ttsbundle\.gryphon-neural_([a-z]+)_([a-z]{2}-[A-Z]{2})_premium$/.exec(t);return e?{name:e[1],locale:e[2]}:null}var ms=/com\.apple\.siri\.tts\.voice\.([a-z]{2})_([A-Z]{2})\.([a-z]+)\.neural\.premium/g;function hs(t){let e=new Map;for(let n of t)for(let[,i,r,s]of n.matchAll(ms)){let o=`${i}-${r}`,a=`${qn}${s}_${o}_premium`;e.has(a)||e.set(a,{id:a,name:s[0].toUpperCase()+s.slice(1),locale:o,quality:"premium",gender:zn[s]??null,siri:!0})}return[...e.values()]}function ue(t=Hn,e={}){if(!Me(e))return[];let n=[];for(let i of t){let r;try{r=us(i)}catch{continue}for(let s of r)try{n.push(Un(Oe(i,s,"Info.plist"),"latin1"))}catch{}}return hs(n)}var jn=`#!/bin/sh
|
|
56
56
|
# Written by agentx; shared by the daemon and AgentX Voice. Do not edit.
|
|
57
57
|
# siri-say.sh [voice] < text speak one line. A Siri voice id switches
|
|
58
58
|
# the OS default for it; any other id is
|
|
@@ -532,4 +532,4 @@ Document the arguments, commands, or files the skill expects. Example:
|
|
|
532
532
|
claude-code ${_t(t)} --arg value
|
|
533
533
|
\`\`\`
|
|
534
534
|
`}jt();var si={maxPixels:12e5,timeoutMs:5e3,intervalMs:100,changeThreshold:.015,stableMs:400,regions:{},buffer:{enabled:!1,seconds:10,fps:2,region:"screen",maxPixels:3e5}};function oi(t){return{...si,...t??{},regions:{...t?.regions??{}},buffer:{...si.buffer,...t?.buffer??{}}}}function Hd(t){try{return oi(Wt(t).screen)}catch{return oi(void 0)}}var Ya=/^[a-z][\w-]*$/,ai=["window","screen","menubar","notifications"];function Z(t,e,n,i){let r=Number(t);if(t===""||t===null||!Number.isFinite(r)||!n(r))throw new Error(`${e} must be ${i}`);return r}var be=(t,e)=>Z(t,e,n=>Number.isInteger(n)&&n>0,"a whole number above 0");function li(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 zd(t,e){let n={...t??{}};if("maxPixels"in e&&(n.maxPixels=be(e.maxPixels,"maxPixels")),"timeoutMs"in e&&(n.timeoutMs=be(e.timeoutMs,"timeoutMs")),"intervalMs"in e&&(n.intervalMs=be(e.intervalMs,"intervalMs")),"stableMs"in e&&(n.stableMs=Z(e.stableMs,"stableMs",r=>Number.isInteger(r)&&r>=0,"a whole number, 0 or more")),"changeThreshold"in e&&(n.changeThreshold=Z(e.changeThreshold,"changeThreshold",r=>r>=0&&r<=1,"between 0 and 1")),e.regions&&typeof e.regions=="object"){let r={...n.regions??{}};for(let[s,o]of Object.entries(e.regions)){if(!Ya.test(s))throw new Error(`region name "${s}" must be lowercase letters, digits, - or _`);o===null?delete r[s]:r[s]=li(o)}n.regions=r}if(e.buffer&&typeof e.buffer=="object"){let r=e.buffer,s={...n.buffer??{}};"enabled"in r&&(s.enabled=!!r.enabled),"seconds"in r&&(s.seconds=Z(r.seconds,"buffer.seconds",o=>o>0&&o<=120,"above 0 and at most 120")),"fps"in r&&(s.fps=Z(r.fps,"buffer.fps",o=>o>0&&o<=10,"above 0 and at most 10")),"maxPixels"in r&&(s.maxPixels=be(r.maxPixels,"buffer.maxPixels")),"region"in r&&(s.region=String(r.region).trim()),n.buffer=s}let i=n.buffer?.region;if(i!==void 0&&!ai.includes(i)&&!n.regions?.[i])try{li(i)}catch{throw new Error(`buffer.region "${i}" is not a region \u2014 use ${[...ai,...Object.keys(n.regions??{})].join(", ")}, or x,y,w,h`)}return n}export{dn as a,el as b,it as c,lo as d,co as e,Fc as f,Uc as g,Vc as h,yr as i,Bc as j,zc as k,D as l,br as m,k as n,il as o,Sr as p,Zc as q,gl as r,ji as s,wl as t,In as u,x as v,cl as w,ul as x,xl as y,ae as z,vl as A,Cn as B,El as C,z as D,Bl as E,Hl as F,Mn as G,nu as H,xr as I,st as J,ru as K,iu as L,Io as M,su as N,ou as O,au as P,vr as Q,uu as R,at as S,mu as T,Mr as U,Bu as V,Hu as W,Yu as X,fa as Y,Zu as Z,Xl as _,Gl as $,Kl as aa,Jl as ba,Yl as ca,Zl as da,ec as ea,tc as fa,uc as ga,Fe as ha,dc as ia,pc as ja,X as ka,G as la,ka as ma,ad as na,ld as oa,cd as pa,ud as qa,mt as ra,dd as sa,qe as ta,Be as ua,ge as va,Is as wa,Ts as xa,yc as ya,ze as za,Xe as Aa,Cs as Ba,Ds as Ca,rr as Da,ar as Ea,bc as Fa,Ns as Ga,wc as Ha,qs as Ia,zs as Ja,Ge as Ka,Gs as La,lr as Ma,P as Na,Gr as Oa,Kr as Pa,Jr as Qa,yd as Ra,Ea as Sa,Zr as Ta,Qr as Ua,Id as Va,Ed as Wa,Ha as Xa,Td as Ya,ti as Za,fe as _a,Cc as $a,fr as ab,Ke as bb,nt as cb,Wc as db,Ld as eb,Nd as fb,Od as gb,Md as hb,Wd as ib,jd as jb,Fd as kb,Ud as lb,Vd as mb,si as nb,oi as ob,Hd as pb,ai as qb,zd as rb};
|
|
535
|
-
//# sourceMappingURL=chunk-
|
|
535
|
+
//# sourceMappingURL=chunk-MO7DH5L6.js.map
|